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