clipboard-polyfill
Advanced tools
Comparing version 2.8.6 to 3.0.0-pre1
@@ -1,18 +0,5 @@ | ||
import { DT } from "./DT"; | ||
export { DT }; | ||
export declare function setDebugLog(f: (s: string) => void): void; | ||
export declare function suppressWarnings(): void; | ||
export declare function write(data: DT): Promise<void>; | ||
import { ClipboardItemInterface } from "./ClipboardItem/spec"; | ||
export declare function write(data: ClipboardItemInterface[]): Promise<void>; | ||
export declare function writeText(s: string): Promise<void>; | ||
export declare function read(): Promise<DT>; | ||
export declare function read(): Promise<ClipboardItemInterface>; | ||
export declare function readText(): Promise<string>; | ||
declare const ClipboardPolyfillDefault: { | ||
DT: typeof DT; | ||
setDebugLog(f: (s: string) => void): void; | ||
suppressWarnings(): void; | ||
write(data: DT): Promise<void>; | ||
writeText(s: string): Promise<void>; | ||
read(): Promise<DT>; | ||
readText(): Promise<string>; | ||
}; | ||
export default ClipboardPolyfillDefault; |
@@ -1,2 +0,16 @@ | ||
function t(t,e,n,r){return new(n||(n=Promise))(function(o,i){function a(t){try{u(r.next(t))}catch(t){i(t)}}function c(t){try{u(r.throw(t))}catch(t){i(t)}}function u(t){t.done?o(t.value):new n(function(e){e(t.value)}).then(a,c)}u((r=r.apply(t,e||[])).next())})}function e(t,e){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(i){return function(c){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,r=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===i[0]||2===i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=e.call(t,a)}catch(t){i=[6,t],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,c])}}}var n=["text/plain","text/html"];var r=function(){(console.warn||console.log).call(arguments)}.bind(console,"[clipboard-polyfill]"),o=!0;var i=function(){function t(){this.m={}}return t.prototype.setData=function(t,e){o&&-1===n.indexOf(t)&&r("Unknown data type: "+t,"Call clipboard.suppressWarnings() to suppress this warning."),this.m[t]=e},t.prototype.getData=function(t){return this.m[t]},t.prototype.forEach=function(t){for(var e in this.m)t(this.m[e],e)},t}(),a=function(t){},c=!0;var u=function(){(console.warn||console.log).apply(console,arguments)}.bind("[clipboard-polyfill]"),s="text/plain";function l(t){a=t}function d(){c=!1,o=!1}function f(n){return t(this,void 0,void 0,function(){var t;return e(this,function(e){if(c&&!n.getData(s)&&u("clipboard.write() was called without a `text/plain` data type. On some platforms, this may result in an empty clipboard. Call clipboard.suppressWarnings() to suppress this warning."),C()){if(function(t){var e=t.getData(s);if(void 0!==e)return window.clipboardData.setData("Text",e);throw new Error("No `text/plain` value was specified.")}(n))return[2];throw new Error("Copying failed, possibly because the user rejected it.")}if(g(n))return a("regular execCopy worked"),[2];if(navigator.userAgent.indexOf("Edge")>-1)return a('UA "Edge" => assuming success'),[2];if(x(document.body,n))return a("copyUsingTempSelection worked"),[2];if(function(t){var e=document.createElement("div");e.setAttribute("style","-webkit-user-select: text !important"),e.textContent="temporary element",document.body.appendChild(e);var n=x(e,t);return document.body.removeChild(e),n}(n))return a("copyUsingTempElem worked"),[2];if(void 0!==(t=n.getData(s))&&function(t){a("copyTextUsingDOM");var e=document.createElement("div");e.setAttribute("style","-webkit-user-select: text !important");var n=e;e.attachShadow&&(a("Using shadow DOM."),n=e.attachShadow({mode:"open"}));var r=document.createElement("span");r.innerText=t,n.appendChild(r),document.body.appendChild(e),D(r);var o=document.execCommand("copy");return E(),document.body.removeChild(e),o}(t))return a("copyTextUsingDOM worked"),[2];throw new Error("Copy command failed.")})})}function p(n){return t(this,void 0,void 0,function(){return e(this,function(t){return navigator.clipboard&&navigator.clipboard.writeText?(a("Using `navigator.clipboard.writeText()`."),[2,navigator.clipboard.writeText(n)]):[2,f(T(n))]})})}function v(){return t(this,void 0,void 0,function(){var t;return e(this,function(e){switch(e.label){case 0:return t=T,[4,h()];case 1:return[2,t.apply(void 0,[e.sent()])]}})})}function h(){return t(this,void 0,void 0,function(){return e(this,function(t){if(navigator.clipboard&&navigator.clipboard.readText)return a("Using `navigator.clipboard.readText()`."),[2,navigator.clipboard.readText()];if(C())return a("Reading text using IE strategy."),[2,k()];throw new Error("Read is not supported in your browser.")})})}var b=!1;function m(){b||(c&&u('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.'),b=!0)}var w={DT:i,setDebugLog:function(t){return m(),l(t)},suppressWarnings:function(){return m(),d()},write:function(n){return t(this,void 0,void 0,function(){return e(this,function(t){return m(),[2,f(n)]})})},writeText:function(n){return t(this,void 0,void 0,function(){return e(this,function(t){return m(),[2,p(n)]})})},read:function(){return t(this,void 0,void 0,function(){return e(this,function(t){return m(),[2,v()]})})},readText:function(){return t(this,void 0,void 0,function(){return e(this,function(t){return m(),[2,h()]})})}},y=function(){this.success=!1};function g(t){var e=new y,n=function(t,e,n){a("listener called"),t.success=!0,e.forEach(function(e,r){var o=n.clipboardData;o.setData(r,e),r===s&&o.getData(r)!==e&&(a("setting text/plain failed"),t.success=!1)}),n.preventDefault()}.bind(this,e,t);document.addEventListener("copy",n);try{document.execCommand("copy")}finally{document.removeEventListener("copy",n)}return e.success}function x(t,e){D(t);var n=g(e);return E(),n}function D(t){var e=document.getSelection();if(e){var n=document.createRange();n.selectNodeContents(t),e.removeAllRanges(),e.addRange(n)}}function E(){var t=document.getSelection();t&&t.removeAllRanges()}function T(t){var e=new i;return e.setData(s,t),e}function C(){return"undefined"==typeof ClipboardEvent&&void 0!==window.clipboardData&&void 0!==window.clipboardData.setData}function k(){return t(this,void 0,void 0,function(){var t;return e(this,function(e){if(""===(t=window.clipboardData.getData("Text")))throw new Error("Empty clipboard or could not read plain text from clipboard");return[2,t]})})}export default w;export{i as DT,v as read,h as readText,l as setDebugLog,d as suppressWarnings,f as write,p as writeText}; | ||
/*! ***************************************************************************** | ||
Copyright (c) Microsoft Corporation. | ||
Permission to use, copy, modify, and/or distribute this software for any | ||
purpose with or without fee is hereby granted. | ||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH | ||
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY | ||
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, | ||
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM | ||
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR | ||
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR | ||
PERFORMANCE OF THIS SOFTWARE. | ||
***************************************************************************** */ | ||
function t(t,e,n,r){return new(n||(n=Promise))((function(i,o){function a(t){try{u(r.next(t))}catch(t){o(t)}}function c(t){try{u(r.throw(t))}catch(t){o(t)}}function u(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,c)}u((r=r.apply(t,e||[])).next())}))}function e(t,e){var n,r,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function c(o){return function(c){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(i=2&o[0]?r.return:o[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,r=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(i=a.trys,(i=i.length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){a.label=o[1];break}if(6===o[0]&&a.label<i[1]){a.label=i[1],i=o;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(o);break}i[2]&&a.ops.pop(),a.trys.pop();continue}o=e.call(t,a)}catch(t){o=[6,t],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,c])}}}function n(t,e){for(var n=0,r=t;n<r.length;n++){if(-1!==r[n].types.indexOf(e))return!0}return!1}var r=function(){function n(t,e){var n;for(var r in void 0===e&&(e={}),this.types=Object.keys(t),this._items={},t){var o=t[r];this._items[r]="string"==typeof o?i(r,o):o}this.presentationStyle=null!==(n=null==e?void 0:e.presentationStyle)&&void 0!==n?n:"unspecified"}return n.prototype.getType=function(n){return t(this,void 0,void 0,(function(){return e(this,(function(t){return[2,this._items[n]]}))}))},n}();function i(t,e){return new Blob([e],{type:t})}function o(n){return t(this,void 0,void 0,(function(){return e(this,(function(t){return[2,new Promise((function(t,e){var r=new FileReader;r.addEventListener("load",(function(){var n=r.result;"string"==typeof n?t(n):e("could not convert blob to string")})),r.readAsText(n)}))]}))}))}function a(n){return t(this,void 0,void 0,(function(){var t,r,i,o,a,c,u;return e(this,(function(e){switch(e.label){case 0:t={},r=0,i=n.types,e.label=1;case 1:return r<i.length?(o=i[r],a=t,c=o,[4,n.getType(o)]):[3,4];case 2:a[c]=e.sent(),e.label=3;case 3:return r++,[3,1];case 4:return u={},n.presentationStyle&&(u.presentationStyle=n.presentationStyle),[2,new window.ClipboardItem(t,u)]}}))}))}function c(t){var e={};return e["text/plain"]=i(t,"text/plain"),new r(e)}function u(n,r){return t(this,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,n.getType(r)];case 1:return[4,o(t.sent())];case 2:return[2,t.sent()]}}))}))}function s(n){return t(this,void 0,void 0,(function(){var t,r,i,o,a,c;return e(this,(function(e){switch(e.label){case 0:t={},r=0,i=n.types,e.label=1;case 1:return r<i.length?(o=i[r],a=t,c=o,[4,u(n,o)]):[3,4];case 2:a[c]=e.sent(),e.label=3;case 3:return r++,[3,1];case 4:return[2,t]}}))}))}var l=function(t){};function d(t){l(t)}function p(t){l=t}var f=!0;function v(){f=!1}function b(){return f}(function(){(console.warn||console.log).apply(console,arguments)}).bind("[clipboard-polyfill]");var h=function(){this.success=!1};function y(t,e,n){for(var r in d("listener called"),t.success=!0,e){var i=e[r],o=n.clipboardData;o.setData(r,i),"text/plain"===r&&o.getData(r)!==i&&(d("setting text/plain failed"),t.success=!1)}n.preventDefault()}function g(t){var e=new h,n=y.bind(this,e,t);document.addEventListener("copy",n);try{document.execCommand("copy")}finally{document.removeEventListener("copy",n)}return e.success}function w(t,e){x(t);var n=g(e);return T(),n}function m(t){d("copyTextUsingDOM");var e=document.createElement("div");e.setAttribute("style","-webkit-user-select: text !important");var n=e;e.attachShadow&&(d("Using shadow DOM."),n=e.attachShadow({mode:"open"}));var r=document.createElement("span");r.innerText=t,n.appendChild(r),document.body.appendChild(e),x(r);var i=document.execCommand("copy");return T(),document.body.removeChild(e),i}function x(t){var e=document.getSelection();if(e){var n=document.createRange();n.selectNodeContents(t),e.removeAllRanges(),e.addRange(n)}}function T(){var t=document.getSelection();t&&t.removeAllRanges()}var E=window;function C(){return"undefined"==typeof ClipboardEvent&&void 0!==E.clipboardData&&void 0!==E.clipboardData.setData}function D(t){return E.clipboardData.setData("Text",t)}function S(){return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){if(""===(t=E.clipboardData.getData("Text")))throw new Error("Empty clipboard or could not read plain text from clipboard");return[2,t]}))}))}function k(r){return t(this,void 0,void 0,(function(){var t,i,o,c,l;return e(this,(function(e){switch(e.label){case 0:return!n(r,"text/html")&&navigator.clipboard&&navigator.clipboard.write?(d("Using `navigator.clipboard.write()`."),[4,Promise.all(r.map(a))]):[3,2];case 1:return t=e.sent(),[2,navigator.clipboard.write(t)];case 2:if(i=n(r,"text/plain"),b&&!i&&d("clipboard.write() was called without a `text/plain` data type. On some platforms, this may result in an empty clipboard. Call suppressWarnings() to suppress this warning."),!C())return[3,4];if(!i)throw new Error("No `text/plain` value was specified.");return o=D,[4,u(r[0],"text/plain")];case 3:if(o.apply(void 0,[e.sent()]))return[2];throw new Error("Copying failed, possibly because the user rejected it.");case 4:return[4,s(r[0])];case 5:return g(c=e.sent())?(d("regular execCopy worked"),[2]):navigator.userAgent.indexOf("Edge")>-1?(d('UA "Edge" => assuming success'),[2]):w(document.body,c)?(d("copyUsingTempSelection worked"),[2]):function(t){var e=document.createElement("div");e.setAttribute("style","-webkit-user-select: text !important"),e.textContent="temporary element",document.body.appendChild(e);var n=w(e,t);return document.body.removeChild(e),n}(c)?(d("copyUsingTempElem worked"),[2]):(l=m,[4,u(r[0],"text/plain")]);case 6:if(l.apply(void 0,[e.sent()]))return d("copyTextUsingDOM worked"),[2];throw new Error("Copy command failed.")}}))}))}function U(n){return t(this,void 0,void 0,(function(){return e(this,(function(t){return navigator.clipboard&&navigator.clipboard.writeText?(d("Using `navigator.clipboard.writeText()`."),[2,navigator.clipboard.writeText(n)]):[2,k([c(n)])]}))}))}function A(){return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return navigator.clipboard&&navigator.clipboard.readText?(d("Using `navigator.clipboard.read()`."),[2,navigator.clipboard.read()]):(t=c,[4,O()]);case 1:return[2,t.apply(void 0,[e.sent()])]}}))}))}function O(){return t(this,void 0,void 0,(function(){return e(this,(function(t){if(navigator.clipboard&&navigator.clipboard.readText)return d("Using `navigator.clipboard.readText()`."),[2,navigator.clipboard.readText()];if(C())return d("Reading text using IE strategy."),[2,S()];throw new Error("Read is not supported in your browser.")}))}))}export{r as ClipboardItem,A as read,O as readText,p as setDebugLog,v as suppressWarnings,k as write,U as writeText}; | ||
//# sourceMappingURL=clipboard-polyfill.esm.js.map |
@@ -1,2 +0,16 @@ | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t=t||self).clipboard={})}(this,function(t){"use strict";function e(t,e,n,r){return new(n||(n=Promise))(function(o,i){function a(t){try{c(r.next(t))}catch(t){i(t)}}function u(t){try{c(r.throw(t))}catch(t){i(t)}}function c(t){t.done?o(t.value):new n(function(e){e(t.value)}).then(a,u)}c((r=r.apply(t,e||[])).next())})}function n(t,e){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function u(i){return function(u){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,r=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===i[0]||2===i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=e.call(t,a)}catch(t){i=[6,t],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,u])}}}var r=["text/plain","text/html"];var o=function(){(console.warn||console.log).call(arguments)}.bind(console,"[clipboard-polyfill]"),i=!0;var a=function(){function t(){this.m={}}return t.prototype.setData=function(t,e){i&&-1===r.indexOf(t)&&o("Unknown data type: "+t,"Call clipboard.suppressWarnings() to suppress this warning."),this.m[t]=e},t.prototype.getData=function(t){return this.m[t]},t.prototype.forEach=function(t){for(var e in this.m)t(this.m[e],e)},t}(),u=function(t){},c=!0;var s=function(){(console.warn||console.log).apply(console,arguments)}.bind("[clipboard-polyfill]"),d="text/plain";function l(t){u=t}function f(){c=!1,i=!1}function p(t){return e(this,void 0,void 0,function(){var e;return n(this,function(n){if(c&&!t.getData(d)&&s("clipboard.write() was called without a `text/plain` data type. On some platforms, this may result in an empty clipboard. Call clipboard.suppressWarnings() to suppress this warning."),k()){if(function(t){var e=t.getData(d);if(void 0!==e)return window.clipboardData.setData("Text",e);throw new Error("No `text/plain` value was specified.")}(t))return[2];throw new Error("Copying failed, possibly because the user rejected it.")}if(x(t))return u("regular execCopy worked"),[2];if(navigator.userAgent.indexOf("Edge")>-1)return u('UA "Edge" => assuming success'),[2];if(D(document.body,t))return u("copyUsingTempSelection worked"),[2];if(function(t){var e=document.createElement("div");e.setAttribute("style","-webkit-user-select: text !important"),e.textContent="temporary element",document.body.appendChild(e);var n=D(e,t);return document.body.removeChild(e),n}(t))return u("copyUsingTempElem worked"),[2];if(void 0!==(e=t.getData(d))&&function(t){u("copyTextUsingDOM");var e=document.createElement("div");e.setAttribute("style","-webkit-user-select: text !important");var n=e;e.attachShadow&&(u("Using shadow DOM."),n=e.attachShadow({mode:"open"}));var r=document.createElement("span");r.innerText=t,n.appendChild(r),document.body.appendChild(e),T(r);var o=document.execCommand("copy");return E(),document.body.removeChild(e),o}(e))return u("copyTextUsingDOM worked"),[2];throw new Error("Copy command failed.")})})}function v(t){return e(this,void 0,void 0,function(){return n(this,function(e){return navigator.clipboard&&navigator.clipboard.writeText?(u("Using `navigator.clipboard.writeText()`."),[2,navigator.clipboard.writeText(t)]):[2,p(C(t))]})})}function h(){return e(this,void 0,void 0,function(){var t;return n(this,function(e){switch(e.label){case 0:return t=C,[4,b()];case 1:return[2,t.apply(void 0,[e.sent()])]}})})}function b(){return e(this,void 0,void 0,function(){return n(this,function(t){if(navigator.clipboard&&navigator.clipboard.readText)return u("Using `navigator.clipboard.readText()`."),[2,navigator.clipboard.readText()];if(k())return u("Reading text using IE strategy."),[2,U()];throw new Error("Read is not supported in your browser.")})})}var m=!1;function w(){m||(c&&s('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.'),m=!0)}var y={DT:a,setDebugLog:function(t){return w(),l(t)},suppressWarnings:function(){return w(),f()},write:function(t){return e(this,void 0,void 0,function(){return n(this,function(e){return w(),[2,p(t)]})})},writeText:function(t){return e(this,void 0,void 0,function(){return n(this,function(e){return w(),[2,v(t)]})})},read:function(){return e(this,void 0,void 0,function(){return n(this,function(t){return w(),[2,h()]})})},readText:function(){return e(this,void 0,void 0,function(){return n(this,function(t){return w(),[2,b()]})})}},g=function(){this.success=!1};function x(t){var e=new g,n=function(t,e,n){u("listener called"),t.success=!0,e.forEach(function(e,r){var o=n.clipboardData;o.setData(r,e),r===d&&o.getData(r)!==e&&(u("setting text/plain failed"),t.success=!1)}),n.preventDefault()}.bind(this,e,t);document.addEventListener("copy",n);try{document.execCommand("copy")}finally{document.removeEventListener("copy",n)}return e.success}function D(t,e){T(t);var n=x(e);return E(),n}function T(t){var e=document.getSelection();if(e){var n=document.createRange();n.selectNodeContents(t),e.removeAllRanges(),e.addRange(n)}}function E(){var t=document.getSelection();t&&t.removeAllRanges()}function C(t){var e=new a;return e.setData(d,t),e}function k(){return"undefined"==typeof ClipboardEvent&&void 0!==window.clipboardData&&void 0!==window.clipboardData.setData}function U(){return e(this,void 0,void 0,function(){var t;return n(this,function(e){if(""===(t=window.clipboardData.getData("Text")))throw new Error("Empty clipboard or could not read plain text from clipboard");return[2,t]})})}t.DT=a,t.default=y,t.read=h,t.readText=b,t.setDebugLog=l,t.suppressWarnings=f,t.write=p,t.writeText=v,Object.defineProperty(t,"__esModule",{value:!0})}); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e=e||self).clipboard={})}(this,(function(e){"use strict"; | ||
/*! ***************************************************************************** | ||
Copyright (c) Microsoft Corporation. | ||
Permission to use, copy, modify, and/or distribute this software for any | ||
purpose with or without fee is hereby granted. | ||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH | ||
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY | ||
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, | ||
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM | ||
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR | ||
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR | ||
PERFORMANCE OF THIS SOFTWARE. | ||
***************************************************************************** */function t(e,t,n,r){return new(n||(n=Promise))((function(i,o){function a(e){try{u(r.next(e))}catch(e){o(e)}}function c(e){try{u(r.throw(e))}catch(e){o(e)}}function u(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,c)}u((r=r.apply(e,t||[])).next())}))}function n(e,t){var n,r,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function c(o){return function(c){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(i=2&o[0]?r.return:o[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,r=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(i=a.trys,(i=i.length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){a.label=o[1];break}if(6===o[0]&&a.label<i[1]){a.label=i[1],i=o;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(o);break}i[2]&&a.ops.pop(),a.trys.pop();continue}o=t.call(e,a)}catch(e){o=[6,e],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,c])}}}function r(e,t){for(var n=0,r=e;n<r.length;n++){if(-1!==r[n].types.indexOf(t))return!0}return!1}var i=function(){function e(e,t){var n;for(var r in void 0===t&&(t={}),this.types=Object.keys(e),this._items={},e){var i=e[r];this._items[r]="string"==typeof i?o(r,i):i}this.presentationStyle=null!==(n=null==t?void 0:t.presentationStyle)&&void 0!==n?n:"unspecified"}return e.prototype.getType=function(e){return t(this,void 0,void 0,(function(){return n(this,(function(t){return[2,this._items[e]]}))}))},e}();function o(e,t){return new Blob([t],{type:e})}function a(e){return t(this,void 0,void 0,(function(){return n(this,(function(t){return[2,new Promise((function(t,n){var r=new FileReader;r.addEventListener("load",(function(){var e=r.result;"string"==typeof e?t(e):n("could not convert blob to string")})),r.readAsText(e)}))]}))}))}function c(e){return t(this,void 0,void 0,(function(){var t,r,i,o,a,c,u;return n(this,(function(n){switch(n.label){case 0:t={},r=0,i=e.types,n.label=1;case 1:return r<i.length?(o=i[r],a=t,c=o,[4,e.getType(o)]):[3,4];case 2:a[c]=n.sent(),n.label=3;case 3:return r++,[3,1];case 4:return u={},e.presentationStyle&&(u.presentationStyle=e.presentationStyle),[2,new window.ClipboardItem(t,u)]}}))}))}function u(e){var t={};return t["text/plain"]=o(e,"text/plain"),new i(t)}function s(e,r){return t(this,void 0,void 0,(function(){return n(this,(function(t){switch(t.label){case 0:return[4,e.getType(r)];case 1:return[4,a(t.sent())];case 2:return[2,t.sent()]}}))}))}function l(e){return t(this,void 0,void 0,(function(){var t,r,i,o,a,c;return n(this,(function(n){switch(n.label){case 0:t={},r=0,i=e.types,n.label=1;case 1:return r<i.length?(o=i[r],a=t,c=o,[4,s(e,o)]):[3,4];case 2:a[c]=n.sent(),n.label=3;case 3:return r++,[3,1];case 4:return[2,t]}}))}))}var d=function(e){};function p(e){d(e)}var f=!0;function v(){return f}(function(){(console.warn||console.log).apply(console,arguments)}).bind("[clipboard-polyfill]");var b=function(){this.success=!1};function h(e,t,n){for(var r in p("listener called"),e.success=!0,t){var i=t[r],o=n.clipboardData;o.setData(r,i),"text/plain"===r&&o.getData(r)!==i&&(p("setting text/plain failed"),e.success=!1)}n.preventDefault()}function y(e){var t=new b,n=h.bind(this,t,e);document.addEventListener("copy",n);try{document.execCommand("copy")}finally{document.removeEventListener("copy",n)}return t.success}function g(e,t){m(e);var n=y(t);return x(),n}function w(e){p("copyTextUsingDOM");var t=document.createElement("div");t.setAttribute("style","-webkit-user-select: text !important");var n=t;t.attachShadow&&(p("Using shadow DOM."),n=t.attachShadow({mode:"open"}));var r=document.createElement("span");r.innerText=e,n.appendChild(r),document.body.appendChild(t),m(r);var i=document.execCommand("copy");return x(),document.body.removeChild(t),i}function m(e){var t=document.getSelection();if(t){var n=document.createRange();n.selectNodeContents(e),t.removeAllRanges(),t.addRange(n)}}function x(){var e=document.getSelection();e&&e.removeAllRanges()}var T=window;function E(){return"undefined"==typeof ClipboardEvent&&void 0!==T.clipboardData&&void 0!==T.clipboardData.setData}function C(e){return T.clipboardData.setData("Text",e)}function D(){return t(this,void 0,void 0,(function(){var e;return n(this,(function(t){if(""===(e=T.clipboardData.getData("Text")))throw new Error("Empty clipboard or could not read plain text from clipboard");return[2,e]}))}))}function S(e){return t(this,void 0,void 0,(function(){var t,i,o,a,u;return n(this,(function(n){switch(n.label){case 0:return!r(e,"text/html")&&navigator.clipboard&&navigator.clipboard.write?(p("Using `navigator.clipboard.write()`."),[4,Promise.all(e.map(c))]):[3,2];case 1:return t=n.sent(),[2,navigator.clipboard.write(t)];case 2:if(i=r(e,"text/plain"),v&&!i&&p("clipboard.write() was called without a `text/plain` data type. On some platforms, this may result in an empty clipboard. Call suppressWarnings() to suppress this warning."),!E())return[3,4];if(!i)throw new Error("No `text/plain` value was specified.");return o=C,[4,s(e[0],"text/plain")];case 3:if(o.apply(void 0,[n.sent()]))return[2];throw new Error("Copying failed, possibly because the user rejected it.");case 4:return[4,l(e[0])];case 5:return y(a=n.sent())?(p("regular execCopy worked"),[2]):navigator.userAgent.indexOf("Edge")>-1?(p('UA "Edge" => assuming success'),[2]):g(document.body,a)?(p("copyUsingTempSelection worked"),[2]):function(e){var t=document.createElement("div");t.setAttribute("style","-webkit-user-select: text !important"),t.textContent="temporary element",document.body.appendChild(t);var n=g(t,e);return document.body.removeChild(t),n}(a)?(p("copyUsingTempElem worked"),[2]):(u=w,[4,s(e[0],"text/plain")]);case 6:if(u.apply(void 0,[n.sent()]))return p("copyTextUsingDOM worked"),[2];throw new Error("Copy command failed.")}}))}))}function k(){return t(this,void 0,void 0,(function(){return n(this,(function(e){if(navigator.clipboard&&navigator.clipboard.readText)return p("Using `navigator.clipboard.readText()`."),[2,navigator.clipboard.readText()];if(E())return p("Reading text using IE strategy."),[2,D()];throw new Error("Read is not supported in your browser.")}))}))}e.ClipboardItem=i,e.read=function(){return t(this,void 0,void 0,(function(){var e;return n(this,(function(t){switch(t.label){case 0:return navigator.clipboard&&navigator.clipboard.readText?(p("Using `navigator.clipboard.read()`."),[2,navigator.clipboard.read()]):(e=u,[4,k()]);case 1:return[2,e.apply(void 0,[t.sent()])]}}))}))},e.readText=k,e.setDebugLog=function(e){d=e},e.suppressWarnings=function(){f=!1},e.write=S,e.writeText=function(e){return t(this,void 0,void 0,(function(){return n(this,(function(t){return navigator.clipboard&&navigator.clipboard.writeText?(p("Using `navigator.clipboard.writeText()`."),[2,navigator.clipboard.writeText(e)]):[2,S([u(e)])]}))}))},Object.defineProperty(e,"__esModule",{value:!0})})); | ||
//# sourceMappingURL=clipboard-polyfill.js.map |
@@ -1,2 +0,16 @@ | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e():"function"==typeof define&&define.amd?define(e):e()}(0,function(){"use strict";function t(t){var e=this.constructor;return this.then(function(n){return e.resolve(t()).then(function(){return n})},function(n){return e.resolve(t()).then(function(){return e.reject(n)})})}function e(t){return!(!t||void 0===t.length)}function n(){}function r(t){if(!(this instanceof r))throw new TypeError("Promises must be constructed via new");if("function"!=typeof t)throw new TypeError("not a function");this._state=0,this._handled=!1,this._value=void 0,this._deferreds=[],c(t,this)}function o(t,e){for(;3===t._state;)t=t._value;0!==t._state?(t._handled=!0,r._immediateFn(function(){var n=1===t._state?e.onFulfilled:e.onRejected;if(null!==n){var r;try{r=n(t._value)}catch(t){return void a(e.promise,t)}i(e.promise,r)}else(1===t._state?i:a)(e.promise,t._value)})):t._deferreds.push(e)}function i(t,e){try{if(e===t)throw new TypeError("A promise cannot be resolved with itself.");if(e&&("object"==typeof e||"function"==typeof e)){var n=e.then;if(e instanceof r)return t._state=3,t._value=e,void u(t);if("function"==typeof n)return void c(function(t,e){return function(){t.apply(e,arguments)}}(n,e),t)}t._state=1,t._value=e,u(t)}catch(e){a(t,e)}}function a(t,e){t._state=2,t._value=e,u(t)}function u(t){2===t._state&&0===t._deferreds.length&&r._immediateFn(function(){t._handled||r._unhandledRejectionFn(t._value)});for(var e=0,n=t._deferreds.length;n>e;e++)o(t,t._deferreds[e]);t._deferreds=null}function c(t,e){var n=!1;try{t(function(t){n||(n=!0,i(e,t))},function(t){n||(n=!0,a(e,t))})}catch(t){if(n)return;n=!0,a(e,t)}}var f=setTimeout;r.prototype.catch=function(t){return this.then(null,t)},r.prototype.then=function(t,e){var r=new this.constructor(n);return o(this,new function(t,e,n){this.onFulfilled="function"==typeof t?t:null,this.onRejected="function"==typeof e?e:null,this.promise=n}(t,e,r)),r},r.prototype.finally=t,r.all=function(t){return new r(function(n,r){function o(t,e){try{if(e&&("object"==typeof e||"function"==typeof e)){var u=e.then;if("function"==typeof u)return void u.call(e,function(e){o(t,e)},r)}i[t]=e,0==--a&&n(i)}catch(t){r(t)}}if(!e(t))return r(new TypeError("Promise.all accepts an array"));var i=Array.prototype.slice.call(t);if(0===i.length)return n([]);for(var a=i.length,u=0;i.length>u;u++)o(u,i[u])})},r.resolve=function(t){return t&&"object"==typeof t&&t.constructor===r?t:new r(function(e){e(t)})},r.reject=function(t){return new r(function(e,n){n(t)})},r.race=function(t){return new r(function(n,o){if(!e(t))return o(new TypeError("Promise.race accepts an array"));for(var i=0,a=t.length;a>i;i++)r.resolve(t[i]).then(n,o)})},r._immediateFn="function"==typeof setImmediate&&function(t){setImmediate(t)}||function(t){f(t,0)},r._unhandledRejectionFn=function(t){void 0!==console&&console&&console.warn("Possible Unhandled Promise Rejection:",t)};var s=function(){if("undefined"!=typeof self)return self;if("undefined"!=typeof window)return window;if("undefined"!=typeof global)return global;throw Error("unable to locate global object")}();"Promise"in s?s.Promise.prototype.finally||(s.Promise.prototype.finally=t):s.Promise=r}),function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t=t||self).clipboard={})}(this,function(t){"use strict";function e(t,e,n,r){return new(n||(n=Promise))(function(o,i){function a(t){try{c(r.next(t))}catch(t){i(t)}}function u(t){try{c(r.throw(t))}catch(t){i(t)}}function c(t){t.done?o(t.value):new n(function(e){e(t.value)}).then(a,u)}c((r=r.apply(t,e||[])).next())})}function n(t,e){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function u(i){return function(u){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,r=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===i[0]||2===i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=e.call(t,a)}catch(t){i=[6,t],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,u])}}}var r=["text/plain","text/html"];var o=function(){(console.warn||console.log).call(arguments)}.bind(console,"[clipboard-polyfill]"),i=!0;var a=function(){function t(){this.m={}}return t.prototype.setData=function(t,e){i&&-1===r.indexOf(t)&&o("Unknown data type: "+t,"Call clipboard.suppressWarnings() to suppress this warning."),this.m[t]=e},t.prototype.getData=function(t){return this.m[t]},t.prototype.forEach=function(t){for(var e in this.m)t(this.m[e],e)},t}(),u=function(t){},c=!0;var f=function(){(console.warn||console.log).apply(console,arguments)}.bind("[clipboard-polyfill]"),s="text/plain";function l(t){u=t}function d(){c=!1,i=!1}function p(t){return e(this,void 0,void 0,function(){var e;return n(this,function(n){if(c&&!t.getData(s)&&f("clipboard.write() was called without a `text/plain` data type. On some platforms, this may result in an empty clipboard. Call clipboard.suppressWarnings() to suppress this warning."),j()){if(function(t){var e=t.getData(s);if(void 0!==e)return window.clipboardData.setData("Text",e);throw new Error("No `text/plain` value was specified.")}(t))return[2];throw new Error("Copying failed, possibly because the user rejected it.")}if(x(t))return u("regular execCopy worked"),[2];if(navigator.userAgent.indexOf("Edge")>-1)return u('UA "Edge" => assuming success'),[2];if(_(document.body,t))return u("copyUsingTempSelection worked"),[2];if(function(t){var e=document.createElement("div");e.setAttribute("style","-webkit-user-select: text !important"),e.textContent="temporary element",document.body.appendChild(e);var n=_(e,t);return document.body.removeChild(e),n}(t))return u("copyUsingTempElem worked"),[2];if(void 0!==(e=t.getData(s))&&function(t){u("copyTextUsingDOM");var e=document.createElement("div");e.setAttribute("style","-webkit-user-select: text !important");var n=e;e.attachShadow&&(u("Using shadow DOM."),n=e.attachShadow({mode:"open"}));var r=document.createElement("span");r.innerText=t,n.appendChild(r),document.body.appendChild(e),T(r);var o=document.execCommand("copy");return E(),document.body.removeChild(e),o}(e))return u("copyTextUsingDOM worked"),[2];throw new Error("Copy command failed.")})})}function h(t){return e(this,void 0,void 0,function(){return n(this,function(e){return navigator.clipboard&&navigator.clipboard.writeText?(u("Using `navigator.clipboard.writeText()`."),[2,navigator.clipboard.writeText(t)]):[2,p(D(t))]})})}function v(){return e(this,void 0,void 0,function(){var t;return n(this,function(e){switch(e.label){case 0:return t=D,[4,y()];case 1:return[2,t.apply(void 0,[e.sent()])]}})})}function y(){return e(this,void 0,void 0,function(){return n(this,function(t){if(navigator.clipboard&&navigator.clipboard.readText)return u("Using `navigator.clipboard.readText()`."),[2,navigator.clipboard.readText()];if(j())return u("Reading text using IE strategy."),[2,C()];throw new Error("Read is not supported in your browser.")})})}var m=!1;function w(){m||(c&&f('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.'),m=!0)}var b={DT:a,setDebugLog:function(t){return w(),l(t)},suppressWarnings:function(){return w(),d()},write:function(t){return e(this,void 0,void 0,function(){return n(this,function(e){return w(),[2,p(t)]})})},writeText:function(t){return e(this,void 0,void 0,function(){return n(this,function(e){return w(),[2,h(t)]})})},read:function(){return e(this,void 0,void 0,function(){return n(this,function(t){return w(),[2,v()]})})},readText:function(){return e(this,void 0,void 0,function(){return n(this,function(t){return w(),[2,y()]})})}},g=function(){this.success=!1};function x(t){var e=new g,n=function(t,e,n){u("listener called"),t.success=!0,e.forEach(function(e,r){var o=n.clipboardData;o.setData(r,e),r===s&&o.getData(r)!==e&&(u("setting text/plain failed"),t.success=!1)}),n.preventDefault()}.bind(this,e,t);document.addEventListener("copy",n);try{document.execCommand("copy")}finally{document.removeEventListener("copy",n)}return e.success}function _(t,e){T(t);var n=x(e);return E(),n}function T(t){var e=document.getSelection();if(e){var n=document.createRange();n.selectNodeContents(t),e.removeAllRanges(),e.addRange(n)}}function E(){var t=document.getSelection();t&&t.removeAllRanges()}function D(t){var e=new a;return e.setData(s,t),e}function j(){return"undefined"==typeof ClipboardEvent&&void 0!==window.clipboardData&&void 0!==window.clipboardData.setData}function C(){return e(this,void 0,void 0,function(){var t;return n(this,function(e){if(""===(t=window.clipboardData.getData("Text")))throw new Error("Empty clipboard or could not read plain text from clipboard");return[2,t]})})}t.DT=a,t.default=b,t.read=v,t.readText=y,t.setDebugLog=l,t.suppressWarnings=d,t.write=p,t.writeText=h,Object.defineProperty(t,"__esModule",{value:!0})}); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t():"function"==typeof define&&define.amd?define(t):t()}(0,(function(){"use strict";function e(e){var t=this.constructor;return this.then((function(n){return t.resolve(e()).then((function(){return n}))}),(function(n){return t.resolve(e()).then((function(){return t.reject(n)}))}))}function t(e){return!(!e||void 0===e.length)}function n(){}function r(e){if(!(this instanceof r))throw new TypeError("Promises must be constructed via new");if("function"!=typeof e)throw new TypeError("not a function");this._state=0,this._handled=!1,this._value=void 0,this._deferreds=[],c(e,this)}function o(e,t){for(;3===e._state;)e=e._value;0!==e._state?(e._handled=!0,r._immediateFn((function(){var n=1===e._state?t.onFulfilled:t.onRejected;if(null!==n){var r;try{r=n(e._value)}catch(e){return void a(t.promise,e)}i(t.promise,r)}else(1===e._state?i:a)(t.promise,e._value)}))):e._deferreds.push(t)}function i(e,t){try{if(t===e)throw new TypeError("A promise cannot be resolved with itself.");if(t&&("object"==typeof t||"function"==typeof t)){var n=t.then;if(t instanceof r)return e._state=3,e._value=t,void u(e);if("function"==typeof n)return void c(function(e,t){return function(){e.apply(t,arguments)}}(n,t),e)}e._state=1,e._value=t,u(e)}catch(t){a(e,t)}}function a(e,t){e._state=2,e._value=t,u(e)}function u(e){2===e._state&&0===e._deferreds.length&&r._immediateFn((function(){e._handled||r._unhandledRejectionFn(e._value)}));for(var t=0,n=e._deferreds.length;n>t;t++)o(e,e._deferreds[t]);e._deferreds=null}function c(e,t){var n=!1;try{e((function(e){n||(n=!0,i(t,e))}),(function(e){n||(n=!0,a(t,e))}))}catch(e){if(n)return;n=!0,a(t,e)}}var s=setTimeout;r.prototype.catch=function(e){return this.then(null,e)},r.prototype.then=function(e,t){var r=new this.constructor(n);return o(this,new function(e,t,n){this.onFulfilled="function"==typeof e?e:null,this.onRejected="function"==typeof t?t:null,this.promise=n}(e,t,r)),r},r.prototype.finally=e,r.all=function(e){return new r((function(n,r){function o(e,t){try{if(t&&("object"==typeof t||"function"==typeof t)){var u=t.then;if("function"==typeof u)return void u.call(t,(function(t){o(e,t)}),r)}i[e]=t,0==--a&&n(i)}catch(e){r(e)}}if(!t(e))return r(new TypeError("Promise.all accepts an array"));var i=Array.prototype.slice.call(e);if(0===i.length)return n([]);for(var a=i.length,u=0;i.length>u;u++)o(u,i[u])}))},r.resolve=function(e){return e&&"object"==typeof e&&e.constructor===r?e:new r((function(t){t(e)}))},r.reject=function(e){return new r((function(t,n){n(e)}))},r.race=function(e){return new r((function(n,o){if(!t(e))return o(new TypeError("Promise.race accepts an array"));for(var i=0,a=e.length;a>i;i++)r.resolve(e[i]).then(n,o)}))},r._immediateFn="function"==typeof setImmediate&&function(e){setImmediate(e)}||function(e){s(e,0)},r._unhandledRejectionFn=function(e){void 0!==console&&console&&console.warn("Possible Unhandled Promise Rejection:",e)};var l=function(){if("undefined"!=typeof self)return self;if("undefined"!=typeof window)return window;if("undefined"!=typeof global)return global;throw Error("unable to locate global object")}();"Promise"in l?l.Promise.prototype.finally||(l.Promise.prototype.finally=e):l.Promise=r})),function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e=e||self).clipboard={})}(this,(function(e){"use strict"; | ||
/*! ***************************************************************************** | ||
Copyright (c) Microsoft Corporation. | ||
Permission to use, copy, modify, and/or distribute this software for any | ||
purpose with or without fee is hereby granted. | ||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH | ||
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY | ||
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, | ||
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM | ||
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR | ||
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR | ||
PERFORMANCE OF THIS SOFTWARE. | ||
***************************************************************************** */function t(e,t,n,r){return new(n||(n=Promise))((function(o,i){function a(e){try{c(r.next(e))}catch(e){i(e)}}function u(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,u)}c((r=r.apply(e,t||[])).next())}))}function n(e,t){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function u(i){return function(u){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,r=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!(o=a.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=t.call(e,a)}catch(e){i=[6,e],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,u])}}}function r(e,t){for(var n=0,r=e;n<r.length;n++){if(-1!==r[n].types.indexOf(t))return!0}return!1}var o=function(){function e(e,t){var n;for(var r in void 0===t&&(t={}),this.types=Object.keys(e),this._items={},e){var o=e[r];this._items[r]="string"==typeof o?i(r,o):o}this.presentationStyle=null!==(n=null==t?void 0:t.presentationStyle)&&void 0!==n?n:"unspecified"}return e.prototype.getType=function(e){return t(this,void 0,void 0,(function(){return n(this,(function(t){return[2,this._items[e]]}))}))},e}();function i(e,t){return new Blob([t],{type:e})}function a(e){return t(this,void 0,void 0,(function(){return n(this,(function(t){return[2,new Promise((function(t,n){var r=new FileReader;r.addEventListener("load",(function(){var e=r.result;"string"==typeof e?t(e):n("could not convert blob to string")})),r.readAsText(e)}))]}))}))}function u(e){return t(this,void 0,void 0,(function(){var t,r,o,i,a,u,c;return n(this,(function(n){switch(n.label){case 0:t={},r=0,o=e.types,n.label=1;case 1:return r<o.length?(i=o[r],a=t,u=i,[4,e.getType(i)]):[3,4];case 2:a[u]=n.sent(),n.label=3;case 3:return r++,[3,1];case 4:return c={},e.presentationStyle&&(c.presentationStyle=e.presentationStyle),[2,new window.ClipboardItem(t,c)]}}))}))}function c(e){var t={};return t["text/plain"]=i(e,"text/plain"),new o(t)}function s(e,r){return t(this,void 0,void 0,(function(){return n(this,(function(t){switch(t.label){case 0:return[4,e.getType(r)];case 1:return[4,a(t.sent())];case 2:return[2,t.sent()]}}))}))}function l(e){return t(this,void 0,void 0,(function(){var t,r,o,i,a,u;return n(this,(function(n){switch(n.label){case 0:t={},r=0,o=e.types,n.label=1;case 1:return r<o.length?(i=o[r],a=t,u=i,[4,s(e,i)]):[3,4];case 2:a[u]=n.sent(),n.label=3;case 3:return r++,[3,1];case 4:return[2,t]}}))}))}var f=function(e){};function d(e){f(e)}var p=!0;function v(){return p}(function(){(console.warn||console.log).apply(console,arguments)}).bind("[clipboard-polyfill]");var h=function(){this.success=!1};function y(e,t,n){for(var r in d("listener called"),e.success=!0,t){var o=t[r],i=n.clipboardData;i.setData(r,o),"text/plain"===r&&i.getData(r)!==o&&(d("setting text/plain failed"),e.success=!1)}n.preventDefault()}function b(e){var t=new h,n=y.bind(this,t,e);document.addEventListener("copy",n);try{document.execCommand("copy")}finally{document.removeEventListener("copy",n)}return t.success}function m(e,t){g(e);var n=b(t);return x(),n}function w(e){d("copyTextUsingDOM");var t=document.createElement("div");t.setAttribute("style","-webkit-user-select: text !important");var n=t;t.attachShadow&&(d("Using shadow DOM."),n=t.attachShadow({mode:"open"}));var r=document.createElement("span");r.innerText=e,n.appendChild(r),document.body.appendChild(t),g(r);var o=document.execCommand("copy");return x(),document.body.removeChild(t),o}function g(e){var t=document.getSelection();if(t){var n=document.createRange();n.selectNodeContents(e),t.removeAllRanges(),t.addRange(n)}}function x(){var e=document.getSelection();e&&e.removeAllRanges()}var _=window;function T(){return"undefined"==typeof ClipboardEvent&&void 0!==_.clipboardData&&void 0!==_.clipboardData.setData}function E(e){return _.clipboardData.setData("Text",e)}function j(){return t(this,void 0,void 0,(function(){var e;return n(this,(function(t){if(""===(e=_.clipboardData.getData("Text")))throw new Error("Empty clipboard or could not read plain text from clipboard");return[2,e]}))}))}function C(e){return t(this,void 0,void 0,(function(){var t,o,i,a,c;return n(this,(function(n){switch(n.label){case 0:return!r(e,"text/html")&&navigator.clipboard&&navigator.clipboard.write?(d("Using `navigator.clipboard.write()`."),[4,Promise.all(e.map(u))]):[3,2];case 1:return t=n.sent(),[2,navigator.clipboard.write(t)];case 2:if(o=r(e,"text/plain"),v&&!o&&d("clipboard.write() was called without a `text/plain` data type. On some platforms, this may result in an empty clipboard. Call suppressWarnings() to suppress this warning."),!T())return[3,4];if(!o)throw new Error("No `text/plain` value was specified.");return i=E,[4,s(e[0],"text/plain")];case 3:if(i.apply(void 0,[n.sent()]))return[2];throw new Error("Copying failed, possibly because the user rejected it.");case 4:return[4,l(e[0])];case 5:return b(a=n.sent())?(d("regular execCopy worked"),[2]):navigator.userAgent.indexOf("Edge")>-1?(d('UA "Edge" => assuming success'),[2]):m(document.body,a)?(d("copyUsingTempSelection worked"),[2]):function(e){var t=document.createElement("div");t.setAttribute("style","-webkit-user-select: text !important"),t.textContent="temporary element",document.body.appendChild(t);var n=m(t,e);return document.body.removeChild(t),n}(a)?(d("copyUsingTempElem worked"),[2]):(c=w,[4,s(e[0],"text/plain")]);case 6:if(c.apply(void 0,[n.sent()]))return d("copyTextUsingDOM worked"),[2];throw new Error("Copy command failed.")}}))}))}function D(){return t(this,void 0,void 0,(function(){return n(this,(function(e){if(navigator.clipboard&&navigator.clipboard.readText)return d("Using `navigator.clipboard.readText()`."),[2,navigator.clipboard.readText()];if(T())return d("Reading text using IE strategy."),[2,j()];throw new Error("Read is not supported in your browser.")}))}))}e.ClipboardItem=o,e.read=function(){return t(this,void 0,void 0,(function(){var e;return n(this,(function(t){switch(t.label){case 0:return navigator.clipboard&&navigator.clipboard.readText?(d("Using `navigator.clipboard.read()`."),[2,navigator.clipboard.read()]):(e=c,[4,D()]);case 1:return[2,e.apply(void 0,[t.sent()])]}}))}))},e.readText=D,e.setDebugLog=function(e){f=e},e.suppressWarnings=function(){p=!1},e.write=C,e.writeText=function(e){return t(this,void 0,void 0,(function(){return n(this,(function(t){return navigator.clipboard&&navigator.clipboard.writeText?(d("Using `navigator.clipboard.writeText()`."),[2,navigator.clipboard.writeText(e)]):[2,C([c(e)])]}))}))},Object.defineProperty(e,"__esModule",{value:!0})})); | ||
//# sourceMappingURL=clipboard-polyfill.promise.js.map |
{ | ||
"name": "clipboard-polyfill", | ||
"version": "2.8.6", | ||
"version": "3.0.0-pre1", | ||
"description": "A polyfill for the asynchronous clipboard API", | ||
@@ -10,21 +10,21 @@ "main": "dist/clipboard-polyfill.js", | ||
"devDependencies": { | ||
"@babel/core": "^7.5.0", | ||
"@babel/preset-env": "^7.5.2", | ||
"@babel/preset-typescript": "^7.3.3", | ||
"@babel/core": "^7.10.3", | ||
"@babel/preset-env": "^7.10.3", | ||
"@babel/preset-typescript": "^7.10.1", | ||
"@types/es6-promise": "^3.3.0", | ||
"@types/jest": "^24.0.17", | ||
"@types/jest": "^24.9.1", | ||
"@types/promise-polyfill": "^6.0.3", | ||
"babel-preset-es2015-rollup": "^3.0.0", | ||
"es6-promise": "^4.2.8", | ||
"jest": "^24.8.0", | ||
"jest": "^26.1.0", | ||
"promise-polyfill": "^8.1.3", | ||
"rollup": "^1.19.4", | ||
"rollup-plugin-babel": "^4.3.3", | ||
"rollup-plugin-terser": "^5.0.0", | ||
"rollup": "^1.32.1", | ||
"rollup-plugin-babel": "^4.4.0", | ||
"rollup-plugin-terser": "^6.1.0", | ||
"rollup-plugin-tslint": "^0.2.2", | ||
"rollup-plugin-typescript2": "^0.21.2", | ||
"ts-jest": "^24.0.2", | ||
"rollup-plugin-typescript2": "^0.27.1", | ||
"ts-jest": "^26.1.1", | ||
"ts-loader": "^5.2.2", | ||
"tslint": "^5.18.0", | ||
"typescript": "^3.5.3" | ||
"typescript": "^3.9.5" | ||
}, | ||
@@ -55,3 +55,3 @@ "repository": { | ||
"/dist", | ||
"*.ts", | ||
"/src", | ||
"README.md" | ||
@@ -63,3 +63,3 @@ ], | ||
"clean": "rm -rf dist", | ||
"test": "jest && npm run lint", | ||
"test": "jest", | ||
"setup": "npm install", | ||
@@ -66,0 +66,0 @@ "lint": "tslint --fix --project . ; tslint --fix rollup.config.js", |
@@ -9,3 +9,4 @@ ![Logo for clipboard-polyfill: an icon of a clipboard fading into a drafting paper grid.](clipboard-polyfill-logo.svg) | ||
As of October 2017, this library is a polyfill for the modern `Promise`-based [asynchronous clipboard API](https://www.w3.org/TR/clipboard-apis/#async-clipboard-api). | ||
As of October 2017, this library is a polyfill for the modern `Promise`-based [asynchronous clipboard API](https://www.w3.org/TR/clipboard-apis/#async-clipboard-api). | ||
(Note: the core library doesn't modify global objects, so it's actually a [_ponyfill_](https://ponyfill.com/).) | ||
@@ -16,2 +17,4 @@ ## Why `clipboard-polyfill`? | ||
See [this presentation](https://docs.google.com/presentation/d/1Ix2rYi67hbZoIQsd85kspkUPLi8Q-PZopy_AtfafHW0) for for a longer history of clipboard access on the web. | ||
Note: If you only need to copy text and want a super simple polyfill that gets you 80% of the way, consider using [this gist](https://gist.github.com/lgarron/d1dee380f4ed9d825ca7). | ||
@@ -27,3 +30,3 @@ | ||
- Download [`dist/clipboard-polyfill.js`](https://raw.githubusercontent.com/lgarron/clipboard-polyfill/master/dist/clipboard-polyfill.js) and include it using a `<script>` tag. | ||
- Download [`clipboard-polyfill.js`](https://github.com/lgarron/clipboard-polyfill/releases/latest/download/clipboard-polyfill.js) and include it using a `<script>` tag. | ||
- `npm install clipboard-polyfill` and one of: | ||
@@ -35,4 +38,11 @@ - `import * as clipboard from "clipboard-polyfill"` | ||
This version works "out of the box" in all browsers that support copying to the clipboard, but is about 2.5x as large. | ||
This version works "out of the box" in all browsers that support copying to the clipboard, but is larger. | ||
- Download [`clipboard-polyfill.promise.js`](https://github.com/lgarron/clipboard-polyfill/releases/latest/download/clipboard-polyfill.promise.js) and include it using a `<script>` tag. | ||
- `npm install clipboard-polyfill` and one of: | ||
- `import * as clipboard from "clipboard-polyfill/dist/clipboard-polyfill.promise"` | ||
- `const clipboard = require("clipboard-polyfill/dist/clipboard-polyfill.promise");` | ||
# Note: the Promise polyfill in this build version _will_ modify the global object. | ||
- Download [`dist/clipboard-polyfill.promise.js`](https://raw.githubusercontent.com/lgarron/clipboard-polyfill/master/dist/clipboard-polyfill.promise.js) and include it using a `<script>` tag. | ||
@@ -109,3 +119,3 @@ - `npm install clipboard-polyfill` and one of: | ||
Ideally, `clipboard-polyfill` would take a `DataTransfer`, so that the code above works verbatim when you replace `navigator.clipboard` with `clipboard`. However, *the `DataTransfer` constructor cannot be called* in most browsers. Thus, this library uses a light-weight alternative to `DataTransfer`, exposed as `clipboard.DT`: | ||
Ideally, `clipboard-polyfill` would take a `DataTransfer`, so that the code above works verbatim when you replace `navigator.clipboard` with `clipboard`. However, _the `DataTransfer` constructor cannot be called_ in most browsers. Thus, this library uses a light-weight alternative to `DataTransfer`, exposed as `clipboard.DT`: | ||
@@ -116,3 +126,2 @@ var dt = new clipboard.DT(); | ||
## This is way too complicated! | ||
@@ -137,7 +146,7 @@ | ||
- In Microsoft Edge, it seems to be impossible to detect whether the copy action actually succeeded ([Edge Bug #14110451](https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/14110451/), [Edge Bug #14080262](https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/14080262/)). `clipboard-polyfill` will always call `resolve()` in Edge. | ||
- In Microsoft Edge, only the *last* data type you specify is copied to the clipboard ([Edge Bug #14080506](https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/14080506/)). | ||
- In Microsoft Edge, only the _last_ data type you specify is copied to the clipboard ([Edge Bug #14080506](https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/14080506/)). | ||
- `DataTransfer` and `clipboard.DT` keep track of the order in which you set items. If you care which data type Edge copies, call `setData()` with that data type last. | ||
- On iOS Safari ([WebKit Bug #177715](https://bugs.webkit.org/show_bug.cgi?id=177715)) and Internet Explorer, only text copying works. | ||
- On iOS Safari, `clipboard-polyfill` needs to use the DOM to copy, so the text will be copied as rich text. `clipboard-polyfill` attempts to use shadow DOM in order to avoid some of the page formatting (e.g. background color) from affecting the copied text. However, such formatting might be copied if shadow DOM is not available. | ||
- In other browsers, writing copy data that does *not* include the `text/plain` data type will succeed, but also show a console warning: | ||
- In other browsers, writing copy data that does _not_ include the `text/plain` data type will succeed, but also show a console warning: | ||
@@ -147,3 +156,3 @@ > clipboard.write() was called without a `text/plain` data type. On some platforms, this may result in an empty clipboard. Call `clipboard.suppressWarnings()` to suppress this warning. | ||
- `clipboard-polyfill` attemps to avoid changing the document selection or modifying the DOM. However, `clipboard-polyfill` will automatically fall back to using such techniques if needed: | ||
- On iOS Safari, the user's current selection will be cleared. This *should* not happen on other platforms unless there are unanticipated bugs. (Please [file an issue](https://github.com/lgarron/clipboard-polyfill/issues/new) if you observe this!) | ||
- On iOS Safari, the user's current selection will be cleared. This _should_ not happen on other platforms unless there are unanticipated bugs. (Please [file an issue](https://github.com/lgarron/clipboard-polyfill/issues/new) if you observe this!) | ||
- On iOS Safari and under certain conditions on desktop Safari ([WebKit Bug #177715](https://bugs.webkit.org/show_bug.cgi?id=156529)), `clipboard-polyfill` needs to add a temporary element to the DOM. This will trigger a [mutation observer](https://developer.mozilla.org/en-US/docs/Web/API/MutationObserver) if you have attached one to `document.body`. Please [file an issue](https://github.com/lgarron/clipboard-polyfill/issues/new) if you'd like to discuss how to detect temporary elements added by `clipboard-polyfill`. | ||
@@ -150,0 +159,0 @@ - `read()` currently only works in Internet Explorer. |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
124361
31
700
155
2
1