react-smart-copy 1.17.2 → 1.19.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 +86 -5
- package/dist/capture.cjs +30 -153
- package/dist/capture.cjs.map +1 -1
- package/dist/capture.d.cts +2 -25
- package/dist/capture.d.ts +2 -25
- package/dist/capture.js +5 -128
- package/dist/capture.js.map +1 -1
- package/dist/chunks/clipboard-adapter-Cfz-rzw3.cjs +102 -0
- package/dist/chunks/clipboard-adapter-Cfz-rzw3.cjs.map +1 -0
- package/dist/chunks/clipboard-adapter-CtH4VELE.d.cts +43 -0
- package/dist/chunks/clipboard-adapter-DEXkXxwV.js +97 -0
- package/dist/chunks/clipboard-adapter-DEXkXxwV.js.map +1 -0
- package/dist/chunks/clipboard-adapter-Ds0irroN.d.ts +43 -0
- package/dist/chunks/contrast-C6CVklEI.cjs +842 -0
- package/dist/chunks/contrast-C6CVklEI.cjs.map +1 -0
- package/dist/chunks/contrast-DpK2JIVu.js +789 -0
- package/dist/chunks/contrast-DpK2JIVu.js.map +1 -0
- package/dist/chunks/copy-interceptor-C6NABy1l.d.ts +141 -0
- package/dist/chunks/copy-interceptor-CZWzGOkL.d.cts +141 -0
- package/dist/chunks/core-Cp2HSpaz.js +1035 -0
- package/dist/chunks/core-Cp2HSpaz.js.map +1 -0
- package/dist/chunks/core-DYf_Lhbe.cjs +1142 -0
- package/dist/chunks/core-DYf_Lhbe.cjs.map +1 -0
- package/dist/chunks/deadline-C29AlS_Q.js +46 -0
- package/dist/chunks/deadline-C29AlS_Q.js.map +1 -0
- package/dist/chunks/deadline-DkiB8ZHE.cjs +51 -0
- package/dist/chunks/deadline-DkiB8ZHE.cjs.map +1 -0
- package/dist/chunks/errors-9h8sdFFX.js +120 -0
- package/dist/chunks/errors-9h8sdFFX.js.map +1 -0
- package/dist/chunks/errors-BwOF6T_M.cjs +167 -0
- package/dist/chunks/errors-BwOF6T_M.cjs.map +1 -0
- package/dist/chunks/index-mr7sSAgP.d.ts +426 -0
- package/dist/chunks/index-vz0iW5V2.d.cts +426 -0
- package/dist/chunks/inert-html-D75NyVvT.js +34 -0
- package/dist/chunks/inert-html-D75NyVvT.js.map +1 -0
- package/dist/chunks/inert-html-DyxjWDok.cjs +39 -0
- package/dist/chunks/inert-html-DyxjWDok.cjs.map +1 -0
- package/dist/chunks/mime--LB7kdqG.cjs +153 -0
- package/dist/chunks/mime--LB7kdqG.cjs.map +1 -0
- package/dist/chunks/mime-aa-HA2dm.js +100 -0
- package/dist/chunks/mime-aa-HA2dm.js.map +1 -0
- package/dist/chunks/paste-adapter--SPL4PRE.d.cts +35 -0
- package/dist/chunks/paste-adapter-uahXnTYk.d.ts +35 -0
- package/dist/chunks/paste-reader-Bo01IMC_.cjs +289 -0
- package/dist/chunks/paste-reader-Bo01IMC_.cjs.map +1 -0
- package/dist/chunks/paste-reader-D9i7yMXF.js +224 -0
- package/dist/chunks/paste-reader-D9i7yMXF.js.map +1 -0
- package/dist/chunks/paste-reader-DcXnRWQr.d.cts +96 -0
- package/dist/chunks/paste-reader-DcXnRWQr.d.ts +96 -0
- package/dist/chunks/payload-CUymxwim.cjs +100 -0
- package/dist/chunks/payload-CUymxwim.cjs.map +1 -0
- package/dist/chunks/payload-CcwKJ_bU.d.cts +162 -0
- package/dist/chunks/payload-Cl_8hCI5.d.ts +162 -0
- package/dist/chunks/payload-DGw-JOo7.js +71 -0
- package/dist/chunks/payload-DGw-JOo7.js.map +1 -0
- package/dist/chunks/payload-DI5AorDz.js +103 -0
- package/dist/chunks/payload-DI5AorDz.js.map +1 -0
- package/dist/chunks/payload-J6GjHuh3.cjs +132 -0
- package/dist/chunks/payload-J6GjHuh3.cjs.map +1 -0
- package/dist/chunks/share-Bop47Znn.js +208 -0
- package/dist/chunks/share-Bop47Znn.js.map +1 -0
- package/dist/chunks/share-C0esXvRK.d.cts +115 -0
- package/dist/chunks/share-ayDz974N.cjs +231 -0
- package/dist/chunks/share-ayDz974N.cjs.map +1 -0
- package/dist/chunks/share-e7FenIr2.d.ts +115 -0
- package/dist/chunks/text-field-Ba8W3v4R.cjs +77 -0
- package/dist/chunks/text-field-Ba8W3v4R.cjs.map +1 -0
- package/dist/chunks/text-field-C0SGmvvR.d.cts +18 -0
- package/dist/chunks/text-field-C0SGmvvR.d.ts +18 -0
- package/dist/chunks/text-field-DUvrMMaK.js +66 -0
- package/dist/chunks/text-field-DUvrMMaK.js.map +1 -0
- package/dist/chunks/url-B9jdFGQy.cjs +86 -0
- package/dist/chunks/url-B9jdFGQy.cjs.map +1 -0
- package/dist/chunks/url-BcMYVCXQ.js +135 -0
- package/dist/chunks/url-BcMYVCXQ.js.map +1 -0
- package/dist/chunks/url-D4PGsRm8.cjs +164 -0
- package/dist/chunks/url-D4PGsRm8.cjs.map +1 -0
- package/dist/chunks/url-DWdElCT3.d.cts +43 -0
- package/dist/chunks/url-DWdElCT3.d.ts +43 -0
- package/dist/chunks/url-vJaFPbNL.js +57 -0
- package/dist/chunks/url-vJaFPbNL.js.map +1 -0
- package/dist/code.cjs +22 -113
- package/dist/code.cjs.map +1 -1
- package/dist/code.d.cts +4 -28
- package/dist/code.d.ts +4 -28
- package/dist/code.js +5 -96
- package/dist/code.js.map +1 -1
- package/dist/color.cjs +21 -893
- package/dist/color.cjs.map +1 -1
- package/dist/color.d.cts +4 -28
- package/dist/color.d.ts +4 -28
- package/dist/color.js +4 -876
- package/dist/color.js.map +1 -1
- package/dist/core.cjs +52 -1659
- package/dist/core.d.cts +8 -878
- package/dist/core.d.ts +8 -878
- package/dist/core.js +7 -1614
- package/dist/image.cjs +23 -94
- package/dist/image.cjs.map +1 -1
- package/dist/image.d.cts +1 -0
- package/dist/image.d.ts +1 -0
- package/dist/image.js +3 -74
- package/dist/image.js.map +1 -1
- package/dist/index.cjs +74 -2072
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +8 -978
- package/dist/index.d.ts +8 -978
- package/dist/index.js +7 -2005
- package/dist/index.js.map +1 -1
- package/dist/link.cjs +26 -339
- package/dist/link.cjs.map +1 -1
- package/dist/link.d.cts +5 -83
- package/dist/link.d.ts +5 -83
- package/dist/link.js +7 -320
- package/dist/link.js.map +1 -1
- package/dist/markdown.cjs +19 -159
- package/dist/markdown.cjs.map +1 -1
- package/dist/markdown.d.cts +3 -16
- package/dist/markdown.d.ts +3 -16
- package/dist/markdown.js +6 -146
- package/dist/markdown.js.map +1 -1
- package/dist/rich.cjs +1123 -940
- package/dist/rich.cjs.map +1 -1
- package/dist/rich.d.cts +101 -91
- package/dist/rich.d.ts +101 -91
- package/dist/rich.js +1099 -919
- package/dist/rich.js.map +1 -1
- package/dist/share.cjs +5 -640
- package/dist/share.d.cts +3 -248
- package/dist/share.d.ts +3 -248
- package/dist/share.js +1 -637
- package/dist/structured.cjs +13 -95
- package/dist/structured.cjs.map +1 -1
- package/dist/structured.d.cts +2 -11
- package/dist/structured.d.ts +2 -11
- package/dist/structured.js +4 -86
- package/dist/structured.js.map +1 -1
- package/dist/table.cjs +13 -40
- package/dist/table.cjs.map +1 -1
- package/dist/table.d.cts +2 -12
- package/dist/table.d.ts +2 -12
- package/dist/table.js +4 -31
- package/dist/table.js.map +1 -1
- package/dist/testing.cjs +10 -43
- package/dist/testing.cjs.map +1 -1
- package/dist/testing.d.cts +6 -181
- package/dist/testing.d.ts +6 -181
- package/dist/testing.js +3 -36
- package/dist/testing.js.map +1 -1
- package/package.json +37 -5
- package/dist/core.cjs.map +0 -1
- package/dist/core.js.map +0 -1
- package/dist/share.cjs.map +0 -1
- package/dist/share.js.map +0 -1
package/dist/share.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"share.js","names":["invalid","defaultEnvironment","invalid","invalid"],"sources":["../src/core/errors.ts","../src/core/payload.ts","../src/core/clipboard-adapter.ts","../src/link/url.ts","../src/link/payload.ts","../src/share/share.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","import { CopyFailure, createCopyError, type CopyError } from './errors';\nimport type { OperationContext } from './machine-shared';\n\n/** The only image MIME type with reliable cross-browser clipboard write support. */\nexport const IMAGE_MIME_TYPE = 'image/png';\n\n/**\n * An image as a Blob, a promise of one, or a function producing one.\n * Prefer the function form: it is invoked synchronously inside the user\n * gesture, which Safari requires for async image generation. The browser\n * adapter always passes an `OperationContext`: stop work once\n * `context.signal` aborts (reset, superseded, unmount). Optional in the type\n * so adapters that call sources themselves keep compiling.\n */\nexport type BlobSource = Blob | PromiseLike<Blob> | ((context?: OperationContext) => Blob | PromiseLike<Blob>);\n\nexport interface TextPayload {\n readonly kind: 'text';\n readonly value: string;\n}\n\nexport interface HtmlPayload {\n readonly kind: 'html';\n readonly html: string;\n /** Required plain-text fallback for targets that don't understand HTML. */\n readonly text: string;\n}\n\nexport interface ImagePayload {\n readonly kind: 'image';\n readonly blob: BlobSource;\n}\n\nexport interface JsonPayload {\n readonly kind: 'json';\n readonly value: unknown;\n /** `true` = 2-space indent, a number = that indent, falsy = compact. */\n readonly pretty?: boolean | number;\n}\n\nexport interface MultiPayloadItem {\n /**\n * The MIME type, or a web custom format (`web application/vnd.acme+json`).\n * Web custom formats are only written by the async Clipboard API; copy and drag\n * events skip them.\n */\n readonly mimeType: string;\n readonly data: string | Blob;\n /**\n * Skip this item, instead of failing the copy, when the browser cannot write its type.\n * An optional item is only written when `ClipboardItem.supports()` confirms the type.\n * At least one item must be written.\n */\n readonly optional?: boolean;\n}\n\nexport interface MultiPayload {\n readonly kind: 'multi';\n readonly items: readonly MultiPayloadItem[];\n}\n\nexport type CopyPayload = TextPayload | HtmlPayload | ImagePayload | JsonPayload | MultiPayload;\nexport type CopyPayloadKind = CopyPayload['kind'];\n\n/** A payload, or a bare string as shorthand for `{ kind: 'text' }`. */\nexport type CopyInput = string | CopyPayload;\n\n/**\n * What `copy()` accepts. The function form is resolved synchronously at copy\n * time, so it always reads the latest value without re-rendering.\n */\nexport type CopySource = CopyInput | (() => CopyInput);\n\nexport function normalizePayload(input: CopyInput): CopyPayload {\n return typeof input === 'string' ? { kind: 'text', value: input } : input;\n}\n\nexport function isBlob(value: unknown): value is Blob {\n if (typeof Blob !== 'undefined' && value instanceof Blob) return true;\n const tag = Object.prototype.toString.call(value);\n return tag === '[object Blob]' || tag === '[object File]';\n}\n\nfunction isThenable(value: unknown): value is PromiseLike<unknown> {\n return (\n (typeof value === 'object' || typeof value === 'function') &&\n value !== null &&\n typeof (value as { then?: unknown }).then === 'function'\n );\n}\n\nconst invalid = (message: string): CopyError => createCopyError('invalid-payload', message);\n\n/**\n * Structural validation. Typed callers can't produce most of these states,\n * but plain-JS callers and runtime data can, so the check is always on.\n */\nexport function validatePayload(payload: unknown): CopyError | null {\n if (typeof payload !== 'object' || payload === null) {\n return invalid('Copy input must be a string or a payload object.');\n }\n const candidate = payload as Record<string, unknown>;\n\n switch (candidate['kind']) {\n case 'text':\n return typeof candidate['value'] === 'string' && candidate['value'].length > 0\n ? null\n : invalid('Text payload must be a non-empty string.');\n case 'html':\n if (typeof candidate['html'] !== 'string' || candidate['html'].length === 0) {\n return invalid('HTML payload requires a non-empty `html` string.');\n }\n return typeof candidate['text'] === 'string' && candidate['text'].length > 0\n ? null\n : invalid('HTML payload requires a non-empty plain-text `text` fallback.');\n case 'image': {\n const source = candidate['blob'];\n return isBlob(source) || typeof source === 'function' || isThenable(source)\n ? null\n : invalid('Image payload requires a Blob, a Promise<Blob> or a function returning one.');\n }\n case 'json':\n return candidate['value'] === undefined ? invalid('JSON payload value is undefined.') : null;\n case 'multi': {\n const items = candidate['items'];\n if (!Array.isArray(items) || items.length === 0) {\n return invalid('Multi payload requires at least one item.');\n }\n const seen = new Set<string>();\n for (const item of items as unknown[]) {\n const entry = (typeof item === 'object' && item !== null ? item : {}) as Record<string, unknown>;\n const mimeType = entry['mimeType'];\n const data = entry['data'];\n if (typeof mimeType !== 'string' || mimeType.length === 0) {\n return invalid('Every multi item needs a non-empty `mimeType`.');\n }\n if (seen.has(mimeType)) return invalid(`Duplicate MIME type \"${mimeType}\" in multi payload.`);\n seen.add(mimeType);\n if (typeof data !== 'string' && !isBlob(data)) {\n return invalid(`Multi item \"${mimeType}\" must contain a string or a Blob.`);\n }\n }\n return null;\n }\n default:\n return invalid(`Unknown payload kind: ${String(candidate['kind'])}.`);\n }\n}\n\n/** Serialises a JSON payload, throwing a classified failure instead of a raw TypeError. */\nexport function serializeJson(payload: JsonPayload): string {\n const indent =\n payload.pretty === true ? 2 : typeof payload.pretty === 'number' ? payload.pretty : undefined;\n // Typed as `string` by lib.d.ts, but returns undefined for functions, symbols and undefined.\n let text: unknown;\n try {\n text = JSON.stringify(payload.value, null, indent);\n } catch (cause) {\n throw new CopyFailure(\n createCopyError('invalid-payload', 'JSON payload could not be serialised (circular reference or BigInt?).', cause),\n );\n }\n if (typeof text !== 'string') {\n throw new CopyFailure(\n createCopyError('invalid-payload', 'JSON payload serialised to nothing (functions, symbols and undefined are not JSON).'),\n );\n }\n return text;\n}\n","import { CopyFailure, createCopyError, type CopyErrorType } from './errors';\nimport type { OperationContext } from './machine-shared';\nimport { IMAGE_MIME_TYPE, isBlob, serializeJson, type BlobSource, type CopyPayload } from './payload';\n\n/** Minimal structural view of `navigator.clipboard`, so fakes and polyfills fit. */\nexport interface ClipboardLike {\n writeText?(text: string): Promise<void>;\n write?(items: readonly unknown[]): Promise<void>;\n}\n\nexport type ClipboardItemData = Blob | PromiseLike<Blob>;\n\nexport interface ClipboardItemConstructorLike {\n new (items: Record<string, ClipboardItemData>): unknown;\n supports?(type: string): boolean;\n}\n\nexport interface ClipboardEnvironment {\n readonly isSecureContext?: boolean;\n readonly navigator?: { readonly clipboard?: ClipboardLike | undefined } | undefined;\n readonly ClipboardItem?: ClipboardItemConstructorLike | undefined;\n}\n\n/**\n * The only thing the state machine needs. Implement it to target Electron,\n * a native bridge, a test double, or anything else.\n *\n * Contract: start the platform write synchronously (before any `await`) so the\n * browser still sees the user gesture, and reject with a `CopyFailure` when you\n * can classify the error. `context.signal` aborts when the copy is reset or its\n * host unmounts; honour it to stop expensive work early.\n */\nexport interface ClipboardAdapter {\n write(payload: CopyPayload, context?: OperationContext): Promise<void>;\n}\n\nexport interface BrowserClipboardAdapterOptions {\n /** Defaults to `window`, read lazily at copy time (SSR-safe). */\n readonly getEnvironment?: () => ClipboardEnvironment | undefined;\n /** When rich HTML copy is unavailable, fall back to its plain text. Default `true`. */\n readonly degradeHtmlToText?: boolean;\n}\n\ninterface RichClipboard {\n readonly Item: ClipboardItemConstructorLike;\n readonly write: (items: readonly unknown[]) => Promise<void>;\n}\n\nconst fail = (type: CopyErrorType, message: string, cause?: unknown): CopyFailure =>\n new CopyFailure(createCopyError(type, message, cause));\n\nconst noop = (): void => undefined;\n\nfunction defaultEnvironment(): ClipboardEnvironment | undefined {\n return typeof window === 'undefined' ? undefined : window;\n}\n\nfunction getRichClipboard(env: ClipboardEnvironment, clipboard: ClipboardLike): RichClipboard | null {\n const Item = env.ClipboardItem;\n if (!Item || typeof clipboard.write !== 'function') return null;\n return { Item, write: clipboard.write.bind(clipboard) };\n}\n\nfunction isTypeSupported(Item: ClipboardItemConstructorLike, type: string): boolean {\n return typeof Item.supports !== 'function' || Item.supports(type);\n}\n\nfunction writeText(clipboard: ClipboardLike, text: string): Promise<void> {\n if (typeof clipboard.writeText !== 'function') {\n throw fail('unsupported', 'navigator.clipboard.writeText() is not available.');\n }\n return clipboard.writeText(text);\n}\n\nasync function resolveImageBlob(source: BlobSource, context: OperationContext | undefined): Promise<Blob> {\n let blob: unknown;\n try {\n // Invoked before the first await, i.e. synchronously inside the gesture.\n blob = await (typeof source === 'function' ? source(context ?? { signal: new AbortController().signal }) : source);\n } catch (cause) {\n if (context?.signal.aborted) throw fail('aborted', 'The image copy was cancelled.', cause);\n throw fail('blob-generation-failed', 'The image source threw or rejected while producing a Blob.', cause);\n }\n if (!isBlob(blob)) throw fail('blob-generation-failed', 'The image source did not produce a Blob.');\n if (blob.type !== IMAGE_MIME_TYPE) {\n throw fail(\n 'unsupported-format',\n `Only ${IMAGE_MIME_TYPE} can be written to the clipboard (received \"${blob.type || 'unknown'}\"). ` +\n `Convert with canvas.toBlob(cb, \"${IMAGE_MIME_TYPE}\").`,\n );\n }\n return blob;\n}\n\nasync function writeImage(\n rich: RichClipboard,\n source: BlobSource,\n context: OperationContext | undefined,\n): Promise<void> {\n if (!isTypeSupported(rich.Item, IMAGE_MIME_TYPE)) {\n throw fail('unsupported-format', `This browser cannot write ${IMAGE_MIME_TYPE} to the clipboard.`);\n }\n // Hand ClipboardItem a *promise* so Safari keeps the gesture while the blob is produced.\n const blob = resolveImageBlob(source, context);\n blob.catch(noop); // Never an unhandled rejection, whichever side fails first.\n try {\n await rich.write([new rich.Item({ [IMAGE_MIME_TYPE]: blob })]);\n } catch (error) {\n // Browsers replace our classified reason with a generic DOMException. Prefer ours.\n const reason = await blob.then(noop, (inner: unknown) => inner);\n throw reason ?? error;\n }\n // Conforming browsers have consumed `blob` by now. Lax polyfills/webviews may resolve\n // without reading it: never report an image that failed to generate as copied.\n await blob;\n}\n\nasync function writeToClipboard(\n payload: CopyPayload,\n env: ClipboardEnvironment | undefined,\n degradeHtmlToText: boolean,\n context: OperationContext | undefined,\n): Promise<void> {\n if (!env) throw fail('unsupported', 'No browser environment: the clipboard only exists in the browser.');\n if (env.isSecureContext === false) {\n throw fail('insecure-context', 'The Clipboard API requires a secure context (HTTPS or localhost).');\n }\n const clipboard = env.navigator?.clipboard;\n if (!clipboard) throw fail('unsupported', 'navigator.clipboard is not available in this browser.');\n\n switch (payload.kind) {\n case 'text':\n return writeText(clipboard, payload.value);\n\n case 'json':\n return writeText(clipboard, serializeJson(payload));\n\n case 'html': {\n const rich = getRichClipboard(env, clipboard);\n if (!rich || !isTypeSupported(rich.Item, 'text/html')) {\n if (degradeHtmlToText) return writeText(clipboard, payload.text);\n throw fail('unsupported-format', 'Rich HTML copy requires ClipboardItem and navigator.clipboard.write().');\n }\n return rich.write([\n new rich.Item({\n 'text/html': new Blob([payload.html], { type: 'text/html' }),\n 'text/plain': new Blob([payload.text], { type: 'text/plain' }),\n }),\n ]);\n }\n\n case 'image': {\n const rich = getRichClipboard(env, clipboard);\n if (!rich) throw fail('unsupported-format', 'Image copy requires ClipboardItem and navigator.clipboard.write().');\n return writeImage(rich, payload.blob, context);\n }\n\n case 'multi': {\n const rich = getRichClipboard(env, clipboard);\n if (!rich) throw fail('unsupported-format', 'Multi-format copy requires ClipboardItem and navigator.clipboard.write().');\n const record: Record<string, ClipboardItemData> = Object.create(null) as Record<string, ClipboardItemData>;\n let written = 0;\n for (const { mimeType, data, optional } of payload.items) {\n // Optional items need positive confirmation: an unknown type can make the whole write reject.\n if (optional === true && !(typeof rich.Item.supports === 'function' && rich.Item.supports(mimeType))) continue;\n if (!isTypeSupported(rich.Item, mimeType)) {\n throw fail('unsupported-format', `This browser cannot write \"${mimeType}\" to the clipboard.`);\n }\n record[mimeType] = typeof data === 'string' ? new Blob([data], { type: mimeType }) : data;\n written += 1;\n }\n if (written === 0) throw fail('unsupported-format', 'This browser can write none of the payload types.');\n return rich.write([new rich.Item(record)]);\n }\n }\n}\n\n/** The default adapter: async Clipboard API with feature detection and honest errors. */\nexport function createBrowserClipboardAdapter(options: BrowserClipboardAdapterOptions = {}): ClipboardAdapter {\n const getEnvironment = options.getEnvironment ?? defaultEnvironment;\n const degradeHtmlToText = options.degradeHtmlToText ?? true;\n return {\n write: (payload, context) => writeToClipboard(payload, getEnvironment(), degradeHtmlToText, context),\n };\n}\n","import { copyFailure } from '../core/errors';\n\n/** Schemes a copied or pasted link may use by default. Never `javascript:`, `data:`, `vbscript:` or `file:`. */\nexport const DEFAULT_LINK_PROTOCOLS: readonly string[] = /* @__PURE__ */ Object.freeze(['https:', 'http:', 'mailto:', 'tel:']);\n\n/**\n * Query parameters that only track where a click came from: the defaults of\n * {@link cleanLinkUrl}. `utm_` matches every parameter starting with it.\n */\nexport const TRACKING_PARAMETERS: readonly string[] = /* @__PURE__ */ Object.freeze([\n 'utm_',\n 'fbclid',\n 'gclid',\n 'gclsrc',\n 'dclid',\n 'gbraid',\n 'wbraid',\n 'msclkid',\n 'yclid',\n 'twclid',\n 'ttclid',\n 'li_fat_id',\n 'igshid',\n 'igsh',\n 'mc_cid',\n 'mc_eid',\n '_hsenc',\n '_hsmi',\n 'mkt_tok',\n 'oly_anon_id',\n 'oly_enc_id',\n 'vero_id',\n 'wickedid',\n '_gl',\n]);\n\nexport interface CleanLinkOptions {\n /**\n * Parameters to remove: exact names, names ending in `_` (a prefix, like\n * `utm_`), or regular expressions tested against the name. Default {@link TRACKING_PARAMETERS}.\n */\n readonly params?: readonly (string | RegExp)[];\n /** Parameters never removed, even when `params` matches them. */\n readonly keep?: readonly string[];\n}\n\nexport interface LinkUrlOptions {\n /** Resolves relative links. Default: the page's address in a browser; required elsewhere for relative links. */\n readonly base?: string | URL;\n /** Allowed schemes, with the colon. Default {@link DEFAULT_LINK_PROTOCOLS}. */\n readonly protocols?: readonly string[];\n /** Remove tracking parameters: `true` for {@link TRACKING_PARAMETERS}, or your own list. Default `false`. */\n readonly clean?: boolean | CleanLinkOptions;\n}\n\nconst invalid = (message: string) => copyFailure('invalid-payload', message);\n\nfunction baseUrl(base: LinkUrlOptions['base']): string | undefined {\n if (base !== undefined) {\n if (typeof base === 'string' || base instanceof URL) return String(base);\n throw invalid('`base` must be a string or a URL.');\n }\n return typeof location === 'undefined' ? undefined : location.href;\n}\n\nfunction protocolSet(protocols: LinkUrlOptions['protocols']): ReadonlySet<string> {\n const list: unknown = protocols ?? DEFAULT_LINK_PROTOCOLS;\n const valid = (protocol: unknown): protocol is string => typeof protocol === 'string' && /^[a-z][a-z\\d+.-]*:$/i.test(protocol);\n if (!Array.isArray(list) || list.length === 0 || !(list as readonly unknown[]).every(valid)) {\n throw invalid('`protocols` must be a non-empty list of schemes with their colon, like \"https:\".');\n }\n return new Set((list as readonly string[]).map((protocol) => protocol.toLowerCase()));\n}\n\nfunction matcher(params: CleanLinkOptions['params']): (name: string) => boolean {\n const list = params ?? TRACKING_PARAMETERS;\n if (!Array.isArray(list) || !list.every((param) => typeof param === 'string' || param instanceof RegExp)) {\n throw invalid('`clean.params` must be a list of strings and regular expressions.');\n }\n return (name) => {\n const lower = name.toLowerCase();\n return list.some((param) => {\n if (typeof param !== 'string') return new RegExp(param.source, param.flags.replace(/[gy]/g, '')).test(name);\n const wanted = param.toLowerCase();\n return wanted.endsWith('_') ? lower.startsWith(wanted) : lower === wanted;\n });\n };\n}\n\n/** The cleaning step `clean` asks for, or `null`. Throws for an invalid option. */\nfunction cleaner(option: LinkUrlOptions['clean']): ((url: URL) => void) | null {\n const cleaning: unknown = option ?? false; // Plain-JS callers can pass anything.\n if (cleaning === false) return null;\n if (cleaning !== true && (typeof cleaning !== 'object' || cleaning === null)) throw invalid('`clean` must be a boolean or an options object.');\n const settings: CleanLinkOptions = cleaning === true ? {} : cleaning;\n const tracking = matcher(settings.params);\n const keep = settings.keep ?? [];\n if (!Array.isArray(keep) || !keep.every((name: unknown) => typeof name === 'string')) throw invalid('`clean.keep` must be a list of strings.');\n const kept = new Set(keep.map((name) => name.toLowerCase()));\n return (url) => {\n for (const name of [...new Set(url.searchParams.keys())]) {\n if (tracking(name) && !kept.has(name.toLowerCase())) url.searchParams.delete(name);\n }\n };\n}\n\n/**\n * Validates `options` once (throwing a typed `invalid-payload` error for invalid\n * ones) and returns a resolver that throws only for invalid links.\n * @internal\n */\nexport function linkUrlResolver(options: LinkUrlOptions = {}): (input: string | URL) => string {\n const protocols = protocolSet(options.protocols);\n const base = baseUrl(options.base);\n const clean = cleaner(options.clean);\n return (input) => {\n if (typeof input !== 'string' && !(input instanceof URL)) throw invalid('A link must be a string or a URL.');\n const raw = String(input).trim();\n if (raw === '') throw invalid('A link must not be empty.');\n let url: URL;\n try {\n url = new URL(raw, base);\n } catch (cause) {\n throw copyFailure('invalid-payload', `Not a valid link: ${JSON.stringify(raw.slice(0, 200))}.`, cause);\n }\n if (!protocols.has(url.protocol)) {\n throw invalid(`Links with the scheme \"${url.protocol}\" are not allowed (allowed: ${[...protocols].join(', ')}).`);\n }\n // Never copy or paste credentials embedded in a link.\n url.username = '';\n url.password = '';\n clean?.(url);\n return url.href;\n };\n}\n\n/**\n * The link as an absolute, safe URL string, or a typed `invalid-payload` error:\n * relative links are resolved, the scheme must be allowed, user names and\n * passwords are always removed, and tracking parameters optionally.\n */\nexport function resolveLinkUrl(input: string | URL, options: LinkUrlOptions = {}): string {\n return linkUrlResolver(options)(input);\n}\n\n/**\n * Removes tracking parameters (`utm_*`, `fbclid`, `gclid`, ...) from a link, keeping\n * everything else, including the fragment. Also validates it like every link here.\n *\n * @example\n * cleanLinkUrl('https://shop.example/p/42?utm_source=news&color=red'); // 'https://shop.example/p/42?color=red'\n */\nexport function cleanLinkUrl(url: string | URL, options: CleanLinkOptions & Omit<LinkUrlOptions, 'clean'> = {}): string {\n const { params, keep, ...rest } = options;\n return resolveLinkUrl(url, { ...rest, clean: { ...(params === undefined ? {} : { params }), ...(keep === undefined ? {} : { keep }) } });\n}\n","import { copyFailure } from '../core/errors';\nimport type { HtmlPayload, MultiPayload } from '../core/payload';\nimport { resolveLinkUrl, type LinkUrlOptions } from './url';\n\n/** A link with an optional title. */\nexport interface Link {\n readonly url: string | URL;\n /** What the link says when pasted into a document or chat. Default: the URL. */\n readonly title?: string;\n}\n\n/** A link: a URL, a `{ url, title }` object, or an `<a>` element (its `href` and text). */\nexport type LinkSource = string | URL | Link | HTMLAnchorElement;\n\n/** A validated link: an absolute, safe URL and a clean title. */\nexport interface ResolvedLink {\n readonly url: string;\n /** Never empty: the URL when there is no title. */\n readonly title: string;\n /** Whether `title` came from the input (`false`: it is the URL). */\n readonly titled: boolean;\n}\n\n/**\n * What the plain-text flavour holds (editors, terminals and address bars paste it):\n * `'url'` (the default), `'title'`, `'title-and-url'` (the title, then the URL on\n * the next line) or `'markdown'` (`[Title](URL)`).\n */\nexport type LinkTextFormat = 'url' | 'title' | 'title-and-url' | 'markdown';\n\nexport interface LinkPayloadOptions extends LinkUrlOptions {\n /** Default `'url'`. */\n readonly text?: LinkTextFormat;\n /** Longest title kept, in characters; longer ones end in an ellipsis. Default {@link DEFAULT_LINK_TITLE_LENGTH}. */\n readonly maxTitleLength?: number;\n}\n\nexport interface LinkDragPayloadOptions extends LinkPayloadOptions {\n /**\n * `'drag'`: a multi-format payload that also carries `text/uri-list` and\n * Firefox's `text/x-moz-url`, for `useDragCopy` and `useCopyInterceptor` (a link\n * dropped on the tab bar opens). Clipboard writes skip those two where the\n * browser can't write them.\n */\n readonly target: 'drag';\n}\n\nexport const DEFAULT_LINK_TITLE_LENGTH = 300;\n\nconst invalid = (message: string) => copyFailure('invalid-payload', message);\n\n/**\n * Characters a title never keeps: controls, bidi overrides and isolates (which can\n * make a title read differently), and zero-width characters.\n */\n// eslint-disable-next-line no-control-regex -- matching control characters is the point\nconst HIDDEN = /[\\0-\\x08\\x0b\\x0c\\x0e-\\x1f\\x7f-\\x9f\\u061C\\u200B-\\u200F\\u202A-\\u202E\\u2060-\\u2064\\u2066-\\u2069\\uFEFF]/g;\n\n/** A title as one clean line: hidden characters removed, whitespace collapsed, length capped. */\nexport function cleanTitle(title: string, maxLength: number): string {\n const clean = title.replace(HIDDEN, '').replace(/\\s+/g, ' ').trim();\n if (clean.length <= maxLength) return clean;\n // Cut on a code point boundary and mark the cut.\n return `${Array.from(clean).slice(0, maxLength - 1).join('').trimEnd()}\\u2026`;\n}\n\nfunction maxTitle(value: number | undefined): number {\n if (value === undefined) return DEFAULT_LINK_TITLE_LENGTH;\n if (Number.isInteger(value) && value >= 1) return value;\n throw invalid(`\\`maxTitleLength\\` must be a positive integer (received ${String(value)}).`);\n}\n\nfunction isAnchor(source: unknown): source is HTMLAnchorElement {\n return typeof source === 'object' && source !== null && (source as { nodeName?: unknown }).nodeName === 'A' && typeof (source as { href?: unknown }).href === 'string';\n}\n\n/**\n * Validates a link and its title: see {@link resolveLinkUrl} for the URL rules.\n * An `<a>` element gives its `href` and its text (or `title` attribute).\n */\nexport function resolveLink(source: LinkSource, options: LinkPayloadOptions = {}): ResolvedLink {\n let url: string | URL;\n let title: unknown;\n if (typeof source === 'string' || source instanceof URL) {\n url = source;\n } else if (isAnchor(source)) {\n url = source.getAttribute('href') ?? '';\n title = source.textContent.trim() !== '' ? source.textContent : (source.getAttribute('title') ?? undefined);\n if (url !== '' && options.base === undefined) url = source.href; // Resolved against the anchor's own document.\n } else if (typeof (source as unknown) === 'object' && (source as unknown) !== null && 'url' in source) {\n url = source.url;\n title = source.title;\n } else {\n throw invalid('A link must be a URL, a { url, title } object or an <a> element.');\n }\n if (title !== undefined && typeof title !== 'string') throw invalid('A link title must be a string.');\n const href = resolveLinkUrl(url, options);\n const clean = title === undefined ? '' : cleanTitle(title, maxTitle(options.maxTitleLength));\n return { url: href, title: clean === '' ? href : clean, titled: clean !== '' };\n}\n\nexport const escapeHtml = (text: string): string =>\n text.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/\"/g, '"').replace(/'/g, ''');\n\n/** `[title](url)`, safe in every CommonMark renderer: brackets and backslashes escaped, parentheses and spaces encoded. */\nexport function markdownLink(link: ResolvedLink): string {\n const label = link.title.replace(/[\\\\[\\]]/g, '\\\\$&');\n const target = link.url.replace(/[()<> ]/g, (char) => `%${char.charCodeAt(0).toString(16).toUpperCase()}`);\n return `[${label}](${target})`;\n}\n\nfunction plainText(link: ResolvedLink, format: LinkTextFormat): string {\n switch (format) {\n case 'url':\n return link.url;\n case 'title':\n return link.title;\n case 'title-and-url':\n return link.titled ? `${link.title}\\n${link.url}` : link.url;\n case 'markdown':\n return markdownLink(link);\n default:\n throw invalid(`\\`text\\` must be \"url\", \"title\", \"title-and-url\" or \"markdown\" (received ${JSON.stringify(format)}).`);\n }\n}\n\n/**\n * A copy payload for a link: an HTML anchor, so Slack, Google Docs, Notion,\n * Teams, Word and mail paste a titled link, and plain text (the URL by default)\n * for editors and address bars. The URL is validated (allowed schemes only,\n * credentials removed, optionally cleaned of tracking) and the title is cleaned\n * of hidden characters; both are escaped.\n *\n * @example\n * copy(() => linkPayload({ url: location.href, title: document.title }, { clean: true }));\n * useDragCopy({ payload: () => linkPayload(anchor, { target: 'drag' }) });\n */\nexport function linkPayload(source: LinkSource, options: LinkDragPayloadOptions): MultiPayload;\nexport function linkPayload(source: LinkSource, options?: LinkPayloadOptions): HtmlPayload;\nexport function linkPayload(source: LinkSource, options: LinkPayloadOptions & { readonly target?: 'drag' | 'clipboard' } = {}): HtmlPayload | MultiPayload {\n const target: unknown = options.target ?? 'clipboard'; // Plain-JS callers can pass anything.\n if (target !== 'drag' && target !== 'clipboard') throw invalid('`target` must be \"clipboard\" or \"drag\".');\n const link = resolveLink(source, options);\n const text = plainText(link, options.text ?? 'url');\n const html = `<a href=\"${escapeHtml(link.url)}\">${escapeHtml(link.title)}</a>`;\n if (target === 'clipboard') return { kind: 'html', html, text };\n return {\n kind: 'multi',\n items: [\n { mimeType: 'text/plain', data: text },\n { mimeType: 'text/html', data: html },\n { mimeType: 'text/uri-list', data: link.url, optional: true },\n // Firefox's titled-link format: the URL, a line break, the title.\n { mimeType: 'text/x-moz-url', data: `${link.url}\\n${link.title}`, optional: true },\n ],\n };\n}\n","import { createBrowserClipboardAdapter, type ClipboardAdapter } from '../core/clipboard-adapter';\nimport { createCopyError, describeCopyError, toCopyError, type CopyError, type CopyErrorType } from '../core/errors';\nimport { normalizePayload, validatePayload, type CopyInput, type CopyPayload } from '../core/payload';\nimport { cleanTitle, DEFAULT_LINK_TITLE_LENGTH, linkPayload } from '../link/payload';\nimport { linkUrlResolver, type LinkUrlOptions } from '../link/url';\n\n/** What to share: a link, a message, files, or any mix of them. */\nexport interface ShareContent {\n /** Validated like every link in this package: allowed schemes only, credentials removed. */\n readonly url?: string | URL;\n readonly title?: string;\n /** A message to share alongside (or instead of) the link. */\n readonly text?: string;\n /** Files for the share sheet, where the browser can share them (`navigator.canShare({ files })`). Never copied. */\n readonly files?: readonly File[];\n}\n\n/** The content after validation: what the share sheet or the clipboard receives. */\nexport interface ResolvedShare {\n readonly url: string | null;\n /** Cleaned of hidden characters; `null` when there is none. */\n readonly title: string | null;\n readonly text: string | null;\n readonly files: readonly File[];\n}\n\n/**\n * How to share:\n * - `auto` (default): the share sheet on phones and tablets, where people expect it; copy elsewhere.\n * - `native`: the share sheet wherever the browser has one (also desktop Safari, Edge and Chrome on Windows and macOS).\n * - `copy`: always copy.\n */\nexport type ShareMode = 'auto' | 'native' | 'copy';\n\nexport type ShareMethod = 'native' | 'copy';\n\n/** Structural view of what sharing needs from the browser; `window` by default. */\nexport interface ShareEnvironment {\n readonly navigator?: {\n readonly share?: (data: ShareData) => Promise<void>;\n readonly canShare?: (data: ShareData) => boolean;\n };\n readonly matchMedia?: (query: string) => { readonly matches: boolean };\n}\n\nexport interface ShareOptions extends LinkUrlOptions {\n /** Default `\"auto\"`. */\n readonly mode?: ShareMode;\n /** When the share sheet fails for a reason other than the user closing it, copy instead. Default `true`. */\n readonly fallback?: boolean;\n /**\n * What to copy. Default: a titled link (`linkPayload`) when there is a URL,\n * otherwise the text. Return a string or any copy payload.\n */\n readonly copy?: (content: ResolvedShare) => CopyInput;\n /** Default: the browser Clipboard API, as `useCopy` uses. */\n readonly adapter?: ClipboardAdapter;\n /** Default: `window`. For tests, webviews and other hosts. */\n readonly environment?: ShareEnvironment;\n /** Aborting it stops a copy in progress; the share sheet itself can only be closed by the user. */\n readonly signal?: AbortSignal;\n}\n\n/**\n * Why the content was copied rather than shared: `preferred` (the mode chose\n * copy, as on desktop in `auto`), `unsupported` (no share sheet, or it can't\n * take this content) or `fallback` (the share sheet failed).\n */\nexport type CopyReason = 'preferred' | 'unsupported' | 'fallback';\n\n/** What `shareOrCopy` resolves to. It never rejects. */\nexport type ShareOutcome =\n | { readonly status: 'shared'; readonly method: 'native'; readonly content: ResolvedShare }\n | { readonly status: 'copied'; readonly method: 'copy'; readonly reason: CopyReason; readonly payload: CopyPayload; readonly content: ResolvedShare }\n /** The user closed the share sheet. Nothing to report. */\n | { readonly status: 'cancelled'; readonly method: 'native' }\n | { readonly status: 'error'; readonly method: ShareMethod; readonly error: CopyError };\n\n/** Phones and tablets: a touch screen is the main input and nothing hovers. */\nexport const TOUCH_FIRST = '(hover: none) and (pointer: coarse)';\n\nconst defaultEnvironment = (): ShareEnvironment | undefined => (typeof window === 'undefined' ? undefined : window);\n\nconst invalid = (message: string): CopyError => createCopyError('invalid-payload', message);\n\n/** Validates and cleans what to share, or returns the typed error for invalid input. */\nfunction resolveContent(content: ShareContent, options: LinkUrlOptions): ResolvedShare | CopyError {\n const value: unknown = content;\n if (typeof value !== 'object' || value === null) return invalid('Share content must be an object with a url, text or files.');\n const { url, title, text, files } = value as Record<string, unknown>;\n let href: string | null = null;\n if (url !== undefined && url !== null) {\n try {\n href = linkUrlResolver(options)(url as string | URL);\n } catch (error) {\n return toCopyError(error);\n }\n }\n if (title !== undefined && typeof title !== 'string') return invalid('`title` must be a string.');\n if (text !== undefined && typeof text !== 'string') return invalid('`text` must be a string.');\n const list: unknown = files ?? [];\n if (!Array.isArray(list) || !list.every((file: unknown) => typeof File !== 'undefined' && file instanceof File)) {\n return invalid('`files` must be a list of File objects.');\n }\n const cleanName = title === undefined ? '' : cleanTitle(title, DEFAULT_LINK_TITLE_LENGTH);\n const message = text === undefined || text.trim() === '' ? null : text;\n if (href === null && message === null && list.length === 0) return invalid('There is nothing to share: give a url, text or files.');\n return { url: href, title: cleanName === '' ? null : cleanName, text: message, files: list as File[] };\n}\n\n/** The `ShareData` the browser receives: only the fields that are set. */\nfunction shareData(content: ResolvedShare): ShareData {\n return {\n ...(content.url === null ? {} : { url: content.url }),\n ...(content.title === null ? {} : { title: content.title }),\n ...(content.text === null ? {} : { text: content.text }),\n ...(content.files.length === 0 ? {} : { files: [...content.files] }),\n };\n}\n\n/** Whether this browser can open its share sheet for `data`. */\nfunction canShareNatively(environment: ShareEnvironment | undefined, data: ShareData | null): boolean {\n const nav = environment?.navigator;\n if (typeof nav?.share !== 'function') return false;\n if (data === null) return true;\n // Without canShare (older Safari), only links and text can be shared.\n return typeof nav.canShare === 'function' ? nav.canShare(data) : data.files === undefined;\n}\n\nfunction isTouchFirst(environment: ShareEnvironment | undefined): boolean {\n return typeof environment?.matchMedia === 'function' && environment.matchMedia(TOUCH_FIRST).matches;\n}\n\nfunction resolveMode(mode: unknown): ShareMode | CopyError {\n if (mode === undefined) return 'auto';\n return mode === 'auto' || mode === 'native' || mode === 'copy' ? mode : invalid('`mode` must be \"auto\", \"native\" or \"copy\".');\n}\n\n/**\n * How {@link shareOrCopy} would share right now: `\"native\"` (the share sheet) or\n * `\"copy\"`. Use it to label the button (\"Share…\" or \"Copy link\"). Pass the\n * content when it has files, since not every share sheet takes them.\n */\nexport function shareMethod(options: Pick<ShareOptions, 'mode' | 'environment'> = {}, content?: ShareContent): ShareMethod {\n const mode = resolveMode(options.mode);\n if (typeof mode !== 'string' || mode === 'copy') return 'copy';\n const environment = options.environment ?? defaultEnvironment();\n if (mode === 'auto' && !isTouchFirst(environment)) return 'copy';\n const resolved = content === undefined ? null : resolveContent(content, {});\n const data = resolved === null ? null : 'type' in resolved ? undefined : shareData(resolved);\n return data !== undefined && canShareNatively(environment, data) ? 'native' : 'copy';\n}\n\n/** The default copy: a titled link when there is a URL, otherwise the text (one of them is always set here). */\nfunction defaultCopy(content: ResolvedShare): CopyInput {\n if (content.url !== null) return linkPayload({ url: content.url, ...(content.title === null ? {} : { title: content.title }) });\n return content.text as string;\n}\n\nasync function copyContent(content: ResolvedShare, reason: CopyReason, options: ShareOptions): Promise<ShareOutcome> {\n if (options.copy === undefined && content.url === null && content.text === null) {\n return { status: 'error', method: 'copy', error: createCopyError('unsupported-format', 'Files can only be shared through a share sheet, and this browser has none for them.') };\n }\n let payload: CopyPayload;\n try {\n payload = normalizePayload((options.copy ?? defaultCopy)(content));\n } catch (error) {\n return { status: 'error', method: 'copy', error: toCopyError(error) };\n }\n const problem = validatePayload(payload);\n if (problem !== null) return { status: 'error', method: 'copy', error: problem };\n if (options.signal?.aborted === true) return { status: 'error', method: 'copy', error: createCopyError('aborted', 'The share was aborted.') };\n try {\n await (options.adapter ?? createBrowserClipboardAdapter()).write(payload, options.signal === undefined ? undefined : { signal: options.signal });\n } catch (error) {\n return { status: 'error', method: 'copy', error: toCopyError(error) };\n }\n return { status: 'copied', method: 'copy', reason, payload, content };\n}\n\n/**\n * Shares through the device's share sheet where people expect one, and copies a\n * titled link everywhere else. Call it directly in a click handler: the share\n * sheet needs the user's gesture.\n *\n * It never rejects. It resolves to `shared`, `copied` (with why), `cancelled`\n * (the user closed the share sheet: nothing to report) or `error` with a typed\n * {@link CopyError}.\n *\n * @example\n * button.addEventListener('click', async () => {\n * const outcome = await shareOrCopy({ url: location.href, title: document.title });\n * if (outcome.status === 'copied') toast('Link copied');\n * });\n */\nexport async function shareOrCopy(content: ShareContent, options: ShareOptions = {}): Promise<ShareOutcome> {\n const mode = resolveMode(options.mode);\n if (typeof mode !== 'string') return { status: 'error', method: 'copy', error: mode };\n const resolved = resolveContent(content, options);\n if ('type' in resolved) return { status: 'error', method: 'copy', error: resolved };\n const environment = options.environment ?? defaultEnvironment();\n if (mode === 'copy' || (mode === 'auto' && !isTouchFirst(environment))) return copyContent(resolved, 'preferred', options);\n const data = shareData(resolved);\n if (!canShareNatively(environment, data)) return copyContent(resolved, 'unsupported', options);\n try {\n // Called before any await: the share sheet needs the click's user activation.\n await (environment?.navigator?.share as (data: ShareData) => Promise<void>)(data);\n return { status: 'shared', method: 'native', content: resolved };\n } catch (error) {\n if (readName(error) === 'AbortError') return { status: 'cancelled', method: 'native' };\n if (options.fallback === false) return { status: 'error', method: 'native', error: shareError(error) };\n return copyContent(resolved, 'fallback', options);\n }\n}\n\nfunction readName(error: unknown): string | undefined {\n const name: unknown = typeof error === 'object' && error !== null ? (error as { name?: unknown }).name : undefined;\n return typeof name === 'string' ? name : undefined;\n}\n\n/** Classifies a share sheet failure. */\nfunction shareError(cause: unknown): CopyError {\n switch (readName(cause)) {\n case 'NotAllowedError':\n return createCopyError('permission-denied', 'The share sheet was blocked: it needs a click, and an iframe needs the web-share permission.', cause);\n case 'InvalidStateError':\n return createCopyError('unknown', 'Another share sheet is already open.', cause);\n case 'DataError':\n case 'TypeError':\n return createCopyError('unsupported-format', 'The share sheet rejected this content.', cause);\n default:\n return toCopyError(cause);\n }\n}\n\nconst SHARE_DESCRIPTIONS: Partial<Readonly<Record<CopyErrorType, string>>> = {\n 'permission-denied': \"Sharing isn't allowed here.\",\n 'unsupported-format': \"This can't be shared from this browser.\",\n timeout: 'Sharing took too long. Try again.',\n};\n\n/**\n * Default English, user-facing sentence for a failed share: a share sheet\n * failure is described as sharing, a failed copy as copying. Replace for i18n.\n */\nexport function describeShareError(error: CopyError, method: ShareMethod): string {\n if (method === 'copy') return describeCopyError(error);\n return SHARE_DESCRIPTIONS[error.type] ?? \"Couldn't share. Try again.\";\n}\n"],"mappings":";AA8CA,SAAgB,gBAAgB,MAAqB,SAAiB,OAA4B;CAChG,OAAO,UAAU,KAAA,IAAY;EAAE;EAAM;CAAQ,IAAI;EAAE;EAAM;EAAS;CAAM;AAC1E;;;;;AAmBA,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;;AA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