@comapeo/core-react 8.0.0 → 9.0.1

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.
Files changed (43) hide show
  1. package/README.md +38 -0
  2. package/dist/commonjs/contexts/ClientApi.d.ts +5 -5
  3. package/dist/commonjs/contexts/ClientApi.js +6 -5
  4. package/dist/commonjs/contexts/ComapeoCore.d.ts +8 -0
  5. package/dist/commonjs/contexts/ComapeoCore.js +9 -0
  6. package/dist/commonjs/contexts/MapServer.d.ts +69 -0
  7. package/dist/commonjs/contexts/MapServer.js +92 -0
  8. package/dist/commonjs/contexts/MapShares.d.ts +52 -0
  9. package/dist/commonjs/contexts/MapShares.js +74 -0
  10. package/dist/commonjs/hooks/maps.d.ts +460 -3
  11. package/dist/commonjs/hooks/maps.js +261 -4
  12. package/dist/commonjs/index.d.ts +5 -2
  13. package/dist/commonjs/index.js +20 -3
  14. package/dist/commonjs/lib/http.d.ts +45 -0
  15. package/dist/commonjs/lib/http.js +103 -0
  16. package/dist/commonjs/lib/map-shares-stores.d.ts +80 -0
  17. package/dist/commonjs/lib/map-shares-stores.js +299 -0
  18. package/dist/commonjs/lib/react-query/maps.d.ts +66 -20
  19. package/dist/commonjs/lib/react-query/maps.js +113 -11
  20. package/dist/commonjs/lib/react-query/mutation-result.d.ts +8 -0
  21. package/dist/commonjs/lib/react-query/mutation-result.js +22 -0
  22. package/dist/esm/contexts/ClientApi.d.ts +5 -5
  23. package/dist/esm/contexts/ClientApi.js +6 -5
  24. package/dist/esm/contexts/ComapeoCore.d.ts +8 -0
  25. package/dist/esm/contexts/ComapeoCore.js +6 -0
  26. package/dist/esm/contexts/MapServer.d.ts +69 -0
  27. package/dist/esm/contexts/MapServer.js +86 -0
  28. package/dist/esm/contexts/MapShares.d.ts +52 -0
  29. package/dist/esm/contexts/MapShares.js +65 -0
  30. package/dist/esm/hooks/maps.d.ts +460 -3
  31. package/dist/esm/hooks/maps.js +252 -6
  32. package/dist/esm/index.d.ts +5 -2
  33. package/dist/esm/index.js +4 -2
  34. package/dist/esm/lib/http.d.ts +45 -0
  35. package/dist/esm/lib/http.js +98 -0
  36. package/dist/esm/lib/map-shares-stores.d.ts +80 -0
  37. package/dist/esm/lib/map-shares-stores.js +291 -0
  38. package/dist/esm/lib/react-query/maps.d.ts +66 -20
  39. package/dist/esm/lib/react-query/maps.js +109 -12
  40. package/dist/esm/lib/react-query/mutation-result.d.ts +8 -0
  41. package/dist/esm/lib/react-query/mutation-result.js +19 -0
  42. package/docs/API.md +567 -60
  43. package/package.json +15 -4
package/docs/API.md CHANGED
@@ -6,6 +6,17 @@
6
6
  - [useIsArchiveDevice](#useisarchivedevice)
7
7
  - [useSetOwnDeviceInfo](#usesetowndeviceinfo)
8
8
  - [useSetIsArchiveDevice](#usesetisarchivedevice)
9
+ - [ReceivedMapSharesProvider](#receivedmapsharesprovider)
10
+ - [SentMapSharesProvider](#sentmapsharesprovider)
11
+ - [useReceivedMapSharesActions](#usereceivedmapsharesactions)
12
+ - [useReceivedMapSharesState](#usereceivedmapsharesstate)
13
+ - [useReceivedMapSharesState](#usereceivedmapsharesstate)
14
+ - [useReceivedMapSharesState](#usereceivedmapsharesstate)
15
+ - [useSentMapSharesActions](#usesentmapsharesactions)
16
+ - [useSentMapSharesState](#usesentmapsharesstate)
17
+ - [createMapServerApi](#createmapserverapi)
18
+ - [MapServerProvider](#mapserverprovider)
19
+ - [useMapServerApi](#usemapserverapi)
9
20
  - [useProjectSettings](#useprojectsettings)
10
21
  - [useSingleProject](#usesingleproject)
11
22
  - [useManyProjects](#usemanyprojects)
@@ -19,8 +30,12 @@
19
30
  - [useRemoveServerPeer](#useremoveserverpeer)
20
31
  - [useCreateProject](#usecreateproject)
21
32
  - [useLeaveProject](#useleaveproject)
33
+ - [useImportProjectCategories](#useimportprojectcategories)
22
34
  - [useImportProjectConfig](#useimportprojectconfig)
23
35
  - [useUpdateProjectSettings](#useupdateprojectsettings)
36
+ - [useChangeMemberRole](#usechangememberrole)
37
+ - [useRemoveMember](#useremovemember)
38
+ - [useProjectOwnRoleChangeListener](#useprojectownrolechangelistener)
24
39
  - [useCreateBlob](#usecreateblob)
25
40
  - [useSyncState](#usesyncstate)
26
41
  - [useDataSyncProgress](#usedatasyncprogress)
@@ -37,7 +52,7 @@
37
52
  - [useCreateDocument](#usecreatedocument)
38
53
  - [useUpdateDocument](#useupdatedocument)
39
54
  - [useDeleteDocument](#usedeletedocument)
40
- - [useSetUpInvitesListeners](#usesetupinviteslisteners)
55
+ - [usePresetsSelection](#usepresetsselection)
41
56
  - [useManyInvites](#usemanyinvites)
42
57
  - [useSingleInvite](#usesingleinvite)
43
58
  - [useAcceptInvite](#useacceptinvite)
@@ -45,6 +60,14 @@
45
60
  - [useSendInvite](#usesendinvite)
46
61
  - [useRequestCancelInvite](#userequestcancelinvite)
47
62
  - [useMapStyleUrl](#usemapstyleurl)
63
+ - [useManyReceivedMapShares](#usemanyreceivedmapshares)
64
+ - [useSingleReceivedMapShare](#usesinglereceivedmapshare)
65
+ - [useDownloadReceivedMapShare](#usedownloadreceivedmapshare)
66
+ - [useDeclineReceivedMapShare](#usedeclinereceivedmapshare)
67
+ - [useAbortReceivedMapShareDownload](#useabortreceivedmapsharedownload)
68
+ - [useSendMapShare](#usesendmapshare)
69
+ - [useCancelSentMapShare](#usecancelsentmapshare)
70
+ - [useSingleSentMapShare](#usesinglesentmapshare)
48
71
 
49
72
  ### ClientApiProvider
50
73
 
@@ -52,7 +75,7 @@ Create a context provider that holds a CoMapeo API client instance.
52
75
 
53
76
  | Function | Type |
54
77
  | ---------- | ---------- |
55
- | `ClientApiProvider` | `({ children, clientApi, }: { children: ReactNode; clientApi: MapeoClientApi; }) => Element` |
78
+ | `ClientApiProvider` | `({ children, clientApi, }: PropsWithChildren<{ clientApi: any; }>) => Element` |
56
79
 
57
80
  Parameters:
58
81
 
@@ -67,7 +90,11 @@ set up, it will throw an error.
67
90
 
68
91
  | Function | Type |
69
92
  | ---------- | ---------- |
70
- | `useClientApi` | `() => MapeoClientApi` |
93
+ | `useClientApi` | `() => any` |
94
+
95
+ Returns:
96
+
97
+ Client API instance
71
98
 
72
99
  Examples:
73
100
 
@@ -95,7 +122,7 @@ Retrieve info about the current device.
95
122
 
96
123
  | Function | Type |
97
124
  | ---------- | ---------- |
98
- | `useOwnDeviceInfo` | `() => { data: { deviceId: string; deviceType: "UNRECOGNIZED" or "device_type_unspecified" or "mobile" or "tablet" or "desktop" or "selfHostedServer"; } and Partial<DeviceInfoParam>; error: Error or null; isRefetching: boolean; }` |
125
+ | `useOwnDeviceInfo` | `() => { data: any; error: Error or null; isRefetching: boolean; }` |
99
126
 
100
127
  Examples:
101
128
 
@@ -112,7 +139,7 @@ Retrieve whether the current device is an archive device or not.
112
139
 
113
140
  | Function | Type |
114
141
  | ---------- | ---------- |
115
- | `useIsArchiveDevice` | `() => { data: boolean; error: Error or null; isRefetching: boolean; }` |
142
+ | `useIsArchiveDevice` | `() => { data: any; error: Error or null; isRefetching: boolean; }` |
116
143
 
117
144
  Examples:
118
145
 
@@ -129,7 +156,7 @@ Update the device info for the current device.
129
156
 
130
157
  | Function | Type |
131
158
  | ---------- | ---------- |
132
- | `useSetOwnDeviceInfo` | `() => { error: Error; mutate: UseMutateFunction<void, Error, { name: string; deviceType: "UNRECOGNIZED" or "device_type_unspecified" or "mobile" or "tablet" or "desktop" or "selfHostedServer"; }, unknown>; mutateAsync: UseMutateAsyncFunction<...>; reset: () => void; status: "error"; } or { ...; }` |
159
+ | `useSetOwnDeviceInfo` | `() => { error: Error; mutate: UseMutateFunction<any, Error, { name: string; deviceType: "device_type_unspecified" or "mobile" or "tablet" or "desktop" or "selfHostedServer" or "UNRECOGNIZED"; }, unknown>; mutateAsync: UseMutateAsyncFunction<...>; reset: () => void; status: "error"; } or { ...; }` |
133
160
 
134
161
  ### useSetIsArchiveDevice
135
162
 
@@ -137,7 +164,120 @@ Set or unset the current device as an archive device.
137
164
 
138
165
  | Function | Type |
139
166
  | ---------- | ---------- |
140
- | `useSetIsArchiveDevice` | `() => { error: Error; mutate: UseMutateFunction<void, Error, { isArchiveDevice: boolean; }, unknown>; mutateAsync: UseMutateAsyncFunction<void, Error, { isArchiveDevice: boolean; }, unknown>; reset: () => void; status: "error"; } or { ...; }` |
167
+ | `useSetIsArchiveDevice` | `() => { error: Error; mutate: UseMutateFunction<any, Error, { isArchiveDevice: boolean; }, unknown>; mutateAsync: UseMutateAsyncFunction<any, Error, { isArchiveDevice: boolean; }, unknown>; reset: () => void; status: "error"; } or { ...; }` |
168
+
169
+ ### ReceivedMapSharesProvider
170
+
171
+ | Function | Type |
172
+ | ---------- | ---------- |
173
+ | `ReceivedMapSharesProvider` | `({ children, clientApi, mapServerApi, }: MapSharesProviderProps) => Element` |
174
+
175
+ ### SentMapSharesProvider
176
+
177
+ | Function | Type |
178
+ | ---------- | ---------- |
179
+ | `SentMapSharesProvider` | `({ children, clientApi, mapServerApi, }: MapSharesProviderProps) => Element` |
180
+
181
+ ### useReceivedMapSharesActions
182
+
183
+ | Function | Type |
184
+ | ---------- | ---------- |
185
+ | `useReceivedMapSharesActions` | `() => { download({ shareId }: DownloadMapShareOptions): Promise<void>; decline({ shareId, reason }: DeclineMapShareOptions): Promise<void>; abort({ shareId }: AbortMapShareOptions): Promise<...>; }` |
186
+
187
+ ### useReceivedMapSharesState
188
+
189
+ | Function | Type |
190
+ | ---------- | ---------- |
191
+ | `useReceivedMapSharesState` | `{ (): any[]; <T>(selector: (state: any[]) => T): T; }` |
192
+
193
+ ### useReceivedMapSharesState
194
+
195
+ | Function | Type |
196
+ | ---------- | ---------- |
197
+ | `useReceivedMapSharesState` | `{ (): any[]; <T>(selector: (state: any[]) => T): T; }` |
198
+
199
+ ### useReceivedMapSharesState
200
+
201
+ | Function | Type |
202
+ | ---------- | ---------- |
203
+ | `useReceivedMapSharesState` | `{ (): any[]; <T>(selector: (state: any[]) => T): T; }` |
204
+
205
+ ### useSentMapSharesActions
206
+
207
+ | Function | Type |
208
+ | ---------- | ---------- |
209
+ | `useSentMapSharesActions` | `() => { createAndSend({ projectId, receiverDeviceId, mapId, }: CreateAndSendMapShareOptions): Promise<ServerMapShareState>; cancel({ shareId }: CancelMapShareOptions): Promise<...>; }` |
210
+
211
+ ### useSentMapSharesState
212
+
213
+ | Function | Type |
214
+ | ---------- | ---------- |
215
+ | `useSentMapSharesState` | `<T>(selector?: ((state: ServerMapShareState[]) => T) or undefined) => T` |
216
+
217
+ ### createMapServerApi
218
+
219
+ Utility function to create a MapServerApi instance.
220
+ Only exported for unit testing purposes.
221
+
222
+ | Function | Type |
223
+ | ---------- | ---------- |
224
+ | `createMapServerApi` | `({ getBaseUrl, fetch, }: MapServerApiOptions) => MapServerApi` |
225
+
226
+ Parameters:
227
+
228
+ * `opts.getBaseUrl`: A function that returns a promise that resolves to the base URL of the map server.
229
+ * `opts.fetch`: An optional custom fetch function to use for making requests to the map server. If not provided, the global `fetch` will be used.
230
+
231
+
232
+ ### MapServerProvider
233
+
234
+ Create a context provider that holds a `MapServerFetch` function, which waits
235
+ for the map server to be ready before making requests.
236
+
237
+ | Function | Type |
238
+ | ---------- | ---------- |
239
+ | `MapServerProvider` | `({ children, getBaseUrl, fetch, }: MapServerProviderProps) => Element` |
240
+
241
+ Parameters:
242
+
243
+ * `opts.children`: React children node
244
+ * `opts.getBaseUrl`: A function that returns a promise that resolves to the base URL of the map server.
245
+ * `opts.fetch`: An optional custom fetch function to use for making requests to the map server. If not provided, the global `fetch` will be used.
246
+
247
+
248
+ Examples:
249
+
250
+ ```tsx
251
+ import { createServer } from '@comapeo/map-server'
252
+
253
+ const server = createServer()
254
+ const listenPromise = server.listen()
255
+
256
+ const getBaseUrl = async () => {
257
+ const { localPort } = await listenPromise
258
+ return new URL(`http://localhost:${localPort}/`)
259
+ }
260
+
261
+ const mapServerApi = createMapServerApi({ getBaseUrl })
262
+
263
+ function App() {
264
+ return (
265
+ <MapServerProvider mapServerApi={mapServerApi}>
266
+ <MyApp />
267
+ </MapServerProvider>
268
+ )
269
+ }
270
+ ```
271
+
272
+
273
+ ### useMapServerApi
274
+
275
+ Internal hook to get the MapServerApi (instance of ky) from context.
276
+ Throws if used outside of MapServerProvider.
277
+
278
+ | Function | Type |
279
+ | ---------- | ---------- |
280
+ | `useMapServerApi` | `() => MapServerApi` |
141
281
 
142
282
  ### useProjectSettings
143
283
 
@@ -145,7 +285,7 @@ Retrieve the project settings for a project.
145
285
 
146
286
  | Function | Type |
147
287
  | ---------- | ---------- |
148
- | `useProjectSettings` | `({ projectId }: { projectId: string; }) => { data: EditableProjectSettings; error: Error or null; isRefetching: boolean; }` |
288
+ | `useProjectSettings` | `({ projectId }: { projectId: string; }) => { data: any; error: Error or null; isRefetching: boolean; }` |
149
289
 
150
290
  Parameters:
151
291
 
@@ -171,7 +311,7 @@ This is mostly used internally by the other hooks and should only be used if cer
171
311
 
172
312
  | Function | Type |
173
313
  | ---------- | ---------- |
174
- | `useSingleProject` | `({ projectId }: { projectId: string; }) => { data: ClientApi<MapeoProject>; error: Error or null; isRefetching: boolean; }` |
314
+ | `useSingleProject` | `({ projectId }: { projectId: string; }) => { data: any; error: Error or null; isRefetching: boolean; }` |
175
315
 
176
316
  Parameters:
177
317
 
@@ -193,7 +333,7 @@ Retrieve project information for each project that exists.
193
333
 
194
334
  | Function | Type |
195
335
  | ---------- | ---------- |
196
- | `useManyProjects` | `() => { data: (Pick<{ schemaName: "projectSettings"; name?: string or undefined; defaultPresets?: { point: string[]; area: string[]; vertex: string[]; line: string[]; relation: string[]; } or undefined; configMetadata?: { ...; } or undefined; }, "name"> and { ...; })[]; error: Error or null; isRefetching: boolean; }` |
336
+ | `useManyProjects` | `() => { data: any; error: Error or null; isRefetching: boolean; }` |
197
337
 
198
338
  Examples:
199
339
 
@@ -212,7 +352,7 @@ Retrieve a single member of a project.
212
352
 
213
353
  | Function | Type |
214
354
  | ---------- | ---------- |
215
- | `useSingleMember` | `({ projectId, deviceId, }: { projectId: string; deviceId: string; }) => { data: MemberInfo; error: Error or null; isRefetching: boolean; }` |
355
+ | `useSingleMember` | `({ projectId, deviceId, }: { projectId: string; deviceId: string; }) => { data: any; error: Error or null; isRefetching: boolean; }` |
216
356
 
217
357
  Parameters:
218
358
 
@@ -237,7 +377,7 @@ Retrieve all members of a project.
237
377
 
238
378
  | Function | Type |
239
379
  | ---------- | ---------- |
240
- | `useManyMembers` | `({ projectId }: { projectId: string; }) => { data: MemberInfo[]; error: Error or null; isRefetching: boolean; }` |
380
+ | `useManyMembers` | `({ projectId }: { projectId: string; }) => { data: any; error: Error or null; isRefetching: boolean; }` |
241
381
 
242
382
  Parameters:
243
383
 
@@ -367,7 +507,7 @@ Retrieve the device ID that created a document.
367
507
 
368
508
  | Function | Type |
369
509
  | ---------- | ---------- |
370
- | `useDocumentCreatedBy` | `({ projectId, originalVersionId, }: { projectId: string; originalVersionId: string; }) => { data: string; error: Error or null; isRefetching: boolean; }` |
510
+ | `useDocumentCreatedBy` | `({ projectId, originalVersionId, }: { projectId: string; originalVersionId: string; }) => { data: any; error: Error or null; isRefetching: boolean; }` |
371
511
 
372
512
  Parameters:
373
513
 
@@ -394,7 +534,7 @@ This is a more convenient alternative to using the `useOwnDeviceInfo` and `useMa
394
534
 
395
535
  | Function | Type |
396
536
  | ---------- | ---------- |
397
- | `useOwnRoleInProject` | `({ projectId }: { projectId: string; }) => { data: Role<"a12a6702b93bd7ff" or "f7c150f5a3a9a855" or "012fd2d431c0bf60" or "9e6d29263cba36c9" or "8ced989b1904606b" or "a24eaca65ab5d5d0" or "08e4251e36f6e7ed">; error: Error or null; isRefetching: boolean; }` |
537
+ | `useOwnRoleInProject` | `({ projectId }: { projectId: string; }) => { data: any; error: Error or null; isRefetching: boolean; }` |
398
538
 
399
539
  Parameters:
400
540
 
@@ -416,13 +556,13 @@ function BasicExample() {
416
556
 
417
557
  | Function | Type |
418
558
  | ---------- | ---------- |
419
- | `useAddServerPeer` | `({ projectId }: { projectId: string; }) => { error: Error; mutate: UseMutateFunction<void, Error, { baseUrl: string; dangerouslyAllowInsecureConnections?: boolean or undefined; }, unknown>; mutateAsync: UseMutateAsyncFunction<...>; reset: () => void; status: "error"; } or { ...; }` |
559
+ | `useAddServerPeer` | `({ projectId }: { projectId: string; }) => { error: Error; mutate: UseMutateFunction<any, Error, { baseUrl: string; dangerouslyAllowInsecureConnections?: boolean or undefined; }, unknown>; mutateAsync: UseMutateAsyncFunction<...>; reset: () => void; status: "error"; } or { ...; }` |
420
560
 
421
561
  ### useRemoveServerPeer
422
562
 
423
563
  | Function | Type |
424
564
  | ---------- | ---------- |
425
- | `useRemoveServerPeer` | `({ projectId }: { projectId: string; }) => { error: Error; mutate: UseMutateFunction<void, Error, { serverDeviceId: string; dangerouslyAllowInsecureConnections?: boolean or undefined; }, unknown>; mutateAsync: UseMutateAsyncFunction<...>; reset: () => void; status: "error"; } or { ...; }` |
565
+ | `useRemoveServerPeer` | `({ projectId }: { projectId: string; }) => { error: Error; mutate: UseMutateFunction<any, Error, { serverDeviceId: string; dangerouslyAllowInsecureConnections?: boolean or undefined; }, unknown>; mutateAsync: UseMutateAsyncFunction<...>; reset: () => void; status: "error"; } or { ...; }` |
426
566
 
427
567
  ### useCreateProject
428
568
 
@@ -430,7 +570,7 @@ Create a new project.
430
570
 
431
571
  | Function | Type |
432
572
  | ---------- | ---------- |
433
- | `useCreateProject` | `() => { error: Error; mutate: UseMutateFunction<string, Error, { name?: string or undefined; configPath?: string or undefined; } or undefined, unknown>; mutateAsync: UseMutateAsyncFunction<...>; reset: () => void; status: "error"; } or { ...; }` |
573
+ | `useCreateProject` | `() => { error: Error; mutate: UseMutateFunction<any, Error, { name?: string or undefined; configPath?: string or undefined; } or undefined, unknown>; mutateAsync: UseMutateAsyncFunction<...>; reset: () => void; status: "error"; } or { ...; }` |
434
574
 
435
575
  ### useLeaveProject
436
576
 
@@ -438,7 +578,20 @@ Leave an existing project.
438
578
 
439
579
  | Function | Type |
440
580
  | ---------- | ---------- |
441
- | `useLeaveProject` | `() => { error: Error; mutate: UseMutateFunction<void, Error, { projectId: string; }, unknown>; mutateAsync: UseMutateAsyncFunction<void, Error, { projectId: string; }, unknown>; reset: () => void; status: "error"; } or { ...; }` |
581
+ | `useLeaveProject` | `() => { error: Error; mutate: UseMutateFunction<any, Error, { projectId: string; }, unknown>; mutateAsync: UseMutateAsyncFunction<any, Error, { projectId: string; }, unknown>; reset: () => void; status: "error"; } or { ...; }` |
582
+
583
+ ### useImportProjectCategories
584
+
585
+ Update the categories of a project using an external file.
586
+
587
+ | Function | Type |
588
+ | ---------- | ---------- |
589
+ | `useImportProjectCategories` | `({ projectId, }: { projectId: string; }) => { error: Error; mutate: UseMutateFunction<unknown, Error, { filePath: string; }, unknown>; mutateAsync: UseMutateAsyncFunction<unknown, Error, { filePath: string; }, unknown>; reset: () => void; status: "error"; } or { ...; }` |
590
+
591
+ Parameters:
592
+
593
+ * `opts.projectId`: Public ID of the project to apply changes to.
594
+
442
595
 
443
596
  ### useImportProjectConfig
444
597
 
@@ -446,7 +599,7 @@ Update the configuration of a project using an external file.
446
599
 
447
600
  | Function | Type |
448
601
  | ---------- | ---------- |
449
- | `useImportProjectConfig` | `({ projectId }: { projectId: string; }) => { error: Error; mutate: UseMutateFunction<Error[], Error, { configPath: string; }, unknown>; mutateAsync: UseMutateAsyncFunction<Error[], Error, { ...; }, unknown>; reset: () => void; status: "error"; } or { ...; }` |
602
+ | `useImportProjectConfig` | `({ projectId }: { projectId: string; }) => { error: Error; mutate: UseMutateFunction<unknown, Error, { configPath: string; }, unknown>; mutateAsync: UseMutateAsyncFunction<unknown, Error, { configPath: string; }, unknown>; reset: () => void; status: "error"; } or { ...; }` |
450
603
 
451
604
  Parameters:
452
605
 
@@ -459,20 +612,108 @@ Update the settings of a project.
459
612
 
460
613
  | Function | Type |
461
614
  | ---------- | ---------- |
462
- | `useUpdateProjectSettings` | `({ projectId }: { projectId: string; }) => { error: Error; mutate: UseMutateFunction<EditableProjectSettings, Error, { name?: string or undefined; configMetadata?: { ...; } or undefined; defaultPresets?: { ...; } or undefined; projectColor?: string or undefined; projectDescription?: string or undefined; }, unknown>; muta...` |
615
+ | `useUpdateProjectSettings` | `({ projectId }: { projectId: string; }) => { error: Error; mutate: UseMutateFunction<any, Error, Partial<EditableProjectSettings>, unknown>; mutateAsync: UseMutateAsyncFunction<...>; reset: () => void; status: "error"; } or { ...; }` |
463
616
 
464
617
  Parameters:
465
618
 
466
619
  * `opts.projectId`: Public ID of the project to apply changes to.
467
620
 
468
621
 
622
+ ### useChangeMemberRole
623
+
624
+ Change a project member's role.
625
+
626
+ | Function | Type |
627
+ | ---------- | ---------- |
628
+ | `useChangeMemberRole` | `({ projectId }: { projectId: string; }) => { error: Error; mutate: UseMutateFunction<any, Error, { deviceId: string; roleId: "f7c150f5a3a9a855" or "012fd2d431c0bf60" or "9e6d29263cba36c9"; }, unknown>; mutateAsync: UseMutateAsyncFunction<...>; reset: () => void; status: "error"; } or { ...; }` |
629
+
630
+ Parameters:
631
+
632
+ * `opts.projectId`: Project public ID
633
+
634
+
635
+ Examples:
636
+
637
+ ```tsx
638
+ function BasicExample() {
639
+ const { mutate } = useChangeMemberRole({ projectId: '...' })
640
+ // Use one of: COORDINATOR_ROLE_ID, MEMBER_ROLE_ID, BLOCKED_ROLE_ID
641
+ mutate({ deviceId: '...', roleId: COORDINATOR_ROLE_ID })
642
+ }
643
+ ```
644
+
645
+
646
+ ### useRemoveMember
647
+
648
+ Remove a member from a project, providing an optional reason for removal.
649
+
650
+ Do NOT use this for removing your own device from a project. Use `useLeaveProject` instead.
651
+
652
+ | Function | Type |
653
+ | ---------- | ---------- |
654
+ | `useRemoveMember` | `({ projectId }: { projectId: string; }) => { error: Error; mutate: UseMutateFunction<any, Error, { deviceId: string; reason?: string or undefined; }, unknown>; mutateAsync: UseMutateAsyncFunction<...>; reset: () => void; status: "error"; } or { ...; }` |
655
+
656
+ Parameters:
657
+
658
+ * `opts.projectId`: Project public ID
659
+
660
+
661
+ Examples:
662
+
663
+ ```tsx
664
+ function BasicExample() {
665
+ const { mutate } = useRemoveMember({ projectId: '...' })
666
+ mutate({
667
+ deviceId: '...',
668
+ // Optional
669
+ reason: '...',
670
+ })
671
+ }
672
+ ```
673
+
674
+
675
+ ### useProjectOwnRoleChangeListener
676
+
677
+ Set up listener for changes to your own role in a project.
678
+ It is necessary to use this if you want the project role-related read hooks to update
679
+ based on role change events that are received in the background.
680
+
681
+ | Function | Type |
682
+ | ---------- | ---------- |
683
+ | `useProjectOwnRoleChangeListener` | `({ projectId, listener, }: { projectId: string; listener?: ((event: RoleChangeEvent) => void) or undefined; }) => void` |
684
+
685
+ Parameters:
686
+
687
+ * `opts.listener`: Optional listener to invoke when role changes
688
+
689
+
690
+ Examples:
691
+
692
+ ```tsx
693
+ function SomeComponent({ projectId }: { projectId: string }) {
694
+ useProjectOwnRoleChangeListener({ projectId })
695
+ }
696
+ ```
697
+ ```tsx
698
+ function ComponentWithListener({ projectId }: { projectId: string }) {
699
+ useProjectOwnRoleChangeListener({
700
+ projectId,
701
+ listener: (event) => {
702
+ // Handle role change, e.g., navigate to default project
703
+ console.log('New role:', event.role)
704
+ }
705
+ })
706
+ }
707
+ ```
708
+
709
+
469
710
  ### useCreateBlob
470
711
 
471
712
  Create a blob for a project.
472
713
 
473
714
  | Function | Type |
474
715
  | ---------- | ---------- |
475
- | `useCreateBlob` | `({ projectId }: { projectId: string; }) => { error: Error; mutate: UseMutateFunction<{ driveId: string; name: string; type: "photo" or "audio" or "video"; hash: string; }, Error, { original: string; preview?: string or undefined; thumbnail?: string or undefined; metadata: Metadata; }, unknown>; mutateAsync: UseMutateAsy...` |
716
+ | `useCreateBlob` | `({ projectId }: { projectId: string; }) => { error: Error; mutate: UseMutateFunction<any, Error, { original: string; preview?: string or undefined; thumbnail?: string or undefined; metadata: Metadata; }, unknown>; mutateAsync: UseMutateAsyncFunction<...>; reset: () => void; status: "error"; } or { ...; }` |
476
717
 
477
718
  Parameters:
478
719
 
@@ -489,7 +730,7 @@ additional listeners across the IPC channel.
489
730
 
490
731
  | Function | Type |
491
732
  | ---------- | ---------- |
492
- | `useSyncState` | `({ projectId, }: { projectId: string; }) => State or null` |
733
+ | `useSyncState` | `({ projectId, }: { projectId: string; }) => any` |
493
734
 
494
735
  Parameters:
495
736
 
@@ -519,35 +760,39 @@ Provides the progress of data sync for sync-enabled connected peers
519
760
  | ---------- | ---------- |
520
761
  | `useDataSyncProgress` | `({ projectId, }: { projectId: string; }) => number or null` |
521
762
 
763
+ Returns:
764
+
765
+ `null` if no sync state events have been received. Otherwise returns a value between 0 and 1 (inclusive)
766
+
522
767
  ### useStartSync
523
768
 
524
769
  | Function | Type |
525
770
  | ---------- | ---------- |
526
- | `useStartSync` | `({ projectId }: { projectId: string; }) => { error: Error; mutate: UseMutateFunction<void, Error, { autostopDataSyncAfter: number or null; } or undefined, unknown>; mutateAsync: UseMutateAsyncFunction<...>; reset: () => void; status: "error"; } or { ...; }` |
771
+ | `useStartSync` | `({ projectId }: { projectId: string; }) => { error: Error; mutate: UseMutateFunction<any, Error, { autostopDataSyncAfter: number or null; } or undefined, unknown>; mutateAsync: UseMutateAsyncFunction<...>; reset: () => void; status: "error"; } or { ...; }` |
527
772
 
528
773
  ### useStopSync
529
774
 
530
775
  | Function | Type |
531
776
  | ---------- | ---------- |
532
- | `useStopSync` | `({ projectId }: { projectId: string; }) => { error: Error; mutate: UseMutateFunction<void, Error, void, unknown>; mutateAsync: UseMutateAsyncFunction<void, Error, void, unknown>; reset: () => void; status: "error"; } or { ...; }` |
777
+ | `useStopSync` | `({ projectId }: { projectId: string; }) => { error: Error; mutate: UseMutateFunction<any, Error, void, unknown>; mutateAsync: UseMutateAsyncFunction<any, Error, void, unknown>; reset: () => void; status: "error"; } or { ...; }` |
533
778
 
534
779
  ### useConnectSyncServers
535
780
 
536
781
  | Function | Type |
537
782
  | ---------- | ---------- |
538
- | `useConnectSyncServers` | `({ projectId }: { projectId: string; }) => { error: Error; mutate: UseMutateFunction<void, Error, void, unknown>; mutateAsync: UseMutateAsyncFunction<void, Error, void, unknown>; reset: () => void; status: "error"; } or { ...; }` |
783
+ | `useConnectSyncServers` | `({ projectId }: { projectId: string; }) => { error: Error; mutate: UseMutateFunction<any, Error, void, unknown>; mutateAsync: UseMutateAsyncFunction<any, Error, void, unknown>; reset: () => void; status: "error"; } or { ...; }` |
539
784
 
540
785
  ### useDisconnectSyncServers
541
786
 
542
787
  | Function | Type |
543
788
  | ---------- | ---------- |
544
- | `useDisconnectSyncServers` | `({ projectId }: { projectId: string; }) => { error: Error; mutate: UseMutateFunction<void, Error, void, unknown>; mutateAsync: UseMutateAsyncFunction<void, Error, void, unknown>; reset: () => void; status: "error"; } or { ...; }` |
789
+ | `useDisconnectSyncServers` | `({ projectId }: { projectId: string; }) => { error: Error; mutate: UseMutateFunction<any, Error, void, unknown>; mutateAsync: UseMutateAsyncFunction<any, Error, void, unknown>; reset: () => void; status: "error"; } or { ...; }` |
545
790
 
546
791
  ### useSetAutostopDataSyncTimeout
547
792
 
548
793
  | Function | Type |
549
794
  | ---------- | ---------- |
550
- | `useSetAutostopDataSyncTimeout` | `({ projectId, }: { projectId: string; }) => { error: Error; mutate: UseMutateFunction<void, Error, { after: number or null; }, unknown>; mutateAsync: UseMutateAsyncFunction<void, Error, { ...; }, unknown>; reset: () => void; status: "error"; } or { ...; }` |
795
+ | `useSetAutostopDataSyncTimeout` | `({ projectId, }: { projectId: string; }) => { error: Error; mutate: UseMutateFunction<any, Error, { after: number or null; }, unknown>; mutateAsync: UseMutateAsyncFunction<any, Error, { ...; }, unknown>; reset: () => void; status: "error"; } or { ...; }` |
551
796
 
552
797
  ### useExportGeoJSON
553
798
 
@@ -555,7 +800,7 @@ Creates a GeoJson file with all the observations and/or tracks in the project.
555
800
 
556
801
  | Function | Type |
557
802
  | ---------- | ---------- |
558
- | `useExportGeoJSON` | `({ projectId }: { projectId: string; }) => { error: Error; mutate: UseMutateFunction<string, Error, { path: string; exportOptions: { observations?: boolean or undefined; tracks?: boolean or undefined; lang?: string or undefined; }; }, unknown>; mutateAsync: UseMutateAsyncFunction<...>; reset: () => void; status: "error...` |
803
+ | `useExportGeoJSON` | `({ projectId }: { projectId: string; }) => { error: Error; mutate: UseMutateFunction<any, Error, { path: string; exportOptions: { observations?: boolean or undefined; tracks?: boolean or undefined; lang?: string or undefined; }; }, unknown>; mutateAsync: UseMutateAsyncFunction<...>; reset: () => void; status: "error"; ...` |
559
804
 
560
805
  Parameters:
561
806
 
@@ -568,7 +813,7 @@ Creates a zip file containing a GeoJson file with all the observations and/or tr
568
813
 
569
814
  | Function | Type |
570
815
  | ---------- | ---------- |
571
- | `useExportZipFile` | `({ projectId }: { projectId: string; }) => { error: Error; mutate: UseMutateFunction<string, Error, { path: string; exportOptions: { observations?: boolean or undefined; tracks?: boolean or undefined; lang?: string or undefined; attachments?: boolean or undefined; }; }, unknown>; mutateAsync: UseMutateAsyncFunction<...>...` |
816
+ | `useExportZipFile` | `({ projectId }: { projectId: string; }) => { error: Error; mutate: UseMutateFunction<any, Error, { path: string; exportOptions: { observations?: boolean or undefined; tracks?: boolean or undefined; lang?: string or undefined; attachments?: boolean or undefined; }; }, unknown>; mutateAsync: UseMutateAsyncFunction<...>; r...` |
572
817
 
573
818
  Parameters:
574
819
 
@@ -583,7 +828,7 @@ Triggers the closest error boundary if the document cannot be found
583
828
 
584
829
  | Function | Type |
585
830
  | ---------- | ---------- |
586
- | `useSingleDocByDocId` | `<D extends WriteableDocumentType>({ projectId, docType, docId, lang, }: { projectId: string; docType: D; docId: string; lang?: string or undefined; }) => ReadHookResult<Extract<{ schemaName: "deviceInfo"; name: string; deviceType: "UNRECOGNIZED" or ... 4 more ... or "selfHostedServer"; ... 7 more ...; deleted: boolean;...` |
831
+ | `useSingleDocByDocId` | `<D extends WriteableDocumentType>({ projectId, docType, docId, lang, }: { projectId: string; docType: D; docId: string; lang?: string or undefined; }) => { data: any; error: Error or null; isRefetching: boolean; }` |
587
832
 
588
833
  Parameters:
589
834
 
@@ -616,7 +861,7 @@ Triggers the closest error boundary if the document cannot be found.
616
861
 
617
862
  | Function | Type |
618
863
  | ---------- | ---------- |
619
- | `useSingleDocByVersionId` | `<D extends WriteableDocumentType>({ projectId, docType, versionId, lang, }: { projectId: string; docType: D; versionId: string; lang?: string or undefined; }) => ReadHookResult<Extract<{ schemaName: "deviceInfo"; name: string; deviceType: "UNRECOGNIZED" or ... 4 more ... or "selfHostedServer"; ... 7 more ...; deleted: ...` |
864
+ | `useSingleDocByVersionId` | `<D extends WriteableDocumentType>({ projectId, docType, versionId, lang, }: { projectId: string; docType: D; versionId: string; lang?: string or undefined; }) => { data: any; error: Error or null; isRefetching: boolean; }` |
620
865
 
621
866
  Parameters:
622
867
 
@@ -649,7 +894,7 @@ Retrieve all documents of a specific `docType`.
649
894
 
650
895
  | Function | Type |
651
896
  | ---------- | ---------- |
652
- | `useManyDocs` | `<D extends WriteableDocumentType>({ projectId, docType, includeDeleted, lang, }: { projectId: string; docType: D; includeDeleted?: boolean or undefined; lang?: string or undefined; }) => ReadHookResult<(Extract<{ schemaName: "deviceInfo"; name: string; deviceType: "UNRECOGNIZED" or ... 4 more ... or "selfHostedServer"; ...` |
897
+ | `useManyDocs` | `<D extends WriteableDocumentType>({ projectId, docType, includeDeleted, lang, }: { projectId: string; docType: D; includeDeleted?: boolean or undefined; lang?: string or undefined; }) => { data: any; error: Error or null; isRefetching: boolean; }` |
653
898
 
654
899
  Parameters:
655
900
 
@@ -693,7 +938,7 @@ Create a document for a project.
693
938
 
694
939
  | Function | Type |
695
940
  | ---------- | ---------- |
696
- | `useCreateDocument` | `<D extends WriteableDocumentType>({ docType, projectId, }: { docType: D; projectId: string; }) => { error: Error; mutate: UseMutateFunction<WriteableDocument<D> and { forks: string[]; }, Error, { ...; }, unknown>; mutateAsync: UseMutateAsyncFunction<...>; reset: () => void; status: "error"; } or { ...; }` |
941
+ | `useCreateDocument` | `<D extends WriteableDocumentType>({ docType, projectId, }: { docType: D; projectId: string; }) => { error: Error; mutate: UseMutateFunction<WriteableDocument<D> and DerivedDocFields, Error, { ...; }, unknown>; mutateAsync: UseMutateAsyncFunction<...>; reset: () => void; status: "error"; } or { ...; }` |
697
942
 
698
943
  Parameters:
699
944
 
@@ -707,7 +952,7 @@ Update a document within a project.
707
952
 
708
953
  | Function | Type |
709
954
  | ---------- | ---------- |
710
- | `useUpdateDocument` | `<D extends WriteableDocumentType>({ docType, projectId, }: { docType: D; projectId: string; }) => { error: Error; mutate: UseMutateFunction<WriteableDocument<D> and { forks: string[]; }, Error, { ...; }, unknown>; mutateAsync: UseMutateAsyncFunction<...>; reset: () => void; status: "error"; } or { ...; }` |
955
+ | `useUpdateDocument` | `<D extends WriteableDocumentType>({ docType, projectId, }: { docType: D; projectId: string; }) => { error: Error; mutate: UseMutateFunction<WriteableDocument<D> and DerivedDocFields, Error, { ...; }, unknown>; mutateAsync: UseMutateAsyncFunction<...>; reset: () => void; status: "error"; } or { ...; }` |
711
956
 
712
957
  Parameters:
713
958
 
@@ -721,7 +966,7 @@ Delete a document within a project.
721
966
 
722
967
  | Function | Type |
723
968
  | ---------- | ---------- |
724
- | `useDeleteDocument` | `<D extends WriteableDocumentType>({ docType, projectId, }: { docType: D; projectId: string; }) => { error: Error; mutate: UseMutateFunction<WriteableDocument<D> and { forks: string[]; }, Error, { ...; }, unknown>; mutateAsync: UseMutateAsyncFunction<...>; reset: () => void; status: "error"; } or { ...; }` |
969
+ | `useDeleteDocument` | `<D extends WriteableDocumentType>({ docType, projectId, }: { docType: D; projectId: string; }) => { error: Error; mutate: UseMutateFunction<WriteableDocument<D> and DerivedDocFields, Error, { ...; }, unknown>; mutateAsync: UseMutateAsyncFunction<...>; reset: () => void; status: "error"; } or { ...; }` |
725
970
 
726
971
  Parameters:
727
972
 
@@ -729,24 +974,41 @@ Parameters:
729
974
  * `opts.projectId`: Public ID of project document belongs to.
730
975
 
731
976
 
732
- ### useSetUpInvitesListeners
977
+ ### usePresetsSelection
733
978
 
734
- Set up listeners for received and updated invites.
735
- It is necessary to use this if you want the invites-related read hooks to update
736
- based on invites that are received or changed in the background.
979
+ Retrieve presets for category selection, ordered by project settings.
980
+
981
+ Returns presets in the order defined by `projectSettings.defaultPresets` for the
982
+ specified data type. Falls back to alphabetical order (by preset name) if no defaults are configured.
737
983
 
738
984
  | Function | Type |
739
985
  | ---------- | ---------- |
740
- | `useSetUpInvitesListeners` | `() => void` |
986
+ | `usePresetsSelection` | `({ projectId, dataType, lang, }: { projectId: string; dataType: "track" or "observation"; lang?: string or undefined; }) => { schemaName: "preset"; name: string; geometry: ("point" or "vertex" or "line" or "area" or "relation")[]; ... 13 more ...; deleted: boolean; }[]` |
987
+
988
+ Parameters:
989
+
990
+ * `opts.projectId`: Project public ID
991
+ * `opts.dataType`: Type of data being created ('observation' or 'track')
992
+ * `opts.lang`: Language to translate presets into
993
+
741
994
 
742
995
  Examples:
743
996
 
744
997
  ```tsx
745
- function App() {
746
- // Use this somewhere near the root of the application
747
- useSetUpInvitesListeners()
998
+ function ObservationCategoryChooser() {
999
+ const presets = usePresetsSelection({
1000
+ projectId: '...',
1001
+ dataType: 'observation',
1002
+ })
1003
+ }
1004
+ ```
748
1005
 
749
- return <RestOfApp />
1006
+ ```tsx
1007
+ function TrackCategoryChooser() {
1008
+ const presets = usePresetsSelection({
1009
+ projectId: '...',
1010
+ dataType: 'track',
1011
+ })
750
1012
  }
751
1013
  ```
752
1014
 
@@ -757,7 +1019,7 @@ Get all invites that the device has received.
757
1019
 
758
1020
  | Function | Type |
759
1021
  | ---------- | ---------- |
760
- | `useManyInvites` | `() => { data: Invite[]; error: Error or null; isRefetching: boolean; }` |
1022
+ | `useManyInvites` | `() => { data: any; error: Error or null; isRefetching: boolean; }` |
761
1023
 
762
1024
  Examples:
763
1025
 
@@ -774,7 +1036,7 @@ Get a single invite based on its ID.
774
1036
 
775
1037
  | Function | Type |
776
1038
  | ---------- | ---------- |
777
- | `useSingleInvite` | `({ inviteId }: { inviteId: string; }) => { data: Invite; error: Error or null; isRefetching: boolean; }` |
1039
+ | `useSingleInvite` | `({ inviteId }: { inviteId: string; }) => { data: any; error: Error or null; isRefetching: boolean; }` |
778
1040
 
779
1041
  Parameters:
780
1042
 
@@ -796,7 +1058,7 @@ Accept an invite that has been received.
796
1058
 
797
1059
  | Function | Type |
798
1060
  | ---------- | ---------- |
799
- | `useAcceptInvite` | `() => { error: Error; mutate: UseMutateFunction<string, Error, { inviteId: string; }, unknown>; mutateAsync: UseMutateAsyncFunction<string, Error, { inviteId: string; }, unknown>; reset: () => void; status: "error"; } or { ...; }` |
1061
+ | `useAcceptInvite` | `() => { error: Error; mutate: UseMutateFunction<any, Error, { inviteId: string; }, unknown>; mutateAsync: UseMutateAsyncFunction<any, Error, { inviteId: string; }, unknown>; reset: () => void; status: "error"; } or { ...; }` |
800
1062
 
801
1063
  ### useRejectInvite
802
1064
 
@@ -804,7 +1066,7 @@ Reject an invite that has been received.
804
1066
 
805
1067
  | Function | Type |
806
1068
  | ---------- | ---------- |
807
- | `useRejectInvite` | `() => { error: Error; mutate: UseMutateFunction<void, Error, { inviteId: string; }, unknown>; mutateAsync: UseMutateAsyncFunction<void, Error, { inviteId: string; }, unknown>; reset: () => void; status: "error"; } or { ...; }` |
1069
+ | `useRejectInvite` | `() => { error: Error; mutate: UseMutateFunction<any, Error, { inviteId: string; }, unknown>; mutateAsync: UseMutateAsyncFunction<any, Error, { inviteId: string; }, unknown>; reset: () => void; status: "error"; } or { ...; }` |
808
1070
 
809
1071
  ### useSendInvite
810
1072
 
@@ -812,7 +1074,7 @@ Send an invite for a project.
812
1074
 
813
1075
  | Function | Type |
814
1076
  | ---------- | ---------- |
815
- | `useSendInvite` | `({ projectId }: { projectId: string; }) => { error: Error; mutate: UseMutateFunction<"ACCEPT" or "REJECT" or "ALREADY", Error, { deviceId: string; roleDescription?: string or undefined; roleId: "f7c150f5a3a9a855" or "012fd2d431c0bf60" or "9e6d29263cba36c9"; roleName?: string or undefined; }, unknown>; mutateAsync: UseMuta...` |
1077
+ | `useSendInvite` | `({ projectId }: { projectId: string; }) => { error: Error; mutate: UseMutateFunction<any, Error, { deviceId: string; roleDescription?: string or undefined; roleId: "f7c150f5a3a9a855" or "012fd2d431c0bf60" or "9e6d29263cba36c9"; roleName?: string or undefined; }, unknown>; mutateAsync: UseMutateAsyncFunction<...>; reset:...` |
816
1078
 
817
1079
  Parameters:
818
1080
 
@@ -825,7 +1087,7 @@ Request a cancellation of an invite sent to another device.
825
1087
 
826
1088
  | Function | Type |
827
1089
  | ---------- | ---------- |
828
- | `useRequestCancelInvite` | `({ projectId }: { projectId: string; }) => { error: Error; mutate: UseMutateFunction<void, Error, { deviceId: string; }, unknown>; mutateAsync: UseMutateAsyncFunction<void, Error, { ...; }, unknown>; reset: () => void; status: "error"; } or { ...; }` |
1090
+ | `useRequestCancelInvite` | `({ projectId }: { projectId: string; }) => { error: Error; mutate: UseMutateFunction<any, Error, { deviceId: string; }, unknown>; mutateAsync: UseMutateAsyncFunction<any, Error, { ...; }, unknown>; reset: () => void; status: "error"; } or { ...; }` |
829
1091
 
830
1092
  Parameters:
831
1093
 
@@ -868,40 +1130,285 @@ function ExampleWithRefreshToken() {
868
1130
  ```
869
1131
 
870
1132
 
1133
+ ### useManyReceivedMapShares
1134
+
1135
+ Get all map shares that the device has received. Automatically updates when
1136
+ new shares arrive or share states change.
1137
+
1138
+ IMPORTANT: This hook will not trigger a re-render when download progress
1139
+ updates, only when the status changes. This is to avoid excessive re-renders
1140
+ during downloads. Use `useSingleReceivedMapShare` to get real-time updates on
1141
+ a specific share, including download progress.
1142
+
1143
+ | Function | Type |
1144
+ | ---------- | ---------- |
1145
+ | `useManyReceivedMapShares` | `() => any[]` |
1146
+
1147
+ Examples:
1148
+
1149
+ ```tsx
1150
+ function MapSharesList() {
1151
+ const shares = useManyReceivedMapShares()
1152
+
1153
+ return shares.map(share => (
1154
+ <div key={share.shareId}>
1155
+ {share.mapName} from {share.senderDeviceName} - {share.state}
1156
+ </div>
1157
+ ))
1158
+ }
1159
+ ```
1160
+
1161
+
1162
+ ### useSingleReceivedMapShare
1163
+
1164
+ Get a single received map share based on its shareId.
1165
+
1166
+ | Function | Type |
1167
+ | ---------- | ---------- |
1168
+ | `useSingleReceivedMapShare` | `({ shareId }: { shareId: string; }) => any` |
1169
+
1170
+ Parameters:
1171
+
1172
+ * `opts.shareId`: ID of the map share
1173
+
1174
+
1175
+ Examples:
1176
+
1177
+ ```tsx
1178
+ function MapShareDetail({ shareId }: { shareId: string }) {
1179
+ const share = useSingleReceivedMapShare({ shareId })
1180
+
1181
+ return <div>{share.mapName} - {share.state}</div>
1182
+ }
1183
+ ```
1184
+
1185
+
1186
+ ### useDownloadReceivedMapShare
1187
+
1188
+ Accept and download a map share that has been received. The mutate promise
1189
+ resolves once the map _starts_ downloading, before it finishes downloading.
1190
+ Use `useManyMapShares` or `useSingleMapShare` to track download progress.
1191
+
1192
+ Throws if the share is not in `status="pending"` or if the download fails to
1193
+ start (e.g. if the shareId if invalid).
1194
+
1195
+ | Function | Type |
1196
+ | ---------- | ---------- |
1197
+ | `useDownloadReceivedMapShare` | `() => Pick<Override<MutationObserverIdleResult<Promise<void>, Error, Omit<DownloadMapShareOptions, "projectId">, unknown>, { ...; }> and { ...; }, "error" or ... 3 more ... or "mutateAsync"> or Pick<...> or Pick<...> or Pick<...>` |
1198
+
1199
+ Examples:
1200
+
1201
+ ```tsx
1202
+ function AcceptButton({ shareId }: { shareId: string }) {
1203
+ const { mutate: accept } = useAcceptMapShare()
1204
+
1205
+ return <button onClick={() => accept({ shareId })}>Accept</button>
1206
+ }
1207
+ ```
1208
+
1209
+
1210
+ ### useDeclineReceivedMapShare
1211
+
1212
+ Decline a map share that has been received. Notifies the sender that the
1213
+ share was declined.
1214
+
1215
+ Throws if the share is not with `status="pending"`
1216
+ Throws if shareId is invalid
1217
+ Throws if decline request fails (e.g. network error)
1218
+
1219
+ | Function | Type |
1220
+ | ---------- | ---------- |
1221
+ | `useDeclineReceivedMapShare` | `() => Pick<Override<MutationObserverIdleResult<Promise<void>, Error, Omit<DeclineMapShareOptions, "projectId">, unknown>, { ...; }> and { ...; }, "error" or ... 3 more ... or "mutateAsync"> or Pick<...> or Pick<...> or Pick<...>` |
1222
+
1223
+ Examples:
1224
+
1225
+ ```tsx
1226
+ function DeclineButton({ shareId }: { shareId: string }) {
1227
+ const { mutate: decline } = useDeclineMapShare()
1228
+
1229
+ return (
1230
+ <button onClick={() => decline({ shareId, reason: 'user_rejected' })}>
1231
+ Decline
1232
+ </button>
1233
+ )
1234
+ }
1235
+ ```
1236
+
1237
+
1238
+ ### useAbortReceivedMapShareDownload
1239
+
1240
+ Abort an in-progress map share download.
1241
+
1242
+ Throws if the share is not in `status="downloading"`
1243
+ Throws if shareId is invalid
1244
+
1245
+ | Function | Type |
1246
+ | ---------- | ---------- |
1247
+ | `useAbortReceivedMapShareDownload` | `() => Pick<Override<MutationObserverIdleResult<Promise<void>, Error, Omit<AbortMapShareOptions, "projectId">, unknown>, { ...; }> and { ...; }, "error" or ... 3 more ... or "mutateAsync"> or Pick<...> or Pick<...> or Pick<...>` |
1248
+
1249
+ Examples:
1250
+
1251
+ ```tsx
1252
+ function AbortButton({ shareId }: { shareId: string }) {
1253
+ const { mutate: abort } = useAbortMapShareDownload()
1254
+
1255
+ return <button onClick={() => abort({ shareId })}>Cancel Download</button>
1256
+ }
1257
+ ```
1258
+
1259
+
1260
+ ### useSendMapShare
1261
+
1262
+ Share a map with a device. The mutation resolves immediately after sending
1263
+ the share offer, without waiting for the recipient to accept or reject. The
1264
+ mutation resolves with the created map share object, including its ID, which
1265
+ can be used to track the share status with `useSingleSentMapShare`.
1266
+
1267
+ | Function | Type |
1268
+ | ---------- | ---------- |
1269
+ | `useSendMapShare` | `({ projectId }: { projectId: string; }) => Pick<Override<MutationObserverIdleResult<Promise<ServerMapShareState>, Error, CreateAndSendMapShareOptions, unknown>, { ...; }> and { ...; }, "error" or ... 3 more ... or "mutateAsync"> or Pick<...> or Pick<...> or Pick<...>` |
1270
+
1271
+ Parameters:
1272
+
1273
+ * `opts.projectId`: Public ID of project for sending the map share: you can only send map shares to users on the same project
1274
+
1275
+
1276
+ Examples:
1277
+
1278
+ ```tsx
1279
+ function SendMapButton({ projectId, deviceId }: { projectId: string; deviceId: string }) {
1280
+ const { mutate: send } = useSendMapShare({ projectId }, {
1281
+ onSuccess: (mapShare) => {
1282
+ console.log('Share sent with id', mapShare.shareId)
1283
+ }
1284
+ })
1285
+
1286
+ return (
1287
+ <button onClick={() => send({ receiverDeviceId: deviceId, mapId: 'custom' })}>
1288
+ Send Map
1289
+ </button>
1290
+ )
1291
+ }
1292
+ ```
1293
+
1294
+
1295
+ ### useCancelSentMapShare
1296
+
1297
+ Cancel a map share that was previously sent. If the recipient has not yet
1298
+ started downloading the share, they will not be notified until they attempt
1299
+ to accept the share and begin downloading it. If they are already downloading
1300
+ the share, the download will be canceled before completion. If the download
1301
+ is already complete, this action will throw an error.
1302
+
1303
+ | Function | Type |
1304
+ | ---------- | ---------- |
1305
+ | `useCancelSentMapShare` | `() => Pick<Override<MutationObserverIdleResult<Promise<void>, Error, Omit<CancelMapShareOptions, "projectId">, unknown>, { ...; }> and { ...; }, "error" or ... 3 more ... or "mutateAsync"> or Pick<...> or Pick<...> or Pick<...>` |
1306
+
1307
+ Parameters:
1308
+
1309
+ * `opts.projectId`: Public ID of project to request the map share cancellation for.
1310
+
1311
+
1312
+ Examples:
1313
+
1314
+ ```tsx
1315
+ function CancelShareButton({ projectId, shareId }: { projectId: string; shareId: string }) {
1316
+ const { mutate: cancel } = useRequestCancelMapShare({ projectId })
1317
+
1318
+ return <button onClick={() => cancel({ shareId })}>Cancel Share</button>
1319
+ }
1320
+ ```
1321
+
1322
+
1323
+ ### useSingleSentMapShare
1324
+
1325
+ Track the status and progress of a sent map share. Returns the current state
1326
+ of the share, updated in real-time. When the recipient starts downloading, or
1327
+ if they decline the share, then the returned share will update.
1328
+
1329
+ Throws if no share with the specified ID is found.
1330
+
1331
+ | Function | Type |
1332
+ | ---------- | ---------- |
1333
+ | `useSingleSentMapShare` | `({ shareId, }: { shareId: string; }) => ServerMapShareState` |
1334
+
1335
+ Parameters:
1336
+
1337
+ * `opts.shareId`: ID of the sent map share
1338
+
1339
+
1340
+ Examples:
1341
+
1342
+ ```tsx
1343
+ function SentShareStatus({ shareId }: { shareId: string }) {
1344
+ const mapShare = useSingleSentMapShare({ shareId })
1345
+
1346
+ return (<div>
1347
+ <div>Share status: {mapShare.status}</div>
1348
+ {mapShare.status === 'pending' && <div>Waiting for recipient to accept...</div>}
1349
+ {mapShare.status === 'downloading' && (<div>Download in progress: {mapShare.downloadProgress}%</div>)}
1350
+ {mapShare.status === 'declined' && <div>Share was declined by recipient</div>}
1351
+ {mapShare.status === 'canceled' && <div>Share was canceled</div>}
1352
+ </div>)
1353
+ }
1354
+ ```
1355
+
1356
+
871
1357
 
872
1358
  ## Constants
873
1359
 
874
1360
  - [ClientApiContext](#clientapicontext)
1361
+ - [ReceivedMapSharesContext](#receivedmapsharescontext)
1362
+ - [SentMapSharesContext](#sentmapsharescontext)
1363
+ - [MapServerContext](#mapservercontext)
875
1364
 
876
1365
  ### ClientApiContext
877
1366
 
878
1367
  | Constant | Type |
879
1368
  | ---------- | ---------- |
880
- | `ClientApiContext` | `Context<MapeoClientApi or null>` |
1369
+ | `ClientApiContext` | `Context<any>` |
1370
+
1371
+ ### ReceivedMapSharesContext
1372
+
1373
+ | Constant | Type |
1374
+ | ---------- | ---------- |
1375
+ | `ReceivedMapSharesContext` | `Context<{ subscribe: (listener: () => void) => () => boolean; getSnapshot: () => any[]; actions: { download({ shareId }: DownloadMapShareOptions): Promise<void>; decline({ shareId, reason }: DeclineMapShareOptions): Promise<...>; abort({ shareId }: AbortMapShareOptions): Promise<...>; }; } or null>` |
1376
+
1377
+ ### SentMapSharesContext
1378
+
1379
+ | Constant | Type |
1380
+ | ---------- | ---------- |
1381
+ | `SentMapSharesContext` | `Context<{ subscribe: (listener: () => void) => () => boolean; getSnapshot: () => ServerMapShareState[]; actions: { createAndSend({ projectId, receiverDeviceId, mapId, }: CreateAndSendMapShareOptions): Promise<ServerMapShareState>; cancel({ shareId }: CancelMapShareOptions): Promise<...>; }; } or null>` |
1382
+
1383
+ ### MapServerContext
1384
+
1385
+ | Constant | Type |
1386
+ | ---------- | ---------- |
1387
+ | `MapServerContext` | `Context<MapServerApi or null>` |
881
1388
 
882
1389
 
883
1390
 
884
1391
  ## Types
885
1392
 
886
- - [WriteableDocumentType](#writeabledocumenttype)
887
- - [WriteableValue](#writeablevalue)
888
- - [WriteableDocument](#writeabledocument)
1393
+ - [MapServerApiOptions](#mapserverapioptions)
1394
+ - [MapServerApi](#mapserverapi)
1395
+ - [MapServerProviderProps](#mapserverproviderprops)
889
1396
 
890
- ### WriteableDocumentType
1397
+ ### MapServerApiOptions
891
1398
 
892
1399
  | Type | Type |
893
1400
  | ---------- | ---------- |
894
- | `WriteableDocumentType` | `Extract< MapeoDoc['schemaName'], 'field' or 'observation' or 'preset' or 'track' or 'remoteDetectionAlert' >` |
1401
+ | `MapServerApiOptions` | `{ getBaseUrl(): Promise<URL> fetch?( input: string or URL or Request, options?: RequestInit, ): Promise<Response> }` |
895
1402
 
896
- ### WriteableValue
1403
+ ### MapServerApi
897
1404
 
898
1405
  | Type | Type |
899
1406
  | ---------- | ---------- |
900
- | `WriteableValue` | `Extract< MapeoValue, { schemaName: D } >` |
1407
+ | `MapServerApi` | `KyInstance and { createEventSource(options: EventSourceOptions): EventSourceClient getMapStyleJsonUrl(mapId: string): Promise<string> }` |
901
1408
 
902
- ### WriteableDocument
1409
+ ### MapServerProviderProps
903
1410
 
904
1411
  | Type | Type |
905
1412
  | ---------- | ---------- |
906
- | `WriteableDocument` | `Extract< MapeoDoc, { schemaName: D } >` |
1413
+ | `MapServerProviderProps` | `PropsWithChildren<MapServerApiOptions>` |
907
1414