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
73 changes: 73 additions & 0 deletions ifc2.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
/// <reference types="typescript" />

import type { Socket } from 'net';

export type IFData = string | number | boolean;

export const name: 'IFC2';
export const LE: true;
export const enableLog: boolean;
export const logLevel: number;
export const keepAlive: boolean;
export const doReconnect: boolean;
export const timeout: number;
export const isConnected: boolean;
export const isWaiting: boolean;
export const isPollWaiting: boolean;
export const isCallback: boolean;

export const INFO = 3;
export const WARN = 2;
export const ERROR = 1;
export const MANDATORY = 0;

export function on(event: string, listener: (...args: unknown[]) => void): void;
export function getCommand(cmd: string): Uint8Array;
export function setCommand<T extends IFData>(cmd: string, value: T): Uint8Array;
export function get<T extends IFData>(
cmd: string,
callback?: (data: T) => void
): void;
export function set<T extends IFData>(cmd: string, value: T): void;
export function run(cmd: string): void;
export function manifestByName(): { [key: string]: ManifestNameItem };
export function manifestByCommand(): { [key: string]: ManifestCommandItem };
export function pollRegister<T extends IFData>(
cmd: string,
callback: (data: T) => void
): void;
export function pollDeregister(cmd: string): void;
export function init(successCallback?: () => void, params?: InitInfo): void;
export function close(callback: () => void): void;

export enum DataType {
BOOLEAN = 0,
INTEGER = 1,
FLOAT = 2,
DOUBLE = 3,
STRING = 4,
LONG = 5,
}

export interface ManifestCommandItem {
name: string;
type: DataType;
}

export interface ManifestNameItem {
command: number;
type: DataType;
}

export interface InitInfo {
enableLog?: boolean;
logLevel?: number;
keepAlive?: boolean;
doReconnect?: boolean;
timeout?: number;
callback?: boolean;
infoCallback?: (info: unknown) => void;
pollThrottle?: number;
host?: string;
port?: number;
}
39 changes: 37 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 7 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
{
"name": "ifc2",
"version": "1.0.22",
"version": "1.1.0",
"description": "A Javascript client for Infinite Flight simulator API version 2",
"main": "ifc2.js",
"types": "ifc2.d.ts",
"repository": {
"type": "git",
"url": "https://github.com/likeablegeek/ifc2"
Expand All @@ -25,5 +26,9 @@
"bugs": {
"url": "https://github.com/likeablegeek/ifc2/issues"
},
"homepage": "https://github.com/likeablegeek/ifc2"
"homepage": "https://github.com/likeablegeek/ifc2",
"devDependencies": {
"@types/node": "^18.7.21",
"typescript": "^4.8.3"
}
}