@finsemble/finsemble-electron-adapter 8.12.1-beta.2 → 8.12.2-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/app.js +1 -1
- package/dist/app.js.map +1 -1
- package/dist/e2o.js +1 -1
- package/dist/e2o.js.map +1 -1
- package/package.json +2 -2
package/dist/e2o.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
(()=>{"use strict";var e={342:(e,t,s)=>{!function(){var t,n,o,r=0,i=[];for(n=0;n<256;n++)i[n]=(n+256).toString(16).substr(1);function a(){var e=(16,(!t||r+16>d.BUFFER_SIZE)&&(r=0,t=d.randomBytes(d.BUFFER_SIZE)),t.slice(r,r+=16));return e[6]=15&e[6]|64,e[8]=63&e[8]|128,e}function d(){var e=a();return i[e[0]]+i[e[1]]+i[e[2]]+i[e[3]]+"-"+i[e[4]]+i[e[5]]+"-"+i[e[6]]+i[e[7]]+"-"+i[e[8]]+i[e[9]]+"-"+i[e[10]]+i[e[11]]+i[e[12]]+i[e[13]]+i[e[14]]+i[e[15]]}d.BUFFER_SIZE=4096,d.bin=a,d.clearBuffer=function(){t=null,r=0},d.test=function(e){return"string"==typeof e&&/^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(e)},"undefined"!=typeof crypto?o=crypto:"undefined"!=typeof window&&void 0!==window.msCrypto&&(o=window.msCrypto),o=o||s(982),e.exports=d,d.randomBytes=function(){if(o){if(o.randomBytes)return o.randomBytes;if(o.getRandomValues)return"function"!=typeof Uint8Array.prototype.slice?function(e){var t=new Uint8Array(e);return o.getRandomValues(t),Array.from(t)}:function(e){var t=new Uint8Array(e);return o.getRandomValues(t),t}}return function(e){var t,s=[];for(t=0;t<e;t++)s.push(Math.floor(256*Math.random()));return s}}()}()},982:e=>{e.exports=require("crypto")}},t={};function s(n){var o=t[n];if(void 0!==o)return o.exports;var r=t[n]={exports:{}};return e[n](r,r.exports,s),r.exports}s.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return s.d(t,{a:t}),t},s.d=(e,t)=>{for(var n in t)s.o(t,n)&&!s.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},s.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),(()=>{const e=require("electron");class t{constructor(e){e&&e.send?this.ipc=e:console.log("FEA LoggerRender using console output by default")}send(e,t){this.ipc?this.ipc.send("logger:message",{level:e,args:t}):("verbose"===e&&(e="debug"),console[e]?console[e]("FEA logger:message",t):console.warn(`FEA logger:message: level: ${e} not defined. defaulting to warn. `,t))}error(...e){this.send("error",e)}warn(...e){this.send("warn",e)}info(...e){this.send("info",e)}log(...e){this.send("log",e)}debug(...e){this.send("debug",e)}verbose(...e){this.send("verbose",e)}}let n;const o=()=>{if(n)return n;try{n=new t(e.ipcRenderer)}catch(e){n=console,n.verbose=n.debug,n.error(`Failed to instantiate LoggerRenderer ${e.message}`)}return n},r=require("events");var i=s(342),a=s.n(i);let d,c=!1;class u extends r.EventEmitter{constructor(){super(),this.request={},e.ipcRenderer.on("systemResponse",this.systemResponse.bind(this)),e.ipcRenderer.on("handleResponse",this.handleResponse.bind(this)),e.ipcRenderer.on("pong",(()=>{clearTimeout(d),c=!0})),d=setInterval((()=>{e.ipcRenderer.send("ping")}),5)}handleResponse(e,t){if(!t||!this.request[t.responseUUID])return void console.warn(`Event object not found in handleResponse: event ${e} data ${t&&JSON.stringify(t)}`);const{responseUUID:s,response:n,err:o}=t,r=this.request[s],i=r.responseUUID;o&&console.error(o),r.persistChannel||delete this.request[i],r.functionCB(r,n)}promisifiedSendRequest(e){return new Promise((t=>{this.sendRequest(e,((e,s)=>t(s)))}))}sendRequest(t,s=Function.prototype){const{topic:n,data:o,persistChannel:r}=t,i=a()(),d={topic:n,data:o,persistChannel:r,responseUUID:i,functionCB:s},u=t=>{const s=t.responseUUID;this.request[s]=t;const r={topic:n,data:o};e.ipcRenderer.send("e2o.mainRequest",JSON.parse(JSON.stringify(r)),s)};let p;c?u(d):p=setInterval((()=>{c&&(clearInterval(p),u(d))}),5)}systemResponse(e,t){let s;try{s=JSON.parse(t.data)}catch(e){s=t.data}this.emit(t.topic,s)}addListener(t,s){const n=this.listenerCount(t);return super.addListener(t,s),0===n&&e.ipcRenderer.send("system.addListener",t),this}removeListener(t,s){return super.removeListener(t,s),0===this.listenerCount(t)&&e.ipcRenderer.send("system.removeListener",t),this}}const p=new u,l=o(),h=e=>"object"==typeof e&&e&&e.error?(console.log("Warning:",e.message),l.warn("Warning:",e.message),!0):!("string"!=typeof e||!e.includes("api_access_denied")||(console.log("Warning:",e),l.warn("Warning:",e),0)),m=o();class w extends r.EventEmitter{constructor(e){var t,s;if(super(),this.uuid="fin.desktop.Window.uuid has been deprecated",this.closeRequestedListeners=[],this.isMoving=!1,this.animationId=0,this.bindAllFunctions(),this.manifest=e.manifest,this.name=e.windowName,this.webContentsName=e.webContentsName,this.webContentsId=e.webContentsId,m.info("Constructing `Window` object in Window.ts",this.name),!this.name)throw new Error("Window being created without a name. This is not allowed.");const n=null===(s=null===(t=this.manifest)||void 0===t?void 0:t["finsemble-electron-adapter"])||void 0===s?void 0:s.useDOMBasedMovement;this.useDOMMovement="darwin"===process.platform||null==n||n}attachToMainWindow(){e.ipcRenderer.on(`windowEvent-${this.name}`,this.remoteFSBLEvents.bind(this))}wrap(t,s){s&&(t=s),m.verbose(`Wrapping window ${t}`);const{err:n,data:o}=e.ipcRenderer.sendSync("fea.getWindowIdentityForWindowName",t);if(n||!o)throw`Window.wrap() failed for ${t}. ${n}`;const r=new w({manifest:this.manifest,windowName:t,webContentsName:o.webContentsName,webContentsId:o.id});return r.attachToMainWindow(),r}static spawnPhysicalWindow(e){return new Promise((t=>{const s=e.name;let n=!1;m.verbose(`spawnPhysicalWindow ${s}`);const o=setTimeout((()=>{const e=`Window ${s}: spawn is taking an unusually long time (>5 seconds, it will timeout at 90 seconds)`;m.warn(e)}),5e3),r=setTimeout((()=>{n=!0;const e=`Window ${s}: spawn failed to return within 90 seconds`;m.error(e),t({err:e})}),9e4);m.debug(`Window ${s}: spawning`),p.sendRequest({topic:"-SpawnWindow",data:e},((e,i)=>{n?m.debug(`Late spawn window response from main process (after 5 sec) for ${s}: `,i):(clearTimeout(o),clearTimeout(r),"ErrorResponse"!==i.type?(m.debug(`Window ${s}: spawn complete`),t({})):t({err:i.payload.err}))}))}))}async createNew(e,t){const{err:s}=await w.spawnPhysicalWindow(e);if(s)return null==t||t(s),{err:s};const n=new w(Object.assign({},e));return n.attachToMainWindow(),null==t||t(null,n),{data:n}}bindAllFunctions(){const e=this;for(const t of Object.getOwnPropertyNames(Object.getPrototypeOf(e))){const s=e[t];s instanceof Function&&s!==w&&(e[t]=e[t].bind(e))}}addEventListener(e,t){this.addListener(e,t)}addBrowserView(e,t){p.sendRequest({topic:`${this.name}-addBrowserView`,data:e},((e,s)=>{h(s),t(s)}))}setViewBounds(e,t,s){const n={type:"window",bounds:{x:t.left,y:t.top,width:t.width,height:t.height},viewId:e};p.sendRequest({topic:`${this.name}-setViewBounds`,data:n},((e,t)=>{t.bounds&&(t.bounds.left=t.bounds.x,t.bounds.top=t.bounds.y),h(t)?s(t):s(t.bounds)}))}bringViewToFront(e,t){p.sendRequest({topic:`${this.name}-bringViewToFront`,data:{viewId:e}},((e,s)=>{h(s)?t(s):t(null)}))}addListener(e,t){const s=`Window.addListener.${e}`;return m.verbose(`Adding listener ${e}, ${this.name}`),p.sendRequest({topic:"checkPermission",data:s},((s,n)=>{if(n)if("close-requested"==e){this.closeRequestedAdd(t);const s=(...e)=>{const s=this,n={eventCancelled:!1,cancel:function(){this.eventCancelled=!0},wait:()=>{},done:function(){this.eventCancelled||s.close(!0)},data:JSON.stringify(e)};t(n)};p.addListener(`windowEvent-${this.name}.${e}`,s)}else p.addListener(`windowEvent-${this.name}.${e}`,t);else m.warn(`PERMISSION DENIED: Attempted to add listener on Window.${this.name}.${e}.`)})),this}blur(e=Function.prototype){p.sendRequest({topic:`${this.name}-blur`},((t,s)=>{h(s),e(s)}))}bringToFront(e=Function.prototype){p.sendRequest({topic:`${this.name}-bringToFront`},((t,s)=>{h(s),e(s)}))}close(e=!1,t=Function.prototype){const s={force:e};p.sendRequest({topic:`${this.name}-close`,data:s},((e,s)=>{h(s),t(s)}))}closeRequestedAdd(e){0===this.closeRequestedListeners.length&&p.sendRequest({topic:`${this.name}-closeRequestedAdd`},((e,t)=>{h(t)||m.debug(`${this.name}-closeRequestedAdd`)})),this.closeRequestedListeners.push(e)}closeRequestedRemove(e){const t=this.closeRequestedListeners.indexOf(e);t>-1&&this.closeRequestedListeners.splice(t,1),0===this.closeRequestedListeners.length&&p.sendRequest({topic:`${this.name}-closeRequestedRemove`},((e,t)=>{h(t)||m.debug(`${this.name}-closeRequestedRemove`)}))}disableFrame(e=Function.prototype){p.sendRequest({topic:`${this.name}-disableFrame`},((t,s)=>{h(s),e(s)}))}enableFrame(e=Function.prototype){p.sendRequest({topic:`${this.name}-enableFrame`},((t,s)=>{h(s),e(s)}))}focus(e=Function.prototype){p.sendRequest({topic:`${this.name}-focus`},((t,s)=>{h(s),e(s)}))}focusTitleBarWindow(e=Function.prototype){p.sendRequest({topic:`${this.name}-focus`,data:{titleBarWindow:!0}},((t,s)=>{h(s),e(s)}))}getBounds(e=Function.prototype){p.sendRequest({topic:`${this.name}-getBounds`},((t,s)=>{h(s),e(s)}))}getBoundsFromSystem(e=Function.prototype){p.sendRequest({topic:`${this.name}-getBoundsFromSystem`},((t,s)=>{h(s),e(s)}))}getCurrent(){return this}getOptions(e=Function.prototype){p.sendRequest({topic:`${this.name}-getDetails`},((t,s)=>{h(s),e(s)}))}getSnapshot(e,t=Function.prototype){return new Promise((s=>{const n={area:e};p.sendRequest({topic:`${this.name}-getSnapshot`,data:n},((e,n)=>{h(n),t(n),s(n)}))}))}getTaskbarTitle(e=Function.prototype){p.sendRequest({topic:`${this.name}-getTaskbarTitle`},((t,s)=>{h(s),e(s)}))}hide(e=Function.prototype){p.sendRequest({topic:`${this.name}-hide`},((t,s)=>{h(s),e(s)}))}isShowing(e=Function.prototype){p.sendRequest({topic:`${this.name}-isShowing`},((t,s)=>{h(s),e(s)}))}minimize(e=Function.prototype){p.sendRequest({topic:`${this.name}-minimize`},((t,s)=>{h(s),e(s)}))}resetBrowserView(e=Function.prototype){p.sendRequest({topic:`${this.name}-resetBrowserView`},((t,s)=>{h(s),e(s)}))}removeBrowserView(e,t=Function.prototype){p.sendRequest({topic:`${this.name}-removeBrowserView`,data:{viewId:e}},((e,s)=>{h(s),t(s)}))}removeEventListener(e,t){this.removeListener(e,t)}removeListener(e,t){return"close-requested"==e&&this.closeRequestedRemove(t),p.removeListener(`windowEvent-${this.name}.${e}`,t),this}removeTrayIcon(e=Function.prototype){p.sendRequest({topic:"removeTrayIcon",data:{}},((e,t)=>{h(t)})),e()}setTrayIcon(e,t,s=Function.prototype){p.sendRequest({topic:"setTrayIconDeprecated",data:{iconpath:e,listeners:t?Object.keys(t):{}},persistChannel:!0},((e,s)=>{!h(s)&&t&&t.clickListener&&"click"==s.event&&(m.debug("setTrayIcon request sent"),t.clickListener(s))})),s()}maximize(e=Function.prototype){p.sendRequest({topic:`${this.name}-maximize`},((t,s)=>{h(s),e(s)}))}reload(e=Function.prototype){p.sendRequest({topic:`${this.name}-reload`},((t,s)=>{h(s),e(s)}))}restore(e=Function.prototype){p.sendRequest({topic:`${this.name}-restore`},((t,s)=>{h(s),e(s)}))}setBounds(e,t,s,n,o){const r={bounds:{x:e,y:t,width:s,height:n}};p.sendRequest({topic:`${this.name}-setBounds`,data:r},((e,t)=>{t.bounds&&(t.bounds.left=t.bounds.x,t.bounds.top=t.bounds.y),h(t)?o(t):o(t.bounds)}))}setIgnoreMouseEvents(e){p.sendRequest({topic:`${this.name}-setIgnoreMouseEvents`,data:e})}setResizable(e){p.sendRequest({topic:`${this.name}-setResizable`,data:e})}setShape(e){p.sendRequest({topic:`${this.name}-setShape`,data:e})}setTaskbarIcon(e){e||(e={}),p.sendRequest({topic:`${this.name}-setTaskbarIcon`,data:e})}setTaskbarIconOverlay(e){p.sendRequest({topic:`${this.name}-setTaskbarIconOverlay`,data:null!=e?e:{}})}setTaskbarTitle(e){p.sendRequest({topic:`${this.name}-setTaskbarTitle`,data:{title:e}})}showNativeOpenDialog(e,t){p.sendRequest({topic:`${this.name}-showNativeOpenDialog`,data:e},((e,s)=>t(s)))}show(e=Function.prototype){p.sendRequest({topic:`${this.name}-show`},((t,s)=>{h(s),e(s)}))}showAt(e,t,s,n=Function.prototype){const o={left:e,top:t};p.sendRequest({topic:`${this.name}-showAt`,data:o},((e,t)=>{h(t),n(t)}))}setMinimumSize(e,t,s=Function.prototype){const n={size:{width:e,height:t}};p.sendRequest({topic:`${this.name}-setMinimumSize`,data:n},((e,t)=>{h(t),s(t)}))}setMaximumSize(e=null,t=null,s=Function.prototype){const n={size:{width:e,height:t}};p.sendRequest({topic:`${this.name}-setMaximumSize`,data:n},((e,t)=>{h(t),s(t)}))}updateOptions(e,t=Function.prototype){const s={options:e};p.sendRequest({topic:`${this.name}-updateOptions`,data:s},((e,s)=>{h(s),t(s)}))}remoteFSBLEvents(e,t){this.emit(t.topic,t.data)}animate(e,t=Function.prototype){t&&"function"==typeof t&&t()}setAsForeground(e){this.bringToFront((()=>this.focus((()=>e()))))}startMovingWindow(e){this.mouseX=e.clientX,this.mouseY=e.clientY,this.isMoving=!0,p.sendRequest({topic:`${this.name}-windowMouseDown`});const t=()=>{this.isMoving&&(p.sendRequest({topic:`${this.name}-windowMoving`,data:{mouseX:this.mouseX,mouseY:this.mouseY}}),this.animationId=requestAnimationFrame(t))};this.animationId=requestAnimationFrame(t)}stopMovingWindow(){this.isMoving=!1,p.sendRequest({topic:`${this.name}-windowMoved`}),cancelAnimationFrame(this.animationId)}}const g=o();class b{constructor(){this.availableFormats=this.availableFormats.bind(this),this.writeText=this.writeText.bind(this),this.writeHTML=this.writeHTML.bind(this),this.writeRTF=this.writeRTF.bind(this),this.readText=this.readText.bind(this),this.readHTML=this.readHTML.bind(this),this.readRTF=this.readRTF.bind(this),this.write=this.write.bind(this)}availableFormats(e=Function.prototype,t=Function.prototype){p.sendRequest({topic:"availableFormatsFromClipboard"},((s,n)=>{if(!h(n))return"error"===n.status?(g.error(`Error fetching available formats from clipboard - ${n.message}`),t(n)):void e(n.value);t(n)}))}writeText(e,t=Function.prototype,s=Function.prototype){p.sendRequest({topic:"writeTextToClipboard",data:e},((e,n)=>{if(!h(n))return"error"===n.status?(g.error(`Clipboard writeText error: ${n.message}`),s(n)):void t(n);s(n)}))}writeHTML(e,t=Function.prototype,s=Function.prototype){p.sendRequest({topic:"writeHTMLToClipboard",data:e},((e,n)=>{if(!h(n))return"error"===n.status?(g.error(`Clipboard writeHTML error: ${n.message}`),s(n)):void t(n);s(n)}))}writeRTF(e,t=Function.prototype,s=Function.prototype){p.sendRequest({topic:"writeRTFToClipboard",data:e},((e,n)=>{if(!h(n))return"error"===n.status?(g.error(`Clipboard writeRTF error: ${n.message}`),s(n)):void t(n);s(n)}))}write(e,t=Function.prototype,s=Function.prototype){p.sendRequest({topic:"writeToClipboard",data:e},((n,o)=>{if(!h(o))return"error"===o.status?(g.error(`Clipboard write error: ${o.message}`),s(o)):void t(e);s(e)}))}readText(e=Function.prototype,t=Function.prototype){p.sendRequest({topic:"readTextFromClipboard"},((s,n)=>{if(!h(n))return"error"===n.status?(g.error(`Error reading text from clipboard - ${n.message}`),t(n)):void e(n.value);t(n)}))}readHTML(e=Function.prototype,t=Function.prototype){p.sendRequest({topic:"readHTMLFromClipboard"},((s,n)=>{if(!h(n))return"error"===n.status?(g.error(`Error reading html from clipboard - ${n.message}`),t(n)):void e(n.value);t(n)}))}readRTF(e=Function.prototype,t=Function.prototype){p.sendRequest({topic:"readRTFFromClipboard"},((s,n)=>{if(!h(n))return"error"===n.status?(g.error(`Error reading RTF from clipboard - ${n.message}`),t(n)):void e(n.value);t(n)}))}}class R{constructor(){this.register=this.register.bind(this),this.isRegistered=this.isRegistered.bind(this),this.unregister=this.unregister.bind(this),this.listeners={}}register(e,t,s=Function.prototype,n=Function.prototype){p.sendRequest({topic:"registerGlobalShortcut",data:e},((o,r)=>{if(!h(r))return"error"===r.status?(g.error(`GlobalShortcut register error: ${r.message}`),n(r)):(r.value?(p.addListener(`globalShortcut.${e}`,t),g.verbose(`Added listener: globalShortcut.${e}`),this.listeners[e]=t):g.verbose(`Shortcut could not be registered: GlobalShortcut ${e} already exists in some application, possibly outside of Finsemble`),void s(r.value));n(r)}))}isRegistered(e,t=Function.prototype,s=Function.prototype){p.sendRequest({topic:"isRegisteredGlobalShortcut",data:e},((e,n)=>{if(!h(n))return"error"===n.status?(g.error(`GlobalShortcut isRegistered error: ${n.message}`),s(n)):void t(n.value);s(n)}))}unregister(e,t=Function.prototype,s=Function.prototype){p.sendRequest({topic:"unregisterGlobalShortcut",data:e},((n,o)=>{if(!h(o)){if("error"===o.status)return g.error(`GlobalShortcut unregister error: ${o.message}`),s(o);const n=this.listeners[e];return"function"==typeof n&&p.removeListener(`globalShortcut.${e}`,n),delete this.listeners[e],void t(o)}s(o)}))}}class f extends r.EventEmitter{constructor(){super(),this.bindAllFunctions(),this.addEventListener=this.addListener.bind(this),this.removeEventListener=this.removeListener.bind(this),this.Clipboard=new b,this.GlobalShortcut=new R,e.ipcRenderer.on("systemEvent",((e,t)=>{this.emit(t.event,t.data)}))}bindAllFunctions(){const e=this;for(const t of Object.getOwnPropertyNames(Object.getPrototypeOf(e))){const s=e[t];s instanceof Function&&s!==f&&(e[t]=e[t].bind(e))}}addListener(e,t){const s=`System.addListener.${e}`;return p.sendRequest({topic:"checkPermission",data:s},((s,n)=>{n?(p.addListener(`systemEvent.${e}`,t),g.verbose(`Added listener: systemEvent.${e}`)):g.warn(`PERMISSION DENIED: Attempted to add listener on SystemEvent.${e}.`)})),this}addSelectClientCertificateListener(e){const t=a()(),s=e=>{p.sendRequest({topic:`picked-client-certificate.${t}`,data:{certificate:e}},((e,t)=>{h(t)}))};p.sendRequest({topic:"select-client-certificate",data:{id:t}},((n,o)=>{h(o),p.addListener(`pick-client-certificate.${t}`,(t=>{const{url:n,list:o}=t;e(n,o,s)}))}))}addCertificateErrorListener(e){const t=a()(),s=e=>{p.sendRequest({topic:`allow-or-disallow-page.${t}`,data:{allowOrDisallow:e}},((e,t)=>{h(t)}))};p.sendRequest({topic:"certificate-error.subscribe",data:{id:t}},((n,o)=>{h(o),p.addListener(`possibly-override-certificate-error.${t}`,(t=>{const{url:n,error:o,certificate:r}=t;e(n,o,r,s)}))}))}clearCache(e){p.sendRequest({topic:"clearCache",data:e},((e,t)=>{h(t)}))}exit(){p.sendRequest({topic:"-terminate",data:null},((e,t)=>{h(t)}))}flushStorage(){return p.sendRequest({topic:"flushStorage"},((e,t)=>{h(t)}))}async getManifest(e){const t=await p.promisifiedSendRequest({topic:"-getManifest",data:{type:"application"}});return h(t),null==e||e(t),t}hideSplashScreen(){return p.sendRequest({topic:"hideSplashScreen"})}notifyLoggerReady(){p.sendRequest({topic:"central-logger-ready"})}updateCentralLoggerState(e){p.sendRequest({topic:"central-logger-state-changed",data:e})}getEnvironmentVariable(e,t=Function.prototype,s=Function.prototype){return p.sendRequest({topic:"getEnvironmentVariable",data:{variableName:e}},((e,n)=>{"error"===n.status?(g.error(`getEnvironmentVariable Error: ${n.message}`),s(n)):(g.debug("getEnvironmentVariable response received."),t(n.value))}))}deleteAssets(e){return new Promise((t=>{p.sendRequest({topic:"deleteAssets",data:e},((e,s)=>{var n;h(s),t({err:null!==(n=s.err)&&void 0!==n?n:s.error})}))}))}getSDServerInfo(e){return p.sendRequest({topic:"getSDServerInfo"},((t,s)=>{h(s),e(s)}))}getHostSpecs(e){return p.sendRequest({topic:"getHostSpecs"},((t,s)=>{h(s),e(s)}))}getMonitorInfo(e){return p.sendRequest({topic:"getMonitorInfo"},((t,s)=>{h(s)?e(s):(e(s.monitorInfo),g.verbose("getMonitorInfo request sent."))}))}getMousePosition(e){return p.sendRequest({topic:"getMousePosition"},((t,s)=>{h(s),e(s)}))}getProcessList(e){return new Promise((t=>{p.sendRequest({topic:"getProcessList",data:{}},((s,n)=>{h(n),e(n),t(n)}))}))}getDownloadList(e){return new Promise((t=>{p.sendRequest({topic:"getDownloadList",data:{}},((s,n)=>{h(n),e(n),t(n)}))}))}removeDownloadItem(e){return new Promise((t=>{p.sendRequest({topic:"removeDownloadItem",data:e},((e,s)=>{h(s),t(s)}))}))}cancelDownload(e,t=Function.prototype){return p.sendRequest({topic:"cancelDownload",data:e},((e,s)=>{h(s),t()}))}pauseDownload(e,t=Function.prototype){return p.sendRequest({topic:"pauseDownload",data:e},((e,s)=>{h(s),t()}))}resumeDownload(e,t=Function.prototype){return p.sendRequest({topic:"resumeDownload",data:e},((e,s)=>{h(s),t()}))}setDownloadSavePath(e,t=Function.prototype){return p.sendRequest({topic:"setDownloadSavePath",data:e},((e,s)=>{h(s),t()}))}clearDownloadList(e=Function.prototype){return p.sendRequest({topic:"clearDownloadList",data:{}},((t,s)=>{h(s),e()}))}showDownloadedFileInFolder(e,t=Function.prototype){return p.sendRequest({topic:"showDownloadedFileInFolder",data:e},((e,s)=>{h(s),t()}))}getVersion(e){return console.log("fin.desktop.System.getVersion() is deprecated. Please use getFEAInfo()."),p.sendRequest({topic:"getVersion"},((t,s)=>{h(s),e(s)}))}getUpdateAvailable(e){return p.sendRequest({topic:"getUpdateAvailable"},((t,s)=>{h(s),e(s)}))}getFEAInfo(e){return p.sendRequest({topic:"getFEAInfo"},((t,s)=>{h(s),e(s)}))}startupApplicationHandshake(){return p.sendRequest({topic:"startupApplicationHandshake"},((e,t)=>{h(t)}))}launchExternalProcess(e,t,s){p.sendRequest({topic:"launchExternalProcess",data:e},((e,n)=>{"error"===n.status?(g.error(`launchExternalProcess: ${n.message}`),null==s||s({status:"error",message:n.error,code:"launch_fail"})):(g.debug("launchExternalProcess request sent."),t(n))}))}openUrlWithBrowser(e,t){return p.sendRequest({topic:"openUrlWithBrowser",data:e},((e,s)=>{h(s),null==t||t(s)}))}removeListener(e,t){return p.removeListener(`systemEvent.${e}`,t),this}showDeveloperTools(e,t=!0,s=Function.prototype){return g.log("System.showDeveloperTools()",e,t),p.sendRequest({topic:`${e}-showDeveloperTools`,data:{name:e,viewId:t,autoPick:!0===t}},((e,t)=>{h(t),s()}))}restart(){p.sendRequest({topic:"restartApplication",data:{}},((e,t)=>{h(t)}))}terminate(){g.log("Render: terminate called for application"),p.sendRequest({topic:"-terminate",data:null},((e,t)=>{h(t)}))}getProtocolString(e){return new Promise((t=>{p.sendRequest({topic:"getProtocolString"},((s,n)=>{t(n),e&&e(n)}))}))}getCommandLineArguments(e=Function.prototype){return p.sendRequest({topic:"getCommandLineArguments"},((t,s)=>{h(s),e(s)}))}async getScreenShareSources(e={}){const t=Object.assign({types:["window","screen"]},e),s=await p.promisifiedSendRequest({topic:"getScreenShareSources",data:t});if(h(s),"error"===s.status)throw g.error(`Error getting ScreenShare sources - ${s.message}`),`Error getting ScreenShare sources - ${s.message}`;return s.value}async getScreenShot(e=null){if(!e)try{if(!(e=(await this.getScreenShareSources()).filter((e=>"Entire Screen"===e.name||"Screen 1"===e.name))[0].id))throw"Not found"}catch(e){throw new Error("Error capturing screenshot: Unable to Find a screen. Please specify a valid sourceId from the sources returned by getScreenShareSources")}try{const t=await navigator.mediaDevices.getUserMedia({audio:!1,video:{mandatory:{chromeMediaSource:"desktop",chromeMediaSourceId:e,minWidth:1280,maxWidth:4e3,minHeight:720,maxHeight:4e3}}});return await(e=>new Promise((t=>{const s=e.getVideoTracks()[0].getSettings(),n=document.createElement("video");n.style.cssText="position:absolute;top:-10000px;left:-10000px;",n.onloadedmetadata=function(){n.style.height=`${s.height}px`,n.style.width=`${s.width}px`,n.play();const o=document.createElement("canvas");o.height=s.height||0,o.width=s.width||0;const r=o.getContext("2d");null==r||r.drawImage(n,0,0,o.width,o.height),t(o.toDataURL("image/png")),n.remove();try{e.getTracks()[0].stop()}catch(e){}},n.srcObject=e,document.body.appendChild(n)})))(t)}catch(e){throw new Error(`Error capturing screenshot: ${e}`)}}setTrayIcon(e,t=Function.prototype){p.sendRequest({topic:"setTrayIcon",data:{url:e}},((e,s)=>{h(s),t()}))}subscribeToWindowEventStream(t){e.ipcRenderer.addListener("e2o.WindowEventStream",((e,s)=>{t(s)})),e.ipcRenderer.send("e2o.SubscribeToWindowEventStream")}logToDisk(e,...t){p.sendRequest({topic:"logToDisk",data:{level:e,messages:t}},((e,t)=>{h(t)}))}}const y={send:e=>{p.sendRequest({topic:"notification",data:e},((e,t)=>{h(t)}))}},v=o();class q extends r.EventEmitter{constructor(){super(),this.subscribers={},this.bindAllFunctions(),this.setUpListeners()}bindAllFunctions(){const e=this;for(const t of Object.getOwnPropertyNames(Object.getPrototypeOf(e))){const s=e[t];s instanceof Function&&s!==q&&(e[t]=e[t].bind(e))}}setUpListeners(){e.ipcRenderer.on("subscribeResponse",this.onSubscribeResponse.bind(this)),e.ipcRenderer.on("subscribeResponseError",((e,t)=>{h(t)})),e.ipcRenderer.on("unSubscribeResponseError",((e,t)=>{h(t)})),e.ipcRenderer.on("publishResponseError",((e,t)=>{h(t)}))}onSubscribeResponse(e,t){const s=this.subscribers[t.listenerID];null==s||s(t.data)}publish(t,s,n,o){try{e.ipcRenderer.send("e2o.iab.publish",{destination:t,data:s}),null==n||n()}catch(e){v.warn(`Publish to ${t} failed. ${e.message}`),null==o||o(e)}}subscribe(t,s,n,o=Function.prototype,r=Function.prototype){try{const t=a()();return e.ipcRenderer.send("e2o.iab.subscribe",{listenerID:t,source:s}),this.subscribers[t]=n,null==o||o(),t}catch(e){return v.warn(`Subscribing for ${s} failed. ${e.message}`),r(e),null}}unsubscribe(t){e.ipcRenderer.send("e2o.iab.unsubscribe",{listenerID:t}),t&&delete this.subscribers[t]}}console.log("Running e2o.js preload");const F=o(),{err:$,data:S}=e.ipcRenderer.sendSync("fea.getWindowIdentity");if($||!S){const e=`Error loading e2o.js preload: ${$}`;console.error(e),F.error(e)}else(t=>{const{id:s,windowName:n,webContentsName:o,isView:r,isTitlebarWindow:i,manifest:a,contextIsolation:d,preloads:c}=t;r||console.log("This is the devtools for the BrowserWindow object (titlebar shell). Use the central logger to access the devtools for the BrowserView (app content)."),d?e.contextBridge.exposeInMainWorld("finsemble",!0):window.finsemble=!0,e.webFrame.executeJavaScript(`window.name = ${JSON.stringify(n)}`);const u=new w({windowName:n,webContentsName:o,webContentsId:s,manifest:a});u.attachToMainWindow();const p={hasBrowserView:()=>(console.log("hasBrowserView() is deprecated. Use isTitlebarWindow()"),i),getViewId:()=>(console.log("getViewId() is deprecated. Use getWebContentsId()"),null!=s?s:null),isBrowserView:()=>r,isTitlebarWindow:()=>i,getWebContentsId:()=>null!=s?s:null,desktop:{main:e=>{console.log("fin.desktop.main has been deprecated. It is no longer necessary to wait before using fin."),e()},InterApplicationBus:new q,Notification:y,System:new f,Window:u}};d?(e.contextBridge.exposeInMainWorld("fin",p),e.contextBridge.exposeInMainWorld("e2o",p)):window.fin=window.e2o=p,((t,s)=>{Array.isArray(s)&&s.length&&s.forEach((s=>{((t,s)=>{let{error:n}=s;s.src&&e.webFrame.executeJavaScript(s.src).catch((e=>{const n=`Error running preload ${s.url} in ${t}: ${e}`;console.error(n),F.error(n)})),n&&(console.error(n),F.error(n))})(t,s)}))})(n,c)})(S),console.log(`Completed e2o.js preload for window ${S.windowName}`)})()})();
|
|
1
|
+
(()=>{"use strict";var e={342:(e,t,s)=>{!function(){var t,n,o,r=0,i=[];for(n=0;n<256;n++)i[n]=(n+256).toString(16).substr(1);function a(){var e=(16,(!t||r+16>d.BUFFER_SIZE)&&(r=0,t=d.randomBytes(d.BUFFER_SIZE)),t.slice(r,r+=16));return e[6]=15&e[6]|64,e[8]=63&e[8]|128,e}function d(){var e=a();return i[e[0]]+i[e[1]]+i[e[2]]+i[e[3]]+"-"+i[e[4]]+i[e[5]]+"-"+i[e[6]]+i[e[7]]+"-"+i[e[8]]+i[e[9]]+"-"+i[e[10]]+i[e[11]]+i[e[12]]+i[e[13]]+i[e[14]]+i[e[15]]}d.BUFFER_SIZE=4096,d.bin=a,d.clearBuffer=function(){t=null,r=0},d.test=function(e){return"string"==typeof e&&/^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(e)},"undefined"!=typeof crypto?o=crypto:"undefined"!=typeof window&&void 0!==window.msCrypto&&(o=window.msCrypto),o=o||s(982),e.exports=d,d.randomBytes=function(){if(o){if(o.randomBytes)return o.randomBytes;if(o.getRandomValues)return"function"!=typeof Uint8Array.prototype.slice?function(e){var t=new Uint8Array(e);return o.getRandomValues(t),Array.from(t)}:function(e){var t=new Uint8Array(e);return o.getRandomValues(t),t}}return function(e){var t,s=[];for(t=0;t<e;t++)s.push(Math.floor(256*Math.random()));return s}}()}()},982:e=>{e.exports=require("crypto")}},t={};function s(n){var o=t[n];if(void 0!==o)return o.exports;var r=t[n]={exports:{}};return e[n](r,r.exports,s),r.exports}s.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return s.d(t,{a:t}),t},s.d=(e,t)=>{for(var n in t)s.o(t,n)&&!s.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},s.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);const n=require("electron");class o{constructor(e){e&&e.send?this.ipc=e:console.log("FEA LoggerRender using console output by default")}send(e,t){this.ipc?this.ipc.send("logger:message",{level:e,args:t}):("verbose"===e&&(e="debug"),console[e]?console[e]("FEA logger:message",t):console.warn(`FEA logger:message: level: ${e} not defined. defaulting to warn. `,t))}error(...e){this.send("error",e)}warn(...e){this.send("warn",e)}info(...e){this.send("info",e)}log(...e){this.send("log",e)}debug(...e){this.send("debug",e)}verbose(...e){this.send("verbose",e)}}let r;const i=()=>{if(r)return r;try{r=new o(n.ipcRenderer)}catch(e){r=console,r.verbose=r.debug,r.error(`Failed to instantiate LoggerRenderer ${e.message}`)}return r},a=require("events");var d=s(342),c=s.n(d);let u,p=!1;class l extends a.EventEmitter{constructor(){super(),this.request={},n.ipcRenderer.on("systemResponse",this.systemResponse.bind(this)),n.ipcRenderer.on("handleResponse",this.handleResponse.bind(this)),n.ipcRenderer.on("pong",(()=>{clearTimeout(u),p=!0})),u=setInterval((()=>{n.ipcRenderer.send("ping")}),5)}handleResponse(e,t){if(!t||!this.request[t.responseUUID])return void console.warn(`Event object not found in handleResponse: event ${e} data ${t&&JSON.stringify(t)}`);const{responseUUID:s,response:n,err:o}=t,r=this.request[s],i=r.responseUUID;o&&console.error(o),r.persistChannel||delete this.request[i],r.functionCB(r,n)}promisifiedSendRequest(e){return new Promise((t=>{this.sendRequest(e,((e,s)=>t(s)))}))}sendRequest(e,t=Function.prototype){const{topic:s,data:o,persistChannel:r}=e,i=c()(),a={topic:s,data:o,persistChannel:r,responseUUID:i,functionCB:t},d=e=>{const t=e.responseUUID;this.request[t]=e;const r={topic:s,data:o};n.ipcRenderer.send("e2o.mainRequest",JSON.parse(JSON.stringify(r)),t)};let u;p?d(a):u=setInterval((()=>{p&&(clearInterval(u),d(a))}),5)}systemResponse(e,t){let s;try{s=JSON.parse(t.data)}catch(e){s=t.data}this.emit(t.topic,s)}addListener(e,t){const s=this.listenerCount(e);return super.addListener(e,t),0===s&&n.ipcRenderer.send("system.addListener",e),this}removeListener(e,t){return super.removeListener(e,t),0===this.listenerCount(e)&&n.ipcRenderer.send("system.removeListener",e),this}}const h=new l,m=i(),w=e=>"object"==typeof e&&e&&e.error?(console.log("Warning:",e.message),m.warn("Warning:",e.message),!0):!("string"!=typeof e||!e.includes("api_access_denied")||(console.log("Warning:",e),m.warn("Warning:",e),0)),g=i();class b extends a.EventEmitter{constructor(e){var t,s;if(super(),this.uuid="fin.desktop.Window.uuid has been deprecated",this.closeRequestedListeners=[],this.isMoving=!1,this.animationId=0,this.bindAllFunctions(),this.manifest=e.manifest,this.name=e.windowName,this.webContentsName=e.webContentsName,this.webContentsId=e.webContentsId,g.info("Constructing `Window` object in Window.ts",this.name),!this.name)throw new Error("Window being created without a name. This is not allowed.");const n=null===(s=null===(t=this.manifest)||void 0===t?void 0:t["finsemble-electron-adapter"])||void 0===s?void 0:s.useDOMBasedMovement;this.useDOMMovement="darwin"===process.platform||null==n||n}attachToMainWindow(){n.ipcRenderer.on(`windowEvent-${this.name}`,this.remoteFSBLEvents.bind(this))}wrap(e,t){t&&(e=t),g.verbose(`Wrapping window ${e}`);const{err:s,data:o}=n.ipcRenderer.sendSync("fea.getWindowIdentityForWindowName",e);if(s||!o)throw`Window.wrap() failed for ${e}. ${s}`;const r=new b({manifest:this.manifest,windowName:e,webContentsName:o.webContentsName,webContentsId:o.id});return r.attachToMainWindow(),r}static spawnPhysicalWindow(e){return new Promise((t=>{const s=e.name;let n=!1;g.verbose(`spawnPhysicalWindow ${s}`);const o=setTimeout((()=>{const e=`Window ${s}: spawn is taking an unusually long time (>5 seconds, it will timeout at 90 seconds)`;g.warn(e)}),5e3),r=setTimeout((()=>{n=!0;const e=`Window ${s}: spawn failed to return within 90 seconds`;g.error(e),t({err:e})}),9e4);g.debug(`Window ${s}: spawning`),h.sendRequest({topic:"-SpawnWindow",data:e},((e,i)=>{n?g.debug(`Late spawn window response from main process (after 5 sec) for ${s}: `,i):(clearTimeout(o),clearTimeout(r),"ErrorResponse"!==i.type?(g.debug(`Window ${s}: spawn complete`),t({})):t({err:i.payload.err}))}))}))}async createNew(e,t){const{err:s}=await b.spawnPhysicalWindow(e);if(s)return null==t||t(s),{err:s};const n=new b(Object.assign({},e));return n.attachToMainWindow(),null==t||t(null,n),{data:n}}bindAllFunctions(){const e=this;for(const t of Object.getOwnPropertyNames(Object.getPrototypeOf(e))){const s=e[t];s instanceof Function&&s!==b&&(e[t]=e[t].bind(e))}}addEventListener(e,t){this.addListener(e,t)}addBrowserView(e,t){h.sendRequest({topic:`${this.name}-addBrowserView`,data:e},((e,s)=>{w(s),t(s)}))}setViewBounds(e,t,s){const n={type:"window",bounds:{x:t.left,y:t.top,width:t.width,height:t.height},viewId:e};h.sendRequest({topic:`${this.name}-setViewBounds`,data:n},((e,t)=>{t.bounds&&(t.bounds.left=t.bounds.x,t.bounds.top=t.bounds.y),w(t)?s(t):s(t.bounds)}))}bringViewToFront(e,t){h.sendRequest({topic:`${this.name}-bringViewToFront`,data:{viewId:e}},((e,s)=>{w(s)?t(s):t(null)}))}addListener(e,t){const s=`Window.addListener.${e}`;return g.verbose(`Adding listener ${e}, ${this.name}`),h.sendRequest({topic:"checkPermission",data:s},((s,n)=>{if(n)if("close-requested"==e){this.closeRequestedAdd(t);const s=(...e)=>{const s=this,n={eventCancelled:!1,cancel:function(){this.eventCancelled=!0},wait:()=>{},done:function(){this.eventCancelled||s.close(!0)},data:JSON.stringify(e)};t(n)};h.addListener(`windowEvent-${this.name}.${e}`,s)}else h.addListener(`windowEvent-${this.name}.${e}`,t);else g.warn(`PERMISSION DENIED: Attempted to add listener on Window.${this.name}.${e}.`)})),this}blur(e=Function.prototype){h.sendRequest({topic:`${this.name}-blur`},((t,s)=>{w(s),e(s)}))}bringToFront(e=Function.prototype){h.sendRequest({topic:`${this.name}-bringToFront`},((t,s)=>{w(s),e(s)}))}close(e=!1,t=Function.prototype){const s={force:e};h.sendRequest({topic:`${this.name}-close`,data:s},((e,s)=>{w(s),t(s)}))}closeRequestedAdd(e){0===this.closeRequestedListeners.length&&h.sendRequest({topic:`${this.name}-closeRequestedAdd`},((e,t)=>{w(t)||g.debug(`${this.name}-closeRequestedAdd`)})),this.closeRequestedListeners.push(e)}closeRequestedRemove(e){const t=this.closeRequestedListeners.indexOf(e);t>-1&&this.closeRequestedListeners.splice(t,1),0===this.closeRequestedListeners.length&&h.sendRequest({topic:`${this.name}-closeRequestedRemove`},((e,t)=>{w(t)||g.debug(`${this.name}-closeRequestedRemove`)}))}disableFrame(e=Function.prototype){h.sendRequest({topic:`${this.name}-disableFrame`},((t,s)=>{w(s),e(s)}))}enableFrame(e=Function.prototype){h.sendRequest({topic:`${this.name}-enableFrame`},((t,s)=>{w(s),e(s)}))}focus(e=Function.prototype){h.sendRequest({topic:`${this.name}-focus`},((t,s)=>{w(s),e(s)}))}focusTitleBarWindow(e=Function.prototype){h.sendRequest({topic:`${this.name}-focus`,data:{titleBarWindow:!0}},((t,s)=>{w(s),e(s)}))}getBounds(e=Function.prototype){h.sendRequest({topic:`${this.name}-getBounds`},((t,s)=>{w(s),e(s)}))}getBoundsFromSystem(e=Function.prototype){h.sendRequest({topic:`${this.name}-getBoundsFromSystem`},((t,s)=>{w(s),e(s)}))}getCurrent(){return this}getOptions(e=Function.prototype){h.sendRequest({topic:`${this.name}-getDetails`},((t,s)=>{w(s),e(s)}))}getSnapshot(e,t=Function.prototype){return new Promise((s=>{const n={area:e};h.sendRequest({topic:`${this.name}-getSnapshot`,data:n},((e,n)=>{w(n),t(n),s(n)}))}))}getTaskbarTitle(e=Function.prototype){h.sendRequest({topic:`${this.name}-getTaskbarTitle`},((t,s)=>{w(s),e(s)}))}hide(e=Function.prototype){h.sendRequest({topic:`${this.name}-hide`},((t,s)=>{w(s),e(s)}))}isShowing(e=Function.prototype){h.sendRequest({topic:`${this.name}-isShowing`},((t,s)=>{w(s),e(s)}))}minimize(e=Function.prototype){h.sendRequest({topic:`${this.name}-minimize`},((t,s)=>{w(s),e(s)}))}resetBrowserView(e=Function.prototype){h.sendRequest({topic:`${this.name}-resetBrowserView`},((t,s)=>{w(s),e(s)}))}removeBrowserView(e,t=Function.prototype){h.sendRequest({topic:`${this.name}-removeBrowserView`,data:{viewId:e}},((e,s)=>{w(s),t(s)}))}removeEventListener(e,t){this.removeListener(e,t)}removeListener(e,t){return"close-requested"==e&&this.closeRequestedRemove(t),h.removeListener(`windowEvent-${this.name}.${e}`,t),this}removeTrayIcon(e=Function.prototype){h.sendRequest({topic:"removeTrayIcon",data:{}},((e,t)=>{w(t)})),e()}setTrayIcon(e,t,s=Function.prototype){h.sendRequest({topic:"setTrayIconDeprecated",data:{iconpath:e,listeners:t?Object.keys(t):{}},persistChannel:!0},((e,s)=>{!w(s)&&t&&t.clickListener&&"click"==s.event&&(g.debug("setTrayIcon request sent"),t.clickListener(s))})),s()}maximize(e=Function.prototype){h.sendRequest({topic:`${this.name}-maximize`},((t,s)=>{w(s),e(s)}))}reload(e=Function.prototype){h.sendRequest({topic:`${this.name}-reload`},((t,s)=>{w(s),e(s)}))}restore(e=Function.prototype){h.sendRequest({topic:`${this.name}-restore`},((t,s)=>{w(s),e(s)}))}setBounds(e,t,s,n,o){const r={bounds:{x:e,y:t,width:s,height:n}};h.sendRequest({topic:`${this.name}-setBounds`,data:r},((e,t)=>{t.bounds&&(t.bounds.left=t.bounds.x,t.bounds.top=t.bounds.y),w(t)?o(t):o(t.bounds)}))}setIgnoreMouseEvents(e){h.sendRequest({topic:`${this.name}-setIgnoreMouseEvents`,data:e})}setResizable(e){h.sendRequest({topic:`${this.name}-setResizable`,data:e})}setShape(e){h.sendRequest({topic:`${this.name}-setShape`,data:e})}setTaskbarIcon(e){e||(e={}),h.sendRequest({topic:`${this.name}-setTaskbarIcon`,data:e})}setTaskbarIconOverlay(e){h.sendRequest({topic:`${this.name}-setTaskbarIconOverlay`,data:null!=e?e:{}})}setTaskbarTitle(e){h.sendRequest({topic:`${this.name}-setTaskbarTitle`,data:{title:e}})}showNativeOpenDialog(e,t){h.sendRequest({topic:`${this.name}-showNativeOpenDialog`,data:e},((e,s)=>t(s)))}show(e=Function.prototype){h.sendRequest({topic:`${this.name}-show`},((t,s)=>{w(s),e(s)}))}showAt(e,t,s,n=Function.prototype){const o={left:e,top:t};h.sendRequest({topic:`${this.name}-showAt`,data:o},((e,t)=>{w(t),n(t)}))}setMinimumSize(e,t,s=Function.prototype){const n={size:{width:e,height:t}};h.sendRequest({topic:`${this.name}-setMinimumSize`,data:n},((e,t)=>{w(t),s(t)}))}setMaximumSize(e=null,t=null,s=Function.prototype){const n={size:{width:e,height:t}};h.sendRequest({topic:`${this.name}-setMaximumSize`,data:n},((e,t)=>{w(t),s(t)}))}updateOptions(e,t=Function.prototype){const s={options:e};h.sendRequest({topic:`${this.name}-updateOptions`,data:s},((e,s)=>{w(s),t(s)}))}remoteFSBLEvents(e,t){this.emit(t.topic,t.data)}animate(e,t=Function.prototype){t&&"function"==typeof t&&t()}setAsForeground(e){this.bringToFront((()=>this.focus((()=>e()))))}startMovingWindow(e){this.mouseX=e.clientX,this.mouseY=e.clientY,this.isMoving=!0,h.sendRequest({topic:`${this.name}-windowMouseDown`});const t=()=>{this.isMoving&&(h.sendRequest({topic:`${this.name}-windowMoving`,data:{mouseX:this.mouseX,mouseY:this.mouseY}}),this.animationId=requestAnimationFrame(t))};this.animationId=requestAnimationFrame(t)}stopMovingWindow(){this.isMoving=!1,h.sendRequest({topic:`${this.name}-windowMoved`}),cancelAnimationFrame(this.animationId)}}const R=i();class f{constructor(){this.availableFormats=this.availableFormats.bind(this),this.writeText=this.writeText.bind(this),this.writeHTML=this.writeHTML.bind(this),this.writeRTF=this.writeRTF.bind(this),this.readText=this.readText.bind(this),this.readHTML=this.readHTML.bind(this),this.readRTF=this.readRTF.bind(this),this.write=this.write.bind(this)}availableFormats(e=Function.prototype,t=Function.prototype){h.sendRequest({topic:"availableFormatsFromClipboard"},((s,n)=>{if(!w(n))return"error"===n.status?(R.error(`Error fetching available formats from clipboard - ${n.message}`),t(n)):void e(n.value);t(n)}))}writeText(e,t=Function.prototype,s=Function.prototype){h.sendRequest({topic:"writeTextToClipboard",data:e},((e,n)=>{if(!w(n))return"error"===n.status?(R.error(`Clipboard writeText error: ${n.message}`),s(n)):void t(n);s(n)}))}writeHTML(e,t=Function.prototype,s=Function.prototype){h.sendRequest({topic:"writeHTMLToClipboard",data:e},((e,n)=>{if(!w(n))return"error"===n.status?(R.error(`Clipboard writeHTML error: ${n.message}`),s(n)):void t(n);s(n)}))}writeRTF(e,t=Function.prototype,s=Function.prototype){h.sendRequest({topic:"writeRTFToClipboard",data:e},((e,n)=>{if(!w(n))return"error"===n.status?(R.error(`Clipboard writeRTF error: ${n.message}`),s(n)):void t(n);s(n)}))}write(e,t=Function.prototype,s=Function.prototype){h.sendRequest({topic:"writeToClipboard",data:e},((n,o)=>{if(!w(o))return"error"===o.status?(R.error(`Clipboard write error: ${o.message}`),s(o)):void t(e);s(e)}))}readText(e=Function.prototype,t=Function.prototype){h.sendRequest({topic:"readTextFromClipboard"},((s,n)=>{if(!w(n))return"error"===n.status?(R.error(`Error reading text from clipboard - ${n.message}`),t(n)):void e(n.value);t(n)}))}readHTML(e=Function.prototype,t=Function.prototype){h.sendRequest({topic:"readHTMLFromClipboard"},((s,n)=>{if(!w(n))return"error"===n.status?(R.error(`Error reading html from clipboard - ${n.message}`),t(n)):void e(n.value);t(n)}))}readRTF(e=Function.prototype,t=Function.prototype){h.sendRequest({topic:"readRTFFromClipboard"},((s,n)=>{if(!w(n))return"error"===n.status?(R.error(`Error reading RTF from clipboard - ${n.message}`),t(n)):void e(n.value);t(n)}))}}class y{constructor(){this.register=this.register.bind(this),this.isRegistered=this.isRegistered.bind(this),this.unregister=this.unregister.bind(this),this.listeners={}}register(e,t,s=Function.prototype,n=Function.prototype){h.sendRequest({topic:"registerGlobalShortcut",data:e},((o,r)=>{if(!w(r))return"error"===r.status?(R.error(`GlobalShortcut register error: ${r.message}`),n(r)):(r.value?(h.addListener(`globalShortcut.${e}`,t),R.verbose(`Added listener: globalShortcut.${e}`),this.listeners[e]=t):R.verbose(`Shortcut could not be registered: GlobalShortcut ${e} already exists in some application, possibly outside of Finsemble`),void s(r.value));n(r)}))}isRegistered(e,t=Function.prototype,s=Function.prototype){h.sendRequest({topic:"isRegisteredGlobalShortcut",data:e},((e,n)=>{if(!w(n))return"error"===n.status?(R.error(`GlobalShortcut isRegistered error: ${n.message}`),s(n)):void t(n.value);s(n)}))}unregister(e,t=Function.prototype,s=Function.prototype){h.sendRequest({topic:"unregisterGlobalShortcut",data:e},((n,o)=>{if(!w(o)){if("error"===o.status)return R.error(`GlobalShortcut unregister error: ${o.message}`),s(o);const n=this.listeners[e];return"function"==typeof n&&h.removeListener(`globalShortcut.${e}`,n),delete this.listeners[e],void t(o)}s(o)}))}}class v extends a.EventEmitter{constructor(){super(),this.bindAllFunctions(),this.addEventListener=this.addListener.bind(this),this.removeEventListener=this.removeListener.bind(this),this.Clipboard=new f,this.GlobalShortcut=new y,n.ipcRenderer.on("systemEvent",((e,t)=>{this.emit(t.event,t.data)}))}bindAllFunctions(){const e=this;for(const t of Object.getOwnPropertyNames(Object.getPrototypeOf(e))){const s=e[t];s instanceof Function&&s!==v&&(e[t]=e[t].bind(e))}}addListener(e,t){const s=`System.addListener.${e}`;return h.sendRequest({topic:"checkPermission",data:s},((s,n)=>{n?(h.addListener(`systemEvent.${e}`,t),R.verbose(`Added listener: systemEvent.${e}`)):R.warn(`PERMISSION DENIED: Attempted to add listener on SystemEvent.${e}.`)})),this}addSelectClientCertificateListener(e){const t=c()(),s=e=>{h.sendRequest({topic:`picked-client-certificate.${t}`,data:{certificate:e}},((e,t)=>{w(t)}))};h.sendRequest({topic:"select-client-certificate",data:{id:t}},((n,o)=>{w(o),h.addListener(`pick-client-certificate.${t}`,(t=>{const{url:n,list:o}=t;e(n,o,s)}))}))}addCertificateErrorListener(e){const t=c()(),s=e=>{h.sendRequest({topic:`allow-or-disallow-page.${t}`,data:{allowOrDisallow:e}},((e,t)=>{w(t)}))};h.sendRequest({topic:"certificate-error.subscribe",data:{id:t}},((n,o)=>{w(o),h.addListener(`possibly-override-certificate-error.${t}`,(t=>{const{url:n,error:o,certificate:r}=t;e(n,o,r,s)}))}))}clearCache(e){h.sendRequest({topic:"clearCache",data:e},((e,t)=>{w(t)}))}exit(){h.sendRequest({topic:"-terminate",data:null},((e,t)=>{w(t)}))}flushStorage(){return h.sendRequest({topic:"flushStorage"},((e,t)=>{w(t)}))}async getManifest(e){const t=await h.promisifiedSendRequest({topic:"-getManifest",data:{type:"application"}});return w(t),null==e||e(t),t}hideSplashScreen(){return h.sendRequest({topic:"hideSplashScreen"})}notifyLoggerReady(){h.sendRequest({topic:"central-logger-ready"})}updateCentralLoggerState(e){h.sendRequest({topic:"central-logger-state-changed",data:e})}getEnvironmentVariable(e,t=Function.prototype,s=Function.prototype){return h.sendRequest({topic:"getEnvironmentVariable",data:{variableName:e}},((e,n)=>{"error"===n.status?(R.error(`getEnvironmentVariable Error: ${n.message}`),s(n)):(R.debug("getEnvironmentVariable response received."),t(n.value))}))}deleteAssets(e){return new Promise((t=>{h.sendRequest({topic:"deleteAssets",data:e},((e,s)=>{var n;w(s),t({err:null!==(n=s.err)&&void 0!==n?n:s.error})}))}))}getSDServerInfo(e){return h.sendRequest({topic:"getSDServerInfo"},((t,s)=>{w(s),e(s)}))}getHostSpecs(e){return h.sendRequest({topic:"getHostSpecs"},((t,s)=>{w(s),e(s)}))}getMonitorInfo(e){return h.sendRequest({topic:"getMonitorInfo"},((t,s)=>{w(s)?e(s):(e(s.monitorInfo),R.verbose("getMonitorInfo request sent."))}))}getMousePosition(e){return h.sendRequest({topic:"getMousePosition"},((t,s)=>{w(s),e(s)}))}getProcessList(e){return new Promise((t=>{h.sendRequest({topic:"getProcessList",data:{}},((s,n)=>{w(n),e(n),t(n)}))}))}getDownloadList(e){return new Promise((t=>{h.sendRequest({topic:"getDownloadList",data:{}},((s,n)=>{w(n),e(n),t(n)}))}))}removeDownloadItem(e){return new Promise((t=>{h.sendRequest({topic:"removeDownloadItem",data:e},((e,s)=>{w(s),t(s)}))}))}cancelDownload(e,t=Function.prototype){return h.sendRequest({topic:"cancelDownload",data:e},((e,s)=>{w(s),t()}))}pauseDownload(e,t=Function.prototype){return h.sendRequest({topic:"pauseDownload",data:e},((e,s)=>{w(s),t()}))}resumeDownload(e,t=Function.prototype){return h.sendRequest({topic:"resumeDownload",data:e},((e,s)=>{w(s),t()}))}setDownloadSavePath(e,t=Function.prototype){return h.sendRequest({topic:"setDownloadSavePath",data:e},((e,s)=>{w(s),t()}))}clearDownloadList(e=Function.prototype){return h.sendRequest({topic:"clearDownloadList",data:{}},((t,s)=>{w(s),e()}))}showDownloadedFileInFolder(e,t=Function.prototype){return h.sendRequest({topic:"showDownloadedFileInFolder",data:e},((e,s)=>{w(s),t()}))}getVersion(e){return console.log("fin.desktop.System.getVersion() is deprecated. Please use getFEAInfo()."),h.sendRequest({topic:"getVersion"},((t,s)=>{w(s),e(s)}))}getUpdateAvailable(e){return h.sendRequest({topic:"getUpdateAvailable"},((t,s)=>{w(s),e(s)}))}getFEAInfo(e){return h.sendRequest({topic:"getFEAInfo"},((t,s)=>{w(s),e(s)}))}startupApplicationHandshake(){return h.sendRequest({topic:"startupApplicationHandshake"},((e,t)=>{w(t)}))}launchExternalProcess(e,t,s){h.sendRequest({topic:"launchExternalProcess",data:e},((e,n)=>{"error"===n.status?(R.error(`launchExternalProcess: ${n.message}`),null==s||s({status:"error",message:n.error,code:"launch_fail"})):(R.debug("launchExternalProcess request sent."),t(n))}))}openUrlWithBrowser(e,t){return h.sendRequest({topic:"openUrlWithBrowser",data:e},((e,s)=>{w(s),null==t||t(s)}))}removeListener(e,t){return h.removeListener(`systemEvent.${e}`,t),this}showDeveloperTools(e,t=!0,s=Function.prototype){return R.log("System.showDeveloperTools()",e,t),h.sendRequest({topic:`${e}-showDeveloperTools`,data:{name:e,viewId:t,autoPick:!0===t}},((e,t)=>{w(t),s()}))}restart(){h.sendRequest({topic:"restartApplication",data:{}},((e,t)=>{w(t)}))}terminate(){R.log("Render: terminate called for application"),h.sendRequest({topic:"-terminate",data:null},((e,t)=>{w(t)}))}getProtocolString(e){return new Promise((t=>{h.sendRequest({topic:"getProtocolString"},((s,n)=>{t(n),e&&e(n)}))}))}getCommandLineArguments(e=Function.prototype){return h.sendRequest({topic:"getCommandLineArguments"},((t,s)=>{w(s),e(s)}))}async getScreenShareSources(e={}){const t=Object.assign({types:["window","screen"]},e),s=await h.promisifiedSendRequest({topic:"getScreenShareSources",data:t});if(w(s),"error"===s.status)throw R.error(`Error getting ScreenShare sources - ${s.message}`),`Error getting ScreenShare sources - ${s.message}`;return s.value}async getScreenShot(e=null){if(!e)try{if(!(e=(await this.getScreenShareSources()).filter((e=>"Entire Screen"===e.name||"Screen 1"===e.name))[0].id))throw"Not found"}catch(e){throw new Error("Error capturing screenshot: Unable to Find a screen. Please specify a valid sourceId from the sources returned by getScreenShareSources")}try{const t=await navigator.mediaDevices.getUserMedia({audio:!1,video:{mandatory:{chromeMediaSource:"desktop",chromeMediaSourceId:e,minWidth:1280,maxWidth:4e3,minHeight:720,maxHeight:4e3}}});return await(e=>new Promise((t=>{const s=e.getVideoTracks()[0].getSettings(),n=document.createElement("video");n.style.cssText="position:absolute;top:-10000px;left:-10000px;",n.onloadedmetadata=function(){n.style.height=`${s.height}px`,n.style.width=`${s.width}px`,n.play();const o=document.createElement("canvas");o.height=s.height||0,o.width=s.width||0;const r=o.getContext("2d");null==r||r.drawImage(n,0,0,o.width,o.height),t(o.toDataURL("image/png")),n.remove();try{e.getTracks()[0].stop()}catch(e){}},n.srcObject=e,document.body.appendChild(n)})))(t)}catch(e){throw new Error(`Error capturing screenshot: ${e}`)}}setTrayIcon(e,t=Function.prototype){h.sendRequest({topic:"setTrayIcon",data:{url:e}},((e,s)=>{w(s),t()}))}subscribeToWindowEventStream(e){n.ipcRenderer.addListener("e2o.WindowEventStream",((t,s)=>{e(s)})),n.ipcRenderer.send("e2o.SubscribeToWindowEventStream")}logToDisk(e,...t){h.sendRequest({topic:"logToDisk",data:{level:e,messages:t}},((e,t)=>{w(t)}))}}const q={send:e=>{h.sendRequest({topic:"notification",data:e},((e,t)=>{w(t)}))}},F=i();class $ extends a.EventEmitter{constructor(){super(),this.subscribers={},this.bindAllFunctions(),this.setUpListeners()}bindAllFunctions(){const e=this;for(const t of Object.getOwnPropertyNames(Object.getPrototypeOf(e))){const s=e[t];s instanceof Function&&s!==$&&(e[t]=e[t].bind(e))}}setUpListeners(){n.ipcRenderer.on("subscribeResponse",this.onSubscribeResponse.bind(this)),n.ipcRenderer.on("subscribeResponseError",((e,t)=>{w(t)})),n.ipcRenderer.on("unSubscribeResponseError",((e,t)=>{w(t)})),n.ipcRenderer.on("publishResponseError",((e,t)=>{w(t)}))}onSubscribeResponse(e,t){const s=this.subscribers[t.listenerID];null==s||s(t.data)}publish(e,t,s,o){try{n.ipcRenderer.send("e2o.iab.publish",{destination:e,data:t}),null==s||s()}catch(t){F.warn(`Publish to ${e} failed. ${t.message}`),null==o||o(t)}}subscribe(e,t,s,o=Function.prototype,r=Function.prototype){try{const e=c()();return n.ipcRenderer.send("e2o.iab.subscribe",{listenerID:e,source:t}),this.subscribers[e]=s,null==o||o(),e}catch(e){return F.warn(`Subscribing for ${t} failed. ${e.message}`),r(e),null}}unsubscribe(e){n.ipcRenderer.send("e2o.iab.unsubscribe",{listenerID:e}),e&&delete this.subscribers[e]}}console.log("Running e2o.js preload");const S=i(),{err:T,data:E}=n.ipcRenderer.sendSync("fea.getWindowIdentity");if(T||!E){const e=`Error loading e2o.js preload: ${T}`;console.error(e),S.error(e)}else(e=>{const{id:t,windowName:s,webContentsName:o,isView:r,isTitlebarWindow:i,manifest:a,contextIsolation:d,preloads:c}=e;r||console.log("This is the devtools for the BrowserWindow object (titlebar shell). Use the central logger to access the devtools for the BrowserView (app content)."),d?n.contextBridge.exposeInMainWorld("finsemble",!0):window.finsemble=!0,n.webFrame.executeJavaScript(`window.name = ${JSON.stringify(s)}`);const u=new b({windowName:s,webContentsName:o,webContentsId:t,manifest:a});u.attachToMainWindow();const p={hasBrowserView:()=>(console.log("hasBrowserView() is deprecated. Use isTitlebarWindow()"),i),getViewId:()=>(console.log("getViewId() is deprecated. Use getWebContentsId()"),null!=t?t:null),isBrowserView:()=>r,isTitlebarWindow:()=>i,getWebContentsId:()=>null!=t?t:null,desktop:{main:e=>{console.log("fin.desktop.main has been deprecated. It is no longer necessary to wait before using fin."),e()},InterApplicationBus:new $,Notification:q,System:new v,Window:u}};d?(n.contextBridge.exposeInMainWorld("fin",p),n.contextBridge.exposeInMainWorld("e2o",p)):window.fin=window.e2o=p,((e,t)=>{Array.isArray(t)&&t.length&&t.forEach((t=>{((e,t)=>{let{error:s}=t;t.src&&n.webFrame.executeJavaScript(t.src).catch((s=>{const n=`Error running preload ${t.url} in ${e}: ${s}`;console.error(n),S.error(n)})),s&&(console.error(s),S.error(s))})(e,t)}))})(s,c)})(E),console.log(`Completed e2o.js preload for window ${E.windowName}`)})();
|
|
2
2
|
//# sourceMappingURL=e2o.js.map
|