@irsdk-node/native 4.1.1 → 5.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +21 -1
- package/dist/cjs/index.cjs +9454 -0
- package/dist/esm/index.js +9441 -0
- package/dist/types/INativeSDK.d.ts +24 -0
- package/dist/types/MockSdk.d.ts +31 -0
- package/dist/types/index.d.ts +4 -0
- package/lib/irsdk_client.cpp +94 -94
- package/lib/irsdk_client.h +23 -23
- package/lib/irsdk_defines.h +136 -82
- package/lib/irsdk_diskclient.cpp +997 -0
- package/lib/irsdk_diskclient.h +205 -0
- package/lib/irsdk_node.cc +336 -283
- package/lib/irsdk_utils.cpp +71 -71
- package/lib/yaml_parser.cpp +41 -41
- package/lib/yaml_parser.h +1 -1
- package/package.json +27 -29
- package/prebuilds/darwin-arm64/@irsdk-node+native.node +0 -0
- package/prebuilds/win32-x64/@irsdk-node+native.node +0 -0
- package/dist/INativeSDK.d.ts +0 -28
- package/dist/INativeSDK.js +0 -2
- package/dist/MockSdk.d.ts +0 -43
- package/dist/MockSdk.js +0 -70
- package/dist/mock-data/loader.js +0 -41
- package/dist/mock-data/session.json +0 -4305
- package/dist/mock-data/telemetry.json +0 -4986
- package/index.d.ts +0 -87
- package/index.js +0 -36
- package/scripts/generate-var-types.js +0 -71
- /package/dist/{mock-data → types/mock-data}/loader.d.ts +0 -0
package/index.d.ts
DELETED
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
BroadcastMessages,
|
|
3
|
-
CameraState,
|
|
4
|
-
ChatCommand,
|
|
5
|
-
FFBCommand,
|
|
6
|
-
PitCommand,
|
|
7
|
-
ReloadTexturesCommand,
|
|
8
|
-
ReplayPositionCommand,
|
|
9
|
-
ReplaySearchCommand,
|
|
10
|
-
ReplayStateCommand,
|
|
11
|
-
TelemetryCommand,
|
|
12
|
-
VideoCaptureCommand,
|
|
13
|
-
TelemetryVariable,
|
|
14
|
-
TelemetryVarList,
|
|
15
|
-
} from '@irsdk-node/types';
|
|
16
|
-
import { INativeSDK } from './dist/INativeSDK';
|
|
17
|
-
|
|
18
|
-
type TelemetryTypesDict = {
|
|
19
|
-
[variableName: string]: number;
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
export { INativeSDK } from './dist/INativeSDK';
|
|
23
|
-
|
|
24
|
-
export const mockedSdk: boolean;
|
|
25
|
-
|
|
26
|
-
export class NativeSDK implements INativeSDK {
|
|
27
|
-
public readonly currDataVersion: number;
|
|
28
|
-
|
|
29
|
-
public readonly isMocked: boolean;
|
|
30
|
-
|
|
31
|
-
public enableLogging: boolean;
|
|
32
|
-
|
|
33
|
-
constructor();
|
|
34
|
-
|
|
35
|
-
// Main API
|
|
36
|
-
// Control
|
|
37
|
-
public startSDK(): boolean;
|
|
38
|
-
|
|
39
|
-
public stopSDK(): void;
|
|
40
|
-
|
|
41
|
-
// State
|
|
42
|
-
public isRunning(): boolean;
|
|
43
|
-
|
|
44
|
-
public waitForData(timeout?: number): boolean;
|
|
45
|
-
|
|
46
|
-
public getSessionData(): string; // full yaml
|
|
47
|
-
|
|
48
|
-
public getTelemetryData(): TelemetryVarList;
|
|
49
|
-
|
|
50
|
-
public getTelemetryVariable<T extends number | boolean | string>(index: number): TelemetryVariable<T[]>;
|
|
51
|
-
|
|
52
|
-
public getTelemetryVariable<T extends number | boolean | string>(name: string): TelemetryVariable<T[]>;
|
|
53
|
-
|
|
54
|
-
// Private helpers
|
|
55
|
-
public __getTelemetryTypes(): TelemetryTypesDict;
|
|
56
|
-
|
|
57
|
-
// Broadcast command overloads
|
|
58
|
-
// This is handled in the cpp side so no need to mess with it in js
|
|
59
|
-
public broadcast(message: BroadcastMessages.CameraSwitchPos, pos: number, group: number, camera: number): void;
|
|
60
|
-
|
|
61
|
-
public broadcast(message: BroadcastMessages.CameraSwitchNum, driver: number, group: number, camera: number): void;
|
|
62
|
-
|
|
63
|
-
public broadcast(message: BroadcastMessages.CameraSetState, state: CameraState): void;
|
|
64
|
-
|
|
65
|
-
public broadcast(message: BroadcastMessages.ReplaySetPlaySpeed, speed: number, slowMotion: number): void;
|
|
66
|
-
|
|
67
|
-
public broadcast(message: BroadcastMessages.ReplaySetPlayPosition, pos: ReplayPositionCommand, frame: number): void;
|
|
68
|
-
|
|
69
|
-
public broadcast(message: BroadcastMessages.ReplaySearch, mode: ReplaySearchCommand): void;
|
|
70
|
-
|
|
71
|
-
public broadcast(message: BroadcastMessages.ReplaySetState, state: ReplayStateCommand): void;
|
|
72
|
-
|
|
73
|
-
public broadcast(message: BroadcastMessages.ReloadTextures, command: ReloadTexturesCommand, carIndex?: number): void;
|
|
74
|
-
|
|
75
|
-
public broadcast(message: BroadcastMessages.ChatCommand, command: ChatCommand, macro?: number): void;
|
|
76
|
-
|
|
77
|
-
public broadcast(message: BroadcastMessages.PitCommand, command: PitCommand, param?: number): void;
|
|
78
|
-
|
|
79
|
-
public broadcast(message: BroadcastMessages.TelemCommand, command: TelemetryCommand): void;
|
|
80
|
-
|
|
81
|
-
public broadcast(message: BroadcastMessages.FFBCommand, command: FFBCommand, value: number): void;
|
|
82
|
-
|
|
83
|
-
public broadcast(message: BroadcastMessages.ReplaySearchSessionTime, session: number, time: number): void;
|
|
84
|
-
|
|
85
|
-
public broadcast(message: BroadcastMessages.VideoCapture, command: VideoCaptureCommand): void;
|
|
86
|
-
}
|
|
87
|
-
|
package/index.js
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
/* eslint-disable import/no-extraneous-dependencies */
|
|
2
|
-
/* eslint-disable @typescript-eslint/no-var-requires */
|
|
3
|
-
/* eslint-disable global-require */
|
|
4
|
-
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
|
|
5
|
-
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
|
|
6
|
-
|
|
7
|
-
// Import from JS so that we can type the API in a nicer way (without aliases)
|
|
8
|
-
// The alternative would be to somehow get types generated, or use aliases to
|
|
9
|
-
// fake a module and then define that module... but those are gross, so no thanks
|
|
10
|
-
const nodePath = require('node:path');
|
|
11
|
-
const { warn } = require('node:console');
|
|
12
|
-
const MockSdk = require('./dist/MockSDK');
|
|
13
|
-
|
|
14
|
-
let sdkBinding;
|
|
15
|
-
let isMocked;
|
|
16
|
-
|
|
17
|
-
try {
|
|
18
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
|
|
19
|
-
const binding = require('node-gyp-build')(nodePath.join(__dirname, '.'));
|
|
20
|
-
isMocked = binding.mockedSdk;
|
|
21
|
-
|
|
22
|
-
if (isMocked) {
|
|
23
|
-
sdkBinding = MockSdk;
|
|
24
|
-
} else {
|
|
25
|
-
sdkBinding = binding.iRacingSdkNode;
|
|
26
|
-
}
|
|
27
|
-
} catch (err) {
|
|
28
|
-
warn('Failed to load native iRacing SDK module. Loading mock SDK instead.');
|
|
29
|
-
isMocked = true;
|
|
30
|
-
sdkBinding = MockSdk;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
module.exports = {
|
|
34
|
-
NativeSDK: sdkBinding,
|
|
35
|
-
mockedSdk: isMocked,
|
|
36
|
-
};
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
const NativeSDK = require("../build/Debug/irsdk_node.node").iRacingSdkNode;
|
|
2
|
-
const path = require("path");
|
|
3
|
-
const fs = require("fs");
|
|
4
|
-
|
|
5
|
-
const TARGET_FILE = "_GENERATED_telemetry.ts";
|
|
6
|
-
const OUT_PATH = path.resolve(process.cwd(), "../irsdk-node-types/src/", TARGET_FILE);
|
|
7
|
-
|
|
8
|
-
console.log("Generating iRacing telemetry variable types.");
|
|
9
|
-
console.log("Make sure the sim is running!");
|
|
10
|
-
|
|
11
|
-
const sdk = new NativeSDK();
|
|
12
|
-
sdk.startSDK();
|
|
13
|
-
|
|
14
|
-
// Telemetry command, Start Recording
|
|
15
|
-
sdk.broadcast(10, 1);
|
|
16
|
-
// Wait a max of 5s
|
|
17
|
-
if (!sdk.waitForData(5000)) {
|
|
18
|
-
process.stderr.write("No data. Make sure the sim is running and try again.");
|
|
19
|
-
process.exit(1);
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
const varTypes = [
|
|
23
|
-
"string",
|
|
24
|
-
"boolean",
|
|
25
|
-
"number",
|
|
26
|
-
"number",
|
|
27
|
-
"number",
|
|
28
|
-
"number",
|
|
29
|
-
];
|
|
30
|
-
|
|
31
|
-
// Get all the types
|
|
32
|
-
const types = sdk.__getTelemetryTypes();
|
|
33
|
-
const out = `
|
|
34
|
-
// ! THIS FILE IS AUTO-GENERATED, EDITS WILL BE OVERRIDDEN !
|
|
35
|
-
// ! Make changes to the generate-var-types in @irsk-node/native !
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* A variable included in the telemetry.
|
|
39
|
-
*/
|
|
40
|
-
export interface TelemetryVariable<VarType = number[]> {
|
|
41
|
-
/** The name of the variable. */
|
|
42
|
-
name: string;
|
|
43
|
-
/** The description. */
|
|
44
|
-
description: string;
|
|
45
|
-
/** The unit of the value (ex. "kg/m^2") */
|
|
46
|
-
unit: string;
|
|
47
|
-
/** Should it be treated as a time? */
|
|
48
|
-
countAsTime: boolean;
|
|
49
|
-
/** The number of values provided. */
|
|
50
|
-
length: number;
|
|
51
|
-
/** The native variable type */
|
|
52
|
-
varType: number;
|
|
53
|
-
/** The current value of this variable. */
|
|
54
|
-
value: VarType;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
export interface TelemetryVarList {
|
|
58
|
-
${Object.keys(types).map((varName) =>
|
|
59
|
-
` ${varName}: TelemetryVariable<${varTypes[types[varName]]}[]>`
|
|
60
|
-
).join(";\n")};
|
|
61
|
-
}
|
|
62
|
-
`;
|
|
63
|
-
|
|
64
|
-
fs.writeFile(OUT_PATH, out, "utf-8", (err) => {
|
|
65
|
-
if (err) {
|
|
66
|
-
console.error("There was an error creating the file:", err);
|
|
67
|
-
return;
|
|
68
|
-
}
|
|
69
|
-
console.log("Successfully generated types!");
|
|
70
|
-
process.exit(0);
|
|
71
|
-
});
|
|
File without changes
|