Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

clipboard-polyfill

Package Overview
Dependencies
Maintainers
1
Versions
50
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

clipboard-polyfill - npm Package Compare versions

Comparing version 3.0.3 to 4.0.0-rc1

2

dist/main/clipboard-polyfill.esm.js

@@ -15,3 +15,3 @@ /*! *****************************************************************************

***************************************************************************** */
function t(t,e,n,r){return new(n||(n=Promise))((function(i,o){function a(t){try{c(r.next(t))}catch(t){o(t)}}function u(t){try{c(r.throw(t))}catch(t){o(t)}}function c(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,u)}c((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:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function u(o){return function(u){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,u])}}}var n=function(t){};function r(t){n(t)}function i(t){n=t}var o=!0;function a(){o=!1}function u(){return o}(function(){(console.warn||console.log).apply(console,arguments)}).bind("[clipboard-polyfill]");var c,s,l,d,f="undefined"==typeof navigator?void 0:navigator,p=null==f?void 0:f.clipboard,v=null===(c=null==p?void 0:p.read)||void 0===c?void 0:c.bind(p),h=null===(s=null==p?void 0:p.readText)||void 0===s?void 0:s.bind(p),y=null===(l=null==p?void 0:p.write)||void 0===l?void 0:l.bind(p),b=null===(d=null==p?void 0:p.writeText)||void 0===d?void 0:d.bind(p),w="undefined"==typeof window?void 0:window,m=null==w?void 0:w.ClipboardItem,g=w;function x(){return"undefined"==typeof ClipboardEvent&&void 0!==g.clipboardData&&void 0!==g.clipboardData.setData}function E(){return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){if(""===(t=g.clipboardData.getData("Text")))throw new Error("Empty clipboard or could not read plain text from clipboard");return[2,t]}))}))}var T=function(){this.success=!1};function C(t,e,n){for(var i in r("listener called"),t.success=!0,e){var o=e[i],a=n.clipboardData;a.setData(i,o),"text/plain"===i&&a.getData(i)!==o&&(r("setting text/plain failed"),t.success=!1)}n.preventDefault()}function D(t){var e=new T,n=C.bind(this,e,t);document.addEventListener("copy",n);try{document.execCommand("copy")}finally{document.removeEventListener("copy",n)}return e.success}function S(t,e){k(t);var n=D(e);return U(),n}function k(t){var e=document.getSelection();if(e){var n=document.createRange();n.selectNodeContents(t),e.removeAllRanges(),e.addRange(n)}}function U(){var t=document.getSelection();t&&t.removeAllRanges()}function A(n){return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){if(t="text/plain"in n,x()){if(!t)throw new Error("No `text/plain` value was specified.");if(i=n["text/plain"],g.clipboardData.setData("Text",i))return[2,!0];throw new Error("Copying failed, possibly because the user rejected it.")}var i;return D(n)?(r("regular execCopy worked"),[2,!0]):navigator.userAgent.indexOf("Edge")>-1?(r('UA "Edge" => assuming success'),[2,!0]):S(document.body,n)?(r("copyUsingTempSelection worked"),[2,!0]):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=S(e,t);return document.body.removeChild(e),n}(n)?(r("copyUsingTempElem worked"),[2,!0]):function(t){r("copyTextUsingDOM");var e=document.createElement("div");e.setAttribute("style","-webkit-user-select: text !important");var n=e;e.attachShadow&&(r("Using shadow DOM."),n=e.attachShadow({mode:"open"}));var i=document.createElement("span");i.innerText=t,n.appendChild(i),document.body.appendChild(e),k(i);var o=document.execCommand("copy");return U(),document.body.removeChild(e),o}(n["text/plain"])?(r("copyTextUsingDOM worked"),[2,!0]):[2,!1]}))}))}function O(n){return t(this,void 0,void 0,(function(){return e(this,(function(t){if(b)return r("Using `navigator.clipboard.writeText()`."),[2,b(n)];if(!A(function(t){var e={};return e["text/plain"]=t,e}(n)))throw new Error("writeText() failed");return[2]}))}))}function R(){return t(this,void 0,void 0,(function(){return e(this,(function(t){if(h)return r("Using `navigator.clipboard.readText()`."),[2,h()];if(x())return r("Reading text using IE strategy."),[2,E()];throw new Error("Read is not supported in your browser.")}))}))}function I(t,e){for(var n=0,r=t;n<r.length;n++){if(-1!==r[n].types.indexOf(e))return!0}return!1}var L=function(){function n(t,e){var n;for(var r in void 0===e&&(e={}),this.types=Object.keys(t),this._items={},t){var i=t[r];this._items[r]="string"==typeof i?M(r,i):i}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 M(t,e){return new Blob([e],{type:t})}function P(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 _(n){return t(this,void 0,void 0,(function(){var t,r,i,o,a,u,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,u=o,[4,n.getType(o)]):[3,4];case 2:a[u]=e.sent(),e.label=3;case 3:return r++,[3,1];case 4:return c={},n.presentationStyle&&(c.presentationStyle=n.presentationStyle),[2,new m(t,c)]}}))}))}function j(t){var e={};return e["text/plain"]=M(t,"text/plain"),new L(e)}function N(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,P(t.sent())];case 2:return[2,t.sent()]}}))}))}function B(n){return t(this,void 0,void 0,(function(){var t,r,i,o,a,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,u=o,[4,N(n,o)]):[3,4];case 2:a[u]=e.sent(),e.label=3;case 3:return r++,[3,1];case 4:return[2,t]}}))}))}function F(n){return t(this,void 0,void 0,(function(){var t,i,o,a;return e(this,(function(e){switch(e.label){case 0:return y&&m?(r("Using `navigator.clipboard.write()`."),[4,Promise.all(n.map(_))]):[3,5];case 1:t=e.sent(),e.label=2;case 2:return e.trys.push([2,4,,5]),[4,y(t)];case 3:return[2,e.sent()];case 4:if(i=e.sent(),!I(n,"text/plain")&&!I(n,"text/html"))throw i;return[3,5];case 5:return o=I(n,"text/plain"),u&&!o&&r("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."),a=A,[4,B(n[0])];case 6:if(!a.apply(void 0,[e.sent()]))throw new Error("write() failed");return[2]}}))}))}function G(){return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return v?(r("Using `navigator.clipboard.read()`."),[2,v()]):(t=j,[4,R()]);case 1:return[2,[t.apply(void 0,[e.sent()])]]}}))}))}export{L as ClipboardItem,G as read,R as readText,i as setDebugLog,a as suppressWarnings,F as write,O as writeText};
function t(t,e,n,r){return new(n||(n=Promise))((function(i,o){function a(t){try{c(r.next(t))}catch(t){o(t)}}function u(t){try{c(r.throw(t))}catch(t){o(t)}}function c(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,u)}c((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:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function u(o){return function(u){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,u])}}}var n=function(t){};function r(t){n(t)}function i(t){n=t}var o=!0;function a(){o=!1}(function(){(console.warn||console.log).apply(console,arguments)}).bind("[clipboard-polyfill]");var u,c,s,l,d="undefined"==typeof navigator?void 0:navigator,f=null==d?void 0:d.clipboard,p=null===(u=null==f?void 0:f.read)||void 0===u?void 0:u.bind(f),v=null===(c=null==f?void 0:f.readText)||void 0===c?void 0:c.bind(f),h=null===(s=null==f?void 0:f.write)||void 0===s?void 0:s.bind(f),y=null===(l=null==f?void 0:f.writeText)||void 0===l?void 0:l.bind(f),b="undefined"==typeof window?void 0:window,w=null==b?void 0:b.ClipboardItem,m=b;function g(){return"undefined"==typeof ClipboardEvent&&void 0!==m.clipboardData&&void 0!==m.clipboardData.setData}function x(){return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){if(""===(t=m.clipboardData.getData("Text")))throw new Error("Empty clipboard or could not read plain text from clipboard");return[2,t]}))}))}var E=function(){this.success=!1};function T(t,e,n){for(var i in r("listener called"),t.success=!0,e){var o=e[i],a=n.clipboardData;a.setData(i,o),"text/plain"===i&&a.getData(i)!==o&&(r("setting text/plain failed"),t.success=!1)}n.preventDefault()}function C(t){var e=new E,n=T.bind(this,e,t);document.addEventListener("copy",n);try{document.execCommand("copy")}finally{document.removeEventListener("copy",n)}return e.success}function D(t,e){S(t);var n=C(e);return k(),n}function S(t){var e=document.getSelection();if(e){var n=document.createRange();n.selectNodeContents(t),e.removeAllRanges(),e.addRange(n)}}function k(){var t=document.getSelection();t&&t.removeAllRanges()}function U(n){return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){if(t="text/plain"in n,g()){if(!t)throw new Error("No `text/plain` value was specified.");if(i=n["text/plain"],m.clipboardData.setData("Text",i))return[2,!0];throw new Error("Copying failed, possibly because the user rejected it.")}var i;return C(n)?(r("regular execCopy worked"),[2,!0]):navigator.userAgent.indexOf("Edge")>-1?(r('UA "Edge" => assuming success'),[2,!0]):D(document.body,n)?(r("copyUsingTempSelection worked"),[2,!0]):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}(n)?(r("copyUsingTempElem worked"),[2,!0]):function(t){r("copyTextUsingDOM");var e=document.createElement("div");e.setAttribute("style","-webkit-user-select: text !important");var n=e;e.attachShadow&&(r("Using shadow DOM."),n=e.attachShadow({mode:"open"}));var i=document.createElement("span");i.innerText=t,n.appendChild(i),document.body.appendChild(e),S(i);var o=document.execCommand("copy");return k(),document.body.removeChild(e),o}(n["text/plain"])?(r("copyTextUsingDOM worked"),[2,!0]):[2,!1]}))}))}function A(n){return t(this,void 0,void 0,(function(){return e(this,(function(t){if(y)return r("Using `navigator.clipboard.writeText()`."),[2,y(n)];if(!U(function(t){var e={};return e["text/plain"]=t,e}(n)))throw new Error("writeText() failed");return[2]}))}))}function O(){return t(this,void 0,void 0,(function(){return e(this,(function(t){if(v)return r("Using `navigator.clipboard.readText()`."),[2,v()];if(g())return r("Reading text using IE strategy."),[2,x()];throw new Error("Read is not supported in your browser.")}))}))}function R(t,e){for(var n=0,r=t;n<r.length;n++){if(-1!==r[n].types.indexOf(e))return!0}return!1}var I=function(){function n(t,e){var n;for(var r in void 0===e&&(e={}),this.types=Object.keys(t),this._items={},t){var i=t[r];this._items[r]="string"==typeof i?L(r,i):i}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 L(t,e){return new Blob([e],{type:t})}function M(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 P(n){return t(this,void 0,void 0,(function(){var t,r,i,o,a,u,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,u=o,[4,n.getType(o)]):[3,4];case 2:a[u]=e.sent(),e.label=3;case 3:return r++,[3,1];case 4:return c={},n.presentationStyle&&(c.presentationStyle=n.presentationStyle),[2,new w(t,c)]}}))}))}function _(t){var e={};return e["text/plain"]=L(t,"text/plain"),new I(e)}function j(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,M(t.sent())];case 2:return[2,t.sent()]}}))}))}function N(n){return t(this,void 0,void 0,(function(){var t,r,i,o,a,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,u=o,[4,j(n,o)]):[3,4];case 2:a[u]=e.sent(),e.label=3;case 3:return r++,[3,1];case 4:return[2,t]}}))}))}function B(n){return t(this,void 0,void 0,(function(){var t,i,a,u;return e(this,(function(e){switch(e.label){case 0:return h&&w?(r("Using `navigator.clipboard.write()`."),[4,Promise.all(n.map(P))]):[3,5];case 1:t=e.sent(),e.label=2;case 2:return e.trys.push([2,4,,5]),[4,h(t)];case 3:return[2,e.sent()];case 4:if(i=e.sent(),!R(n,"text/plain")&&!R(n,"text/html"))throw i;return[3,5];case 5:return a=R(n,"text/plain"),o&&!a&&r("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."),u=U,[4,N(n[0])];case 6:if(!u.apply(void 0,[e.sent()]))throw new Error("write() failed");return[2]}}))}))}function F(){return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return p?(r("Using `navigator.clipboard.read()`."),[2,p()]):(t=_,[4,O()]);case 1:return[2,[t.apply(void 0,[e.sent()])]]}}))}))}export{I as ClipboardItem,F as read,O as readText,i as setDebugLog,a as suppressWarnings,B as write,A as writeText};
//# sourceMappingURL=clipboard-polyfill.esm.js.map

@@ -15,3 +15,3 @@ !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";

PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */function t(e,t,n,r){return new(n||(n=Promise))((function(i,o){function a(e){try{c(r.next(e))}catch(e){o(e)}}function u(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(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,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function u(o){return function(u){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,u])}}}var r=function(e){};function i(e){r(e)}var o=!0;function a(){return o}(function(){(console.warn||console.log).apply(console,arguments)}).bind("[clipboard-polyfill]");var u,c,s,l,d="undefined"==typeof navigator?void 0:navigator,f=null==d?void 0:d.clipboard,p=null===(u=null==f?void 0:f.read)||void 0===u?void 0:u.bind(f),v=null===(c=null==f?void 0:f.readText)||void 0===c?void 0:c.bind(f),h=null===(s=null==f?void 0:f.write)||void 0===s?void 0:s.bind(f),y=null===(l=null==f?void 0:f.writeText)||void 0===l?void 0:l.bind(f),b="undefined"==typeof window?void 0:window,w=null==b?void 0:b.ClipboardItem,m=b;function g(){return"undefined"==typeof ClipboardEvent&&void 0!==m.clipboardData&&void 0!==m.clipboardData.setData}function x(){return t(this,void 0,void 0,(function(){var e;return n(this,(function(t){if(""===(e=m.clipboardData.getData("Text")))throw new Error("Empty clipboard or could not read plain text from clipboard");return[2,e]}))}))}var E=function(){this.success=!1};function T(e,t,n){for(var r in i("listener called"),e.success=!0,t){var o=t[r],a=n.clipboardData;a.setData(r,o),"text/plain"===r&&a.getData(r)!==o&&(i("setting text/plain failed"),e.success=!1)}n.preventDefault()}function C(e){var t=new E,n=T.bind(this,t,e);document.addEventListener("copy",n);try{document.execCommand("copy")}finally{document.removeEventListener("copy",n)}return t.success}function D(e,t){S(e);var n=C(t);return k(),n}function S(e){var t=document.getSelection();if(t){var n=document.createRange();n.selectNodeContents(e),t.removeAllRanges(),t.addRange(n)}}function k(){var e=document.getSelection();e&&e.removeAllRanges()}function U(e){return t(this,void 0,void 0,(function(){var t;return n(this,(function(n){if(t="text/plain"in e,g()){if(!t)throw new Error("No `text/plain` value was specified.");if(r=e["text/plain"],m.clipboardData.setData("Text",r))return[2,!0];throw new Error("Copying failed, possibly because the user rejected it.")}var r;return C(e)?(i("regular execCopy worked"),[2,!0]):navigator.userAgent.indexOf("Edge")>-1?(i('UA "Edge" => assuming success'),[2,!0]):D(document.body,e)?(i("copyUsingTempSelection worked"),[2,!0]):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=D(t,e);return document.body.removeChild(t),n}(e)?(i("copyUsingTempElem worked"),[2,!0]):function(e){i("copyTextUsingDOM");var t=document.createElement("div");t.setAttribute("style","-webkit-user-select: text !important");var n=t;t.attachShadow&&(i("Using shadow DOM."),n=t.attachShadow({mode:"open"}));var r=document.createElement("span");r.innerText=e,n.appendChild(r),document.body.appendChild(t),S(r);var o=document.execCommand("copy");return k(),document.body.removeChild(t),o}(e["text/plain"])?(i("copyTextUsingDOM worked"),[2,!0]):[2,!1]}))}))}function O(){return t(this,void 0,void 0,(function(){return n(this,(function(e){if(v)return i("Using `navigator.clipboard.readText()`."),[2,v()];if(g())return i("Reading text using IE strategy."),[2,x()];throw new Error("Read is not supported in your browser.")}))}))}function A(e,t){for(var n=0,r=e;n<r.length;n++){if(-1!==r[n].types.indexOf(t))return!0}return!1}var R=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?_(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 _(e,t){return new Blob([t],{type:e})}function j(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 L(e){return t(this,void 0,void 0,(function(){var t,r,i,o,a,u,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,u=o,[4,e.getType(o)]):[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 w(t,c)]}}))}))}function M(e){var t={};return t["text/plain"]=_(e,"text/plain"),new R(t)}function P(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,j(t.sent())];case 2:return[2,t.sent()]}}))}))}function I(e){return t(this,void 0,void 0,(function(){var t,r,i,o,a,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,u=o,[4,P(e,o)]):[3,4];case 2:a[u]=n.sent(),n.label=3;case 3:return r++,[3,1];case 4:return[2,t]}}))}))}e.ClipboardItem=R,e.read=function(){return t(this,void 0,void 0,(function(){var e;return n(this,(function(t){switch(t.label){case 0:return p?(i("Using `navigator.clipboard.read()`."),[2,p()]):(e=M,[4,O()]);case 1:return[2,[e.apply(void 0,[t.sent()])]]}}))}))},e.readText=O,e.setDebugLog=function(e){r=e},e.suppressWarnings=function(){o=!1},e.write=function(e){return t(this,void 0,void 0,(function(){var t,r,o,u;return n(this,(function(n){switch(n.label){case 0:return h&&w?(i("Using `navigator.clipboard.write()`."),[4,Promise.all(e.map(L))]):[3,5];case 1:t=n.sent(),n.label=2;case 2:return n.trys.push([2,4,,5]),[4,h(t)];case 3:return[2,n.sent()];case 4:if(r=n.sent(),!A(e,"text/plain")&&!A(e,"text/html"))throw r;return[3,5];case 5:return o=A(e,"text/plain"),a&&!o&&i("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."),u=U,[4,I(e[0])];case 6:if(!u.apply(void 0,[n.sent()]))throw new Error("write() failed");return[2]}}))}))},e.writeText=function(e){return t(this,void 0,void 0,(function(){return n(this,(function(t){if(y)return i("Using `navigator.clipboard.writeText()`."),[2,y(e)];if(!U(function(e){var t={};return t["text/plain"]=e,t}(e)))throw new Error("writeText() failed");return[2]}))}))},Object.defineProperty(e,"__esModule",{value:!0})}));
***************************************************************************** */function t(e,t,n,r){return new(n||(n=Promise))((function(i,o){function a(e){try{c(r.next(e))}catch(e){o(e)}}function u(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(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,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function u(o){return function(u){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,u])}}}var r=function(e){};function i(e){r(e)}var o=!0;(function(){(console.warn||console.log).apply(console,arguments)}).bind("[clipboard-polyfill]");var a,u,c,s,l="undefined"==typeof navigator?void 0:navigator,d=null==l?void 0:l.clipboard,f=null===(a=null==d?void 0:d.read)||void 0===a?void 0:a.bind(d),p=null===(u=null==d?void 0:d.readText)||void 0===u?void 0:u.bind(d),v=null===(c=null==d?void 0:d.write)||void 0===c?void 0:c.bind(d),h=null===(s=null==d?void 0:d.writeText)||void 0===s?void 0:s.bind(d),y="undefined"==typeof window?void 0:window,b=null==y?void 0:y.ClipboardItem,w=y;function m(){return"undefined"==typeof ClipboardEvent&&void 0!==w.clipboardData&&void 0!==w.clipboardData.setData}function g(){return t(this,void 0,void 0,(function(){var e;return n(this,(function(t){if(""===(e=w.clipboardData.getData("Text")))throw new Error("Empty clipboard or could not read plain text from clipboard");return[2,e]}))}))}var x=function(){this.success=!1};function E(e,t,n){for(var r in i("listener called"),e.success=!0,t){var o=t[r],a=n.clipboardData;a.setData(r,o),"text/plain"===r&&a.getData(r)!==o&&(i("setting text/plain failed"),e.success=!1)}n.preventDefault()}function T(e){var t=new x,n=E.bind(this,t,e);document.addEventListener("copy",n);try{document.execCommand("copy")}finally{document.removeEventListener("copy",n)}return t.success}function C(e,t){D(e);var n=T(t);return S(),n}function D(e){var t=document.getSelection();if(t){var n=document.createRange();n.selectNodeContents(e),t.removeAllRanges(),t.addRange(n)}}function S(){var e=document.getSelection();e&&e.removeAllRanges()}function k(e){return t(this,void 0,void 0,(function(){var t;return n(this,(function(n){if(t="text/plain"in e,m()){if(!t)throw new Error("No `text/plain` value was specified.");if(r=e["text/plain"],w.clipboardData.setData("Text",r))return[2,!0];throw new Error("Copying failed, possibly because the user rejected it.")}var r;return T(e)?(i("regular execCopy worked"),[2,!0]):navigator.userAgent.indexOf("Edge")>-1?(i('UA "Edge" => assuming success'),[2,!0]):C(document.body,e)?(i("copyUsingTempSelection worked"),[2,!0]):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=C(t,e);return document.body.removeChild(t),n}(e)?(i("copyUsingTempElem worked"),[2,!0]):function(e){i("copyTextUsingDOM");var t=document.createElement("div");t.setAttribute("style","-webkit-user-select: text !important");var n=t;t.attachShadow&&(i("Using shadow DOM."),n=t.attachShadow({mode:"open"}));var r=document.createElement("span");r.innerText=e,n.appendChild(r),document.body.appendChild(t),D(r);var o=document.execCommand("copy");return S(),document.body.removeChild(t),o}(e["text/plain"])?(i("copyTextUsingDOM worked"),[2,!0]):[2,!1]}))}))}function U(){return t(this,void 0,void 0,(function(){return n(this,(function(e){if(p)return i("Using `navigator.clipboard.readText()`."),[2,p()];if(m())return i("Reading text using IE strategy."),[2,g()];throw new Error("Read is not supported in your browser.")}))}))}function O(e,t){for(var n=0,r=e;n<r.length;n++){if(-1!==r[n].types.indexOf(t))return!0}return!1}var A=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?R(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 R(e,t){return new Blob([t],{type:e})}function _(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 j(e){return t(this,void 0,void 0,(function(){var t,r,i,o,a,u,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,u=o,[4,e.getType(o)]):[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 b(t,c)]}}))}))}function L(e){var t={};return t["text/plain"]=R(e,"text/plain"),new A(t)}function M(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,_(t.sent())];case 2:return[2,t.sent()]}}))}))}function P(e){return t(this,void 0,void 0,(function(){var t,r,i,o,a,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,u=o,[4,M(e,o)]):[3,4];case 2:a[u]=n.sent(),n.label=3;case 3:return r++,[3,1];case 4:return[2,t]}}))}))}e.ClipboardItem=A,e.read=function(){return t(this,void 0,void 0,(function(){var e;return n(this,(function(t){switch(t.label){case 0:return f?(i("Using `navigator.clipboard.read()`."),[2,f()]):(e=L,[4,U()]);case 1:return[2,[e.apply(void 0,[t.sent()])]]}}))}))},e.readText=U,e.setDebugLog=function(e){r=e},e.suppressWarnings=function(){o=!1},e.write=function(e){return t(this,void 0,void 0,(function(){var t,r,a,u;return n(this,(function(n){switch(n.label){case 0:return v&&b?(i("Using `navigator.clipboard.write()`."),[4,Promise.all(e.map(j))]):[3,5];case 1:t=n.sent(),n.label=2;case 2:return n.trys.push([2,4,,5]),[4,v(t)];case 3:return[2,n.sent()];case 4:if(r=n.sent(),!O(e,"text/plain")&&!O(e,"text/html"))throw r;return[3,5];case 5:return a=O(e,"text/plain"),o&&!a&&i("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."),u=k,[4,P(e[0])];case 6:if(!u.apply(void 0,[n.sent()]))throw new Error("write() failed");return[2]}}))}))},e.writeText=function(e){return t(this,void 0,void 0,(function(){return n(this,(function(t){if(h)return i("Using `navigator.clipboard.writeText()`."),[2,h(e)];if(!k(function(e){var t={};return t["text/plain"]=e,t}(e)))throw new Error("writeText() failed");return[2]}))}))},Object.defineProperty(e,"__esModule",{value:!0})}));
//# sourceMappingURL=clipboard-polyfill.js.map

@@ -1,2 +0,2 @@

!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 i(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 u(t.promise,e)}o(t.promise,r)}else(1===e._state?o:u)(t.promise,e._value)}))):e._deferreds.push(t)}function o(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 a(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,a(e)}catch(t){u(e,t)}}function u(e,t){e._state=2,e._value=t,a(e)}function a(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++)i(e,e._deferreds[t]);e._deferreds=null}function c(e,t){var n=!1;try{e((function(e){n||(n=!0,o(t,e))}),(function(e){n||(n=!0,u(t,e))}))}catch(e){if(n)return;n=!0,u(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 i(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 i(e,t){try{if(t&&("object"==typeof t||"function"==typeof t)){var a=t.then;if("function"==typeof a)return void a.call(t,(function(t){i(e,t)}),r)}o[e]=t,0==--u&&n(o)}catch(e){r(e)}}if(!t(e))return r(new TypeError("Promise.all accepts an array"));var o=Array.prototype.slice.call(e);if(0===o.length)return n([]);for(var u=o.length,a=0;o.length>a;a++)i(a,o[a])}))},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,i){if(!t(e))return i(new TypeError("Promise.race accepts an array"));for(var o=0,u=e.length;u>o;o++)r.resolve(e[o]).then(n,i)}))},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";
!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 i(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)}o(t.promise,r)}else(1===e._state?o:a)(t.promise,e._value)}))):e._deferreds.push(t)}function o(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++)i(e,e._deferreds[t]);e._deferreds=null}function c(e,t){var n=!1;try{e((function(e){n||(n=!0,o(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 i(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 i(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){i(e,t)}),r)}o[e]=t,0==--a&&n(o)}catch(e){r(e)}}if(!t(e))return r(new TypeError("Promise.all accepts an array"));var o=Array.prototype.slice.call(e);if(0===o.length)return n([]);for(var a=o.length,u=0;o.length>u;u++)i(u,o[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,i){if(!t(e))return i(new TypeError("Promise.race accepts an array"));for(var o=0,a=e.length;a>o;o++)r.resolve(e[o]).then(n,i)}))},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";
/*! *****************************************************************************

@@ -15,3 +15,3 @@ Copyright (c) Microsoft Corporation.

PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */function t(e,t,n,r){return new(n||(n=Promise))((function(i,o){function u(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(u,a)}c((r=r.apply(e,t||[])).next())}))}function n(e,t){var n,r,i,o,u={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(o){return function(a){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;u;)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 u.label++,{value:o[1],done:!1};case 5:u.label++,r=o[1],o=[0];continue;case 7:o=u.ops.pop(),u.trys.pop();continue;default:if(!(i=u.trys,(i=i.length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){u=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){u.label=o[1];break}if(6===o[0]&&u.label<i[1]){u.label=i[1],i=o;break}if(i&&u.label<i[2]){u.label=i[2],u.ops.push(o);break}i[2]&&u.ops.pop(),u.trys.pop();continue}o=t.call(e,u)}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,a])}}}var r=function(e){};function i(e){r(e)}var o=!0;function u(){return o}(function(){(console.warn||console.log).apply(console,arguments)}).bind("[clipboard-polyfill]");var a,c,s,l,f="undefined"==typeof navigator?void 0:navigator,d=null==f?void 0:f.clipboard,p=null===(a=null==d?void 0:d.read)||void 0===a?void 0:a.bind(d),v=null===(c=null==d?void 0:d.readText)||void 0===c?void 0:c.bind(d),h=null===(s=null==d?void 0:d.write)||void 0===s?void 0:s.bind(d),y=null===(l=null==d?void 0:d.writeText)||void 0===l?void 0:l.bind(d),w="undefined"==typeof window?void 0:window,m=null==w?void 0:w.ClipboardItem,b=w;function g(){return"undefined"==typeof ClipboardEvent&&void 0!==b.clipboardData&&void 0!==b.clipboardData.setData}function x(){return t(this,void 0,void 0,(function(){var e;return n(this,(function(t){if(""===(e=b.clipboardData.getData("Text")))throw new Error("Empty clipboard or could not read plain text from clipboard");return[2,e]}))}))}var _=function(){this.success=!1};function E(e,t,n){for(var r in i("listener called"),e.success=!0,t){var o=t[r],u=n.clipboardData;u.setData(r,o),"text/plain"===r&&u.getData(r)!==o&&(i("setting text/plain failed"),e.success=!1)}n.preventDefault()}function T(e){var t=new _,n=E.bind(this,t,e);document.addEventListener("copy",n);try{document.execCommand("copy")}finally{document.removeEventListener("copy",n)}return t.success}function j(e,t){C(e);var n=T(t);return D(),n}function C(e){var t=document.getSelection();if(t){var n=document.createRange();n.selectNodeContents(e),t.removeAllRanges(),t.addRange(n)}}function D(){var e=document.getSelection();e&&e.removeAllRanges()}function P(e){return t(this,void 0,void 0,(function(){var t;return n(this,(function(n){if(t="text/plain"in e,g()){if(!t)throw new Error("No `text/plain` value was specified.");if(r=e["text/plain"],b.clipboardData.setData("Text",r))return[2,!0];throw new Error("Copying failed, possibly because the user rejected it.")}var r;return T(e)?(i("regular execCopy worked"),[2,!0]):navigator.userAgent.indexOf("Edge")>-1?(i('UA "Edge" => assuming success'),[2,!0]):j(document.body,e)?(i("copyUsingTempSelection worked"),[2,!0]):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=j(t,e);return document.body.removeChild(t),n}(e)?(i("copyUsingTempElem worked"),[2,!0]):function(e){i("copyTextUsingDOM");var t=document.createElement("div");t.setAttribute("style","-webkit-user-select: text !important");var n=t;t.attachShadow&&(i("Using shadow DOM."),n=t.attachShadow({mode:"open"}));var r=document.createElement("span");r.innerText=e,n.appendChild(r),document.body.appendChild(t),C(r);var o=document.execCommand("copy");return D(),document.body.removeChild(t),o}(e["text/plain"])?(i("copyTextUsingDOM worked"),[2,!0]):[2,!1]}))}))}function R(){return t(this,void 0,void 0,(function(){return n(this,(function(e){if(v)return i("Using `navigator.clipboard.readText()`."),[2,v()];if(g())return i("Reading text using IE strategy."),[2,x()];throw new Error("Read is not supported in your browser.")}))}))}function S(e,t){for(var n=0,r=e;n<r.length;n++){if(-1!==r[n].types.indexOf(t))return!0}return!1}var k=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?U(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 U(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 F(e){return t(this,void 0,void 0,(function(){var t,r,i,o,u,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],u=t,a=o,[4,e.getType(o)]):[3,4];case 2:u[a]=n.sent(),n.label=3;case 3:return r++,[3,1];case 4:return c={},e.presentationStyle&&(c.presentationStyle=e.presentationStyle),[2,new m(t,c)]}}))}))}function O(e){var t={};return t["text/plain"]=U(e,"text/plain"),new k(t)}function I(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,u,a;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],u=t,a=o,[4,I(e,o)]):[3,4];case 2:u[a]=n.sent(),n.label=3;case 3:return r++,[3,1];case 4:return[2,t]}}))}))}e.ClipboardItem=k,e.read=function(){return t(this,void 0,void 0,(function(){var e;return n(this,(function(t){switch(t.label){case 0:return p?(i("Using `navigator.clipboard.read()`."),[2,p()]):(e=O,[4,R()]);case 1:return[2,[e.apply(void 0,[t.sent()])]]}}))}))},e.readText=R,e.setDebugLog=function(e){r=e},e.suppressWarnings=function(){o=!1},e.write=function(e){return t(this,void 0,void 0,(function(){var t,r,o,a;return n(this,(function(n){switch(n.label){case 0:return h&&m?(i("Using `navigator.clipboard.write()`."),[4,Promise.all(e.map(F))]):[3,5];case 1:t=n.sent(),n.label=2;case 2:return n.trys.push([2,4,,5]),[4,h(t)];case 3:return[2,n.sent()];case 4:if(r=n.sent(),!S(e,"text/plain")&&!S(e,"text/html"))throw r;return[3,5];case 5:return o=S(e,"text/plain"),u&&!o&&i("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."),a=P,[4,L(e[0])];case 6:if(!a.apply(void 0,[n.sent()]))throw new Error("write() failed");return[2]}}))}))},e.writeText=function(e){return t(this,void 0,void 0,(function(){return n(this,(function(t){if(y)return i("Using `navigator.clipboard.writeText()`."),[2,y(e)];if(!P(function(e){var t={};return t["text/plain"]=e,t}(e)))throw new Error("writeText() failed");return[2]}))}))},Object.defineProperty(e,"__esModule",{value:!0})}));
***************************************************************************** */function t(e,t,n,r){return new(n||(n=Promise))((function(i,o){function a(e){try{c(r.next(e))}catch(e){o(e)}}function u(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(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,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function u(o){return function(u){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,u])}}}var r=function(e){};function i(e){r(e)}var o=!0;(function(){(console.warn||console.log).apply(console,arguments)}).bind("[clipboard-polyfill]");var a,u,c,s,l="undefined"==typeof navigator?void 0:navigator,f=null==l?void 0:l.clipboard,d=null===(a=null==f?void 0:f.read)||void 0===a?void 0:a.bind(f),p=null===(u=null==f?void 0:f.readText)||void 0===u?void 0:u.bind(f),v=null===(c=null==f?void 0:f.write)||void 0===c?void 0:c.bind(f),h=null===(s=null==f?void 0:f.writeText)||void 0===s?void 0:s.bind(f),y="undefined"==typeof window?void 0:window,w=null==y?void 0:y.ClipboardItem,m=y;function b(){return"undefined"==typeof ClipboardEvent&&void 0!==m.clipboardData&&void 0!==m.clipboardData.setData}function g(){return t(this,void 0,void 0,(function(){var e;return n(this,(function(t){if(""===(e=m.clipboardData.getData("Text")))throw new Error("Empty clipboard or could not read plain text from clipboard");return[2,e]}))}))}var x=function(){this.success=!1};function _(e,t,n){for(var r in i("listener called"),e.success=!0,t){var o=t[r],a=n.clipboardData;a.setData(r,o),"text/plain"===r&&a.getData(r)!==o&&(i("setting text/plain failed"),e.success=!1)}n.preventDefault()}function E(e){var t=new x,n=_.bind(this,t,e);document.addEventListener("copy",n);try{document.execCommand("copy")}finally{document.removeEventListener("copy",n)}return t.success}function T(e,t){j(e);var n=E(t);return C(),n}function j(e){var t=document.getSelection();if(t){var n=document.createRange();n.selectNodeContents(e),t.removeAllRanges(),t.addRange(n)}}function C(){var e=document.getSelection();e&&e.removeAllRanges()}function D(e){return t(this,void 0,void 0,(function(){var t;return n(this,(function(n){if(t="text/plain"in e,b()){if(!t)throw new Error("No `text/plain` value was specified.");if(r=e["text/plain"],m.clipboardData.setData("Text",r))return[2,!0];throw new Error("Copying failed, possibly because the user rejected it.")}var r;return E(e)?(i("regular execCopy worked"),[2,!0]):navigator.userAgent.indexOf("Edge")>-1?(i('UA "Edge" => assuming success'),[2,!0]):T(document.body,e)?(i("copyUsingTempSelection worked"),[2,!0]):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=T(t,e);return document.body.removeChild(t),n}(e)?(i("copyUsingTempElem worked"),[2,!0]):function(e){i("copyTextUsingDOM");var t=document.createElement("div");t.setAttribute("style","-webkit-user-select: text !important");var n=t;t.attachShadow&&(i("Using shadow DOM."),n=t.attachShadow({mode:"open"}));var r=document.createElement("span");r.innerText=e,n.appendChild(r),document.body.appendChild(t),j(r);var o=document.execCommand("copy");return C(),document.body.removeChild(t),o}(e["text/plain"])?(i("copyTextUsingDOM worked"),[2,!0]):[2,!1]}))}))}function P(){return t(this,void 0,void 0,(function(){return n(this,(function(e){if(p)return i("Using `navigator.clipboard.readText()`."),[2,p()];if(b())return i("Reading text using IE strategy."),[2,g()];throw new Error("Read is not supported in your browser.")}))}))}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 S=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?k(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 k(e,t){return new Blob([t],{type:e})}function U(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 A(e){return t(this,void 0,void 0,(function(){var t,r,i,o,a,u,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,u=o,[4,e.getType(o)]):[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 w(t,c)]}}))}))}function F(e){var t={};return t["text/plain"]=k(e,"text/plain"),new S(t)}function O(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,U(t.sent())];case 2:return[2,t.sent()]}}))}))}function I(e){return t(this,void 0,void 0,(function(){var t,r,i,o,a,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,u=o,[4,O(e,o)]):[3,4];case 2:a[u]=n.sent(),n.label=3;case 3:return r++,[3,1];case 4:return[2,t]}}))}))}e.ClipboardItem=S,e.read=function(){return t(this,void 0,void 0,(function(){var e;return n(this,(function(t){switch(t.label){case 0:return d?(i("Using `navigator.clipboard.read()`."),[2,d()]):(e=F,[4,P()]);case 1:return[2,[e.apply(void 0,[t.sent()])]]}}))}))},e.readText=P,e.setDebugLog=function(e){r=e},e.suppressWarnings=function(){o=!1},e.write=function(e){return t(this,void 0,void 0,(function(){var t,r,a,u;return n(this,(function(n){switch(n.label){case 0:return v&&w?(i("Using `navigator.clipboard.write()`."),[4,Promise.all(e.map(A))]):[3,5];case 1:t=n.sent(),n.label=2;case 2:return n.trys.push([2,4,,5]),[4,v(t)];case 3:return[2,n.sent()];case 4:if(r=n.sent(),!R(e,"text/plain")&&!R(e,"text/html"))throw r;return[3,5];case 5:return a=R(e,"text/plain"),o&&!a&&i("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."),u=D,[4,I(e[0])];case 6:if(!u.apply(void 0,[n.sent()]))throw new Error("write() failed");return[2]}}))}))},e.writeText=function(e){return t(this,void 0,void 0,(function(){return n(this,(function(t){if(h)return i("Using `navigator.clipboard.writeText()`."),[2,h(e)];if(!D(function(e){var t={};return t["text/plain"]=e,t}(e)))throw new Error("writeText() failed");return[2]}))}))},Object.defineProperty(e,"__esModule",{value:!0})}));
//# sourceMappingURL=clipboard-polyfill.promise.js.map
{
"name": "clipboard-polyfill",
"version": "3.0.3",
"version": "4.0.0-rc1",
"description": "A polyfill for the asynchronous clipboard API",

@@ -13,3 +13,3 @@ "main": "dist/main/clipboard-polyfill.js",

"@types/es6-promise": "^3.3.0",
"@types/jest": "^24.9.1",
"@types/jest": "^27.4.0",
"@types/promise-polyfill": "^6.0.3",

@@ -16,0 +16,0 @@ "babel-preset-es2015-rollup": "^3.0.0",

@@ -5,2 +5,25 @@ ![Logo for clipboard-polyfill: an icon of a clipboard fading into a drafting paper grid.](clipboard-polyfill-logo.svg)

## ⚠️⚠️⚠️ TO BE DEPRECATED ⚠️⚠️⚠️
I plan to deprecate `clipboard-polyfill` in the near future, since it has finished serving its purpose of providing a simple, safe clipboard API in lieu of browser support.
If you believe you have a use case that warrants continued maintenance, please [file an issue](https://github.com/lgarron/clipboard-polyfill/issues/new)!
### A brief history
This project dates from a time when clipboard access in JS was barely becoming possible, and [ergonomic clipboard API efforts were stalling](https://lists.w3.org/Archives/Public/public-webapps/2015JulSep/0235.html). (See [this presentation](https://docs.google.com/presentation/d/1Ix2rYi67hbZoIQsd85kspkUPLi8Q-PZopy_AtfafHW0/) for a bit more context.) Fortunately, [an ergonomic API with the same functionality](https://developer.mozilla.org/en-US/docs/Web/API/Clipboard) is now available in all modern browsers since 2020:
- 2015: Browsers [start supporting](https://caniuse.com/mdn-api_document_execcommand_copy) the [defunct](https://w3c.github.io/editing/docs/execCommand/) `document.execCommand("copy")` call (with [many, many issues](./experiment/Conclusions.md)).
- 2015: Started this project as `clipboard.js` (half a year before @zenorocha picked [the same name](https://github.com/zenorocha/clipboard.js) 😛).
- 2016: Renewed discussions about an async clipboard API (e.g. [proposal doc](https://docs.google.com/document/d/1QI5rKJSiYeD9ekP2NyCYJuOnivduC9-tqEOn-GsCGS4/edit#), [`crbug.com/593475`](https://bugs.chromium.org/p/chromium/issues/detail?id=593475)).
- 2017: Renamed this project to `clipboard-polyfill` to reflect a `v2` API overhaul aligned with the draft spec.
- 2018: Browsers [start supporting](https://caniuse.com/mdn-api_clipboard_writetext) `navigator.clipboard.writeText()`.
- 2020: Browsers [start supporting](https://caniuse.com/mdn-api_clipboard_write) `navigator.clipboard.write()` (including `text/html` support).
Thanks to Gary Kacmarcik, Hallvord Steen, and others for helping to bring the [async clipboard API](https://w3c.github.io/clipboard-apis/) to life!
---
## Summary
Makes copying on the web as easy as:

@@ -10,5 +33,5 @@

This library is a polyfill for the modern `Promise`-based [asynchronous clipboard API](https://www.w3.org/TR/clipboard-apis/#async-clipboard-api).
This library is a [ponyfill](https://github.com/sindresorhus/ponyfill)/polyfill for the modern `Promise`-based [asynchronous clipboard API](https://www.w3.org/TR/clipboard-apis/#async-clipboard-api).
Note: As of late June 2020, you can use `navigator.clipboard.writeText("hello world);` in the stable versions of all major browsers (see below for compatibility). This library will only be useful to you if you 1) need to copy `text/html`, or 2) need to target older browsers.
Note: As of 2021, you can use `navigator.clipboard` [in the stable versions of all major browsers](https://caniuse.com/mdn-api_clipboard_writetext). This library will only be useful to you if you need to target older browsers (see below for compatibility).

@@ -32,6 +55,6 @@ ## Usage

clipboard.writeText("This text is plain.").then(
function () {
() => {
console.log("success!");
},
function () {
() => {
console.log("error!");

@@ -142,3 +165,3 @@ }

If you need to grab a version that "just works", 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:
If you need to grab a version that "just works", download [`clipboard-polyfill.promise.js`](https://unpkg.com/browse/clipboard-polyfill/dist/promise/clipboard-polyfill.promise.js) and include it using a `<script>` tag:

@@ -165,3 +188,3 @@ ```html

- ☑️: Browser has native async clipboard support.
- ✅: `clipboard-polyfill` provides support.
- ✅: `clipboard-polyfill` adds support.
- ❌: Support is not possible.

@@ -175,3 +198,4 @@ - **Bold browser names** indicate the latest functionality changes for stable versions of modern browsers.

| **Safari 13.1** | ☑️ | ☑️ | ☑️ (`image/uri-list`, `image/png`) |
| **Chrome 76**ᵃ / **Edge 79** | ☑️ | ✅ | ☑️ (`image/png`) |
| **Chrome 86**ᵃ / **Edge 86** | ☑️ | ☑️ | ☑️ (`image/png`) |
| Chrome 76ᵃ / Edge 79 | ☑️ | ✅ | ☑️ (`image/png`) |
| Chrome 66ᵃ / **Firefox 63** | ☑️ | ✅ | ❌ |

@@ -203,4 +227,4 @@ | Safari 10 / Chrome 42ᵃ / Edgeᵈ / Firefox 41 | ✅ | ✅ᵇ | ❌ |

If you only need to copy text, try [this gist](https://gist.github.com/lgarron/d1dee380f4ed9d825ca7) for a simpler solution.
If you only need to copy text in modern browsers, consider using `navigator.clipboard.writeText()` directly: <https://caniuse.com/mdn-api_clipboard_writetext>
Alternatively, if you wait until iOS 14 / macOS 11, `navigator.clipboard.writeText()` will be supported in the stable versions of all major modern browsers.
If you need copy text in older browsers as well, you could also try [this gist](https://gist.github.com/lgarron/d1dee380f4ed9d825ca7) for a simple hacky solution.

@@ -34,3 +34,3 @@ import { hasItemWithType } from "../ClipboardItem/check";

const hasTextPlain = hasItemWithType(data, TEXT_PLAIN);
if (shouldShowWarnings && !hasTextPlain) {
if (shouldShowWarnings() && !hasTextPlain) {
debugLog(

@@ -37,0 +37,0 @@ "clipboard.write() was called without a " +

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

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc