Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/api/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ export function exit(code?: number): Promise<void> {
return sendMessage('app.exit', { code });
};

export function getProcessId(): Promise<number> {
return sendMessage('app.getProcessId');
};

export function killProcess(): Promise<void> {
return sendMessage('app.killProcess');
};
Expand Down
5 changes: 5 additions & 0 deletions src/api/os.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import type {
ExecCommandResult,
FolderDialogOptions,
KnownPath,
LocaleInfo,
OpenDialogOptions,
SaveDialogOptions,
SpawnedProcess,
Expand All @@ -29,6 +30,10 @@ export function getSpawnedProcesses(): Promise<SpawnedProcess[]> {
return sendMessage('os.getSpawnedProcesses');
};

export function getLocale(): Promise<LocaleInfo> {
return sendMessage('os.getLocale');
};

export function getEnv(key: string): Promise<string> {
return sendMessage('os.getEnv', { key });
};
Expand Down
6 changes: 4 additions & 2 deletions src/api/storage.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { sendMessage } from '../ws/websocket';

export function setData(key: string, data: string | null): Promise<void> {
return sendMessage('storage.setData', { key, data });
export function setData(key: string, data?: string | null): Promise<void> {
const payload: Record<string, unknown> = { key };
if (data != null) payload.data = data;
return sendMessage('storage.setData', payload);
};

export function getData(key: string): Promise<string> {
Expand Down
4 changes: 4 additions & 0 deletions src/api/window.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,10 @@ export function setIcon(icon: string): Promise<void> {
return sendMessage('window.setIcon', { icon });
}

export function setBadge(count: number): Promise<void> {
return sendMessage('window.setBadge', { count });
}

export function move(x: number, y: number): Promise<void> {
return sendMessage('window.move', { x, y });
}
Expand Down
12 changes: 12 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,18 @@ declare global {
NL_RESMODE: string;
/** Release commit of the client library */
NL_CCOMMIT: string;
/** Release commit of the Neutralinojs server */
NL_COMMIT: string;
/** Application config file path */
NL_CONFIGFILE: string;
/** Compilation data */
NL_COMPDATA: string;
/** System locale string */
NL_LOCALE: string;
/** Returns true if the client library is injected by the server */
NL_SINJECTED: boolean;
/** Returns true if the window saved state was loaded */
NL_WSAVSTLOADED: boolean;
/** An array of custom methods */
NL_CMETHODS: string[];
// --- globals ---
Expand Down
2 changes: 2 additions & 0 deletions src/types/api/clipboard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,7 @@ export interface ClipboardImage {
redShift: number;
greenShift: number;
blueShift: number;
alphaShift: number;
alphaMask: number;
data: ArrayBuffer;
}
4 changes: 2 additions & 2 deletions src/types/api/computer.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { NetworkFamily } from '../enums';
import type { NetworkFamily } from '../enums';

export interface MemoryInfo {
physical: {
Expand Down Expand Up @@ -58,5 +58,5 @@ export interface NetworkInterfaceAddress {
}

export interface NetworkInterfaceInfo {
[key: string]: NetworkInterfaceAddress;
[key: string]: NetworkInterfaceAddress[];
}
11 changes: 10 additions & 1 deletion src/types/api/os.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@ export interface ExecCommandOptions {
stdIn?: string;
background?: boolean;
cwd?: string;
envs?: Record<string, string>;
}

export interface LocaleInfo {
locale: string;
language: string;
region: string;
}

export interface ExecCommandResult {
Expand Down Expand Up @@ -70,4 +77,6 @@ export type KnownPath =
'downloads' |
'savedGames1' |
'savedGames2' |
'temp'
'temp' |
'desktop' |
'home'
69 changes: 60 additions & 9 deletions src/types/api/protocol.ts
Original file line number Diff line number Diff line change
@@ -1,27 +1,78 @@
export type ErrorCode =
// Filesystem
'NE_FS_ACSFAIL' |
'NE_FS_CHMDERR' |
'NE_FS_CHWNERR' |
'NE_FS_COPYERR' |
'NE_FS_COPYFER' |
'NE_FS_DIRCRER' |
'NE_FS_RMDIRER' |
'NE_FS_FILOPER' |
'NE_FS_FILRDER' |
'NE_FS_FILWRER' |
'NE_FS_FILRMER' |
'NE_FS_NOPATHE' |
'NE_FS_COPYFER' |
'NE_FS_FILWRER' |
'NE_FS_MOVEERR' |
'NE_FS_MOVEFER' |
'NE_OS_INVMSGA' |
'NE_FS_NOPATHE' |
'NE_FS_NOTADIR' |
'NE_FS_NOWATID' |
'NE_FS_REMVERR' |
'NE_FS_RMDIRER' |
'NE_FS_UNLCWAT' |
'NE_FS_UNLSTPR' |
'NE_FS_UNLTFOP' |
'NE_FS_UNLTOUP' |
// OS
'NE_OS_INVKNPT' |
'NE_OS_INVMSGA' |
'NE_OS_INVNOTA' |
'NE_OS_TRAYIER' |
'NE_OS_UNLTOUP' |
'NE_OS_UNLTRAS' |
// Storage
'NE_ST_INVSTKY' |
'NE_ST_NOSTDIR' |
'NE_ST_NOSTKEX' |
'NE_ST_STKEYRE' |
'NE_ST_STKEYWE' |
// Runtime
'NE_RT_APIPRME' |
'NE_RT_INVTOKN' |
'NE_RT_NATNTIM' |
'NE_RT_NATPRME' |
'NE_RT_APIPRME' |
'NE_RT_NATRTER' |
'NE_RT_NATNTIM' |
// Client
'NE_CL_NSEROFF' |
// Extensions
'NE_EX_EXTNOTC' |
'NE_UP_CUPDMER' |
// Updater
'NE_UP_CUPDERR' |
'NE_UP_CUPDMER' |
'NE_UP_UPDINER' |
'NE_UP_UPDNOUF' |
'NE_UP_UPDINER'
// Computer
'NE_CO_UNLTOMG' |
'NE_CO_UNLTONI' |
'NE_CO_UNLTOSC' |
'NE_CO_UNLTOSK' |
// Window
'NE_WI_UNBSWSR' |
// Resources
'NE_RS_DIREXTF' |
'NE_RS_FILEXTF' |
'NE_RS_NOPATHE' |
'NE_RS_TREEGER' |
'NE_RS_UNBLDRE' |
// Server
'NE_SR_MPINUSE' |
'NE_SR_NOMTPTH' |
'NE_SR_UNBPARS' |
'NE_SR_UNBSEND' |
// Config
'NE_CF_UNBLDCF' |
'NE_CF_UNBLWCF' |
'NE_CF_UNBPRCF' |
'NE_CF_UNSUPMD'


export interface Error {
code: ErrorCode;
Expand Down
3 changes: 2 additions & 1 deletion src/types/enums.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
export enum LoggerType {
WARNING = 'WARNING',
ERROR = 'ERROR',
INFO = 'INFO'
INFO = 'INFO',
DEBUG = 'DEBUG'
}

// os
Expand Down