react-smart-copy 1.17.1 → 1.18.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.
Files changed (146) hide show
  1. package/README.md +22 -3
  2. package/dist/capture.cjs +30 -153
  3. package/dist/capture.cjs.map +1 -1
  4. package/dist/capture.d.cts +2 -25
  5. package/dist/capture.d.ts +2 -25
  6. package/dist/capture.js +5 -128
  7. package/dist/capture.js.map +1 -1
  8. package/dist/chunks/clipboard-adapter-Cfz-rzw3.cjs +102 -0
  9. package/dist/chunks/clipboard-adapter-Cfz-rzw3.cjs.map +1 -0
  10. package/dist/chunks/clipboard-adapter-CtH4VELE.d.cts +43 -0
  11. package/dist/chunks/clipboard-adapter-DEXkXxwV.js +97 -0
  12. package/dist/chunks/clipboard-adapter-DEXkXxwV.js.map +1 -0
  13. package/dist/chunks/clipboard-adapter-Ds0irroN.d.ts +43 -0
  14. package/dist/chunks/contrast-C6CVklEI.cjs +842 -0
  15. package/dist/chunks/contrast-C6CVklEI.cjs.map +1 -0
  16. package/dist/chunks/contrast-DpK2JIVu.js +789 -0
  17. package/dist/chunks/contrast-DpK2JIVu.js.map +1 -0
  18. package/dist/chunks/copy-interceptor-C6NABy1l.d.ts +141 -0
  19. package/dist/chunks/copy-interceptor-CZWzGOkL.d.cts +141 -0
  20. package/dist/chunks/core-Cp2HSpaz.js +1035 -0
  21. package/dist/chunks/core-Cp2HSpaz.js.map +1 -0
  22. package/dist/chunks/core-DYf_Lhbe.cjs +1142 -0
  23. package/dist/chunks/core-DYf_Lhbe.cjs.map +1 -0
  24. package/dist/chunks/deadline-C29AlS_Q.js +46 -0
  25. package/dist/chunks/deadline-C29AlS_Q.js.map +1 -0
  26. package/dist/chunks/deadline-DkiB8ZHE.cjs +51 -0
  27. package/dist/chunks/deadline-DkiB8ZHE.cjs.map +1 -0
  28. package/dist/chunks/errors-9h8sdFFX.js +120 -0
  29. package/dist/chunks/errors-9h8sdFFX.js.map +1 -0
  30. package/dist/chunks/errors-BwOF6T_M.cjs +167 -0
  31. package/dist/chunks/errors-BwOF6T_M.cjs.map +1 -0
  32. package/dist/chunks/index-mr7sSAgP.d.ts +426 -0
  33. package/dist/chunks/index-vz0iW5V2.d.cts +426 -0
  34. package/dist/chunks/mime--LB7kdqG.cjs +153 -0
  35. package/dist/chunks/mime--LB7kdqG.cjs.map +1 -0
  36. package/dist/chunks/mime-aa-HA2dm.js +100 -0
  37. package/dist/chunks/mime-aa-HA2dm.js.map +1 -0
  38. package/dist/chunks/paste-adapter--SPL4PRE.d.cts +35 -0
  39. package/dist/chunks/paste-adapter-uahXnTYk.d.ts +35 -0
  40. package/dist/chunks/paste-reader-Bo01IMC_.cjs +289 -0
  41. package/dist/chunks/paste-reader-Bo01IMC_.cjs.map +1 -0
  42. package/dist/chunks/paste-reader-D9i7yMXF.js +224 -0
  43. package/dist/chunks/paste-reader-D9i7yMXF.js.map +1 -0
  44. package/dist/chunks/paste-reader-DcXnRWQr.d.cts +96 -0
  45. package/dist/chunks/paste-reader-DcXnRWQr.d.ts +96 -0
  46. package/dist/chunks/payload-CUymxwim.cjs +100 -0
  47. package/dist/chunks/payload-CUymxwim.cjs.map +1 -0
  48. package/dist/chunks/payload-CcwKJ_bU.d.cts +162 -0
  49. package/dist/chunks/payload-Cl_8hCI5.d.ts +162 -0
  50. package/dist/chunks/payload-DGw-JOo7.js +71 -0
  51. package/dist/chunks/payload-DGw-JOo7.js.map +1 -0
  52. package/dist/chunks/payload-DI5AorDz.js +103 -0
  53. package/dist/chunks/payload-DI5AorDz.js.map +1 -0
  54. package/dist/chunks/payload-J6GjHuh3.cjs +132 -0
  55. package/dist/chunks/payload-J6GjHuh3.cjs.map +1 -0
  56. package/dist/chunks/share-Bop47Znn.js +208 -0
  57. package/dist/chunks/share-Bop47Znn.js.map +1 -0
  58. package/dist/chunks/share-C0esXvRK.d.cts +115 -0
  59. package/dist/chunks/share-ayDz974N.cjs +231 -0
  60. package/dist/chunks/share-ayDz974N.cjs.map +1 -0
  61. package/dist/chunks/share-e7FenIr2.d.ts +115 -0
  62. package/dist/chunks/text-field-Ba8W3v4R.cjs +77 -0
  63. package/dist/chunks/text-field-Ba8W3v4R.cjs.map +1 -0
  64. package/dist/chunks/text-field-C0SGmvvR.d.cts +18 -0
  65. package/dist/chunks/text-field-C0SGmvvR.d.ts +18 -0
  66. package/dist/chunks/text-field-DUvrMMaK.js +66 -0
  67. package/dist/chunks/text-field-DUvrMMaK.js.map +1 -0
  68. package/dist/chunks/url-BcMYVCXQ.js +135 -0
  69. package/dist/chunks/url-BcMYVCXQ.js.map +1 -0
  70. package/dist/chunks/url-D4PGsRm8.cjs +164 -0
  71. package/dist/chunks/url-D4PGsRm8.cjs.map +1 -0
  72. package/dist/chunks/url-DWdElCT3.d.cts +43 -0
  73. package/dist/chunks/url-DWdElCT3.d.ts +43 -0
  74. package/dist/code.cjs +20 -109
  75. package/dist/code.cjs.map +1 -1
  76. package/dist/code.d.cts +4 -28
  77. package/dist/code.d.ts +4 -28
  78. package/dist/code.js +4 -93
  79. package/dist/code.js.map +1 -1
  80. package/dist/color.cjs +21 -893
  81. package/dist/color.cjs.map +1 -1
  82. package/dist/color.d.cts +4 -28
  83. package/dist/color.d.ts +4 -28
  84. package/dist/color.js +4 -876
  85. package/dist/color.js.map +1 -1
  86. package/dist/core.cjs +52 -1659
  87. package/dist/core.d.cts +8 -878
  88. package/dist/core.d.ts +8 -878
  89. package/dist/core.js +7 -1614
  90. package/dist/image.cjs +23 -91
  91. package/dist/image.cjs.map +1 -1
  92. package/dist/image.d.cts +1 -0
  93. package/dist/image.d.ts +1 -0
  94. package/dist/image.js +5 -73
  95. package/dist/image.js.map +1 -1
  96. package/dist/index.cjs +74 -2072
  97. package/dist/index.cjs.map +1 -1
  98. package/dist/index.d.cts +8 -978
  99. package/dist/index.d.ts +8 -978
  100. package/dist/index.js +7 -2005
  101. package/dist/index.js.map +1 -1
  102. package/dist/link.cjs +24 -338
  103. package/dist/link.cjs.map +1 -1
  104. package/dist/link.d.cts +5 -83
  105. package/dist/link.d.ts +5 -83
  106. package/dist/link.js +5 -319
  107. package/dist/link.js.map +1 -1
  108. package/dist/markdown.cjs +8 -97
  109. package/dist/markdown.cjs.map +1 -1
  110. package/dist/markdown.d.cts +3 -16
  111. package/dist/markdown.d.ts +3 -16
  112. package/dist/markdown.js +3 -92
  113. package/dist/markdown.js.map +1 -1
  114. package/dist/rich.cjs +26 -934
  115. package/dist/rich.cjs.map +1 -1
  116. package/dist/rich.d.cts +4 -90
  117. package/dist/rich.d.ts +4 -90
  118. package/dist/rich.js +4 -912
  119. package/dist/rich.js.map +1 -1
  120. package/dist/share.cjs +5 -640
  121. package/dist/share.d.cts +3 -248
  122. package/dist/share.d.ts +3 -248
  123. package/dist/share.js +1 -637
  124. package/dist/structured.cjs +13 -95
  125. package/dist/structured.cjs.map +1 -1
  126. package/dist/structured.d.cts +2 -11
  127. package/dist/structured.d.ts +2 -11
  128. package/dist/structured.js +4 -86
  129. package/dist/structured.js.map +1 -1
  130. package/dist/table.cjs +11 -39
  131. package/dist/table.cjs.map +1 -1
  132. package/dist/table.d.cts +2 -12
  133. package/dist/table.d.ts +2 -12
  134. package/dist/table.js +2 -30
  135. package/dist/table.js.map +1 -1
  136. package/dist/testing.cjs +10 -43
  137. package/dist/testing.cjs.map +1 -1
  138. package/dist/testing.d.cts +6 -181
  139. package/dist/testing.d.ts +6 -181
  140. package/dist/testing.js +3 -36
  141. package/dist/testing.js.map +1 -1
  142. package/package.json +20 -2
  143. package/dist/core.cjs.map +0 -1
  144. package/dist/core.js.map +0 -1
  145. package/dist/share.cjs.map +0 -1
  146. package/dist/share.js.map +0 -1
@@ -0,0 +1,167 @@
1
+
2
+ //#region src/core/errors.ts
3
+ function createCopyError(type, message, cause) {
4
+ return cause === void 0 ? {
5
+ type,
6
+ message
7
+ } : {
8
+ type,
9
+ message,
10
+ cause
11
+ };
12
+ }
13
+ const RETRYABLE_ERRORS = /* @__PURE__ */ new Set([
14
+ "permission-denied",
15
+ "not-focused",
16
+ "blob-generation-failed",
17
+ "timeout",
18
+ "unknown"
19
+ ]);
20
+ /** Whether retrying the same payload could plausibly succeed. */
21
+ function isRetryableError(error) {
22
+ return RETRYABLE_ERRORS.has(error.type);
23
+ }
24
+ /**
25
+ * Branded (not `instanceof`) so failures stay recognisable even when the core
26
+ * is bundled twice, e.g. `react-smart-copy` and `react-smart-copy/core` together.
27
+ */
28
+ const COPY_FAILURE_BRAND = Symbol.for("react-smart-copy.CopyFailure");
29
+ /** Error thrown by adapters to carry a fully classified {@link CopyError}. */
30
+ var CopyFailure = class extends Error {
31
+ constructor(copyError) {
32
+ super(copyError.message);
33
+ this[COPY_FAILURE_BRAND] = true;
34
+ this.name = "CopyFailure";
35
+ this.copyError = copyError;
36
+ }
37
+ };
38
+ function isCopyFailure(value) {
39
+ return typeof value === "object" && value !== null && value[COPY_FAILURE_BRAND] === true;
40
+ }
41
+ /** Shorthand for throwing a classified failure. */
42
+ function copyFailure(type, message, cause) {
43
+ return new CopyFailure(createCopyError(type, message, cause));
44
+ }
45
+ function readString(value, key) {
46
+ if (typeof value !== "object" || value === null) return void 0;
47
+ const field = value[key];
48
+ return typeof field === "string" ? field : void 0;
49
+ }
50
+ /**
51
+ * Classifies anything thrown by the platform or an adapter into a {@link CopyError}.
52
+ * `operation` only tailors the developer-facing message.
53
+ */
54
+ function toCopyError(cause, operation = "write") {
55
+ if (isCopyFailure(cause)) return cause.copyError;
56
+ const name = readString(cause, "name");
57
+ const message = readString(cause, "message") ?? "";
58
+ const verb = operation === "read" ? "read" : "write";
59
+ switch (name) {
60
+ case "NotAllowedError": return /focus/i.test(message) ? createCopyError("not-focused", `The document was not focused during the clipboard ${verb}.`, cause) : createCopyError("permission-denied", `Clipboard ${verb} permission was denied.`, cause);
61
+ case "SecurityError": return createCopyError("insecure-context", "The clipboard is blocked in this context.", cause);
62
+ case "NotSupportedError":
63
+ case "DataError": return createCopyError("unsupported-format", "The browser rejected this clipboard format.", cause);
64
+ case "AbortError": return createCopyError("aborted", `The clipboard ${verb} was aborted.`, cause);
65
+ case "TimeoutError": return createCopyError("timeout", `The clipboard ${verb} timed out.`, cause);
66
+ default: return createCopyError("unknown", message || `The clipboard ${verb} failed for an unknown reason.`, cause);
67
+ }
68
+ }
69
+ const COPY_DESCRIPTIONS = {
70
+ unsupported: "Copying isn't supported in this browser.",
71
+ "insecure-context": "Copying requires a secure (HTTPS) connection.",
72
+ "permission-denied": "Clipboard access was blocked. Allow it and try again.",
73
+ "not-focused": "The page lost focus while copying. Try again.",
74
+ "invalid-payload": "There is nothing to copy.",
75
+ "unsupported-format": "This content can't be copied in this browser.",
76
+ "blob-generation-failed": "The image couldn't be prepared for copying.",
77
+ "max-retries-exceeded": "Copying failed after several attempts.",
78
+ "no-content": "There is nothing to copy.",
79
+ "too-large": "This content is too large to copy.",
80
+ timeout: "Copying took too long. Try again.",
81
+ aborted: "Copying was cancelled.",
82
+ unknown: "Couldn't copy to the clipboard. Try again."
83
+ };
84
+ const PASTE_DESCRIPTIONS = {
85
+ unsupported: "Pasting isn't supported in this browser.",
86
+ "insecure-context": "Pasting requires a secure (HTTPS) connection.",
87
+ "permission-denied": "Clipboard access was blocked. Allow it and try again.",
88
+ "not-focused": "The page lost focus while pasting. Try again.",
89
+ "invalid-payload": "The clipboard content couldn't be read.",
90
+ "unsupported-format": "This clipboard content isn't supported here.",
91
+ "blob-generation-failed": "The pasted image couldn't be read.",
92
+ "max-retries-exceeded": "Pasting failed after several attempts.",
93
+ "no-content": "The clipboard doesn't contain anything that can be pasted here.",
94
+ "too-large": "The clipboard content is too large to paste.",
95
+ timeout: "Pasting took too long. Try again.",
96
+ aborted: "Pasting was cancelled.",
97
+ unknown: "Couldn't read the clipboard. Try again."
98
+ };
99
+ /** Default English, user-facing sentence for a copy error. Replace for i18n. */
100
+ function describeCopyError(error) {
101
+ return COPY_DESCRIPTIONS[error.type];
102
+ }
103
+ /** Drops can only fail in these ways; the rest of the paste wording would mention the clipboard. */
104
+ const DROP_DESCRIPTIONS = {
105
+ "invalid-payload": "The dropped content couldn't be read.",
106
+ "no-content": "Nothing that was dropped can be used here.",
107
+ "too-large": "The dropped content is too large.",
108
+ unknown: "Couldn't read the dropped content. Try again."
109
+ };
110
+ /**
111
+ * Default English, user-facing sentence for a paste error. Pass the error
112
+ * state's `source` to word drag-and-drop failures as drops. Replace for i18n.
113
+ */
114
+ function describePasteError(error, source) {
115
+ return (source === "drop" ? DROP_DESCRIPTIONS[error.type] : void 0) ?? PASTE_DESCRIPTIONS[error.type];
116
+ }
117
+ //#endregion
118
+ Object.defineProperty(exports, "CopyFailure", {
119
+ enumerable: true,
120
+ get: function() {
121
+ return CopyFailure;
122
+ }
123
+ });
124
+ Object.defineProperty(exports, "copyFailure", {
125
+ enumerable: true,
126
+ get: function() {
127
+ return copyFailure;
128
+ }
129
+ });
130
+ Object.defineProperty(exports, "createCopyError", {
131
+ enumerable: true,
132
+ get: function() {
133
+ return createCopyError;
134
+ }
135
+ });
136
+ Object.defineProperty(exports, "describeCopyError", {
137
+ enumerable: true,
138
+ get: function() {
139
+ return describeCopyError;
140
+ }
141
+ });
142
+ Object.defineProperty(exports, "describePasteError", {
143
+ enumerable: true,
144
+ get: function() {
145
+ return describePasteError;
146
+ }
147
+ });
148
+ Object.defineProperty(exports, "isCopyFailure", {
149
+ enumerable: true,
150
+ get: function() {
151
+ return isCopyFailure;
152
+ }
153
+ });
154
+ Object.defineProperty(exports, "isRetryableError", {
155
+ enumerable: true,
156
+ get: function() {
157
+ return isRetryableError;
158
+ }
159
+ });
160
+ Object.defineProperty(exports, "toCopyError", {
161
+ enumerable: true,
162
+ get: function() {
163
+ return toCopyError;
164
+ }
165
+ });
166
+
167
+ //# sourceMappingURL=errors-BwOF6T_M.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors-BwOF6T_M.cjs","names":[],"sources":["../../src/core/errors.ts"],"sourcesContent":["import type { PasteSource } from './paste-reader';\n\n/**\n * Every way a clipboard operation can fail, as a closed union.\n *\n * `CopyError.message` is developer-facing (logs, telemetry). For user-facing\n * text use {@link describeCopyError} / {@link describePasteError}, or map\n * `type` through your own i18n layer.\n */\nexport type CopyErrorType =\n /** No Clipboard API (old browser, server, locked-down webview). Not retryable. */\n | 'unsupported'\n /** Page is not served over HTTPS/localhost. Not retryable. */\n | 'insecure-context'\n /** Browser or user blocked the operation. Also what Safari reports for a missing user gesture. */\n | 'permission-denied'\n /** The document lost focus mid-operation (Chromium). Retrying after refocus usually works. */\n | 'not-focused'\n /** Empty or malformed payload, or a lazy source that threw. Caught before touching the clipboard. */\n | 'invalid-payload'\n /** The browser cannot handle this MIME type (e.g. non-PNG image, HTML without ClipboardItem). */\n | 'unsupported-format'\n /** A lazy image source (or capture) threw, rejected or did not produce a Blob. */\n | 'blob-generation-failed'\n /** `retry()` was called after `maxRetries` was reached. Terminal. */\n | 'max-retries-exceeded'\n /** Paste: the clipboard held nothing matching `accept`. */\n | 'no-content'\n /** Content exceeded a configured safety limit (bytes, items or pixels). Not retryable. */\n | 'too-large'\n /** An operation did not settle within its deadline. Retryable. */\n | 'timeout'\n /** The caller aborted the operation through an `AbortSignal`. Not retryable. */\n | 'aborted'\n /** Anything the platform threw that we could not classify. */\n | 'unknown';\n\n/** Which clipboard direction failed; only changes developer-facing messages. */\nexport type ClipboardOperation = 'write' | 'read';\n\nexport interface CopyError {\n readonly type: CopyErrorType;\n readonly message: string;\n readonly cause?: unknown;\n}\n\nexport function createCopyError(type: CopyErrorType, message: string, cause?: unknown): CopyError {\n return cause === undefined ? { type, message } : { type, message, cause };\n}\n\nconst RETRYABLE_ERRORS: ReadonlySet<CopyErrorType> = /* @__PURE__ */ new Set<CopyErrorType>([\n 'permission-denied',\n 'not-focused',\n 'blob-generation-failed',\n 'timeout',\n 'unknown',\n]);\n\n/** Whether retrying the same payload could plausibly succeed. */\nexport function isRetryableError(error: CopyError): boolean {\n return RETRYABLE_ERRORS.has(error.type);\n}\n\n/**\n * Branded (not `instanceof`) so failures stay recognisable even when the core\n * is bundled twice, e.g. `react-smart-copy` and `react-smart-copy/core` together.\n */\nconst COPY_FAILURE_BRAND = Symbol.for('react-smart-copy.CopyFailure');\n\n/** Error thrown by adapters to carry a fully classified {@link CopyError}. */\nexport class CopyFailure extends Error {\n readonly copyError: CopyError;\n readonly [COPY_FAILURE_BRAND] = true;\n\n constructor(copyError: CopyError) {\n super(copyError.message);\n this.name = 'CopyFailure';\n this.copyError = copyError;\n }\n}\n\nexport function isCopyFailure(value: unknown): value is CopyFailure {\n return (\n typeof value === 'object' &&\n value !== null &&\n (value as Record<PropertyKey, unknown>)[COPY_FAILURE_BRAND] === true\n );\n}\n\n/** Shorthand for throwing a classified failure. */\nexport function copyFailure(type: CopyErrorType, message: string, cause?: unknown): CopyFailure {\n return new CopyFailure(createCopyError(type, message, cause));\n}\n\nfunction readString(value: unknown, key: string): string | undefined {\n if (typeof value !== 'object' || value === null) return undefined;\n const field = (value as Record<string, unknown>)[key];\n return typeof field === 'string' ? field : undefined;\n}\n\n/**\n * Classifies anything thrown by the platform or an adapter into a {@link CopyError}.\n * `operation` only tailors the developer-facing message.\n */\nexport function toCopyError(cause: unknown, operation: ClipboardOperation = 'write'): CopyError {\n if (isCopyFailure(cause)) return cause.copyError;\n\n const name = readString(cause, 'name');\n const message = readString(cause, 'message') ?? '';\n const verb = operation === 'read' ? 'read' : 'write';\n\n switch (name) {\n case 'NotAllowedError':\n return /focus/i.test(message)\n ? createCopyError('not-focused', `The document was not focused during the clipboard ${verb}.`, cause)\n : createCopyError('permission-denied', `Clipboard ${verb} permission was denied.`, cause);\n case 'SecurityError':\n return createCopyError('insecure-context', 'The clipboard is blocked in this context.', cause);\n case 'NotSupportedError':\n case 'DataError':\n return createCopyError('unsupported-format', 'The browser rejected this clipboard format.', cause);\n case 'AbortError':\n return createCopyError('aborted', `The clipboard ${verb} was aborted.`, cause);\n case 'TimeoutError':\n return createCopyError('timeout', `The clipboard ${verb} timed out.`, cause);\n default:\n return createCopyError('unknown', message || `The clipboard ${verb} failed for an unknown reason.`, cause);\n }\n}\n\nconst COPY_DESCRIPTIONS: Readonly<Record<CopyErrorType, string>> = {\n unsupported: \"Copying isn't supported in this browser.\",\n 'insecure-context': 'Copying requires a secure (HTTPS) connection.',\n 'permission-denied': 'Clipboard access was blocked. Allow it and try again.',\n 'not-focused': 'The page lost focus while copying. Try again.',\n 'invalid-payload': 'There is nothing to copy.',\n 'unsupported-format': \"This content can't be copied in this browser.\",\n 'blob-generation-failed': \"The image couldn't be prepared for copying.\",\n 'max-retries-exceeded': 'Copying failed after several attempts.',\n 'no-content': 'There is nothing to copy.',\n 'too-large': 'This content is too large to copy.',\n timeout: 'Copying took too long. Try again.',\n aborted: 'Copying was cancelled.',\n unknown: \"Couldn't copy to the clipboard. Try again.\",\n};\n\nconst PASTE_DESCRIPTIONS: Readonly<Record<CopyErrorType, string>> = {\n unsupported: \"Pasting isn't supported in this browser.\",\n 'insecure-context': 'Pasting requires a secure (HTTPS) connection.',\n 'permission-denied': 'Clipboard access was blocked. Allow it and try again.',\n 'not-focused': 'The page lost focus while pasting. Try again.',\n 'invalid-payload': \"The clipboard content couldn't be read.\",\n 'unsupported-format': \"This clipboard content isn't supported here.\",\n 'blob-generation-failed': \"The pasted image couldn't be read.\",\n 'max-retries-exceeded': 'Pasting failed after several attempts.',\n 'no-content': \"The clipboard doesn't contain anything that can be pasted here.\",\n 'too-large': 'The clipboard content is too large to paste.',\n timeout: 'Pasting took too long. Try again.',\n aborted: 'Pasting was cancelled.',\n unknown: \"Couldn't read the clipboard. Try again.\",\n};\n\n/** Default English, user-facing sentence for a copy error. Replace for i18n. */\nexport function describeCopyError(error: CopyError): string {\n return COPY_DESCRIPTIONS[error.type];\n}\n\n/** Drops can only fail in these ways; the rest of the paste wording would mention the clipboard. */\nconst DROP_DESCRIPTIONS: Readonly<Partial<Record<CopyErrorType, string>>> = {\n 'invalid-payload': \"The dropped content couldn't be read.\",\n 'no-content': 'Nothing that was dropped can be used here.',\n 'too-large': 'The dropped content is too large.',\n unknown: \"Couldn't read the dropped content. Try again.\",\n};\n\n/**\n * Default English, user-facing sentence for a paste error. Pass the error\n * state's `source` to word drag-and-drop failures as drops. Replace for i18n.\n */\nexport function describePasteError(error: CopyError, source?: PasteSource): string {\n return (source === 'drop' ? DROP_DESCRIPTIONS[error.type] : undefined) ?? PASTE_DESCRIPTIONS[error.type];\n}\n"],"mappings":";;AA8CA,SAAgB,gBAAgB,MAAqB,SAAiB,OAA4B;CAChG,OAAO,UAAU,KAAA,IAAY;EAAE;EAAM;CAAQ,IAAI;EAAE;EAAM;EAAS;CAAM;AAC1E;AAEA,MAAM,mCAA+D,IAAI,IAAmB;CAC1F;CACA;CACA;CACA;CACA;AACF,CAAC;;AAGD,SAAgB,iBAAiB,OAA2B;CAC1D,OAAO,iBAAiB,IAAI,MAAM,IAAI;AACxC;;;;;AAMA,MAAM,qBAAqB,OAAO,IAAI,8BAA8B;;AAGpE,IAAa,cAAb,cAAiC,MAAM;CAIrC,YAAY,WAAsB;EAChC,MAAM,UAAU,OAAO;EAHzB,KAAU,sBAAsB;EAI9B,KAAK,OAAO;EACZ,KAAK,YAAY;CACnB;AACF;AAEA,SAAgB,cAAc,OAAsC;CAClE,OACE,OAAO,UAAU,YACjB,UAAU,QACT,MAAuC,wBAAwB;AAEpE;;AAGA,SAAgB,YAAY,MAAqB,SAAiB,OAA8B;CAC9F,OAAO,IAAI,YAAY,gBAAgB,MAAM,SAAS,KAAK,CAAC;AAC9D;AAEA,SAAS,WAAW,OAAgB,KAAiC;CACnE,IAAI,OAAO,UAAU,YAAY,UAAU,MAAM,OAAO,KAAA;CACxD,MAAM,QAAS,MAAkC;CACjD,OAAO,OAAO,UAAU,WAAW,QAAQ,KAAA;AAC7C;;;;;AAMA,SAAgB,YAAY,OAAgB,YAAgC,SAAoB;CAC9F,IAAI,cAAc,KAAK,GAAG,OAAO,MAAM;CAEvC,MAAM,OAAO,WAAW,OAAO,MAAM;CACrC,MAAM,UAAU,WAAW,OAAO,SAAS,KAAK;CAChD,MAAM,OAAO,cAAc,SAAS,SAAS;CAE7C,QAAQ,MAAR;EACE,KAAK,mBACH,OAAO,SAAS,KAAK,OAAO,IACxB,gBAAgB,eAAe,qDAAqD,KAAK,IAAI,KAAK,IAClG,gBAAgB,qBAAqB,aAAa,KAAK,0BAA0B,KAAK;EAC5F,KAAK,iBACH,OAAO,gBAAgB,oBAAoB,6CAA6C,KAAK;EAC/F,KAAK;EACL,KAAK,aACH,OAAO,gBAAgB,sBAAsB,+CAA+C,KAAK;EACnG,KAAK,cACH,OAAO,gBAAgB,WAAW,iBAAiB,KAAK,gBAAgB,KAAK;EAC/E,KAAK,gBACH,OAAO,gBAAgB,WAAW,iBAAiB,KAAK,cAAc,KAAK;EAC7E,SACE,OAAO,gBAAgB,WAAW,WAAW,iBAAiB,KAAK,iCAAiC,KAAK;CAC7G;AACF;AAEA,MAAM,oBAA6D;CACjE,aAAa;CACb,oBAAoB;CACpB,qBAAqB;CACrB,eAAe;CACf,mBAAmB;CACnB,sBAAsB;CACtB,0BAA0B;CAC1B,wBAAwB;CACxB,cAAc;CACd,aAAa;CACb,SAAS;CACT,SAAS;CACT,SAAS;AACX;AAEA,MAAM,qBAA8D;CAClE,aAAa;CACb,oBAAoB;CACpB,qBAAqB;CACrB,eAAe;CACf,mBAAmB;CACnB,sBAAsB;CACtB,0BAA0B;CAC1B,wBAAwB;CACxB,cAAc;CACd,aAAa;CACb,SAAS;CACT,SAAS;CACT,SAAS;AACX;;AAGA,SAAgB,kBAAkB,OAA0B;CAC1D,OAAO,kBAAkB,MAAM;AACjC;;AAGA,MAAM,oBAAsE;CAC1E,mBAAmB;CACnB,cAAc;CACd,aAAa;CACb,SAAS;AACX;;;;;AAMA,SAAgB,mBAAmB,OAAkB,QAA8B;CACjF,QAAQ,WAAW,SAAS,kBAAkB,MAAM,QAAQ,KAAA,MAAc,mBAAmB,MAAM;AACrG"}
@@ -0,0 +1,426 @@
1
+
2
+ import { a as CopySource, f as TextPayload, l as JsonPayload, o as HtmlPayload, r as CopyPayload, v as CopyError } from "./payload-Cl_8hCI5.js";
3
+ import { d as PasteReadOptions, m as PasteSource, o as DataTransferLike$1, p as PasteResult } from "./paste-reader-DcXnRWQr.js";
4
+ import { n as ClipboardAdapter } from "./clipboard-adapter-Ds0irroN.js";
5
+ import { n as PasteAdapter } from "./paste-adapter-uahXnTYk.js";
6
+ //#region src/core/mime.d.ts
7
+ /**
8
+ * MIME helpers shared by paste and capture. Everything that comes from the
9
+ * clipboard is untrusted input, so types are normalised and validated before
10
+ * they are compared, and image types are confirmed from the bytes themselves.
11
+ */
12
+ /** SVG is XML that can carry scripts; it is never matched by a wildcard. */
13
+ declare const SVG_MIME_TYPE = "image/svg+xml";
14
+ /** Lower-cased `type/subtype` without parameters, or `null` if it is not a valid MIME type. */
15
+ declare function normalizeMimeType(value: string): string | null;
16
+ /** Prefix of the async Clipboard API's web custom formats (`web application/vnd.acme+json`). */
17
+ declare const WEB_CUSTOM_FORMAT_PREFIX = "web ";
18
+ /** Whether a clipboard type is a web custom format (`web type/subtype`). */
19
+ declare function isWebCustomFormat(type: string): boolean;
20
+ /**
21
+ * Like {@link normalizeMimeType}, but also accepts web custom formats
22
+ * (`web type/subtype`), returned as `web ` + the normalised MIME type.
23
+ */
24
+ declare function normalizeClipboardType(value: string): string | null;
25
+ /**
26
+ * Does `mimeType` (already normalised) match `pattern` (`type/subtype`, `type/*` or `*\/*`)?
27
+ * Wildcards never match `image/svg+xml`, web custom formats or `+json` types: those must be listed exactly.
28
+ */
29
+ declare function matchesMimePattern(mimeType: string, pattern: string): boolean;
30
+ /** Types whose clipboard data is text and is therefore surfaced as a `string`. */
31
+ declare function isTextualMimeType(mimeType: string): boolean;
32
+ /** Raster image formats recognised from their leading bytes. */
33
+ type RasterImageMimeType = 'image/png' | 'image/jpeg' | 'image/gif' | 'image/webp' | 'image/bmp' | 'image/avif';
34
+ /** Identifies a raster image from its magic bytes, ignoring whatever type the Blob claims. */
35
+ declare function sniffImageBytes(bytes: Uint8Array): RasterImageMimeType | null;
36
+ /** Reads only the first bytes of a Blob, so sniffing a 20 MB screenshot stays cheap. */
37
+ declare function sniffImageType(blob: Blob): Promise<RasterImageMimeType | null>;
38
+ //#endregion
39
+ //#region src/core/copy-coordinator.d.ts
40
+ /**
41
+ * A copy machine as seen by a coordinator. `release()` returns it from
42
+ * `copied` to `idle`; it is a no-op in any other state.
43
+ */
44
+ interface CopyCoordinatorMember {
45
+ readonly release: () => void;
46
+ }
47
+ /**
48
+ * Makes a set of copy machines behave like one clipboard: when a member
49
+ * succeeds, the member that previously showed "Copied" goes back to idle,
50
+ * because the clipboard no longer holds its value.
51
+ *
52
+ * Failed copies never release anyone (the clipboard still holds the previous value).
53
+ */
54
+ interface CopyCoordinator {
55
+ /** A member just reached `copied`. Releases the previous one. */
56
+ readonly activate: (member: CopyCoordinatorMember) => void;
57
+ /** A member left `copied` on its own (auto-reset, reset, unmount). */
58
+ readonly deactivate: (member: CopyCoordinatorMember) => void;
59
+ /** The member currently showing `copied`, if any. */
60
+ readonly getActive: () => CopyCoordinatorMember | null;
61
+ }
62
+ declare function createCopyCoordinator(): CopyCoordinator;
63
+ //#endregion
64
+ //#region src/core/copy-machine.d.ts
65
+ declare const DEFAULT_RESET_AFTER_MS = 2000;
66
+ interface IdleState {
67
+ readonly status: 'idle';
68
+ }
69
+ interface CopyingState {
70
+ readonly status: 'copying';
71
+ readonly payload: CopyPayload;
72
+ readonly retryCount: number;
73
+ }
74
+ interface CopiedState {
75
+ readonly status: 'copied';
76
+ readonly payload: CopyPayload;
77
+ /** Epoch ms when the write resolved. */
78
+ readonly at: number;
79
+ }
80
+ interface ErrorState {
81
+ readonly status: 'error';
82
+ /** `null` when the input itself could not be resolved. */
83
+ readonly payload: CopyPayload | null;
84
+ readonly error: CopyError;
85
+ readonly retryCount: number;
86
+ }
87
+ type CopyState = IdleState | CopyingState | CopiedState | ErrorState;
88
+ type CopyStatus = CopyState['status'];
89
+ /**
90
+ * `cancelled`: the copy was reset or its host unmounted before it finished,
91
+ * so its work was aborted. Nothing to report to the user.
92
+ */
93
+ type CopyIgnoredReason = 'in-flight' | 'nothing-to-retry' | 'not-retryable' | 'cancelled';
94
+ /**
95
+ * Why an in-flight copy was cancelled: `reset` (`reset()` was called) or
96
+ * `disconnect` (its host disconnected, e.g. the React component unmounted).
97
+ */
98
+ type CopyCancelReason = 'reset' | 'disconnect';
99
+ /** What `copy()`/`retry()` resolve to. They never reject. */
100
+ type CopyOutcome = {
101
+ readonly status: 'copied';
102
+ readonly payload: CopyPayload;
103
+ } | {
104
+ readonly status: 'error';
105
+ readonly error: CopyError;
106
+ } | {
107
+ readonly status: 'ignored';
108
+ readonly reason: CopyIgnoredReason;
109
+ };
110
+ interface CopyMachineOptions {
111
+ /** Defaults to the browser Clipboard API adapter. */
112
+ readonly adapter?: ClipboardAdapter;
113
+ /** Time in `copied` before returning to `idle`. `false`/`Infinity` disables. Default 2000. */
114
+ readonly resetAfterMs?: number | false;
115
+ /**
116
+ * Max `retry()` calls after the first failure. Default 3. `0` disables
117
+ * retry; `Infinity` allows unlimited retries.
118
+ */
119
+ readonly maxRetries?: number;
120
+ /**
121
+ * Share "Copied" with other machines: only one member of a coordinator
122
+ * shows `copied` at a time. `null` explicitly opts out (e.g. of a React `<CopyGroup>`).
123
+ */
124
+ readonly coordinator?: CopyCoordinator | null;
125
+ readonly onCopy?: (payload: CopyPayload) => void;
126
+ readonly onError?: (error: CopyError, payload: CopyPayload | null) => void;
127
+ /**
128
+ * `reset()` moved the machine back to `idle` from any other state. Not
129
+ * called for the automatic return after `resetAfterMs`, for a `<CopyGroup>`
130
+ * handing "Copied" to another member, or when already `idle`.
131
+ */
132
+ readonly onReset?: () => void;
133
+ /**
134
+ * A copy in flight was cancelled before it settled: its `signal` aborted
135
+ * and its result will not reach state or `onCopy` / `onError`. Fires
136
+ * before `onReset` when `reset()` cancels a copy.
137
+ */
138
+ readonly onCancel?: (reason: CopyCancelReason) => void;
139
+ /** Clock injection for tests and deterministic environments. */
140
+ readonly now?: () => number;
141
+ }
142
+ /** Options object, or a getter so hosts (like React) can supply the latest options. */
143
+ type CopyMachineOptionsSource = CopyMachineOptions | (() => CopyMachineOptions);
144
+ interface CopyMachine {
145
+ readonly getSnapshot: () => CopyState;
146
+ readonly subscribe: (listener: () => void) => () => void;
147
+ readonly copy: (source: CopySource) => Promise<CopyOutcome>;
148
+ readonly retry: () => Promise<CopyOutcome>;
149
+ /** Back to `idle`. Discards any in-flight result and aborts its `signal`. */
150
+ readonly reset: () => void;
151
+ /**
152
+ * Lifecycle hook for hosts. Re-arms a pending auto-reset; the returned
153
+ * cleanup clears timers, drops in-flight results, aborts in-flight work and
154
+ * unsticks `copying`.
155
+ * Safe to call repeatedly (React StrictMode).
156
+ */
157
+ readonly connect: () => () => void;
158
+ }
159
+ declare const IDLE_STATE: IdleState;
160
+ /** Pure helper: can `retry()` do anything from this state? */
161
+ declare function canRetryState(state: CopyState, maxRetries?: number): boolean;
162
+ /** Framework-agnostic copy state machine. */
163
+ declare function createCopyMachine(options?: CopyMachineOptionsSource): CopyMachine;
164
+ //#endregion
165
+ //#region src/core/drag-copy.d.ts
166
+ /**
167
+ * The `effectAllowed` a drag operation advertises. Controls which cursor the
168
+ * browser shows and which `dropEffect` the drop target may request.
169
+ *
170
+ * - `'copy'` (default): dragging produces a copy of the data.
171
+ * - `'move'`: dragging removes the source after a drop (the app must do this).
172
+ * - `'link'`: dragging creates a link/reference.
173
+ * - `'copyMove'` / `'copyLink'` / `'linkMove'` / `'all'`: combinations.
174
+ * - `'none'`: the drag is not droppable anywhere.
175
+ * - `'uninitialized'`: browser default (same as `'all'` in most cases).
176
+ */
177
+ type DragEffectAllowed = 'copy' | 'move' | 'link' | 'copyMove' | 'copyLink' | 'linkMove' | 'all' | 'none' | 'uninitialized';
178
+ /** What is put into `DataTransfer` when a drag starts. */
179
+ interface DragCopyItem {
180
+ /** Web custom formats (`web …`) are skipped: only the async Clipboard API writes them. */
181
+ readonly mimeType: string;
182
+ readonly data: string;
183
+ /** Accepted for parity with `MultiPayloadItem`; every non-web item can be written to a drag. */
184
+ readonly optional?: boolean;
185
+ }
186
+ /**
187
+ * A multi-format drag payload — strings only (DataTransfer only accepts strings).
188
+ * Mirrors `SyncCopyPayload` from copy-interceptor but scoped to drag.
189
+ */
190
+ type DragCopyPayload = TextPayload | HtmlPayload | JsonPayload | DragMultiPayload;
191
+ interface DragMultiPayload {
192
+ readonly kind: 'multi';
193
+ readonly items: readonly DragCopyItem[];
194
+ }
195
+ /**
196
+ * What the source getter returns:
197
+ * - a string: written as `text/plain`.
198
+ * - a `DragCopyPayload`: written according to its `kind`.
199
+ * - `false`: cancels the drag (`preventDefault()` on `dragstart`).
200
+ * - `null` / `undefined`: leaves the browser's default drag data untouched.
201
+ */
202
+ type DragCopyDecision = string | DragCopyPayload | false | null | undefined;
203
+ /** Called once when the user begins dragging the element. Must be synchronous. */
204
+ type DragCopySource = (event: DragStartEventLike) => DragCopyDecision;
205
+ /** Structural `DragEvent`: DOM and React drag events both satisfy it. */
206
+ interface DragStartEventLike {
207
+ readonly type: string;
208
+ readonly dataTransfer: DataTransferLike | null;
209
+ readonly defaultPrevented: boolean;
210
+ preventDefault(): void;
211
+ }
212
+ /** The writable face of `DataTransfer`. */
213
+ interface DataTransferLike {
214
+ effectAllowed: string;
215
+ setData(format: string, data: string): void;
216
+ clearData?(format?: string): void;
217
+ }
218
+ type DragCopyStatus =
219
+ /** No drag has started yet, or it was cancelled / never had source data. */
220
+ 'idle' |
221
+ /** The element is being dragged and data is on the DataTransfer. */
222
+ 'dragging' |
223
+ /** The drag ended (dropped or abandoned). */
224
+ 'done';
225
+ type DragCopyPassReason =
226
+ /** Source returned `null`/`undefined`. */
227
+ 'declined' |
228
+ /** `DataTransfer` is not present on this event. */
229
+ 'no-transfer' |
230
+ /** Source returned `false`. */
231
+ 'cancelled';
232
+ type DragCopyOutcome = {
233
+ readonly status: 'written';
234
+ readonly payload: DragCopyPayload;
235
+ } | {
236
+ readonly status: 'passed';
237
+ readonly reason: DragCopyPassReason;
238
+ } | {
239
+ readonly status: 'failed';
240
+ readonly error: CopyError;
241
+ };
242
+ interface DragCopyState {
243
+ readonly status: DragCopyStatus;
244
+ /** The last `dragstart` outcome; `null` before the first drag. */
245
+ readonly outcome: DragCopyOutcome | null;
246
+ }
247
+ interface DragCopyOptions {
248
+ /**
249
+ * Returns the data to put in the drag. Called synchronously on `dragstart`.
250
+ * Return a string (shorthand for `{ kind: 'text' }`), a payload object,
251
+ * `false` to cancel the drag, or `null`/`undefined` to pass through.
252
+ */
253
+ readonly source: DragCopySource;
254
+ /**
255
+ * `effectAllowed` advertised on the drag. Default `'copy'`.
256
+ * Setting `'move'` signals to drop targets that the source will be removed.
257
+ */
258
+ readonly effectAllowed?: DragEffectAllowed;
259
+ /**
260
+ * Called each time a drag starts or ends, with the latest outcome and status.
261
+ * Stable across re-renders when written as a class method or via `useRef`.
262
+ */
263
+ readonly onDrag?: (state: DragCopyState) => void;
264
+ /** Called when preparing the drag payload fails. */
265
+ readonly onError?: (error: CopyError) => void;
266
+ }
267
+ /**
268
+ * Populates a `dragstart` event's `DataTransfer` with the given payload.
269
+ * Use this from a raw `dragstart` handler or a React `onDragStart` prop.
270
+ * Returns the outcome so you can inspect what happened.
271
+ */
272
+ declare function applyDragCopy(event: DragStartEventLike, options: DragCopyOptions): DragCopyOutcome;
273
+ interface RegisterDragCopyResult {
274
+ /** Unsubscribes all listeners. Idempotent. */
275
+ readonly unsubscribe: () => void;
276
+ }
277
+ /**
278
+ * Attaches `dragstart` and `dragend` listeners to `element`, calling
279
+ * `applyDragCopy` on every drag start. Returns an object with an
280
+ * `unsubscribe` function.
281
+ *
282
+ * Pass an options getter so the latest options are always used without
283
+ * re-registering — safe to pass an inline object from a React render.
284
+ *
285
+ * ```ts
286
+ * const { unsubscribe } = registerDragCopy(el, () => ({
287
+ * source: () => `${title}\n${url}`,
288
+ * }));
289
+ * ```
290
+ */
291
+ declare function registerDragCopy(element: HTMLElement, options: DragCopyOptions | (() => DragCopyOptions)): RegisterDragCopyResult;
292
+ //#endregion
293
+ //#region src/core/paste-machine.d.ts
294
+ interface PasteIdleState {
295
+ readonly status: 'idle';
296
+ }
297
+ interface PasteReadingState {
298
+ readonly status: 'reading';
299
+ }
300
+ interface PasteReadState {
301
+ readonly status: 'read';
302
+ readonly result: PasteResult;
303
+ /** Epoch ms when the read resolved. */
304
+ readonly at: number;
305
+ }
306
+ interface PasteErrorState {
307
+ readonly status: 'error';
308
+ readonly error: CopyError;
309
+ /** Where the failed read came from. Only `'clipboard'` reads can be retried. */
310
+ readonly source: PasteSource;
311
+ /** `retry()` calls made since the last fresh `paste()`. */
312
+ readonly retryCount: number;
313
+ }
314
+ type PasteState = PasteIdleState | PasteReadingState | PasteReadState | PasteErrorState;
315
+ type PasteStatus = PasteState['status'];
316
+ /**
317
+ * `cancelled`: the read was superseded, reset, or its host unmounted before it
318
+ * finished, so its work was aborted. Nothing to report to the user.
319
+ */
320
+ type PasteIgnoredReason = 'in-flight' | 'no-accepted-content' | 'nothing-to-retry' | 'not-retryable' | 'cancelled';
321
+ /**
322
+ * Why an in-flight read was cancelled: `reset` (`reset()` was called),
323
+ * `disconnect` (its host disconnected, e.g. the React component unmounted) or
324
+ * `superseded` (a paste or drop event arrived while a read was pending).
325
+ */
326
+ type PasteCancelReason = 'reset' | 'disconnect' | 'superseded';
327
+ /** What `paste()` / `pasteEvent()` / `dropEvent()` / `retry()` resolve to. They never reject. */
328
+ type PasteOutcome = {
329
+ readonly status: 'read';
330
+ readonly result: PasteResult;
331
+ } | {
332
+ readonly status: 'error';
333
+ readonly error: CopyError;
334
+ } | {
335
+ readonly status: 'ignored';
336
+ readonly reason: PasteIgnoredReason;
337
+ };
338
+ /** Structural view of a DOM / React `paste` event. */
339
+ interface PasteEventLike {
340
+ readonly clipboardData: DataTransferLike$1 | null | undefined;
341
+ preventDefault(): void;
342
+ }
343
+ /** Structural view of a DOM / React `drop` event. */
344
+ interface PasteDropEventLike {
345
+ readonly dataTransfer: DataTransferLike$1 | null | undefined;
346
+ preventDefault(): void;
347
+ }
348
+ interface PasteMachineOptions extends PasteReadOptions {
349
+ /** Defaults to the browser Clipboard API adapter. */
350
+ readonly adapter?: PasteAdapter;
351
+ /** Return from `read` to `idle` after this many ms. `false` / `Infinity` / omitted = keep the result. */
352
+ readonly resetAfterMs?: number | false;
353
+ /**
354
+ * Paste events: call `event.preventDefault()` when the event carried accepted
355
+ * content, so the browser doesn't also insert it. Drop events: always call it,
356
+ * so the browser doesn't open the dropped file. Default `true`.
357
+ */
358
+ readonly preventDefault?: boolean;
359
+ /**
360
+ * Max `retry()` calls after a failed clipboard read. Default 3. `0`
361
+ * disables retry; `Infinity` allows unlimited retries.
362
+ */
363
+ readonly maxRetries?: number;
364
+ readonly onPaste?: (result: PasteResult) => void;
365
+ readonly onError?: (error: CopyError) => void;
366
+ /**
367
+ * `reset()` moved the machine back to `idle` from any other state. Not
368
+ * called for the automatic return after `resetAfterMs`, or when already `idle`.
369
+ */
370
+ readonly onReset?: () => void;
371
+ /**
372
+ * A read in flight was cancelled before it settled: its `signal` aborted
373
+ * and its result will not reach state or `onPaste` / `onError`. Fires
374
+ * before `onReset` when `reset()` cancels a read.
375
+ */
376
+ readonly onCancel?: (reason: PasteCancelReason) => void;
377
+ /** Clock injection for tests and deterministic environments. */
378
+ readonly now?: () => number;
379
+ }
380
+ /** Options object, or a getter so hosts (like React) can supply the latest options. */
381
+ type PasteMachineOptionsSource = PasteMachineOptions | (() => PasteMachineOptions);
382
+ interface PasteMachine {
383
+ readonly getSnapshot: () => PasteState;
384
+ readonly subscribe: (listener: () => void) => () => void;
385
+ /**
386
+ * Reads the system clipboard via the adapter. Call it from a user gesture
387
+ * (click, keypress). May show a permission prompt. Ignored while `reading`.
388
+ */
389
+ readonly paste: () => Promise<PasteOutcome>;
390
+ /**
391
+ * Handles a `paste` event (Ctrl/⌘+V). No permission prompt: the data is
392
+ * already in the event. Supersedes any read in flight. Events without
393
+ * accepted content are ignored and left untouched for the browser.
394
+ */
395
+ readonly pasteEvent: (event: PasteEventLike) => Promise<PasteOutcome>;
396
+ /**
397
+ * Handles a drag-and-drop `drop` event exactly like a paste event: same
398
+ * `accept`, limits and image checks, `result.source === 'drop'`. Always calls
399
+ * `event.preventDefault()` (unless `preventDefault: false`), so a rejected
400
+ * file is not opened by the browser in place of the page.
401
+ */
402
+ readonly dropEvent: (event: PasteDropEventLike) => Promise<PasteOutcome>;
403
+ /**
404
+ * Re-reads the clipboard after a retryable failure (e.g. permission denied,
405
+ * page not focused), up to `maxRetries`. Call it from a user gesture.
406
+ * Paste-event failures can't be retried: their data is gone after dispatch.
407
+ */
408
+ readonly retry: () => Promise<PasteOutcome>;
409
+ /** Back to `idle`. Discards any in-flight result and aborts its `signal`. */
410
+ readonly reset: () => void;
411
+ /**
412
+ * Lifecycle hook for hosts. Re-arms a pending auto-reset; the returned
413
+ * cleanup clears timers, drops in-flight results, aborts in-flight work and
414
+ * unsticks `reading`.
415
+ * Safe to call repeatedly (React StrictMode).
416
+ */
417
+ readonly connect: () => () => void;
418
+ }
419
+ declare const PASTE_IDLE_STATE: PasteIdleState;
420
+ /** Pure helper: can `retry()` do anything from this state? */
421
+ declare function canRetryPasteState(state: PasteState, maxRetries?: number): boolean;
422
+ /** Framework-agnostic paste state machine. */
423
+ declare function createPasteMachine(options?: PasteMachineOptionsSource): PasteMachine;
424
+ //#endregion
425
+ export { SVG_MIME_TYPE as $, RegisterDragCopyResult as A, CopyState as B, DragCopyPayload as C, DragEffectAllowed as D, DragCopyStatus as E, CopyIgnoredReason as F, IDLE_STATE as G, CopyingState as H, CopyMachine as I, createCopyMachine as J, IdleState as K, CopyMachineOptions as L, registerDragCopy as M, CopiedState as N, DragMultiPayload as O, CopyCancelReason as P, RasterImageMimeType as Q, CopyMachineOptionsSource as R, DragCopyPassReason as S, DragCopyState as T, DEFAULT_RESET_AFTER_MS as U, CopyStatus as V, ErrorState as W, CopyCoordinatorMember as X, CopyCoordinator as Y, createCopyCoordinator as Z, createPasteMachine as _, PasteEventLike as a, normalizeMimeType as at, DragCopyOptions as b, PasteMachine as c, PasteOutcome as d, WEB_CUSTOM_FORMAT_PREFIX as et, PasteReadState as f, canRetryPasteState as g, PasteStatus as h, PasteErrorState as i, normalizeClipboardType as it, applyDragCopy as j, DragStartEventLike as k, PasteMachineOptions as l, PasteState as m, PasteCancelReason as n, isWebCustomFormat as nt, PasteIdleState as o, sniffImageBytes as ot, PasteReadingState as p, canRetryState as q, PasteDropEventLike as r, matchesMimePattern as rt, PasteIgnoredReason as s, sniffImageType as st, PASTE_IDLE_STATE as t, isTextualMimeType as tt, PasteMachineOptionsSource as u, DragCopyDecision as v, DragCopySource as w, DragCopyOutcome as x, DragCopyItem as y, CopyOutcome as z };
426
+ //# sourceMappingURL=index-mr7sSAgP.d.ts.map