diff --git a/README.md b/README.md index fbe2edf..363907e 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,7 @@ await Neutralino.events.on(`windowClose`, () => { ## Building ### Requirements -- NodeJS v14+. It's required for the extension to work (the dns lookup required by the radio API) +- NodeJS v18+. It's required for the extension to work (the dns lookup required by the radio API) - Neutralino CLI ### Steps diff --git a/extensions/dnslookup/main.js b/extensions/dnslookup/main.js index f5b5ecf..41ca5c3 100644 --- a/extensions/dnslookup/main.js +++ b/extensions/dnslookup/main.js @@ -13,14 +13,14 @@ const NL_PORT = argv["nl-port"]; const NL_TOKEN = argv["nl-token"]; const NL_EXTID = argv["nl-extension-id"]; -let client = new WS(`ws://localhost:${NL_PORT}?extensionId=${NL_EXTID}`); +let client = new WS(`ws://127.0.0.1:${NL_PORT}?extensionId=${NL_EXTID}`); /** * Get a list of base urls of all available radio-browser servers * Returns: array of strings - base urls of radio-browser servers */ -function get_radiobrowser_base_urls() { - return resolve4("all.api.radio-browser.info") +async function get_radiobrowser_base_urls() { + return await resolve4("all.api.radio-browser.info") .then((hosts) => { let jobs = hosts.map((host) => reverse(host)); return Promise.all(jobs); @@ -35,8 +35,8 @@ function get_radiobrowser_base_urls() { * Get a random available radio-browser server. * Returns: string - base url for radio-browser api */ -function get_radiobrowser_base_url_random() { - return get_radiobrowser_base_urls().then((hosts) => { +async function get_radiobrowser_base_url_random() { + return await get_radiobrowser_base_urls().then((hosts) => { var item = hosts[Math.floor(Math.random() * hosts.length)]; return item; }); diff --git a/neutralino.config.json b/neutralino.config.json index de8715a..2cb11b4 100644 --- a/neutralino.config.json +++ b/neutralino.config.json @@ -1,12 +1,13 @@ { "applicationId": "js.neutralino.xradio", - "version": "1.0.3", + "version": "1.0.4", "defaultMode": "window", "documentRoot": "/xradio-vue/dist/", "port": 6498, "url": "/", "enableServer": true, "enableNativeAPI": true, + "tokenSecurity": "one-time", "extensions": [ { "id": "js.neutralino.dnslookup", @@ -38,8 +39,8 @@ "resourcesPath": "/xradio-vue/dist/", "extensionsPath": "/extensions/", "clientLibrary": "/xradio-vue/public/neutralino.js", - "binaryVersion": "4.11.0", - "clientVersion": "3.8.0", + "binaryVersion": "4.12.0", + "clientVersion": "3.12.0", "frontendLibrary": { "patchFile": "/xradio-vue/public/index.html", "devUrl": "http://localhost:8080" diff --git a/xradio-vue/public/neutralino.d.ts b/xradio-vue/public/neutralino.d.ts new file mode 100644 index 0000000..65042b3 --- /dev/null +++ b/xradio-vue/public/neutralino.d.ts @@ -0,0 +1,338 @@ +// Type definitions for Neutralino 3.12.0 +// Project: https://github.com/neutralinojs +// Definitions project: https://github.com/neutralinojs/neutralino.js + +declare namespace Neutralino { + +namespace filesystem { + interface DirectoryEntry { + entry: string; + type: string; + } + interface FileReaderOptions { + pos: number; + size: number; + } + interface OpenedFile { + id: number; + eof: boolean; + pos: number; + lastRead: number; + } + interface Stats { + size: number; + isFile: boolean; + isDirectory: boolean; + createdAt: number; + modifiedAt: number; + } + interface Watcher { + id: number; + path: string; + } + function createDirectory(path: string): Promise; + function removeDirectory(path: string): Promise; + function writeFile(path: string, data: string): Promise; + function appendFile(path: string, data: string): Promise; + function writeBinaryFile(path: string, data: ArrayBuffer): Promise; + function appendBinaryFile(path: string, data: ArrayBuffer): Promise; + function readFile(path: string, options?: FileReaderOptions): Promise; + function readBinaryFile(path: string, options?: FileReaderOptions): Promise; + function openFile(path: string): Promise; + function createWatcher(path: string): Promise; + function removeWatcher(id: number): Promise; + function getWatchers(): Promise; + function updateOpenedFile(id: number, event: string, data?: any): Promise; + function getOpenedFileInfo(id: number): Promise; + function removeFile(path: string): Promise; + function readDirectory(path: string): Promise; + function copyFile(source: string, destination: string): Promise; + function moveFile(source: string, destination: string): Promise; + function getStats(path: string): Promise; +} +namespace os { + interface ExecCommandOptions { + stdIn?: string; + background?: boolean; + cwd?: string; + } + interface ExecCommandResult { + pid: number; + stdOut: string; + stdErr: string; + exitCode: number; + } + interface SpawnedProcess { + id: number; + pid: number; + } + interface Envs { + [key: string]: string; + } + interface OpenDialogOptions { + multiSelections?: boolean; + filters?: Filter[]; + defaultPath?: string; + } + interface FolderDialogOptions { + defaultPath?: string; + } + interface SaveDialogOptions { + forceOverwrite?: boolean; + filters?: Filter[]; + defaultPath?: string; + } + interface Filter { + name: string; + extensions: string[]; + } + interface TrayOptions { + icon: string; + menuItems: TrayMenuItem[]; + } + interface TrayMenuItem { + id?: string; + text: string; + isDisabled?: boolean; + isChecked?: boolean; + } + enum Icon { + WARNING = "WARNING", + ERROR = "ERROR", + INFO = "INFO", + QUESTION = "QUESTION" + } + enum MessageBoxChoice { + OK = "OK", + OK_CANCEL = "OK_CANCEL", + YES_NO = "YES_NO", + YES_NO_CANCEL = "YES_NO_CANCEL", + RETRY_CANCEL = "RETRY_CANCEL", + ABORT_RETRY_IGNORE = "ABORT_RETRY_IGNORE" + } + type KnownPath = "config" | "data" | "cache" | "documents" | "pictures" | "music" | "video" | "downloads" | "savedGames1" | "savedGames2"; + function execCommand(command: string, options?: ExecCommandOptions): Promise; + function spawnProcess(command: string, cwd?: string): Promise; + function updateSpawnedProcess(id: number, event: string, data?: any): Promise; + function getSpawnedProcesses(): Promise; + function getEnv(key: string): Promise; + function getEnvs(): Promise; + function showOpenDialog(title?: string, options?: OpenDialogOptions): Promise; + function showFolderDialog(title?: string, options?: FolderDialogOptions): Promise; + function showSaveDialog(title?: string, options?: SaveDialogOptions): Promise; + function showNotification(title: string, content: string, icon?: Icon): Promise; + function showMessageBox(title: string, content: string, choice?: MessageBoxChoice, icon?: Icon): Promise; + function setTray(options: TrayOptions): Promise; + function open(url: string): Promise; + function getPath(name: KnownPath): Promise; +} +namespace computer { + interface MemoryInfo { + total: number; + available: number; + } + interface KernelInfo { + variant: string; + version: string; + } + interface OSInfo { + name: string; + description: string; + version: string; + } + interface CPUInfo { + vendor: string; + model: string; + frequency: number; + architecture: string; + logicalThreads: number; + physicalCores: number; + physicalUnits: number; + } + interface Display { + id: number; + resolution: Resolution; + dpi: number; + bpp: number; + refreshRate: number; + } + interface Resolution { + width: number; + height: number; + } + interface MousePosition { + x: number; + y: number; + } + function getMemoryInfo(): Promise; + function getArch(): Promise; + function getKernelInfo(): Promise; + function getOSInfo(): Promise; + function getCPUInfo(): Promise; + function getDisplays(): Promise; + function getMousePosition(): Promise; +} +namespace storage { + function setData(key: string, data: string): Promise; + function getData(key: string): Promise; + function getKeys(): Promise; +} +namespace debug { + enum LoggerType { + WARNING = "WARNING", + ERROR = "ERROR", + INFO = "INFO" + } + function log(message: string, type?: LoggerType): Promise; +} +namespace app { + interface OpenActionOptions { + url: string; + } + interface RestartOptions { + args: string; + } + function exit(code?: number): Promise; + function killProcess(): Promise; + function restartProcess(options?: RestartOptions): Promise; + function getConfig(): Promise; + function broadcast(event: string, data?: any): Promise; +} +namespace window { + interface WindowOptions extends WindowSizeOptions, WindowPosOptions { + title?: string; + icon?: string; + fullScreen?: boolean; + alwaysOnTop?: boolean; + enableInspector?: boolean; + borderless?: boolean; + maximize?: boolean; + hidden?: boolean; + maximizable?: boolean; + useSavedState?: boolean; + processArgs?: string; + } + interface WindowSizeOptions { + width?: number; + height?: number; + minWidth?: number; + minHeight?: number; + maxWidth?: number; + maxHeight?: number; + resizable?: boolean; + } + interface WindowPosOptions { + x: number; + y: number; + } + function setTitle(title: string): Promise; + function getTitle(): Promise; + function maximize(): Promise; + function unmaximize(): Promise; + function isMaximized(): Promise; + function minimize(): Promise; + function setFullScreen(): Promise; + function exitFullScreen(): Promise; + function isFullScreen(): Promise; + function show(): Promise; + function hide(): Promise; + function isVisible(): Promise; + function focus(): Promise; + function setIcon(icon: string): Promise; + function move(x: number, y: number): Promise; + function center(): Promise; + function setDraggableRegion(domElementOrId: string | HTMLElement): Promise; + function unsetDraggableRegion(domElementOrId: string | HTMLElement): Promise; + function setSize(options: WindowSizeOptions): Promise; + function getSize(): Promise; + function getPosition(): Promise; + function setAlwaysOnTop(onTop: boolean): Promise; + function create(url: string, options?: WindowOptions): Promise; +} +namespace events { + interface Response { + success: boolean; + message: string; + } + type Builtin = "ready" | "trayMenuItemClicked" | "windowClose" | "serverOffline" | "clientConnect" | "clientDisconnect" | "appClientConnect" | "appClientDisconnect" | "extClientConnect" | "extClientDisconnect" | "extensionReady" | "neuDev_reloadApp"; + function on(event: string, handler: (ev: CustomEvent) => void): Promise; + function off(event: string, handler: (ev: CustomEvent) => void): Promise; + function dispatch(event: string, data?: any): Promise; + function broadcast(event: string, data?: any): Promise; +} +namespace extensions { + interface ExtensionStats { + loaded: string[]; + connected: string[]; + } + function dispatch(extensionId: string, event: string, data?: any): Promise; + function broadcast(event: string, data?: any): Promise; + function getStats(): Promise; +} +namespace updater { + interface Manifest { + applicationId: string; + version: string; + resourcesURL: string; + } + function checkForUpdates(url: string): Promise; + function install(): Promise; +} +namespace clipboard { + function readText(key: string, data: string): Promise; + function writeText(data: string): Promise; +} +namespace custom { + function getMethods(): Promise; +} +interface InitOptions { + exportCustomMethods?: boolean; +} +function init(options?: InitOptions): void; +type ErrorCode = "NE_FS_DIRCRER" | "NE_FS_RMDIRER" | "NE_FS_FILRDER" | "NE_FS_FILWRER" | "NE_FS_FILRMER" | "NE_FS_NOPATHE" | "NE_FS_COPYFER" | "NE_FS_MOVEFER" | "NE_OS_INVMSGA" | "NE_OS_INVKNPT" | "NE_ST_INVSTKY" | "NE_ST_STKEYWE" | "NE_RT_INVTOKN" | "NE_RT_NATPRME" | "NE_RT_APIPRME" | "NE_RT_NATRTER" | "NE_RT_NATNTIM" | "NE_CL_NSEROFF" | "NE_EX_EXTNOTC" | "NE_UP_CUPDMER" | "NE_UP_CUPDERR" | "NE_UP_UPDNOUF" | "NE_UP_UPDINER"; +interface Error { + code: ErrorCode; + message: string; +} + +} + +/** Basic authentication token */ +declare const NL_TOKEN: string; + +/** Operating system name: Linux, Windows, or Darwin */ +declare const NL_OS: "Linux"|"Windows"|"Darwin"; + +/** 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"; + +/** Neutralinojs server version */ +declare const NL_VERSION: string; + +/** Neutralinojs client version */ +declare const NL_CVERSION: "3.12.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 + +/** Release commit of the client library */ +declare const NL_CCOMMIT: string; + +/** An array of custom methods */ +declare const NL_CMETHODS: string[]; + diff --git a/xradio-vue/public/neutralino.js b/xradio-vue/public/neutralino.js index ec431d1..938810c 100644 --- a/xradio-vue/public/neutralino.js +++ b/xradio-vue/public/neutralino.js @@ -1 +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{u(o.next(e))}catch(e){r(e)}}function a(e){try{u(o.throw(e))}catch(e){r(e)}}function u(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}u((o=o.apply(e,t||[])).next())}))}function n(e,t){let n=new CustomEvent(e,{detail:t});return window.dispatchEvent(n),Promise.resolve({success:!0,message:"Message dispatched"})}let o,i={},r=[],s={};function a(){window.NL_TOKEN&&sessionStorage.setItem("NL_TOKEN",window.NL_TOKEN),o=new WebSocket(`ws://${window.location.hostname}:${window.NL_PORT}`),function(){if(Neutralino.events.on("ready",(()=>t(this,void 0,void 0,(function*(){if(yield c(r),!window.NL_EXTENABLED)return;let e=yield Neutralino.extensions.getStats();for(let t of e.connected)n("extensionReady",t)})))),Neutralino.events.on("extClientConnect",(e=>{n("extensionReady",e.detail)})),!window.NL_EXTENABLED)return;Neutralino.events.on("extensionReady",(e=>t(this,void 0,void 0,(function*(){e.detail in s&&(yield c(s[e.detail]),delete s[e.detail])}))))}(),function(){o.addEventListener("message",(e=>{var t,r;const s=JSON.parse(e.data);s.id&&s.id in i?((null===(t=s.data)||void 0===t?void 0:t.error)?(i[s.id].reject(s.data.error),"NE_RT_INVTOKN"==s.data.error.code&&(o.close(),document.body.innerText="",document.write("NE_RT_INVTOKN: Neutralinojs application configuration prevents accepting native calls from this client."))):(null===(r=s.data)||void 0===r?void 0:r.success)&&i[s.id].resolve(s.data.hasOwnProperty("returnValue")?s.data.returnValue:s.data),delete i[s.id]):s.event&&n(s.event,s.data)})),o.addEventListener("open",(e=>t(this,void 0,void 0,(function*(){n("ready")})))),o.addEventListener("close",(e=>t(this,void 0,void 0,(function*(){n("serverOffline",{code:"NE_CL_NSEROFF",message:"Neutralino server is offline. Try restarting the application"})}))))}()}function u(e,t){return new Promise(((n,s)=>{if((null==o?void 0:o.readyState)!=WebSocket.OPEN)return a={method:e,data:t,resolve:n,reject:s},void r.push(a);var a;const u="10000000-1000-4000-8000-100000000000".replace(/[018]/g,(e=>(e^crypto.getRandomValues(new Uint8Array(1))[0]&15>>e/4).toString(16))),c=window.NL_TOKEN||sessionStorage.getItem("NL_TOKEN")||"";i[u]={resolve:n,reject:s},o.send(JSON.stringify({id:u,method:e,data:t,accessToken:c}))}))}function c(e){return t(this,void 0,void 0,(function*(){for(;e.length>0;){let t=e.shift();try{let e=yield u(t.method,t.data);t.resolve(e)}catch(e){t.reject(e)}}}))}function d(e){let t=new Uint8Array(e),n="";for(let e of t)n+=String.fromCharCode(e);return window.btoa(n)}var l,f,p={__proto__:null,createDirectory:function(e){return u("filesystem.createDirectory",{path:e})},removeDirectory:function(e){return u("filesystem.removeDirectory",{path:e})},writeFile:function(e,t){return u("filesystem.writeFile",{path:e,data:t})},appendFile:function(e,t){return u("filesystem.appendFile",{path:e,data:t})},writeBinaryFile:function(e,t){return u("filesystem.writeBinaryFile",{path:e,data:d(t)})},appendBinaryFile:function(e,t){return u("filesystem.appendBinaryFile",{path:e,data:d(t)})},readFile:function(e,t){return u("filesystem.readFile",Object.assign({path:e},t))},readBinaryFile:function(e,t){return new Promise(((n,o)=>{u("filesystem.readBinaryFile",Object.assign({path:e},t)).then((e=>{let t=window.atob(e),o=t.length,i=new Uint8Array(o);for(let e=0;e{o(e)}))}))},openFile:function(e){return u("filesystem.openFile",{path:e})},updateOpenedFile:function(e,t,n){return u("filesystem.updateOpenedFile",{id:e,event:t,data:n})},getOpenedFileInfo:function(e){return u("filesystem.getOpenedFileInfo",{id:e})},removeFile:function(e){return u("filesystem.removeFile",{path:e})},readDirectory:function(e){return u("filesystem.readDirectory",{path:e})},copyFile:function(e,t){return u("filesystem.copyFile",{source:e,destination:t})},moveFile:function(e,t){return u("filesystem.moveFile",{source:e,destination:t})},getStats:function(e){return u("filesystem.getStats",{path:e})}};!function(e){e.WARNING="WARNING",e.ERROR="ERROR",e.INFO="INFO",e.QUESTION="QUESTION"}(l||(l={})),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"}(f||(f={}));var g={__proto__:null,get Icon(){return l},get MessageBoxChoice(){return f},execCommand:function(e,t){return u("os.execCommand",Object.assign({command:e},t))},spawnProcess:function(e){return u("os.spawnProcess",{command:e})},updateSpawnedProcess:function(e,t,n){return u("os.updateSpawnedProcess",{id:e,event:t,data:n})},getSpawnedProcesses:function(){return u("os.getSpawnedProcesses")},getEnv:function(e){return u("os.getEnv",{key:e})},getEnvs:function(){return u("os.getEnvs")},showOpenDialog:function(e,t){return u("os.showOpenDialog",Object.assign({title:e},t))},showFolderDialog:function(e,t){return u("os.showFolderDialog",Object.assign({title:e},t))},showSaveDialog:function(e,t){return u("os.showSaveDialog",Object.assign({title:e},t))},showNotification:function(e,t,n){return u("os.showNotification",{title:e,content:t,icon:n})},showMessageBox:function(e,t,n,o){return u("os.showMessageBox",{title:e,content:t,choice:n,icon:o})},setTray:function(e){return u("os.setTray",e)},open:function(e){return u("os.open",{url:e})},getPath:function(e){return u("os.getPath",{name:e})}};var w={__proto__:null,getMemoryInfo:function(){return u("computer.getMemoryInfo")},getArch:function(){return u("computer.getArch")},getKernelInfo:function(){return u("computer.getKernelInfo")},getOSInfo:function(){return u("computer.getOSInfo")},getCPUInfo:function(){return u("computer.getCPUInfo")},getDisplays:function(){return u("computer.getDisplays")},getMousePosition:function(){return u("computer.getMousePosition")}};var m,v={__proto__:null,setData:function(e,t){return u("storage.setData",{key:e,data:t})},getData:function(e){return u("storage.getData",{key:e})},getKeys:function(){return u("storage.getKeys")}};!function(e){e.WARNING="WARNING",e.ERROR="ERROR",e.INFO="INFO"}(m||(m={}));var _={__proto__:null,get LoggerType(){return m},log:function(e,t){return u("debug.log",{message:e,type:t})}};var N={__proto__:null,exit:function(e){return u("app.exit",{code:e})},killProcess:function(){return u("app.killProcess")},restartProcess:function(e){return new Promise((n=>t(this,void 0,void 0,(function*(){let t=window.NL_ARGS.reduce(((e,t)=>e+=" "+t),"");(null==e?void 0:e.args)&&(t+=" "+e.args),yield Neutralino.os.execCommand(t,{background:!0}),Neutralino.app.exit(),n()}))))},getConfig:function(){return u("app.getConfig")},broadcast:function(e,t){return u("app.broadcast",{event:e,data:t})}};const h=new WeakMap;var y={__proto__:null,setTitle:function(e){return u("window.setTitle",{title:e})},getTitle:function(){return u("window.getTitle")},maximize:function(){return u("window.maximize")},unmaximize:function(){return u("window.unmaximize")},isMaximized:function(){return u("window.isMaximized")},minimize:function(){return u("window.minimize")},setFullScreen:function(){return u("window.setFullScreen")},exitFullScreen:function(){return u("window.exitFullScreen")},isFullScreen:function(){return u("window.isFullScreen")},show:function(){return u("window.show")},hide:function(){return u("window.hide")},isVisible:function(){return u("window.isVisible")},focus:function(){return u("window.focus")},setIcon:function(e){return u("window.setIcon",{icon:e})},move:function(e,t){return u("window.move",{x:e,y:t})},setDraggableRegion:function(e){return new Promise(((n,o)=>{const i=e instanceof Element?e:document.getElementById(e);let r=0,s=0;if(!i)return o({code:"NE_WD_DOMNOTF",message:"Unable to find DOM element"});if(h.has(i))return o({code:"NE_WD_ALRDREL",message:"This DOM element is already an active draggable region"});function a(e){return t(this,void 0,void 0,(function*(){yield Neutralino.window.move(e.screenX-r,e.screenY-s)}))}function u(e){0===e.button&&(r=e.clientX,s=e.clientY,i.addEventListener("pointermove",a),i.setPointerCapture(e.pointerId))}function c(e){i.removeEventListener("pointermove",a),i.releasePointerCapture(e.pointerId)}i.addEventListener("pointerdown",u),i.addEventListener("pointerup",c),h.set(i,{pointerdown:u,pointerup:c}),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(!h.has(o))return n({code:"NE_WD_NOTDRRE",message:"DOM element is not an active draggable region"});const{pointerdown:i,pointerup:r}=h.get(o);o.removeEventListener("pointerdown",i),o.removeEventListener("pointerup",r),h.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 Neutralino.window.getSize();u("window.setSize",e=Object.assign(Object.assign({},t),e)).then((e=>{n(e)})).catch((e=>{o(e)}))}))))},getSize:function(){return u("window.getSize")},getPosition:function(){return u("window.getPosition")},setAlwaysOnTop:function(e){return u("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}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),Neutralino.os.execCommand(r,{background:!0}).then((e=>{n(e)})).catch((e=>{o(e)}))}))}};var E={__proto__:null,broadcast:function(e,t){return u("events.broadcast",{event:e,data:t})},on:function(e,t){return window.addEventListener(e,t),Promise.resolve({success:!0,message:"Event listener added"})},off:function(e,t){return window.removeEventListener(e,t),Promise.resolve({success:!0,message:"Event listener removed"})},dispatch:n};var O={__proto__:null,dispatch:function(e,n,o){return new Promise(((i,r)=>t(this,void 0,void 0,(function*(){let t=yield Neutralino.extensions.getStats();if(t.loaded.includes(e))if(t.connected.includes(e))try{let t=yield u("extensions.dispatch",{extensionId:e,event:n,data:o});i(t)}catch(e){r(e)}else!function(e,t){e in s?s[e].push(t):s[e]=[t]}(e,{method:"extensions.dispatch",data:{extensionId:e,event:n,data:o},resolve:i,reject:r});else r({code:"NE_EX_EXTNOTL",message:`${e} is not loaded`})}))))},broadcast:function(e,t){return u("extensions.broadcast",{event:e,data:t})},getStats:function(){return u("extensions.getStats")}};let R=null;var T={__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);R=JSON.parse(yield t.text()),!function(e){return!!(e.applicationId&&e.applicationId==window.NL_APPID&&e.version&&e.resourcesURL)}(R)?o({code:"NE_UP_CUPDMER",message:"Invalid update manifest or mismatching applicationId"}):n(R)}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(!R)return n({code:"NE_UP_UPDNOUF",message:"No update manifest loaded"});try{let t=yield fetch(R.resourcesURL),n=yield t.arrayBuffer();yield Neutralino.filesystem.writeBinaryFile(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 S={__proto__:null,readText:function(e,t){return u("clipboard.readText",{key:e,data:t})},writeText:function(e){return u("clipboard.writeText",{data:e})}};var b={__proto__:null,getMethods:function(){return u("custom.getMethods")}};let P=!1;return e.app=N,e.clipboard=S,e.computer=w,e.custom=b,e.debug=_,e.events=E,e.extensions=O,e.filesystem=p,e.init=function(e={}){if(e=Object.assign({exportCustomMethods:!0},e),!P){if(a(),window.NL_ARGS.find((e=>"--neu-dev-auto-reload"==e))&&Neutralino.events.on("neuDev_reloadApp",(()=>t(this,void 0,void 0,(function*(){yield Neutralino.debug.log("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 u("custom."+e,n)};window.NL_CVERSION="3.8.0",window.NL_CCOMMIT="07c0015dca56609e465d7f260f4e8310615d37c3",P=!0}},e.os=g,e.storage=v,e.updater=T,e.window=y,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;et(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("NE_RT_INVTOKN: Neutralinojs application configuration prevents accepting native calls from this client."))):(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"})}))))}()}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=window.NL_TOKEN||sessionStorage.getItem("NL_TOKEN")||"";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 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 w,v,_={__proto__:null,createDirectory:function(e){return f("filesystem.createDirectory",{path:e})},removeDirectory:function(e){return f("filesystem.removeDirectory",{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})},removeFile:function(e){return f("filesystem.removeFile",{path:e})},readDirectory:function(e){return f("filesystem.readDirectory",{path:e})},copyFile:function(e,t){return f("filesystem.copyFile",{source:e,destination:t})},moveFile:function(e,t){return f("filesystem.moveFile",{source:e,destination:t})},getStats:function(e){return f("filesystem.getStats",{path:e})}};function h(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"}(w||(w={})),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 y={__proto__:null,get Icon(){return w},get MessageBoxChoice(){return v},execCommand:h,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 N={__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 E,O={__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 R(e,t){return f("debug.log",{message:e,type:t})}!function(e){e.WARNING="WARNING",e.ERROR="ERROR",e.INFO="INFO"}(E||(E={}));var b={__proto__:null,get LoggerType(){return E},log:R};function T(e){return f("app.exit",{code:e})}var S={__proto__:null,exit:T,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 h(t,{background:!0}),T(),n()}))))},getConfig:function(){return f("app.getConfig")},broadcast:function(e,t){return f("app.broadcast",{event:e,data:t})}};const P=new WeakMap;function D(e,t){return f("window.move",{x:e,y:t})}function L(){return f("window.getSize")}var F={__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:D,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(P.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 D(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),P.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(!P.has(o))return n({code:"NE_WD_NOTDRRE",message:"DOM element is not an active draggable region"});const{pointerdown:i,pointerup:r}=P.get(o);o.removeEventListener("pointerdown",i),o.removeEventListener("pointerup",r),P.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 L();f("window.setSize",e=Object.assign(Object.assign({},t),e)).then((e=>{n(e)})).catch((e=>{o(e)}))}))))},getSize:L,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),h(r,{background:!0}).then((e=>{n(e)})).catch((e=>{o(e)}))}))}};var I={__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 C=null;var x={__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);C=JSON.parse(yield t.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(((e,n)=>t(this,void 0,void 0,(function*(){if(!C)return n({code:"NE_UP_UPDNOUF",message:"No update manifest loaded"});try{let t=yield fetch(C.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 A={__proto__:null,readText:function(e,t){return f("clipboard.readText",{key:e,data:t})},writeText:function(e){return f("clipboard.writeText",{data:e})}};var M={__proto__:null,getMethods:function(){return f("custom.getMethods")}};let U=!1;return e.app=S,e.clipboard=A,e.computer=N,e.custom=M,e.debug=b,e.events=I,e.extensions=o,e.filesystem=_,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 R("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="3.12.0",window.NL_CCOMMIT="043cc4f11ec6c545b8c747bddf3370871bd7b96a",U=!0}},e.os=y,e.storage=O,e.updater=x,e.window=F,e}({}); diff --git a/xradio-vue/src/App.vue b/xradio-vue/src/App.vue index ee6ecda..76120b6 100644 --- a/xradio-vue/src/App.vue +++ b/xradio-vue/src/App.vue @@ -263,6 +263,11 @@ function play(station) { src: [station.url_resolved], html5: true, volume: store.state.volume / 100, + xhr: { + headers: { + "User-Agent": "XRadio/" + config.value.version, + }, + }, }); document.title = station.name; sound.value.play();