UNPKG

20.2 kBSource Map (JSON)View Raw
1{"version":3,"sources":["webpack://clipboard/webpack/universalModuleDefinition","webpack://clipboard/webpack/bootstrap","webpack://clipboard/./clipboard-polyfill.ts","webpack://clipboard/./DT.ts"],"names":["root","factory","exports","module","define","amd","self","this","installedModules","__webpack_require__","moduleId","i","l","modules","call","m","c","d","name","getter","o","Object","defineProperty","enumerable","get","r","Symbol","toStringTag","value","t","mode","__esModule","ns","create","key","bind","n","object","property","prototype","hasOwnProperty","p","s","DT_1","DT","debugLog","showWarnings","warn","console","log","apply","arguments","TEXT_PLAIN","setDebugLog","f","suppressWarnings","suppressDTWarnings","write","data","getData","seemToBeInIE","text","undefined","window","clipboardData","setData","writeIE","execCopy","navigator","userAgent","indexOf","copyUsingTempSelection","document","body","tempElem","createElement","setAttribute","textContent","appendChild","success","removeChild","copyUsingTempElem","str","spanParent","attachShadow","span","innerText","selectionSet","result","execCommand","selectionClear","copyTextUsingDOM","writeText","clipboard","DTFromText","read","_a","readText","_b","sent","readIE","useStarShown","useStar","ClipboardPolyfillDefault","FallbackTracker","tracker","listener","e","forEach","preventDefault","addEventListener","removeEventListener","elem","sel","getSelection","range","createRange","selectNodeContents","removeAllRanges","addRange","dt","ClipboardEvent","dataTypes","type","k"],"mappings":"CAAA,SAAAA,KAAAC,SACA,iBAAAC,SAAA,iBAAAC,OACAA,OAAAD,QAAAD,UACA,mBAAAG,eAAAC,IACAD,UAAAH,SACA,iBAAAC,QACAA,QAAA,UAAAD,UAEAD,KAAA,UAAAC,UARA,CASC,oBAAAK,UAAAC,KAAA,WACD,yBCTA,IAAAC,oBAGA,SAAAC,oBAAAC,UAGA,GAAAF,iBAAAE,UACA,OAAAF,iBAAAE,UAAAR,QAGA,IAAAC,OAAAK,iBAAAE,WACAC,EAAAD,SACAE,GAAA,EACAV,YAUA,OANAW,QAAAH,UAAAI,KAAAX,OAAAD,QAAAC,cAAAD,QAAAO,qBAGAN,OAAAS,GAAA,EAGAT,OAAAD,QA0DA,OAr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BS6B,GAAAL,UAAA0B,QAAP,SAAe0D,KAAc/F,OACvBkB,eAA6C,IAA7B4E,UAAUpD,QAAQqD,OACpC5E,KAAK,sBAAwB4E,KAAM,+DAIrCpH,KAAKQ,EAAE4G,MAAQ/F,OAGVgB,GAAAL,UAAAoB,QAAP,SAAegE,MACb,OAAOpH,KAAKQ,EAAE4G,OAIT/E,GAAAL,UAAAqE,QAAP,SAAetD,GACb,IAAK,IAAIsE,KAAKrH,KAAKQ,EACjBuC,EAAE/C,KAAKQ,EAAE6G,GAAIA,IAGnBhF,GAtBA,GAAa1C,QAAA0C","file":"clipboard-polyfill.js","sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"clipboard\"] = factory();\n\telse\n\t\troot[\"clipboard\"] = factory();\n})(typeof self !== \"undefined\" ? self : this, function() {\nreturn "," \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 0);\n","import {DT, suppressDTWarnings} from \"./DT\";\n\n// Debug log strings should be short, since they are compiled into the production build.\n// TODO: Compile debug logging code out of production builds?\nvar debugLog: (s: string) => void = function(s: string) {};\nvar showWarnings = true;\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)\nvar warnOrLog = function() {\n (console.warn || console.log).apply(console, arguments);\n};\nvar warn = warnOrLog.bind(\"[clipboard-polyfill]\");\n\nvar TEXT_PLAIN = \"text/plain\";\n\n// declare global {\n// interface Navigator {\n// clipboard: {\n// writeText?: (s: string) => Promise<void>;\n// readText?: () => Promise<string>;\n// };\n// }\n// }\n\nexport {DT};\n\nexport function setDebugLog(f: (s: string) => void): void {\n debugLog = f;\n}\n\nexport function suppressWarnings() {\n showWarnings = false;\n suppressDTWarnings();\n}\n\nexport async function write(data: DT): Promise<void> {\n if (showWarnings && !data.getData(TEXT_PLAIN)) {\n warn(\"clipboard.write() was called without a \"+\n \"`text/plain` data type. On some platforms, this may result in an \"+\n \"empty clipboard. Call clipboard.suppressWarnings() \"+\n \"to suppress this warning.\");\n }\n\n // Internet Explorer\n if (seemToBeInIE()) {\n if (writeIE(data)) {\n return;\n } else {\n throw \"Copying failed, possibly because the user rejected it.\";\n }\n }\n\n if (execCopy(data)) {\n debugLog(\"regular execCopy worked\");\n return;\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;\n }\n\n // Fallback 1 for desktop Safari.\n if (copyUsingTempSelection(document.body, data)) {\n debugLog(\"copyUsingTempSelection worked\");\n return;\n }\n\n // Fallback 2 for desktop Safari.\n if (copyUsingTempElem(data)) {\n debugLog(\"copyUsingTempElem worked\");\n return;\n }\n\n // Fallback for iOS Safari.\n var text = data.getData(TEXT_PLAIN);\n if (text !== undefined && copyTextUsingDOM(text)) {\n debugLog(\"copyTextUsingDOM worked\");\n return;\n }\n\n throw \"Copy command failed.\";\n}\n\nexport async function writeText(s: string): Promise<void> {\n if (navigator.clipboard && navigator.clipboard.writeText) {\n debugLog(\"Using `navigator.clipboard.writeText()`.\");\n return navigator.clipboard.writeText(s);\n }\n return write(DTFromText(s));\n}\n\nexport async function read(): Promise<DT> {\n return DTFromText(await readText());\n}\n\nexport async function readText(): Promise<string> {\n if (navigator.clipboard && navigator.clipboard.readText) {\n debugLog(\"Using `navigator.clipboard.readText()`.\");\n return navigator.clipboard.readText();\n }\n if (seemToBeInIE()) {\n debugLog(\"Reading text using IE strategy.\");\n return readIE();\n }\n throw \"Read is not supported in your browser.\";\n}\n\nvar useStarShown = false;\nfunction useStar(): void {\n if (useStarShown) {\n return;\n }\n if (showWarnings) {\n warn(\"The deprecated default object of `clipboard-polyfill` was called. Please switch to `import * as clipboard from \\\"clipboard-polyfill\\\"` and see https://github.com/lgarron/clipboard-polyfill/issues/101 for more info.\");\n }\n useStarShown = true;\n}\n\nexport default class ClipboardPolyfillDefault {\n public static readonly DT = DT;\n public static setDebugLog(f: (s: string) => void): void {\n useStar();\n return setDebugLog(f);\n }\n public static suppressWarnings() {\n useStar();\n return suppressWarnings();\n }\n public static async write(data: DT): Promise<void> {\n useStar();\n return write(data);\n }\n public static async writeText(s: string): Promise<void> {\n useStar();\n return writeText(s);\n }\n public static async read(): Promise<DT> {\n useStar();\n return read();\n }\n public static async readText(): Promise<string> {\n useStar();\n return readText();\n }\n}\n\n/******** Implementations ********/\n\nclass FallbackTracker {\n public success: boolean = false;\n}\n\nfunction copyListener(tracker: FallbackTracker, data: DT, e: ClipboardEvent): void {\n debugLog(\"listener called\");\n tracker.success = true;\n data.forEach((value: string, key: string) => {\n const clipboardData = e.clipboardData!;\n clipboardData.setData(key, value);\n if (key === TEXT_PLAIN && clipboardData.getData(key) != value) {\n debugLog(\"setting text/plain failed\");\n tracker.success = false;\n }\n });\n e.preventDefault();\n}\n\nfunction execCopy(data: DT): boolean {\n var tracker = new FallbackTracker();\n var 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.\nfunction copyUsingTempSelection(e: HTMLElement, data: DT): boolean {\n selectionSet(e);\n var 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.\nfunction copyUsingTempElem(data: DT): boolean {\n var 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 var success = copyUsingTempSelection(tempElem, data);\n\n document.body.removeChild(tempElem);\n return success;\n}\n\n// Uses shadow DOM.\nfunction copyTextUsingDOM(str: string): boolean {\n debugLog(\"copyTextUsingDOM\");\n\n var 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 var spanParent: Node = tempElem;\n if (tempElem.attachShadow) {\n debugLog(\"Using shadow DOM.\");\n spanParent = tempElem.attachShadow({mode: \"open\"});\n }\n\n var span = document.createElement(\"span\");\n span.innerText = str;\n\n spanParent.appendChild(span);\n document.body.appendChild(tempElem);\n selectionSet(span);\n\n var 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 var sel = document.getSelection();\n if (sel) {\n var range = document.createRange();\n range.selectNodeContents(elem);\n sel.removeAllRanges();\n sel.addRange(range);\n }\n}\n\nfunction selectionClear(): void {\n var sel = document.getSelection();\n if (sel) {\n sel.removeAllRanges();\n }\n}\n\n/******** Convenience ********/\n\nfunction DTFromText(s: string): DT {\n var dt = new DT();\n dt.setData(TEXT_PLAIN, s);\n return dt;\n}\n\n/******** Internet Explorer ********/\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\nfunction seemToBeInIE(): boolean {\n return typeof ClipboardEvent === \"undefined\" &&\n typeof (window as IEWindow).clipboardData !== \"undefined\" &&\n typeof (window as IEWindow).clipboardData.setData !== \"undefined\";\n}\n\nfunction writeIE(data: DT): 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 var text = data.getData(TEXT_PLAIN);\n if (text !== undefined) {\n return (window as IEWindow).clipboardData.setData(\"Text\", text);\n }\n\n throw (\"No `text/plain` value was specified.\");\n}\n\n// Returns \"\" if the read failed, e.g. because the user rejected the permission.\nasync function readIE(): Promise<string> {\n var text = (window as IEWindow).clipboardData.getData(\"Text\");\n if (text === \"\") {\n throw \"Empty clipboard or could not read plain text from clipboard\";\n }\n return text;\n}\n","const dataTypes = [\n \"text/plain\",\n \"text/html\"\n];\n\n// TODO: Dedup with main file?\nvar warnOrLog = function() {\n (console.warn || console.log).call(arguments);\n}; // IE9 workaround (can't bind console functions).\nvar warn = warnOrLog.bind(console, \"[clipboard-polyfill]\");\nvar showWarnings = true;\nexport function suppressDTWarnings() {\n showWarnings = false;\n}\n\nexport class DT {\n private m: {[key:string]: string} = {};\n\n public setData(type: string, value: string): void {\n if (showWarnings && dataTypes.indexOf(type) === -1) {\n warn(\"Unknown data type: \" + type, \"Call clipboard.suppressWarnings() \"+\n \"to suppress this warning.\");\n }\n\n this.m[type] = value;\n }\n\n public getData(type: string): string | undefined {\n return this.m[type];\n }\n\n // TODO: Provide an iterator consistent with DataTransfer.\n public forEach(f: (value: string, key: string) => void): void {\n for (var k in this.m) {\n f(this.m[k], k);\n }\n }\n}\n"],"sourceRoot":""}
\No newline at end of file