react-smart-copy 1.26.0 → 1.27.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/README.md +6 -3
- package/dist/capture.cjs +4 -4
- package/dist/capture.cjs.map +1 -1
- package/dist/capture.js +4 -4
- package/dist/capture.js.map +1 -1
- package/dist/chunks/clipboard-adapter-0haPt4jJ.js +217 -0
- package/dist/chunks/clipboard-adapter-0haPt4jJ.js.map +1 -0
- package/dist/chunks/clipboard-adapter-5bmjKbyK.cjs +222 -0
- package/dist/chunks/clipboard-adapter-5bmjKbyK.cjs.map +1 -0
- package/dist/chunks/{clipboard-adapter-CfaIbZpv.d.cts → clipboard-adapter-CUvmAcRE.d.cts} +10 -1
- package/dist/chunks/{clipboard-adapter-Chm6zq60.d.ts → clipboard-adapter-CdOzN135.d.ts} +10 -1
- package/dist/chunks/{contrast-C9d8QuaF.cjs → contrast-BatHkv8j.cjs} +2 -2
- package/dist/chunks/{contrast-C9d8QuaF.cjs.map → contrast-BatHkv8j.cjs.map} +1 -1
- package/dist/chunks/{contrast-DUaZq5SA.js → contrast-DnCunIr1.js} +2 -2
- package/dist/chunks/{contrast-DUaZq5SA.js.map → contrast-DnCunIr1.js.map} +1 -1
- package/dist/chunks/{core-t59Z4gdy.cjs → core-BRMlZOtj.cjs} +5 -5
- package/dist/chunks/{core-t59Z4gdy.cjs.map → core-BRMlZOtj.cjs.map} +1 -1
- package/dist/chunks/{core-D3GCO3yT.js → core-CnAFS4Wh.js} +5 -5
- package/dist/chunks/{core-D3GCO3yT.js.map → core-CnAFS4Wh.js.map} +1 -1
- package/dist/chunks/{deadline-j2hD7JKz.cjs → deadline-Cz6l-PDR.cjs} +14 -2
- package/dist/chunks/deadline-Cz6l-PDR.cjs.map +1 -0
- package/dist/chunks/{deadline-CbwnZ3Oq.js → deadline-DTAkra5B.js} +9 -3
- package/dist/chunks/deadline-DTAkra5B.js.map +1 -0
- package/dist/chunks/{errors-DFmEAC4E.cjs → errors-CF2EQNbc.cjs} +14 -2
- package/dist/chunks/errors-CF2EQNbc.cjs.map +1 -0
- package/dist/chunks/{errors-CT-FfUtU.js → errors-CGcMvbhJ.js} +9 -3
- package/dist/chunks/errors-CGcMvbhJ.js.map +1 -0
- package/dist/chunks/{field-B6SRWRbI.cjs → field-C8A5Yxln.cjs} +3 -3
- package/dist/chunks/{field-B6SRWRbI.cjs.map → field-C8A5Yxln.cjs.map} +1 -1
- package/dist/chunks/{field-DsRKkbav.js → field-CDCN9x0L.js} +3 -3
- package/dist/chunks/{field-DsRKkbav.js.map → field-CDCN9x0L.js.map} +1 -1
- package/dist/chunks/{index-CZ6HpdKm.d.cts → index-Ct2V52et.d.cts} +2 -2
- package/dist/chunks/{index-BidyqUMa.d.ts → index-U91G1nS9.d.ts} +2 -2
- package/dist/chunks/{limits-BP9R5wnr.js → limits-DvJZJn0V.js} +2 -2
- package/dist/chunks/{limits-BP9R5wnr.js.map → limits-DvJZJn0V.js.map} +1 -1
- package/dist/chunks/{limits-9wi1f6xT.cjs → limits-Vy-Xv26D.cjs} +2 -2
- package/dist/chunks/{limits-9wi1f6xT.cjs.map → limits-Vy-Xv26D.cjs.map} +1 -1
- package/dist/chunks/{paste-reader-BWQaYNaV.cjs → paste-reader-BL51Jt1y.cjs} +2 -2
- package/dist/chunks/{paste-reader-BWQaYNaV.cjs.map → paste-reader-BL51Jt1y.cjs.map} +1 -1
- package/dist/chunks/{paste-reader-D6uOTDBM.js → paste-reader-BpXOH_Px.js} +2 -2
- package/dist/chunks/{paste-reader-D6uOTDBM.js.map → paste-reader-BpXOH_Px.js.map} +1 -1
- package/dist/chunks/{payload-BrQWGwyx.js → payload-5uJedhwz.js} +2 -2
- package/dist/chunks/{payload-BrQWGwyx.js.map → payload-5uJedhwz.js.map} +1 -1
- package/dist/chunks/{payload-BWQ6sPtS.js → payload-DZnXoBmF.js} +3 -3
- package/dist/chunks/{payload-BWQ6sPtS.js.map → payload-DZnXoBmF.js.map} +1 -1
- package/dist/chunks/{payload-sBxkG7jH.cjs → payload-DjSSLonm.cjs} +2 -2
- package/dist/chunks/{payload-sBxkG7jH.cjs.map → payload-DjSSLonm.cjs.map} +1 -1
- package/dist/chunks/{payload-tTK6REua.cjs → payload-DzHhs6Ey.cjs} +3 -3
- package/dist/chunks/{payload-tTK6REua.cjs.map → payload-DzHhs6Ey.cjs.map} +1 -1
- package/dist/chunks/{share-nx7M4Z0t.cjs → share-Bu5u2ItX.cjs} +6 -6
- package/dist/chunks/{share-nx7M4Z0t.cjs.map → share-Bu5u2ItX.cjs.map} +1 -1
- package/dist/chunks/{share-CU91L4EK.js → share-CL72PUqq.js} +6 -6
- package/dist/chunks/{share-CU91L4EK.js.map → share-CL72PUqq.js.map} +1 -1
- package/dist/chunks/{share-DVR_DhHc.d.ts → share-DMqvWz32.d.ts} +2 -2
- package/dist/chunks/{share-hIwth7Dh.d.cts → share-DQFF73gt.d.cts} +2 -2
- package/dist/chunks/{url-BrhVUwn7.cjs → url-CL4YTCvM.cjs} +2 -2
- package/dist/chunks/{url-BrhVUwn7.cjs.map → url-CL4YTCvM.cjs.map} +1 -1
- package/dist/chunks/{url-COID0BLY.js → url-zB_krkuF.js} +2 -2
- package/dist/chunks/{url-COID0BLY.js.map → url-zB_krkuF.js.map} +1 -1
- package/dist/code.cjs +2 -2
- package/dist/code.js +2 -2
- package/dist/color.cjs +2 -2
- package/dist/color.js +2 -2
- package/dist/core.cjs +5 -5
- package/dist/core.d.cts +2 -2
- package/dist/core.d.ts +2 -2
- package/dist/core.js +5 -5
- package/dist/email.cjs +2 -2
- package/dist/email.js +2 -2
- package/dist/files.cjs +1 -1
- package/dist/files.js +1 -1
- package/dist/image.cjs +3 -3
- package/dist/image.cjs.map +1 -1
- package/dist/image.js +3 -3
- package/dist/image.js.map +1 -1
- package/dist/index.cjs +7 -7
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +7 -7
- package/dist/link.cjs +3 -3
- package/dist/link.js +3 -3
- package/dist/markdown.cjs +1 -1
- package/dist/markdown.js +1 -1
- package/dist/number.cjs +2 -2
- package/dist/number.js +2 -2
- package/dist/otp.cjs +1 -1
- package/dist/otp.js +1 -1
- package/dist/rich.cjs +3 -3
- package/dist/rich.js +3 -3
- package/dist/secrets.cjs +1 -1
- package/dist/secrets.js +1 -1
- package/dist/share.cjs +1 -1
- package/dist/share.d.cts +1 -1
- package/dist/share.d.ts +1 -1
- package/dist/share.js +1 -1
- package/dist/structured.cjs +2 -2
- package/dist/structured.js +2 -2
- package/dist/table.cjs +1 -1
- package/dist/table.js +1 -1
- package/dist/testing.cjs +2 -2
- package/dist/testing.d.cts +1 -1
- package/dist/testing.d.ts +1 -1
- package/dist/testing.js +2 -2
- package/package.json +8 -8
- package/dist/chunks/clipboard-adapter-CmKDTFdO.js +0 -97
- package/dist/chunks/clipboard-adapter-CmKDTFdO.js.map +0 -1
- package/dist/chunks/clipboard-adapter-UIFc_Qso.cjs +0 -102
- package/dist/chunks/clipboard-adapter-UIFc_Qso.cjs.map +0 -1
- package/dist/chunks/deadline-CbwnZ3Oq.js.map +0 -1
- package/dist/chunks/deadline-j2hD7JKz.cjs.map +0 -1
- package/dist/chunks/errors-CT-FfUtU.js.map +0 -1
- package/dist/chunks/errors-DFmEAC4E.cjs.map +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"errors-DFmEAC4E.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: unique symbol = Symbol.for('react-smart-copy.CopyFailure');\n\n// The brand is declared here and set in the constructor: a class can't declare a symbol-named\n// property in a way its declaration file can be written from this file alone.\n// eslint-disable-next-line @typescript-eslint/no-unsafe-declaration-merging -- the constructor sets the brand\nexport interface CopyFailure {\n readonly [COPY_FAILURE_BRAND]: true;\n}\n\n/** Error thrown by adapters to carry a fully classified {@link CopyError}. */\n// eslint-disable-next-line @typescript-eslint/no-unsafe-declaration-merging -- see the interface above\nexport class CopyFailure extends Error {\n readonly copyError: CopyError;\n\n constructor(copyError: CopyError) {\n super(copyError.message);\n this.name = 'CopyFailure';\n this.copyError = copyError;\n // An own, enumerable property, as a class field would be.\n (this as { [COPY_FAILURE_BRAND]: true })[COPY_FAILURE_BRAND] = true;\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,qBAAoC,OAAO,IAAI,8BAA8B;;AAWnF,IAAa,cAAb,cAAiC,MAAM;CAGrC,YAAY,WAAsB;EAChC,MAAM,UAAU,OAAO;EACvB,KAAK,OAAO;EACZ,KAAK,YAAY;EAEjB,KAAyC,sBAAsB;CACjE;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,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