@comapeo/core-react 11.0.0 → 11.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.
@@ -141,6 +141,9 @@ export declare function useManyReceivedMapShares(): ReceivedMapShareState[];
141
141
  *
142
142
  * @param opts.shareId ID of the map share
143
143
  *
144
+ * @throws An error with code `'MAP_SHARE_NOT_FOUND'` if no received share
145
+ * with the given `shareId` exists.
146
+ *
144
147
  * @example
145
148
  * ```tsx
146
149
  * function MapShareDetail({ shareId }: { shareId: string }) {
@@ -165,11 +168,14 @@ export declare function useSingleReceivedMapShare({ shareId }: {
165
168
  * receiver discovers that a share has been canceled — check `share.status`
166
169
  * after the download settles.
167
170
  *
168
- * @throws {MapShareCanceledError} If the share is already known to be canceled
169
- * (i.e. `status` is `'canceled'` in the store, e.g. after a previous
170
- * download attempt discovered the cancellation).
171
- * @throws {InvalidStatusTransitionError} If the share is not in a valid state
172
- * to start downloading (e.g. already downloading, completed, or declined).
171
+ * @throws An error with code `'MAP_SHARE_CANCELED'` if the share is already
172
+ * known to be canceled (i.e. `status` is `'canceled'` in the store, e.g.
173
+ * after a previous download attempt discovered the cancellation).
174
+ * @throws An error with code `'INVALID_STATUS_TRANSITION'` if the share is
175
+ * not in a valid state to start downloading (e.g. already downloading,
176
+ * completed, or declined).
177
+ * @throws An error with code `'MAP_SHARE_NOT_FOUND'` if no share with the
178
+ * given `shareId` exists in the store.
173
179
  *
174
180
  * @example
175
181
  * ```tsx
@@ -206,12 +212,15 @@ export declare function useDownloadReceivedMapShare(): Pick<import("@tanstack/re
206
212
  * share status will transition to `'canceled'` (not `'error'`) and the
207
213
  * mutation will throw a `MapShareCanceledError`.
208
214
  *
209
- * @throws {MapShareCanceledError} If the share is already known to be
210
- * canceled, or if the server reports that the sender canceled the share
211
- * while the decline was in flight. In both cases `share.status` will be
212
- * `'canceled'`.
213
- * @throws {InvalidStatusTransitionError} If the share is not in
214
- * `status='pending'` (e.g. already downloading, completed, or declined).
215
+ * @throws An error with code `'MAP_SHARE_CANCELED'` if the share is already
216
+ * known to be canceled, or if the server reports that the sender canceled
217
+ * the share while the decline was in flight. In both cases `share.status`
218
+ * will be `'canceled'`.
219
+ * @throws An error with code `'INVALID_STATUS_TRANSITION'` if the share is
220
+ * not in `status='pending'` (e.g. already downloading, completed, or
221
+ * declined).
222
+ * @throws An error with code `'MAP_SHARE_NOT_FOUND'` if no share with the
223
+ * given `shareId` exists in the store.
215
224
  *
216
225
  * @example
217
226
  * ```tsx
@@ -247,10 +256,15 @@ export declare function useDeclineReceivedMapShare(): Pick<import("@tanstack/rea
247
256
  /**
248
257
  * Abort an in-progress map share download.
249
258
  *
250
- * @throws {MapShareCanceledError} If the share is already known to be canceled.
251
- * @throws {InvalidStatusTransitionError} If the share is not in
252
- * `status='downloading'` (e.g. still pending, already completed, or
259
+ * @throws An error with code `'MAP_SHARE_CANCELED'` if the share is already
260
+ * known to be canceled.
261
+ * @throws An error with code `'INVALID_STATUS_TRANSITION'` if the share is
262
+ * not in `status='downloading'` (e.g. still pending, already completed, or
253
263
  * declined).
264
+ * @throws An error with code `'MAP_SHARE_NOT_FOUND'` if no share with the
265
+ * given `shareId` exists in the store.
266
+ * @throws An error with code `'DOWNLOAD_NOT_FOUND'` if no download is
267
+ * currently tracked for this share (e.g. the download was never started).
254
268
  *
255
269
  * @example
256
270
  * ```tsx
@@ -329,6 +343,12 @@ export declare function useSendMapShare(): Pick<import("@tanstack/react-query").
329
343
  * the share, the download will be canceled before completion. If the download
330
344
  * is already complete, this action will throw an error.
331
345
  *
346
+ * @throws An error with code `'INVALID_STATUS_TRANSITION'` if the share is
347
+ * not in `status='pending'` or `status='downloading'` (e.g. already
348
+ * completed, canceled, aborted, or declined).
349
+ * @throws An error with code `'MAP_SHARE_NOT_FOUND'` if no share with the
350
+ * given `shareId` exists in the store.
351
+ *
332
352
  * @param opts.projectId Public ID of project to request the map share cancellation for.
333
353
  *
334
354
  * @example
@@ -362,7 +382,8 @@ export declare function useCancelSentMapShare(): Pick<import("@tanstack/react-qu
362
382
  * of the share, updated in real-time. When the recipient starts downloading, or
363
383
  * if they decline the share, then the returned share will update.
364
384
  *
365
- * Throws if no share with the specified ID is found.
385
+ * @throws An error with code `'MAP_SHARE_NOT_FOUND'` if no sent share with
386
+ * the given `shareId` exists in the store.
366
387
  *
367
388
  * @param opts.shareId ID of the sent map share
368
389
  *
@@ -163,6 +163,9 @@ function useManyReceivedMapShares() {
163
163
  *
164
164
  * @param opts.shareId ID of the map share
165
165
  *
166
+ * @throws An error with code `'MAP_SHARE_NOT_FOUND'` if no received share
167
+ * with the given `shareId` exists.
168
+ *
166
169
  * @example
167
170
  * ```tsx
168
171
  * function MapShareDetail({ shareId }: { shareId: string }) {
@@ -175,7 +178,7 @@ function useManyReceivedMapShares() {
175
178
  function useSingleReceivedMapShare({ shareId }) {
176
179
  const mapShare = (0, MapShares_js_1.useReceivedMapSharesState)((0, react_1.useCallback)((shares) => shares.find((s) => s.shareId === shareId), [shareId]));
177
180
  if (!mapShare) {
178
- throw new Error(`Map share with id ${shareId} not found`);
181
+ throw new errors_js_1.errors.MAP_SHARE_NOT_FOUND(`Received map share with id ${shareId} not found`);
179
182
  }
180
183
  return mapShare;
181
184
  }
@@ -191,11 +194,14 @@ function useSingleReceivedMapShare({ shareId }) {
191
194
  * receiver discovers that a share has been canceled — check `share.status`
192
195
  * after the download settles.
193
196
  *
194
- * @throws {MapShareCanceledError} If the share is already known to be canceled
195
- * (i.e. `status` is `'canceled'` in the store, e.g. after a previous
196
- * download attempt discovered the cancellation).
197
- * @throws {InvalidStatusTransitionError} If the share is not in a valid state
198
- * to start downloading (e.g. already downloading, completed, or declined).
197
+ * @throws An error with code `'MAP_SHARE_CANCELED'` if the share is already
198
+ * known to be canceled (i.e. `status` is `'canceled'` in the store, e.g.
199
+ * after a previous download attempt discovered the cancellation).
200
+ * @throws An error with code `'INVALID_STATUS_TRANSITION'` if the share is
201
+ * not in a valid state to start downloading (e.g. already downloading,
202
+ * completed, or declined).
203
+ * @throws An error with code `'MAP_SHARE_NOT_FOUND'` if no share with the
204
+ * given `shareId` exists in the store.
199
205
  *
200
206
  * @example
201
207
  * ```tsx
@@ -224,12 +230,15 @@ function useDownloadReceivedMapShare() {
224
230
  * share status will transition to `'canceled'` (not `'error'`) and the
225
231
  * mutation will throw a `MapShareCanceledError`.
226
232
  *
227
- * @throws {MapShareCanceledError} If the share is already known to be
228
- * canceled, or if the server reports that the sender canceled the share
229
- * while the decline was in flight. In both cases `share.status` will be
230
- * `'canceled'`.
231
- * @throws {InvalidStatusTransitionError} If the share is not in
232
- * `status='pending'` (e.g. already downloading, completed, or declined).
233
+ * @throws An error with code `'MAP_SHARE_CANCELED'` if the share is already
234
+ * known to be canceled, or if the server reports that the sender canceled
235
+ * the share while the decline was in flight. In both cases `share.status`
236
+ * will be `'canceled'`.
237
+ * @throws An error with code `'INVALID_STATUS_TRANSITION'` if the share is
238
+ * not in `status='pending'` (e.g. already downloading, completed, or
239
+ * declined).
240
+ * @throws An error with code `'MAP_SHARE_NOT_FOUND'` if no share with the
241
+ * given `shareId` exists in the store.
233
242
  *
234
243
  * @example
235
244
  * ```tsx
@@ -257,10 +266,15 @@ function useDeclineReceivedMapShare() {
257
266
  /**
258
267
  * Abort an in-progress map share download.
259
268
  *
260
- * @throws {MapShareCanceledError} If the share is already known to be canceled.
261
- * @throws {InvalidStatusTransitionError} If the share is not in
262
- * `status='downloading'` (e.g. still pending, already completed, or
269
+ * @throws An error with code `'MAP_SHARE_CANCELED'` if the share is already
270
+ * known to be canceled.
271
+ * @throws An error with code `'INVALID_STATUS_TRANSITION'` if the share is
272
+ * not in `status='downloading'` (e.g. still pending, already completed, or
263
273
  * declined).
274
+ * @throws An error with code `'MAP_SHARE_NOT_FOUND'` if no share with the
275
+ * given `shareId` exists in the store.
276
+ * @throws An error with code `'DOWNLOAD_NOT_FOUND'` if no download is
277
+ * currently tracked for this share (e.g. the download was never started).
264
278
  *
265
279
  * @example
266
280
  * ```tsx
@@ -326,6 +340,12 @@ function useSendMapShare() {
326
340
  * the share, the download will be canceled before completion. If the download
327
341
  * is already complete, this action will throw an error.
328
342
  *
343
+ * @throws An error with code `'INVALID_STATUS_TRANSITION'` if the share is
344
+ * not in `status='pending'` or `status='downloading'` (e.g. already
345
+ * completed, canceled, aborted, or declined).
346
+ * @throws An error with code `'MAP_SHARE_NOT_FOUND'` if no share with the
347
+ * given `shareId` exists in the store.
348
+ *
329
349
  * @param opts.projectId Public ID of project to request the map share cancellation for.
330
350
  *
331
351
  * @example
@@ -351,7 +371,8 @@ function useCancelSentMapShare() {
351
371
  * of the share, updated in real-time. When the recipient starts downloading, or
352
372
  * if they decline the share, then the returned share will update.
353
373
  *
354
- * Throws if no share with the specified ID is found.
374
+ * @throws An error with code `'MAP_SHARE_NOT_FOUND'` if no sent share with
375
+ * the given `shareId` exists in the store.
355
376
  *
356
377
  * @param opts.shareId ID of the sent map share
357
378
  *
@@ -23,7 +23,7 @@ exports.getDocumentsQueryKey = getDocumentsQueryKey;
23
23
  exports.getManyDocumentsQueryKey = getManyDocumentsQueryKey;
24
24
  exports.getDocumentByDocIdQueryKey = getDocumentByDocIdQueryKey;
25
25
  exports.getDocumentByVersionIdQueryKey = getDocumentByVersionIdQueryKey;
26
- const map_server_1 = require("@comapeo/map-server");
26
+ const constants_js_1 = require("@comapeo/map-server/constants.js");
27
27
  // #region Shared
28
28
  const ROOT_QUERY_KEY = '@comapeo/core-react';
29
29
  // Since the API is running locally, queries should run regardless of network
@@ -103,7 +103,7 @@ async function invalidateMapQueries(queryClient, { mapId }) {
103
103
  queryKey: getMapQueryKey({ mapId }),
104
104
  }),
105
105
  queryClient.invalidateQueries({
106
- queryKey: getMapQueryKey({ mapId: map_server_1.DEFAULT_MAP_ID }),
106
+ queryKey: getMapQueryKey({ mapId: constants_js_1.DEFAULT_MAP_ID }),
107
107
  }),
108
108
  ]);
109
109
  }
@@ -141,6 +141,9 @@ export declare function useManyReceivedMapShares(): ReceivedMapShareState[];
141
141
  *
142
142
  * @param opts.shareId ID of the map share
143
143
  *
144
+ * @throws An error with code `'MAP_SHARE_NOT_FOUND'` if no received share
145
+ * with the given `shareId` exists.
146
+ *
144
147
  * @example
145
148
  * ```tsx
146
149
  * function MapShareDetail({ shareId }: { shareId: string }) {
@@ -165,11 +168,14 @@ export declare function useSingleReceivedMapShare({ shareId }: {
165
168
  * receiver discovers that a share has been canceled — check `share.status`
166
169
  * after the download settles.
167
170
  *
168
- * @throws {MapShareCanceledError} If the share is already known to be canceled
169
- * (i.e. `status` is `'canceled'` in the store, e.g. after a previous
170
- * download attempt discovered the cancellation).
171
- * @throws {InvalidStatusTransitionError} If the share is not in a valid state
172
- * to start downloading (e.g. already downloading, completed, or declined).
171
+ * @throws An error with code `'MAP_SHARE_CANCELED'` if the share is already
172
+ * known to be canceled (i.e. `status` is `'canceled'` in the store, e.g.
173
+ * after a previous download attempt discovered the cancellation).
174
+ * @throws An error with code `'INVALID_STATUS_TRANSITION'` if the share is
175
+ * not in a valid state to start downloading (e.g. already downloading,
176
+ * completed, or declined).
177
+ * @throws An error with code `'MAP_SHARE_NOT_FOUND'` if no share with the
178
+ * given `shareId` exists in the store.
173
179
  *
174
180
  * @example
175
181
  * ```tsx
@@ -206,12 +212,15 @@ export declare function useDownloadReceivedMapShare(): Pick<import("@tanstack/re
206
212
  * share status will transition to `'canceled'` (not `'error'`) and the
207
213
  * mutation will throw a `MapShareCanceledError`.
208
214
  *
209
- * @throws {MapShareCanceledError} If the share is already known to be
210
- * canceled, or if the server reports that the sender canceled the share
211
- * while the decline was in flight. In both cases `share.status` will be
212
- * `'canceled'`.
213
- * @throws {InvalidStatusTransitionError} If the share is not in
214
- * `status='pending'` (e.g. already downloading, completed, or declined).
215
+ * @throws An error with code `'MAP_SHARE_CANCELED'` if the share is already
216
+ * known to be canceled, or if the server reports that the sender canceled
217
+ * the share while the decline was in flight. In both cases `share.status`
218
+ * will be `'canceled'`.
219
+ * @throws An error with code `'INVALID_STATUS_TRANSITION'` if the share is
220
+ * not in `status='pending'` (e.g. already downloading, completed, or
221
+ * declined).
222
+ * @throws An error with code `'MAP_SHARE_NOT_FOUND'` if no share with the
223
+ * given `shareId` exists in the store.
215
224
  *
216
225
  * @example
217
226
  * ```tsx
@@ -247,10 +256,15 @@ export declare function useDeclineReceivedMapShare(): Pick<import("@tanstack/rea
247
256
  /**
248
257
  * Abort an in-progress map share download.
249
258
  *
250
- * @throws {MapShareCanceledError} If the share is already known to be canceled.
251
- * @throws {InvalidStatusTransitionError} If the share is not in
252
- * `status='downloading'` (e.g. still pending, already completed, or
259
+ * @throws An error with code `'MAP_SHARE_CANCELED'` if the share is already
260
+ * known to be canceled.
261
+ * @throws An error with code `'INVALID_STATUS_TRANSITION'` if the share is
262
+ * not in `status='downloading'` (e.g. still pending, already completed, or
253
263
  * declined).
264
+ * @throws An error with code `'MAP_SHARE_NOT_FOUND'` if no share with the
265
+ * given `shareId` exists in the store.
266
+ * @throws An error with code `'DOWNLOAD_NOT_FOUND'` if no download is
267
+ * currently tracked for this share (e.g. the download was never started).
254
268
  *
255
269
  * @example
256
270
  * ```tsx
@@ -329,6 +343,12 @@ export declare function useSendMapShare(): Pick<import("@tanstack/react-query").
329
343
  * the share, the download will be canceled before completion. If the download
330
344
  * is already complete, this action will throw an error.
331
345
  *
346
+ * @throws An error with code `'INVALID_STATUS_TRANSITION'` if the share is
347
+ * not in `status='pending'` or `status='downloading'` (e.g. already
348
+ * completed, canceled, aborted, or declined).
349
+ * @throws An error with code `'MAP_SHARE_NOT_FOUND'` if no share with the
350
+ * given `shareId` exists in the store.
351
+ *
332
352
  * @param opts.projectId Public ID of project to request the map share cancellation for.
333
353
  *
334
354
  * @example
@@ -362,7 +382,8 @@ export declare function useCancelSentMapShare(): Pick<import("@tanstack/react-qu
362
382
  * of the share, updated in real-time. When the recipient starts downloading, or
363
383
  * if they decline the share, then the returned share will update.
364
384
  *
365
- * Throws if no share with the specified ID is found.
385
+ * @throws An error with code `'MAP_SHARE_NOT_FOUND'` if no sent share with
386
+ * the given `shareId` exists in the store.
366
387
  *
367
388
  * @param opts.shareId ID of the sent map share
368
389
  *
@@ -149,6 +149,9 @@ export function useManyReceivedMapShares() {
149
149
  *
150
150
  * @param opts.shareId ID of the map share
151
151
  *
152
+ * @throws An error with code `'MAP_SHARE_NOT_FOUND'` if no received share
153
+ * with the given `shareId` exists.
154
+ *
152
155
  * @example
153
156
  * ```tsx
154
157
  * function MapShareDetail({ shareId }: { shareId: string }) {
@@ -161,7 +164,7 @@ export function useManyReceivedMapShares() {
161
164
  export function useSingleReceivedMapShare({ shareId }) {
162
165
  const mapShare = useReceivedMapSharesState(useCallback((shares) => shares.find((s) => s.shareId === shareId), [shareId]));
163
166
  if (!mapShare) {
164
- throw new Error(`Map share with id ${shareId} not found`);
167
+ throw new errors.MAP_SHARE_NOT_FOUND(`Received map share with id ${shareId} not found`);
165
168
  }
166
169
  return mapShare;
167
170
  }
@@ -177,11 +180,14 @@ export function useSingleReceivedMapShare({ shareId }) {
177
180
  * receiver discovers that a share has been canceled — check `share.status`
178
181
  * after the download settles.
179
182
  *
180
- * @throws {MapShareCanceledError} If the share is already known to be canceled
181
- * (i.e. `status` is `'canceled'` in the store, e.g. after a previous
182
- * download attempt discovered the cancellation).
183
- * @throws {InvalidStatusTransitionError} If the share is not in a valid state
184
- * to start downloading (e.g. already downloading, completed, or declined).
183
+ * @throws An error with code `'MAP_SHARE_CANCELED'` if the share is already
184
+ * known to be canceled (i.e. `status` is `'canceled'` in the store, e.g.
185
+ * after a previous download attempt discovered the cancellation).
186
+ * @throws An error with code `'INVALID_STATUS_TRANSITION'` if the share is
187
+ * not in a valid state to start downloading (e.g. already downloading,
188
+ * completed, or declined).
189
+ * @throws An error with code `'MAP_SHARE_NOT_FOUND'` if no share with the
190
+ * given `shareId` exists in the store.
185
191
  *
186
192
  * @example
187
193
  * ```tsx
@@ -210,12 +216,15 @@ export function useDownloadReceivedMapShare() {
210
216
  * share status will transition to `'canceled'` (not `'error'`) and the
211
217
  * mutation will throw a `MapShareCanceledError`.
212
218
  *
213
- * @throws {MapShareCanceledError} If the share is already known to be
214
- * canceled, or if the server reports that the sender canceled the share
215
- * while the decline was in flight. In both cases `share.status` will be
216
- * `'canceled'`.
217
- * @throws {InvalidStatusTransitionError} If the share is not in
218
- * `status='pending'` (e.g. already downloading, completed, or declined).
219
+ * @throws An error with code `'MAP_SHARE_CANCELED'` if the share is already
220
+ * known to be canceled, or if the server reports that the sender canceled
221
+ * the share while the decline was in flight. In both cases `share.status`
222
+ * will be `'canceled'`.
223
+ * @throws An error with code `'INVALID_STATUS_TRANSITION'` if the share is
224
+ * not in `status='pending'` (e.g. already downloading, completed, or
225
+ * declined).
226
+ * @throws An error with code `'MAP_SHARE_NOT_FOUND'` if no share with the
227
+ * given `shareId` exists in the store.
219
228
  *
220
229
  * @example
221
230
  * ```tsx
@@ -243,10 +252,15 @@ export function useDeclineReceivedMapShare() {
243
252
  /**
244
253
  * Abort an in-progress map share download.
245
254
  *
246
- * @throws {MapShareCanceledError} If the share is already known to be canceled.
247
- * @throws {InvalidStatusTransitionError} If the share is not in
248
- * `status='downloading'` (e.g. still pending, already completed, or
255
+ * @throws An error with code `'MAP_SHARE_CANCELED'` if the share is already
256
+ * known to be canceled.
257
+ * @throws An error with code `'INVALID_STATUS_TRANSITION'` if the share is
258
+ * not in `status='downloading'` (e.g. still pending, already completed, or
249
259
  * declined).
260
+ * @throws An error with code `'MAP_SHARE_NOT_FOUND'` if no share with the
261
+ * given `shareId` exists in the store.
262
+ * @throws An error with code `'DOWNLOAD_NOT_FOUND'` if no download is
263
+ * currently tracked for this share (e.g. the download was never started).
250
264
  *
251
265
  * @example
252
266
  * ```tsx
@@ -312,6 +326,12 @@ export function useSendMapShare() {
312
326
  * the share, the download will be canceled before completion. If the download
313
327
  * is already complete, this action will throw an error.
314
328
  *
329
+ * @throws An error with code `'INVALID_STATUS_TRANSITION'` if the share is
330
+ * not in `status='pending'` or `status='downloading'` (e.g. already
331
+ * completed, canceled, aborted, or declined).
332
+ * @throws An error with code `'MAP_SHARE_NOT_FOUND'` if no share with the
333
+ * given `shareId` exists in the store.
334
+ *
315
335
  * @param opts.projectId Public ID of project to request the map share cancellation for.
316
336
  *
317
337
  * @example
@@ -337,7 +357,8 @@ export function useCancelSentMapShare() {
337
357
  * of the share, updated in real-time. When the recipient starts downloading, or
338
358
  * if they decline the share, then the returned share will update.
339
359
  *
340
- * Throws if no share with the specified ID is found.
360
+ * @throws An error with code `'MAP_SHARE_NOT_FOUND'` if no sent share with
361
+ * the given `shareId` exists in the store.
341
362
  *
342
363
  * @param opts.shareId ID of the sent map share
343
364
  *
@@ -1,4 +1,4 @@
1
- import { DEFAULT_MAP_ID } from '@comapeo/map-server';
1
+ import { DEFAULT_MAP_ID } from '@comapeo/map-server/constants.js';
2
2
  // #region Shared
3
3
  const ROOT_QUERY_KEY = '@comapeo/core-react';
4
4
  // Since the API is running locally, queries should run regardless of network
package/docs/API.md CHANGED
@@ -1231,10 +1231,14 @@ function MapShareDetail({ shareId }: { shareId: string }) {
1231
1231
 
1232
1232
  Accept and download a map share that has been received. The mutate promise
1233
1233
  resolves once the map _starts_ downloading, before it finishes downloading.
1234
- Use `useManyMapShares` or `useSingleMapShare` to track download progress.
1234
+ Use `useManyReceivedMapShares` or `useSingleReceivedMapShare` to track
1235
+ download progress and final status.
1235
1236
 
1236
- Throws if the share is not in `status="pending"` or if the download fails to
1237
- start (e.g. if the shareId if invalid).
1237
+ If the sender canceled the share before the receiver calls this, the
1238
+ mutation will still resolve (the download starts), but the share status will
1239
+ end up as `'canceled'` rather than `'completed'`. This is the only way the
1240
+ receiver discovers that a share has been canceled — check `share.status`
1241
+ after the download settles.
1238
1242
 
1239
1243
  | Function | Type |
1240
1244
  | ---------- | ---------- |
@@ -1244,7 +1248,7 @@ Examples:
1244
1248
 
1245
1249
  ```tsx
1246
1250
  function AcceptButton({ shareId }: { shareId: string }) {
1247
- const { mutate: accept } = useAcceptMapShare()
1251
+ const { mutate: accept } = useDownloadReceivedMapShare()
1248
1252
 
1249
1253
  return <button onClick={() => accept({ shareId })}>Accept</button>
1250
1254
  }
@@ -1254,11 +1258,12 @@ function AcceptButton({ shareId }: { shareId: string }) {
1254
1258
  ### useDeclineReceivedMapShare
1255
1259
 
1256
1260
  Decline a map share that has been received. Notifies the sender that the
1257
- share was declined.
1261
+ share was declined. The share status is only updated to `'declined'` after
1262
+ the server confirms the decline — there is no optimistic update.
1258
1263
 
1259
- Throws if the share is not with `status="pending"`
1260
- Throws if shareId is invalid
1261
- Throws if decline request fails (e.g. network error)
1264
+ If the sender canceled the share before the decline reaches the server, the
1265
+ share status will transition to `'canceled'` (not `'error'`) and the
1266
+ mutation will throw a `MapShareCanceledError`.
1262
1267
 
1263
1268
  | Function | Type |
1264
1269
  | ---------- | ---------- |
@@ -1269,7 +1274,7 @@ Examples:
1269
1274
  ```tsx
1270
1275
  import { DeclineReason } from '@comapeo/core-react'
1271
1276
  function DeclineButton({ shareId }: { shareId: string }) {
1272
- const { mutate: decline } = useDeclineMapShare()
1277
+ const { mutate: decline } = useDeclineReceivedMapShare()
1273
1278
 
1274
1279
  return (
1275
1280
  <button onClick={() => decline({ shareId, reason: DeclineReason.user_rejected })}>
@@ -1284,9 +1289,6 @@ function DeclineButton({ shareId }: { shareId: string }) {
1284
1289
 
1285
1290
  Abort an in-progress map share download.
1286
1291
 
1287
- Throws if the share is not in `status="downloading"`
1288
- Throws if shareId is invalid
1289
-
1290
1292
  | Function | Type |
1291
1293
  | ---------- | ---------- |
1292
1294
  | `useAbortReceivedMapShareDownload` | `() => Pick<Override<MutationObserverIdleResult<void, Error, AbortMapShareOptions, unknown>, { mutate: UseMutateFunction<void, Error, AbortMapShareOptions, unknown>; }> and { ...; }, "error" or ... 3 more ... or "mutateAsync"> or Pick<...> or Pick<...> or Pick<...>` |
@@ -1295,7 +1297,7 @@ Examples:
1295
1297
 
1296
1298
  ```tsx
1297
1299
  function AbortButton({ shareId }: { shareId: string }) {
1298
- const { mutate: abort } = useAbortMapShareDownload()
1300
+ const { mutate: abort } = useAbortReceivedMapShareDownload()
1299
1301
 
1300
1302
  return <button onClick={() => abort({ shareId })}>Cancel Download</button>
1301
1303
  }
@@ -1370,8 +1372,6 @@ Track the status and progress of a sent map share. Returns the current state
1370
1372
  of the share, updated in real-time. When the recipient starts downloading, or
1371
1373
  if they decline the share, then the returned share will update.
1372
1374
 
1373
- Throws if no share with the specified ID is found.
1374
-
1375
1375
  | Function | Type |
1376
1376
  | ---------- | ---------- |
1377
1377
  | `useSingleSentMapShare` | `({ shareId, }: { shareId: string; }) => ServerMapShareState` |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@comapeo/core-react",
3
- "version": "11.0.0",
3
+ "version": "11.0.1",
4
4
  "description": "React wrapper for working with @comapeo/core",
5
5
  "repository": {
6
6
  "type": "git",