neutralino.d.ts 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531
  1. export declare enum LoggerType {
  2. WARNING = "WARNING",
  3. ERROR = "ERROR",
  4. INFO = "INFO"
  5. }
  6. export declare enum Icon {
  7. WARNING = "WARNING",
  8. ERROR = "ERROR",
  9. INFO = "INFO",
  10. QUESTION = "QUESTION"
  11. }
  12. export declare enum MessageBoxChoice {
  13. OK = "OK",
  14. OK_CANCEL = "OK_CANCEL",
  15. YES_NO = "YES_NO",
  16. YES_NO_CANCEL = "YES_NO_CANCEL",
  17. RETRY_CANCEL = "RETRY_CANCEL",
  18. ABORT_RETRY_IGNORE = "ABORT_RETRY_IGNORE"
  19. }
  20. export declare enum ClipboardFormat {
  21. unknown = "unknown",
  22. text = "text",
  23. image = "image"
  24. }
  25. export declare enum Mode {
  26. window = "window",
  27. browser = "browser",
  28. cloud = "cloud",
  29. chrome = "chrome"
  30. }
  31. export declare enum OperatingSystem {
  32. Linux = "Linux",
  33. Windows = "Windows",
  34. Darwin = "Darwin",
  35. FreeBSD = "FreeBSD",
  36. Unknown = "Unknown"
  37. }
  38. export declare enum Architecture {
  39. x64 = "x64",
  40. arm = "arm",
  41. itanium = "itanium",
  42. ia32 = "ia32",
  43. unknown = "unknown"
  44. }
  45. export interface DirectoryEntry {
  46. entry: string;
  47. path: string;
  48. type: string;
  49. }
  50. export interface FileReaderOptions {
  51. pos: number;
  52. size: number;
  53. }
  54. export interface DirectoryReaderOptions {
  55. recursive: boolean;
  56. }
  57. export interface OpenedFile {
  58. id: number;
  59. eof: boolean;
  60. pos: number;
  61. lastRead: number;
  62. }
  63. export interface Stats {
  64. size: number;
  65. isFile: boolean;
  66. isDirectory: boolean;
  67. createdAt: number;
  68. modifiedAt: number;
  69. }
  70. export interface Watcher {
  71. id: number;
  72. path: string;
  73. }
  74. export interface CopyOptions {
  75. recursive: boolean;
  76. overwrite: boolean;
  77. skip: boolean;
  78. }
  79. export interface PathParts {
  80. rootName: string;
  81. rootDirectory: string;
  82. rootPath: string;
  83. relativePath: string;
  84. parentPath: string;
  85. filename: string;
  86. stem: string;
  87. extension: string;
  88. }
  89. interface Permissions$1 {
  90. all: boolean;
  91. ownerAll: boolean;
  92. ownerRead: boolean;
  93. ownerWrite: boolean;
  94. ownerExec: boolean;
  95. groupAll: boolean;
  96. groupRead: boolean;
  97. groupWrite: boolean;
  98. groupExec: boolean;
  99. othersAll: boolean;
  100. othersRead: boolean;
  101. othersWrite: boolean;
  102. othersExec: boolean;
  103. }
  104. export type PermissionsMode = "ADD" | "REPLACE" | "REMOVE";
  105. declare function createDirectory(path: string): Promise<void>;
  106. declare function remove(path: string): Promise<void>;
  107. declare function writeFile(path: string, data: string): Promise<void>;
  108. declare function appendFile(path: string, data: string): Promise<void>;
  109. declare function writeBinaryFile(path: string, data: ArrayBuffer): Promise<void>;
  110. declare function appendBinaryFile(path: string, data: ArrayBuffer): Promise<void>;
  111. declare function readFile(path: string, options?: FileReaderOptions): Promise<string>;
  112. declare function readBinaryFile(path: string, options?: FileReaderOptions): Promise<ArrayBuffer>;
  113. declare function openFile(path: string): Promise<number>;
  114. declare function createWatcher(path: string): Promise<number>;
  115. declare function removeWatcher(id: number): Promise<number>;
  116. declare function getWatchers(): Promise<Watcher[]>;
  117. declare function updateOpenedFile(id: number, event: string, data?: any): Promise<void>;
  118. declare function getOpenedFileInfo(id: number): Promise<OpenedFile>;
  119. declare function readDirectory(path: string, options?: DirectoryReaderOptions): Promise<DirectoryEntry[]>;
  120. declare function copy(source: string, destination: string, options?: CopyOptions): Promise<void>;
  121. declare function move(source: string, destination: string): Promise<void>;
  122. declare function getStats(path: string): Promise<Stats>;
  123. declare function getAbsolutePath(path: string): Promise<string>;
  124. declare function getRelativePath(path: string, base?: string): Promise<string>;
  125. declare function getPathParts(path: string): Promise<PathParts>;
  126. declare function getPermissions(path: string): Promise<Permissions$1>;
  127. declare function setPermissions(path: string, permissions: Permissions$1, mode: PermissionsMode): Promise<void>;
  128. declare function getJoinedPath(...paths: string[]): Promise<string>;
  129. declare function getNormalizedPath(path: string): Promise<string>;
  130. declare function getUnnormalizedPath(path: string): Promise<string>;
  131. export interface ExecCommandOptions {
  132. stdIn?: string;
  133. background?: boolean;
  134. cwd?: string;
  135. }
  136. export interface ExecCommandResult {
  137. pid: number;
  138. stdOut: string;
  139. stdErr: string;
  140. exitCode: number;
  141. }
  142. export interface SpawnedProcess {
  143. id: number;
  144. pid: number;
  145. }
  146. export interface SpawnedProcessOptions {
  147. cwd?: string;
  148. envs?: Record<string, string>;
  149. }
  150. export interface Envs {
  151. [key: string]: string;
  152. }
  153. export interface OpenDialogOptions {
  154. multiSelections?: boolean;
  155. filters?: Filter[];
  156. defaultPath?: string;
  157. }
  158. export interface FolderDialogOptions {
  159. defaultPath?: string;
  160. }
  161. export interface SaveDialogOptions {
  162. forceOverwrite?: boolean;
  163. filters?: Filter[];
  164. defaultPath?: string;
  165. }
  166. export interface Filter {
  167. name: string;
  168. extensions: string[];
  169. }
  170. export interface TrayOptions {
  171. icon: string;
  172. menuItems: TrayMenuItem[];
  173. }
  174. export interface TrayMenuItem {
  175. id?: string;
  176. text: string;
  177. isDisabled?: boolean;
  178. isChecked?: boolean;
  179. }
  180. export type KnownPath = "config" | "data" | "cache" | "documents" | "pictures" | "music" | "video" | "downloads" | "savedGames1" | "savedGames2" | "temp";
  181. declare function execCommand(command: string, options?: ExecCommandOptions): Promise<ExecCommandResult>;
  182. declare function spawnProcess(command: string, options?: SpawnedProcessOptions): Promise<SpawnedProcess>;
  183. declare function updateSpawnedProcess(id: number, event: string, data?: any): Promise<void>;
  184. declare function getSpawnedProcesses(): Promise<SpawnedProcess[]>;
  185. declare function getEnv(key: string): Promise<string>;
  186. declare function getEnvs(): Promise<Envs>;
  187. declare function showOpenDialog(title?: string, options?: OpenDialogOptions): Promise<string[]>;
  188. declare function showFolderDialog(title?: string, options?: FolderDialogOptions): Promise<string>;
  189. declare function showSaveDialog(title?: string, options?: SaveDialogOptions): Promise<string>;
  190. declare function showNotification(title: string, content: string, icon?: Icon): Promise<void>;
  191. declare function showMessageBox(title: string, content: string, choice?: MessageBoxChoice, icon?: Icon): Promise<string>;
  192. declare function setTray(options: TrayOptions): Promise<void>;
  193. declare function open$1(url: string): Promise<void>;
  194. declare function getPath(name: KnownPath): Promise<string>;
  195. export interface MemoryInfo {
  196. physical: {
  197. total: number;
  198. available: number;
  199. };
  200. virtual: {
  201. total: number;
  202. available: number;
  203. };
  204. }
  205. export interface KernelInfo {
  206. variant: string;
  207. version: string;
  208. }
  209. export interface OSInfo {
  210. name: string;
  211. description: string;
  212. version: string;
  213. }
  214. export interface CPUInfo {
  215. vendor: string;
  216. model: string;
  217. frequency: number;
  218. architecture: string;
  219. logicalThreads: number;
  220. physicalCores: number;
  221. physicalUnits: number;
  222. }
  223. export interface Display {
  224. id: number;
  225. resolution: Resolution;
  226. dpi: number;
  227. bpp: number;
  228. refreshRate: number;
  229. }
  230. export interface Resolution {
  231. width: number;
  232. height: number;
  233. }
  234. export interface MousePosition {
  235. x: number;
  236. y: number;
  237. }
  238. declare function getMemoryInfo(): Promise<MemoryInfo>;
  239. declare function getArch(): Promise<string>;
  240. declare function getKernelInfo(): Promise<KernelInfo>;
  241. declare function getOSInfo(): Promise<OSInfo>;
  242. declare function getCPUInfo(): Promise<CPUInfo>;
  243. declare function getDisplays(): Promise<Display[]>;
  244. declare function getMousePosition(): Promise<MousePosition>;
  245. declare function setData(key: string, data: string | null): Promise<void>;
  246. declare function getData(key: string): Promise<string>;
  247. declare function removeData(key: string): Promise<void>;
  248. declare function getKeys(): Promise<string[]>;
  249. declare function clear(): Promise<void>;
  250. declare function log(message: string, type?: LoggerType): Promise<void>;
  251. export interface OpenActionOptions {
  252. url: string;
  253. }
  254. export interface RestartOptions {
  255. args: string;
  256. }
  257. declare function exit(code?: number): Promise<void>;
  258. declare function killProcess(): Promise<void>;
  259. declare function restartProcess(options?: RestartOptions): Promise<void>;
  260. declare function getConfig(): Promise<any>;
  261. declare function broadcast(event: string, data?: any): Promise<void>;
  262. declare function readProcessInput(readAll?: boolean): Promise<string>;
  263. declare function writeProcessOutput(data: string): Promise<void>;
  264. declare function writeProcessError(data: string): Promise<void>;
  265. export interface WindowOptions extends WindowSizeOptions, WindowPosOptions {
  266. title?: string;
  267. icon?: string;
  268. fullScreen?: boolean;
  269. alwaysOnTop?: boolean;
  270. enableInspector?: boolean;
  271. borderless?: boolean;
  272. maximize?: boolean;
  273. hidden?: boolean;
  274. maximizable?: boolean;
  275. useSavedState?: boolean;
  276. exitProcessOnClose?: boolean;
  277. extendUserAgentWith?: string;
  278. injectGlobals?: boolean;
  279. injectClientLibrary?: boolean;
  280. injectScript?: string;
  281. processArgs?: string;
  282. }
  283. export interface WindowSizeOptions {
  284. width?: number;
  285. height?: number;
  286. minWidth?: number;
  287. minHeight?: number;
  288. maxWidth?: number;
  289. maxHeight?: number;
  290. resizable?: boolean;
  291. }
  292. export interface WindowPosOptions {
  293. x?: number;
  294. y?: number;
  295. center?: boolean;
  296. }
  297. export interface WindowMenu extends Array<WindowMenuItem> {
  298. }
  299. export interface WindowMenuItem {
  300. id?: string;
  301. text: string;
  302. action?: string;
  303. shortcut?: string;
  304. isDisabled?: boolean;
  305. isChecked?: boolean;
  306. menuItems?: WindowMenuItem[];
  307. }
  308. declare function setTitle(title: string): Promise<void>;
  309. declare function getTitle(): Promise<string>;
  310. declare function maximize(): Promise<void>;
  311. declare function unmaximize(): Promise<void>;
  312. declare function isMaximized(): Promise<boolean>;
  313. declare function minimize(): Promise<void>;
  314. declare function unminimize(): Promise<void>;
  315. declare function isMinimized(): Promise<boolean>;
  316. declare function setFullScreen(): Promise<void>;
  317. declare function exitFullScreen(): Promise<void>;
  318. declare function isFullScreen(): Promise<boolean>;
  319. declare function show(): Promise<void>;
  320. declare function hide(): Promise<void>;
  321. declare function isVisible(): Promise<boolean>;
  322. declare function focus$1(): Promise<void>;
  323. declare function setIcon(icon: string): Promise<void>;
  324. declare function move$1(x: number, y: number): Promise<void>;
  325. declare function center(): Promise<void>;
  326. declare function beginDrag(screenX?: number, screenY?: number): Promise<void>;
  327. declare function setDraggableRegion(DOMElementOrId: string | HTMLElement, options?: {
  328. exclude?: Array<string | HTMLElement>;
  329. }): Promise<{
  330. success: true;
  331. message: string;
  332. exclusions: {
  333. add(elements: Array<string | HTMLElement>): void;
  334. remove(elements: Array<string | HTMLElement>): void;
  335. removeAll(): void;
  336. };
  337. }>;
  338. declare function unsetDraggableRegion(DOMElementOrId: string | HTMLElement): Promise<{
  339. success: true;
  340. message: string;
  341. }>;
  342. declare function setSize(options: WindowSizeOptions): Promise<void>;
  343. declare function getSize(): Promise<WindowSizeOptions>;
  344. declare function getPosition(): Promise<WindowPosOptions>;
  345. declare function setAlwaysOnTop(onTop: boolean): Promise<void>;
  346. declare function setBorderless(borderless: boolean): Promise<void>;
  347. declare function create(url: string, options?: WindowOptions): Promise<void>;
  348. declare function snapshot(path: string): Promise<void>;
  349. declare function setMainMenu(options: WindowMenu): Promise<void>;
  350. declare function print$1(): Promise<void>;
  351. interface Response$1 {
  352. success: boolean;
  353. message: string;
  354. }
  355. export type Builtin = "ready" | "trayMenuItemClicked" | "windowClose" | "serverOffline" | "clientConnect" | "clientDisconnect" | "appClientConnect" | "appClientDisconnect" | "extClientConnect" | "extClientDisconnect" | "extensionReady" | "neuDev_reloadApp";
  356. declare function on(event: string, handler: (ev: CustomEvent) => void): Promise<Response$1>;
  357. declare function off(event: string, handler: (ev: CustomEvent) => void): Promise<Response$1>;
  358. declare function dispatch(event: string, data?: any): Promise<Response$1>;
  359. declare function broadcast$1(event: string, data?: any): Promise<void>;
  360. export interface ExtensionStats {
  361. loaded: string[];
  362. connected: string[];
  363. }
  364. declare function dispatch$1(extensionId: string, event: string, data?: any): Promise<void>;
  365. declare function broadcast$2(event: string, data?: any): Promise<void>;
  366. declare function getStats$1(): Promise<ExtensionStats>;
  367. export interface Manifest {
  368. applicationId: string;
  369. version: string;
  370. resourcesURL: string;
  371. }
  372. declare function checkForUpdates(url: string): Promise<Manifest>;
  373. declare function install(): Promise<void>;
  374. export interface ClipboardImage {
  375. width: number;
  376. height: number;
  377. bpp: number;
  378. bpr: number;
  379. redMask: number;
  380. greenMask: number;
  381. blueMask: number;
  382. redShift: number;
  383. greenShift: number;
  384. blueShift: number;
  385. data: ArrayBuffer;
  386. }
  387. declare function getFormat(): Promise<ClipboardFormat>;
  388. declare function readText(): Promise<string>;
  389. declare function readImage(format?: string): Promise<ClipboardImage | null>;
  390. declare function writeText(data: string): Promise<void>;
  391. declare function writeImage(image: ClipboardImage): Promise<void>;
  392. declare function readHTML(): Promise<string>;
  393. declare function writeHTML(data: string): Promise<void>;
  394. declare function clear$1(): Promise<void>;
  395. interface Stats$1 {
  396. size: number;
  397. isFile: boolean;
  398. isDirectory: boolean;
  399. }
  400. declare function getFiles(): Promise<string[]>;
  401. declare function getStats$2(path: string): Promise<Stats$1>;
  402. declare function extractFile(path: string, destination: string): Promise<void>;
  403. declare function extractDirectory(path: string, destination: string): Promise<void>;
  404. declare function readFile$1(path: string): Promise<string>;
  405. declare function readBinaryFile$1(path: string): Promise<ArrayBuffer>;
  406. declare function mount(path: string, target: string): Promise<void>;
  407. declare function unmount(path: string): Promise<void>;
  408. declare function getMounts(): Promise<Record<string, string>>;
  409. declare function getMethods(): Promise<string[]>;
  410. export interface InitOptions {
  411. exportCustomMethods?: boolean;
  412. }
  413. export declare function init(options?: InitOptions): void;
  414. export 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";
  415. interface Error$1 {
  416. code: ErrorCode;
  417. message: string;
  418. }
  419. declare global {
  420. interface Window {
  421. /** Mode of the application: window, browser, cloud, or chrome */
  422. NL_MODE: Mode;
  423. /** Application port */
  424. NL_PORT: number;
  425. /** Command-line arguments */
  426. NL_ARGS: string[];
  427. /** Basic authentication token */
  428. NL_TOKEN: string;
  429. /** Neutralinojs client version */
  430. NL_CVERSION: string;
  431. /** Application identifier */
  432. NL_APPID: string;
  433. /** Application version */
  434. NL_APPVERSION: string;
  435. /** Application path */
  436. NL_PATH: string;
  437. /** Application data path */
  438. NL_DATAPATH: string;
  439. /** Returns true if extensions are enabled */
  440. NL_EXTENABLED: boolean;
  441. /** Returns true if the client library is injected */
  442. NL_GINJECTED: boolean;
  443. /** Returns true if globals are injected */
  444. NL_CINJECTED: boolean;
  445. /** Operating system name: Linux, Windows, Darwin, FreeBSD, or Uknown */
  446. NL_OS: OperatingSystem;
  447. /** CPU architecture: x64, arm, itanium, ia32, or unknown */
  448. NL_ARCH: Architecture;
  449. /** Neutralinojs server version */
  450. NL_VERSION: string;
  451. /** Current working directory */
  452. NL_CWD: string;
  453. /** Identifier of the current process */
  454. NL_PID: string;
  455. /** Source of application resources: bundle or directory */
  456. NL_RESMODE: string;
  457. /** Release commit of the client library */
  458. NL_CCOMMIT: string;
  459. /** An array of custom methods */
  460. NL_CMETHODS: string[];
  461. }
  462. /** Neutralino global object for custom methods **/
  463. const Neutralino: any;
  464. }
  465. declare namespace custom {
  466. export { getMethods };
  467. }
  468. declare namespace filesystem {
  469. export { appendBinaryFile, appendFile, copy, createDirectory, createWatcher, getAbsolutePath, getJoinedPath, getNormalizedPath, getOpenedFileInfo, getPathParts, getPermissions, getRelativePath, getStats, getUnnormalizedPath, getWatchers, move, openFile, readBinaryFile, readDirectory, readFile, remove, removeWatcher, setPermissions, updateOpenedFile, writeBinaryFile, writeFile };
  470. }
  471. declare namespace os {
  472. export { execCommand, getEnv, getEnvs, getPath, getSpawnedProcesses, open$1 as open, setTray, showFolderDialog, showMessageBox, showNotification, showOpenDialog, showSaveDialog, spawnProcess, updateSpawnedProcess };
  473. }
  474. declare namespace computer {
  475. export { getArch, getCPUInfo, getDisplays, getKernelInfo, getMemoryInfo, getMousePosition, getOSInfo };
  476. }
  477. declare namespace storage {
  478. export { clear, getData, getKeys, removeData, setData };
  479. }
  480. declare namespace debug {
  481. export { log };
  482. }
  483. declare namespace app {
  484. export { broadcast, exit, getConfig, killProcess, readProcessInput, restartProcess, writeProcessError, writeProcessOutput };
  485. }
  486. declare namespace window$1 {
  487. export { beginDrag, center, create, exitFullScreen, focus$1 as focus, getPosition, getSize, getTitle, hide, isFullScreen, isMaximized, isMinimized, isVisible, maximize, minimize, move$1 as move, print$1 as print, setAlwaysOnTop, setBorderless, setDraggableRegion, setFullScreen, setIcon, setMainMenu, setSize, setTitle, show, snapshot, unmaximize, unminimize, unsetDraggableRegion };
  488. }
  489. declare namespace events {
  490. export { broadcast$1 as broadcast, dispatch, off, on };
  491. }
  492. declare namespace extensions {
  493. export { broadcast$2 as broadcast, dispatch$1 as dispatch, getStats$1 as getStats };
  494. }
  495. declare namespace updater {
  496. export { checkForUpdates, install };
  497. }
  498. declare namespace clipboard {
  499. export { clear$1 as clear, getFormat, readHTML, readImage, readText, writeHTML, writeImage, writeText };
  500. }
  501. declare namespace resources {
  502. export { extractDirectory, extractFile, getFiles, getStats$2 as getStats, readBinaryFile$1 as readBinaryFile, readFile$1 as readFile };
  503. }
  504. declare namespace server {
  505. export { getMounts, mount, unmount };
  506. }
  507. export {
  508. Error$1 as Error,
  509. Permissions$1 as Permissions,
  510. Response$1 as Response,
  511. app,
  512. clipboard,
  513. computer,
  514. custom,
  515. debug,
  516. events,
  517. extensions,
  518. filesystem,
  519. os,
  520. resources,
  521. server,
  522. storage,
  523. updater,
  524. window$1 as window,
  525. };
  526. export as namespace Neutralino;
  527. export {};