steamworks.js-timmy 0.1.17 → 0.1.19

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.
@@ -0,0 +1,6 @@
1
+ export function init(appId?: number): Omit<Client, "init" | "runCallbacks">;
2
+ export function shutdown(): void;
3
+ export function restartAppIfNecessary(appId: number): boolean;
4
+ export function electronEnableSteamOverlay(disableEachFrameInvalidation?: boolean): void;
5
+ export type Client = typeof import("./client.d");
6
+ export const SteamCallback: typeof import("./client.d").callback.SteamCallback;
@@ -0,0 +1,89 @@
1
+ const { platform, arch } = process
2
+
3
+ /** @typedef {typeof import('./client.d')} Client */
4
+ /** @type {Client} */
5
+ let nativeBinding = undefined
6
+
7
+ if (platform === 'win32' && arch === 'x64') {
8
+ nativeBinding = require('./dist/win64/steamworksjs.win32-x64-msvc.node')
9
+ } else if (platform === 'linux' && arch === 'x64') {
10
+ nativeBinding = require('./dist/linux64/steamworksjs.linux-x64-gnu.node')
11
+ } else if (platform === 'darwin') {
12
+ if (arch === 'x64') {
13
+ nativeBinding = require('./dist/osx/steamworksjs.darwin-x64.node')
14
+ } else if (arch === 'arm64') {
15
+ nativeBinding = require('./dist/osx/steamworksjs.darwin-arm64.node')
16
+ }
17
+ } else {
18
+ throw new Error(`Unsupported OS: ${platform}, architecture: ${arch}`)
19
+ }
20
+
21
+ let runCallbacksInterval = undefined
22
+
23
+ /**
24
+ * Initialize the steam client or throw an error if it fails
25
+ * @param {number} [appId] - App ID of the game to load, if undefined, will search for a steam_appid.txt file
26
+ * @returns {Omit<Client, 'init' | 'runCallbacks'>}
27
+ */
28
+ module.exports.init = (appId) => {
29
+ const { init: internalInit, runCallbacks, restartAppIfNecessary, ...api } = nativeBinding
30
+
31
+ internalInit(appId)
32
+
33
+ clearInterval(runCallbacksInterval)
34
+ runCallbacksInterval = setInterval(() => {
35
+ // console.log("Running callbacks")
36
+ runCallbacks()
37
+ }, 1000 / 120)
38
+
39
+ return api
40
+ }
41
+
42
+ /**
43
+ * @description Shuts down the steam client
44
+ */
45
+ module.exports.shutdown = () => {
46
+ clearInterval(runCallbacksInterval)
47
+ nativeBinding.shutdownClient()
48
+ runCallbacksInterval = undefined
49
+ }
50
+
51
+ /**
52
+ * @param {number} appId - App ID of the game to load
53
+ * {@link https://partner.steamgames.com/doc/api/steam_api#SteamAPI_RestartAppIfNecessary}
54
+ * @returns {boolean}
55
+ */
56
+ module.exports.restartAppIfNecessary = (appId) => nativeBinding.restartAppIfNecessary(appId);
57
+
58
+ /**
59
+ * Enable the steam overlay on electron
60
+ * @param {boolean} [disableEachFrameInvalidation] - Should attach a single pixel to be rendered each frame
61
+ */
62
+ module.exports.electronEnableSteamOverlay = (disableEachFrameInvalidation) => {
63
+ const electron = require('electron')
64
+ if (!electron) {
65
+ throw new Error('Electron module not found')
66
+ }
67
+
68
+ electron.app.commandLine.appendSwitch('in-process-gpu')
69
+ electron.app.commandLine.appendSwitch('disable-direct-composition')
70
+
71
+ if (!disableEachFrameInvalidation) {
72
+ /** @param {electron.BrowserWindow} browserWindow */
73
+ const attachFrameInvalidator = (browserWindow) => {
74
+ browserWindow.steamworksRepaintInterval = setInterval(() => {
75
+ if (browserWindow.isDestroyed()) {
76
+ clearInterval(browserWindow.steamworksRepaintInterval)
77
+ } else if (!browserWindow.webContents.isPainting()) {
78
+ browserWindow.webContents.invalidate()
79
+ }
80
+ }, 1000 / 60)
81
+ }
82
+
83
+ electron.BrowserWindow.getAllWindows().forEach(attachFrameInvalidator)
84
+ electron.app.on('browser-window-created', (_, bw) => attachFrameInvalidator(bw))
85
+ }
86
+ }
87
+
88
+ const SteamCallback = nativeBinding.callback.SteamCallback
89
+ module.exports.SteamCallback = SteamCallback
Binary file
@@ -567,6 +567,16 @@ export declare namespace input {
567
567
  PS5Controller = 'PS5Controller',
568
568
  SteamDeckController = 'SteamDeckController'
569
569
  }
570
+ export const enum KeyboardInputKind {
571
+ /** The text input that will closes on Enter keypress */
572
+ SingleLine = 0,
573
+ /** Text input that will closes on user's demand. */
574
+ MultiLine = 1,
575
+ /** Text input that will make typing email address easier. */
576
+ Email = 2,
577
+ /** Text input that will make typing numeric input easier. */
578
+ Numeric = 3
579
+ }
570
580
  export interface MotionData {
571
581
  /** Absolute Rotation (drift) X axis */
572
582
  rotQuatX: number
@@ -592,6 +602,11 @@ export declare namespace input {
592
602
  export function runFrame(): void
593
603
  export function setInputActionManifestFilePath(path: string): boolean
594
604
  export function shutdown(): void
605
+ /**
606
+ * Opens a floating keyboard over the game content and sends OS keyboard keys directly to the game.
607
+ * The text field position is specified in pixels relative the origin of the game window and is used to position the floating keyboard in a way that doesn't cover the text field.
608
+ */
609
+ export function triggerOnScreenKeyboard(keyboardInputKind: KeyboardInputKind, xPosOfTextInput: number, yPosOfTextInput: number, widthOfTextInput: number, heightOfTextInput: number, dismissedCallback?: (arg?: unknown) => unknown | undefined | null): boolean
595
610
  export const enum VibrateSide {
596
611
  Left = 0,
597
612
  Right = 1
package/index.js CHANGED
@@ -1,89 +1,89 @@
1
- const { platform, arch } = process
2
-
3
- /** @typedef {typeof import('./client.d')} Client */
4
- /** @type {Client} */
5
- let nativeBinding = undefined
6
-
7
- if (platform === 'win32' && arch === 'x64') {
8
- nativeBinding = require('./dist/win64/steamworksjs.win32-x64-msvc.node')
9
- } else if (platform === 'linux' && arch === 'x64') {
10
- nativeBinding = require('./dist/linux64/steamworksjs.linux-x64-gnu.node')
11
- } else if (platform === 'darwin') {
12
- if (arch === 'x64') {
13
- nativeBinding = require('./dist/osx/steamworksjs.darwin-x64.node')
14
- } else if (arch === 'arm64') {
15
- nativeBinding = require('./dist/osx/steamworksjs.darwin-arm64.node')
16
- }
17
- } else {
18
- throw new Error(`Unsupported OS: ${platform}, architecture: ${arch}`)
19
- }
20
-
21
- let runCallbacksInterval = undefined
22
-
23
- /**
24
- * Initialize the steam client or throw an error if it fails
25
- * @param {number} [appId] - App ID of the game to load, if undefined, will search for a steam_appid.txt file
26
- * @returns {Omit<Client, 'init' | 'runCallbacks'>}
27
- */
28
- module.exports.init = (appId) => {
29
- const { init: internalInit, runCallbacks, restartAppIfNecessary, ...api } = nativeBinding
30
-
31
- internalInit(appId)
32
-
33
- clearInterval(runCallbacksInterval)
34
- runCallbacksInterval = setInterval(() => {
35
- // console.log("Running callbacks")
36
- runCallbacks()
37
- }, 1000 / 120)
38
-
39
- return api
40
- }
41
-
42
- /**
43
- * @description Shuts down the steam client
44
- */
45
- module.exports.shutdown = () => {
46
- clearInterval(runCallbacksInterval)
47
- nativeBinding.shutdownClient()
48
- runCallbacksInterval = undefined
49
- }
50
-
51
- /**
52
- * @param {number} appId - App ID of the game to load
53
- * {@link https://partner.steamgames.com/doc/api/steam_api#SteamAPI_RestartAppIfNecessary}
54
- * @returns {boolean}
55
- */
56
- module.exports.restartAppIfNecessary = (appId) => nativeBinding.restartAppIfNecessary(appId);
57
-
58
- /**
59
- * Enable the steam overlay on electron
60
- * @param {boolean} [disableEachFrameInvalidation] - Should attach a single pixel to be rendered each frame
61
- */
62
- module.exports.electronEnableSteamOverlay = (disableEachFrameInvalidation) => {
63
- const electron = require('electron')
64
- if (!electron) {
65
- throw new Error('Electron module not found')
66
- }
67
-
68
- electron.app.commandLine.appendSwitch('in-process-gpu')
69
- electron.app.commandLine.appendSwitch('disable-direct-composition')
70
-
71
- if (!disableEachFrameInvalidation) {
72
- /** @param {electron.BrowserWindow} browserWindow */
73
- const attachFrameInvalidator = (browserWindow) => {
74
- browserWindow.steamworksRepaintInterval = setInterval(() => {
75
- if (browserWindow.isDestroyed()) {
76
- clearInterval(browserWindow.steamworksRepaintInterval)
77
- } else if (!browserWindow.webContents.isPainting()) {
78
- browserWindow.webContents.invalidate()
79
- }
80
- }, 1000 / 60)
81
- }
82
-
83
- electron.BrowserWindow.getAllWindows().forEach(attachFrameInvalidator)
84
- electron.app.on('browser-window-created', (_, bw) => attachFrameInvalidator(bw))
85
- }
86
- }
87
-
88
- const SteamCallback = nativeBinding.callback.SteamCallback
1
+ const { platform, arch } = process
2
+
3
+ /** @typedef {typeof import('./client.d')} Client */
4
+ /** @type {Client} */
5
+ let nativeBinding = undefined
6
+
7
+ if (platform === 'win32' && arch === 'x64') {
8
+ nativeBinding = require('./dist/win64/steamworksjs.win32-x64-msvc.node')
9
+ } else if (platform === 'linux' && arch === 'x64') {
10
+ nativeBinding = require('./dist/linux64/steamworksjs.linux-x64-gnu.node')
11
+ } else if (platform === 'darwin') {
12
+ if (arch === 'x64') {
13
+ nativeBinding = require('./dist/osx/steamworksjs.darwin-x64.node')
14
+ } else if (arch === 'arm64') {
15
+ nativeBinding = require('./dist/osx/steamworksjs.darwin-arm64.node')
16
+ }
17
+ } else {
18
+ throw new Error(`Unsupported OS: ${platform}, architecture: ${arch}`)
19
+ }
20
+
21
+ let runCallbacksInterval = undefined
22
+
23
+ /**
24
+ * Initialize the steam client or throw an error if it fails
25
+ * @param {number} [appId] - App ID of the game to load, if undefined, will search for a steam_appid.txt file
26
+ * @returns {Omit<Client, 'init' | 'runCallbacks'>}
27
+ */
28
+ module.exports.init = (appId) => {
29
+ const { init: internalInit, runCallbacks, restartAppIfNecessary, ...api } = nativeBinding
30
+
31
+ internalInit(appId)
32
+
33
+ clearInterval(runCallbacksInterval)
34
+ runCallbacksInterval = setInterval(() => {
35
+ // console.log("Running callbacks")
36
+ runCallbacks()
37
+ }, 1000 / 120)
38
+
39
+ return api
40
+ }
41
+
42
+ /**
43
+ * @description Shuts down the steam client
44
+ */
45
+ module.exports.shutdown = () => {
46
+ clearInterval(runCallbacksInterval)
47
+ nativeBinding.shutdownClient()
48
+ runCallbacksInterval = undefined
49
+ }
50
+
51
+ /**
52
+ * @param {number} appId - App ID of the game to load
53
+ * {@link https://partner.steamgames.com/doc/api/steam_api#SteamAPI_RestartAppIfNecessary}
54
+ * @returns {boolean}
55
+ */
56
+ module.exports.restartAppIfNecessary = (appId) => nativeBinding.restartAppIfNecessary(appId);
57
+
58
+ /**
59
+ * Enable the steam overlay on electron
60
+ * @param {boolean} [disableEachFrameInvalidation] - Should attach a single pixel to be rendered each frame
61
+ */
62
+ module.exports.electronEnableSteamOverlay = (disableEachFrameInvalidation) => {
63
+ const electron = require('electron')
64
+ if (!electron) {
65
+ throw new Error('Electron module not found')
66
+ }
67
+
68
+ electron.app.commandLine.appendSwitch('in-process-gpu')
69
+ electron.app.commandLine.appendSwitch('disable-direct-composition')
70
+
71
+ if (!disableEachFrameInvalidation) {
72
+ /** @param {electron.BrowserWindow} browserWindow */
73
+ const attachFrameInvalidator = (browserWindow) => {
74
+ browserWindow.steamworksRepaintInterval = setInterval(() => {
75
+ if (browserWindow.isDestroyed()) {
76
+ clearInterval(browserWindow.steamworksRepaintInterval)
77
+ } else if (!browserWindow.webContents.isPainting()) {
78
+ browserWindow.webContents.invalidate()
79
+ }
80
+ }, 1000 / 60)
81
+ }
82
+
83
+ electron.BrowserWindow.getAllWindows().forEach(attachFrameInvalidator)
84
+ electron.app.on('browser-window-created', (_, bw) => attachFrameInvalidator(bw))
85
+ }
86
+ }
87
+
88
+ const SteamCallback = nativeBinding.callback.SteamCallback
89
89
  module.exports.SteamCallback = SteamCallback
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "steamworks.js-timmy",
3
- "version": "0.1.17",
3
+ "version": "0.1.19",
4
4
  "main": "index.js",
5
5
  "types": "index.d.ts",
6
6
  "napi": {
@@ -21,9 +21,11 @@
21
21
  "README.md"
22
22
  ],
23
23
  "license": "MIT",
24
+ "dependencies": {
25
+ "@types/node": "*"
26
+ },
24
27
  "devDependencies": {
25
28
  "@napi-rs/cli": "3.3.1",
26
- "@types/node": "*",
27
29
  "electron": "24.2.0",
28
30
  "rimraf": "6.0.1",
29
31
  "typescript": "5.5.3"