{"version":3,"file":"clipboard-polyfill.js","sources":["../../src/ClipboardItem/data-types.ts","../../src/debug.ts","../../src/globals.ts","../../src/strategies/internet-explorer.ts","../../src/strategies/dom.ts","../../src/implementations/write-fallback.ts","../../src/implementations/text.ts","../../src/ClipboardItem/check.ts","../../src/ClipboardItem/ClipboardItemPolyfill.ts","../../src/ClipboardItem/convert.ts","../../src/implementations/blob.ts"],"sourcesContent":["export const TEXT_PLAIN = \"text/plain\";\nexport const TEXT_HTML = \"text/html\";\n","/******** Debug Logging ********/\n\n// tslint:disable-next-line: no-empty\nlet debugLogImpl = (s: string) => {};\n\nexport function debugLog(s: string) {\n debugLogImpl(s);\n}\n\nexport function setDebugLog(logFn: (s: string) => void) {\n debugLogImpl = logFn;\n}\n\n/******** Warnings ********/\n\nlet showWarnings = true;\n\nexport function suppressWarnings() {\n showWarnings = false;\n}\n\nexport function shouldShowWarnings(): boolean {\n return showWarnings;\n}\n\n// Workaround for:\n// - IE9 (can't bind console functions directly), and\n// - Edge Issue #14495220 (referencing `console` without F12 Developer Tools can cause an exception)\nfunction warnOrLog() {\n // tslint:disable-next-line: no-console\n (console.warn || console.log).apply(console, arguments);\n}\n\nexport const warn = warnOrLog.bind(\"[clipboard-polyfill]\");\n","\n// We cache the references so that callers can do the following without causing infinite recursion/bugs:\n//\n// import * as clipboard from \"clipboard-polyfill\";\n// navigator.clipboard = clipboard;\n//\n// import { ClipboardItem } from \"clipboard-polyfill\";\n// window.ClipboardItem = clipboard;\n//\n// Note that per the spec:\n//\n// - is *not* possible to overwrite `navigator.clipboard`. https://www.w3.org/TR/clipboard-apis/#navigator-interface\n// - it *may* be possible to overwrite `window.ClipboardItem`.\n//\n// Chrome 83 and Safari 13.1 match this. We save the original\n// `navigator.clipboard` anyhow, because 1) it doesn't cost more code (in fact,\n// it probably saves code), and 2) just in case an unknown/future implementation\n// allows overwriting `navigator.clipboard` like this.\n\nimport { ClipboardItemConstructor, Clipboard, ClipboardItems } from \"./ClipboardItem/spec\";\n\nconst originalNavigator = (typeof navigator === \"undefined\" ? undefined : navigator);\nconst originalNavigatorClipboard: Clipboard | undefined = originalNavigator?.clipboard as any;\nexport const originalNavigatorClipboardRead: (() => Promise) | undefined = originalNavigatorClipboard?.read?.bind(originalNavigatorClipboard);\nexport const originalNavigatorClipboardReadText: (() => Promise) | undefined = originalNavigatorClipboard?.readText?.bind(originalNavigatorClipboard);\nexport const originalNavigatorClipboardWrite: ((data: ClipboardItems) => Promise) | undefined = originalNavigatorClipboard?.write?.bind(originalNavigatorClipboard);\nexport const originalNavigatorClipboardWriteText: ((data: string) => Promise) | undefined = originalNavigatorClipboard?.writeText?.bind(originalNavigatorClipboard);\n\n// The spec specifies that this goes on `window`, not e.g. `globalThis`. It's not (currently) available in workers.\nexport const originalWindow = (typeof window === \"undefined\" ? undefined : window);\nexport const originalWindowClipboardItem: ClipboardItemConstructor | undefined = originalWindow?.ClipboardItem;\n","import { originalWindow } from \"../globals\";\n\ninterface IEWindow extends Window {\n clipboardData: {\n setData: (key: string, value: string) => boolean;\n // Always results in a string: https://msdn.microsoft.com/en-us/library/ms536436(v=vs.85).aspx\n getData: (key: string) => string;\n };\n}\n\nconst ieWindow = (originalWindow as unknown) as IEWindow;\n\nexport function seemToBeInIE(): boolean {\n return (\n typeof ClipboardEvent === \"undefined\" &&\n typeof ieWindow.clipboardData !== \"undefined\" &&\n typeof ieWindow.clipboardData.setData !== \"undefined\"\n );\n}\n\nexport function writeTextIE(text: string): boolean {\n // IE supports text or URL, but not HTML: https://msdn.microsoft.com/en-us/library/ms536744(v=vs.85).aspx\n // TODO: Write URLs to `text/uri-list`? https://developer.mozilla.org/en-US/docs/Web/API/HTML_Drag_and_Drop_API/Recommended_drag_types\n return ieWindow.clipboardData.setData(\"Text\", text);\n}\n\n// Returns \"\" if the read failed, e.g. because the user rejected the permission.\nexport async function readTextIE(): Promise {\n const text = ieWindow.clipboardData.getData(\"Text\");\n if (text === \"\") {\n throw new Error(\n \"Empty clipboard or could not read plain text from clipboard\"\n );\n }\n return text;\n}\n","import { StringItem } from \"../ClipboardItem/convert\";\nimport { TEXT_PLAIN } from \"../ClipboardItem/data-types\";\nimport { debugLog } from \"../debug\";\n\n/******** Implementations ********/\n\nclass FallbackTracker {\n public success: boolean = false;\n}\n\nfunction copyListener(\n tracker: FallbackTracker,\n data: StringItem,\n e: ClipboardEvent,\n): void {\n debugLog(\"listener called\");\n tracker.success = true;\n // tslint:disable-next-line: forin\n for (const type in data) {\n const value = data[type];\n const clipboardData = e.clipboardData!;\n clipboardData.setData(type, value);\n if (type === TEXT_PLAIN && clipboardData.getData(type) !== value) {\n debugLog(\"setting text/plain failed\");\n tracker.success = false;\n }\n }\n e.preventDefault();\n}\n\nexport function execCopy(data: StringItem): boolean {\n const tracker = new FallbackTracker();\n const listener = copyListener.bind(this, tracker, data);\n\n document.addEventListener(\"copy\", listener);\n try {\n // We ignore the return value, since FallbackTracker tells us whether the\n // listener was called. It seems that checking the return value here gives\n // us no extra information in any browser.\n document.execCommand(\"copy\");\n } finally {\n document.removeEventListener(\"copy\", listener);\n }\n return tracker.success;\n}\n\n// Temporarily select a DOM element, so that `execCommand()` is not rejected.\nexport function copyUsingTempSelection(\n e: HTMLElement,\n data: StringItem,\n): boolean {\n selectionSet(e);\n const success = execCopy(data);\n selectionClear();\n return success;\n}\n\n// Create a temporary DOM element to select, so that `execCommand()` is not\n// rejected.\nexport function copyUsingTempElem(data: StringItem): boolean {\n const tempElem = document.createElement(\"div\");\n // Setting an individual property does not support `!important`, so we set the\n // whole style instead of just the `-webkit-user-select` property.\n tempElem.setAttribute(\"style\", \"-webkit-user-select: text !important\");\n // Place some text in the elem so that Safari has something to select.\n tempElem.textContent = \"temporary element\";\n document.body.appendChild(tempElem);\n\n const success = copyUsingTempSelection(tempElem, data);\n\n document.body.removeChild(tempElem);\n return success;\n}\n\n// Uses shadow DOM.\nexport function copyTextUsingDOM(str: string): boolean {\n debugLog(\"copyTextUsingDOM\");\n\n const tempElem = document.createElement(\"div\");\n // Setting an individual property does not support `!important`, so we set the\n // whole style instead of just the `-webkit-user-select` property.\n tempElem.setAttribute(\"style\", \"-webkit-user-select: text !important\");\n // Use shadow DOM if available.\n let spanParent: Node = tempElem;\n if (tempElem.attachShadow) {\n debugLog(\"Using shadow DOM.\");\n spanParent = tempElem.attachShadow({ mode: \"open\" });\n }\n\n const span = document.createElement(\"span\");\n span.innerText = str;\n\n spanParent.appendChild(span);\n document.body.appendChild(tempElem);\n selectionSet(span);\n\n const result = document.execCommand(\"copy\");\n\n selectionClear();\n document.body.removeChild(tempElem);\n\n return result;\n}\n\n/******** Selection ********/\n\nfunction selectionSet(elem: Element): void {\n const sel = document.getSelection();\n if (sel) {\n const range = document.createRange();\n range.selectNodeContents(elem);\n sel.removeAllRanges();\n sel.addRange(range);\n }\n}\n\nfunction selectionClear(): void {\n const sel = document.getSelection();\n if (sel) {\n sel.removeAllRanges();\n }\n}\n","import { StringItem } from \"../ClipboardItem/convert\";\nimport { TEXT_PLAIN } from \"../ClipboardItem/data-types\";\nimport { debugLog } from \"../debug\";\nimport {\n copyTextUsingDOM,\n copyUsingTempElem,\n copyUsingTempSelection,\n execCopy\n} from \"../strategies/dom\";\nimport { seemToBeInIE, writeTextIE } from \"../strategies/internet-explorer\";\n\n// Note: the fallback order is carefully tuned for compatibility. It might seem\n// safe to move some of them around, but do not do so without testing all browsers.\nexport async function writeFallback(stringItem: StringItem): Promise {\n const hasTextPlain = TEXT_PLAIN in stringItem;\n\n // Internet Explorer\n if (seemToBeInIE()) {\n if (!hasTextPlain) {\n throw new Error(\"No `text/plain` value was specified.\");\n }\n if (writeTextIE(stringItem[TEXT_PLAIN])) {\n return true;\n } else {\n throw new Error(\"Copying failed, possibly because the user rejected it.\");\n }\n }\n\n if (execCopy(stringItem)) {\n debugLog(\"regular execCopy worked\");\n return true;\n }\n\n // Success detection on Edge is not possible, due to bugs in all 4\n // detection mechanisms we could try to use. Assume success.\n if (navigator.userAgent.indexOf(\"Edge\") > -1) {\n debugLog('UA \"Edge\" => assuming success');\n return true;\n }\n\n // Fallback 1 for desktop Safari.\n if (copyUsingTempSelection(document.body, stringItem)) {\n debugLog(\"copyUsingTempSelection worked\");\n return true;\n }\n\n // Fallback 2 for desktop Safari.\n if (copyUsingTempElem(stringItem)) {\n debugLog(\"copyUsingTempElem worked\");\n return true;\n }\n\n // Fallback for iOS Safari.\n if (copyTextUsingDOM(stringItem[TEXT_PLAIN])) {\n debugLog(\"copyTextUsingDOM worked\");\n return true;\n }\n\n return false;\n}\n","import { StringItem } from \"../ClipboardItem/convert\";\nimport { TEXT_PLAIN } from \"../ClipboardItem/data-types\";\nimport { debugLog } from \"../debug\";\nimport { originalNavigatorClipboardReadText, originalNavigatorClipboardWriteText } from \"../globals\";\nimport { readTextIE, seemToBeInIE } from \"../strategies/internet-explorer\";\nimport { writeFallback } from \"./write-fallback\";\n\nfunction stringToStringItem(s: string): StringItem {\n const stringItem: StringItem = {};\n stringItem[TEXT_PLAIN] = s;\n return stringItem\n}\n\nexport async function writeText(s: string): Promise {\n // Use the browser implementation if it exists.\n if (originalNavigatorClipboardWriteText) {\n debugLog(\"Using `navigator.clipboard.writeText()`.\");\n return originalNavigatorClipboardWriteText(s);\n }\n\n if (!writeFallback(stringToStringItem(s))) {\n throw new Error(\"writeText() failed\");\n }\n}\n\nexport async function readText(): Promise {\n // Use the browser implementation if it exists.\n if (originalNavigatorClipboardReadText) {\n debugLog(\"Using `navigator.clipboard.readText()`.\");\n return originalNavigatorClipboardReadText();\n }\n\n // Fallback for IE.\n if (seemToBeInIE()) {\n debugLog(\"Reading text using IE strategy.\");\n return readTextIE();\n }\n\n throw new Error(\"Read is not supported in your browser.\");\n}\n","import { ClipboardItemInterface } from \"./spec\";\n\nexport function hasItemWithType(\n clipboardItems: ClipboardItemInterface[],\n typeName: string\n): boolean {\n for (const item of clipboardItems) {\n if (item.types.indexOf(typeName) !== -1) {\n return true;\n }\n }\n return false;\n}\n","import { stringToBlob } from \"./convert\";\nimport {\n ClipboardItemConstructor,\n ClipboardItemDataType,\n ClipboardItemInterface,\n ClipboardItemOptions,\n PresentationStyle,\n} from \"./spec\";\n\nexport class ClipboardItemPolyfillImpl implements ClipboardItemInterface {\n public readonly types: string[];\n public readonly presentationStyle: PresentationStyle;\n // We use an underscore to suggest that this field is private. We could\n // theoretically transpile private fields to closure-scoped vars, but\n // TypeScript doesn't do this. So we do the most compatible thing, and only\n // mark it as private.\n private _items: { [type: string]: Blob };\n public constructor(\n // TODO: The spec specifies values as `ClipboardItemData`, but\n // implementations (e.g. Chrome 83) seem to assume `ClipboardItemDataType`\n // values. https://github.com/w3c/clipboard-apis/pull/126\n items: { [type: string]: ClipboardItemDataType },\n options: ClipboardItemOptions = {}\n ) {\n this.types = Object.keys(items);\n this._items = {};\n // We avoid `Object.entries()` to avoid potential compatibility issues.\n for (const type in items) {\n const item = items[type];\n if (typeof item === \"string\") {\n this._items[type] = stringToBlob(type, item);\n } else {\n this._items[type] = item;\n }\n }\n // The explicit default for `presentationStyle` is \"unspecified\":\n // https://www.w3.org/TR/clipboard-apis/#clipboard-interface\n this.presentationStyle = options?.presentationStyle ?? \"unspecified\";\n }\n\n public async getType(type: string): Promise {\n return this._items[type];\n }\n}\n\nexport const ClipboardItemPolyfill: ClipboardItemConstructor = ClipboardItemPolyfillImpl;\n","import { ClipboardItemPolyfill } from \"./ClipboardItemPolyfill\";\nimport { TEXT_PLAIN } from \"./data-types\";\nimport { ClipboardItemInterface, ClipboardItemOptions } from \"./spec\";\nimport { originalWindowClipboardItem } from \"../globals\";\n\nexport function stringToBlob(type: string, str: string): Blob {\n return new Blob([str], {\n type,\n });\n}\n\nexport async function blobToString(blob: Blob): Promise {\n return new Promise((resolve, reject) => {\n const fileReader = new FileReader();\n fileReader.addEventListener(\"load\", () => {\n const result = fileReader.result;\n if (typeof result === \"string\") {\n resolve(result);\n } else {\n reject(\"could not convert blob to string\");\n }\n });\n fileReader.readAsText(blob);\n });\n}\n\nexport async function clipboardItemToGlobalClipboardItem(\n clipboardItem: ClipboardItemInterface\n): Promise {\n // Note that we use `Blob` instead of `ClipboardItemDataType`. This is because\n // Chrome 83 can only accept `Blob` (not `string`). The return value of\n // `getType()` is already `Blob` per the spec, so this is simple for us.\n const items: { [type: string]: Blob } = {};\n for (const type of clipboardItem.types) {\n items[type] = await clipboardItem.getType(type);\n }\n const options: ClipboardItemOptions = {};\n if (clipboardItem.presentationStyle) {\n options.presentationStyle = clipboardItem.presentationStyle;\n }\n return new originalWindowClipboardItem!(items, options);\n}\n\nexport function textToClipboardItem(text: string): ClipboardItemInterface {\n const items: { [type: string]: Blob } = {};\n items[TEXT_PLAIN] = stringToBlob(text, TEXT_PLAIN);\n return new ClipboardItemPolyfill(items);\n}\n\nexport async function getTypeAsString(\n clipboardItem: ClipboardItemInterface,\n type: string\n): Promise {\n const text: Blob = await clipboardItem.getType(type);\n return await blobToString(text);\n}\n\nexport interface StringItem {\n [type: string]: string;\n}\n\nexport async function toStringItem(\n data: ClipboardItemInterface\n): Promise {\n const items: StringItem = {};\n for (const type of data.types) {\n items[type] = await getTypeAsString(data, type);\n // Object.defineProperty(items, type, {\n // value: data.getType(type),\n // // tslint:disable-next-line: object-literal-sort-keys\n // enumerable: true,\n // });\n }\n return items;\n}\n","import { hasItemWithType } from \"../ClipboardItem/check\";\nimport { clipboardItemToGlobalClipboardItem, toStringItem, textToClipboardItem } from \"../ClipboardItem/convert\";\nimport { TEXT_HTML, TEXT_PLAIN } from \"../ClipboardItem/data-types\";\nimport { ClipboardItemInterface, ClipboardItems } from \"../ClipboardItem/spec\";\nimport { debugLog, shouldShowWarnings } from \"../debug\";\nimport { originalNavigatorClipboardRead, originalNavigatorClipboardWrite, originalWindowClipboardItem } from \"../globals\";\nimport { readText } from \"./text\";\nimport { writeFallback } from \"./write-fallback\";\n\nexport async function write(data: ClipboardItemInterface[]): Promise {\n // Use the browser implementation if it exists.\n // TODO: detect `text/html`.\n if (\n originalNavigatorClipboardWrite &&\n originalWindowClipboardItem\n ) {\n debugLog(\"Using `navigator.clipboard.write()`.\");\n const globalClipboardItems: ClipboardItemInterface[] = await Promise.all(\n data.map(clipboardItemToGlobalClipboardItem)\n );\n try {\n return await originalNavigatorClipboardWrite(globalClipboardItems);\n } catch (e) {\n // Chrome 83 will throw a DOMException or NotAllowedError because it doesn't support e.g. `text/html`.\n // We want to fall back to the other strategies in a situation like this.\n // See https://github.com/w3c/clipboard-apis/issues/128 and https://github.com/w3c/clipboard-apis/issues/67\n if (!hasItemWithType(data, TEXT_PLAIN) && !hasItemWithType(data, TEXT_HTML)) {\n throw e;\n }\n }\n }\n\n const hasTextPlain = hasItemWithType(data, TEXT_PLAIN);\n if (shouldShowWarnings && !hasTextPlain) {\n debugLog(\n \"clipboard.write() was called without a \" +\n \"`text/plain` data type. On some platforms, this may result in an \" +\n \"empty clipboard. Call suppressWarnings() \" +\n \"to suppress this warning.\"\n );\n }\n\n if (!writeFallback(await toStringItem(data[0]))) {\n throw new Error(\"write() failed\");\n }\n}\n\nexport async function read(): Promise {\n // Use the browser implementation if it exists.\n if (originalNavigatorClipboardRead) {\n debugLog(\"Using `navigator.clipboard.read()`.\");\n return originalNavigatorClipboardRead();\n }\n\n // Fallback to reading text only.\n return [textToClipboardItem(await readText())];\n}\n"],"names":["debugLogImpl","s","debugLog","showWarnings","shouldShowWarnings","console","warn","log","apply","arguments","bind","originalNavigator","navigator","undefined","originalNavigatorClipboard","clipboard","originalNavigatorClipboardRead","read","originalNavigatorClipboardReadText","readText","originalNavigatorClipboardWrite","write","originalNavigatorClipboardWriteText","writeText","originalWindow","window","originalWindowClipboardItem","ClipboardItem","ieWindow","seemToBeInIE","ClipboardEvent","clipboardData","setData","readTextIE","text","getData","Error","this","copyListener","tracker","data","e","type","success","value","preventDefault","execCopy","FallbackTracker","listener","document","addEventListener","execCommand","removeEventListener","copyUsingTempSelection","selectionSet","selectionClear","elem","sel","getSelection","range","createRange","selectNodeContents","removeAllRanges","addRange","writeFallback","stringItem","hasTextPlain","userAgent","indexOf","body","tempElem","createElement","setAttribute","textContent","appendChild","removeChild","copyUsingTempElem","str","spanParent","attachShadow","mode","span","innerText","result","copyTextUsingDOM","hasItemWithType","clipboardItems","typeName","clipboardItems_1","_i","types","ClipboardItemPolyfill","items","options","Object","keys","_items","item","stringToBlob","presentationStyle","ClipboardItemPolyfillImpl","Blob","blobToString","blob","Promise","resolve","reject","fileReader","FileReader","readAsText","clipboardItemToGlobalClipboardItem","clipboardItem","_a","_b","_c","getType","_d","textToClipboardItem","getTypeAsString","toStringItem","logFn","all","map","globalClipboardItems","e_1","stringToStringItem"],"mappings":";;;;;;;;;;;;;;+5CAAO,ICGHA,EAAe,SAACC,cAEJC,EAASD,GACvBD,EAAaC,GASf,IAAIE,GAAe,WAMHC,IACd,OAAOD,GAMT,YAEGE,QAAQC,MAAQD,QAAQE,KAAKC,MAAMH,QAASI,aAGjBC,KAAK,wBAA5B,YCZDC,EAA0C,oBAAdC,eAA4BC,EAAYD,UACpEE,EAAoDH,MAAAA,SAAAA,EAAmBI,UAChEC,YAA8EF,MAAAA,SAAAA,EAA4BG,2BAAMP,KAAKI,GACrHI,YAA0EJ,MAAAA,SAAAA,EAA4BK,+BAAUT,KAAKI,GACrHM,YAAyFN,MAAAA,SAAAA,EAA4BO,4BAAOX,KAAKI,GACjIQ,YAAqFR,MAAAA,SAAAA,EAA4BS,gCAAWb,KAAKI,GAGjIU,EAAoC,oBAAXC,YAAyBZ,EAAYY,OAC9DC,EAAoEF,MAAAA,SAAAA,EAAgBG,cCpB3FC,EAAYJ,WAEFK,IACd,MAC4B,oBAAnBC,qBAC2B,IAA3BF,EAASG,oBAC0B,IAAnCH,EAASG,cAAcC,iBAWZC,6EAEpB,GAAa,MADPC,EAAON,EAASG,cAAcI,QAAQ,SAE1C,MAAM,IAAIC,MACR,+DAGJ,SAAOF,SC5BT,MAAA,WACSG,cAAmB,GAG5B,SAASC,EACPC,EACAC,EACAC,GAKA,IAAK,IAAMC,KAHXxC,EAAS,mBACTqC,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