Dataset Viewer
Auto-converted to Parquet Duplicate
content
listlengths
3
3
[ { "role": "system", "content": "You are an expert coding assistant specializing in Javascript GUI frameworks." }, { "role": "user", "content": "Explain the structure of this repository and provide the source code." }, { "role": "assistant", "content": "<REPO_NAME>\nneutralinojs/neutralino.js\n</REPO_NAME>\n\n<DESCRIPTION>\nJavaScript API for Neutralinojs\n</DESCRIPTION>\n\n<README>\n# neutralino.js\n\n[![GitHub release (latest by date)](https://img.shields.io/github/v/release/neutralinojs/neutralino.js)](https://github.com/neutralinojs/neutralino.js/releases)\n![npm](https://img.shields.io/npm/v/@neutralinojs/lib)\n![npm](https://img.shields.io/npm/dt/@neutralinojs/lib)\n[![GitHub last commit](https://img.shields.io/github/last-commit/neutralinojs/neutralino.js.svg)](https://github.com/neutralinojs/neutralino.js/commits/main)\n![Build status](https://github.com/neutralinojs/neutralino.js/actions/workflows/ci.yml/badge.svg)\n\nThe official JavaScript client for [Neutralinojs](https://github.com/neutralinojs/neutralinojs). Neutralinojs CLI automatically downloads a minified version of `neutralino.js` and lets you use the Neutralinojs native API via the global `Neutralino` JavaScript object (aka `window.Neutralino`). Also, you can download this client from the NPM registry via a Node package manager and bundle with your application:\n\n```bash\nnpm install @neutralinojs/lib\n# --- or ---\nyarn add @neutralinojs/lib\n```\n\nSee Neutralinojs JavaScript API [documentation](https://neutralino.js.org/docs/api/overview) for more details. Release notes are available at [this page](https://neutralino.js.org/docs/release-notes/client-library/). This repository doesn't host the entire Neutralinojs codebase — this is the JavaScript client that Neutralinojs C++ server codebase loads. Browse the Neutralinojs server source code from [this repository](https://github.com/neutralinojs/neutralinojs).\n\n## Developer's FAQ\n\nHow to build `neutralino.js` from this repository?\n\n```bash\ngit clone https://github.com/neutralinojs/neutralino.js.git\ncd neutralino.js\nnpm install\nnpm run build\n```\n\nHow to test with the Neutralinojs server?\n\n```bash\ncd ../neutralinojs\nbash ./bin/script_update_client.sh\n./bin/neutralino-{platform}_{arch} --load-dir-res # Eg: ./bin/neutralino-linux_x64 --load-dir-res\n```\n\n### License\n\n[MIT](LICENSE)\n\n### Contributing to Neutralinojs\n\nWe really appreciate your code contributions. Please read [this contribution guide](https://neutralino.js.org/docs/contributing/framework-developer-guide#contribution-guidelines) before sending a pull request. Thanks for your contributions.\n\n### Contributors\n\n<a href=\"https://github.com/neutralinojs/neutralino.js/graphs/contributors\">\n <img src=\"https://contrib.rocks/image?repo=neutralinojs/neutralino.js\" />\n</a>\n\nMade with [contributors-img](https://contrib.rocks).\n</README>\n\n<FILE path=\"build.mjs\">\n/*/\n This script generates the files `neutralino.js`, `neutralino.mjs`, and `neutralino.d.ts`.\n For a development version, use: `node ./build.mjs --dev`\n this will produce an unminified `neutralino.js` file and the neutralino.js.map file.\n neutralino.js.map can be moved without the source code.\n/*/\n\n// @ts-check\n\nimport {\n readFileSync,\n writeFile,\n writeFileSync,\n mkdirSync,\n existsSync,\n readdirSync,\n rmSync,\n} from 'fs';\nimport { exec } from 'child_process';\nimport { join as joinPath } from 'path';\nimport { rollup } from 'rollup';\nimport typescript from '@rollup/plugin-typescript';\nimport Json from '@rollup/plugin-json';\nimport Minify from '@rollup/plugin-terser';\nimport cleanup from 'rollup-plugin-cleanup';\nimport { generateDtsBundle } from 'dts-bundle-generator';\n\n// JSON modules is experimental https://nodejs.org/api/esm.html#esm_experimental_json_modules\nconst { version } = JSON.parse(\n readFileSync('./package.json', { encoding: 'utf8' }),\n);\nconst outdir = 'dist';\nconst devmode = process.argv.includes('--dev');\n\nlet commitHash = null;\n\nif (existsSync(outdir)) {\n rmSync(outdir, { recursive: true });\n} else {\n mkdirSync(outdir, { recursive: true });\n}\n\nconsole.log('Preprocessing files...');\naddCommitHash();\n\nconsole.log('import src/index.ts');\n\nrollup({\n input: 'src/index.ts',\n plugins: [\n Json(),\n typescript({\n tsconfig: './tsconfig.json', // Use this tsconfig file to configure TypeScript compilation\n }),\n devmode\n ? cleanup({ comments: 'none' })\n : Minify({ format: { comments: false } }),\n ],\n})\n .then(async build => {\n console.log('generate dist/neutralino.mjs');\n\n await build.write({\n file: joinPath(outdir, 'neutralino.mjs'),\n format: 'esm',\n name: 'Neutralino',\n sourcemap: devmode,\n });\n\n console.log('generate lib');\n\n await build.write({\n dir: outdir,\n format: 'cjs',\n sourcemap: devmode,\n });\n\n console.log('generate dist/neutralino.js');\n\n await build.write({\n file: joinPath(outdir, 'neutralino.js'),\n format: 'iife',\n name: 'Neutralino',\n sourcemap: devmode,\n freeze: false,\n esModule: false,\n });\n return 0;\n })\n .then(returned => {\n console.log('Rolling up typescript declarations');\n\n const bundled = generateDtsBundle([\n {\n filePath: './dist/declarations/index.d.ts',\n output: {\n inlineDeclareGlobals: true,\n inlineDeclareExternals: true,\n noBanner: true,\n exportReferencedTypes: false,\n },\n },\n ]);\n const bundledUnderNamespace = generateDtsBundle([\n {\n filePath: './dist/declarations/index.d.ts',\n output: {\n inlineDeclareGlobals: true,\n inlineDeclareExternals: true,\n noBanner: true,\n exportReferencedTypes: false,\n umdModuleName: 'Neutralino',\n },\n },\n ]);\n write(joinPath(outdir, 'neutralino.d.ts'), bundledUnderNamespace[0]);\n write(joinPath(outdir, 'neutralino.d.mts'), bundled[0]);\n write(joinPath(outdir, 'index.d.ts'), bundled[0]);\n rmSync(joinPath(outdir, 'declarations'), { recursive: true });\n resetCommitHash();\n })\n .catch(err => {\n console.error(\n '\\n' +\n err +\n // RollupLogProps, https://github.com/rollup/rollup/blob/master/src/rollup/types.d.ts#L24\n (typeof err.loc === 'object'\n ? '\\n' + err.loc.file + ':' + err.loc.line\n : '') +\n (typeof err.frame === 'string' ? '\\n' + err.frame : ''),\n );\n });\n\nfunction write(filepath, content) {\n console.log('write', filepath);\n writeFile(filepath, content, { encoding: 'utf8' }, err => {\n if (err) console.error('' + err);\n });\n}\n\nfunction patchInitFile(search, replace) {\n let initSource = readFileSync('./src/api/init.ts', { encoding: 'utf8' });\n initSource = initSource.replace(search, replace);\n writeFileSync('./src/api/init.ts', initSource, { encoding: 'utf8' });\n}\n\nfunction addCommitHash() {\n try {\n const hash = exec('git log -n 1 main --pretty=format:\"%H\"')\n .toString()\n .trim();\n patchInitFile('<git_commit_hash_latest>', hash);\n commitHash = hash;\n } catch (err) {\n console.warn('Warning: Could not get git commit hash:', err.message);\n commitHash = '<git_commit_hash_latest>';\n }\n}\nfunction resetCommitHash() {\n patchInitFile(commitHash, '<git_commit_hash_latest>');\n}\n\n</FILE>\n<FILE path=\"README.md\">\n# neutralino.js\n\n[![GitHub release (latest by date)](https://img.shields.io/github/v/release/neutralinojs/neutralino.js)](https://github.com/neutralinojs/neutralino.js/releases)\n![npm](https://img.shields.io/npm/v/@neutralinojs/lib)\n![npm](https://img.shields.io/npm/dt/@neutralinojs/lib)\n[![GitHub last commit](https://img.shields.io/github/last-commit/neutralinojs/neutralino.js.svg)](https://github.com/neutralinojs/neutralino.js/commits/main)\n![Build status](https://github.com/neutralinojs/neutralino.js/actions/workflows/ci.yml/badge.svg)\n\nThe official JavaScript client for [Neutralinojs](https://github.com/neutralinojs/neutralinojs). Neutralinojs CLI automatically downloads a minified version of `neutralino.js` and lets you use the Neutralinojs native API via the global `Neutralino` JavaScript object (aka `window.Neutralino`). Also, you can download this client from the NPM registry via a Node package manager and bundle with your application:\n\n```bash\nnpm install @neutralinojs/lib\n# --- or ---\nyarn add @neutralinojs/lib\n```\n\nSee Neutralinojs JavaScript API [documentation](https://neutralino.js.org/docs/api/overview) for more details. Release notes are available at [this page](https://neutralino.js.org/docs/release-notes/client-library/). This repository doesn't host the entire Neutralinojs codebase — this is the JavaScript client that Neutralinojs C++ server codebase loads. Browse the Neutralinojs server source code from [this repository](https://github.com/neutralinojs/neutralinojs).\n\n## Developer's FAQ\n\nHow to build `neutralino.js` from this repository?\n\n```bash\ngit clone https://github.com/neutralinojs/neutralino.js.git\ncd neutralino.js\nnpm install\nnpm run build\n```\n\nHow to test with the Neutralinojs server?\n\n```bash\ncd ../neutralinojs\nbash ./bin/script_update_client.sh\n./bin/neutralino-{platform}_{arch} --load-dir-res # Eg: ./bin/neutralino-linux_x64 --load-dir-res\n```\n\n### License\n\n[MIT](LICENSE)\n\n### Contributing to Neutralinojs\n\nWe really appreciate your code contributions. Please read [this contribution guide](https://neutralino.js.org/docs/contributing/framework-developer-guide#contribution-guidelines) before sending a pull request. Thanks for your contributions.\n\n### Contributors\n\n<a href=\"https://github.com/neutralinojs/neutralino.js/graphs/contributors\">\n <img src=\"https://contrib.rocks/image?repo=neutralinojs/neutralino.js\" />\n</a>\n\nMade with [contributors-img](https://contrib.rocks).\n\n\n\n</FILE>\n<FILE path=\"package.json\">\n{\n \"name\": \"@neutralinojs/lib\",\n \"version\": \"6.5.0\",\n \"description\": \"JavaScript API for Neutralinojs\",\n \"main\": \"./dist/index.js\",\n \"files\": [\n \"dist\"\n ],\n \"scripts\": {\n \"test\": \"echo \\\"Error: no test specified\\\" && exit 1\",\n \"build\": \"node build.mjs\",\n \"watch\": \"rollup -c -w\",\n \"lint\": \"eslint --ignore-path .eslintignore --ext .js,.ts\",\n \"format\": \"prettier --ignore-path .gitignore --write \\\"**/*.+(js|ts|json)\\\"\"\n },\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"git+https://github.com/neutralinojs/neutralino.js.git\"\n },\n \"author\": \"Neutralinojs\",\n \"license\": \"MIT\",\n \"bugs\": {\n \"url\": \"https://github.com/neutralinojs/neutralino.js/issues\"\n },\n \"homepage\": \"https://github.com/neutralinojs/neutralino.js#readme\",\n \"devDependencies\": {\n \"@rollup/plugin-json\": \"^6.1.0\",\n \"@rollup/plugin-terser\": \"^0.4.4\",\n \"@rollup/plugin-typescript\": \"^12.1.4\",\n \"@types/node\": \"^24.3.0\",\n \"@typescript-eslint/eslint-plugin\": \"^8.41.0\",\n \"@typescript-eslint/parser\": \"^8.41.0\",\n \"dts-bundle-generator\": \"^9.5.1\",\n \"eslint\": \"^9.34.0\",\n \"eslint-config-prettier\": \"^10.1.8\",\n \"prettier\": \"^3.6.2\",\n \"rollup\": \"^4.48.1\",\n \"rollup-plugin-cleanup\": \"^3.2.1\",\n \"rollup-plugin-dts\": \"^6.2.3\",\n \"tslib\": \"^2.6.2\",\n \"typescript\": \"^5.9.2\"\n },\n \"optionalDependencies\": {\n \"@rollup/rollup-linux-x64-gnu\": \"*\",\n \"@rollup/rollup-darwin-x64\": \"*\"\n }\n}\n\n</FILE>\n<FILE path=\"tsconfig.json\">\n{\n \"compilerOptions\": {\n \"target\": \"ESNext\",\n \"module\": \"ESNext\",\n \"moduleResolution\": \"node\",\n \"declarationDir\": \"./dist/declarations/\",\n \"noImplicitAny\": false,\n \"allowJs\": false,\n \"resolveJsonModule\": true,\n \"declaration\": true\n }\n}\n\n</FILE>\n<FILE path=\"src/helpers.ts\">\nexport function base64ToBytesArray(data: string): ArrayBufferLike {\n const binaryData: string = window.atob(data);\n const len: number = binaryData.length;\n const bytes: Uint8Array = new Uint8Array(len);\n\n for (let i = 0; i < len; i++) {\n bytes[i] = binaryData.charCodeAt(i);\n }\n\n return bytes.buffer;\n}\n\nexport function arrayBufferToBase64(data: ArrayBuffer): string {\n let bytes: Uint8Array = new Uint8Array(data);\n let asciiStr: string = '';\n\n for (let byte of bytes) {\n asciiStr += String.fromCharCode(byte);\n }\n\n return window.btoa(asciiStr);\n}\n\nexport function normalizeElements(inputs: any[]): HTMLElement[] {\n const result: HTMLElement[] = [];\n\n for (const input of inputs) {\n const items = Array.isArray(input) ? input : [input];\n for (const item of items) {\n const el =\n item instanceof HTMLElement\n ? item\n : document.getElementById(item);\n if (el) result.push(el);\n }\n }\n\n return result;\n}\n\n</FILE>\n<FILE path=\"src/index.ts\">\nimport type { Architecture, Mode, OperatingSystem } from './types/enums';\n\ndeclare global {\n interface Window {\n // --- globals ---\n /** Mode of the application: window, browser, cloud, or chrome */\n NL_MODE: Mode;\n /** Application port */\n NL_PORT: number;\n /** Command-line arguments */\n NL_ARGS: string[];\n /** Basic authentication token */\n NL_TOKEN: string;\n /** Neutralinojs client version */\n NL_CVERSION: string;\n /** Application identifier */\n NL_APPID: string;\n /** Application version */\n NL_APPVERSION: string;\n /** Application path */\n NL_PATH: string;\n /** Application data path */\n NL_DATAPATH: string;\n /** Returns true if extensions are enabled */\n NL_EXTENABLED: boolean;\n /** Returns true if the client library is injected */\n NL_GINJECTED: boolean;\n /** Returns true if globals are injected */\n NL_CINJECTED: boolean;\n /** Operating system name: Linux, Windows, Darwin, FreeBSD, or Uknown */\n NL_OS: OperatingSystem;\n /** CPU architecture: x64, arm, itanium, ia32, or unknown */\n NL_ARCH: Architecture;\n /** Neutralinojs server version */\n NL_VERSION: string;\n /** Current working directory */\n NL_CWD: string;\n /** Identifier of the current process */\n NL_PID: string;\n /** Source of application resources: bundle or directory */\n NL_RESMODE: string;\n /** Release commit of the client library */\n NL_CCOMMIT: string;\n /** An array of custom methods */\n NL_CMETHODS: string[];\n // --- globals ---\n }\n /** Neutralino global object for custom methods **/\n const Neutralino: any;\n}\n\nexport * as filesystem from './api/filesystem';\nexport * as os from './api/os';\nexport * as computer from './api/computer';\nexport * as storage from './api/storage';\nexport * as debug from './api/debug';\nexport * as app from './api/app';\nexport * as window from './api/window';\nexport * as events from './api/events';\nexport * as extensions from './api/extensions';\nexport * as updater from './api/updater';\nexport * as clipboard from './api/clipboard';\nexport * as resources from './api/resources';\nexport * as server from './api/server';\nexport * as custom from './api/custom';\n\nexport { init } from './api/init';\n\nexport type * from './types/api/protocol';\nexport type * from './types/api/app';\nexport type * from './types/api/computer';\nexport type * from './types/api/clipboard';\nexport type * from './types/api/extensions';\nexport type * from './types/api/filesystem';\nexport type * from './types/api/init';\nexport type * from './types/api/os';\nexport type * from './types/api/updater';\nexport type * from './types/api/window';\nexport type * from './types/enums';\nexport type * from './types/events';\n\n</FILE>\n<FILE path=\"src/browser/events.ts\">\nimport type { Response } from '../types/events';\n\nexport function on(event: string, handler: (ev: CustomEvent) => void): Promise<Response> {\n window.addEventListener(event, handler);\n return Promise.resolve({\n success: true,\n message: 'Event listener added'\n });\n};\n\nexport function off(event: string, handler: (ev: CustomEvent) => void): Promise<Response> {\n window.removeEventListener(event, handler);\n return Promise.resolve({\n success: true,\n message: 'Event listener removed'\n });\n};\n\nexport function dispatch(event: string, data?: any): Promise<Response> {\n const customEvent = new CustomEvent(event, {detail: data});\n window.dispatchEvent(customEvent);\n return Promise.resolve({\n success: true,\n message: 'Message dispatched'\n });\n};\n\n</FILE>\n<FILE path=\"src/api/window.ts\">\nimport { sendMessage } from '../ws/websocket';\nimport * as os from './os';\nimport {\n WindowOptions,\n WindowPosOptions,\n WindowSizeOptions,\n WindowMenu,\n} from '../types/api/window';\n\nimport { normalizeElements } from '../helpers';\n\nconst draggableRegions = new Set<HTMLElement>();\nconst draggableExclusions = new Map<HTMLElement, Set<HTMLElement>>();\nconst draggableListeners = new Map<HTMLElement, EventListener>();\n\nexport function setTitle(title: string): Promise<void> {\n return sendMessage('window.setTitle', { title });\n}\n\nexport function getTitle(): Promise<string> {\n return sendMessage('window.getTitle');\n}\n\nexport function maximize(): Promise<void> {\n return sendMessage('window.maximize');\n}\n\nexport function unmaximize(): Promise<void> {\n return sendMessage('window.unmaximize');\n}\n\nexport function isMaximized(): Promise<boolean> {\n return sendMessage('window.isMaximized');\n}\n\nexport function minimize(): Promise<void> {\n return sendMessage('window.minimize');\n}\n\nexport function unminimize(): Promise<void> {\n return sendMessage('window.unminimize');\n}\n\nexport function isMinimized(): Promise<boolean> {\n return sendMessage('window.isMinimized');\n}\n\nexport function setFullScreen(): Promise<void> {\n return sendMessage('window.setFullScreen');\n}\n\nexport function exitFullScreen(): Promise<void> {\n return sendMessage('window.exitFullScreen');\n}\n\nexport function isFullScreen(): Promise<boolean> {\n return sendMessage('window.isFullScreen');\n}\n\nexport function show(): Promise<void> {\n return sendMessage('window.show');\n}\n\nexport function hide(): Promise<void> {\n return sendMessage('window.hide');\n}\n\nexport function isVisible(): Promise<boolean> {\n return sendMessage('window.isVisible');\n}\n\nexport function focus(): Promise<void> {\n return sendMessage('window.focus');\n}\n\nexport function setIcon(icon: string): Promise<void> {\n return sendMessage('window.setIcon', { icon });\n}\n\nexport function move(x: number, y: number): Promise<void> {\n return sendMessage('window.move', { x, y });\n}\n\nexport function center(): Promise<void> {\n return sendMessage('window.center');\n}\n\nexport function beginDrag(\n screenX: number = 0,\n screenY: number = 0,\n): Promise<void> {\n return sendMessage('window.beginDrag', { screenX, screenY });\n}\n\nfunction createDraggableListener(region: HTMLElement): EventListener {\n return async function draggableListener(ev: PointerEvent) {\n if (ev.button !== 0) return;\n\n const exclusions = draggableExclusions.get(region);\n if (exclusions) {\n for (const excludedEl of exclusions) {\n if (excludedEl.contains(ev.target as Node)) return;\n }\n }\n\n await beginDrag(ev.screenX, ev.screenY);\n ev.preventDefault();\n };\n}\n\nexport function setDraggableRegion(\n DOMElementOrId: string | HTMLElement,\n options?: {\n exclude?: Array<string | HTMLElement>;\n },\n): Promise<{\n success: true;\n message: string;\n exclusions: {\n add(elements: Array<string | HTMLElement>): void;\n remove(elements: Array<string | HTMLElement>): void;\n removeAll(): void;\n };\n}> {\n return new Promise<Awaited<ReturnType<typeof setDraggableRegion>>>(\n (resolve, reject) => {\n const draggableRegion =\n DOMElementOrId instanceof HTMLElement\n ? DOMElementOrId\n : document.getElementById(DOMElementOrId);\n\n if (!draggableRegion) {\n return reject({\n code: 'NE_WD_DOMNOTF',\n message: 'Unable to find DOM element',\n });\n }\n\n if (draggableRegions.has(draggableRegion)) {\n return reject({\n code: 'NE_WD_ALRDREL',\n message:\n 'This DOM element is already an active draggable region',\n });\n }\n\n if (options?.exclude?.length) {\n const exclusions = new Set<HTMLElement>();\n for (const item of options.exclude) {\n const el =\n item instanceof HTMLElement\n ? item\n : document.getElementById(item);\n if (el) exclusions.add(el);\n }\n if (exclusions.size) {\n draggableExclusions.set(draggableRegion, exclusions);\n }\n }\n\n const listener = createDraggableListener(draggableRegion);\n draggableRegion.addEventListener('pointerdown', listener);\n\n draggableRegions.add(draggableRegion);\n draggableListeners.set(draggableRegion, listener);\n\n const exclusionControls = {\n add(\n ...elements: Array<\n string | HTMLElement | Array<string | HTMLElement>\n >\n ) {\n if (!draggableRegions.has(draggableRegion)) {\n throw {\n code: 'NE_WD_NOTDRRE',\n message:\n 'DOM element is no longer an active draggable region. You likely called unsetDraggableRegion on this element too early!',\n };\n }\n\n let set = draggableExclusions.get(draggableRegion);\n if (!set) {\n set = new Set<HTMLElement>();\n draggableExclusions.set(draggableRegion, set);\n }\n\n const normalized = normalizeElements(elements);\n for (const el of normalized) set.add(el);\n },\n\n remove(\n ...elements: Array<\n string | HTMLElement | Array<string | HTMLElement>\n >\n ) {\n if (!draggableRegions.has(draggableRegion)) {\n throw {\n code: 'NE_WD_NOTDRRE',\n message:\n 'DOM element is no longer an active draggable region. You likely called unsetDraggableRegion on this element too early!',\n };\n }\n\n const set = draggableExclusions.get(draggableRegion);\n if (!set) return;\n\n const normalized = normalizeElements(elements);\n for (const el of normalized) set.delete(el);\n },\n\n removeAll() {\n if (!draggableRegions.has(draggableRegion)) {\n throw {\n code: 'NE_WD_NOTDRRE',\n message:\n 'DOM element is no longer an active draggable region. You likely called unsetDraggableRegion on this element too early!',\n };\n }\n\n draggableExclusions.delete(draggableRegion);\n },\n };\n\n resolve({\n success: true,\n message: 'Draggable region was activated',\n exclusions: exclusionControls,\n });\n },\n );\n}\n\nexport function unsetDraggableRegion(\n DOMElementOrId: string | HTMLElement,\n): Promise<{\n success: true;\n message: string;\n}> {\n return new Promise((resolve, reject) => {\n const draggableRegion =\n DOMElementOrId instanceof HTMLElement\n ? DOMElementOrId\n : document.getElementById(DOMElementOrId);\n\n if (!draggableRegion) {\n return reject({\n code: 'NE_WD_DOMNOTF',\n message: 'Unable to find DOM element',\n });\n }\n\n if (!draggableRegions.has(draggableRegion)) {\n return reject({\n code: 'NE_WD_NOTDRRE',\n message: 'DOM element is not an active draggable region',\n });\n }\n\n const listener = draggableListeners.get(draggableRegion);\n\n if (listener) {\n draggableRegion.removeEventListener('pointerdown', listener);\n draggableListeners.delete(draggableRegion);\n }\n\n draggableRegions.delete(draggableRegion);\n draggableExclusions.delete(draggableRegion);\n\n resolve({\n success: true,\n message: 'Draggable region was deactivated',\n });\n });\n}\n\nexport function setSize(options: WindowSizeOptions): Promise<void> {\n return new Promise(async (resolve: any, reject: any) => {\n let sizeOptions = await getSize();\n\n options = { ...sizeOptions, ...options }; // merge prioritizing options arg\n\n sendMessage('window.setSize', options)\n .then((response: any) => {\n resolve(response);\n })\n .catch((error: any) => {\n reject(error);\n });\n });\n}\n\nexport function getSize(): Promise<WindowSizeOptions> {\n return sendMessage('window.getSize');\n}\n\nexport function getPosition(): Promise<WindowPosOptions> {\n return sendMessage('window.getPosition');\n}\n\nexport function setAlwaysOnTop(onTop: boolean): Promise<void> {\n return sendMessage('window.setAlwaysOnTop', { onTop });\n}\n\nexport function setBorderless(borderless: boolean): Promise<void> {\n return sendMessage('window.setBorderless', { borderless });\n}\n\nexport function create(url: string, options?: WindowOptions): Promise<void> {\n return new Promise((resolve: any, reject: any) => {\n options = { ...options, useSavedState: false };\n // useSavedState: false -> Child windows won't save their states\n\n function normalize(arg: any) {\n if (typeof arg != 'string') return arg;\n arg = arg.trim();\n if (arg.includes(' ')) {\n arg = `\"${arg}\"`;\n }\n return arg;\n }\n\n let command = window.NL_ARGS.reduce(\n (acc: string, arg: string, index: number) => {\n if (\n arg.includes('--path=') ||\n arg.includes('--debug-mode') ||\n arg.includes('--load-dir-res') ||\n index == 0\n ) {\n acc += ' ' + normalize(arg);\n }\n return acc;\n },\n '',\n );\n\n command += ' --url=' + normalize(url);\n\n for (let key in options) {\n if (key == 'processArgs') continue;\n\n let cliKey: string =\n '-' + key.replace(/([a-z])([A-Z])/g, '$1-$2').toLowerCase();\n command += ` --window${cliKey}=${normalize(options[key])}`;\n }\n\n if (options && options.processArgs)\n command += ' ' + options.processArgs;\n\n os.execCommand(command, { background: true })\n .then((processInfo: any) => {\n resolve(processInfo);\n })\n .catch((error: any) => {\n reject(error);\n });\n });\n}\n\nexport function snapshot(path: string): Promise<void> {\n return sendMessage('window.snapshot', { path });\n}\n\nexport function setMainMenu(options: WindowMenu): Promise<void> {\n return sendMessage('window.setMainMenu', options);\n};\n\nexport function print(): Promise<void> {\n return sendMessage('window.print');\n};\n\n</FILE>\n<FILE path=\"src/api/os.ts\">\nimport { sendMessage } from '../ws/websocket';\nimport type { MessageBoxChoice, Icon } from '../types/enums';\nimport type {\n Envs,\n ExecCommandOptions,\n ExecCommandResult,\n FolderDialogOptions,\n KnownPath,\n OpenDialogOptions,\n SaveDialogOptions,\n SpawnedProcess,\n TrayOptions,\n SpawnedProcessOptions,\n} from '../types/api/os';\n\nexport function execCommand(command: string, options?: ExecCommandOptions): Promise<ExecCommandResult> {\n return sendMessage('os.execCommand', { command, ...options });\n};\n\nexport function spawnProcess(command: string, options?: SpawnedProcessOptions): Promise<SpawnedProcess> {\n return sendMessage('os.spawnProcess', { command, ...options });\n};\n\nexport function updateSpawnedProcess(id: number, event: string, data?: any): Promise<void> {\n return sendMessage('os.updateSpawnedProcess', { id, event, data });\n};\n\nexport function getSpawnedProcesses(): Promise<SpawnedProcess[]> {\n return sendMessage('os.getSpawnedProcesses');\n};\n\nexport function getEnv(key: string): Promise<string> {\n return sendMessage('os.getEnv', { key });\n};\n\nexport function getEnvs(): Promise<Envs> {\n return sendMessage('os.getEnvs');\n};\n\nexport function showOpenDialog(title?: string, options?: OpenDialogOptions): Promise<string[]> {\n return sendMessage('os.showOpenDialog', { title, ...options });\n};\n\nexport function showFolderDialog(title?: string, options?: FolderDialogOptions): Promise<string> {\n return sendMessage('os.showFolderDialog', { title, ...options });\n};\n\nexport function showSaveDialog(title?: string, options?: SaveDialogOptions): Promise<string> {\n return sendMessage('os.showSaveDialog', { title, ...options });\n};\n\nexport function showNotification(title: string, content: string, icon?: Icon): Promise<void> {\n return sendMessage('os.showNotification', { title, content, icon });\n};\n\nexport function showMessageBox(title: string, content: string,\n choice?: MessageBoxChoice, icon?: Icon): Promise<string> {\n return sendMessage('os.showMessageBox', { title, content, choice, icon });\n};\n\nexport function setTray(options: TrayOptions): Promise<void> {\n return sendMessage('os.setTray', options);\n};\n\nexport function open(url: string): Promise<void> {\n return sendMessage('os.open', { url });\n};\n\nexport function getPath(name: KnownPath): Promise<string> {\n return sendMessage('os.getPath', { name });\n};\n\n</FILE>\n<FILE path=\"src/api/updater.ts\">\nimport * as filesystem from './filesystem';\nimport { Error } from '../types/api/protocol';\nimport { Manifest } from '../types/api/updater';\n\nlet manifest: Manifest = null;\n\nexport function checkForUpdates(url: string): Promise<Manifest> {\n function isValidManifest(manifest: Manifest): manifest is Manifest {\n if(manifest.applicationId && manifest.applicationId == window.NL_APPID\n && manifest.version && manifest.resourcesURL) {\n return true;\n }\n return false;\n }\n\n return new Promise(async (resolve: (m: Manifest) => void, reject: (e: Error) => void) => {\n if(!url) {\n return reject({\n code: 'NE_RT_NATRTER',\n message: 'Missing require parameter: url'\n });\n }\n try {\n const response = await fetch(url);\n manifest = JSON.parse(await response.text());\n\n if(isValidManifest(manifest)) {\n resolve(manifest);\n }\n else {\n reject({\n code: 'NE_UP_CUPDMER',\n message: 'Invalid update manifest or mismatching applicationId'\n });\n }\n }\n catch(err) {\n reject({\n code: 'NE_UP_CUPDERR',\n message: 'Unable to fetch update manifest'\n });\n }\n\n });\n};\n\nexport function install(): Promise<void> {\n return new Promise(async (resolve: any, reject: any) => {\n if(!manifest) {\n return reject({\n code: 'NE_UP_UPDNOUF',\n message: 'No update manifest loaded. Make sure that updater.checkForUpdates() is called before install().'\n });\n }\n\n try {\n const response = await fetch(manifest.resourcesURL);\n const resourcesBuffer = await response.arrayBuffer();\n await filesystem.writeBinaryFile(window.NL_PATH + \"/resources.neu\", resourcesBuffer);\n\n resolve({\n success: true,\n message: 'Update installed. Restart the process to see updates'\n });\n }\n catch(err) {\n reject({\n code: 'NE_UP_UPDINER',\n message: 'Update installation error'\n });\n }\n });\n};\n\n</FILE>\n<FILE path=\"src/api/server.ts\">\nimport { sendMessage } from '../ws/websocket';\n\nexport function mount(path: string, target: string): Promise<void> {\n return sendMessage('server.mount', { path, target });\n}\n\nexport function unmount(path: string): Promise<void> {\n return sendMessage('server.unmount', { path });\n}\n\nexport function getMounts(): Promise<Record<string, string>> {\n return sendMessage('server.getMounts');\n}\n</FILE>\n<FILE path=\"src/api/events.ts\">\nimport { sendMessage } from '../ws/websocket';\n\nexport * from '../browser/events';\n\nexport function broadcast(event: string, data?: any): Promise<void> {\n return sendMessage('events.broadcast', {event, data});\n};\n\n</FILE>\n<FILE path=\"src/api/resources.ts\">\nimport { sendMessage } from '../ws/websocket';\nimport { base64ToBytesArray } from '../helpers';\nimport { Stats } from '../types/api/resources';\n\nexport function getFiles(): Promise<string[]> {\n return sendMessage('resources.getFiles');\n};\n\nexport function getStats(path: string): Promise<Stats> {\n return sendMessage('resources.getStats', { path });\n};\n\nexport function extractFile(path: string, destination: string): Promise<void> {\n return sendMessage('resources.extractFile', { path, destination });\n};\n\nexport function extractDirectory(path: string, destination: string): Promise<void> {\n return sendMessage('resources.extractDirectory', { path, destination });\n};\n\nexport function readFile(path: string): Promise<string> {\n return sendMessage('resources.readFile', { path });\n};\n\nexport function readBinaryFile(path: string): Promise<ArrayBuffer> {\n return new Promise((resolve: any, reject: any) => {\n sendMessage('resources.readBinaryFile', { path })\n .then((base64Data: string) => {\n resolve(base64ToBytesArray(base64Data));\n })\n .catch((error: any) => {\n reject(error);\n });\n });\n};\n\n</FILE>\n<FILE path=\"src/api/custom.ts\">\nimport { sendMessage } from '../ws/websocket';\n\nexport function getMethods(): Promise<string[]> {\n return sendMessage('custom.getMethods');\n};\n\n</FILE>\n<FILE path=\"src/api/init.ts\">\nimport { version } from '../../package.json';\nimport * as websocket from '../ws/websocket';\nimport * as debug from './debug';\nimport * as events from './events';\nimport type { InitOptions } from '../types/api/init';\n\nlet initialized = false;\n\nexport function init(options: InitOptions = {}): void {\n options = { exportCustomMethods: true ,...options };\n\n if(initialized) {\n return;\n }\n\n websocket.init();\n\n if(window.NL_ARGS.find((arg) => arg == '--neu-dev-auto-reload')) {\n events.on('neuDev_reloadApp', async () => {\n await debug.log('Reloading the application...');\n location.reload();\n });\n }\n\n if(options.exportCustomMethods && window.NL_CMETHODS && window.NL_CMETHODS.length > 0) {\n for(const method of window.NL_CMETHODS) {\n Neutralino.custom[method] = (...args) => {\n let data = {};\n for(const [argi, argv] of args.entries()) {\n if(typeof argv == 'object' && !Array.isArray(argv) && argv != null) {\n data = {...data, ...argv};\n }\n else {\n data = {...data, ['arg' + argi]: argv};\n }\n }\n return websocket.sendMessage('custom.' + method, data);\n };\n }\n }\n\n window.NL_CVERSION = version;\n window.NL_CCOMMIT = '425c526c318342e0e5d0f17caceef2a53049eda4'; // only the build server will update this\n initialized = true;\n}\n\n</FILE>\n<FILE path=\"src/api/debug.ts\">\nimport { sendMessage } from '../ws/websocket';\nimport type { LoggerType } from '../types/enums';\n\nexport function log(message: string, type?: LoggerType): Promise<void> {\n return sendMessage('debug.log', { message, type });\n};\n\n</FILE>\n<FILE path=\"src/api/clipboard.ts\">\nimport { sendMessage } from '../ws/websocket';\nimport { arrayBufferToBase64 } from '../helpers';\nimport type { ClipboardImage } from '../types/api/clipboard';\nimport type { ClipboardFormat } from '../types/enums';\n\nexport function getFormat(): Promise<ClipboardFormat> {\n return sendMessage('clipboard.getFormat');\n};\n\nexport function readText(): Promise<string> {\n return sendMessage('clipboard.readText');\n};\n\nexport function readImage(format: string = ''): Promise < ClipboardImage | null > {\n\treturn new Promise((resolve: any, reject: any) => {\n\t\tsendMessage('clipboard.readImage')\n\t\t\t.then((image: any) => {\n\t\t\t\tif (image) {\n\t\t\t\t\tconst binaryData = window.atob(image.data);\n\t\t\t\t\tlet numOfBytes: number = image.bpp == 32 ? 4 : 3;\n\t\t\t\t\tlet len: number, pattern: number[], bytes: Uint8Array;\n\n\t\t\t\t\tswitch (format.toLowerCase()) {\n\t\t\t\t\t\tcase 'rgb':\n\t\t\t\t\t\t\tlen = image.width * image.height * 3;\n\t\t\t\t\t\t\tpattern = [0, 1, 2];\n\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\tcase 'rgba':\n\t\t\t\t\t\t\tlen = image.width * image.height * 4;\n\t\t\t\t\t\t\tpattern = [0, 1, 2, 3];\n\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\tcase 'argb':\n\t\t\t\t\t\t\tlen = image.width * image.height * 4;\n\t\t\t\t\t\t\tpattern = [3, 0, 1, 2];\n\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\tcase 'bgra':\n\t\t\t\t\t\t\tlen = image.width * image.height * 4;\n\t\t\t\t\t\t\tpattern = [2, 1, 0, 3];\n\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\tdefault:\n\t\t\t\t\t\t\tlen = binaryData.length;\n\t\t\t\t\t\t\tbytes = new Uint8Array(len);\n\t\t\t\t\t\t\tfor (let i = 0; i < len; i++) {\n\t\t\t\t\t\t\t\tbytes[i] = binaryData.charCodeAt(i);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\timage.data = bytes;\n\t\t\t\t\t\t\tresolve(image);\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\tbytes = new Uint8Array(len);\n\t\t\t\t\tlet isLittleEndian: boolean = new Uint8Array(new Uint32Array([0x000000ff]).buffer)[0] == 0xff;\n\t\t\t\t\tlet byteA: number, byteB: number, byteC: number, byteD: number, uint32: number;\n\t\t\t\t\tlet rgba: number[] = [];\n\t\t\t\t\tlet outIndex: number = 0;\n\t\t\t\t\tfor (let i = 0; i < binaryData.length; i += numOfBytes) {\n\t\t\t\t\t\tbyteA = binaryData.charCodeAt(i);\n\t\t\t\t\t\tbyteB = binaryData.charCodeAt(i + 1);\n\t\t\t\t\t\tbyteC = binaryData.charCodeAt(i + 2);\n\t\t\t\t\t\tbyteD = numOfBytes == 4 ? binaryData.charCodeAt(i + 3) : 0xff;\n\t\t\t\t\t\tif (isLittleEndian) {\n\t\t\t\t\t\t\tuint32 = ((byteD << 24) | (byteC << 16) | (byteB << 8) | byteA) >>> 0;\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tuint32 = ((byteA << 24) | (byteB << 16) | (byteC << 8) | byteD) >>> 0;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\trgba = [(uint32 >> image.redShift) & 0xff, (uint32 >> image.greenShift) & 0xff, (uint32 >> image.blueShift) & 0xff, (uint32 >> image.alphaShift) & 0xff]\n\t\t\t\t\t\tpattern.forEach((el, index) => {\n\t\t\t\t\t\t\tbytes[index + outIndex] = rgba[el];\n\t\t\t\t\t\t});\n\t\t\t\t\t\toutIndex += pattern.length;\n\t\t\t\t\t}\n\t\t\t\t\timage.data = bytes;\n\t\t\t\t}\n\t\t\t\tresolve(image);\n\t\t\t})\n\t\t\t.catch((error: any) => {\n\t\t\t\treject(error);\n\t\t\t});\n\t});\n};\n\nexport function writeText(data: string): Promise<void> {\n return sendMessage('clipboard.writeText', { data });\n};\n\nexport function writeImage(image: ClipboardImage): Promise<void> {\n const props: any = {...image};\n if(image?.data) {\n props.data = arrayBufferToBase64(image.data);\n }\n return sendMessage('clipboard.writeImage', props);\n};\n\nexport function readHTML(): Promise<string> {\n\treturn sendMessage('clipboard.readHTML');\n};\n\nexport function writeHTML(data: string): Promise<void> {\n\treturn sendMessage('clipboard.writeHTML', { data });\n};\n\nexport function clear(): Promise<void> {\n return sendMessage('clipboard.clear');\n};\n\n</FILE>\n<FILE path=\"src/api/computer.ts\">\nimport { sendMessage } from '../ws/websocket';\nimport type {\n MemoryInfo,\n KernelInfo,\n OSInfo,\n CPUInfo,\n Display,\n MousePosition\n} from '../types/api/computer';\n\nexport function getMemoryInfo(): Promise<MemoryInfo> {\n return sendMessage('computer.getMemoryInfo');\n};\n\nexport function getArch(): Promise<string> {\n return sendMessage('computer.getArch');\n};\n\nexport function getKernelInfo(): Promise<KernelInfo> {\n return sendMessage('computer.getKernelInfo');\n};\n\nexport function getOSInfo(): Promise<OSInfo> {\n return sendMessage('computer.getOSInfo');\n};\n\nexport function getCPUInfo(): Promise<CPUInfo> {\n return sendMessage('computer.getCPUInfo');\n};\n\nexport function getDisplays(): Promise<Display[]> {\n return sendMessage('computer.getDisplays');\n};\n\nexport function getMousePosition(): Promise<MousePosition> {\n return sendMessage('computer.getMousePosition');\n};\n\n</FILE>\n<FILE path=\"src/api/app.ts\">\nimport { sendMessage } from '../ws/websocket';\nimport * as os from './os';\nimport type { RestartOptions } from \"../types/api/app\"\n\nexport function exit(code?: number): Promise<void> {\n return sendMessage('app.exit', { code });\n};\n\nexport function killProcess(): Promise<void> {\n return sendMessage('app.killProcess');\n};\n\nexport function restartProcess(options?: RestartOptions): Promise<void> {\n return new Promise(async (resolve: () => void) => {\n let command = window.NL_ARGS.reduce((acc: string, arg: string) => {\n if(arg.includes(' ')) {\n arg = `\"${arg}\"`\n }\n acc += ' ' + arg;\n return acc;\n }, '');\n\n if(options?.args) {\n command += ' ' + options.args;\n }\n\n await os.execCommand(command, {background: true});\n exit();\n resolve();\n });\n};\n\nexport function getConfig(): Promise<any> {\n return sendMessage('app.getConfig');\n};\n\nexport function broadcast(event: string, data?: any): Promise<void> {\n return sendMessage('app.broadcast', {event, data});\n};\n\nexport function readProcessInput(readAll?: boolean): Promise<string> {\n return sendMessage('app.readProcessInput', { readAll });\n};\n\nexport function writeProcessOutput(data: string): Promise<void> {\n return sendMessage('app.writeProcessOutput', { data });\n};\n\nexport function writeProcessError(data: string): Promise<void> {\n return sendMessage('app.writeProcessError', { data });\n};\n\n</FILE>\n<FILE path=\"src/api/filesystem.ts\">\nimport { sendMessage } from '../ws/websocket';\nimport { base64ToBytesArray, arrayBufferToBase64 } from '../helpers';\nimport type {\n DirectoryEntry,\n DirectoryReaderOptions,\n FileReaderOptions,\n CopyOptions,\n OpenedFile,\n Stats,\n Watcher,\n PathParts,\n Permissions,\n PermissionsMode,\n} from '../types/api/filesystem';\n\nexport function createDirectory(path: string): Promise<void> {\n return sendMessage('filesystem.createDirectory', { path });\n};\n\nexport function remove(path: string): Promise<void> {\n return sendMessage('filesystem.remove', { path });\n};\n\nexport function writeFile(path: string, data: string): Promise<void> {\n return sendMessage('filesystem.writeFile', { path, data });\n};\n\nexport function appendFile(path: string, data: string): Promise<void> {\n return sendMessage('filesystem.appendFile', { path, data });\n};\n\nexport function writeBinaryFile(path: string, data: ArrayBuffer): Promise<void> {\n return sendMessage('filesystem.writeBinaryFile', {\n path,\n data: arrayBufferToBase64(data)\n });\n};\n\nexport function appendBinaryFile(path: string, data: ArrayBuffer): Promise<void> {\n return sendMessage('filesystem.appendBinaryFile', {\n path,\n data: arrayBufferToBase64(data)\n });\n};\n\nexport function readFile(path: string, options?: FileReaderOptions): Promise<string> {\n return sendMessage('filesystem.readFile', { path, ...options });\n};\n\nexport function readBinaryFile(path: string, options?: FileReaderOptions): Promise<ArrayBuffer> {\n return new Promise((resolve: any, reject: any) => {\n sendMessage('filesystem.readBinaryFile', { path, ...options })\n .then((base64Data: string) => {\n resolve(base64ToBytesArray(base64Data));\n })\n .catch((error: any) => {\n reject(error);\n });\n });\n};\n\nexport function openFile(path: string): Promise<number> {\n return sendMessage('filesystem.openFile', { path });\n};\n\nexport function createWatcher(path: string): Promise<number> {\n return sendMessage('filesystem.createWatcher', { path });\n};\n\nexport function removeWatcher(id: number): Promise<number> {\n return sendMessage('filesystem.removeWatcher', { id });\n};\n\nexport function getWatchers(): Promise<Watcher[]> {\n return sendMessage('filesystem.getWatchers');\n};\n\nexport function updateOpenedFile(id: number, event: string, data?: any): Promise<void> {\n return sendMessage('filesystem.updateOpenedFile', { id, event, data });\n};\n\nexport function getOpenedFileInfo(id: number): Promise<OpenedFile> {\n return sendMessage('filesystem.getOpenedFileInfo', { id });\n};\n\nexport function readDirectory(path: string, options?: DirectoryReaderOptions): Promise<DirectoryEntry[]> {\n return sendMessage('filesystem.readDirectory', { path, ...options });\n};\n\nexport function copy(source: string, destination: string, options?: CopyOptions ): Promise<void> {\n return sendMessage('filesystem.copy', { source, destination, ...options } );\n};\n\nexport function move(source: string, destination: string): Promise<void> {\n return sendMessage('filesystem.move', { source, destination });\n};\n\nexport function getStats(path: string): Promise<Stats> {\n return sendMessage('filesystem.getStats', { path });\n};\n\nexport function getAbsolutePath(path: string): Promise<string> {\n return sendMessage('filesystem.getAbsolutePath', { path });\n};\n\nexport function getRelativePath(path: string, base?: string): Promise<string> {\n return sendMessage('filesystem.getRelativePath', { path, base });\n};\n\nexport function getPathParts(path: string): Promise<PathParts> {\n return sendMessage('filesystem.getPathParts', { path });\n};\n\nexport function getPermissions(path: string): Promise<Permissions> {\n return sendMessage('filesystem.getPermissions', { path });\n};\n\nexport function setPermissions(path: string, permissions: Permissions, mode: PermissionsMode): Promise<void> {\n return sendMessage('filesystem.setPermissions', { path, ...permissions, mode });\n};\n\nexport function getJoinedPath(...paths: string[]): Promise<string> {\n return sendMessage('filesystem.getJoinedPath', { paths });\n};\n\nexport function getNormalizedPath(path: string): Promise<string> {\n return sendMessage('filesystem.getNormalizedPath', { path });\n};\n\nexport function getUnnormalizedPath(path: string): Promise<string> {\n return sendMessage('filesystem.getUnnormalizedPath', { path });\n};\n\n</FILE>\n<FILE path=\"src/api/storage.ts\">\nimport { sendMessage } from '../ws/websocket';\n\nexport function setData(key: string, data: string | null): Promise<void> {\n return sendMessage('storage.setData', { key, data });\n};\n\nexport function getData(key: string): Promise<string> {\n return sendMessage('storage.getData', { key });\n};\n\nexport function removeData(key: string): Promise<void> {\n return sendMessage('storage.removeData', { key });\n};\n\nexport function getKeys(): Promise<string[]> {\n return sendMessage('storage.getKeys');\n};\n\nexport function clear(): Promise<void> {\n return sendMessage('storage.clear');\n};\n\n</FILE>\n<FILE path=\"src/api/extensions.ts\">\nimport * as websocket from '../ws/websocket';\nimport type { ExtensionStats } from '../types/api/extensions';\n\nexport function dispatch(extensionId: string, event: string, data?: any): Promise<void> {\n return new Promise(async (resolve: any, reject: any) => {\n const stats = await getStats();\n if(!stats.loaded.includes(extensionId)) {\n reject({\n code: 'NE_EX_EXTNOTL',\n message: `${extensionId} is not loaded`\n });\n }\n else if(stats.connected.includes(extensionId)) {\n try {\n const result = await websocket.sendMessage('extensions.dispatch', {extensionId, event, data});\n resolve(result);\n }\n catch(err: any) {\n reject(err);\n }\n }\n else {\n // loaded but not connected yet.\n websocket.sendWhenExtReady(extensionId, {\n method: 'extensions.dispatch',\n data: {extensionId, event, data}, resolve, reject\n });\n }\n });\n};\n\nexport function broadcast(event: string, data?: any): Promise<void> {\n return websocket.sendMessage('extensions.broadcast', {event, data});\n};\n\nexport function getStats(): Promise<ExtensionStats> {\n return websocket.sendMessage('extensions.getStats');\n};\n\n</FILE>\n<FILE path=\"src/types/events.ts\">\nexport interface Response {\n success: boolean;\n message: string;\n }\n \n export type Builtin =\n 'ready' |\n 'trayMenuItemClicked' |\n 'windowClose' |\n 'serverOffline' |\n 'clientConnect' |\n 'clientDisconnect' |\n 'appClientConnect' |\n 'appClientDisconnect' |\n 'extClientConnect' |\n 'extClientDisconnect' |\n 'extensionReady' |\n 'neuDev_reloadApp'\n</FILE>\n<FILE path=\"src/types/enums.ts\">\n// debug\nexport enum LoggerType {\n WARNING = 'WARNING',\n ERROR = 'ERROR',\n INFO = 'INFO'\n }\n\n// os\nexport enum Icon {\n WARNING = 'WARNING',\n ERROR = 'ERROR',\n INFO = 'INFO',\n QUESTION = 'QUESTION'\n}\n\nexport enum MessageBoxChoice {\n OK = 'OK',\n OK_CANCEL = 'OK_CANCEL',\n YES_NO = 'YES_NO',\n YES_NO_CANCEL = 'YES_NO_CANCEL',\n RETRY_CANCEL = 'RETRY_CANCEL',\n ABORT_RETRY_IGNORE = 'ABORT_RETRY_IGNORE'\n}\n\n//clipboard\nexport enum ClipboardFormat {\n unknown = 'unknown',\n text = 'text',\n image = 'image'\n}\n\n// NL_GLOBALS\nexport enum Mode {\n window = 'window',\n browser = 'browser',\n cloud = 'cloud',\n chrome = 'chrome'\n}\n\nexport enum OperatingSystem {\n Linux = 'Linux',\n Windows = 'Windows',\n Darwin = 'Darwin',\n FreeBSD = 'FreeBSD',\n Unknown = 'Unknown'\n}\n\nexport enum Architecture {\n x64 = 'x64',\n arm = 'arm',\n itanium = 'itanium',\n ia32 = 'ia32',\n unknown = 'unknown'\n}\n\n</FILE>\n<FILE path=\"src/types/api/window.ts\">\nexport interface WindowOptions extends WindowSizeOptions, WindowPosOptions {\n title?: string;\n icon?: string;\n fullScreen?: boolean;\n alwaysOnTop?: boolean;\n enableInspector?: boolean;\n borderless?: boolean;\n maximize?: boolean;\n hidden?: boolean;\n maximizable?: boolean;\n useSavedState?: boolean;\n exitProcessOnClose?: boolean;\n extendUserAgentWith?: string;\n injectGlobals?: boolean;\n injectClientLibrary?: boolean;\n injectScript?: string;\n processArgs?: string;\n}\n\nexport interface WindowSizeOptions {\n width?: number;\n height?: number;\n minWidth?: number;\n minHeight?: number;\n maxWidth?: number;\n maxHeight?: number;\n resizable?: boolean;\n}\nexport interface WindowPosOptions {\n x?: number;\n y?: number;\n center?: boolean;\n}\nexport interface WindowMenu extends Array<WindowMenuItem> {}\n\nexport interface WindowMenuItem {\n id?: string;\n text: string;\n action?: string;\n shortcut?: string;\n isDisabled?: boolean;\n isChecked?: boolean;\n menuItems?: WindowMenuItem[];\n}\n\n</FILE>\n<FILE path=\"src/types/api/os.ts\">\nexport interface ExecCommandOptions {\n stdIn?: string;\n background?: boolean;\n cwd?: string;\n}\n\nexport interface ExecCommandResult {\n pid: number;\n stdOut: string;\n stdErr: string;\n exitCode: number;\n}\n\nexport interface SpawnedProcess {\n id: number;\n pid: number;\n}\n\nexport interface SpawnedProcessOptions {\n cwd?: string;\n envs?: Record<string, string>;\n}\n\nexport interface Envs {\n [key: string]: string;\n}\n\nexport interface OpenDialogOptions {\n multiSelections?: boolean;\n filters?: Filter[];\n defaultPath?: string;\n}\n\nexport interface FolderDialogOptions {\n defaultPath?: string;\n}\n\nexport interface SaveDialogOptions {\n forceOverwrite?: boolean;\n filters?: Filter[];\n defaultPath?: string;\n}\n\nexport interface Filter {\n name: string;\n extensions: string[];\n}\n\nexport interface TrayOptions {\n icon: string;\n menuItems: TrayMenuItem[];\n}\n\nexport interface TrayMenuItem {\n id?: string;\n text: string;\n isDisabled?: boolean;\n isChecked?: boolean;\n}\n\nexport type KnownPath =\n 'config' |\n 'data' |\n 'cache' |\n 'documents' |\n 'pictures' |\n 'music' |\n 'video' |\n 'downloads' |\n 'savedGames1' |\n 'savedGames2' | \n 'temp'\n\n</FILE>\n<FILE path=\"src/types/api/updater.ts\">\nexport interface Manifest {\n applicationId: string;\n version: string;\n resourcesURL: string;\n}\n\n</FILE>\n<FILE path=\"src/types/api/resources.ts\">\nexport interface Stats {\n size: number;\n isFile: boolean;\n isDirectory: boolean;\n}\n\n</FILE>\n<FILE path=\"src/types/api/init.ts\">\nexport interface InitOptions {\n exportCustomMethods?: boolean;\n}\n</FILE>\n<FILE path=\"src/types/api/clipboard.ts\">\nexport interface ClipboardImage {\n width: number;\n height: number;\n bpp: number;\n bpr: number;\n redMask: number;\n greenMask: number;\n blueMask: number;\n redShift: number;\n greenShift: number;\n blueShift: number;\n data: ArrayBuffer;\n}\n\n</FILE>\n<FILE path=\"src/types/api/protocol.ts\">\nexport type ErrorCode =\n 'NE_FS_DIRCRER' |\n 'NE_FS_RMDIRER' |\n 'NE_FS_FILRDER' |\n 'NE_FS_FILWRER' |\n 'NE_FS_FILRMER' |\n 'NE_FS_NOPATHE' |\n 'NE_FS_COPYFER' |\n 'NE_FS_MOVEFER' |\n 'NE_OS_INVMSGA' |\n 'NE_OS_INVKNPT' |\n 'NE_ST_INVSTKY' |\n 'NE_ST_STKEYWE' |\n 'NE_RT_INVTOKN' |\n 'NE_RT_NATPRME' |\n 'NE_RT_APIPRME' |\n 'NE_RT_NATRTER' |\n 'NE_RT_NATNTIM' |\n 'NE_CL_NSEROFF' |\n 'NE_EX_EXTNOTC' |\n 'NE_UP_CUPDMER' |\n 'NE_UP_CUPDERR' |\n 'NE_UP_UPDNOUF' |\n 'NE_UP_UPDINER'\n\nexport interface Error {\n code: ErrorCode;\n message: string;\n}\n\n</FILE>\n<FILE path=\"src/types/api/computer.ts\">\nexport interface MemoryInfo {\n physical: {\n total: number;\n available: number;\n },\n virtual: {\n total: number;\n available: number;\n }\n}\n\nexport interface KernelInfo {\n variant: string;\n version: string;\n}\n\nexport interface OSInfo {\n name: string;\n description: string;\n version: string;\n}\n\nexport interface CPUInfo {\n vendor: string;\n model: string;\n frequency: number;\n architecture: string;\n logicalThreads: number;\n physicalCores: number;\n physicalUnits: number;\n}\n\nexport interface Display {\n id: number;\n resolution: Resolution;\n dpi: number;\n bpp: number;\n refreshRate: number;\n}\n\nexport interface Resolution {\n width: number;\n height: number;\n}\n\nexport interface MousePosition {\n x: number;\n y: number;\n}\n</FILE>\n<FILE path=\"src/types/api/app.ts\">\nexport interface OpenActionOptions {\n url: string;\n}\n\nexport interface RestartOptions {\n args: string;\n}\n</FILE>\n<FILE path=\"src/types/api/filesystem.ts\">\nexport interface DirectoryEntry {\n entry: string;\n path: string;\n type: string;\n}\n\nexport interface FileReaderOptions {\n pos: number;\n size: number;\n}\n\nexport interface DirectoryReaderOptions {\n recursive: boolean;\n}\n\nexport interface OpenedFile {\n id: number;\n eof: boolean;\n pos: number;\n lastRead: number;\n}\n\nexport interface Stats {\n size: number;\n isFile: boolean;\n isDirectory: boolean;\n createdAt: number;\n modifiedAt: number;\n}\n\nexport interface Watcher {\n id: number;\n path: string;\n}\n\nexport interface CopyOptions {\n recursive: boolean;\n overwrite: boolean;\n skip: boolean;\n}\n\nexport interface PathParts {\n rootName: string;\n rootDirectory: string;\n rootPath: string;\n relativePath: string;\n parentPath: string;\n filename: string;\n stem: string;\n extension: string;\n}\n\nexport interface Permissions {\n all: boolean;\n ownerAll: boolean;\n ownerRead: boolean;\n ownerWrite: boolean;\n ownerExec: boolean;\n groupAll: boolean;\n groupRead: boolean;\n groupWrite: boolean;\n groupExec: boolean;\n othersAll: boolean;\n othersRead: boolean;\n othersWrite: boolean;\n othersExec: boolean;\n}\n\nexport type PermissionsMode = \n 'ADD' |\n 'REPLACE' | \n 'REMOVE'\n\n</FILE>\n<FILE path=\"src/types/api/extensions.ts\">\nexport interface ExtensionStats {\n loaded: string[];\n connected: string[];\n}\n\n</FILE>\n<FILE path=\"src/ws/websocket.ts\">\nimport * as events from '../browser/events';\nimport { base64ToBytesArray } from '../helpers';\n\nlet ws;\nconst nativeCalls = {};\nconst offlineMessageQueue = [];\nconst extensionMessageQueue = {}\n\nexport function init() {\n initAuth();\n const connectToken: string = getAuthToken().split('.')[1];\n const hostname: string = (window.NL_GINJECTED || window.NL_CINJECTED) ? \n '127.0.0.1' : window.location.hostname;\n ws = new WebSocket(`ws://${hostname}:${window.NL_PORT}?connectToken=${connectToken}`);\n registerLibraryEvents();\n registerSocketEvents();\n}\n\nexport function sendMessage(method: string, data?: any): Promise<any> {\n return new Promise((resolve: any, reject: any) => {\n\n if(ws?.readyState != WebSocket.OPEN) {\n sendWhenReady({method, data, resolve, reject});\n return;\n }\n\n const id: string = uuidv4();\n const accessToken: string = getAuthToken();\n\n nativeCalls[id] = {resolve, reject};\n\n ws.send(JSON.stringify({\n id,\n method,\n data,\n accessToken\n }));\n\n });\n}\n\nexport function sendWhenReady(message: any) {\n offlineMessageQueue.push(message);\n}\n\nexport function sendWhenExtReady(extensionId: string, message: any) {\n if(extensionId in extensionMessageQueue) {\n extensionMessageQueue[extensionId].push(message);\n }\n else {\n extensionMessageQueue[extensionId] = [message];\n }\n}\n\nfunction registerLibraryEvents() {\n events.on('ready', async () => {\n await processQueue(offlineMessageQueue);\n\n if(!window.NL_EXTENABLED) {\n return;\n }\n\n let stats = await sendMessage('extensions.getStats');\n for(let extension of stats.connected) {\n events.dispatch('extensionReady', extension);\n }\n });\n\n events.on('extClientConnect', (evt) => {\n events.dispatch('extensionReady', evt.detail);\n });\n\n if(!window.NL_EXTENABLED) {\n return;\n }\n\n events.on('extensionReady', async (evt) => {\n if(evt.detail in extensionMessageQueue) {\n await processQueue(extensionMessageQueue[evt.detail]);\n delete extensionMessageQueue[evt.detail];\n }\n });\n}\n\nfunction registerSocketEvents() {\n ws.addEventListener('message', (event) => {\n const message = JSON.parse(event.data);\n\n if(message.id && message.id in nativeCalls) {\n // Native call response\n if(message.data?.error) {\n nativeCalls[message.id].reject(message.data.error);\n if(message.data.error.code == 'NE_RT_INVTOKN') {\n // Invalid native method token\n handleNativeMethodTokenError();\n }\n }\n else if(message.data?.success) {\n nativeCalls[message.id]\n .resolve(message.data.hasOwnProperty('returnValue') ? message.data.returnValue\n : message.data);\n }\n delete nativeCalls[message.id];\n }\n else if(message.event) {\n // Event from process\n if(message.event == 'openedFile' && message?.data?.action == 'dataBinary') {\n message.data.data = base64ToBytesArray(message.data.data);\n }\n events.dispatch(message.event, message.data);\n }\n });\n\n ws.addEventListener('open', async (event) => {\n events.dispatch('ready');\n });\n\n ws.addEventListener('close', async (event) => {\n const error = {\n code: 'NE_CL_NSEROFF',\n message: 'Neutralino server is offline. Try restarting the application'\n };\n events.dispatch('serverOffline', error);\n });\n\n ws.addEventListener('error', async (event) => {\n handleConnectError();\n });\n}\n\nasync function processQueue(messageQueue: any[]) {\n while(messageQueue.length > 0) {\n const message = messageQueue.shift();\n try {\n const response = await sendMessage(message.method, message.data);\n message.resolve(response);\n }\n catch(err: any) {\n message.reject(err);\n }\n }\n}\n\nfunction handleNativeMethodTokenError() {\n ws.close();\n document.body.innerText = '';\n document.write('<code>NE_RT_INVTOKN</code>: Neutralinojs application cannot' +\n ' execute native methods since <code>NL_TOKEN</code> is invalid.');\n}\n\nfunction handleConnectError() {\n document.body.innerText = '';\n document.write('<code>NE_CL_IVCTOKN</code>: Neutralinojs application cannot' +\n ' connect with the framework core using <code>NL_TOKEN</code>.');\n}\n\nfunction initAuth() {\n if (window.NL_TOKEN) {\n sessionStorage.setItem('NL_TOKEN', window.NL_TOKEN);\n }\n}\nfunction getAuthToken() {\n return window.NL_TOKEN || sessionStorage.getItem('NL_TOKEN') || '';\n}\n\n// From: https://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid\nfunction uuidv4(): string {\n return \"10000000-1000-4000-8000-100000000000\".replace(/[018]/g, (c: any) =>\n (c ^ crypto.getRandomValues(new Uint8Array(1))[0] & 15 >> c / 4).toString(16)\n );\n}\n\n</FILE>\n<FILE path=\"scripts/rz.py\">\n#!/usr/bin/env python3\n\nimport sys\nimport os\nimport shutil\nfrom datetime import datetime\n\nRZ_DIR = './.releasezri'\nTEMPLATE_FILE = './.releasezri/template.md'\nCHANGELOG_FILE = './CHANGELOG.md'\nTMP_DIR = './.tmprz'\nRELEASE_NOTE_FILE = './.tmprz/release_notes.md'\nRZ_VERSION = '1.3.0'\nVERSION = ''\nVERSION_WITH_V = ''\n\ndef get_cli_option_value(option):\n for arg in sys.argv:\n if option in arg:\n return arg.split('=')[1]\n return ''\n\ndef apply_notes_to_template(note):\n md = ''\n today = datetime.today()\n with open(TEMPLATE_FILE, 'r') as tf:\n md = tf.read() \\\n .replace('{RZ_RZVERSION}', RZ_VERSION) \\\n .replace('{RZ_VERSION}', VERSION) \\\n .replace('{RZ_DATE}', today.strftime('%Y-%m-%d')) \\\n .replace('{RZ_TIME}', today.strftime('%H:%M:%S')) \\\n .replace('{RZ_CHANGELOG}', note) \\\n .replace('{RZ_TOP}', get_cli_option_value('--top')) \\\n .strip()\n return md\n\ndef parse_release_note():\n note = ''\n collect = False\n updated_changelog = ''\n\n with open(CHANGELOG_FILE, 'r') as cf:\n for line in cf:\n if '## Unreleased' in line:\n collect = True\n continue\n if '## v' in line:\n break\n if collect:\n note += line\n return note\n\ndef save_release_note(note):\n os.makedirs(TMP_DIR, exist_ok = True)\n\n with open(RELEASE_NOTE_FILE, 'w') as rf:\n rf.write(note)\n\ndef update_changelog():\n updated_changelog = ''\n pre_replace = '''## Unreleased\n\n'''\n with open(CHANGELOG_FILE, 'r') as cf:\n replace_text = pre_replace + '## ' + VERSION_WITH_V\n updated_changelog = cf.read().replace('## Unreleased', replace_text)\n\n with open(CHANGELOG_FILE, 'w') as cf:\n cf.write(updated_changelog)\n\ndef create_note():\n print('INFO: Preparing release notes...')\n note = parse_release_note()\n if note.strip() == '':\n if '--no-changes' in sys.argv:\n note = 'No changes — this version is similar to the previous version'\n else:\n print('ERROR: No changes so far.')\n sys.exit(1)\n print('---- Release note for %s (parsed) ----' % VERSION_WITH_V)\n print('----')\n\n note = apply_notes_to_template(note)\n print('---- Release note for %s (applied to template) ----' % VERSION_WITH_V)\n print(note)\n print('----')\n save_release_note(note)\n\n print('INFO: Updating change log...')\n update_changelog()\n\n print('OK: All done. Run \"cleanup\" command after using release note.')\n\ndef cleanup():\n shutil.rmtree(TMP_DIR)\n print('OK: All done.')\n\ndef print_art():\n print('''\n ____ __ _____ _\n / __ \\___ / /__ ____ ________/__ / _____(_)\n / /_/ / _ \\/ / _ \\/ __ `/ ___/ _ \\/ / / ___/ /\n / _, _/ __/ / __/ /_/ (__ ) __/ /__/ / / /\n/_/ |_|\\___/_/\\___/\\__,_/____/\\___/____/_/ /_/\n ''')\n\nif __name__ == '__main__':\n print_art()\n if len(sys.argv) < 2:\n print('ERROR: Missing command (create or cleanup)')\n sys.exit(1)\n\n command = sys.argv[1]\n\n if command == 'create':\n if len(sys.argv) < 3:\n print('ERROR: Missing version argument')\n sys.exit(1)\n VERSION = sys.argv[2]\n VERSION_WITH_V = 'v' + VERSION\n create_note()\n\n elif command == 'cleanup':\n cleanup()\n\n elif command == 'check':\n if parse_release_note().strip() == '':\n print('ST_NO_CHANGES')\n else:\n print('ST_HAS_CHANGES')\n\n else:\n print('ERROR: Invalid command!')\n\n</FILE>" } ]
[ { "role": "system", "content": "You are an expert coding assistant specializing in Javascript GUI frameworks." }, { "role": "user", "content": "Instruction: Added Api support for Env variables in os.spawnProcess (#152)\n\nOld scripts:\n<FILE path=\"src/api/os.ts\">\nimport { sendMessage } from '../ws/websocket';\nimport type { MessageBoxChoice, Icon } from '../types/enums';\nimport type {\n Envs,\n ExecCommandOptions,\n ExecCommandResult,\n FolderDialogOptions,\n KnownPath,\n OpenDialogOptions,\n SaveDialogOptions,\n SpawnedProcess,\n TrayOptions\n} from '../types/api/os';\n\nexport function execCommand(command: string, options?: ExecCommandOptions): Promise<ExecCommandResult> {\n return sendMessage('os.execCommand', { command, ...options });\n};\n\nexport function spawnProcess(command: string, cwd?: string): Promise<SpawnedProcess> {\n return sendMessage('os.spawnProcess', { command, cwd });\n};\n\nexport function updateSpawnedProcess(id: number, event: string, data?: any): Promise<void> {\n return sendMessage('os.updateSpawnedProcess', { id, event, data });\n};\n\nexport function getSpawnedProcesses(): Promise<SpawnedProcess[]> {\n return sendMessage('os.getSpawnedProcesses');\n};\n\nexport function getEnv(key: string): Promise<string> {\n return sendMessage('os.getEnv', { key });\n};\n\nexport function getEnvs(): Promise<Envs> {\n return sendMessage('os.getEnvs');\n};\n\nexport function showOpenDialog(title?: string, options?: OpenDialogOptions): Promise<string[]> {\n return sendMessage('os.showOpenDialog', { title, ...options });\n};\n\nexport function showFolderDialog(title?: string, options?: FolderDialogOptions): Promise<string> {\n return sendMessage('os.showFolderDialog', { title, ...options });\n};\n\nexport function showSaveDialog(title?: string, options?: SaveDialogOptions): Promise<string> {\n return sendMessage('os.showSaveDialog', { title, ...options });\n};\n\nexport function showNotification(title: string, content: string, icon?: Icon): Promise<void> {\n return sendMessage('os.showNotification', { title, content, icon });\n};\n\nexport function showMessageBox(title: string, content: string,\n choice?: MessageBoxChoice, icon?: Icon): Promise<string> {\n return sendMessage('os.showMessageBox', { title, content, choice, icon });\n};\n\nexport function setTray(options: TrayOptions): Promise<void> {\n return sendMessage('os.setTray', options);\n};\n\nexport function open(url: string): Promise<void> {\n return sendMessage('os.open', { url });\n};\n\nexport function getPath(name: KnownPath): Promise<string> {\n return sendMessage('os.getPath', { name });\n};\n\n</FILE>\n<FILE path=\"src/types/api/os.ts\">\nexport interface ExecCommandOptions {\n stdIn?: string;\n background?: boolean;\n cwd?: string;\n}\n\nexport interface ExecCommandResult {\n pid: number;\n stdOut: string;\n stdErr: string;\n exitCode: number;\n}\n\nexport interface SpawnedProcess {\n id: number;\n pid: number;\n}\n\nexport interface Envs {\n [key: string]: string;\n}\n\nexport interface OpenDialogOptions {\n multiSelections?: boolean;\n filters?: Filter[];\n defaultPath?: string;\n}\n\nexport interface FolderDialogOptions {\n defaultPath?: string;\n}\n\nexport interface SaveDialogOptions {\n forceOverwrite?: boolean;\n filters?: Filter[];\n defaultPath?: string;\n}\n\nexport interface Filter {\n name: string;\n extensions: string[];\n}\n\nexport interface TrayOptions {\n icon: string;\n menuItems: TrayMenuItem[];\n}\n\nexport interface TrayMenuItem {\n id?: string;\n text: string;\n isDisabled?: boolean;\n isChecked?: boolean;\n}\n\nexport type KnownPath =\n 'config' |\n 'data' |\n 'cache' |\n 'documents' |\n 'pictures' |\n 'music' |\n 'video' |\n 'downloads' |\n 'savedGames1' |\n 'savedGames2' | \n 'temp'\n\n</FILE>" }, { "role": "assistant", "content": "New content:\n<FILE path=\"src/api/os.ts\">\nimport { sendMessage } from '../ws/websocket';\nimport type { MessageBoxChoice, Icon } from '../types/enums';\nimport type {\n Envs,\n ExecCommandOptions,\n ExecCommandResult,\n FolderDialogOptions,\n KnownPath,\n OpenDialogOptions,\n SaveDialogOptions,\n SpawnedProcess,\n TrayOptions,\n SpawnedProcessOptions,\n} from '../types/api/os';\n\nexport function execCommand(command: string, options?: ExecCommandOptions): Promise<ExecCommandResult> {\n return sendMessage('os.execCommand', { command, ...options });\n};\n\nexport function spawnProcess(command: string, options?: SpawnedProcessOptions): Promise<SpawnedProcess> {\n return sendMessage('os.spawnProcess', { command, ...options });\n};\n\nexport function updateSpawnedProcess(id: number, event: string, data?: any): Promise<void> {\n return sendMessage('os.updateSpawnedProcess', { id, event, data });\n};\n\nexport function getSpawnedProcesses(): Promise<SpawnedProcess[]> {\n return sendMessage('os.getSpawnedProcesses');\n};\n\nexport function getEnv(key: string): Promise<string> {\n return sendMessage('os.getEnv', { key });\n};\n\nexport function getEnvs(): Promise<Envs> {\n return sendMessage('os.getEnvs');\n};\n\nexport function showOpenDialog(title?: string, options?: OpenDialogOptions): Promise<string[]> {\n return sendMessage('os.showOpenDialog', { title, ...options });\n};\n\nexport function showFolderDialog(title?: string, options?: FolderDialogOptions): Promise<string> {\n return sendMessage('os.showFolderDialog', { title, ...options });\n};\n\nexport function showSaveDialog(title?: string, options?: SaveDialogOptions): Promise<string> {\n return sendMessage('os.showSaveDialog', { title, ...options });\n};\n\nexport function showNotification(title: string, content: string, icon?: Icon): Promise<void> {\n return sendMessage('os.showNotification', { title, content, icon });\n};\n\nexport function showMessageBox(title: string, content: string,\n choice?: MessageBoxChoice, icon?: Icon): Promise<string> {\n return sendMessage('os.showMessageBox', { title, content, choice, icon });\n};\n\nexport function setTray(options: TrayOptions): Promise<void> {\n return sendMessage('os.setTray', options);\n};\n\nexport function open(url: string): Promise<void> {\n return sendMessage('os.open', { url });\n};\n\nexport function getPath(name: KnownPath): Promise<string> {\n return sendMessage('os.getPath', { name });\n};\n\n</FILE>\n<FILE path=\"src/types/api/os.ts\">\nexport interface ExecCommandOptions {\n stdIn?: string;\n background?: boolean;\n cwd?: string;\n}\n\nexport interface ExecCommandResult {\n pid: number;\n stdOut: string;\n stdErr: string;\n exitCode: number;\n}\n\nexport interface SpawnedProcess {\n id: number;\n pid: number;\n}\n\nexport interface SpawnedProcessOptions {\n cwd?: string;\n envs?: Record<string, string>;\n}\n\nexport interface Envs {\n [key: string]: string;\n}\n\nexport interface OpenDialogOptions {\n multiSelections?: boolean;\n filters?: Filter[];\n defaultPath?: string;\n}\n\nexport interface FolderDialogOptions {\n defaultPath?: string;\n}\n\nexport interface SaveDialogOptions {\n forceOverwrite?: boolean;\n filters?: Filter[];\n defaultPath?: string;\n}\n\nexport interface Filter {\n name: string;\n extensions: string[];\n}\n\nexport interface TrayOptions {\n icon: string;\n menuItems: TrayMenuItem[];\n}\n\nexport interface TrayMenuItem {\n id?: string;\n text: string;\n isDisabled?: boolean;\n isChecked?: boolean;\n}\n\nexport type KnownPath =\n 'config' |\n 'data' |\n 'cache' |\n 'documents' |\n 'pictures' |\n 'music' |\n 'video' |\n 'downloads' |\n 'savedGames1' |\n 'savedGames2' | \n 'temp'\n\n</FILE>" } ]
[{"role":"system","content":"You are an expert coding assistant specializing in Javascript GUI frame(...TRUNCATED)
[{"role":"system","content":"You are an expert coding assistant specializing in Javascript GUI frame(...TRUNCATED)
[{"role":"system","content":"You are an expert coding assistant specializing in Javascript GUI frame(...TRUNCATED)
[{"role":"system","content":"You are an expert coding assistant specializing in Javascript GUI frame(...TRUNCATED)
[{"role":"system","content":"You are an expert coding assistant specializing in Javascript GUI frame(...TRUNCATED)
[{"role":"system","content":"You are an expert coding assistant specializing in Javascript GUI frame(...TRUNCATED)
[{"role":"system","content":"You are an expert coding assistant specializing in Javascript GUI frame(...TRUNCATED)
[{"role":"system","content":"You are an expert coding assistant specializing in Javascript GUI frame(...TRUNCATED)
End of preview. Expand in Data Studio

No dataset card yet

Downloads last month
-