react-smart-copy 1.8.1 → 1.9.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/dist/index.js CHANGED
@@ -407,6 +407,17 @@ function createOperations() {
407
407
  };
408
408
  }
409
409
  //#endregion
410
+ //#region src/core/source-error.ts
411
+ /**
412
+ * The error for a user-supplied source (copy source, drag source, copy transform)
413
+ * that threw. A thrown `CopyFailure` keeps its classification, so a helper such as
414
+ * `tablePayload()` can report `too-large` instead of a generic `invalid-payload`.
415
+ * Internal: not part of the public API.
416
+ */
417
+ function sourceError(cause, message) {
418
+ return isCopyFailure(cause) ? cause.copyError : createCopyError("invalid-payload", message, cause);
419
+ }
420
+ //#endregion
410
421
  //#region src/core/copy-machine.ts
411
422
  const DEFAULT_RESET_AFTER_MS = 2e3;
412
423
  const IDLE_STATE = /* @__PURE__ */ Object.freeze({ status: "idle" });
@@ -509,7 +520,7 @@ function createCopyMachine(options = {}) {
509
520
  }
510
521
  payload = normalizePayload(resolved);
511
522
  } catch (cause) {
512
- const error = createCopyError("invalid-payload", "The copy source function threw.", cause);
523
+ const error = sourceError(cause, "The copy source function threw.");
513
524
  settleError(error, null, retryCount);
514
525
  return Promise.resolve({
515
526
  status: "error",
@@ -799,7 +810,7 @@ function interceptCopyEvent(event, options) {
799
810
  try {
800
811
  decision = options.transform(selection);
801
812
  } catch (cause) {
802
- return fail(createCopyError("invalid-payload", "The copy transform threw.", cause));
813
+ return fail(sourceError(cause, "The copy transform threw."));
803
814
  }
804
815
  if (decision === null || decision === void 0) return {
805
816
  status: "passed",
@@ -1006,7 +1017,7 @@ function applyDragCopy(event, options) {
1006
1017
  } catch (cause) {
1007
1018
  return {
1008
1019
  status: "failed",
1009
- error: createCopyError("invalid-payload", "The drag source threw.", cause)
1020
+ error: sourceError(cause, "The drag source threw.")
1010
1021
  };
1011
1022
  }
1012
1023
  if (decision === null || decision === void 0) return {