Skip to content

Commit

Permalink
Fix TypeScript definition compilation issues
Browse files Browse the repository at this point in the history
  • Loading branch information
shalithasuranga committed Mar 18, 2024
1 parent 425c526 commit 56cc994
Show file tree
Hide file tree
Showing 26 changed files with 1,021 additions and 423 deletions.
6 changes: 3 additions & 3 deletions build.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -152,12 +152,12 @@ function resetCommitHash ()
patchInitFile (commitHash, '<git_commit_hash_latest>')
}

// Function to fetch all .d.ts files from the typings directory
// Function to fetch all .ts files from the typings directory
const getTypeDefinitionFiles = () => {
const typingsDir = './types'; // Path to your typings directory
const typingsDir = './src/types'; // Path to your typings directory
try {
const files = readdirSync(typingsDir);
return files.filter(file => file.endsWith('.d.ts'));
return files.filter(file => file.endsWith('.ts'));
} catch (error) {
console.error('Error reading typings directory:', error);
return [];
Expand Down
1,362 changes: 962 additions & 400 deletions package-lock.json

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@
"rollup": "^2.57.0",
"rollup-plugin-cleanup": "^3.2.1",
"rollup-plugin-terser": "^7.0.2",
"rollup-plugin-ts": "^1.4.7",
"rollup-plugin-ts": "^3.4.5",
"tslib": "^2.3.1",
"typescript": "^4.3.5"
"typescript": "^5.4.2"
}
}
2 changes: 1 addition & 1 deletion src/api/app.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { sendMessage } from '../ws/websocket';
import * as os from './os';
import type { RestartOptions } from "../../types/api/app"
import type { RestartOptions } from "../types/api/app"

export function exit(code?: number): Promise<void> {
return sendMessage('app.exit', { code });
Expand Down
9 changes: 8 additions & 1 deletion src/api/computer.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
import { sendMessage } from '../ws/websocket';
import type { MemoryInfo, KernelInfo, OSInfo, CPUInfo, Display, MousePosition} from '../../types/api/computer';
import type {
MemoryInfo,
KernelInfo,
OSInfo,
CPUInfo,
Display,
MousePosition
} from '../types/api/computer';

export function getMemoryInfo(): Promise<MemoryInfo> {
return sendMessage('computer.getMemoryInfo');
Expand Down
2 changes: 1 addition & 1 deletion src/api/debug.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { sendMessage } from '../ws/websocket';
import type { LoggerType } from '../../types/enums';
import type { LoggerType } from '../types/enums';

export function log(message: string, type?: LoggerType): Promise<void> {
return sendMessage('debug.log', { message, type });
Expand Down
2 changes: 1 addition & 1 deletion src/api/extensions.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as websocket from '../ws/websocket';
import type { ExtensionStats } from '../../types/api/extensions';
import type { ExtensionStats } from '../types/api/extensions';

export function dispatch(extensionId: string, event: string, data?: any): Promise<void> {
return new Promise(async (resolve: any, reject: any) => {
Expand Down
9 changes: 8 additions & 1 deletion src/api/filesystem.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
import { sendMessage } from '../ws/websocket';
import { base64ToBytesArray } from '../helpers';
import type {DirectoryEntry, DirectoryReaderOptions, FileReaderOptions, OpenedFile, Stats, Watcher } from '../../types/api/filesystem';
import type {
DirectoryEntry,
DirectoryReaderOptions,
FileReaderOptions,
OpenedFile,
Stats,
Watcher
} from '../types/api/filesystem';

export function createDirectory(path: string): Promise<void> {
return sendMessage('filesystem.createDirectory', { path });
Expand Down
4 changes: 2 additions & 2 deletions src/api/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { version } from '../../package.json';
import * as websocket from '../ws/websocket';
import * as debug from './debug';
import * as events from './events';
import type { InitOptions } from '../../types/api/init';
import type { InitOptions } from '../types/api/init';

let initialized = false;

Expand Down Expand Up @@ -40,6 +40,6 @@ export function init(options: InitOptions = {}): void {
}

window.NL_CVERSION = version;
window.NL_CCOMMIT = '<git_commit_hash_latest>'; // only the build server will update this
window.NL_CCOMMIT = '425c526c318342e0e5d0f17caceef2a53049eda4'; // only the build server will update this
initialized = true;
}
14 changes: 12 additions & 2 deletions src/api/os.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
import { sendMessage } from '../ws/websocket';
import type { MessageBoxChoice, Icon } from '../../types/enums';
import type { Envs, ExecCommandOptions, ExecCommandResult, FolderDialogOptions, KnownPath, OpenDialogOptions, SaveDialogOptions, SpawnedProcess, TrayOptions } from '../../types/api/os';
import type { MessageBoxChoice, Icon } from '../types/enums';
import type {
Envs,
ExecCommandOptions,
ExecCommandResult,
FolderDialogOptions,
KnownPath,
OpenDialogOptions,
SaveDialogOptions,
SpawnedProcess,
TrayOptions
} from '../types/api/os';

export function execCommand(command: string, options?: ExecCommandOptions): Promise<ExecCommandResult> {
return sendMessage('os.execCommand', { command, ...options });
Expand Down
4 changes: 2 additions & 2 deletions src/api/updater.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as filesystem from './filesystem';
import { Error } from '../../types/api/protocol';
import { Manifest } from '../../types/api/updater';
import { Error } from '../types/api/protocol';
import { Manifest } from '../types/api/updater';

let manifest: Manifest = null;

Expand Down
6 changes: 5 additions & 1 deletion src/api/window.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import { sendMessage } from '../ws/websocket';
import * as os from './os';
import { WindowOptions, WindowPosOptions, WindowSizeOptions } from '../../types/api/window';
import {
WindowOptions,
WindowPosOptions,
WindowSizeOptions
} from '../types/api/window';

const draggableRegions: WeakMap<HTMLElement, any> = new WeakMap();

Expand Down
2 changes: 1 addition & 1 deletion src/browser/events.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { Response } from '../../types/events';
import type { Response } from '../types/events';

export function on(event: string, handler: (ev: CustomEvent) => void): Promise<Response> {
window.addEventListener(event, handler);
Expand Down
15 changes: 13 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Architecture, Mode, OperatingSystem } from '../types/enums';
import type { Architecture, Mode, OperatingSystem } from './types/enums';

declare global {
interface Window {
Expand Down Expand Up @@ -57,4 +57,15 @@ export * as clipboard from './api/clipboard';
export * as custom from './api/custom';

export { init } from './api/init';
export { Error, ErrorCode } from '../types/api/protocol';

export type * from './types/api/protocol';
export type * from './types/api/app';
export type * from './types/api/computer';
export type * from './types/api/extensions';
export type * from './types/api/filesystem';
export type * from './types/api/init';
export type * from './types/api/os';
export type * from './types/api/updater';
export type * from './types/api/window';
export type * from './types/enums';
export type * from './types/events';
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
3 changes: 0 additions & 3 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
{
"include": [
"src/**/*.ts" // otherwise, the neutralino.d.ts file is included by webpack.
],
"compilerOptions": {
"outDir": "./dist/",
"noImplicitAny": false,
Expand Down

0 comments on commit 56cc994

Please sign in to comment.