antosdk-apps/Clipper/build/debug/main.js

21 lines
165 KiB
JavaScript
Raw Permalink Normal View History

(function(){var A;(A=class extends this.OS.application.BaseApplication{constructor(A){super("Clipper",A)}main(){var A;if(this.scene=this.find("scene"),this.wrapper=this.find("wrapper"),this.cropwin=this.find("cropwin"),this.dirty=!1,this.currfile="Untitled".asFileHandle(),$(this.cropwin).css("position","absolute").hide(),this.find("btnCptScreen").onbtclick=()=>this.capture(document.body,!0),this.find("btnCptWindow").onbtclick=()=>{var A,e,t,r,n,B,s;for(e in s=[],n=OS.PM.processes)for(A=0,t=(B=n[e]).length;A<t;A++)r=B[A],0===OS.application[r.name].type&&s.push({text:r.scheme.apptitle,el:r.scheme,icon:r.meta().icon,iconclass:r.meta().iconclass});return this.openDialog("SelectionDialog",{title:"Select a window",data:s}).then(A=>{if(A)return this.capture(A.el)})},A=this.find("btnCrop"),this.cropselect=A=>{var e,t,r;return t=$(this.cropwin).offset(),r=A.clientX-t.left,e=A.clientY-t.top,$(this.cropwin).css("width",r+"px").css("height",e+"px")},this.cropup=e=>($(window).off("mousemove",this.cropselect),$(window).off("mouseup",this.cropup),this.ask({text:__("Crop the selected zone ?")}).then(e=>{var t,r,n,B,s,o,i,a;if(A.enable=!0,A.selected=!1,t=$(this.cropwin).offset(),s=$(this.scene).offset(),i=t.left-s.left,a=t.top-s.top,o=$(this.cropwin).width(),B=$(this.cropwin).height(),$(this.cropwin).hide(),$(this.cropwin).css("width","0px").css("height","0px"),e)return n=(r=this.scene.getContext("2d")).getImageData(i,a,o,B),this.scene.width=o,this.scene.height=B,r.putImageData(n,0,0),this.dirty=!0})),this.cropdown=e=>{var t;return A.enable=!1,t=$(this.scheme).offset(),$(this.cropwin).css("left",e.clientX-t.left+"px").css("top",e.clientY-t.top+"px").show(),$(window).off("mousedown",this.cropdown),$(window).mousemove(this.cropselect),$(window).mouseup(this.cropup)},A.onbtclick=()=>A.selected?$(window).mousedown(this.cropdown):$(window).off("mousedown",this.cropdown),this.bindKey("CTRL-S",()=>this.actionFile(this.name+"-Save")),this.bindKey("ALT-W",()=>this.actionFile(this.name+"-Saveas")),this.notify(__("User ALT-S global shortcut to capture the entire VDE")),this._gui.bindKey("ALT-S",()=>{if(html2canvas)return html2canvas(document.body).then(A=>this._gui.launch("Clipper",[A]))}),this.args&&1===this.args.length)return this.copycanvas(this.args[0])}copycanvas(A){return this.scene.height=A.height,this.scene.width=A.width,this.scene.getContext("2d").drawImage(A,0,0),this.dirty=!0}capture(A,e){return e&&this.hide(),this.load(new Promise((t,r)=>html2canvas(A).then(A=>(this.copycanvas(A),e&&this.show(),t())).catch((function(A){return r(__e(A))})))).then(()=>this.notify(__("Screen captured"))).catch(A=>this.error(A.toString(),A))}menu(){return[{text:"__(File)",nodes:[{text:"__(Save)",dataid:this.name+"-Save",shortcut:"C-S"},{text:"__(Save as)",dataid:this.name+"-Saveas",shortcut:"A-W"}],onchildselect:A=>this.actionFile(A.data.item.data.dataid)}]}save(){return this.currfile.cache=this.scene.toDataURL("image/png"),this.currfile.write("base64").then(A=>(this.notify(__("File saved")),this.dirty=!1)).catch(A=>this.error(__("Cannot save to file: {0}",A.toString()),A))}actionFile(A){var e;switch(e=()=>this.openDialog("FileDialog",{title:__("Save as"),file:this.currfile}).then(A=>{var e;return e=A.file.path.asFileHandle(),"file"===A.file.type&&(e=e.parent()),this.currfile.setPath(`${e.path}/${A.name}`),this.save(this.currfile)}),A){case this.name+"-Save":return this.currfile.basename?this.save():e();case this.name+"-Saveas":return e()}}cleanup(A){if(this.dirty)return A.preventDefault(),this.ask({title:__("Quit"),text:__("Quit without saving ?")}).then(A=>{if(A)return this.dirty=!1,this.quit()})}}).singleton=!0,this.OS.register("Clipper",A)}).call(this),
2020-07-14 22:16:09 +02:00
/*!
* html2canvas 1.0.0-rc.5 <https://html2canvas.hertzen.com>
* Copyright (c) 2020 Niklas von Hertzen <https://hertzen.com>
* Released under MIT License
*/
function(A,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(A=A||self).html2canvas=e()}(this,(function(){"use strict";
2020-07-14 22:16:09 +02:00
/*! *****************************************************************************
Copyright (c) Microsoft Corporation. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
this file except in compliance with the License. You may obtain a copy of the
License at http://www.apache.org/licenses/LICENSE-2.0
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
MERCHANTABLITY OR NON-INFRINGEMENT.
See the Apache Version 2.0 License for specific language governing permissions
and limitations under the License.
***************************************************************************** */var A=function(e,t){return(A=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(A,e){A.__proto__=e}||function(A,e){for(var t in e)e.hasOwnProperty(t)&&(A[t]=e[t])})(e,t)};function e(e,t){function r(){this.constructor=e}A(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}var t=function(){return(t=Object.assign||function(A){for(var e,t=1,r=arguments.length;t<r;t++)for(var n in e=arguments[t])Object.prototype.hasOwnProperty.call(e,n)&&(A[n]=e[n]);return A}).apply(this,arguments)};function r(A,e,t,r){return new(t||(t=Promise))((function(n,B){function s(A){try{i(r.next(A))}catch(A){B(A)}}function o(A){try{i(r.throw(A))}catch(A){B(A)}}function i(A){A.done?n(A.value):new t((function(e){e(A.value)})).then(s,o)}i((r=r.apply(A,e||[])).next())}))}function n(A,e){var t,r,n,B,s={label:0,sent:function(){if(1&n[0])throw n[1];return n[1]},trys:[],ops:[]};return B={next:o(0),throw:o(1),return:o(2)},"function"==typeof Symbol&&(B[Symbol.iterator]=function(){return this}),B;function o(B){return function(o){return function(B){if(t)throw new TypeError("Generator is already executing.");for(;s;)try{if(t=1,r&&(n=2&B[0]?r.return:B[0]?r.throw||((n=r.return)&&n.call(r),0):r.next)&&!(n=n.call(r,B[1])).done)return n;switch(r=0,n&&(B=[2&B[0],n.value]),B[0]){case 0:case 1:n=B;break;case 4:return s.label++,{value:B[1],done:!1};case 5:s.label++,r=B[1],B=[0];continue;case 7:B=s.ops.pop(),s.trys.pop();continue;default:if(!((n=(n=s.trys).length>0&&n[n.length-1])||6!==B[0]&&2!==B[0])){s=0;continue}if(3===B[0]&&(!n||B[1]>n[0]&&B[1]<n[3])){s.label=B[1];break}if(6===B[0]&&s.label<n[1]){s.label=n[1],n=B;break}if(n&&s.label<n[2]){s.label=n[2],s.ops.push(B);break}n[2]&&s.ops.pop(),s.trys.pop();continue}B=e.call(A,s)}catch(A){B=[6,A],r=0}finally{t=n=0}if(5&B[0])throw B[1];return{value:B[0]?B[1]:void 0,done:!0}}([B,o])}}}for(var B=function(){function A(A,e,t,r){this.left=A,this.top=e,this.width=t,this.height=r}return A.prototype.add=function(e,t,r,n){return new A(this.left+e,this.top+t,this.width+r,this.height+n)},A.fromClientRect=function(e){return new A(e.left,e.top,e.width,e.height)},A}(),s=function(A){return B.fromClientRect(A.getBoundingClientRect())},o=function(A){for(var e=[],t=0,r=A.length;t<r;){var n=A.charCodeAt(t++);if(n>=55296&&n<=56319&&t<r){var B=A.charCodeAt(t++);56320==(64512&B)?e.push(((1023&n)<<10)+(1023&B)+65536):(e.push(n),t--)}else e.push(n)}return e},i=function(){for(var A=[],e=0;e<arguments.length;e++)A[e]=arguments[e];if(String.fromCodePoint)return String.fromCodePoint.apply(String,A);var t=A.length;if(!t)return"";for(var r=[],n=-1,B="";++n<t;){var s=A[n];s<=65535?r.push(s):(s-=65536,r.push(55296+(s>>10),s%1024+56320)),(n+1===t||r.length>16384)&&(B+=String.fromCharCode.apply(String,r),r.length=0)}return B},a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",c="undefined"==typeof Uint8Array?[]:new Uint8Array(256),Q=0;Q<a.length;Q++)c[a.charCodeAt(Q)]=Q;var u,w,U,l,C,g,E,h,F=function(A,e,t){return A.slice?A.slice(e,t):new Uint16Array(Array.prototype.slice.call(A,e,t))},d=function(){function A(A,e,t,r,n,B){this.initialValue=A,this.errorValue=e,this.highStart=t,this.highValueIndex=r,this.index=n,this.data=B}return A.prototype.get=function(A){var e;if(A>=0){if(A<55296||A>56319&&A<=65535)return e=((e=this.index[A>>5])<<2)+(31&A),this.data[e];if(A<=65535)return e=((e=this.index[2048+(A-55296>>5)])<<2)+(31&A),this.data[e];if(A<this.highStart)return e=2080+(A>>11),e=this.index[e],e+=A>>5&63,e=((e=this.index[e])<<2)+(31&A),this.data[e];if(A<=1114111)return this.data[this.highValueIndex]}return this.errorValue},A}(),H=10,f=13,p=15,N=17,K=18,I=19,m=20,T=21,R=22,L=24,v=25,O=26,D=27,b=28,S=30,y=32,M=33,_=34,P=35,x=37,V=38,z=39,X=40,J=42,G=(l=function(A){var e,t,r,n,B,s=.75*A.length,o=A.length,i=0;"="===A[A.length-1]&&(s--,"="===A[A.length-2]&&s--);var a="undefined"!=typeof ArrayBuffer&&"undefined"!=typeof Uint8Array&&void 0!==Uint8Array.prototype.slice?new ArrayBuffer(s):new Array(s),Q=Array.isArray(a)?a:new Uint8Arra