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/core.js CHANGED
@@ -404,6 +404,17 @@ function createOperations() {
404
404
  };
405
405
  }
406
406
  //#endregion
407
+ //#region src/core/source-error.ts
408
+ /**
409
+ * The error for a user-supplied source (copy source, drag source, copy transform)
410
+ * that threw. A thrown `CopyFailure` keeps its classification, so a helper such as
411
+ * `tablePayload()` can report `too-large` instead of a generic `invalid-payload`.
412
+ * Internal: not part of the public API.
413
+ */
414
+ function sourceError(cause, message) {
415
+ return isCopyFailure(cause) ? cause.copyError : createCopyError("invalid-payload", message, cause);
416
+ }
417
+ //#endregion
407
418
  //#region src/core/copy-machine.ts
408
419
  const DEFAULT_RESET_AFTER_MS = 2e3;
409
420
  const IDLE_STATE = /* @__PURE__ */ Object.freeze({ status: "idle" });
@@ -506,7 +517,7 @@ function createCopyMachine(options = {}) {
506
517
  }
507
518
  payload = normalizePayload(resolved);
508
519
  } catch (cause) {
509
- const error = createCopyError("invalid-payload", "The copy source function threw.", cause);
520
+ const error = sourceError(cause, "The copy source function threw.");
510
521
  settleError(error, null, retryCount);
511
522
  return Promise.resolve({
512
523
  status: "error",
@@ -796,7 +807,7 @@ function interceptCopyEvent(event, options) {
796
807
  try {
797
808
  decision = options.transform(selection);
798
809
  } catch (cause) {
799
- return fail(createCopyError("invalid-payload", "The copy transform threw.", cause));
810
+ return fail(sourceError(cause, "The copy transform threw."));
800
811
  }
801
812
  if (decision === null || decision === void 0) return {
802
813
  status: "passed",
@@ -1003,7 +1014,7 @@ function applyDragCopy(event, options) {
1003
1014
  } catch (cause) {
1004
1015
  return {
1005
1016
  status: "failed",
1006
- error: createCopyError("invalid-payload", "The drag source threw.", cause)
1017
+ error: sourceError(cause, "The drag source threw.")
1007
1018
  };
1008
1019
  }
1009
1020
  if (decision === null || decision === void 0) return {