diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2022-01-26 18:05:10 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2022-01-26 18:05:10 +0000 |
commit | 34a0b66bc2d48223748ed1cf5bc1b305c396bd74 (patch) | |
tree | fbd36be86cc6bc4288fe627f2b5beada569848bb /web/gui/dashboard/static/js/8.f438a1b5.chunk.js | |
parent | Adding upstream version 1.32.1. (diff) | |
download | netdata-34a0b66bc2d48223748ed1cf5bc1b305c396bd74.tar.xz netdata-34a0b66bc2d48223748ed1cf5bc1b305c396bd74.zip |
Adding upstream version 1.33.0.upstream/1.33.0
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | web/gui/dashboard/static/js/8.f438a1b5.chunk.js (renamed from web/gui/dashboard/static/js/8.fb328a3a.chunk.js) | 4 | ||||
-rw-r--r-- | web/gui/dashboard/static/js/8.f438a1b5.chunk.js.map (renamed from web/gui/dashboard/static/js/8.fb328a3a.chunk.js.map) | 2 |
2 files changed, 3 insertions, 3 deletions
diff --git a/web/gui/dashboard/static/js/8.fb328a3a.chunk.js b/web/gui/dashboard/static/js/8.f438a1b5.chunk.js index 605fb86e2..a8847e3f5 100644 --- a/web/gui/dashboard/static/js/8.fb328a3a.chunk.js +++ b/web/gui/dashboard/static/js/8.f438a1b5.chunk.js @@ -1,2 +1,2 @@ -(this["webpackJsonp@netdata/dashboard"]=this["webpackJsonp@netdata/dashboard"]||[]).push([[8],{509:function(t,n,e){"use strict";function r(t,n,e,r){return new(e||(e=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 e((function(n){n(t.value)})).then(a,u)}c((r=r.apply(t,n||[])).next())}))}function o(t,n){var e,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(e)throw new TypeError("Generator is already executing.");for(;a;)try{if(e=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=n.call(t,a)}catch(t){i=[6,t],r=0}finally{e=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,u])}}}e.r(n),e.d(n,"DT",(function(){return c})),e.d(n,"read",(function(){return w})),e.d(n,"readText",(function(){return m})),e.d(n,"setDebugLog",(function(){return p})),e.d(n,"suppressWarnings",(function(){return h})),e.d(n,"write",(function(){return v})),e.d(n,"writeText",(function(){return b}));var i=["text/plain","text/html"],a=function(){(console.warn||console.log).call(arguments)}.bind(console,"[clipboard-polyfill]"),u=!0,c=function(){function t(){this.m={}}return t.prototype.setData=function(t,n){u&&-1===i.indexOf(t)&&a("Unknown data type: "+t,"Call clipboard.suppressWarnings() to suppress this warning."),this.m[t]=n},t.prototype.getData=function(t){return this.m[t]},t.prototype.forEach=function(t){for(var n in this.m)t(this.m[n],n)},t}(),s=function(t){},d=!0,l=function(){(console.warn||console.log).apply(console,arguments)}.bind("[clipboard-polyfill]"),f="text/plain";function p(t){s=t}function h(){d=!1,u=!1}function v(t){return r(this,void 0,void 0,(function(){var n;return o(this,(function(e){if(d&&!t.getData(f)&&l("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."),S()){if(function(t){var n=t.getData(f);if(void 0!==n)return window.clipboardData.setData("Text",n);throw new Error("No `text/plain` value was specified.")}(t))return[2];throw new Error("Copying failed, possibly because the user rejected it.")}if(T(t))return s("regular execCopy worked"),[2];if(navigator.userAgent.indexOf("Edge")>-1)return s('UA "Edge" => assuming success'),[2];if(E(document.body,t))return s("copyUsingTempSelection worked"),[2];if(function(t){var n=document.createElement("div");n.setAttribute("style","-webkit-user-select: text !important"),n.textContent="temporary element",document.body.appendChild(n);var e=E(n,t);return document.body.removeChild(n),e}(t))return s("copyUsingTempElem worked"),[2];if(void 0!==(n=t.getData(f))&&function(t){s("copyTextUsingDOM");var n=document.createElement("div");n.setAttribute("style","-webkit-user-select: text !important");var e=n;n.attachShadow&&(s("Using shadow DOM."),e=n.attachShadow({mode:"open"}));var r=document.createElement("span");r.innerText=t,e.appendChild(r),document.body.appendChild(n),C(r);var o=document.execCommand("copy");return k(),document.body.removeChild(n),o}(n))return s("copyTextUsingDOM worked"),[2];throw new Error("Copy command failed.")}))}))}function b(t){return r(this,void 0,void 0,(function(){return o(this,(function(n){return navigator.clipboard&&navigator.clipboard.writeText?(s("Using `navigator.clipboard.writeText()`."),[2,navigator.clipboard.writeText(t)]):[2,v(U(t))]}))}))}function w(){return r(this,void 0,void 0,(function(){var t;return o(this,(function(n){switch(n.label){case 0:return t=U,[4,m()];case 1:return[2,t.apply(void 0,[n.sent()])]}}))}))}function m(){return r(this,void 0,void 0,(function(){return o(this,(function(t){if(navigator.clipboard&&navigator.clipboard.readText)return s("Using `navigator.clipboard.readText()`."),[2,navigator.clipboard.readText()];if(S())return s("Reading text using IE strategy."),[2,A()];throw new Error("Read is not supported in your browser.")}))}))}var g=!1;function y(){g||(d&&l('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.'),g=!0)}var x={DT:c,setDebugLog:function(t){return y(),p(t)},suppressWarnings:function(){return y(),h()},write:function(t){return r(this,void 0,void 0,(function(){return o(this,(function(n){return y(),[2,v(t)]}))}))},writeText:function(t){return r(this,void 0,void 0,(function(){return o(this,(function(n){return y(),[2,b(t)]}))}))},read:function(){return r(this,void 0,void 0,(function(){return o(this,(function(t){return y(),[2,w()]}))}))},readText:function(){return r(this,void 0,void 0,(function(){return o(this,(function(t){return y(),[2,m()]}))}))}},D=function(){this.success=!1};function T(t){var n=new D,e=function(t,n,e){s("listener called"),t.success=!0,n.forEach((function(n,r){var o=e.clipboardData;o.setData(r,n),r===f&&o.getData(r)!==n&&(s("setting text/plain failed"),t.success=!1)})),e.preventDefault()}.bind(this,n,t);document.addEventListener("copy",e);try{document.execCommand("copy")}finally{document.removeEventListener("copy",e)}return n.success}function E(t,n){C(t);var e=T(n);return k(),e}function C(t){var n=document.getSelection();if(n){var e=document.createRange();e.selectNodeContents(t),n.removeAllRanges(),n.addRange(e)}}function k(){var t=document.getSelection();t&&t.removeAllRanges()}function U(t){var n=new c;return n.setData(f,t),n}function S(){return"undefined"==typeof ClipboardEvent&&void 0!==window.clipboardData&&void 0!==window.clipboardData.setData}function A(){return r(this,void 0,void 0,(function(){var t;return o(this,(function(n){if(""===(t=window.clipboardData.getData("Text")))throw new Error("Empty clipboard or could not read plain text from clipboard");return[2,t]}))}))}n.default=x}}]); -//# sourceMappingURL=8.fb328a3a.chunk.js.map
\ No newline at end of file +(this["webpackJsonp@netdata/dashboard"]=this["webpackJsonp@netdata/dashboard"]||[]).push([[8],{511:function(t,n,e){"use strict";function r(t,n,e,r){return new(e||(e=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 e((function(n){n(t.value)})).then(a,u)}c((r=r.apply(t,n||[])).next())}))}function o(t,n){var e,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(e)throw new TypeError("Generator is already executing.");for(;a;)try{if(e=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=n.call(t,a)}catch(t){i=[6,t],r=0}finally{e=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,u])}}}e.r(n),e.d(n,"DT",(function(){return c})),e.d(n,"read",(function(){return w})),e.d(n,"readText",(function(){return m})),e.d(n,"setDebugLog",(function(){return p})),e.d(n,"suppressWarnings",(function(){return h})),e.d(n,"write",(function(){return v})),e.d(n,"writeText",(function(){return b}));var i=["text/plain","text/html"],a=function(){(console.warn||console.log).call(arguments)}.bind(console,"[clipboard-polyfill]"),u=!0,c=function(){function t(){this.m={}}return t.prototype.setData=function(t,n){u&&-1===i.indexOf(t)&&a("Unknown data type: "+t,"Call clipboard.suppressWarnings() to suppress this warning."),this.m[t]=n},t.prototype.getData=function(t){return this.m[t]},t.prototype.forEach=function(t){for(var n in this.m)t(this.m[n],n)},t}(),s=function(t){},d=!0,l=function(){(console.warn||console.log).apply(console,arguments)}.bind("[clipboard-polyfill]"),f="text/plain";function p(t){s=t}function h(){d=!1,u=!1}function v(t){return r(this,void 0,void 0,(function(){var n;return o(this,(function(e){if(d&&!t.getData(f)&&l("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."),S()){if(function(t){var n=t.getData(f);if(void 0!==n)return window.clipboardData.setData("Text",n);throw new Error("No `text/plain` value was specified.")}(t))return[2];throw new Error("Copying failed, possibly because the user rejected it.")}if(T(t))return s("regular execCopy worked"),[2];if(navigator.userAgent.indexOf("Edge")>-1)return s('UA "Edge" => assuming success'),[2];if(E(document.body,t))return s("copyUsingTempSelection worked"),[2];if(function(t){var n=document.createElement("div");n.setAttribute("style","-webkit-user-select: text !important"),n.textContent="temporary element",document.body.appendChild(n);var e=E(n,t);return document.body.removeChild(n),e}(t))return s("copyUsingTempElem worked"),[2];if(void 0!==(n=t.getData(f))&&function(t){s("copyTextUsingDOM");var n=document.createElement("div");n.setAttribute("style","-webkit-user-select: text !important");var e=n;n.attachShadow&&(s("Using shadow DOM."),e=n.attachShadow({mode:"open"}));var r=document.createElement("span");r.innerText=t,e.appendChild(r),document.body.appendChild(n),C(r);var o=document.execCommand("copy");return k(),document.body.removeChild(n),o}(n))return s("copyTextUsingDOM worked"),[2];throw new Error("Copy command failed.")}))}))}function b(t){return r(this,void 0,void 0,(function(){return o(this,(function(n){return navigator.clipboard&&navigator.clipboard.writeText?(s("Using `navigator.clipboard.writeText()`."),[2,navigator.clipboard.writeText(t)]):[2,v(U(t))]}))}))}function w(){return r(this,void 0,void 0,(function(){var t;return o(this,(function(n){switch(n.label){case 0:return t=U,[4,m()];case 1:return[2,t.apply(void 0,[n.sent()])]}}))}))}function m(){return r(this,void 0,void 0,(function(){return o(this,(function(t){if(navigator.clipboard&&navigator.clipboard.readText)return s("Using `navigator.clipboard.readText()`."),[2,navigator.clipboard.readText()];if(S())return s("Reading text using IE strategy."),[2,A()];throw new Error("Read is not supported in your browser.")}))}))}var g=!1;function y(){g||(d&&l('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.'),g=!0)}var x={DT:c,setDebugLog:function(t){return y(),p(t)},suppressWarnings:function(){return y(),h()},write:function(t){return r(this,void 0,void 0,(function(){return o(this,(function(n){return y(),[2,v(t)]}))}))},writeText:function(t){return r(this,void 0,void 0,(function(){return o(this,(function(n){return y(),[2,b(t)]}))}))},read:function(){return r(this,void 0,void 0,(function(){return o(this,(function(t){return y(),[2,w()]}))}))},readText:function(){return r(this,void 0,void 0,(function(){return o(this,(function(t){return y(),[2,m()]}))}))}},D=function(){this.success=!1};function T(t){var n=new D,e=function(t,n,e){s("listener called"),t.success=!0,n.forEach((function(n,r){var o=e.clipboardData;o.setData(r,n),r===f&&o.getData(r)!==n&&(s("setting text/plain failed"),t.success=!1)})),e.preventDefault()}.bind(this,n,t);document.addEventListener("copy",e);try{document.execCommand("copy")}finally{document.removeEventListener("copy",e)}return n.success}function E(t,n){C(t);var e=T(n);return k(),e}function C(t){var n=document.getSelection();if(n){var e=document.createRange();e.selectNodeContents(t),n.removeAllRanges(),n.addRange(e)}}function k(){var t=document.getSelection();t&&t.removeAllRanges()}function U(t){var n=new c;return n.setData(f,t),n}function S(){return"undefined"==typeof ClipboardEvent&&void 0!==window.clipboardData&&void 0!==window.clipboardData.setData}function A(){return r(this,void 0,void 0,(function(){var t;return o(this,(function(n){if(""===(t=window.clipboardData.getData("Text")))throw new Error("Empty clipboard or could not read plain text from clipboard");return[2,t]}))}))}n.default=x}}]); +//# sourceMappingURL=8.f438a1b5.chunk.js.map
\ No newline at end of file diff --git a/web/gui/dashboard/static/js/8.fb328a3a.chunk.js.map b/web/gui/dashboard/static/js/8.f438a1b5.chunk.js.map index f8d45938f..436f02ad2 100644 --- a/web/gui/dashboard/static/js/8.fb328a3a.chunk.js.map +++ b/web/gui/dashboard/static/js/8.f438a1b5.chunk.js.map @@ -1 +1 @@ -{"version":3,"sources":["../../DT.ts","../../clipboard-polyfill.ts"],"names":["dataTypes","warn","console","log","call","arguments","bind","showWarnings","this","DT","type","value","indexOf","m","f","k","debugLog","s","apply","TEXT_PLAIN","setDebugLog","suppressWarnings","write","data","getData","seemToBeInIE","text","window","clipboardData","setData","Error","execCopy","navigator","userAgent","copyUsingTempSelection","document","body","tempElem","createElement","setAttribute","textContent","appendChild","success","removeChild","str","spanParent","attachShadow","mode","span","innerText","selectionSet","result","execCommand","selectionClear","writeText","clipboard","DTFromText","read","_a","readText","readIE","useStarShown","useStar","ClipboardPolyfillDefault","tracker","FallbackTracker","listener","e","forEach","key","preventDefault","addEventListener","removeEventListener","elem","sel","getSelection","range","createRange","selectNodeContents","removeAllRanges","addRange","dt","ClipboardEvent"],"mappings":"mtDAAA,IAAMA,EAAY,CAChB,aACA,aAQIC,EAJN,YAEGC,QAAQD,MAAQC,QAAQC,KAAKC,KAAKC,YAEdC,KAAKJ,QAAS,wBACjCK,KAKJ,0BACUC,OAA6B,GAsBvC,OApBSC,oBAAP,SAAeC,EAAcC,GACvBJ,IAA6C,IAA7BP,EAAUY,QAAQF,IACpCT,EAAK,sBAAwBS,EAAM,+DAIrCF,KAAKK,EAAEH,GAAQC,GAGVF,oBAAP,SAAeC,GACb,OAAOF,KAAKK,EAAEH,IAITD,oBAAP,SAAeK,GAEb,IAAK,IAAMC,KAAKP,KAAKK,EACnBC,EAAEN,KAAKK,EAAEE,GAAIA,MApBnB,GCXIC,EAAgC,SAACC,KACjCV,KAQEN,EAJN,YAEGC,QAAQD,MAAQC,QAAQC,KAAKe,MAAMhB,QAASG,YAExBC,KAAK,wBAEtBa,EAAa,sBAIHC,EAAYN,GAC1BE,EAAWF,EAGb,SAAgBO,IACdd,KDZAA,KAAe,SCgBKe,EAAMC,4EAS1B,GARIhB,IAAiBgB,EAAKC,QAAQL,IAChClB,EAAK,wLAOHwB,IAAgB,CAClB,GAgPJ,SAAiBF,GAGf,IAAMG,EAAOH,EAAKC,QAAQL,GAC1B,YAAIO,EACF,O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IAAMqB,EAAMvC,SAASwC,eACjBD,GACFA,EAAIK,kBAMR,SAASvB,EAAWvC,GAClB,IAAMgE,EAAK,IAAIxE,EAEf,OADAwE,EAAGpD,QAAQV,EAAYF,GAChBgE,EAaT,SAASxD,IACP,MAAiC,oBAAnByD,yBACCvD,OAAoBC,wBACpBD,OAAoBC,cAAcC,QAenD,SAAe+B,6EAEb,GAAa,MADPlC,EAAQC,OAAoBC,cAAcJ,QAAQ,SAEtD,MAAM,IAAIM,MAAM,+DAElB,SAAOJ","file":"static/js/8.fb328a3a.chunk.js","sourcesContent":["const dataTypes = [\n \"text/plain\",\n \"text/html\",\n];\n\n// TODO: Dedup with main file?\nfunction warnOrLog() {\n // tslint:disable-next-line: no-console\n (console.warn || console.log).call(arguments);\n} // IE9 workaround (can't bind console functions).\nconst warn = warnOrLog.bind(console, \"[clipboard-polyfill]\");\nlet showWarnings = true;\nexport function suppressDTWarnings() {\n showWarnings = false;\n}\n\nexport class DT {\n private m: {[key: string]: string} = {};\n\n public setData(type: string, value: string): void {\n if (showWarnings && dataTypes.indexOf(type) === -1) {\n warn(\"Unknown data type: \" + type, \"Call clipboard.suppressWarnings() \" +\n \"to suppress this warning.\");\n }\n\n this.m[type] = value;\n }\n\n public getData(type: string): string | undefined {\n return this.m[type];\n }\n\n // TODO: Provide an iterator consistent with DataTransfer.\n public forEach(f: (value: string, key: string) => void): void {\n // tslint:disable-next-line: forin\n for (const k in this.m) {\n f(this.m[k], k);\n }\n }\n}\n","import {DT, suppressDTWarnings} from \"./DT\";\n\n// Debug log strings should be short, since they are compiled into the production build.\n// TODO: Compile debug logging code out of production builds?\n// tslint:disable-next-line: no-empty\nlet debugLog: (s: string) => void = (s: string) => {};\nlet showWarnings = true;\n// Workaround for:\n// - IE9 (can't bind console functions directly), and\n// - Edge Issue #14495220 (referencing `console` without F12 Developer Tools can cause an exception)\nfunction warnOrLog() {\n // tslint:disable-next-line: no-console\n (console.warn || console.log).apply(console, arguments);\n}\nconst warn = warnOrLog.bind(\"[clipboard-polyfill]\");\n\nconst TEXT_PLAIN = \"text/plain\";\n\nexport {DT};\n\nexport function setDebugLog(f: (s: string) => void): void {\n debugLog = f;\n}\n\nexport function suppressWarnings() {\n showWarnings = false;\n suppressDTWarnings();\n}\n\nexport async function write(data: DT): Promise<void> {\n if (showWarnings && !data.getData(TEXT_PLAIN)) {\n warn(\"clipboard.write() was called without a \" +\n \"`text/plain` data type. On some platforms, this may result in an \" +\n \"empty clipboard. Call clipboard.suppressWarnings() \" +\n \"to suppress this warning.\");\n }\n\n // Internet Explorer\n if (seemToBeInIE()) {\n if (writeIE(data)) {\n return;\n } else {\n throw new Error(\"Copying failed, possibly because the user rejected it.\");\n }\n }\n\n if (execCopy(data)) {\n debugLog(\"regular execCopy worked\");\n return;\n }\n\n // Success detection on Edge is not possible, due to bugs in all 4\n // detection mechanisms we could try to use. Assume success.\n if (navigator.userAgent.indexOf(\"Edge\") > -1) {\n debugLog(\"UA \\\"Edge\\\" => assuming success\");\n return;\n }\n\n // Fallback 1 for desktop Safari.\n if (copyUsingTempSelection(document.body, data)) {\n debugLog(\"copyUsingTempSelection worked\");\n return;\n }\n\n // Fallback 2 for desktop Safari.\n if (copyUsingTempElem(data)) {\n debugLog(\"copyUsingTempElem worked\");\n return;\n }\n\n // Fallback for iOS Safari.\n const text = data.getData(TEXT_PLAIN);\n if (text !== undefined && copyTextUsingDOM(text)) {\n debugLog(\"copyTextUsingDOM worked\");\n return;\n }\n\n throw new Error(\"Copy command failed.\");\n}\n\nexport async function writeText(s: string): Promise<void> {\n if (navigator.clipboard && navigator.clipboard.writeText) {\n debugLog(\"Using `navigator.clipboard.writeText()`.\");\n return navigator.clipboard.writeText(s);\n }\n return write(DTFromText(s));\n}\n\nexport async function read(): Promise<DT> {\n return DTFromText(await readText());\n}\n\nexport async function readText(): Promise<string> {\n if (navigator.clipboard && navigator.clipboard.readText) {\n debugLog(\"Using `navigator.clipboard.readText()`.\");\n return navigator.clipboard.readText();\n }\n if (seemToBeInIE()) {\n debugLog(\"Reading text using IE strategy.\");\n return readIE();\n }\n throw new Error(\"Read is not supported in your browser.\");\n}\n\nlet useStarShown = false;\nfunction useStar(): void {\n if (useStarShown) {\n return;\n }\n if (showWarnings) {\n warn(\"The deprecated default object of `clipboard-polyfill` was called. Please switch to `import * as clipboard from \\\"clipboard-polyfill\\\"` and see https://github.com/lgarron/clipboard-polyfill/issues/101 for more info.\");\n }\n useStarShown = true;\n}\n\nconst ClipboardPolyfillDefault = {\n DT,\n setDebugLog(f: (s: string) => void): void {\n useStar();\n return setDebugLog(f);\n },\n suppressWarnings() {\n useStar();\n return suppressWarnings();\n },\n async write(data: DT): Promise<void> {\n useStar();\n return write(data);\n },\n async writeText(s: string): Promise<void> {\n useStar();\n return writeText(s);\n },\n async read(): Promise<DT> {\n useStar();\n return read();\n },\n async readText(): Promise<string> {\n useStar();\n return readText();\n },\n};\n\nexport default ClipboardPolyfillDefault;\n\n/******** Implementations ********/\n\nclass FallbackTracker {\n public success: boolean = false;\n}\n\nfunction copyListener(tracker: FallbackTracker, data: DT, e: ClipboardEvent): void {\n debugLog(\"listener called\");\n tracker.success = true;\n data.forEach((value: string, key: string) => {\n const clipboardData = e.clipboardData!;\n clipboardData.setData(key, value);\n if (key === TEXT_PLAIN && clipboardData.getData(key) !== value) {\n debugLog(\"setting text/plain failed\");\n tracker.success = false;\n }\n });\n e.preventDefault();\n}\n\nfunction execCopy(data: DT): boolean {\n const tracker = new FallbackTracker();\n const listener = copyListener.bind(this, tracker, data);\n\n document.addEventListener(\"copy\", listener);\n try {\n // We ignore the return value, since FallbackTracker tells us whether the\n // listener was called. It seems that checking the return value here gives\n // us no extra information in any browser.\n document.execCommand(\"copy\");\n } finally {\n document.removeEventListener(\"copy\", listener);\n }\n return tracker.success;\n}\n\n// Temporarily select a DOM element, so that `execCommand()` is not rejected.\nfunction copyUsingTempSelection(e: HTMLElement, data: DT): boolean {\n selectionSet(e);\n const success = execCopy(data);\n selectionClear();\n return success;\n}\n\n// Create a temporary DOM element to select, so that `execCommand()` is not\n// rejected.\nfunction copyUsingTempElem(data: DT): boolean {\n const tempElem = document.createElement(\"div\");\n // Setting an individual property does not support `!important`, so we set the\n // whole style instead of just the `-webkit-user-select` property.\n tempElem.setAttribute(\"style\", \"-webkit-user-select: text !important\");\n // Place some text in the elem so that Safari has something to select.\n tempElem.textContent = \"temporary element\";\n document.body.appendChild(tempElem);\n\n const success = copyUsingTempSelection(tempElem, data);\n\n document.body.removeChild(tempElem);\n return success;\n}\n\n// Uses shadow DOM.\nfunction copyTextUsingDOM(str: string): boolean {\n debugLog(\"copyTextUsingDOM\");\n\n const tempElem = document.createElement(\"div\");\n // Setting an individual property does not support `!important`, so we set the\n // whole style instead of just the `-webkit-user-select` property.\n tempElem.setAttribute(\"style\", \"-webkit-user-select: text !important\");\n // Use shadow DOM if available.\n let spanParent: Node = tempElem;\n if (tempElem.attachShadow) {\n debugLog(\"Using shadow DOM.\");\n spanParent = tempElem.attachShadow({mode: \"open\"});\n }\n\n const span = document.createElement(\"span\");\n span.innerText = str;\n\n spanParent.appendChild(span);\n document.body.appendChild(tempElem);\n selectionSet(span);\n\n const result = document.execCommand(\"copy\");\n\n selectionClear();\n document.body.removeChild(tempElem);\n\n return result;\n}\n\n/******** Selection ********/\n\nfunction selectionSet(elem: Element): void {\n const sel = document.getSelection();\n if (sel) {\n const range = document.createRange();\n range.selectNodeContents(elem);\n sel.removeAllRanges();\n sel.addRange(range);\n }\n}\n\nfunction selectionClear(): void {\n const sel = document.getSelection();\n if (sel) {\n sel.removeAllRanges();\n }\n}\n\n/******** Convenience ********/\n\nfunction DTFromText(s: string): DT {\n const dt = new DT();\n dt.setData(TEXT_PLAIN, s);\n return dt;\n}\n\n/******** Internet Explorer ********/\n\ninterface IEWindow extends Window {\n clipboardData: {\n setData: (key: string, value: string) => boolean;\n // Always results in a string: https://msdn.microsoft.com/en-us/library/ms536436(v=vs.85).aspx\n getData: (key: string) => string;\n };\n}\n\nfunction seemToBeInIE(): boolean {\n return typeof ClipboardEvent === \"undefined\" &&\n typeof (window as IEWindow).clipboardData !== \"undefined\" &&\n typeof (window as IEWindow).clipboardData.setData !== \"undefined\";\n}\n\nfunction writeIE(data: DT): boolean {\n // IE supports text or URL, but not HTML: https://msdn.microsoft.com/en-us/library/ms536744(v=vs.85).aspx\n // TODO: Write URLs to `text/uri-list`? https://developer.mozilla.org/en-US/docs/Web/API/HTML_Drag_and_Drop_API/Recommended_drag_types\n const text = data.getData(TEXT_PLAIN);\n if (text !== undefined) {\n return (window as IEWindow).clipboardData.setData(\"Text\", text);\n }\n\n throw new Error((\"No `text/plain` value was specified.\"));\n}\n\n// Returns \"\" if the read failed, e.g. because the user rejected the permission.\nasync function readIE(): Promise<string> {\n const text = (window as IEWindow).clipboardData.getData(\"Text\");\n if (text === \"\") {\n throw new Error(\"Empty clipboard or could not read plain text from clipboard\");\n }\n return text;\n}\n"],"sourceRoot":""}
\ No newline at end of file +{"version":3,"sources":["../../DT.ts","../../clipboard-polyfill.ts"],"names":["dataTypes","warn","console","log","call","arguments","bind","showWarnings","this","DT","type","value","indexOf","m","f","k","debugLog","s","apply","TEXT_PLAIN","setDebugLog","suppressWarnings","write","data","getData","seemToBeInIE","text","window","clipboardData","setData","Error","execCopy","navigator","userAgent","copyUsingTempSelection","document","body","tempElem","createElement","setAttribute","textContent","appendChild","success","removeChild","str","spanParent","attachShadow","mode","span","innerText","selectionSet","result","execCommand","selectionClear","writeText","clipboard","DTFromText","read","_a","readText","readIE","useStarShown","useStar","ClipboardPolyfillDefault","tracker","FallbackTracker","listener","e","forEach","key","preventDefault","addEventListener","removeEventListener","elem","sel","getSelection","range","createRange","selectNodeContents","removeAllRanges","addRange","dt","ClipboardEvent"],"mappings":"mtDAAA,IAAMA,EAAY,CAChB,aACA,aAQIC,EAJN,YAEGC,QAAQD,MAAQC,QAAQC,KAAKC,KAAKC,YAEdC,KAAKJ,QAAS,wBACjCK,KAKJ,0BACUC,OAA6B,GAsBvC,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RnB,EAAK6C,SAAQ,SAACzD,EAAe0D,GAC3B,IAAMzC,EAAgBuC,EAAEvC,cACxBA,EAAcC,QAAQwC,EAAK1D,GACvB0D,IAAQlD,GAAcS,EAAcJ,QAAQ6C,KAAS1D,IACvDK,EAAS,6BACTgD,EAAQtB,eAGZyB,EAAEG,kBAK4BhE,KAAKE,KAAMwD,EAASzC,GAElDY,SAASoC,iBAAiB,OAAQL,GAClC,IAIE/B,SAASiB,YAAY,QAJvB,QAMEjB,SAASqC,oBAAoB,OAAQN,GAEvC,OAAOF,EAAQtB,QAIjB,SAASR,EAAuBiC,EAAgB5C,GAC9C2B,EAAaiB,GACb,IAAMzB,EAAUX,EAASR,GAEzB,OADA8B,IACOX,EAoDT,SAASQ,EAAauB,GACpB,IAAMC,EAAMvC,SAASwC,eACrB,GAAID,EAAK,CACP,IAAME,EAAQzC,SAAS0C,cACvBD,EAAME,mBAAmBL,GACzBC,EAAIK,kBACJL,EAAIM,SAASJ,IAIjB,SAASvB,IACP,IAAMqB,EAAMvC,SAASwC,eACjBD,GACFA,EAAIK,kBAMR,SAASvB,EAAWvC,GAClB,IAAMgE,EAAK,IAAIxE,EAEf,OADAwE,EAAGpD,QAAQV,EAAYF,GAChBgE,EAaT,SAASxD,IACP,MAAiC,oBAAnByD,yBACCvD,OAAoBC,wBACpBD,OAAoBC,cAAcC,QAenD,SAAe+B,6EAEb,GAAa,MADPlC,EAAQC,OAAoBC,cAAcJ,QAAQ,SAEtD,MAAM,IAAIM,MAAM,+DAElB,SAAOJ","file":"static/js/8.f438a1b5.chunk.js","sourcesContent":["const dataTypes = [\n \"text/plain\",\n \"text/html\",\n];\n\n// TODO: Dedup with main file?\nfunction warnOrLog() {\n // tslint:disable-next-line: no-console\n (console.warn || console.log).call(arguments);\n} // IE9 workaround (can't bind console functions).\nconst warn = warnOrLog.bind(console, \"[clipboard-polyfill]\");\nlet showWarnings = true;\nexport function suppressDTWarnings() {\n showWarnings = false;\n}\n\nexport class DT {\n private m: {[key: string]: string} = {};\n\n public setData(type: string, value: string): void {\n if (showWarnings && dataTypes.indexOf(type) === -1) {\n warn(\"Unknown data type: \" + type, \"Call clipboard.suppressWarnings() \" +\n \"to suppress this warning.\");\n }\n\n this.m[type] = value;\n }\n\n public getData(type: string): string | undefined {\n return this.m[type];\n }\n\n // TODO: Provide an iterator consistent with DataTransfer.\n public forEach(f: (value: string, key: string) => void): void {\n // tslint:disable-next-line: forin\n for (const k in this.m) {\n f(this.m[k], k);\n }\n }\n}\n","import {DT, suppressDTWarnings} from \"./DT\";\n\n// Debug log strings should be short, since they are compiled into the production build.\n// TODO: Compile debug logging code out of production builds?\n// tslint:disable-next-line: no-empty\nlet debugLog: (s: string) => void = (s: string) => {};\nlet showWarnings = true;\n// Workaround for:\n// - IE9 (can't bind console functions directly), and\n// - Edge Issue #14495220 (referencing `console` without F12 Developer Tools can cause an exception)\nfunction warnOrLog() {\n // tslint:disable-next-line: no-console\n (console.warn || console.log).apply(console, arguments);\n}\nconst warn = warnOrLog.bind(\"[clipboard-polyfill]\");\n\nconst TEXT_PLAIN = \"text/plain\";\n\nexport {DT};\n\nexport function setDebugLog(f: (s: string) => void): void {\n debugLog = f;\n}\n\nexport function suppressWarnings() {\n showWarnings = false;\n suppressDTWarnings();\n}\n\nexport async function write(data: DT): Promise<void> {\n if (showWarnings && !data.getData(TEXT_PLAIN)) {\n warn(\"clipboard.write() was called without a \" +\n \"`text/plain` data type. On some platforms, this may result in an \" +\n \"empty clipboard. Call clipboard.suppressWarnings() \" +\n \"to suppress this warning.\");\n }\n\n // Internet Explorer\n if (seemToBeInIE()) {\n if (writeIE(data)) {\n return;\n } else {\n throw new Error(\"Copying failed, possibly because the user rejected it.\");\n }\n }\n\n if (execCopy(data)) {\n debugLog(\"regular execCopy worked\");\n return;\n }\n\n // Success detection on Edge is not possible, due to bugs in all 4\n // detection mechanisms we could try to use. Assume success.\n if (navigator.userAgent.indexOf(\"Edge\") > -1) {\n debugLog(\"UA \\\"Edge\\\" => assuming success\");\n return;\n }\n\n // Fallback 1 for desktop Safari.\n if (copyUsingTempSelection(document.body, data)) {\n debugLog(\"copyUsingTempSelection worked\");\n return;\n }\n\n // Fallback 2 for desktop Safari.\n if (copyUsingTempElem(data)) {\n debugLog(\"copyUsingTempElem worked\");\n return;\n }\n\n // Fallback for iOS Safari.\n const text = data.getData(TEXT_PLAIN);\n if (text !== undefined && copyTextUsingDOM(text)) {\n debugLog(\"copyTextUsingDOM worked\");\n return;\n }\n\n throw new Error(\"Copy command failed.\");\n}\n\nexport async function writeText(s: string): Promise<void> {\n if (navigator.clipboard && navigator.clipboard.writeText) {\n debugLog(\"Using `navigator.clipboard.writeText()`.\");\n return navigator.clipboard.writeText(s);\n }\n return write(DTFromText(s));\n}\n\nexport async function read(): Promise<DT> {\n return DTFromText(await readText());\n}\n\nexport async function readText(): Promise<string> {\n if (navigator.clipboard && navigator.clipboard.readText) {\n debugLog(\"Using `navigator.clipboard.readText()`.\");\n return navigator.clipboard.readText();\n }\n if (seemToBeInIE()) {\n debugLog(\"Reading text using IE strategy.\");\n return readIE();\n }\n throw new Error(\"Read is not supported in your browser.\");\n}\n\nlet useStarShown = false;\nfunction useStar(): void {\n if (useStarShown) {\n return;\n }\n if (showWarnings) {\n warn(\"The deprecated default object of `clipboard-polyfill` was called. Please switch to `import * as clipboard from \\\"clipboard-polyfill\\\"` and see https://github.com/lgarron/clipboard-polyfill/issues/101 for more info.\");\n }\n useStarShown = true;\n}\n\nconst ClipboardPolyfillDefault = {\n DT,\n setDebugLog(f: (s: string) => void): void {\n useStar();\n return setDebugLog(f);\n },\n suppressWarnings() {\n useStar();\n return suppressWarnings();\n },\n async write(data: DT): Promise<void> {\n useStar();\n return write(data);\n },\n async writeText(s: string): Promise<void> {\n useStar();\n return writeText(s);\n },\n async read(): Promise<DT> {\n useStar();\n return read();\n },\n async readText(): Promise<string> {\n useStar();\n return readText();\n },\n};\n\nexport default ClipboardPolyfillDefault;\n\n/******** Implementations ********/\n\nclass FallbackTracker {\n public success: boolean = false;\n}\n\nfunction copyListener(tracker: FallbackTracker, data: DT, e: ClipboardEvent): void {\n debugLog(\"listener called\");\n tracker.success = true;\n data.forEach((value: string, key: string) => {\n const clipboardData = e.clipboardData!;\n clipboardData.setData(key, value);\n if (key === TEXT_PLAIN && clipboardData.getData(key) !== value) {\n debugLog(\"setting text/plain failed\");\n tracker.success = false;\n }\n });\n e.preventDefault();\n}\n\nfunction execCopy(data: DT): boolean {\n const tracker = new FallbackTracker();\n const listener = copyListener.bind(this, tracker, data);\n\n document.addEventListener(\"copy\", listener);\n try {\n // We ignore the return value, since FallbackTracker tells us whether the\n // listener was called. It seems that checking the return value here gives\n // us no extra information in any browser.\n document.execCommand(\"copy\");\n } finally {\n document.removeEventListener(\"copy\", listener);\n }\n return tracker.success;\n}\n\n// Temporarily select a DOM element, so that `execCommand()` is not rejected.\nfunction copyUsingTempSelection(e: HTMLElement, data: DT): boolean {\n selectionSet(e);\n const success = execCopy(data);\n selectionClear();\n return success;\n}\n\n// Create a temporary DOM element to select, so that `execCommand()` is not\n// rejected.\nfunction copyUsingTempElem(data: DT): boolean {\n const tempElem = document.createElement(\"div\");\n // Setting an individual property does not support `!important`, so we set the\n // whole style instead of just the `-webkit-user-select` property.\n tempElem.setAttribute(\"style\", \"-webkit-user-select: text !important\");\n // Place some text in the elem so that Safari has something to select.\n tempElem.textContent = \"temporary element\";\n document.body.appendChild(tempElem);\n\n const success = copyUsingTempSelection(tempElem, data);\n\n document.body.removeChild(tempElem);\n return success;\n}\n\n// Uses shadow DOM.\nfunction copyTextUsingDOM(str: string): boolean {\n debugLog(\"copyTextUsingDOM\");\n\n const tempElem = document.createElement(\"div\");\n // Setting an individual property does not support `!important`, so we set the\n // whole style instead of just the `-webkit-user-select` property.\n tempElem.setAttribute(\"style\", \"-webkit-user-select: text !important\");\n // Use shadow DOM if available.\n let spanParent: Node = tempElem;\n if (tempElem.attachShadow) {\n debugLog(\"Using shadow DOM.\");\n spanParent = tempElem.attachShadow({mode: \"open\"});\n }\n\n const span = document.createElement(\"span\");\n span.innerText = str;\n\n spanParent.appendChild(span);\n document.body.appendChild(tempElem);\n selectionSet(span);\n\n const result = document.execCommand(\"copy\");\n\n selectionClear();\n document.body.removeChild(tempElem);\n\n return result;\n}\n\n/******** Selection ********/\n\nfunction selectionSet(elem: Element): void {\n const sel = document.getSelection();\n if (sel) {\n const range = document.createRange();\n range.selectNodeContents(elem);\n sel.removeAllRanges();\n sel.addRange(range);\n }\n}\n\nfunction selectionClear(): void {\n const sel = document.getSelection();\n if (sel) {\n sel.removeAllRanges();\n }\n}\n\n/******** Convenience ********/\n\nfunction DTFromText(s: string): DT {\n const dt = new DT();\n dt.setData(TEXT_PLAIN, s);\n return dt;\n}\n\n/******** Internet Explorer ********/\n\ninterface IEWindow extends Window {\n clipboardData: {\n setData: (key: string, value: string) => boolean;\n // Always results in a string: https://msdn.microsoft.com/en-us/library/ms536436(v=vs.85).aspx\n getData: (key: string) => string;\n };\n}\n\nfunction seemToBeInIE(): boolean {\n return typeof ClipboardEvent === \"undefined\" &&\n typeof (window as IEWindow).clipboardData !== \"undefined\" &&\n typeof (window as IEWindow).clipboardData.setData !== \"undefined\";\n}\n\nfunction writeIE(data: DT): boolean {\n // IE supports text or URL, but not HTML: https://msdn.microsoft.com/en-us/library/ms536744(v=vs.85).aspx\n // TODO: Write URLs to `text/uri-list`? https://developer.mozilla.org/en-US/docs/Web/API/HTML_Drag_and_Drop_API/Recommended_drag_types\n const text = data.getData(TEXT_PLAIN);\n if (text !== undefined) {\n return (window as IEWindow).clipboardData.setData(\"Text\", text);\n }\n\n throw new Error((\"No `text/plain` value was specified.\"));\n}\n\n// Returns \"\" if the read failed, e.g. because the user rejected the permission.\nasync function readIE(): Promise<string> {\n const text = (window as IEWindow).clipboardData.getData(\"Text\");\n if (text === \"\") {\n throw new Error(\"Empty clipboard or could not read plain text from clipboard\");\n }\n return text;\n}\n"],"sourceRoot":""}
\ No newline at end of file |