@neutralinojs/lib
Advanced tools
Comparing version 5.0.0 to 5.0.1
@@ -0,1 +1,41 @@ | ||
declare global { | ||
interface Window { | ||
/** Mode of the application: window, browser, cloud, or chrome */ | ||
NL_MODE: string; | ||
/** Application port */ | ||
NL_PORT: number; | ||
/** Command-line arguments */ | ||
NL_ARGS: string[]; | ||
/** Basic authentication token */ | ||
NL_TOKEN: string; | ||
/** Neutralinojs client version */ | ||
NL_CVERSION: string; | ||
/** Application identifier */ | ||
NL_APPID: string; | ||
/** Application version */ | ||
NL_APPVERSION: string; | ||
/** Application path */ | ||
NL_PATH: string; | ||
/** Returns true if extensions are enabled */ | ||
NL_EXTENABLED: boolean; | ||
/** Operating system name: Linux, Windows, Darwin, FreeBSD, or Uknown */ | ||
NL_OS: string; | ||
/** CPU architecture: x64, arm, itanium, ia32, or unknown */ | ||
NL_ARCH: string; | ||
/** Neutralinojs server version */ | ||
NL_VERSION: string; | ||
/** Current working directory */ | ||
NL_CWD: string; | ||
/** Identifier of the current process */ | ||
NL_PID: string; | ||
/** Source of application resources: bundle or directory */ | ||
NL_RESMODE: string; | ||
/** Release commit of the client library */ | ||
NL_CCOMMIT: string; | ||
/** An array of custom methods */ | ||
NL_CMETHODS: string[]; | ||
} | ||
/** Neutralino global object for custom methods **/ | ||
const Neutralino: any; | ||
} | ||
declare namespace filesystem { | ||
@@ -2,0 +42,0 @@ interface DirectoryEntry { |
@@ -1,1 +0,1 @@ | ||
"use strict";function e(e,t,n,o){return new(n||(n=Promise))((function(r,i){function s(e){try{c(o.next(e))}catch(e){i(e)}}function a(e){try{c(o.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((o=o.apply(e,t||[])).next())}))}function t(){return l("extensions.getStats")}Object.defineProperty(exports,"__esModule",{value:!0});var n=Object.freeze({__proto__:null,dispatch:function(n,o,r){return new Promise(((i,s)=>e(this,void 0,void 0,(function*(){let e=yield t();if(e.loaded.includes(n))if(e.connected.includes(n))try{let e=yield l("extensions.dispatch",{extensionId:n,event:o,data:r});i(e)}catch(e){s(e)}else!function(e,t){e in u?u[e].push(t):u[e]=[t]}(n,{method:"extensions.dispatch",data:{extensionId:n,event:o,data:r},resolve:i,reject:s});else s({code:"NE_EX_EXTNOTL",message:`${n} is not loaded`})}))))},broadcast:function(e,t){return l("extensions.broadcast",{event:e,data:t})},getStats:t});function o(e,t){return window.addEventListener(e,t),Promise.resolve({success:!0,message:"Event listener added"})}function r(e,t){let n=new CustomEvent(e,{detail:t});return window.dispatchEvent(n),Promise.resolve({success:!0,message:"Message dispatched"})}function i(e){let t=window.atob(e),n=t.length,o=new Uint8Array(n);for(let e=0;e<n;e++)o[e]=t.charCodeAt(e);return o.buffer}let s,a={},c=[],u={};function d(){window.NL_TOKEN&&sessionStorage.setItem("NL_TOKEN",window.NL_TOKEN);const n=p().split(".")[1];s=new WebSocket(`ws://${window.location.hostname}:${window.NL_PORT}?connectToken=${n}`),function(){if(o("ready",(()=>e(this,void 0,void 0,(function*(){if(yield f(c),!window.NL_EXTENABLED)return;let e=yield t();for(let t of e.connected)r("extensionReady",t)})))),o("extClientConnect",(e=>{r("extensionReady",e.detail)})),!window.NL_EXTENABLED)return;o("extensionReady",(t=>e(this,void 0,void 0,(function*(){t.detail in u&&(yield f(u[t.detail]),delete u[t.detail])}))))}(),function(){s.addEventListener("message",(e=>{var t,n,o;const c=JSON.parse(e.data);c.id&&c.id in a?((null===(t=c.data)||void 0===t?void 0:t.error)?(a[c.id].reject(c.data.error),"NE_RT_INVTOKN"==c.data.error.code&&(s.close(),document.body.innerText="",document.write("<code>NE_RT_INVTOKN</code>: Neutralinojs application cannot execute native methods since <code>NL_TOKEN</code> is invalid."))):(null===(n=c.data)||void 0===n?void 0:n.success)&&a[c.id].resolve(c.data.hasOwnProperty("returnValue")?c.data.returnValue:c.data),delete a[c.id]):c.event&&("openedFile"==c.event&&"dataBinary"==(null===(o=null==c?void 0:c.data)||void 0===o?void 0:o.action)&&(c.data.data=i(c.data.data)),r(c.event,c.data))})),s.addEventListener("open",(t=>e(this,void 0,void 0,(function*(){r("ready")})))),s.addEventListener("close",(t=>e(this,void 0,void 0,(function*(){r("serverOffline",{code:"NE_CL_NSEROFF",message:"Neutralino server is offline. Try restarting the application"})})))),s.addEventListener("error",(t=>e(this,void 0,void 0,(function*(){document.body.innerText="",document.write("<code>NE_CL_IVCTOKN</code>: Neutralinojs application cannot connect with the framework core using <code>NL_TOKEN</code>.")}))))}()}function l(e,t){return new Promise(((n,o)=>{if((null==s?void 0:s.readyState)!=WebSocket.OPEN)return r={method:e,data:t,resolve:n,reject:o},void c.push(r);var r;const i="10000000-1000-4000-8000-100000000000".replace(/[018]/g,(e=>(e^crypto.getRandomValues(new Uint8Array(1))[0]&15>>e/4).toString(16))),u=p();a[i]={resolve:n,reject:o},s.send(JSON.stringify({id:i,method:e,data:t,accessToken:u}))}))}function f(t){return e(this,void 0,void 0,(function*(){for(;t.length>0;){let e=t.shift();try{let t=yield l(e.method,e.data);e.resolve(t)}catch(t){e.reject(t)}}}))}function p(){return window.NL_TOKEN||sessionStorage.getItem("NL_TOKEN")||""}function w(e,t){return l("filesystem.writeBinaryFile",{path:e,data:g(t)})}function g(e){let t=new Uint8Array(e),n="";for(let e of t)n+=String.fromCharCode(e);return window.btoa(n)}var m,v,_=Object.freeze({__proto__:null,createDirectory:function(e){return l("filesystem.createDirectory",{path:e})},remove:function(e){return l("filesystem.remove",{path:e})},writeFile:function(e,t){return l("filesystem.writeFile",{path:e,data:t})},appendFile:function(e,t){return l("filesystem.appendFile",{path:e,data:t})},writeBinaryFile:w,appendBinaryFile:function(e,t){return l("filesystem.appendBinaryFile",{path:e,data:g(t)})},readFile:function(e,t){return l("filesystem.readFile",Object.assign({path:e},t))},readBinaryFile:function(e,t){return new Promise(((n,o)=>{l("filesystem.readBinaryFile",Object.assign({path:e},t)).then((e=>{n(i(e))})).catch((e=>{o(e)}))}))},openFile:function(e){return l("filesystem.openFile",{path:e})},createWatcher:function(e){return l("filesystem.createWatcher",{path:e})},removeWatcher:function(e){return l("filesystem.removeWatcher",{id:e})},getWatchers:function(){return l("filesystem.getWatchers")},updateOpenedFile:function(e,t,n){return l("filesystem.updateOpenedFile",{id:e,event:t,data:n})},getOpenedFileInfo:function(e){return l("filesystem.getOpenedFileInfo",{id:e})},readDirectory:function(e,t){return l("filesystem.readDirectory",Object.assign({path:e},t))},copy:function(e,t){return l("filesystem.copy",{source:e,destination:t})},move:function(e,t){return l("filesystem.move",{source:e,destination:t})},getStats:function(e){return l("filesystem.getStats",{path:e})}});function h(e,t){return l("os.execCommand",Object.assign({command:e},t))}!function(e){e.WARNING="WARNING",e.ERROR="ERROR",e.INFO="INFO",e.QUESTION="QUESTION"}(m||(m={})),function(e){e.OK="OK",e.OK_CANCEL="OK_CANCEL",e.YES_NO="YES_NO",e.YES_NO_CANCEL="YES_NO_CANCEL",e.RETRY_CANCEL="RETRY_CANCEL",e.ABORT_RETRY_IGNORE="ABORT_RETRY_IGNORE"}(v||(v={}));var O=Object.freeze({__proto__:null,get Icon(){return m},get MessageBoxChoice(){return v},execCommand:h,spawnProcess:function(e,t){return l("os.spawnProcess",{command:e,cwd:t})},updateSpawnedProcess:function(e,t,n){return l("os.updateSpawnedProcess",{id:e,event:t,data:n})},getSpawnedProcesses:function(){return l("os.getSpawnedProcesses")},getEnv:function(e){return l("os.getEnv",{key:e})},getEnvs:function(){return l("os.getEnvs")},showOpenDialog:function(e,t){return l("os.showOpenDialog",Object.assign({title:e},t))},showFolderDialog:function(e,t){return l("os.showFolderDialog",Object.assign({title:e},t))},showSaveDialog:function(e,t){return l("os.showSaveDialog",Object.assign({title:e},t))},showNotification:function(e,t,n){return l("os.showNotification",{title:e,content:t,icon:n})},showMessageBox:function(e,t,n,o){return l("os.showMessageBox",{title:e,content:t,choice:n,icon:o})},setTray:function(e){return l("os.setTray",e)},open:function(e){return l("os.open",{url:e})},getPath:function(e){return l("os.getPath",{name:e})}});var y=Object.freeze({__proto__:null,getMemoryInfo:function(){return l("computer.getMemoryInfo")},getArch:function(){return l("computer.getArch")},getKernelInfo:function(){return l("computer.getKernelInfo")},getOSInfo:function(){return l("computer.getOSInfo")},getCPUInfo:function(){return l("computer.getCPUInfo")},getDisplays:function(){return l("computer.getDisplays")},getMousePosition:function(){return l("computer.getMousePosition")}});var N,E=Object.freeze({__proto__:null,setData:function(e,t){return l("storage.setData",{key:e,data:t})},getData:function(e){return l("storage.getData",{key:e})},getKeys:function(){return l("storage.getKeys")}});function b(e,t){return l("debug.log",{message:e,type:t})}!function(e){e.WARNING="WARNING",e.ERROR="ERROR",e.INFO="INFO"}(N||(N={}));var R=Object.freeze({__proto__:null,get LoggerType(){return N},log:b});function T(e){return l("app.exit",{code:e})}var P=Object.freeze({__proto__:null,exit:T,killProcess:function(){return l("app.killProcess")},restartProcess:function(t){return new Promise((n=>e(this,void 0,void 0,(function*(){let e=window.NL_ARGS.reduce(((e,t)=>(t.includes(" ")&&(t=`"${t}"`),e+=" "+t)),"");(null==t?void 0:t.args)&&(e+=" "+t.args),yield h(e,{background:!0}),T(),n()}))))},getConfig:function(){return l("app.getConfig")},broadcast:function(e,t){return l("app.broadcast",{event:e,data:t})},readProcessInput:function(e){return l("app.readProcessInput",{readAll:e})},writeProcessOutput:function(e){return l("app.writeProcessOutput",{data:e})},writeProcessError:function(e){return l("app.writeProcessError",{data:e})}});const x=new WeakMap;function L(e,t){return l("window.move",{x:e,y:t})}function S(){return l("window.getSize")}var I=Object.freeze({__proto__:null,setTitle:function(e){return l("window.setTitle",{title:e})},getTitle:function(){return l("window.getTitle")},maximize:function(){return l("window.maximize")},unmaximize:function(){return l("window.unmaximize")},isMaximized:function(){return l("window.isMaximized")},minimize:function(){return l("window.minimize")},setFullScreen:function(){return l("window.setFullScreen")},exitFullScreen:function(){return l("window.exitFullScreen")},isFullScreen:function(){return l("window.isFullScreen")},show:function(){return l("window.show")},hide:function(){return l("window.hide")},isVisible:function(){return l("window.isVisible")},focus:function(){return l("window.focus")},setIcon:function(e){return l("window.setIcon",{icon:e})},move:L,center:function(){return l("window.center")},setDraggableRegion:function(t){return new Promise(((n,o)=>{const r=t instanceof Element?t:document.getElementById(t);let i=0,s=0,a=0,c=!1,u=performance.now();if(!r)return o({code:"NE_WD_DOMNOTF",message:"Unable to find DOM element"});if(x.has(r))return o({code:"NE_WD_ALRDREL",message:"This DOM element is already an active draggable region"});function d(t){return e(this,void 0,void 0,(function*(){if(c){const e=performance.now(),n=e-u;if(n<5)return;return u=e-(n-5),void(yield L(t.screenX-i,t.screenY-s))}a=Math.sqrt(t.movementX*t.movementX+t.movementY*t.movementY),a>=10&&(c=!0,r.setPointerCapture(t.pointerId))}))}function l(e){0===e.button&&(i=e.clientX,s=e.clientY,r.addEventListener("pointermove",d))}function f(e){r.removeEventListener("pointermove",d),r.releasePointerCapture(e.pointerId)}r.addEventListener("pointerdown",l),r.addEventListener("pointerup",f),x.set(r,{pointerdown:l,pointerup:f}),n({success:!0,message:"Draggable region was activated"})}))},unsetDraggableRegion:function(e){return new Promise(((t,n)=>{const o=e instanceof Element?e:document.getElementById(e);if(!o)return n({code:"NE_WD_DOMNOTF",message:"Unable to find DOM element"});if(!x.has(o))return n({code:"NE_WD_NOTDRRE",message:"DOM element is not an active draggable region"});const{pointerdown:r,pointerup:i}=x.get(o);o.removeEventListener("pointerdown",r),o.removeEventListener("pointerup",i),x.delete(o),t({success:!0,message:"Draggable region was deactivated"})}))},setSize:function(t){return new Promise(((n,o)=>e(this,void 0,void 0,(function*(){let e=yield S();l("window.setSize",t=Object.assign(Object.assign({},e),t)).then((e=>{n(e)})).catch((e=>{o(e)}))}))))},getSize:S,getPosition:function(){return l("window.getPosition")},setAlwaysOnTop:function(e){return l("window.setAlwaysOnTop",{onTop:e})},create:function(e,t){return new Promise(((n,o)=>{function r(e){return"string"!=typeof e||(e=e.trim()).includes(" ")&&(e=`"${e}"`),e}t=Object.assign(Object.assign({},t),{useSavedState:!1});let i=window.NL_ARGS.reduce(((e,t,n)=>((t.includes("--path=")||t.includes("--debug-mode")||t.includes("--load-dir-res")||0==n)&&(e+=" "+r(t)),e)),"");i+=" --url="+r(e);for(let e in t){if("processArgs"==e)continue;i+=` --window${e.replace(/[A-Z]|^[a-z]/g,(e=>"-"+e.toLowerCase()))}=${r(t[e])}`}t&&t.processArgs&&(i+=" "+t.processArgs),h(i,{background:!0}).then((e=>{n(e)})).catch((e=>{o(e)}))}))}});var D=Object.freeze({__proto__:null,broadcast:function(e,t){return l("events.broadcast",{event:e,data:t})},on:o,off:function(e,t){return window.removeEventListener(e,t),Promise.resolve({success:!0,message:"Event listener removed"})},dispatch:r});let C=null;var j=Object.freeze({__proto__:null,checkForUpdates:function(t){return new Promise(((n,o)=>e(this,void 0,void 0,(function*(){if(!t)return o({code:"NE_RT_NATRTER",message:"Missing require parameter: url"});try{let e=yield fetch(t);C=JSON.parse(yield e.text()),!function(e){return!!(e.applicationId&&e.applicationId==window.NL_APPID&&e.version&&e.resourcesURL)}(C)?o({code:"NE_UP_CUPDMER",message:"Invalid update manifest or mismatching applicationId"}):n(C)}catch(e){o({code:"NE_UP_CUPDERR",message:"Unable to fetch update manifest"})}}))))},install:function(){return new Promise(((t,n)=>e(this,void 0,void 0,(function*(){if(!C)return n({code:"NE_UP_UPDNOUF",message:"No update manifest loaded"});try{let e=yield fetch(C.resourcesURL),n=yield e.arrayBuffer();yield w(window.NL_PATH+"/resources.neu",n),t({success:!0,message:"Update installed. Restart the process to see updates"})}catch(e){n({code:"NE_UP_UPDINER",message:"Update installation error"})}}))))}});var A=Object.freeze({__proto__:null,readText:function(e,t){return l("clipboard.readText",{key:e,data:t})},writeText:function(e){return l("clipboard.writeText",{data:e})}});var F=Object.freeze({__proto__:null,getMethods:function(){return l("custom.getMethods")}});let M=!1;exports.app=P,exports.clipboard=A,exports.computer=y,exports.custom=F,exports.debug=R,exports.events=D,exports.extensions=n,exports.filesystem=_,exports.init=function(t={}){if(t=Object.assign({exportCustomMethods:!0},t),!M){if(d(),window.NL_ARGS.find((e=>"--neu-dev-auto-reload"==e))&&o("neuDev_reloadApp",(()=>e(this,void 0,void 0,(function*(){yield b("Reloading the application..."),location.reload()})))),t.exportCustomMethods&&window.NL_CMETHODS&&window.NL_CMETHODS.length>0)for(let e of window.NL_CMETHODS)Neutralino.custom[e]=(...t)=>{let n={};for(let[e,o]of t.entries())n="object"!=typeof o||Array.isArray(o)||null==o?Object.assign(Object.assign({},n),{["arg"+e]:o}):Object.assign(Object.assign({},n),o);return l("custom."+e,n)};window.NL_CVERSION="5.0.0",window.NL_CCOMMIT="8ac7ce9a81b3001f5f185913760eff83c746eb5f",M=!0}},exports.os=O,exports.storage=E,exports.updater=j,exports.window=I; | ||
"use strict";function e(e,t,n,o){return new(n||(n=Promise))((function(r,i){function s(e){try{c(o.next(e))}catch(e){i(e)}}function a(e){try{c(o.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((o=o.apply(e,t||[])).next())}))}function t(){return l("extensions.getStats")}Object.defineProperty(exports,"__esModule",{value:!0});var n=Object.freeze({__proto__:null,dispatch:function(n,o,r){return new Promise(((i,s)=>e(this,void 0,void 0,(function*(){let e=yield t();if(e.loaded.includes(n))if(e.connected.includes(n))try{let e=yield l("extensions.dispatch",{extensionId:n,event:o,data:r});i(e)}catch(e){s(e)}else!function(e,t){e in u?u[e].push(t):u[e]=[t]}(n,{method:"extensions.dispatch",data:{extensionId:n,event:o,data:r},resolve:i,reject:s});else s({code:"NE_EX_EXTNOTL",message:`${n} is not loaded`})}))))},broadcast:function(e,t){return l("extensions.broadcast",{event:e,data:t})},getStats:t});function o(e,t){return window.addEventListener(e,t),Promise.resolve({success:!0,message:"Event listener added"})}function r(e,t){let n=new CustomEvent(e,{detail:t});return window.dispatchEvent(n),Promise.resolve({success:!0,message:"Message dispatched"})}function i(e){let t=window.atob(e),n=t.length,o=new Uint8Array(n);for(let e=0;e<n;e++)o[e]=t.charCodeAt(e);return o.buffer}let s,a={},c=[],u={};function d(){window.NL_TOKEN&&sessionStorage.setItem("NL_TOKEN",window.NL_TOKEN);const n=p().split(".")[1];s=new WebSocket(`ws://${window.location.hostname}:${window.NL_PORT}?connectToken=${n}`),function(){if(o("ready",(()=>e(this,void 0,void 0,(function*(){if(yield f(c),!window.NL_EXTENABLED)return;let e=yield t();for(let t of e.connected)r("extensionReady",t)})))),o("extClientConnect",(e=>{r("extensionReady",e.detail)})),!window.NL_EXTENABLED)return;o("extensionReady",(t=>e(this,void 0,void 0,(function*(){t.detail in u&&(yield f(u[t.detail]),delete u[t.detail])}))))}(),function(){s.addEventListener("message",(e=>{var t,n,o;const c=JSON.parse(e.data);c.id&&c.id in a?((null===(t=c.data)||void 0===t?void 0:t.error)?(a[c.id].reject(c.data.error),"NE_RT_INVTOKN"==c.data.error.code&&(s.close(),document.body.innerText="",document.write("<code>NE_RT_INVTOKN</code>: Neutralinojs application cannot execute native methods since <code>NL_TOKEN</code> is invalid."))):(null===(n=c.data)||void 0===n?void 0:n.success)&&a[c.id].resolve(c.data.hasOwnProperty("returnValue")?c.data.returnValue:c.data),delete a[c.id]):c.event&&("openedFile"==c.event&&"dataBinary"==(null===(o=null==c?void 0:c.data)||void 0===o?void 0:o.action)&&(c.data.data=i(c.data.data)),r(c.event,c.data))})),s.addEventListener("open",(t=>e(this,void 0,void 0,(function*(){r("ready")})))),s.addEventListener("close",(t=>e(this,void 0,void 0,(function*(){r("serverOffline",{code:"NE_CL_NSEROFF",message:"Neutralino server is offline. Try restarting the application"})})))),s.addEventListener("error",(t=>e(this,void 0,void 0,(function*(){document.body.innerText="",document.write("<code>NE_CL_IVCTOKN</code>: Neutralinojs application cannot connect with the framework core using <code>NL_TOKEN</code>.")}))))}()}function l(e,t){return new Promise(((n,o)=>{if((null==s?void 0:s.readyState)!=WebSocket.OPEN)return r={method:e,data:t,resolve:n,reject:o},void c.push(r);var r;const i="10000000-1000-4000-8000-100000000000".replace(/[018]/g,(e=>(e^crypto.getRandomValues(new Uint8Array(1))[0]&15>>e/4).toString(16))),u=p();a[i]={resolve:n,reject:o},s.send(JSON.stringify({id:i,method:e,data:t,accessToken:u}))}))}function f(t){return e(this,void 0,void 0,(function*(){for(;t.length>0;){let e=t.shift();try{let t=yield l(e.method,e.data);e.resolve(t)}catch(t){e.reject(t)}}}))}function p(){return window.NL_TOKEN||sessionStorage.getItem("NL_TOKEN")||""}function w(e,t){return l("filesystem.writeBinaryFile",{path:e,data:g(t)})}function g(e){let t=new Uint8Array(e),n="";for(let e of t)n+=String.fromCharCode(e);return window.btoa(n)}var m,v,_=Object.freeze({__proto__:null,createDirectory:function(e){return l("filesystem.createDirectory",{path:e})},remove:function(e){return l("filesystem.remove",{path:e})},writeFile:function(e,t){return l("filesystem.writeFile",{path:e,data:t})},appendFile:function(e,t){return l("filesystem.appendFile",{path:e,data:t})},writeBinaryFile:w,appendBinaryFile:function(e,t){return l("filesystem.appendBinaryFile",{path:e,data:g(t)})},readFile:function(e,t){return l("filesystem.readFile",Object.assign({path:e},t))},readBinaryFile:function(e,t){return new Promise(((n,o)=>{l("filesystem.readBinaryFile",Object.assign({path:e},t)).then((e=>{n(i(e))})).catch((e=>{o(e)}))}))},openFile:function(e){return l("filesystem.openFile",{path:e})},createWatcher:function(e){return l("filesystem.createWatcher",{path:e})},removeWatcher:function(e){return l("filesystem.removeWatcher",{id:e})},getWatchers:function(){return l("filesystem.getWatchers")},updateOpenedFile:function(e,t,n){return l("filesystem.updateOpenedFile",{id:e,event:t,data:n})},getOpenedFileInfo:function(e){return l("filesystem.getOpenedFileInfo",{id:e})},readDirectory:function(e,t){return l("filesystem.readDirectory",Object.assign({path:e},t))},copy:function(e,t){return l("filesystem.copy",{source:e,destination:t})},move:function(e,t){return l("filesystem.move",{source:e,destination:t})},getStats:function(e){return l("filesystem.getStats",{path:e})}});function h(e,t){return l("os.execCommand",Object.assign({command:e},t))}!function(e){e.WARNING="WARNING",e.ERROR="ERROR",e.INFO="INFO",e.QUESTION="QUESTION"}(m||(m={})),function(e){e.OK="OK",e.OK_CANCEL="OK_CANCEL",e.YES_NO="YES_NO",e.YES_NO_CANCEL="YES_NO_CANCEL",e.RETRY_CANCEL="RETRY_CANCEL",e.ABORT_RETRY_IGNORE="ABORT_RETRY_IGNORE"}(v||(v={}));var O=Object.freeze({__proto__:null,get Icon(){return m},get MessageBoxChoice(){return v},execCommand:h,spawnProcess:function(e,t){return l("os.spawnProcess",{command:e,cwd:t})},updateSpawnedProcess:function(e,t,n){return l("os.updateSpawnedProcess",{id:e,event:t,data:n})},getSpawnedProcesses:function(){return l("os.getSpawnedProcesses")},getEnv:function(e){return l("os.getEnv",{key:e})},getEnvs:function(){return l("os.getEnvs")},showOpenDialog:function(e,t){return l("os.showOpenDialog",Object.assign({title:e},t))},showFolderDialog:function(e,t){return l("os.showFolderDialog",Object.assign({title:e},t))},showSaveDialog:function(e,t){return l("os.showSaveDialog",Object.assign({title:e},t))},showNotification:function(e,t,n){return l("os.showNotification",{title:e,content:t,icon:n})},showMessageBox:function(e,t,n,o){return l("os.showMessageBox",{title:e,content:t,choice:n,icon:o})},setTray:function(e){return l("os.setTray",e)},open:function(e){return l("os.open",{url:e})},getPath:function(e){return l("os.getPath",{name:e})}});var y=Object.freeze({__proto__:null,getMemoryInfo:function(){return l("computer.getMemoryInfo")},getArch:function(){return l("computer.getArch")},getKernelInfo:function(){return l("computer.getKernelInfo")},getOSInfo:function(){return l("computer.getOSInfo")},getCPUInfo:function(){return l("computer.getCPUInfo")},getDisplays:function(){return l("computer.getDisplays")},getMousePosition:function(){return l("computer.getMousePosition")}});var N,E=Object.freeze({__proto__:null,setData:function(e,t){return l("storage.setData",{key:e,data:t})},getData:function(e){return l("storage.getData",{key:e})},getKeys:function(){return l("storage.getKeys")}});function b(e,t){return l("debug.log",{message:e,type:t})}!function(e){e.WARNING="WARNING",e.ERROR="ERROR",e.INFO="INFO"}(N||(N={}));var R=Object.freeze({__proto__:null,get LoggerType(){return N},log:b});function T(e){return l("app.exit",{code:e})}var P=Object.freeze({__proto__:null,exit:T,killProcess:function(){return l("app.killProcess")},restartProcess:function(t){return new Promise((n=>e(this,void 0,void 0,(function*(){let e=window.NL_ARGS.reduce(((e,t)=>(t.includes(" ")&&(t=`"${t}"`),e+=" "+t)),"");(null==t?void 0:t.args)&&(e+=" "+t.args),yield h(e,{background:!0}),T(),n()}))))},getConfig:function(){return l("app.getConfig")},broadcast:function(e,t){return l("app.broadcast",{event:e,data:t})},readProcessInput:function(e){return l("app.readProcessInput",{readAll:e})},writeProcessOutput:function(e){return l("app.writeProcessOutput",{data:e})},writeProcessError:function(e){return l("app.writeProcessError",{data:e})}});const x=new WeakMap;function L(e,t){return l("window.move",{x:e,y:t})}function S(){return l("window.getSize")}var I=Object.freeze({__proto__:null,setTitle:function(e){return l("window.setTitle",{title:e})},getTitle:function(){return l("window.getTitle")},maximize:function(){return l("window.maximize")},unmaximize:function(){return l("window.unmaximize")},isMaximized:function(){return l("window.isMaximized")},minimize:function(){return l("window.minimize")},setFullScreen:function(){return l("window.setFullScreen")},exitFullScreen:function(){return l("window.exitFullScreen")},isFullScreen:function(){return l("window.isFullScreen")},show:function(){return l("window.show")},hide:function(){return l("window.hide")},isVisible:function(){return l("window.isVisible")},focus:function(){return l("window.focus")},setIcon:function(e){return l("window.setIcon",{icon:e})},move:L,center:function(){return l("window.center")},setDraggableRegion:function(t){return new Promise(((n,o)=>{const r=t instanceof Element?t:document.getElementById(t);let i=0,s=0,a=0,c=!1,u=performance.now();if(!r)return o({code:"NE_WD_DOMNOTF",message:"Unable to find DOM element"});if(x.has(r))return o({code:"NE_WD_ALRDREL",message:"This DOM element is already an active draggable region"});function d(t){return e(this,void 0,void 0,(function*(){if(c){const e=performance.now(),n=e-u;if(n<5)return;return u=e-(n-5),void(yield L(t.screenX-i,t.screenY-s))}a=Math.sqrt(t.movementX*t.movementX+t.movementY*t.movementY),a>=10&&(c=!0,r.setPointerCapture(t.pointerId))}))}function l(e){0===e.button&&(i=e.clientX,s=e.clientY,r.addEventListener("pointermove",d))}function f(e){r.removeEventListener("pointermove",d),r.releasePointerCapture(e.pointerId)}r.addEventListener("pointerdown",l),r.addEventListener("pointerup",f),x.set(r,{pointerdown:l,pointerup:f}),n({success:!0,message:"Draggable region was activated"})}))},unsetDraggableRegion:function(e){return new Promise(((t,n)=>{const o=e instanceof Element?e:document.getElementById(e);if(!o)return n({code:"NE_WD_DOMNOTF",message:"Unable to find DOM element"});if(!x.has(o))return n({code:"NE_WD_NOTDRRE",message:"DOM element is not an active draggable region"});const{pointerdown:r,pointerup:i}=x.get(o);o.removeEventListener("pointerdown",r),o.removeEventListener("pointerup",i),x.delete(o),t({success:!0,message:"Draggable region was deactivated"})}))},setSize:function(t){return new Promise(((n,o)=>e(this,void 0,void 0,(function*(){let e=yield S();l("window.setSize",t=Object.assign(Object.assign({},e),t)).then((e=>{n(e)})).catch((e=>{o(e)}))}))))},getSize:S,getPosition:function(){return l("window.getPosition")},setAlwaysOnTop:function(e){return l("window.setAlwaysOnTop",{onTop:e})},create:function(e,t){return new Promise(((n,o)=>{function r(e){return"string"!=typeof e||(e=e.trim()).includes(" ")&&(e=`"${e}"`),e}t=Object.assign(Object.assign({},t),{useSavedState:!1});let i=window.NL_ARGS.reduce(((e,t,n)=>((t.includes("--path=")||t.includes("--debug-mode")||t.includes("--load-dir-res")||0==n)&&(e+=" "+r(t)),e)),"");i+=" --url="+r(e);for(let e in t){if("processArgs"==e)continue;i+=` --window${e.replace(/[A-Z]|^[a-z]/g,(e=>"-"+e.toLowerCase()))}=${r(t[e])}`}t&&t.processArgs&&(i+=" "+t.processArgs),h(i,{background:!0}).then((e=>{n(e)})).catch((e=>{o(e)}))}))}});var D=Object.freeze({__proto__:null,broadcast:function(e,t){return l("events.broadcast",{event:e,data:t})},on:o,off:function(e,t){return window.removeEventListener(e,t),Promise.resolve({success:!0,message:"Event listener removed"})},dispatch:r});let C=null;var j=Object.freeze({__proto__:null,checkForUpdates:function(t){return new Promise(((n,o)=>e(this,void 0,void 0,(function*(){if(!t)return o({code:"NE_RT_NATRTER",message:"Missing require parameter: url"});try{let e=yield fetch(t);C=JSON.parse(yield e.text()),!function(e){return!!(e.applicationId&&e.applicationId==window.NL_APPID&&e.version&&e.resourcesURL)}(C)?o({code:"NE_UP_CUPDMER",message:"Invalid update manifest or mismatching applicationId"}):n(C)}catch(e){o({code:"NE_UP_CUPDERR",message:"Unable to fetch update manifest"})}}))))},install:function(){return new Promise(((t,n)=>e(this,void 0,void 0,(function*(){if(!C)return n({code:"NE_UP_UPDNOUF",message:"No update manifest loaded"});try{let e=yield fetch(C.resourcesURL),n=yield e.arrayBuffer();yield w(window.NL_PATH+"/resources.neu",n),t({success:!0,message:"Update installed. Restart the process to see updates"})}catch(e){n({code:"NE_UP_UPDINER",message:"Update installation error"})}}))))}});var A=Object.freeze({__proto__:null,readText:function(e,t){return l("clipboard.readText",{key:e,data:t})},writeText:function(e){return l("clipboard.writeText",{data:e})}});var F=Object.freeze({__proto__:null,getMethods:function(){return l("custom.getMethods")}});let M=!1;exports.app=P,exports.clipboard=A,exports.computer=y,exports.custom=F,exports.debug=R,exports.events=D,exports.extensions=n,exports.filesystem=_,exports.init=function(t={}){if(t=Object.assign({exportCustomMethods:!0},t),!M){if(d(),window.NL_ARGS.find((e=>"--neu-dev-auto-reload"==e))&&o("neuDev_reloadApp",(()=>e(this,void 0,void 0,(function*(){yield b("Reloading the application..."),location.reload()})))),t.exportCustomMethods&&window.NL_CMETHODS&&window.NL_CMETHODS.length>0)for(let e of window.NL_CMETHODS)Neutralino.custom[e]=(...t)=>{let n={};for(let[e,o]of t.entries())n="object"!=typeof o||Array.isArray(o)||null==o?Object.assign(Object.assign({},n),{["arg"+e]:o}):Object.assign(Object.assign({},n),o);return l("custom."+e,n)};window.NL_CVERSION="5.0.1",window.NL_CCOMMIT="8f0ed4cf6418bf0980a76e63d7b7813de112d16b",M=!0}},exports.os=O,exports.storage=E,exports.updater=j,exports.window=I; |
@@ -1,2 +0,2 @@ | ||
// Type definitions for Neutralino 5.0.0 | ||
// Type definitions for Neutralino 5.0.1 | ||
// Project: https://github.com/neutralinojs | ||
@@ -308,40 +308,37 @@ // Definitions project: https://github.com/neutralinojs/neutralino.js | ||
// --- globals --- | ||
/** Mode of the application: window, browser, cloud, or chrome */ | ||
declare const NL_MODE: string; | ||
/** Application port */ | ||
declare const NL_PORT: number; | ||
/** Command-line arguments */ | ||
declare const NL_ARGS: string[]; | ||
/** Basic authentication token */ | ||
declare const NL_TOKEN: string; | ||
/** Operating system name: Linux, Windows, or Darwin */ | ||
declare const NL_OS: "Linux"|"Windows"|"Darwin"; | ||
/** Neutralinojs client version */ | ||
declare const NL_CVERSION: string; | ||
/** Application identifier */ | ||
declare const NL_APPID: string; | ||
/** Application port */ | ||
declare const NL_PORT: number; | ||
/** Mode of the application: window, browser, or cloud */ | ||
declare const NL_MODE: "window"|"browser"|"cloud"; | ||
/** Application version */ | ||
declare const NL_APPVERSION: string; | ||
/** Application path */ | ||
declare const NL_PATH: string; | ||
/** Returns true if extensions are enabled */ | ||
declare const NL_EXTENABLED: boolean; | ||
/** Operating system name: Linux, Windows, Darwin, FreeBSD, or Uknown */ | ||
declare const NL_OS: string; | ||
/** CPU architecture: x64, arm, itanium, ia32, or unknown */ | ||
declare const NL_ARCH: string; | ||
/** Neutralinojs server version */ | ||
declare const NL_VERSION: string; | ||
/** Neutralinojs client version */ | ||
declare const NL_CVERSION: "5.0.0"; | ||
/** Current working directory */ | ||
declare const NL_CWD: string; | ||
/** Application path */ | ||
declare const NL_PATH: string; | ||
/** Command-line arguments */ | ||
declare const NL_ARGS: string[]; | ||
/** Current process's identifier */ | ||
declare const NL_PID: number | ||
/** Identifier of the current process */ | ||
declare const NL_PID: string; | ||
/** Source of application resources: bundle or directory */ | ||
declare const NL_RESMODE: string; | ||
/** Release commit of the client library */ | ||
declare const NL_CCOMMIT: string; | ||
/** An array of custom methods */ | ||
declare const NL_CMETHODS: string[]; | ||
@@ -1,1 +0,1 @@ | ||
var Neutralino=function(e){"use strict";function t(e,t,n,o){return new(n||(n=Promise))((function(i,r){function s(e){try{c(o.next(e))}catch(e){r(e)}}function a(e){try{c(o.throw(e))}catch(e){r(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((o=o.apply(e,t||[])).next())}))}function n(){return f("extensions.getStats")}var o={__proto__:null,dispatch:function(e,o,i){return new Promise(((r,s)=>t(this,void 0,void 0,(function*(){let t=yield n();if(t.loaded.includes(e))if(t.connected.includes(e))try{let t=yield f("extensions.dispatch",{extensionId:e,event:o,data:i});r(t)}catch(e){s(e)}else!function(e,t){e in d?d[e].push(t):d[e]=[t]}(e,{method:"extensions.dispatch",data:{extensionId:e,event:o,data:i},resolve:r,reject:s});else s({code:"NE_EX_EXTNOTL",message:`${e} is not loaded`})}))))},broadcast:function(e,t){return f("extensions.broadcast",{event:e,data:t})},getStats:n};function i(e,t){return window.addEventListener(e,t),Promise.resolve({success:!0,message:"Event listener added"})}function r(e,t){let n=new CustomEvent(e,{detail:t});return window.dispatchEvent(n),Promise.resolve({success:!0,message:"Message dispatched"})}function s(e){let t=window.atob(e),n=t.length,o=new Uint8Array(n);for(let e=0;e<n;e++)o[e]=t.charCodeAt(e);return o.buffer}let a,c={},u=[],d={};function l(){window.NL_TOKEN&&sessionStorage.setItem("NL_TOKEN",window.NL_TOKEN);const e=w().split(".")[1];a=new WebSocket(`ws://${window.location.hostname}:${window.NL_PORT}?connectToken=${e}`),function(){if(i("ready",(()=>t(this,void 0,void 0,(function*(){if(yield p(u),!window.NL_EXTENABLED)return;let e=yield n();for(let t of e.connected)r("extensionReady",t)})))),i("extClientConnect",(e=>{r("extensionReady",e.detail)})),!window.NL_EXTENABLED)return;i("extensionReady",(e=>t(this,void 0,void 0,(function*(){e.detail in d&&(yield p(d[e.detail]),delete d[e.detail])}))))}(),function(){a.addEventListener("message",(e=>{var t,n,o;const i=JSON.parse(e.data);i.id&&i.id in c?((null===(t=i.data)||void 0===t?void 0:t.error)?(c[i.id].reject(i.data.error),"NE_RT_INVTOKN"==i.data.error.code&&(a.close(),document.body.innerText="",document.write("<code>NE_RT_INVTOKN</code>: Neutralinojs application cannot execute native methods since <code>NL_TOKEN</code> is invalid."))):(null===(n=i.data)||void 0===n?void 0:n.success)&&c[i.id].resolve(i.data.hasOwnProperty("returnValue")?i.data.returnValue:i.data),delete c[i.id]):i.event&&("openedFile"==i.event&&"dataBinary"==(null===(o=null==i?void 0:i.data)||void 0===o?void 0:o.action)&&(i.data.data=s(i.data.data)),r(i.event,i.data))})),a.addEventListener("open",(e=>t(this,void 0,void 0,(function*(){r("ready")})))),a.addEventListener("close",(e=>t(this,void 0,void 0,(function*(){r("serverOffline",{code:"NE_CL_NSEROFF",message:"Neutralino server is offline. Try restarting the application"})})))),a.addEventListener("error",(e=>t(this,void 0,void 0,(function*(){document.body.innerText="",document.write("<code>NE_CL_IVCTOKN</code>: Neutralinojs application cannot connect with the framework core using <code>NL_TOKEN</code>.")}))))}()}function f(e,t){return new Promise(((n,o)=>{if((null==a?void 0:a.readyState)!=WebSocket.OPEN)return i={method:e,data:t,resolve:n,reject:o},void u.push(i);var i;const r="10000000-1000-4000-8000-100000000000".replace(/[018]/g,(e=>(e^crypto.getRandomValues(new Uint8Array(1))[0]&15>>e/4).toString(16))),s=w();c[r]={resolve:n,reject:o},a.send(JSON.stringify({id:r,method:e,data:t,accessToken:s}))}))}function p(e){return t(this,void 0,void 0,(function*(){for(;e.length>0;){let t=e.shift();try{let e=yield f(t.method,t.data);t.resolve(e)}catch(e){t.reject(e)}}}))}function w(){return window.NL_TOKEN||sessionStorage.getItem("NL_TOKEN")||""}function g(e,t){return f("filesystem.writeBinaryFile",{path:e,data:m(t)})}function m(e){let t=new Uint8Array(e),n="";for(let e of t)n+=String.fromCharCode(e);return window.btoa(n)}var v,_,h={__proto__:null,createDirectory:function(e){return f("filesystem.createDirectory",{path:e})},remove:function(e){return f("filesystem.remove",{path:e})},writeFile:function(e,t){return f("filesystem.writeFile",{path:e,data:t})},appendFile:function(e,t){return f("filesystem.appendFile",{path:e,data:t})},writeBinaryFile:g,appendBinaryFile:function(e,t){return f("filesystem.appendBinaryFile",{path:e,data:m(t)})},readFile:function(e,t){return f("filesystem.readFile",Object.assign({path:e},t))},readBinaryFile:function(e,t){return new Promise(((n,o)=>{f("filesystem.readBinaryFile",Object.assign({path:e},t)).then((e=>{n(s(e))})).catch((e=>{o(e)}))}))},openFile:function(e){return f("filesystem.openFile",{path:e})},createWatcher:function(e){return f("filesystem.createWatcher",{path:e})},removeWatcher:function(e){return f("filesystem.removeWatcher",{id:e})},getWatchers:function(){return f("filesystem.getWatchers")},updateOpenedFile:function(e,t,n){return f("filesystem.updateOpenedFile",{id:e,event:t,data:n})},getOpenedFileInfo:function(e){return f("filesystem.getOpenedFileInfo",{id:e})},readDirectory:function(e,t){return f("filesystem.readDirectory",Object.assign({path:e},t))},copy:function(e,t){return f("filesystem.copy",{source:e,destination:t})},move:function(e,t){return f("filesystem.move",{source:e,destination:t})},getStats:function(e){return f("filesystem.getStats",{path:e})}};function N(e,t){return f("os.execCommand",Object.assign({command:e},t))}!function(e){e.WARNING="WARNING",e.ERROR="ERROR",e.INFO="INFO",e.QUESTION="QUESTION"}(v||(v={})),function(e){e.OK="OK",e.OK_CANCEL="OK_CANCEL",e.YES_NO="YES_NO",e.YES_NO_CANCEL="YES_NO_CANCEL",e.RETRY_CANCEL="RETRY_CANCEL",e.ABORT_RETRY_IGNORE="ABORT_RETRY_IGNORE"}(_||(_={}));var y={__proto__:null,get Icon(){return v},get MessageBoxChoice(){return _},execCommand:N,spawnProcess:function(e,t){return f("os.spawnProcess",{command:e,cwd:t})},updateSpawnedProcess:function(e,t,n){return f("os.updateSpawnedProcess",{id:e,event:t,data:n})},getSpawnedProcesses:function(){return f("os.getSpawnedProcesses")},getEnv:function(e){return f("os.getEnv",{key:e})},getEnvs:function(){return f("os.getEnvs")},showOpenDialog:function(e,t){return f("os.showOpenDialog",Object.assign({title:e},t))},showFolderDialog:function(e,t){return f("os.showFolderDialog",Object.assign({title:e},t))},showSaveDialog:function(e,t){return f("os.showSaveDialog",Object.assign({title:e},t))},showNotification:function(e,t,n){return f("os.showNotification",{title:e,content:t,icon:n})},showMessageBox:function(e,t,n,o){return f("os.showMessageBox",{title:e,content:t,choice:n,icon:o})},setTray:function(e){return f("os.setTray",e)},open:function(e){return f("os.open",{url:e})},getPath:function(e){return f("os.getPath",{name:e})}};var E={__proto__:null,getMemoryInfo:function(){return f("computer.getMemoryInfo")},getArch:function(){return f("computer.getArch")},getKernelInfo:function(){return f("computer.getKernelInfo")},getOSInfo:function(){return f("computer.getOSInfo")},getCPUInfo:function(){return f("computer.getCPUInfo")},getDisplays:function(){return f("computer.getDisplays")},getMousePosition:function(){return f("computer.getMousePosition")}};var O,R={__proto__:null,setData:function(e,t){return f("storage.setData",{key:e,data:t})},getData:function(e){return f("storage.getData",{key:e})},getKeys:function(){return f("storage.getKeys")}};function T(e,t){return f("debug.log",{message:e,type:t})}!function(e){e.WARNING="WARNING",e.ERROR="ERROR",e.INFO="INFO"}(O||(O={}));var P={__proto__:null,get LoggerType(){return O},log:T};function b(e){return f("app.exit",{code:e})}var L={__proto__:null,exit:b,killProcess:function(){return f("app.killProcess")},restartProcess:function(e){return new Promise((n=>t(this,void 0,void 0,(function*(){let t=window.NL_ARGS.reduce(((e,t)=>(t.includes(" ")&&(t=`"${t}"`),e+=" "+t)),"");(null==e?void 0:e.args)&&(t+=" "+e.args),yield N(t,{background:!0}),b(),n()}))))},getConfig:function(){return f("app.getConfig")},broadcast:function(e,t){return f("app.broadcast",{event:e,data:t})},readProcessInput:function(e){return f("app.readProcessInput",{readAll:e})},writeProcessOutput:function(e){return f("app.writeProcessOutput",{data:e})},writeProcessError:function(e){return f("app.writeProcessError",{data:e})}};const S=new WeakMap;function I(e,t){return f("window.move",{x:e,y:t})}function D(){return f("window.getSize")}var C={__proto__:null,setTitle:function(e){return f("window.setTitle",{title:e})},getTitle:function(){return f("window.getTitle")},maximize:function(){return f("window.maximize")},unmaximize:function(){return f("window.unmaximize")},isMaximized:function(){return f("window.isMaximized")},minimize:function(){return f("window.minimize")},setFullScreen:function(){return f("window.setFullScreen")},exitFullScreen:function(){return f("window.exitFullScreen")},isFullScreen:function(){return f("window.isFullScreen")},show:function(){return f("window.show")},hide:function(){return f("window.hide")},isVisible:function(){return f("window.isVisible")},focus:function(){return f("window.focus")},setIcon:function(e){return f("window.setIcon",{icon:e})},move:I,center:function(){return f("window.center")},setDraggableRegion:function(e){return new Promise(((n,o)=>{const i=e instanceof Element?e:document.getElementById(e);let r=0,s=0,a=0,c=!1,u=performance.now();if(!i)return o({code:"NE_WD_DOMNOTF",message:"Unable to find DOM element"});if(S.has(i))return o({code:"NE_WD_ALRDREL",message:"This DOM element is already an active draggable region"});function d(e){return t(this,void 0,void 0,(function*(){if(c){const t=performance.now(),n=t-u;if(n<5)return;return u=t-(n-5),void(yield I(e.screenX-r,e.screenY-s))}a=Math.sqrt(e.movementX*e.movementX+e.movementY*e.movementY),a>=10&&(c=!0,i.setPointerCapture(e.pointerId))}))}function l(e){0===e.button&&(r=e.clientX,s=e.clientY,i.addEventListener("pointermove",d))}function f(e){i.removeEventListener("pointermove",d),i.releasePointerCapture(e.pointerId)}i.addEventListener("pointerdown",l),i.addEventListener("pointerup",f),S.set(i,{pointerdown:l,pointerup:f}),n({success:!0,message:"Draggable region was activated"})}))},unsetDraggableRegion:function(e){return new Promise(((t,n)=>{const o=e instanceof Element?e:document.getElementById(e);if(!o)return n({code:"NE_WD_DOMNOTF",message:"Unable to find DOM element"});if(!S.has(o))return n({code:"NE_WD_NOTDRRE",message:"DOM element is not an active draggable region"});const{pointerdown:i,pointerup:r}=S.get(o);o.removeEventListener("pointerdown",i),o.removeEventListener("pointerup",r),S.delete(o),t({success:!0,message:"Draggable region was deactivated"})}))},setSize:function(e){return new Promise(((n,o)=>t(this,void 0,void 0,(function*(){let t=yield D();f("window.setSize",e=Object.assign(Object.assign({},t),e)).then((e=>{n(e)})).catch((e=>{o(e)}))}))))},getSize:D,getPosition:function(){return f("window.getPosition")},setAlwaysOnTop:function(e){return f("window.setAlwaysOnTop",{onTop:e})},create:function(e,t){return new Promise(((n,o)=>{function i(e){return"string"!=typeof e||(e=e.trim()).includes(" ")&&(e=`"${e}"`),e}t=Object.assign(Object.assign({},t),{useSavedState:!1});let r=window.NL_ARGS.reduce(((e,t,n)=>((t.includes("--path=")||t.includes("--debug-mode")||t.includes("--load-dir-res")||0==n)&&(e+=" "+i(t)),e)),"");r+=" --url="+i(e);for(let e in t){if("processArgs"==e)continue;r+=` --window${e.replace(/[A-Z]|^[a-z]/g,(e=>"-"+e.toLowerCase()))}=${i(t[e])}`}t&&t.processArgs&&(r+=" "+t.processArgs),N(r,{background:!0}).then((e=>{n(e)})).catch((e=>{o(e)}))}))}};var x={__proto__:null,broadcast:function(e,t){return f("events.broadcast",{event:e,data:t})},on:i,off:function(e,t){return window.removeEventListener(e,t),Promise.resolve({success:!0,message:"Event listener removed"})},dispatch:r};let A=null;var F={__proto__:null,checkForUpdates:function(e){return new Promise(((n,o)=>t(this,void 0,void 0,(function*(){if(!e)return o({code:"NE_RT_NATRTER",message:"Missing require parameter: url"});try{let t=yield fetch(e);A=JSON.parse(yield t.text()),!function(e){return!!(e.applicationId&&e.applicationId==window.NL_APPID&&e.version&&e.resourcesURL)}(A)?o({code:"NE_UP_CUPDMER",message:"Invalid update manifest or mismatching applicationId"}):n(A)}catch(e){o({code:"NE_UP_CUPDERR",message:"Unable to fetch update manifest"})}}))))},install:function(){return new Promise(((e,n)=>t(this,void 0,void 0,(function*(){if(!A)return n({code:"NE_UP_UPDNOUF",message:"No update manifest loaded"});try{let t=yield fetch(A.resourcesURL),n=yield t.arrayBuffer();yield g(window.NL_PATH+"/resources.neu",n),e({success:!0,message:"Update installed. Restart the process to see updates"})}catch(e){n({code:"NE_UP_UPDINER",message:"Update installation error"})}}))))}};var M={__proto__:null,readText:function(e,t){return f("clipboard.readText",{key:e,data:t})},writeText:function(e){return f("clipboard.writeText",{data:e})}};var j={__proto__:null,getMethods:function(){return f("custom.getMethods")}};let U=!1;return e.app=L,e.clipboard=M,e.computer=E,e.custom=j,e.debug=P,e.events=x,e.extensions=o,e.filesystem=h,e.init=function(e={}){if(e=Object.assign({exportCustomMethods:!0},e),!U){if(l(),window.NL_ARGS.find((e=>"--neu-dev-auto-reload"==e))&&i("neuDev_reloadApp",(()=>t(this,void 0,void 0,(function*(){yield T("Reloading the application..."),location.reload()})))),e.exportCustomMethods&&window.NL_CMETHODS&&window.NL_CMETHODS.length>0)for(let e of window.NL_CMETHODS)Neutralino.custom[e]=(...t)=>{let n={};for(let[e,o]of t.entries())n="object"!=typeof o||Array.isArray(o)||null==o?Object.assign(Object.assign({},n),{["arg"+e]:o}):Object.assign(Object.assign({},n),o);return f("custom."+e,n)};window.NL_CVERSION="5.0.0",window.NL_CCOMMIT="8ac7ce9a81b3001f5f185913760eff83c746eb5f",U=!0}},e.os=y,e.storage=R,e.updater=F,e.window=C,e}({}); | ||
var Neutralino=function(e){"use strict";function t(e,t,n,o){return new(n||(n=Promise))((function(i,r){function s(e){try{c(o.next(e))}catch(e){r(e)}}function a(e){try{c(o.throw(e))}catch(e){r(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((o=o.apply(e,t||[])).next())}))}function n(){return f("extensions.getStats")}var o={__proto__:null,dispatch:function(e,o,i){return new Promise(((r,s)=>t(this,void 0,void 0,(function*(){let t=yield n();if(t.loaded.includes(e))if(t.connected.includes(e))try{let t=yield f("extensions.dispatch",{extensionId:e,event:o,data:i});r(t)}catch(e){s(e)}else!function(e,t){e in d?d[e].push(t):d[e]=[t]}(e,{method:"extensions.dispatch",data:{extensionId:e,event:o,data:i},resolve:r,reject:s});else s({code:"NE_EX_EXTNOTL",message:`${e} is not loaded`})}))))},broadcast:function(e,t){return f("extensions.broadcast",{event:e,data:t})},getStats:n};function i(e,t){return window.addEventListener(e,t),Promise.resolve({success:!0,message:"Event listener added"})}function r(e,t){let n=new CustomEvent(e,{detail:t});return window.dispatchEvent(n),Promise.resolve({success:!0,message:"Message dispatched"})}function s(e){let t=window.atob(e),n=t.length,o=new Uint8Array(n);for(let e=0;e<n;e++)o[e]=t.charCodeAt(e);return o.buffer}let a,c={},u=[],d={};function l(){window.NL_TOKEN&&sessionStorage.setItem("NL_TOKEN",window.NL_TOKEN);const e=w().split(".")[1];a=new WebSocket(`ws://${window.location.hostname}:${window.NL_PORT}?connectToken=${e}`),function(){if(i("ready",(()=>t(this,void 0,void 0,(function*(){if(yield p(u),!window.NL_EXTENABLED)return;let e=yield n();for(let t of e.connected)r("extensionReady",t)})))),i("extClientConnect",(e=>{r("extensionReady",e.detail)})),!window.NL_EXTENABLED)return;i("extensionReady",(e=>t(this,void 0,void 0,(function*(){e.detail in d&&(yield p(d[e.detail]),delete d[e.detail])}))))}(),function(){a.addEventListener("message",(e=>{var t,n,o;const i=JSON.parse(e.data);i.id&&i.id in c?((null===(t=i.data)||void 0===t?void 0:t.error)?(c[i.id].reject(i.data.error),"NE_RT_INVTOKN"==i.data.error.code&&(a.close(),document.body.innerText="",document.write("<code>NE_RT_INVTOKN</code>: Neutralinojs application cannot execute native methods since <code>NL_TOKEN</code> is invalid."))):(null===(n=i.data)||void 0===n?void 0:n.success)&&c[i.id].resolve(i.data.hasOwnProperty("returnValue")?i.data.returnValue:i.data),delete c[i.id]):i.event&&("openedFile"==i.event&&"dataBinary"==(null===(o=null==i?void 0:i.data)||void 0===o?void 0:o.action)&&(i.data.data=s(i.data.data)),r(i.event,i.data))})),a.addEventListener("open",(e=>t(this,void 0,void 0,(function*(){r("ready")})))),a.addEventListener("close",(e=>t(this,void 0,void 0,(function*(){r("serverOffline",{code:"NE_CL_NSEROFF",message:"Neutralino server is offline. Try restarting the application"})})))),a.addEventListener("error",(e=>t(this,void 0,void 0,(function*(){document.body.innerText="",document.write("<code>NE_CL_IVCTOKN</code>: Neutralinojs application cannot connect with the framework core using <code>NL_TOKEN</code>.")}))))}()}function f(e,t){return new Promise(((n,o)=>{if((null==a?void 0:a.readyState)!=WebSocket.OPEN)return i={method:e,data:t,resolve:n,reject:o},void u.push(i);var i;const r="10000000-1000-4000-8000-100000000000".replace(/[018]/g,(e=>(e^crypto.getRandomValues(new Uint8Array(1))[0]&15>>e/4).toString(16))),s=w();c[r]={resolve:n,reject:o},a.send(JSON.stringify({id:r,method:e,data:t,accessToken:s}))}))}function p(e){return t(this,void 0,void 0,(function*(){for(;e.length>0;){let t=e.shift();try{let e=yield f(t.method,t.data);t.resolve(e)}catch(e){t.reject(e)}}}))}function w(){return window.NL_TOKEN||sessionStorage.getItem("NL_TOKEN")||""}function g(e,t){return f("filesystem.writeBinaryFile",{path:e,data:m(t)})}function m(e){let t=new Uint8Array(e),n="";for(let e of t)n+=String.fromCharCode(e);return window.btoa(n)}var v,_,h={__proto__:null,createDirectory:function(e){return f("filesystem.createDirectory",{path:e})},remove:function(e){return f("filesystem.remove",{path:e})},writeFile:function(e,t){return f("filesystem.writeFile",{path:e,data:t})},appendFile:function(e,t){return f("filesystem.appendFile",{path:e,data:t})},writeBinaryFile:g,appendBinaryFile:function(e,t){return f("filesystem.appendBinaryFile",{path:e,data:m(t)})},readFile:function(e,t){return f("filesystem.readFile",Object.assign({path:e},t))},readBinaryFile:function(e,t){return new Promise(((n,o)=>{f("filesystem.readBinaryFile",Object.assign({path:e},t)).then((e=>{n(s(e))})).catch((e=>{o(e)}))}))},openFile:function(e){return f("filesystem.openFile",{path:e})},createWatcher:function(e){return f("filesystem.createWatcher",{path:e})},removeWatcher:function(e){return f("filesystem.removeWatcher",{id:e})},getWatchers:function(){return f("filesystem.getWatchers")},updateOpenedFile:function(e,t,n){return f("filesystem.updateOpenedFile",{id:e,event:t,data:n})},getOpenedFileInfo:function(e){return f("filesystem.getOpenedFileInfo",{id:e})},readDirectory:function(e,t){return f("filesystem.readDirectory",Object.assign({path:e},t))},copy:function(e,t){return f("filesystem.copy",{source:e,destination:t})},move:function(e,t){return f("filesystem.move",{source:e,destination:t})},getStats:function(e){return f("filesystem.getStats",{path:e})}};function N(e,t){return f("os.execCommand",Object.assign({command:e},t))}!function(e){e.WARNING="WARNING",e.ERROR="ERROR",e.INFO="INFO",e.QUESTION="QUESTION"}(v||(v={})),function(e){e.OK="OK",e.OK_CANCEL="OK_CANCEL",e.YES_NO="YES_NO",e.YES_NO_CANCEL="YES_NO_CANCEL",e.RETRY_CANCEL="RETRY_CANCEL",e.ABORT_RETRY_IGNORE="ABORT_RETRY_IGNORE"}(_||(_={}));var y={__proto__:null,get Icon(){return v},get MessageBoxChoice(){return _},execCommand:N,spawnProcess:function(e,t){return f("os.spawnProcess",{command:e,cwd:t})},updateSpawnedProcess:function(e,t,n){return f("os.updateSpawnedProcess",{id:e,event:t,data:n})},getSpawnedProcesses:function(){return f("os.getSpawnedProcesses")},getEnv:function(e){return f("os.getEnv",{key:e})},getEnvs:function(){return f("os.getEnvs")},showOpenDialog:function(e,t){return f("os.showOpenDialog",Object.assign({title:e},t))},showFolderDialog:function(e,t){return f("os.showFolderDialog",Object.assign({title:e},t))},showSaveDialog:function(e,t){return f("os.showSaveDialog",Object.assign({title:e},t))},showNotification:function(e,t,n){return f("os.showNotification",{title:e,content:t,icon:n})},showMessageBox:function(e,t,n,o){return f("os.showMessageBox",{title:e,content:t,choice:n,icon:o})},setTray:function(e){return f("os.setTray",e)},open:function(e){return f("os.open",{url:e})},getPath:function(e){return f("os.getPath",{name:e})}};var E={__proto__:null,getMemoryInfo:function(){return f("computer.getMemoryInfo")},getArch:function(){return f("computer.getArch")},getKernelInfo:function(){return f("computer.getKernelInfo")},getOSInfo:function(){return f("computer.getOSInfo")},getCPUInfo:function(){return f("computer.getCPUInfo")},getDisplays:function(){return f("computer.getDisplays")},getMousePosition:function(){return f("computer.getMousePosition")}};var O,R={__proto__:null,setData:function(e,t){return f("storage.setData",{key:e,data:t})},getData:function(e){return f("storage.getData",{key:e})},getKeys:function(){return f("storage.getKeys")}};function T(e,t){return f("debug.log",{message:e,type:t})}!function(e){e.WARNING="WARNING",e.ERROR="ERROR",e.INFO="INFO"}(O||(O={}));var b={__proto__:null,get LoggerType(){return O},log:T};function P(e){return f("app.exit",{code:e})}var L={__proto__:null,exit:P,killProcess:function(){return f("app.killProcess")},restartProcess:function(e){return new Promise((n=>t(this,void 0,void 0,(function*(){let t=window.NL_ARGS.reduce(((e,t)=>(t.includes(" ")&&(t=`"${t}"`),e+=" "+t)),"");(null==e?void 0:e.args)&&(t+=" "+e.args),yield N(t,{background:!0}),P(),n()}))))},getConfig:function(){return f("app.getConfig")},broadcast:function(e,t){return f("app.broadcast",{event:e,data:t})},readProcessInput:function(e){return f("app.readProcessInput",{readAll:e})},writeProcessOutput:function(e){return f("app.writeProcessOutput",{data:e})},writeProcessError:function(e){return f("app.writeProcessError",{data:e})}};const S=new WeakMap;function I(e,t){return f("window.move",{x:e,y:t})}function D(){return f("window.getSize")}var C={__proto__:null,setTitle:function(e){return f("window.setTitle",{title:e})},getTitle:function(){return f("window.getTitle")},maximize:function(){return f("window.maximize")},unmaximize:function(){return f("window.unmaximize")},isMaximized:function(){return f("window.isMaximized")},minimize:function(){return f("window.minimize")},setFullScreen:function(){return f("window.setFullScreen")},exitFullScreen:function(){return f("window.exitFullScreen")},isFullScreen:function(){return f("window.isFullScreen")},show:function(){return f("window.show")},hide:function(){return f("window.hide")},isVisible:function(){return f("window.isVisible")},focus:function(){return f("window.focus")},setIcon:function(e){return f("window.setIcon",{icon:e})},move:I,center:function(){return f("window.center")},setDraggableRegion:function(e){return new Promise(((n,o)=>{const i=e instanceof Element?e:document.getElementById(e);let r=0,s=0,a=0,c=!1,u=performance.now();if(!i)return o({code:"NE_WD_DOMNOTF",message:"Unable to find DOM element"});if(S.has(i))return o({code:"NE_WD_ALRDREL",message:"This DOM element is already an active draggable region"});function d(e){return t(this,void 0,void 0,(function*(){if(c){const t=performance.now(),n=t-u;if(n<5)return;return u=t-(n-5),void(yield I(e.screenX-r,e.screenY-s))}a=Math.sqrt(e.movementX*e.movementX+e.movementY*e.movementY),a>=10&&(c=!0,i.setPointerCapture(e.pointerId))}))}function l(e){0===e.button&&(r=e.clientX,s=e.clientY,i.addEventListener("pointermove",d))}function f(e){i.removeEventListener("pointermove",d),i.releasePointerCapture(e.pointerId)}i.addEventListener("pointerdown",l),i.addEventListener("pointerup",f),S.set(i,{pointerdown:l,pointerup:f}),n({success:!0,message:"Draggable region was activated"})}))},unsetDraggableRegion:function(e){return new Promise(((t,n)=>{const o=e instanceof Element?e:document.getElementById(e);if(!o)return n({code:"NE_WD_DOMNOTF",message:"Unable to find DOM element"});if(!S.has(o))return n({code:"NE_WD_NOTDRRE",message:"DOM element is not an active draggable region"});const{pointerdown:i,pointerup:r}=S.get(o);o.removeEventListener("pointerdown",i),o.removeEventListener("pointerup",r),S.delete(o),t({success:!0,message:"Draggable region was deactivated"})}))},setSize:function(e){return new Promise(((n,o)=>t(this,void 0,void 0,(function*(){let t=yield D();f("window.setSize",e=Object.assign(Object.assign({},t),e)).then((e=>{n(e)})).catch((e=>{o(e)}))}))))},getSize:D,getPosition:function(){return f("window.getPosition")},setAlwaysOnTop:function(e){return f("window.setAlwaysOnTop",{onTop:e})},create:function(e,t){return new Promise(((n,o)=>{function i(e){return"string"!=typeof e||(e=e.trim()).includes(" ")&&(e=`"${e}"`),e}t=Object.assign(Object.assign({},t),{useSavedState:!1});let r=window.NL_ARGS.reduce(((e,t,n)=>((t.includes("--path=")||t.includes("--debug-mode")||t.includes("--load-dir-res")||0==n)&&(e+=" "+i(t)),e)),"");r+=" --url="+i(e);for(let e in t){if("processArgs"==e)continue;r+=` --window${e.replace(/[A-Z]|^[a-z]/g,(e=>"-"+e.toLowerCase()))}=${i(t[e])}`}t&&t.processArgs&&(r+=" "+t.processArgs),N(r,{background:!0}).then((e=>{n(e)})).catch((e=>{o(e)}))}))}};var x={__proto__:null,broadcast:function(e,t){return f("events.broadcast",{event:e,data:t})},on:i,off:function(e,t){return window.removeEventListener(e,t),Promise.resolve({success:!0,message:"Event listener removed"})},dispatch:r};let A=null;var F={__proto__:null,checkForUpdates:function(e){return new Promise(((n,o)=>t(this,void 0,void 0,(function*(){if(!e)return o({code:"NE_RT_NATRTER",message:"Missing require parameter: url"});try{let t=yield fetch(e);A=JSON.parse(yield t.text()),!function(e){return!!(e.applicationId&&e.applicationId==window.NL_APPID&&e.version&&e.resourcesURL)}(A)?o({code:"NE_UP_CUPDMER",message:"Invalid update manifest or mismatching applicationId"}):n(A)}catch(e){o({code:"NE_UP_CUPDERR",message:"Unable to fetch update manifest"})}}))))},install:function(){return new Promise(((e,n)=>t(this,void 0,void 0,(function*(){if(!A)return n({code:"NE_UP_UPDNOUF",message:"No update manifest loaded"});try{let t=yield fetch(A.resourcesURL),n=yield t.arrayBuffer();yield g(window.NL_PATH+"/resources.neu",n),e({success:!0,message:"Update installed. Restart the process to see updates"})}catch(e){n({code:"NE_UP_UPDINER",message:"Update installation error"})}}))))}};var M={__proto__:null,readText:function(e,t){return f("clipboard.readText",{key:e,data:t})},writeText:function(e){return f("clipboard.writeText",{data:e})}};var j={__proto__:null,getMethods:function(){return f("custom.getMethods")}};let U=!1;return e.app=L,e.clipboard=M,e.computer=E,e.custom=j,e.debug=b,e.events=x,e.extensions=o,e.filesystem=h,e.init=function(e={}){if(e=Object.assign({exportCustomMethods:!0},e),!U){if(l(),window.NL_ARGS.find((e=>"--neu-dev-auto-reload"==e))&&i("neuDev_reloadApp",(()=>t(this,void 0,void 0,(function*(){yield T("Reloading the application..."),location.reload()})))),e.exportCustomMethods&&window.NL_CMETHODS&&window.NL_CMETHODS.length>0)for(let e of window.NL_CMETHODS)Neutralino.custom[e]=(...t)=>{let n={};for(let[e,o]of t.entries())n="object"!=typeof o||Array.isArray(o)||null==o?Object.assign(Object.assign({},n),{["arg"+e]:o}):Object.assign(Object.assign({},n),o);return f("custom."+e,n)};window.NL_CVERSION="5.0.1",window.NL_CCOMMIT="8f0ed4cf6418bf0980a76e63d7b7813de112d16b",U=!0}},e.os=y,e.storage=R,e.updater=F,e.window=C,e}({}); |
{ | ||
"name": "@neutralinojs/lib", | ||
"version": "5.0.0", | ||
"version": "5.0.1", | ||
"description": "JavaScript API for Neutralinojs", | ||
@@ -5,0 +5,0 @@ "main": "./dist/index.js", |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
70661
839