react-smart-copy 1.26.1 → 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/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/{core-DF6jiigD.cjs → core-BRMlZOtj.cjs} +2 -2
- package/dist/chunks/{core-DF6jiigD.cjs.map → core-BRMlZOtj.cjs.map} +1 -1
- package/dist/chunks/{core-88XdCKaH.js → core-CnAFS4Wh.js} +2 -2
- package/dist/chunks/{core-88XdCKaH.js.map → core-CnAFS4Wh.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/{share-Bk6MPmJg.cjs → share-Bu5u2ItX.cjs} +2 -2
- package/dist/chunks/{share-Bk6MPmJg.cjs.map → share-Bu5u2ItX.cjs.map} +1 -1
- package/dist/chunks/{share-tdlNQeje.js → share-CL72PUqq.js} +2 -2
- package/dist/chunks/{share-tdlNQeje.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/core.cjs +2 -2
- package/dist/core.d.cts +2 -2
- package/dist/core.d.ts +2 -2
- package/dist/core.js +2 -2
- package/dist/index.cjs +3 -3
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +3 -3
- 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/testing.d.cts +1 -1
- package/dist/testing.d.ts +1 -1
- package/package.json +8 -8
- package/dist/chunks/clipboard-adapter-Bpuf5GmB.cjs +0 -102
- package/dist/chunks/clipboard-adapter-Bpuf5GmB.cjs.map +0 -1
- package/dist/chunks/clipboard-adapter-DyCmyZV9.js +0 -97
- package/dist/chunks/clipboard-adapter-DyCmyZV9.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"share-Bk6MPmJg.cjs","names":["createCopyError","linkUrlResolver","toCopyError","cleanTitle","linkPayload","normalizePayload","validatePayload","createBrowserClipboardAdapter","describeCopyError"],"sources":["../../src/share/share.ts"],"sourcesContent":["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":";;;;;;;;AA+EA,MAAa,cAAc;AAE3B,MAAM,2BAA0D,OAAO,WAAW,cAAc,KAAA,IAAY;AAE5G,MAAM,WAAW,YAA+BA,eAAAA,gBAAgB,mBAAmB,OAAO;;AAG1F,SAAS,eAAe,SAAuB,SAAoD;CACjG,MAAM,QAAiB;CACvB,IAAI,OAAO,UAAU,YAAY,UAAU,MAAM,OAAO,QAAQ,4DAA4D;CAC5H,MAAM,EAAE,KAAK,OAAO,MAAM,UAAU;CACpC,IAAI,OAAsB;CAC1B,IAAI,QAAQ,KAAA,KAAa,QAAQ,MAC/B,IAAI;EACF,OAAOC,YAAAA,gBAAgB,OAAO,CAAC,CAAC,GAAmB;CACrD,SAAS,OAAO;EACd,OAAOC,eAAAA,YAAY,KAAK;CAC1B;CAEF,IAAI,UAAU,KAAA,KAAa,OAAO,UAAU,UAAU,OAAO,QAAQ,2BAA2B;CAChG,IAAI,SAAS,KAAA,KAAa,OAAO,SAAS,UAAU,OAAO,QAAQ,0BAA0B;CAC7F,MAAM,OAAgB,SAAS,CAAC;CAChC,IAAI,CAAC,MAAM,QAAQ,IAAI,KAAK,CAAC,KAAK,OAAO,SAAkB,OAAO,SAAS,eAAe,gBAAgB,IAAI,GAC5G,OAAO,QAAQ,yCAAyC;CAE1D,MAAM,YAAY,UAAU,KAAA,IAAY,KAAKC,kBAAAA,WAAW,OAAA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SAAS,WAAW,OAA2B;CAC7C,QAAQ,SAAS,KAAK,GAAtB;EACE,KAAK,mBACH,OAAOF,eAAAA,gBAAgB,qBAAqB,gGAAgG,KAAK;EACnJ,KAAK,qBACH,OAAOA,eAAAA,gBAAgB,WAAW,wCAAwC,KAAK;EACjF,KAAK;EACL,KAAK,aACH,OAAOA,eAAAA,gBAAgB,sBAAsB,0CAA0C,KAAK;EAC9F,SACE,OAAOE,eAAAA,YAAY,KAAK;CAC5B;AACF;AAEA,MAAM,qBAAuE;CAC3E,qBAAqB;CACrB,sBAAsB;CACtB,SAAS;AACX;;;;;AAMA,SAAgB,mBAAmB,OAAkB,QAA6B;CAChF,IAAI,WAAW,QAAQ,OAAOM,eAAAA,kBAAkB,KAAK;CACrD,OAAO,mBAAmB,MAAM,SAAS;AAC3C"}
|
|
1
|
+
{"version":3,"file":"share-Bu5u2ItX.cjs","names":["createCopyError","linkUrlResolver","toCopyError","cleanTitle","linkPayload","normalizePayload","validatePayload","createBrowserClipboardAdapter","describeCopyError"],"sources":["../../src/share/share.ts"],"sourcesContent":["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":";;;;;;;;AA+EA,MAAa,cAAc;AAE3B,MAAM,2BAA0D,OAAO,WAAW,cAAc,KAAA,IAAY;AAE5G,MAAM,WAAW,YAA+BA,eAAAA,gBAAgB,mBAAmB,OAAO;;AAG1F,SAAS,eAAe,SAAuB,SAAoD;CACjG,MAAM,QAAiB;CACvB,IAAI,OAAO,UAAU,YAAY,UAAU,MAAM,OAAO,QAAQ,4DAA4D;CAC5H,MAAM,EAAE,KAAK,OAAO,MAAM,UAAU;CACpC,IAAI,OAAsB;CAC1B,IAAI,QAAQ,KAAA,KAAa,QAAQ,MAC/B,IAAI;EACF,OAAOC,YAAAA,gBAAgB,OAAO,CAAC,CAAC,GAAmB;CACrD,SAAS,OAAO;EACd,OAAOC,eAAAA,YAAY,KAAK;CAC1B;CAEF,IAAI,UAAU,KAAA,KAAa,OAAO,UAAU,UAAU,OAAO,QAAQ,2BAA2B;CAChG,IAAI,SAAS,KAAA,KAAa,OAAO,SAAS,UAAU,OAAO,QAAQ,0BAA0B;CAC7F,MAAM,OAAgB,SAAS,CAAC;CAChC,IAAI,CAAC,MAAM,QAAQ,IAAI,KAAK,CAAC,KAAK,OAAO,SAAkB,OAAO,SAAS,eAAe,gBAA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,UAAU,YAAY,UAAU,OAAQ,MAA6B,OAAO,KAAA;CACzG,OAAO,OAAO,SAAS,WAAW,OAAO,KAAA;AAC3C;;AAGA,SAAS,WAAW,OAA2B;CAC7C,QAAQ,SAAS,KAAK,GAAtB;EACE,KAAK,mBACH,OAAOF,eAAAA,gBAAgB,qBAAqB,gGAAgG,KAAK;EACnJ,KAAK,qBACH,OAAOA,eAAAA,gBAAgB,WAAW,wCAAwC,KAAK;EACjF,KAAK;EACL,KAAK,aACH,OAAOA,eAAAA,gBAAgB,sBAAsB,0CAA0C,KAAK;EAC9F,SACE,OAAOE,eAAAA,YAAY,KAAK;CAC5B;AACF;AAEA,MAAM,qBAAuE;CAC3E,qBAAqB;CACrB,sBAAsB;CACtB,SAAS;AACX;;;;;AAMA,SAAgB,mBAAmB,OAAkB,QAA6B;CAChF,IAAI,WAAW,QAAQ,OAAOM,eAAAA,kBAAkB,KAAK;CACrD,OAAO,mBAAmB,MAAM,SAAS;AAC3C"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
|
|
2
2
|
import { c as toCopyError, i as describeCopyError, r as createCopyError } from "./errors-CGcMvbhJ.js";
|
|
3
3
|
import { a as validatePayload, r as normalizePayload } from "./payload-5uJedhwz.js";
|
|
4
|
-
import { t as createBrowserClipboardAdapter } from "./clipboard-adapter-
|
|
4
|
+
import { t as createBrowserClipboardAdapter } from "./clipboard-adapter-0haPt4jJ.js";
|
|
5
5
|
import { i as linkUrlResolver } from "./url-zB_krkuF.js";
|
|
6
6
|
import { n as cleanTitle, r as linkPayload } from "./payload-DZnXoBmF.js";
|
|
7
7
|
//#region src/share/share.ts
|
|
@@ -205,4 +205,4 @@ function describeShareError(error, method) {
|
|
|
205
205
|
//#endregion
|
|
206
206
|
export { shareOrCopy as i, describeShareError as n, shareMethod as r, TOUCH_FIRST as t };
|
|
207
207
|
|
|
208
|
-
//# sourceMappingURL=share-
|
|
208
|
+
//# sourceMappingURL=share-CL72PUqq.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"share-tdlNQeje.js","names":[],"sources":["../../src/share/share.ts"],"sourcesContent":["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":";;;;;;;;AA+EA,MAAa,cAAc;AAE3B,MAAM,2BAA0D,OAAO,WAAW,cAAc,KAAA,IAAY;AAE5G,MAAM,WAA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W,GAAI,OAAO,YAAY,UAAU,aAAa,OAAO;CACzH,MAAM,OAAO,UAAU,QAAQ;CAC/B,IAAI,CAAC,iBAAiB,aAAa,IAAI,GAAG,OAAO,YAAY,UAAU,eAAe,OAAO;CAC7F,IAAI;EAEF,OAAO,aAAa,WAAW,MAAA,CAA6C,IAAI;EAChF,OAAO;GAAE,QAAQ;GAAU,QAAQ;GAAU,SAAS;EAAS;CACjE,SAAS,OAAO;EACd,IAAI,SAAS,KAAK,MAAM,cAAc,OAAO;GAAE,QAAQ;GAAa,QAAQ;EAAS;EACrF,IAAI,QAAQ,aAAa,OAAO,OAAO;GAAE,QAAQ;GAAS,QAAQ;GAAU,OAAO,WAAW,KAAK;EAAE;EACrG,OAAO,YAAY,UAAU,YAAY,OAAO;CAClD;AACF;AAEA,SAAS,SAAS,OAAoC;CACpD,MAAM,OAAgB,OAAO,UAAU,YAAY,UAAU,OAAQ,MAA6B,OAAO,KAAA;CACzG,OAAO,OAAO,SAAS,WAAW,OAAO,KAAA;AAC3C;;AAGA,SAAS,WAAW,OAA2B;CAC7C,QAAQ,SAAS,KAAK,GAAtB;EACE,KAAK,mBACH,OAAO,gBAAgB,qBAAqB,gGAAgG,KAAK;EACnJ,KAAK,qBACH,OAAO,gBAAgB,WAAW,wCAAwC,KAAK;EACjF,KAAK;EACL,KAAK,aACH,OAAO,gBAAgB,sBAAsB,0CAA0C,KAAK;EAC9F,SACE,OAAO,YAAY,KAAK;CAC5B;AACF;AAEA,MAAM,qBAAuE;CAC3E,qBAAqB;CACrB,sBAAsB;CACtB,SAAS;AACX;;;;;AAMA,SAAgB,mBAAmB,OAAkB,QAA6B;CAChF,IAAI,WAAW,QAAQ,OAAO,kBAAkB,KAAK;CACrD,OAAO,mBAAmB,MAAM,SAAS;AAC3C"}
|
|
1
|
+
{"version":3,"file":"share-CL72PUqq.js","names":[],"sources":["../../src/share/share.ts"],"sourcesContent":["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":";;;;;;;;AA+EA,MAAa,cAAc;AAE3B,MAAM,2BAA0D,OAAO,WAAW,cAAc,KAAA,IAAY;AAE5G,MAAM,WAAW,YAA+B,gBAAgB,mBAAmB,OAAO;;AAG1F,SAAS,eAAe,SAAuB,SAAoD;CACjG,MAAM,QAAiB;CACvB,IAAI,OAAO,UAAU,YAAY,UAAU,MAAM,OAAO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eAAe,OAAO;CAC7F,IAAI;EAEF,OAAO,aAAa,WAAW,MAAA,CAA6C,IAAI;EAChF,OAAO;GAAE,QAAQ;GAAU,QAAQ;GAAU,SAAS;EAAS;CACjE,SAAS,OAAO;EACd,IAAI,SAAS,KAAK,MAAM,cAAc,OAAO;GAAE,QAAQ;GAAa,QAAQ;EAAS;EACrF,IAAI,QAAQ,aAAa,OAAO,OAAO;GAAE,QAAQ;GAAS,QAAQ;GAAU,OAAO,WAAW,KAAK;EAAE;EACrG,OAAO,YAAY,UAAU,YAAY,OAAO;CAClD;AACF;AAEA,SAAS,SAAS,OAAoC;CACpD,MAAM,OAAgB,OAAO,UAAU,YAAY,UAAU,OAAQ,MAA6B,OAAO,KAAA;CACzG,OAAO,OAAO,SAAS,WAAW,OAAO,KAAA;AAC3C;;AAGA,SAAS,WAAW,OAA2B;CAC7C,QAAQ,SAAS,KAAK,GAAtB;EACE,KAAK,mBACH,OAAO,gBAAgB,qBAAqB,gGAAgG,KAAK;EACnJ,KAAK,qBACH,OAAO,gBAAgB,WAAW,wCAAwC,KAAK;EACjF,KAAK;EACL,KAAK,aACH,OAAO,gBAAgB,sBAAsB,0CAA0C,KAAK;EAC9F,SACE,OAAO,YAAY,KAAK;CAC5B;AACF;AAEA,MAAM,qBAAuE;CAC3E,qBAAqB;CACrB,sBAAsB;CACtB,SAAS;AACX;;;;;AAMA,SAAgB,mBAAmB,OAAkB,QAA6B;CAChF,IAAI,WAAW,QAAQ,OAAO,kBAAkB,KAAK;CACrD,OAAO,mBAAmB,MAAM,SAAS;AAC3C"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
|
|
2
2
|
import { n as CopyInput, r as CopyPayload, v as CopyError } from "./payload-CcvSx_Hq.js";
|
|
3
|
-
import { n as ClipboardAdapter } from "./clipboard-adapter-
|
|
3
|
+
import { n as ClipboardAdapter } from "./clipboard-adapter-CdOzN135.js";
|
|
4
4
|
import { r as LinkUrlOptions } from "./url-DWdElCT3.js";
|
|
5
5
|
//#region src/share/share.d.ts
|
|
6
6
|
/** What to share: a link, a message, files, or any mix of them. */
|
|
@@ -112,4 +112,4 @@ declare function shareOrCopy(content: ShareContent, options?: ShareOptions): Pro
|
|
|
112
112
|
declare function describeShareError(error: CopyError, method: ShareMethod): string;
|
|
113
113
|
//#endregion
|
|
114
114
|
export { ShareMethod as a, ShareOutcome as c, shareOrCopy as d, ShareEnvironment as i, describeShareError as l, ResolvedShare as n, ShareMode as o, ShareContent as r, ShareOptions as s, CopyReason as t, shareMethod as u };
|
|
115
|
-
//# sourceMappingURL=share-
|
|
115
|
+
//# sourceMappingURL=share-DMqvWz32.d.ts.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
|
|
2
2
|
import { n as CopyInput, r as CopyPayload, v as CopyError } from "./payload-qkAWVXWA.cjs";
|
|
3
|
-
import { n as ClipboardAdapter } from "./clipboard-adapter-
|
|
3
|
+
import { n as ClipboardAdapter } from "./clipboard-adapter-CUvmAcRE.cjs";
|
|
4
4
|
import { r as LinkUrlOptions } from "./url-DWdElCT3.cjs";
|
|
5
5
|
//#region src/share/share.d.ts
|
|
6
6
|
/** What to share: a link, a message, files, or any mix of them. */
|
|
@@ -112,4 +112,4 @@ declare function shareOrCopy(content: ShareContent, options?: ShareOptions): Pro
|
|
|
112
112
|
declare function describeShareError(error: CopyError, method: ShareMethod): string;
|
|
113
113
|
//#endregion
|
|
114
114
|
export { ShareMethod as a, ShareOutcome as c, shareOrCopy as d, ShareEnvironment as i, describeShareError as l, ResolvedShare as n, ShareMode as o, ShareContent as r, ShareOptions as s, CopyReason as t, shareMethod as u };
|
|
115
|
-
//# sourceMappingURL=share-
|
|
115
|
+
//# sourceMappingURL=share-DQFF73gt.d.cts.map
|
package/dist/core.cjs
CHANGED
|
@@ -3,8 +3,8 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
|
3
3
|
const require_errors = require("./chunks/errors-CF2EQNbc.cjs");
|
|
4
4
|
const require_payload = require("./chunks/payload-DjSSLonm.cjs");
|
|
5
5
|
const require_mime = require("./chunks/mime--LB7kdqG.cjs");
|
|
6
|
-
const require_clipboard_adapter = require("./chunks/clipboard-adapter-
|
|
7
|
-
const require_core = require("./chunks/core-
|
|
6
|
+
const require_clipboard_adapter = require("./chunks/clipboard-adapter-5bmjKbyK.cjs");
|
|
7
|
+
const require_core = require("./chunks/core-BRMlZOtj.cjs");
|
|
8
8
|
const require_paste_reader = require("./chunks/paste-reader-BL51Jt1y.cjs");
|
|
9
9
|
exports.CopyFailure = require_errors.CopyFailure;
|
|
10
10
|
exports.DEFAULT_INTERCEPTED_EVENTS = require_core.DEFAULT_INTERCEPTED_EVENTS;
|
package/dist/core.d.cts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
|
|
2
2
|
import { A as resolveMaxRetries, C as describeCopyError, D as toCopyError, E as isRetryableError, O as DEFAULT_MAX_RETRIES, S as createCopyError, T as isCopyFailure, _ as ClipboardOperation, a as CopySource, b as CopyFailure, c as ImagePayload, d as MultiPayloadItem, f as TextPayload, g as validatePayload, h as serializeJson, i as CopyPayloadKind, k as OperationContext, l as JsonPayload, m as normalizePayload, n as CopyInput, o as HtmlPayload, p as isBlob, r as CopyPayload, s as IMAGE_MIME_TYPE, t as BlobSource, u as MultiPayload, v as CopyError, w as describePasteError, x as copyFailure, y as CopyErrorType } from "./chunks/payload-qkAWVXWA.cjs";
|
|
3
3
|
import { _ as resolvePasteReadOptions, a as DataTransferItemLike, c as PasteAcceptShorthand, d as PasteReadOptions, f as PasteReadResult, g as canAcceptDrag, h as ResolvedPasteReadOptions, i as DEFAULT_PASTE_MAX_ITEMS, l as PasteItem, m as PasteSource, n as DEFAULT_PASTE_ACCEPT, o as DataTransferLike, p as PasteResult, r as DEFAULT_PASTE_MAX_BYTES, s as PasteAccept, t as ClipboardItemLike, u as PasteLimits } from "./chunks/paste-reader-DcXnRWQr.cjs";
|
|
4
|
-
import { $ as CopyCoordinator, A as DragCopyStatus, B as CopyMachine, C as DragCopyItem, D as DragCopyPayload, E as DragCopyPassReason, F as applyDragCopy, G as CopyStatus, H as CopyMachineOptionsSource, I as registerDragCopy, J as ErrorState, K as CopyingState, L as CopiedState, M as DragMultiPayload, N as DragStartEventLike, O as DragCopySource, P as RegisterDragCopyResult, Q as createCopyMachine, R as CopyCancelReason, S as DragCopyDecision, T as DragCopyOutcome, U as CopyOutcome, V as CopyMachineOptions, W as CopyState, X as IdleState, Y as IDLE_STATE, Z as canRetryState, _ as createPasteMachine, a as PasteEventLike, at as isTextualMimeType, b as readClipboardPermission, c as PasteMachine, ct as normalizeClipboardType, d as PasteOutcome, dt as sniffImageType, et as CopyCoordinatorMember, f as PasteReadState, g as canRetryPasteState, h as PasteStatus, i as PasteErrorState, it as WEB_CUSTOM_FORMAT_PREFIX, j as DragEffectAllowed, k as DragCopyState, l as PasteMachineOptions, lt as normalizeMimeType, m as PasteState, n as PasteCancelReason, nt as RasterImageMimeType, o as PasteIdleState, ot as isWebCustomFormat, p as PasteReadingState, q as DEFAULT_RESET_AFTER_MS, r as PasteDropEventLike, rt as SVG_MIME_TYPE, s as PasteIgnoredReason, st as matchesMimePattern, t as PASTE_IDLE_STATE, tt as createCopyCoordinator, u as PasteMachineOptionsSource, ut as sniffImageBytes, v as ClipboardPermissionName, w as DragCopyOptions, x as watchClipboardPermission, y as ClipboardPermissionState, z as CopyIgnoredReason } from "./chunks/index-
|
|
5
|
-
import { a as ClipboardItemData, i as ClipboardItemConstructorLike, n as ClipboardAdapter, o as ClipboardLike, r as ClipboardEnvironment, s as createBrowserClipboardAdapter, t as BrowserClipboardAdapterOptions } from "./chunks/clipboard-adapter-
|
|
4
|
+
import { $ as CopyCoordinator, A as DragCopyStatus, B as CopyMachine, C as DragCopyItem, D as DragCopyPayload, E as DragCopyPassReason, F as applyDragCopy, G as CopyStatus, H as CopyMachineOptionsSource, I as registerDragCopy, J as ErrorState, K as CopyingState, L as CopiedState, M as DragMultiPayload, N as DragStartEventLike, O as DragCopySource, P as RegisterDragCopyResult, Q as createCopyMachine, R as CopyCancelReason, S as DragCopyDecision, T as DragCopyOutcome, U as CopyOutcome, V as CopyMachineOptions, W as CopyState, X as IdleState, Y as IDLE_STATE, Z as canRetryState, _ as createPasteMachine, a as PasteEventLike, at as isTextualMimeType, b as readClipboardPermission, c as PasteMachine, ct as normalizeClipboardType, d as PasteOutcome, dt as sniffImageType, et as CopyCoordinatorMember, f as PasteReadState, g as canRetryPasteState, h as PasteStatus, i as PasteErrorState, it as WEB_CUSTOM_FORMAT_PREFIX, j as DragEffectAllowed, k as DragCopyState, l as PasteMachineOptions, lt as normalizeMimeType, m as PasteState, n as PasteCancelReason, nt as RasterImageMimeType, o as PasteIdleState, ot as isWebCustomFormat, p as PasteReadingState, q as DEFAULT_RESET_AFTER_MS, r as PasteDropEventLike, rt as SVG_MIME_TYPE, s as PasteIgnoredReason, st as matchesMimePattern, t as PASTE_IDLE_STATE, tt as createCopyCoordinator, u as PasteMachineOptionsSource, ut as sniffImageBytes, v as ClipboardPermissionName, w as DragCopyOptions, x as watchClipboardPermission, y as ClipboardPermissionState, z as CopyIgnoredReason } from "./chunks/index-Ct2V52et.cjs";
|
|
5
|
+
import { a as ClipboardItemData, i as ClipboardItemConstructorLike, n as ClipboardAdapter, o as ClipboardLike, r as ClipboardEnvironment, s as createBrowserClipboardAdapter, t as BrowserClipboardAdapterOptions } from "./chunks/clipboard-adapter-CUvmAcRE.cjs";
|
|
6
6
|
import { _ as registerCopyInterceptor, a as CopyInterceptOptions, c as CopyInterceptTransform, d as DEFAULT_INTERCEPTED_EVENTS, f as InterceptedCopyKind, g as readCopySelection, h as interceptCopyEvent, i as CopyInterceptFailureMode, l as CopyInterceptorOptions, m as SyncMultiPayload, n as CopyEventLike, o as CopyInterceptOutcome, p as SyncCopyPayload, r as CopyInterceptDecision, s as CopyInterceptPassReason, t as ClipboardDataLike, u as CopySelection } from "./chunks/copy-interceptor-BClcHS_P.cjs";
|
|
7
7
|
import { a as createBrowserPasteAdapter, i as PasteEnvironment, n as PasteAdapter, r as PasteClipboardLike, t as BrowserPasteAdapterOptions } from "./chunks/paste-adapter-B6eucH3E.cjs";
|
|
8
8
|
export { BlobSource, BrowserClipboardAdapterOptions, type BrowserPasteAdapterOptions, ClipboardAdapter, ClipboardDataLike, ClipboardEnvironment, ClipboardItemConstructorLike, ClipboardItemData, type ClipboardItemLike, ClipboardLike, ClipboardOperation, ClipboardPermissionName, ClipboardPermissionState, CopiedState, CopyCancelReason, CopyCoordinator, CopyCoordinatorMember, CopyError, CopyErrorType, CopyEventLike, CopyFailure, CopyIgnoredReason, CopyInput, CopyInterceptDecision, CopyInterceptFailureMode, CopyInterceptOptions, CopyInterceptOutcome, CopyInterceptPassReason, CopyInterceptTransform, CopyInterceptorOptions, CopyMachine, CopyMachineOptions, CopyMachineOptionsSource, CopyOutcome, CopyPayload, CopyPayloadKind, CopySelection, CopySource, CopyState, CopyStatus, CopyingState, DEFAULT_INTERCEPTED_EVENTS, DEFAULT_MAX_RETRIES, DEFAULT_PASTE_ACCEPT, DEFAULT_PASTE_MAX_BYTES, DEFAULT_PASTE_MAX_ITEMS, DEFAULT_RESET_AFTER_MS, type DataTransferItemLike, DataTransferLike, DragCopyDecision, DragCopyItem, DragCopyOptions, DragCopyOutcome, DragCopyPassReason, DragCopyPayload, DragCopySource, DragCopyState, DragCopyStatus, DragEffectAllowed, DragMultiPayload, DragStartEventLike, ErrorState, HtmlPayload, IDLE_STATE, IMAGE_MIME_TYPE, IdleState, ImagePayload, InterceptedCopyKind, JsonPayload, MultiPayload, MultiPayloadItem, type OperationContext, PASTE_IDLE_STATE, type PasteAccept, type PasteAcceptShorthand, type PasteAdapter, PasteCancelReason, type PasteClipboardLike, PasteDropEventLike, type PasteEnvironment, PasteErrorState, PasteEventLike, PasteIdleState, PasteIgnoredReason, type PasteItem, type PasteLimits, PasteMachine, PasteMachineOptions, PasteMachineOptionsSource, PasteOutcome, type PasteReadOptions, type PasteReadResult, PasteReadState, PasteReadingState, type PasteResult, type PasteSource, PasteState, PasteStatus, RasterImageMimeType, RegisterDragCopyResult, type ResolvedPasteReadOptions, SVG_MIME_TYPE, SyncCopyPayload, SyncMultiPayload, TextPayload, WEB_CUSTOM_FORMAT_PREFIX, applyDragCopy, canAcceptDrag, canRetryPasteState, canRetryState, copyFailure, createBrowserClipboardAdapter, createBrowserPasteAdapter, createCopyCoordinator, createCopyError, createCopyMachine, createPasteMachine, describeCopyError, describePasteError, interceptCopyEvent, isBlob, isCopyFailure, isRetryableError, isTextualMimeType, isWebCustomFormat, matchesMimePattern, normalizeClipboardType, normalizeMimeType, normalizePayload, readClipboardPermission, readCopySelection, registerCopyInterceptor, registerDragCopy, resolveMaxRetries, resolvePasteReadOptions, serializeJson, sniffImageBytes, sniffImageType, toCopyError, validatePayload, watchClipboardPermission };
|
package/dist/core.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
|
|
2
2
|
import { A as resolveMaxRetries, C as describeCopyError, D as toCopyError, E as isRetryableError, O as DEFAULT_MAX_RETRIES, S as createCopyError, T as isCopyFailure, _ as ClipboardOperation, a as CopySource, b as CopyFailure, c as ImagePayload, d as MultiPayloadItem, f as TextPayload, g as validatePayload, h as serializeJson, i as CopyPayloadKind, k as OperationContext, l as JsonPayload, m as normalizePayload, n as CopyInput, o as HtmlPayload, p as isBlob, r as CopyPayload, s as IMAGE_MIME_TYPE, t as BlobSource, u as MultiPayload, v as CopyError, w as describePasteError, x as copyFailure, y as CopyErrorType } from "./chunks/payload-CcvSx_Hq.js";
|
|
3
3
|
import { _ as resolvePasteReadOptions, a as DataTransferItemLike, c as PasteAcceptShorthand, d as PasteReadOptions, f as PasteReadResult, g as canAcceptDrag, h as ResolvedPasteReadOptions, i as DEFAULT_PASTE_MAX_ITEMS, l as PasteItem, m as PasteSource, n as DEFAULT_PASTE_ACCEPT, o as DataTransferLike, p as PasteResult, r as DEFAULT_PASTE_MAX_BYTES, s as PasteAccept, t as ClipboardItemLike, u as PasteLimits } from "./chunks/paste-reader-DcXnRWQr.js";
|
|
4
|
-
import { $ as CopyCoordinator, A as DragCopyStatus, B as CopyMachine, C as DragCopyItem, D as DragCopyPayload, E as DragCopyPassReason, F as applyDragCopy, G as CopyStatus, H as CopyMachineOptionsSource, I as registerDragCopy, J as ErrorState, K as CopyingState, L as CopiedState, M as DragMultiPayload, N as DragStartEventLike, O as DragCopySource, P as RegisterDragCopyResult, Q as createCopyMachine, R as CopyCancelReason, S as DragCopyDecision, T as DragCopyOutcome, U as CopyOutcome, V as CopyMachineOptions, W as CopyState, X as IdleState, Y as IDLE_STATE, Z as canRetryState, _ as createPasteMachine, a as PasteEventLike, at as isTextualMimeType, b as readClipboardPermission, c as PasteMachine, ct as normalizeClipboardType, d as PasteOutcome, dt as sniffImageType, et as CopyCoordinatorMember, f as PasteReadState, g as canRetryPasteState, h as PasteStatus, i as PasteErrorState, it as WEB_CUSTOM_FORMAT_PREFIX, j as DragEffectAllowed, k as DragCopyState, l as PasteMachineOptions, lt as normalizeMimeType, m as PasteState, n as PasteCancelReason, nt as RasterImageMimeType, o as PasteIdleState, ot as isWebCustomFormat, p as PasteReadingState, q as DEFAULT_RESET_AFTER_MS, r as PasteDropEventLike, rt as SVG_MIME_TYPE, s as PasteIgnoredReason, st as matchesMimePattern, t as PASTE_IDLE_STATE, tt as createCopyCoordinator, u as PasteMachineOptionsSource, ut as sniffImageBytes, v as ClipboardPermissionName, w as DragCopyOptions, x as watchClipboardPermission, y as ClipboardPermissionState, z as CopyIgnoredReason } from "./chunks/index-
|
|
5
|
-
import { a as ClipboardItemData, i as ClipboardItemConstructorLike, n as ClipboardAdapter, o as ClipboardLike, r as ClipboardEnvironment, s as createBrowserClipboardAdapter, t as BrowserClipboardAdapterOptions } from "./chunks/clipboard-adapter-
|
|
4
|
+
import { $ as CopyCoordinator, A as DragCopyStatus, B as CopyMachine, C as DragCopyItem, D as DragCopyPayload, E as DragCopyPassReason, F as applyDragCopy, G as CopyStatus, H as CopyMachineOptionsSource, I as registerDragCopy, J as ErrorState, K as CopyingState, L as CopiedState, M as DragMultiPayload, N as DragStartEventLike, O as DragCopySource, P as RegisterDragCopyResult, Q as createCopyMachine, R as CopyCancelReason, S as DragCopyDecision, T as DragCopyOutcome, U as CopyOutcome, V as CopyMachineOptions, W as CopyState, X as IdleState, Y as IDLE_STATE, Z as canRetryState, _ as createPasteMachine, a as PasteEventLike, at as isTextualMimeType, b as readClipboardPermission, c as PasteMachine, ct as normalizeClipboardType, d as PasteOutcome, dt as sniffImageType, et as CopyCoordinatorMember, f as PasteReadState, g as canRetryPasteState, h as PasteStatus, i as PasteErrorState, it as WEB_CUSTOM_FORMAT_PREFIX, j as DragEffectAllowed, k as DragCopyState, l as PasteMachineOptions, lt as normalizeMimeType, m as PasteState, n as PasteCancelReason, nt as RasterImageMimeType, o as PasteIdleState, ot as isWebCustomFormat, p as PasteReadingState, q as DEFAULT_RESET_AFTER_MS, r as PasteDropEventLike, rt as SVG_MIME_TYPE, s as PasteIgnoredReason, st as matchesMimePattern, t as PASTE_IDLE_STATE, tt as createCopyCoordinator, u as PasteMachineOptionsSource, ut as sniffImageBytes, v as ClipboardPermissionName, w as DragCopyOptions, x as watchClipboardPermission, y as ClipboardPermissionState, z as CopyIgnoredReason } from "./chunks/index-U91G1nS9.js";
|
|
5
|
+
import { a as ClipboardItemData, i as ClipboardItemConstructorLike, n as ClipboardAdapter, o as ClipboardLike, r as ClipboardEnvironment, s as createBrowserClipboardAdapter, t as BrowserClipboardAdapterOptions } from "./chunks/clipboard-adapter-CdOzN135.js";
|
|
6
6
|
import { _ as registerCopyInterceptor, a as CopyInterceptOptions, c as CopyInterceptTransform, d as DEFAULT_INTERCEPTED_EVENTS, f as InterceptedCopyKind, g as readCopySelection, h as interceptCopyEvent, i as CopyInterceptFailureMode, l as CopyInterceptorOptions, m as SyncMultiPayload, n as CopyEventLike, o as CopyInterceptOutcome, p as SyncCopyPayload, r as CopyInterceptDecision, s as CopyInterceptPassReason, t as ClipboardDataLike, u as CopySelection } from "./chunks/copy-interceptor-D8c9EDnO.js";
|
|
7
7
|
import { a as createBrowserPasteAdapter, i as PasteEnvironment, n as PasteAdapter, r as PasteClipboardLike, t as BrowserPasteAdapterOptions } from "./chunks/paste-adapter-CfIDT3mp.js";
|
|
8
8
|
export { BlobSource, BrowserClipboardAdapterOptions, type BrowserPasteAdapterOptions, ClipboardAdapter, ClipboardDataLike, ClipboardEnvironment, ClipboardItemConstructorLike, ClipboardItemData, type ClipboardItemLike, ClipboardLike, ClipboardOperation, ClipboardPermissionName, ClipboardPermissionState, CopiedState, CopyCancelReason, CopyCoordinator, CopyCoordinatorMember, CopyError, CopyErrorType, CopyEventLike, CopyFailure, CopyIgnoredReason, CopyInput, CopyInterceptDecision, CopyInterceptFailureMode, CopyInterceptOptions, CopyInterceptOutcome, CopyInterceptPassReason, CopyInterceptTransform, CopyInterceptorOptions, CopyMachine, CopyMachineOptions, CopyMachineOptionsSource, CopyOutcome, CopyPayload, CopyPayloadKind, CopySelection, CopySource, CopyState, CopyStatus, CopyingState, DEFAULT_INTERCEPTED_EVENTS, DEFAULT_MAX_RETRIES, DEFAULT_PASTE_ACCEPT, DEFAULT_PASTE_MAX_BYTES, DEFAULT_PASTE_MAX_ITEMS, DEFAULT_RESET_AFTER_MS, type DataTransferItemLike, DataTransferLike, DragCopyDecision, DragCopyItem, DragCopyOptions, DragCopyOutcome, DragCopyPassReason, DragCopyPayload, DragCopySource, DragCopyState, DragCopyStatus, DragEffectAllowed, DragMultiPayload, DragStartEventLike, ErrorState, HtmlPayload, IDLE_STATE, IMAGE_MIME_TYPE, IdleState, ImagePayload, InterceptedCopyKind, JsonPayload, MultiPayload, MultiPayloadItem, type OperationContext, PASTE_IDLE_STATE, type PasteAccept, type PasteAcceptShorthand, type PasteAdapter, PasteCancelReason, type PasteClipboardLike, PasteDropEventLike, type PasteEnvironment, PasteErrorState, PasteEventLike, PasteIdleState, PasteIgnoredReason, type PasteItem, type PasteLimits, PasteMachine, PasteMachineOptions, PasteMachineOptionsSource, PasteOutcome, type PasteReadOptions, type PasteReadResult, PasteReadState, PasteReadingState, type PasteResult, type PasteSource, PasteState, PasteStatus, RasterImageMimeType, RegisterDragCopyResult, type ResolvedPasteReadOptions, SVG_MIME_TYPE, SyncCopyPayload, SyncMultiPayload, TextPayload, WEB_CUSTOM_FORMAT_PREFIX, applyDragCopy, canAcceptDrag, canRetryPasteState, canRetryState, copyFailure, createBrowserClipboardAdapter, createBrowserPasteAdapter, createCopyCoordinator, createCopyError, createCopyMachine, createPasteMachine, describeCopyError, describePasteError, interceptCopyEvent, isBlob, isCopyFailure, isRetryableError, isTextualMimeType, isWebCustomFormat, matchesMimePattern, normalizeClipboardType, normalizeMimeType, normalizePayload, readClipboardPermission, readCopySelection, registerCopyInterceptor, registerDragCopy, resolveMaxRetries, resolvePasteReadOptions, serializeJson, sniffImageBytes, sniffImageType, toCopyError, validatePayload, watchClipboardPermission };
|
package/dist/core.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { a as describePasteError, c as toCopyError, i as describeCopyError, n as copyFailure, o as isCopyFailure, r as createCopyError, s as isRetryableError, t as CopyFailure } from "./chunks/errors-CGcMvbhJ.js";
|
|
3
3
|
import { a as validatePayload, i as serializeJson, n as isBlob, r as normalizePayload, t as IMAGE_MIME_TYPE } from "./chunks/payload-5uJedhwz.js";
|
|
4
4
|
import { a as matchesMimePattern, c as sniffImageBytes, i as isWebCustomFormat, l as sniffImageType, n as WEB_CUSTOM_FORMAT_PREFIX, o as normalizeClipboardType, r as isTextualMimeType, s as normalizeMimeType, t as SVG_MIME_TYPE } from "./chunks/mime-aa-HA2dm.js";
|
|
5
|
-
import { t as createBrowserClipboardAdapter } from "./chunks/clipboard-adapter-
|
|
6
|
-
import { _ as DEFAULT_MAX_RETRIES, a as readClipboardPermission, b as createCopyCoordinator, c as registerDragCopy, d as readCopySelection, f as registerCopyInterceptor, g as createCopyMachine, h as canRetryState, i as createBrowserPasteAdapter, l as DEFAULT_INTERCEPTED_EVENTS, m as IDLE_STATE, n as canRetryPasteState, o as watchClipboardPermission, p as DEFAULT_RESET_AFTER_MS, r as createPasteMachine, s as applyDragCopy, t as PASTE_IDLE_STATE, u as interceptCopyEvent, y as resolveMaxRetries } from "./chunks/core-
|
|
5
|
+
import { t as createBrowserClipboardAdapter } from "./chunks/clipboard-adapter-0haPt4jJ.js";
|
|
6
|
+
import { _ as DEFAULT_MAX_RETRIES, a as readClipboardPermission, b as createCopyCoordinator, c as registerDragCopy, d as readCopySelection, f as registerCopyInterceptor, g as createCopyMachine, h as canRetryState, i as createBrowserPasteAdapter, l as DEFAULT_INTERCEPTED_EVENTS, m as IDLE_STATE, n as canRetryPasteState, o as watchClipboardPermission, p as DEFAULT_RESET_AFTER_MS, r as createPasteMachine, s as applyDragCopy, t as PASTE_IDLE_STATE, u as interceptCopyEvent, y as resolveMaxRetries } from "./chunks/core-CnAFS4Wh.js";
|
|
7
7
|
import { i as canAcceptDrag, l as resolvePasteReadOptions, n as DEFAULT_PASTE_MAX_BYTES, r as DEFAULT_PASTE_MAX_ITEMS, t as DEFAULT_PASTE_ACCEPT } from "./chunks/paste-reader-BpXOH_Px.js";
|
|
8
8
|
export { CopyFailure, DEFAULT_INTERCEPTED_EVENTS, DEFAULT_MAX_RETRIES, DEFAULT_PASTE_ACCEPT, DEFAULT_PASTE_MAX_BYTES, DEFAULT_PASTE_MAX_ITEMS, DEFAULT_RESET_AFTER_MS, IDLE_STATE, IMAGE_MIME_TYPE, PASTE_IDLE_STATE, SVG_MIME_TYPE, WEB_CUSTOM_FORMAT_PREFIX, applyDragCopy, canAcceptDrag, canRetryPasteState, canRetryState, copyFailure, createBrowserClipboardAdapter, createBrowserPasteAdapter, createCopyCoordinator, createCopyError, createCopyMachine, createPasteMachine, describeCopyError, describePasteError, interceptCopyEvent, isBlob, isCopyFailure, isRetryableError, isTextualMimeType, isWebCustomFormat, matchesMimePattern, normalizeClipboardType, normalizeMimeType, normalizePayload, readClipboardPermission, readCopySelection, registerCopyInterceptor, registerDragCopy, resolveMaxRetries, resolvePasteReadOptions, serializeJson, sniffImageBytes, sniffImageType, toCopyError, validatePayload, watchClipboardPermission };
|
package/dist/index.cjs
CHANGED
|
@@ -3,10 +3,10 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
|
3
3
|
const require_errors = require("./chunks/errors-CF2EQNbc.cjs");
|
|
4
4
|
const require_payload = require("./chunks/payload-DjSSLonm.cjs");
|
|
5
5
|
const require_mime = require("./chunks/mime--LB7kdqG.cjs");
|
|
6
|
-
const require_clipboard_adapter = require("./chunks/clipboard-adapter-
|
|
7
|
-
const require_core = require("./chunks/core-
|
|
6
|
+
const require_clipboard_adapter = require("./chunks/clipboard-adapter-5bmjKbyK.cjs");
|
|
7
|
+
const require_core = require("./chunks/core-BRMlZOtj.cjs");
|
|
8
8
|
const require_paste_reader = require("./chunks/paste-reader-BL51Jt1y.cjs");
|
|
9
|
-
const require_share = require("./chunks/share-
|
|
9
|
+
const require_share = require("./chunks/share-Bu5u2ItX.cjs");
|
|
10
10
|
const require_field = require("./chunks/field-C8A5Yxln.cjs");
|
|
11
11
|
let react = require("react");
|
|
12
12
|
let react_jsx_runtime = require("react/jsx-runtime");
|
package/dist/index.d.cts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
|
|
2
2
|
import { A as resolveMaxRetries, C as describeCopyError, D as toCopyError, E as isRetryableError, O as DEFAULT_MAX_RETRIES, S as createCopyError, T as isCopyFailure, _ as ClipboardOperation, a as CopySource, b as CopyFailure, c as ImagePayload, d as MultiPayloadItem, f as TextPayload, g as validatePayload, h as serializeJson, i as CopyPayloadKind, k as OperationContext, l as JsonPayload, m as normalizePayload, n as CopyInput, o as HtmlPayload, p as isBlob, r as CopyPayload, s as IMAGE_MIME_TYPE, t as BlobSource, u as MultiPayload, v as CopyError, w as describePasteError, x as copyFailure, y as CopyErrorType } from "./chunks/payload-qkAWVXWA.cjs";
|
|
3
3
|
import { _ as resolvePasteReadOptions, a as DataTransferItemLike, c as PasteAcceptShorthand, d as PasteReadOptions, f as PasteReadResult, g as canAcceptDrag, h as ResolvedPasteReadOptions, i as DEFAULT_PASTE_MAX_ITEMS, l as PasteItem, m as PasteSource, n as DEFAULT_PASTE_ACCEPT, o as DataTransferLike, p as PasteResult, r as DEFAULT_PASTE_MAX_BYTES, s as PasteAccept, t as ClipboardItemLike, u as PasteLimits } from "./chunks/paste-reader-DcXnRWQr.cjs";
|
|
4
|
-
import { $ as CopyCoordinator, A as DragCopyStatus, B as CopyMachine, C as DragCopyItem, D as DragCopyPayload, E as DragCopyPassReason, F as applyDragCopy, G as CopyStatus, H as CopyMachineOptionsSource, I as registerDragCopy, J as ErrorState, K as CopyingState, L as CopiedState, M as DragMultiPayload, N as DragStartEventLike, O as DragCopySource, P as RegisterDragCopyResult, Q as createCopyMachine, R as CopyCancelReason, S as DragCopyDecision, T as DragCopyOutcome, U as CopyOutcome, V as CopyMachineOptions, W as CopyState, X as IdleState, Y as IDLE_STATE, Z as canRetryState, _ as createPasteMachine, a as PasteEventLike, at as isTextualMimeType, b as readClipboardPermission, c as PasteMachine, ct as normalizeClipboardType, d as PasteOutcome, dt as sniffImageType, et as CopyCoordinatorMember, f as PasteReadState, g as canRetryPasteState, h as PasteStatus, i as PasteErrorState, it as WEB_CUSTOM_FORMAT_PREFIX, j as DragEffectAllowed, k as DragCopyState, l as PasteMachineOptions, lt as normalizeMimeType, m as PasteState, n as PasteCancelReason, nt as RasterImageMimeType, o as PasteIdleState, ot as isWebCustomFormat, p as PasteReadingState, q as DEFAULT_RESET_AFTER_MS, r as PasteDropEventLike, rt as SVG_MIME_TYPE, s as PasteIgnoredReason, st as matchesMimePattern, t as PASTE_IDLE_STATE, tt as createCopyCoordinator, u as PasteMachineOptionsSource, ut as sniffImageBytes, v as ClipboardPermissionName, w as DragCopyOptions, x as watchClipboardPermission, y as ClipboardPermissionState, z as CopyIgnoredReason } from "./chunks/index-
|
|
5
|
-
import { a as ClipboardItemData, i as ClipboardItemConstructorLike, n as ClipboardAdapter, o as ClipboardLike, r as ClipboardEnvironment, s as createBrowserClipboardAdapter, t as BrowserClipboardAdapterOptions } from "./chunks/clipboard-adapter-
|
|
4
|
+
import { $ as CopyCoordinator, A as DragCopyStatus, B as CopyMachine, C as DragCopyItem, D as DragCopyPayload, E as DragCopyPassReason, F as applyDragCopy, G as CopyStatus, H as CopyMachineOptionsSource, I as registerDragCopy, J as ErrorState, K as CopyingState, L as CopiedState, M as DragMultiPayload, N as DragStartEventLike, O as DragCopySource, P as RegisterDragCopyResult, Q as createCopyMachine, R as CopyCancelReason, S as DragCopyDecision, T as DragCopyOutcome, U as CopyOutcome, V as CopyMachineOptions, W as CopyState, X as IdleState, Y as IDLE_STATE, Z as canRetryState, _ as createPasteMachine, a as PasteEventLike, at as isTextualMimeType, b as readClipboardPermission, c as PasteMachine, ct as normalizeClipboardType, d as PasteOutcome, dt as sniffImageType, et as CopyCoordinatorMember, f as PasteReadState, g as canRetryPasteState, h as PasteStatus, i as PasteErrorState, it as WEB_CUSTOM_FORMAT_PREFIX, j as DragEffectAllowed, k as DragCopyState, l as PasteMachineOptions, lt as normalizeMimeType, m as PasteState, n as PasteCancelReason, nt as RasterImageMimeType, o as PasteIdleState, ot as isWebCustomFormat, p as PasteReadingState, q as DEFAULT_RESET_AFTER_MS, r as PasteDropEventLike, rt as SVG_MIME_TYPE, s as PasteIgnoredReason, st as matchesMimePattern, t as PASTE_IDLE_STATE, tt as createCopyCoordinator, u as PasteMachineOptionsSource, ut as sniffImageBytes, v as ClipboardPermissionName, w as DragCopyOptions, x as watchClipboardPermission, y as ClipboardPermissionState, z as CopyIgnoredReason } from "./chunks/index-Ct2V52et.cjs";
|
|
5
|
+
import { a as ClipboardItemData, i as ClipboardItemConstructorLike, n as ClipboardAdapter, o as ClipboardLike, r as ClipboardEnvironment, s as createBrowserClipboardAdapter, t as BrowserClipboardAdapterOptions } from "./chunks/clipboard-adapter-CUvmAcRE.cjs";
|
|
6
6
|
import { _ as registerCopyInterceptor, a as CopyInterceptOptions, c as CopyInterceptTransform, d as DEFAULT_INTERCEPTED_EVENTS, f as InterceptedCopyKind, g as readCopySelection, h as interceptCopyEvent, i as CopyInterceptFailureMode, l as CopyInterceptorOptions, m as SyncMultiPayload, n as CopyEventLike, o as CopyInterceptOutcome, p as SyncCopyPayload, r as CopyInterceptDecision, s as CopyInterceptPassReason, t as ClipboardDataLike, u as CopySelection } from "./chunks/copy-interceptor-BClcHS_P.cjs";
|
|
7
7
|
import { a as createBrowserPasteAdapter, i as PasteEnvironment, n as PasteAdapter, r as PasteClipboardLike, t as BrowserPasteAdapterOptions } from "./chunks/paste-adapter-B6eucH3E.cjs";
|
|
8
|
-
import { a as ShareMethod, c as ShareOutcome, i as ShareEnvironment, n as ResolvedShare, o as ShareMode, r as ShareContent, s as ShareOptions, t as CopyReason } from "./chunks/share-
|
|
8
|
+
import { a as ShareMethod, c as ShareOutcome, i as ShareEnvironment, n as ResolvedShare, o as ShareMode, r as ShareContent, s as ShareOptions, t as CopyReason } from "./chunks/share-DQFF73gt.cjs";
|
|
9
9
|
import { n as OtpFieldOptions, r as OtpSnapshot } from "./chunks/field-BTsKTs2M.cjs";
|
|
10
10
|
import { ButtonHTMLAttributes, CSSProperties, ClipboardEventHandler, DragEventHandler, FocusEventHandler, ForwardRefExoticComponent, HTMLAttributes, JSX, PointerEventHandler, ReactNode, RefAttributes, RefCallback } from "react";
|
|
11
11
|
//#region src/react/useCopy.d.ts
|
package/dist/index.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
|
|
2
2
|
import { A as resolveMaxRetries, C as describeCopyError, D as toCopyError, E as isRetryableError, O as DEFAULT_MAX_RETRIES, S as createCopyError, T as isCopyFailure, _ as ClipboardOperation, a as CopySource, b as CopyFailure, c as ImagePayload, d as MultiPayloadItem, f as TextPayload, g as validatePayload, h as serializeJson, i as CopyPayloadKind, k as OperationContext, l as JsonPayload, m as normalizePayload, n as CopyInput, o as HtmlPayload, p as isBlob, r as CopyPayload, s as IMAGE_MIME_TYPE, t as BlobSource, u as MultiPayload, v as CopyError, w as describePasteError, x as copyFailure, y as CopyErrorType } from "./chunks/payload-CcvSx_Hq.js";
|
|
3
3
|
import { _ as resolvePasteReadOptions, a as DataTransferItemLike, c as PasteAcceptShorthand, d as PasteReadOptions, f as PasteReadResult, g as canAcceptDrag, h as ResolvedPasteReadOptions, i as DEFAULT_PASTE_MAX_ITEMS, l as PasteItem, m as PasteSource, n as DEFAULT_PASTE_ACCEPT, o as DataTransferLike, p as PasteResult, r as DEFAULT_PASTE_MAX_BYTES, s as PasteAccept, t as ClipboardItemLike, u as PasteLimits } from "./chunks/paste-reader-DcXnRWQr.js";
|
|
4
|
-
import { $ as CopyCoordinator, A as DragCopyStatus, B as CopyMachine, C as DragCopyItem, D as DragCopyPayload, E as DragCopyPassReason, F as applyDragCopy, G as CopyStatus, H as CopyMachineOptionsSource, I as registerDragCopy, J as ErrorState, K as CopyingState, L as CopiedState, M as DragMultiPayload, N as DragStartEventLike, O as DragCopySource, P as RegisterDragCopyResult, Q as createCopyMachine, R as CopyCancelReason, S as DragCopyDecision, T as DragCopyOutcome, U as CopyOutcome, V as CopyMachineOptions, W as CopyState, X as IdleState, Y as IDLE_STATE, Z as canRetryState, _ as createPasteMachine, a as PasteEventLike, at as isTextualMimeType, b as readClipboardPermission, c as PasteMachine, ct as normalizeClipboardType, d as PasteOutcome, dt as sniffImageType, et as CopyCoordinatorMember, f as PasteReadState, g as canRetryPasteState, h as PasteStatus, i as PasteErrorState, it as WEB_CUSTOM_FORMAT_PREFIX, j as DragEffectAllowed, k as DragCopyState, l as PasteMachineOptions, lt as normalizeMimeType, m as PasteState, n as PasteCancelReason, nt as RasterImageMimeType, o as PasteIdleState, ot as isWebCustomFormat, p as PasteReadingState, q as DEFAULT_RESET_AFTER_MS, r as PasteDropEventLike, rt as SVG_MIME_TYPE, s as PasteIgnoredReason, st as matchesMimePattern, t as PASTE_IDLE_STATE, tt as createCopyCoordinator, u as PasteMachineOptionsSource, ut as sniffImageBytes, v as ClipboardPermissionName, w as DragCopyOptions, x as watchClipboardPermission, y as ClipboardPermissionState, z as CopyIgnoredReason } from "./chunks/index-
|
|
5
|
-
import { a as ClipboardItemData, i as ClipboardItemConstructorLike, n as ClipboardAdapter, o as ClipboardLike, r as ClipboardEnvironment, s as createBrowserClipboardAdapter, t as BrowserClipboardAdapterOptions } from "./chunks/clipboard-adapter-
|
|
4
|
+
import { $ as CopyCoordinator, A as DragCopyStatus, B as CopyMachine, C as DragCopyItem, D as DragCopyPayload, E as DragCopyPassReason, F as applyDragCopy, G as CopyStatus, H as CopyMachineOptionsSource, I as registerDragCopy, J as ErrorState, K as CopyingState, L as CopiedState, M as DragMultiPayload, N as DragStartEventLike, O as DragCopySource, P as RegisterDragCopyResult, Q as createCopyMachine, R as CopyCancelReason, S as DragCopyDecision, T as DragCopyOutcome, U as CopyOutcome, V as CopyMachineOptions, W as CopyState, X as IdleState, Y as IDLE_STATE, Z as canRetryState, _ as createPasteMachine, a as PasteEventLike, at as isTextualMimeType, b as readClipboardPermission, c as PasteMachine, ct as normalizeClipboardType, d as PasteOutcome, dt as sniffImageType, et as CopyCoordinatorMember, f as PasteReadState, g as canRetryPasteState, h as PasteStatus, i as PasteErrorState, it as WEB_CUSTOM_FORMAT_PREFIX, j as DragEffectAllowed, k as DragCopyState, l as PasteMachineOptions, lt as normalizeMimeType, m as PasteState, n as PasteCancelReason, nt as RasterImageMimeType, o as PasteIdleState, ot as isWebCustomFormat, p as PasteReadingState, q as DEFAULT_RESET_AFTER_MS, r as PasteDropEventLike, rt as SVG_MIME_TYPE, s as PasteIgnoredReason, st as matchesMimePattern, t as PASTE_IDLE_STATE, tt as createCopyCoordinator, u as PasteMachineOptionsSource, ut as sniffImageBytes, v as ClipboardPermissionName, w as DragCopyOptions, x as watchClipboardPermission, y as ClipboardPermissionState, z as CopyIgnoredReason } from "./chunks/index-U91G1nS9.js";
|
|
5
|
+
import { a as ClipboardItemData, i as ClipboardItemConstructorLike, n as ClipboardAdapter, o as ClipboardLike, r as ClipboardEnvironment, s as createBrowserClipboardAdapter, t as BrowserClipboardAdapterOptions } from "./chunks/clipboard-adapter-CdOzN135.js";
|
|
6
6
|
import { _ as registerCopyInterceptor, a as CopyInterceptOptions, c as CopyInterceptTransform, d as DEFAULT_INTERCEPTED_EVENTS, f as InterceptedCopyKind, g as readCopySelection, h as interceptCopyEvent, i as CopyInterceptFailureMode, l as CopyInterceptorOptions, m as SyncMultiPayload, n as CopyEventLike, o as CopyInterceptOutcome, p as SyncCopyPayload, r as CopyInterceptDecision, s as CopyInterceptPassReason, t as ClipboardDataLike, u as CopySelection } from "./chunks/copy-interceptor-D8c9EDnO.js";
|
|
7
7
|
import { a as createBrowserPasteAdapter, i as PasteEnvironment, n as PasteAdapter, r as PasteClipboardLike, t as BrowserPasteAdapterOptions } from "./chunks/paste-adapter-CfIDT3mp.js";
|
|
8
|
-
import { a as ShareMethod, c as ShareOutcome, i as ShareEnvironment, n as ResolvedShare, o as ShareMode, r as ShareContent, s as ShareOptions, t as CopyReason } from "./chunks/share-
|
|
8
|
+
import { a as ShareMethod, c as ShareOutcome, i as ShareEnvironment, n as ResolvedShare, o as ShareMode, r as ShareContent, s as ShareOptions, t as CopyReason } from "./chunks/share-DMqvWz32.js";
|
|
9
9
|
import { n as OtpFieldOptions, r as OtpSnapshot } from "./chunks/field-BTsKTs2M.js";
|
|
10
10
|
import { ButtonHTMLAttributes, CSSProperties, ClipboardEventHandler, DragEventHandler, FocusEventHandler, ForwardRefExoticComponent, HTMLAttributes, JSX, PointerEventHandler, ReactNode, RefAttributes, RefCallback } from "react";
|
|
11
11
|
//#region src/react/useCopy.d.ts
|
package/dist/index.js
CHANGED
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
import { a as describePasteError, c as toCopyError, i as describeCopyError, n as copyFailure, o as isCopyFailure, r as createCopyError, s as isRetryableError, t as CopyFailure } from "./chunks/errors-CGcMvbhJ.js";
|
|
3
3
|
import { a as validatePayload, i as serializeJson, n as isBlob, r as normalizePayload, t as IMAGE_MIME_TYPE } from "./chunks/payload-5uJedhwz.js";
|
|
4
4
|
import { a as matchesMimePattern, c as sniffImageBytes, i as isWebCustomFormat, l as sniffImageType, n as WEB_CUSTOM_FORMAT_PREFIX, o as normalizeClipboardType, r as isTextualMimeType, s as normalizeMimeType, t as SVG_MIME_TYPE } from "./chunks/mime-aa-HA2dm.js";
|
|
5
|
-
import { t as createBrowserClipboardAdapter } from "./chunks/clipboard-adapter-
|
|
6
|
-
import { _ as DEFAULT_MAX_RETRIES, a as readClipboardPermission, b as createCopyCoordinator, c as registerDragCopy, d as readCopySelection, f as registerCopyInterceptor, g as createCopyMachine, h as canRetryState, i as createBrowserPasteAdapter, l as DEFAULT_INTERCEPTED_EVENTS, m as IDLE_STATE, n as canRetryPasteState, o as watchClipboardPermission, p as DEFAULT_RESET_AFTER_MS, r as createPasteMachine, s as applyDragCopy, t as PASTE_IDLE_STATE, u as interceptCopyEvent, v as invoke, y as resolveMaxRetries } from "./chunks/core-
|
|
5
|
+
import { t as createBrowserClipboardAdapter } from "./chunks/clipboard-adapter-0haPt4jJ.js";
|
|
6
|
+
import { _ as DEFAULT_MAX_RETRIES, a as readClipboardPermission, b as createCopyCoordinator, c as registerDragCopy, d as readCopySelection, f as registerCopyInterceptor, g as createCopyMachine, h as canRetryState, i as createBrowserPasteAdapter, l as DEFAULT_INTERCEPTED_EVENTS, m as IDLE_STATE, n as canRetryPasteState, o as watchClipboardPermission, p as DEFAULT_RESET_AFTER_MS, r as createPasteMachine, s as applyDragCopy, t as PASTE_IDLE_STATE, u as interceptCopyEvent, v as invoke, y as resolveMaxRetries } from "./chunks/core-CnAFS4Wh.js";
|
|
7
7
|
import { i as canAcceptDrag, l as resolvePasteReadOptions, n as DEFAULT_PASTE_MAX_BYTES, r as DEFAULT_PASTE_MAX_ITEMS, t as DEFAULT_PASTE_ACCEPT } from "./chunks/paste-reader-BpXOH_Px.js";
|
|
8
|
-
import { i as shareOrCopy, r as shareMethod, t as TOUCH_FIRST } from "./chunks/share-
|
|
8
|
+
import { i as shareOrCopy, r as shareMethod, t as TOUCH_FIRST } from "./chunks/share-CL72PUqq.js";
|
|
9
9
|
import { t as createOtpField } from "./chunks/field-CDCN9x0L.js";
|
|
10
10
|
import { createContext, forwardRef, useCallback, useContext, useEffect, useId, useLayoutEffect, useMemo, useRef, useState, useSyncExternalStore } from "react";
|
|
11
11
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
package/dist/share.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const require_share = require("./chunks/share-
|
|
3
|
+
const require_share = require("./chunks/share-Bu5u2ItX.cjs");
|
|
4
4
|
exports.describeShareError = require_share.describeShareError;
|
|
5
5
|
exports.shareMethod = require_share.shareMethod;
|
|
6
6
|
exports.shareOrCopy = require_share.shareOrCopy;
|
package/dist/share.d.cts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
|
|
2
|
-
import { a as ShareMethod, c as ShareOutcome, d as shareOrCopy, i as ShareEnvironment, l as describeShareError, n as ResolvedShare, o as ShareMode, r as ShareContent, s as ShareOptions, t as CopyReason, u as shareMethod } from "./chunks/share-
|
|
2
|
+
import { a as ShareMethod, c as ShareOutcome, d as shareOrCopy, i as ShareEnvironment, l as describeShareError, n as ResolvedShare, o as ShareMode, r as ShareContent, s as ShareOptions, t as CopyReason, u as shareMethod } from "./chunks/share-DQFF73gt.cjs";
|
|
3
3
|
export { type CopyReason, type ResolvedShare, type ShareContent, type ShareEnvironment, type ShareMethod, type ShareMode, type ShareOptions, type ShareOutcome, describeShareError, shareMethod, shareOrCopy };
|
package/dist/share.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
|
|
2
|
-
import { a as ShareMethod, c as ShareOutcome, d as shareOrCopy, i as ShareEnvironment, l as describeShareError, n as ResolvedShare, o as ShareMode, r as ShareContent, s as ShareOptions, t as CopyReason, u as shareMethod } from "./chunks/share-
|
|
2
|
+
import { a as ShareMethod, c as ShareOutcome, d as shareOrCopy, i as ShareEnvironment, l as describeShareError, n as ResolvedShare, o as ShareMode, r as ShareContent, s as ShareOptions, t as CopyReason, u as shareMethod } from "./chunks/share-DMqvWz32.js";
|
|
3
3
|
export { type CopyReason, type ResolvedShare, type ShareContent, type ShareEnvironment, type ShareMethod, type ShareMode, type ShareOptions, type ShareOutcome, describeShareError, shareMethod, shareOrCopy };
|
package/dist/share.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
|
|
2
|
-
export { n as describeShareError, r as shareMethod, i as shareOrCopy } from "./chunks/share-
|
|
2
|
+
export { n as describeShareError, r as shareMethod, i as shareOrCopy } from "./chunks/share-CL72PUqq.js";
|
package/dist/testing.d.cts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
|
|
2
2
|
import { b as CopyFailure, r as CopyPayload, v as CopyError } from "./chunks/payload-qkAWVXWA.cjs";
|
|
3
3
|
import { f as PasteReadResult, l as PasteItem, m as PasteSource, p as PasteResult } from "./chunks/paste-reader-DcXnRWQr.cjs";
|
|
4
|
-
import { n as ClipboardAdapter } from "./chunks/clipboard-adapter-
|
|
4
|
+
import { n as ClipboardAdapter } from "./chunks/clipboard-adapter-CUvmAcRE.cjs";
|
|
5
5
|
import { n as PasteAdapter } from "./chunks/paste-adapter-B6eucH3E.cjs";
|
|
6
6
|
//#region src/testing/index.d.ts
|
|
7
7
|
/**
|
package/dist/testing.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
|
|
2
2
|
import { b as CopyFailure, r as CopyPayload, v as CopyError } from "./chunks/payload-CcvSx_Hq.js";
|
|
3
3
|
import { f as PasteReadResult, l as PasteItem, m as PasteSource, p as PasteResult } from "./chunks/paste-reader-DcXnRWQr.js";
|
|
4
|
-
import { n as ClipboardAdapter } from "./chunks/clipboard-adapter-
|
|
4
|
+
import { n as ClipboardAdapter } from "./chunks/clipboard-adapter-CdOzN135.js";
|
|
5
5
|
import { n as PasteAdapter } from "./chunks/paste-adapter-CfIDT3mp.js";
|
|
6
6
|
//#region src/testing/index.d.ts
|
|
7
7
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-smart-copy",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.27.0",
|
|
4
4
|
"description": "Headless, type-safe clipboard interactions for React: copy and paste text, rich HTML, images, spreadsheet tables, typed application data, Markdown, code, privacy-safe images, links, sharing, colours, portable rich text, clean pastes from Word and Google Docs, safe file and folder drops with content-type checks, secret detection and redaction in pastes and copies, one-time codes read from pasted messages into accessible code fields with SMS autofill and WebOTP, numbers and amounts pasted and copied exactly across locales, and lists of e-mail recipients pasted from Outlook, Gmail and spreadsheets, checked for lookalike domains, with coordinated copy groups, SVG/DOM capture, Trojan Source and homoglyph detection, honest error states, retry and screen-reader announcements.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -393,7 +393,7 @@
|
|
|
393
393
|
"name": "useCopy (text only)",
|
|
394
394
|
"path": "dist/index.js",
|
|
395
395
|
"import": "{ useCopy }",
|
|
396
|
-
"limit": "
|
|
396
|
+
"limit": "4.2 kB"
|
|
397
397
|
},
|
|
398
398
|
{
|
|
399
399
|
"name": "usePaste",
|
|
@@ -411,7 +411,7 @@
|
|
|
411
411
|
"name": "CopyField + CopyGroup (everything copy, React)",
|
|
412
412
|
"path": "dist/index.js",
|
|
413
413
|
"import": "{ CopyField, CopyGroup }",
|
|
414
|
-
"limit": "
|
|
414
|
+
"limit": "6.25 kB"
|
|
415
415
|
},
|
|
416
416
|
{
|
|
417
417
|
"name": "PasteField (everything paste, React)",
|
|
@@ -429,7 +429,7 @@
|
|
|
429
429
|
"name": "useShare",
|
|
430
430
|
"path": "dist/index.js",
|
|
431
431
|
"import": "{ useShare }",
|
|
432
|
-
"limit": "5.
|
|
432
|
+
"limit": "5.75 kB"
|
|
433
433
|
},
|
|
434
434
|
{
|
|
435
435
|
"name": "useClipboardPermission",
|
|
@@ -440,7 +440,7 @@
|
|
|
440
440
|
{
|
|
441
441
|
"name": "core, all exports (framework-agnostic)",
|
|
442
442
|
"path": "dist/core.js",
|
|
443
|
-
"limit": "
|
|
443
|
+
"limit": "9.35 kB"
|
|
444
444
|
},
|
|
445
445
|
{
|
|
446
446
|
"name": "capture, all exports",
|
|
@@ -536,13 +536,13 @@
|
|
|
536
536
|
{
|
|
537
537
|
"name": "share, all exports",
|
|
538
538
|
"path": "dist/share.js",
|
|
539
|
-
"limit": "
|
|
539
|
+
"limit": "5.55 kB"
|
|
540
540
|
},
|
|
541
541
|
{
|
|
542
542
|
"name": "share: shareOrCopy (no React)",
|
|
543
543
|
"path": "dist/share.js",
|
|
544
544
|
"import": "{ shareOrCopy }",
|
|
545
|
-
"limit": "
|
|
545
|
+
"limit": "5.15 kB"
|
|
546
546
|
},
|
|
547
547
|
{
|
|
548
548
|
"name": "color, all exports",
|
|
@@ -667,7 +667,7 @@
|
|
|
667
667
|
"dist/link.js": "{ linkPayload }",
|
|
668
668
|
"dist/color.js": "{ formatColor }"
|
|
669
669
|
},
|
|
670
|
-
"limit": "25 kB"
|
|
670
|
+
"limit": "25.35 kB"
|
|
671
671
|
}
|
|
672
672
|
],
|
|
673
673
|
"publishConfig": {
|