steamworks.js-timmy 0.1.16 → 0.1.17

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.
@@ -1,6 +0,0 @@
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;
package/dist/osx/index.js DELETED
@@ -1,86 +0,0 @@
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(runCallbacks, 1000 / 30)
35
-
36
- return api
37
- }
38
-
39
- /**
40
- * @description Shuts down the steam client
41
- */
42
- module.exports.shutdown = () => {
43
- clearInterval(runCallbacksInterval)
44
- nativeBinding.shutdownClient()
45
- runCallbacksInterval = undefined
46
- }
47
-
48
- /**
49
- * @param {number} appId - App ID of the game to load
50
- * {@link https://partner.steamgames.com/doc/api/steam_api#SteamAPI_RestartAppIfNecessary}
51
- * @returns {boolean}
52
- */
53
- module.exports.restartAppIfNecessary = (appId) => nativeBinding.restartAppIfNecessary(appId);
54
-
55
- /**
56
- * Enable the steam overlay on electron
57
- * @param {boolean} [disableEachFrameInvalidation] - Should attach a single pixel to be rendered each frame
58
- */
59
- module.exports.electronEnableSteamOverlay = (disableEachFrameInvalidation) => {
60
- const electron = require('electron')
61
- if (!electron) {
62
- throw new Error('Electron module not found')
63
- }
64
-
65
- electron.app.commandLine.appendSwitch('in-process-gpu')
66
- electron.app.commandLine.appendSwitch('disable-direct-composition')
67
-
68
- if (!disableEachFrameInvalidation) {
69
- /** @param {electron.BrowserWindow} browserWindow */
70
- const attachFrameInvalidator = (browserWindow) => {
71
- browserWindow.steamworksRepaintInterval = setInterval(() => {
72
- if (browserWindow.isDestroyed()) {
73
- clearInterval(browserWindow.steamworksRepaintInterval)
74
- } else if (!browserWindow.webContents.isPainting()) {
75
- browserWindow.webContents.invalidate()
76
- }
77
- }, 1000 / 60)
78
- }
79
-
80
- electron.BrowserWindow.getAllWindows().forEach(attachFrameInvalidator)
81
- electron.app.on('browser-window-created', (_, bw) => attachFrameInvalidator(bw))
82
- }
83
- }
84
-
85
- const SteamCallback = nativeBinding.callback.SteamCallback
86
- module.exports.SteamCallback = SteamCallback
Binary file