@pipelab/asset-electron 1.0.0-beta.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.
Files changed (64) hide show
  1. package/LICENSE +110 -0
  2. package/package.json +18 -0
  3. package/template/config.cjs +45 -0
  4. package/template/forge.config.cjs +70 -0
  5. package/template/package.json +62 -0
  6. package/template/pipelab-plugin.cjs +160 -0
  7. package/template/src/custom-main.js +1 -0
  8. package/template/src/handlers/dialog/folder.js +25 -0
  9. package/template/src/handlers/dialog/open.js +25 -0
  10. package/template/src/handlers/dialog/save.js +24 -0
  11. package/template/src/handlers/discord/set-activity.js +68 -0
  12. package/template/src/handlers/fs/copy.js +29 -0
  13. package/template/src/handlers/fs/delete.js +23 -0
  14. package/template/src/handlers/fs/exist.js +37 -0
  15. package/template/src/handlers/fs/file-size.js +24 -0
  16. package/template/src/handlers/fs/folder-create.js +25 -0
  17. package/template/src/handlers/fs/list.js +61 -0
  18. package/template/src/handlers/fs/move.js +30 -0
  19. package/template/src/handlers/fs/read-binary.js +24 -0
  20. package/template/src/handlers/fs/read.js +42 -0
  21. package/template/src/handlers/fs/write-base64.js +32 -0
  22. package/template/src/handlers/fs/write.js +30 -0
  23. package/template/src/handlers/general/engine.js +17 -0
  24. package/template/src/handlers/general/exit.js +20 -0
  25. package/template/src/handlers/general/infos.js +23 -0
  26. package/template/src/handlers/general/open-in-explorer.js +21 -0
  27. package/template/src/handlers/general/open.js +21 -0
  28. package/template/src/handlers/general/run.js +27 -0
  29. package/template/src/handlers/steam/deleteItem.js +26 -0
  30. package/template/src/handlers/steam/download.js +26 -0
  31. package/template/src/handlers/steam/downloadInfo.js +26 -0
  32. package/template/src/handlers/steam/downloadScore.js +28 -0
  33. package/template/src/handlers/steam/getItem.js +28 -0
  34. package/template/src/handlers/steam/getItems.js +28 -0
  35. package/template/src/handlers/steam/installInfo.js +26 -0
  36. package/template/src/handlers/steam/raw.js +42 -0
  37. package/template/src/handlers/steam/saveScreenshot.js +66 -0
  38. package/template/src/handlers/steam/state.js +26 -0
  39. package/template/src/handlers/steam/subscribe.js +26 -0
  40. package/template/src/handlers/steam/unsubscribe.js +26 -0
  41. package/template/src/handlers/steam/updateItem.js +26 -0
  42. package/template/src/handlers/steam/uploadScore.js +27 -0
  43. package/template/src/handlers/steam/utils.js +78 -0
  44. package/template/src/handlers/user/folder.js +71 -0
  45. package/template/src/handlers/window/maximize.js +20 -0
  46. package/template/src/handlers/window/minimize.js +20 -0
  47. package/template/src/handlers/window/request-attention.js +20 -0
  48. package/template/src/handlers/window/restore.js +20 -0
  49. package/template/src/handlers/window/set-always-on-top.js +20 -0
  50. package/template/src/handlers/window/set-fullscreen.js +26 -0
  51. package/template/src/handlers/window/set-height.js +21 -0
  52. package/template/src/handlers/window/set-ignore-mouse-events.js +36 -0
  53. package/template/src/handlers/window/set-maximum-size.js +20 -0
  54. package/template/src/handlers/window/set-minimum-size.js +20 -0
  55. package/template/src/handlers/window/set-resizable.js +20 -0
  56. package/template/src/handlers/window/set-title.js +20 -0
  57. package/template/src/handlers/window/set-width.js +21 -0
  58. package/template/src/handlers/window/set-x.js +21 -0
  59. package/template/src/handlers/window/set-y.js +21 -0
  60. package/template/src/handlers/window/show-dev-tools.js +24 -0
  61. package/template/src/handlers/window/unmaximize.js +20 -0
  62. package/template/src/index.js +958 -0
  63. package/template/src/preload.js +27 -0
  64. package/template/src/utils.js +18 -0
@@ -0,0 +1,37 @@
1
+ // @ts-check
2
+
3
+ import { access } from "node:fs/promises";
4
+
5
+ /**
6
+ * @param {import('@pipelab/core').MakeInputOutput<import('@pipelab/core').MessageExistFile, 'input'>} json
7
+ * @param {import('ws').WebSocket} ws
8
+ */
9
+ export default async (json, ws) => {
10
+ try {
11
+ await access(json.body.path);
12
+
13
+ /**
14
+ * @type {import('@pipelab/core').MakeInputOutput<import('@pipelab/core').MessageExistFile, 'output'>}
15
+ */
16
+ const existResult = {
17
+ correlationId: json.correlationId,
18
+ url: json.url,
19
+ body: {
20
+ success: true,
21
+ },
22
+ };
23
+ ws.send(JSON.stringify(existResult));
24
+ } catch (e) {
25
+ /**
26
+ * @type {import('@pipelab/core').MakeInputOutput<import('@pipelab/core').MessageExistFile, 'output'>}
27
+ */
28
+ const existResult = {
29
+ correlationId: json.correlationId,
30
+ url: json.url,
31
+ body: {
32
+ success: false,
33
+ },
34
+ };
35
+ ws.send(JSON.stringify(existResult));
36
+ }
37
+ };
@@ -0,0 +1,24 @@
1
+ // @ts-check
2
+
3
+ import { stat } from "node:fs/promises";
4
+
5
+ /**
6
+ * @param {import('@pipelab/core').MakeInputOutput<import('@pipelab/core').MessageFileSize, 'input'>} json
7
+ * @param {import('ws').WebSocket} ws
8
+ */
9
+ export default async (json, ws) => {
10
+ const stats = await stat(json.body.path);
11
+
12
+ /**
13
+ * @type {import('@pipelab/core').MakeInputOutput<import('@pipelab/core').MessageFileSize, 'output'>}
14
+ */
15
+ const readFileResult = {
16
+ correlationId: json.correlationId,
17
+ url: json.url,
18
+ body: {
19
+ success: true,
20
+ size: stats.size,
21
+ },
22
+ };
23
+ ws.send(JSON.stringify(readFileResult));
24
+ };
@@ -0,0 +1,25 @@
1
+ // @ts-check
2
+
3
+ import { mkdir } from "node:fs/promises";
4
+
5
+ /**
6
+ * @param {import('@pipelab/core').MakeInputOutput<import('@pipelab/core').MessageCreateFolder, 'input'>} json
7
+ * @param {import('ws').WebSocket} ws
8
+ */
9
+ export default async (json, ws) => {
10
+ await mkdir(json.body.path, {
11
+ recursive: json.body.recursive,
12
+ });
13
+
14
+ /**
15
+ * @type {import('@pipelab/core').MakeInputOutput<import('@pipelab/core').MessageCreateFolder, 'output'>}
16
+ */
17
+ const folderCreateResult = {
18
+ correlationId: json.correlationId,
19
+ url: json.url,
20
+ body: {
21
+ success: true,
22
+ },
23
+ };
24
+ ws.send(JSON.stringify(folderCreateResult));
25
+ };
@@ -0,0 +1,61 @@
1
+ // @ts-check
2
+
3
+ import { readdir } from "node:fs/promises";
4
+ import { join, dirname, relative } from "node:path";
5
+ import slash from "slash";
6
+
7
+ /**
8
+ * @param {import('@pipelab/core').MakeInputOutput<import('@pipelab/core').MessageListFiles, 'input'>} json
9
+ * @param {import('ws').WebSocket} ws
10
+ */
11
+ export default async (json, ws) => {
12
+ // Custom recursive directory listing for Node 18 compatibility
13
+ async function listDirRecursive(dir, parentPath) {
14
+ let results = [];
15
+ const entries = await readdir(dir, { withFileTypes: true });
16
+ for (const entry of entries) {
17
+ const fullpath = join(dir, entry.name);
18
+ const type = entry.isDirectory() ? "directory" : "file";
19
+ const relPath = slash(fullpath);
20
+ results.push({
21
+ type,
22
+ name: entry.name,
23
+ parent: slash(parentPath),
24
+ path: relPath,
25
+ });
26
+ if (entry.isDirectory()) {
27
+ const subResults = await listDirRecursive(fullpath, fullpath);
28
+ results = results.concat(subResults);
29
+ }
30
+ }
31
+ return results;
32
+ }
33
+
34
+ let fileList = [];
35
+ try {
36
+ fileList = await listDirRecursive(json.body.path, dirname(json.body.path));
37
+ } catch (err) {
38
+ console.error("Error listing files:", err);
39
+ ws.send(
40
+ JSON.stringify({
41
+ correlationId: json.correlationId,
42
+ url: json.url,
43
+ body: { success: false, error: err.message },
44
+ }),
45
+ );
46
+ return;
47
+ }
48
+
49
+ /**
50
+ * @type {import('@pipelab/core').MakeInputOutput<import('@pipelab/core').MessageListFiles, 'output'>}
51
+ */
52
+ const readFileResult = {
53
+ correlationId: json.correlationId,
54
+ url: json.url,
55
+ body: {
56
+ success: true,
57
+ list: fileList,
58
+ },
59
+ };
60
+ ws.send(JSON.stringify(readFileResult));
61
+ };
@@ -0,0 +1,30 @@
1
+ // @ts-check
2
+
3
+ import { moveFile } from "move-file";
4
+ import { mkdir } from "node:fs/promises";
5
+ import { dirname } from "node:path";
6
+
7
+ /**
8
+ * @param {import('@pipelab/core').MakeInputOutput<import('@pipelab/core').MessageMove, 'input'>} json
9
+ * @param {import('ws').WebSocket} ws
10
+ */
11
+ export default async (json, ws) => {
12
+ const destDirName = dirname(json.body.destination);
13
+ await mkdir(destDirName, { recursive: true });
14
+
15
+ await moveFile(json.body.source, json.body.destination, {
16
+ overwrite: json.body.overwrite,
17
+ });
18
+
19
+ /**
20
+ * @type {import('@pipelab/core').MakeInputOutput<import('@pipelab/core').MessageMove, 'output'>}
21
+ */
22
+ const readFileResult = {
23
+ correlationId: json.correlationId,
24
+ url: json.url,
25
+ body: {
26
+ success: true,
27
+ },
28
+ };
29
+ ws.send(JSON.stringify(readFileResult));
30
+ };
@@ -0,0 +1,24 @@
1
+ // @ts-check
2
+
3
+ import { readFile } from "node:fs/promises";
4
+
5
+ /**
6
+ * @param {import('@pipelab/core').MakeInputOutput<import('@pipelab/core').MessageReadFileBinary, 'input'>} json
7
+ * @param {import('ws').WebSocket} ws
8
+ */
9
+ export default async (json, ws) => {
10
+ const file = await readFile(json.body.path);
11
+
12
+ /**
13
+ * @type {import('@pipelab/core').MakeInputOutput<import('@pipelab/core').MessageReadFileBinary, 'output'>}
14
+ */
15
+ const readFileResult = {
16
+ correlationId: json.correlationId,
17
+ url: json.url,
18
+ body: {
19
+ success: true,
20
+ content: [...file],
21
+ },
22
+ };
23
+ ws.send(JSON.stringify(readFileResult));
24
+ };
@@ -0,0 +1,42 @@
1
+ // @ts-check
2
+
3
+ import { readFile } from "node:fs/promises";
4
+
5
+ /**
6
+ * @param {import('@pipelab/core').MakeInputOutput<import('@pipelab/core').MessageReadFile, 'input'>} json
7
+ * @param {import('ws').WebSocket} ws
8
+ */
9
+ export default async (json, ws) => {
10
+ try {
11
+ const file = await readFile(json.body.path, {
12
+ encoding: json.body.encoding,
13
+ });
14
+
15
+ /**
16
+ * @type {import('@pipelab/core').MakeInputOutput<import('@pipelab/core').MessageReadFile, 'output'>}
17
+ */
18
+ const readFileResult = {
19
+ correlationId: json.correlationId,
20
+ url: json.url,
21
+ body: {
22
+ success: true,
23
+ content: file,
24
+ },
25
+ };
26
+ ws.send(JSON.stringify(readFileResult));
27
+ } catch (e) {
28
+ console.error("e", e);
29
+ /**
30
+ * @type {import('@pipelab/core').MakeInputOutput<import('@pipelab/core').MessageReadFile, 'output'>}
31
+ */
32
+ const readFileResult = {
33
+ correlationId: json.correlationId,
34
+ url: json.url,
35
+ body: {
36
+ success: false,
37
+ error: e.message,
38
+ },
39
+ };
40
+ ws.send(JSON.stringify(readFileResult));
41
+ }
42
+ };
@@ -0,0 +1,32 @@
1
+ // @ts-check
2
+
3
+ import { mkdir, writeFile } from "node:fs/promises";
4
+ import { dirname } from "node:path";
5
+
6
+ /**
7
+ * @param {{url: string, correlationId?: string, body: {path: string, base64Data: string, flag?: string}}} json
8
+ * @param {import('ws').WebSocket} ws
9
+ */
10
+ export default async (json, ws) => {
11
+ const destDirName = dirname(json.body.path);
12
+ await mkdir(destDirName, { recursive: true });
13
+
14
+ // Decode base64 string to buffer
15
+ const buffer = Buffer.from(json.body.base64Data, "base64");
16
+
17
+ await writeFile(json.body.path, buffer, {
18
+ flag: json.body.flag,
19
+ });
20
+
21
+ /**
22
+ * @type {{url: string, correlationId?: string, body: {success: boolean}}}
23
+ */
24
+ const writeFileResult = {
25
+ correlationId: json.correlationId,
26
+ url: json.url,
27
+ body: {
28
+ success: true,
29
+ },
30
+ };
31
+ ws.send(JSON.stringify(writeFileResult));
32
+ };
@@ -0,0 +1,30 @@
1
+ // @ts-check
2
+
3
+ import { mkdir, writeFile } from "node:fs/promises";
4
+ import { dirname } from "node:path";
5
+
6
+ /**
7
+ * @param {import('@pipelab/core').MakeInputOutput<import('@pipelab/core').MessageWriteFile, 'input'>} json
8
+ * @param {import('ws').WebSocket} ws
9
+ */
10
+ export default async (json, ws) => {
11
+ const destDirName = dirname(json.body.path);
12
+ await mkdir(destDirName, { recursive: true });
13
+
14
+ await writeFile(json.body.path, json.body.contents, {
15
+ encoding: json.body.encoding,
16
+ flag: json.body.flag,
17
+ });
18
+
19
+ /**
20
+ * @type {import('@pipelab/core').MakeInputOutput<import('@pipelab/core').MessageWriteFile, 'output'>}
21
+ */
22
+ const writeFileResult = {
23
+ correlationId: json.correlationId,
24
+ url: json.url,
25
+ body: {
26
+ success: true,
27
+ },
28
+ };
29
+ ws.send(JSON.stringify(writeFileResult));
30
+ };
@@ -0,0 +1,17 @@
1
+ /**
2
+ * @param {import('@pipelab/core').MakeInputOutput<import('@pipelab/core').MessageEngine, 'input'>} json
3
+ * @param {import('ws').WebSocket} ws
4
+ */
5
+ export default async (json, ws) => {
6
+ /**
7
+ * @type {import('@pipelab/core').MakeInputOutput<import('@pipelab/core').MessageEngine, 'output'>}
8
+ */
9
+ const engineResult = {
10
+ correlationId: json.correlationId,
11
+ url: json.url,
12
+ body: {
13
+ engine: "electron",
14
+ },
15
+ };
16
+ ws.send(JSON.stringify(engineResult));
17
+ };
@@ -0,0 +1,20 @@
1
+ import { app } from "electron";
2
+ /**
3
+ * @param {import('@pipelab/core').MakeInputOutput<import('@pipelab/core').MessageExit, 'input'>} json
4
+ * @param {import('ws').WebSocket} ws
5
+ */
6
+ export default async (json, ws) => {
7
+ /**
8
+ * @type {import('@pipelab/core').MakeInputOutput<import('@pipelab/core').MessageExit, 'output'>}
9
+ */
10
+ const engineResult = {
11
+ correlationId: json.correlationId,
12
+ url: json.url,
13
+ body: {
14
+ success: true,
15
+ },
16
+ };
17
+ ws.send(JSON.stringify(engineResult));
18
+
19
+ app.exit(json.body.code);
20
+ };
@@ -0,0 +1,23 @@
1
+ import { arch, platform } from "os";
2
+ /**
3
+ * @param {import('@pipelab/core').MakeInputOutput<import('@pipelab/core').MessageInfos, 'input'>} json
4
+ * @param {import('ws').WebSocket} ws
5
+ */
6
+ export default async (json, ws) => {
7
+ const myArch = arch();
8
+ const myPlatform = platform();
9
+
10
+ /**
11
+ * @type {import('@pipelab/core').MakeInputOutput<import('@pipelab/core').MessageInfos, 'output'>}
12
+ */
13
+ const engineResult = {
14
+ correlationId: json.correlationId,
15
+ url: json.url,
16
+ body: {
17
+ arch: myArch,
18
+ platform: myPlatform,
19
+ version: "0.0.0",
20
+ },
21
+ };
22
+ ws.send(JSON.stringify(engineResult));
23
+ };
@@ -0,0 +1,21 @@
1
+ import { shell } from "electron";
2
+
3
+ /**
4
+ * @param {import('@pipelab/core').MakeInputOutput<import('@pipelab/core').MessageExplorerOpen, 'input'>} json
5
+ * @param {import('ws').WebSocket} ws
6
+ */
7
+ export default async (json, ws) => {
8
+ await shell.showItemInFolder(json.body.path);
9
+
10
+ /**
11
+ * @type {import('@pipelab/core').MakeInputOutput<import('@pipelab/core').MessageExplorerOpen, 'output'>}
12
+ */
13
+ const runResult = {
14
+ correlationId: json.correlationId,
15
+ url: json.url,
16
+ body: {
17
+ success: true,
18
+ },
19
+ };
20
+ ws.send(JSON.stringify(runResult));
21
+ };
@@ -0,0 +1,21 @@
1
+ import { shell } from "electron";
2
+
3
+ /**
4
+ * @param {import('@pipelab/core').MakeInputOutput<import('@pipelab/core').MessageOpen, 'input'>} json
5
+ * @param {import('ws').WebSocket} ws
6
+ */
7
+ export default async (json, ws) => {
8
+ await shell.openPath(json.body.path);
9
+
10
+ /**
11
+ * @type {import('@pipelab/core').MakeInputOutput<import('@pipelab/core').MessageOpen, 'output'>}
12
+ */
13
+ const runResult = {
14
+ correlationId: json.correlationId,
15
+ url: json.url,
16
+ body: {
17
+ success: true,
18
+ },
19
+ };
20
+ ws.send(JSON.stringify(runResult));
21
+ };
@@ -0,0 +1,27 @@
1
+ import { execa } from "execa";
2
+
3
+ /**
4
+ * @param {import('@pipelab/core').MakeInputOutput<import('@pipelab/core').MessageRun, 'input'>} json
5
+ * @param {import('ws').WebSocket} ws
6
+ */
7
+ export default async (json, ws) => {
8
+ const exec = execa({
9
+ cwd: json.body.cwd,
10
+ env: json.body.env,
11
+ });
12
+ const { stderr, stdout } = await exec(json.body.command, json.body.args);
13
+
14
+ /**
15
+ * @type {import('@pipelab/core').MakeInputOutput<import('@pipelab/core').MessageRun, 'output'>}
16
+ */
17
+ const execResult = {
18
+ correlationId: json.correlationId,
19
+ url: json.url,
20
+ body: {
21
+ success: true,
22
+ stdout,
23
+ stderr,
24
+ },
25
+ };
26
+ ws.send(JSON.stringify(execResult));
27
+ };
@@ -0,0 +1,26 @@
1
+ import { handleSteamRequest } from "./utils.js";
2
+
3
+ /**
4
+ * Core Steam workshop delete item logic
5
+ * @param {Omit<import('@pipelab/steamworks.js').Client, "init" | "runCallbacks">} client
6
+ * @param {import('@pipelab/core').MakeInputOutput<import('@pipelab/core').SteamRaw, 'input'>} json
7
+ * @returns {Promise<any>} The delete result
8
+ */
9
+ const deleteItemHandler = async (client, json) => {
10
+ const { itemId } = json.body;
11
+
12
+ const itemIdBigInt = BigInt(itemId);
13
+
14
+ const result = await client.workshop.deleteItem(itemIdBigInt);
15
+
16
+ return result;
17
+ };
18
+
19
+ /**
20
+ * @param {import('@pipelab/core').MakeInputOutput<import('@pipelab/core').SteamRaw, 'input'>} json
21
+ * @param {import('ws').WebSocket} ws
22
+ * @param {Omit<import('@pipelab/steamworks.js').Client, "init" | "runCallbacks">} client
23
+ */
24
+ export default async (json, ws, client) => {
25
+ await handleSteamRequest(client, json, ws, deleteItemHandler);
26
+ };
@@ -0,0 +1,26 @@
1
+ import { handleSteamRequest } from "./utils.js";
2
+
3
+ /**
4
+ * Core Steam workshop download logic
5
+ * @param {Omit<import('@pipelab/steamworks.js').Client, "init" | "runCallbacks">} client
6
+ * @param {import('@pipelab/core').MakeInputOutput<import('@pipelab/core').SteamRaw, 'input'>} json
7
+ * @returns {Promise<any>} The download result
8
+ */
9
+ const downloadHandler = async (client, json) => {
10
+ const { itemId, highPriority } = json.body;
11
+
12
+ const itemIdBigInt = BigInt(itemId);
13
+
14
+ const result = client.workshop.download(itemIdBigInt, highPriority);
15
+
16
+ return result;
17
+ };
18
+
19
+ /**
20
+ * @param {import('@pipelab/core').MakeInputOutput<import('@pipelab/core').SteamRaw, 'input'>} json
21
+ * @param {import('ws').WebSocket} ws
22
+ * @param {Omit<import('@pipelab/steamworks.js').Client, "init" | "runCallbacks">} client
23
+ */
24
+ export default async (json, ws, client) => {
25
+ await handleSteamRequest(client, json, ws, downloadHandler);
26
+ };
@@ -0,0 +1,26 @@
1
+ import { handleSteamRequest } from "./utils.js";
2
+
3
+ /**
4
+ * Core Steam workshop download info logic
5
+ * @param {Omit<import('@pipelab/steamworks.js').Client, "init" | "runCallbacks">} client
6
+ * @param {import('@pipelab/core').MakeInputOutput<import('@pipelab/core').SteamRaw, 'input'>} json
7
+ * @returns {Promise<any>} The download info result
8
+ */
9
+ const downloadInfoHandler = async (client, json) => {
10
+ const { itemId } = json.body;
11
+
12
+ const itemIdBigInt = BigInt(itemId);
13
+
14
+ const result = client.workshop.downloadInfo(itemIdBigInt);
15
+
16
+ return result;
17
+ };
18
+
19
+ /**
20
+ * @param {import('@pipelab/core').MakeInputOutput<import('@pipelab/core').SteamRaw, 'input'>} json
21
+ * @param {import('ws').WebSocket} ws
22
+ * @param {Omit<import('@pipelab/steamworks.js').Client, "init" | "runCallbacks">} client
23
+ */
24
+ export default async (json, ws, client) => {
25
+ await handleSteamRequest(client, json, ws, downloadInfoHandler);
26
+ };
@@ -0,0 +1,28 @@
1
+ import { handleSteamRequest } from "./utils.js";
2
+
3
+ // * @param {Omit<import('@pipelab/steamworks.js').Client, "init" | "runCallbacks">} client
4
+ /**
5
+ * @param {import('@pipelab/core').MakeInputOutput<import('@pipelab/core').SteamRaw, 'input'>} json
6
+ * @param {import('ws').WebSocket} ws
7
+ * @param {import('@pipelab/steamworks.js').Client} client
8
+ */
9
+ export default async (json, ws, client) => {
10
+ await handleSteamRequest(client, json, ws, async (client, json) => {
11
+ const { body } = json;
12
+ const { name, type, start, end } = body;
13
+
14
+ const leaderboard = await client.leaderboards.findLeaderboard(name);
15
+ /** @type {Awaited<ReturnType<leaderboards['downloadScores']>>} */
16
+ const result = await client.leaderboards.downloadScores(leaderboard, type, start, end);
17
+
18
+ // Enhance each result with the Steam friend name
19
+ const enhancedResult = await Promise.all(
20
+ result.map(async (entry) => ({
21
+ ...entry,
22
+ name: await client.friends.getFriendName(entry.steamId),
23
+ })),
24
+ );
25
+
26
+ return enhancedResult;
27
+ });
28
+ };
@@ -0,0 +1,28 @@
1
+ import { handleSteamRequest } from "./utils.js";
2
+
3
+ /**
4
+ * Core Steam workshop get item logic
5
+ * @param {Omit<import('@pipelab/steamworks.js').Client, "init" | "runCallbacks">} client
6
+ * @param {import('@pipelab/core').MakeInputOutput<import('@pipelab/core').SteamRaw, 'input'>} json
7
+ * @returns {Promise<any>} The item result
8
+ */
9
+ const getItemHandler = async (client, json) => {
10
+ const { itemId } = json.body;
11
+
12
+ // Convert itemId from string to BigInt
13
+ const itemIdBigInt = BigInt(itemId);
14
+
15
+ // TODO: Handle queryConfig parameter when needed
16
+ const result = await client.workshop.getItem(itemIdBigInt);
17
+
18
+ return result;
19
+ };
20
+
21
+ /**
22
+ * @param {import('@pipelab/core').MakeInputOutput<import('@pipelab/core').SteamRaw, 'input'>} json
23
+ * @param {import('ws').WebSocket} ws
24
+ * @param {Omit<import('@pipelab/steamworks.js').Client, "init" | "runCallbacks">} client
25
+ */
26
+ export default async (json, ws, client) => {
27
+ await handleSteamRequest(client, json, ws, getItemHandler);
28
+ };
@@ -0,0 +1,28 @@
1
+ import { handleSteamRequest } from "./utils.js";
2
+
3
+ /**
4
+ * Core Steam workshop get items logic
5
+ * @param {Omit<import('@pipelab/steamworks.js').Client, "init" | "runCallbacks">} client
6
+ * @param {import('@pipelab/core').MakeInputOutput<import('@pipelab/core').SteamRaw, 'input'>} json
7
+ * @returns {Promise<any>} The items result
8
+ */
9
+ const getItemsHandler = async (client, json) => {
10
+ const { itemIds } = json.body;
11
+
12
+ // Convert array of string itemIds to array of BigInts
13
+ const itemIdsBigInt = itemIds.map((id) => BigInt(id));
14
+
15
+ // TODO: Handle queryConfig parameter when needed
16
+ const result = await client.workshop.getItems(itemIdsBigInt);
17
+
18
+ return result;
19
+ };
20
+
21
+ /**
22
+ * @param {import('@pipelab/core').MakeInputOutput<import('@pipelab/core').SteamRaw, 'input'>} json
23
+ * @param {import('ws').WebSocket} ws
24
+ * @param {Omit<import('@pipelab/steamworks.js').Client, "init" | "runCallbacks">} client
25
+ */
26
+ export default async (json, ws, client) => {
27
+ await handleSteamRequest(client, json, ws, getItemsHandler);
28
+ };
@@ -0,0 +1,26 @@
1
+ import { handleSteamRequest } from "./utils.js";
2
+
3
+ /**
4
+ * Core Steam workshop install info logic
5
+ * @param {Omit<import('@pipelab/steamworks.js').Client, "init" | "runCallbacks">} client
6
+ * @param {import('@pipelab/core').MakeInputOutput<import('@pipelab/core').SteamRaw, 'input'>} json
7
+ * @returns {Promise<any>} The install info result
8
+ */
9
+ const installInfoHandler = async (client, json) => {
10
+ const { itemId } = json.body;
11
+
12
+ const itemIdBigInt = BigInt(itemId);
13
+
14
+ const result = client.workshop.installInfo(itemIdBigInt);
15
+
16
+ return result;
17
+ };
18
+
19
+ /**
20
+ * @param {import('@pipelab/core').MakeInputOutput<import('@pipelab/core').SteamRaw, 'input'>} json
21
+ * @param {import('ws').WebSocket} ws
22
+ * @param {Omit<import('@pipelab/steamworks.js').Client, "init" | "runCallbacks">} client
23
+ */
24
+ export default async (json, ws, client) => {
25
+ await handleSteamRequest(client, json, ws, installInfoHandler);
26
+ };