@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.
- package/LICENSE +110 -0
- package/package.json +18 -0
- package/template/config.cjs +45 -0
- package/template/forge.config.cjs +70 -0
- package/template/package.json +62 -0
- package/template/pipelab-plugin.cjs +160 -0
- package/template/src/custom-main.js +1 -0
- package/template/src/handlers/dialog/folder.js +25 -0
- package/template/src/handlers/dialog/open.js +25 -0
- package/template/src/handlers/dialog/save.js +24 -0
- package/template/src/handlers/discord/set-activity.js +68 -0
- package/template/src/handlers/fs/copy.js +29 -0
- package/template/src/handlers/fs/delete.js +23 -0
- package/template/src/handlers/fs/exist.js +37 -0
- package/template/src/handlers/fs/file-size.js +24 -0
- package/template/src/handlers/fs/folder-create.js +25 -0
- package/template/src/handlers/fs/list.js +61 -0
- package/template/src/handlers/fs/move.js +30 -0
- package/template/src/handlers/fs/read-binary.js +24 -0
- package/template/src/handlers/fs/read.js +42 -0
- package/template/src/handlers/fs/write-base64.js +32 -0
- package/template/src/handlers/fs/write.js +30 -0
- package/template/src/handlers/general/engine.js +17 -0
- package/template/src/handlers/general/exit.js +20 -0
- package/template/src/handlers/general/infos.js +23 -0
- package/template/src/handlers/general/open-in-explorer.js +21 -0
- package/template/src/handlers/general/open.js +21 -0
- package/template/src/handlers/general/run.js +27 -0
- package/template/src/handlers/steam/deleteItem.js +26 -0
- package/template/src/handlers/steam/download.js +26 -0
- package/template/src/handlers/steam/downloadInfo.js +26 -0
- package/template/src/handlers/steam/downloadScore.js +28 -0
- package/template/src/handlers/steam/getItem.js +28 -0
- package/template/src/handlers/steam/getItems.js +28 -0
- package/template/src/handlers/steam/installInfo.js +26 -0
- package/template/src/handlers/steam/raw.js +42 -0
- package/template/src/handlers/steam/saveScreenshot.js +66 -0
- package/template/src/handlers/steam/state.js +26 -0
- package/template/src/handlers/steam/subscribe.js +26 -0
- package/template/src/handlers/steam/unsubscribe.js +26 -0
- package/template/src/handlers/steam/updateItem.js +26 -0
- package/template/src/handlers/steam/uploadScore.js +27 -0
- package/template/src/handlers/steam/utils.js +78 -0
- package/template/src/handlers/user/folder.js +71 -0
- package/template/src/handlers/window/maximize.js +20 -0
- package/template/src/handlers/window/minimize.js +20 -0
- package/template/src/handlers/window/request-attention.js +20 -0
- package/template/src/handlers/window/restore.js +20 -0
- package/template/src/handlers/window/set-always-on-top.js +20 -0
- package/template/src/handlers/window/set-fullscreen.js +26 -0
- package/template/src/handlers/window/set-height.js +21 -0
- package/template/src/handlers/window/set-ignore-mouse-events.js +36 -0
- package/template/src/handlers/window/set-maximum-size.js +20 -0
- package/template/src/handlers/window/set-minimum-size.js +20 -0
- package/template/src/handlers/window/set-resizable.js +20 -0
- package/template/src/handlers/window/set-title.js +20 -0
- package/template/src/handlers/window/set-width.js +21 -0
- package/template/src/handlers/window/set-x.js +21 -0
- package/template/src/handlers/window/set-y.js +21 -0
- package/template/src/handlers/window/show-dev-tools.js +24 -0
- package/template/src/handlers/window/unmaximize.js +20 -0
- package/template/src/index.js +958 -0
- package/template/src/preload.js +27 -0
- package/template/src/utils.js +18 -0
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { handleSteamRequest } from "./utils.js";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @param {import('@pipelab/core').MakeInputOutput<import('@pipelab/core').SteamRaw, 'input'>} json
|
|
5
|
+
* @param {import('ws').WebSocket} ws
|
|
6
|
+
* @param {Omit<import('@pipelab/steamworks.js').Client, "init" | "runCallbacks">} client
|
|
7
|
+
*/
|
|
8
|
+
export default async (json, ws, client) => {
|
|
9
|
+
console.log("json", json);
|
|
10
|
+
|
|
11
|
+
await handleSteamRequest(
|
|
12
|
+
client,
|
|
13
|
+
json,
|
|
14
|
+
ws,
|
|
15
|
+
async (client, json) => {
|
|
16
|
+
const { body } = json;
|
|
17
|
+
const { args, method, namespace } = body;
|
|
18
|
+
|
|
19
|
+
const result = await client[namespace][method](...args);
|
|
20
|
+
|
|
21
|
+
// if (namespace === 'localplayer' && method === 'getSteamId') {
|
|
22
|
+
// console.log('result', result)
|
|
23
|
+
// // handle bigint to string
|
|
24
|
+
// /**
|
|
25
|
+
// * @type {{
|
|
26
|
+
// steamId64: bigint,
|
|
27
|
+
// steamId32: string,
|
|
28
|
+
// accountId: number
|
|
29
|
+
// }}
|
|
30
|
+
// */
|
|
31
|
+
// result = {
|
|
32
|
+
// steamId64: result.steamId64.toString(),
|
|
33
|
+
// steamId32: result.steamId32,
|
|
34
|
+
// accountId: result.accountId
|
|
35
|
+
// }
|
|
36
|
+
// }
|
|
37
|
+
|
|
38
|
+
return result;
|
|
39
|
+
},
|
|
40
|
+
true,
|
|
41
|
+
);
|
|
42
|
+
};
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { handleSteamRequest } from "./utils.js";
|
|
2
|
+
import { writeFileSync, unlinkSync, mkdirSync, rmdirSync } from "node:fs";
|
|
3
|
+
import { join } from "node:path";
|
|
4
|
+
import { tmpdir } from "node:os";
|
|
5
|
+
import { randomUUID } from "node:crypto";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Save screenshot from base64 data URL to Steam library
|
|
9
|
+
* @param {Omit<import('@pipelab/steamworks.js').Client, "init" | "runCallbacks">} client
|
|
10
|
+
* @param {Object} json
|
|
11
|
+
* @returns {Promise<number>} The screenshot handle
|
|
12
|
+
*/
|
|
13
|
+
const saveScreenshotHandler = async (client, json) => {
|
|
14
|
+
const { body } = json;
|
|
15
|
+
const { dataUrl, width, height } = body;
|
|
16
|
+
|
|
17
|
+
// Validate input
|
|
18
|
+
if (!dataUrl || typeof dataUrl !== "string") {
|
|
19
|
+
throw new Error("dataUrl is required and must be a string");
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
if (!dataUrl.startsWith("data:image/")) {
|
|
23
|
+
throw new Error("dataUrl must be a base64 data URL (data:image/...)");
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// Extract base64 data
|
|
27
|
+
const matches = dataUrl.match(/^data:image\/(\w+);base64,(.+)$/);
|
|
28
|
+
if (!matches) {
|
|
29
|
+
throw new Error("Invalid base64 data URL format");
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const [, format, base64Data] = matches;
|
|
33
|
+
const buffer = Buffer.from(base64Data, "base64");
|
|
34
|
+
|
|
35
|
+
// Create temp file
|
|
36
|
+
const tempDir = join(tmpdir(), "pipelab-screenshots");
|
|
37
|
+
mkdirSync(tempDir, { recursive: true });
|
|
38
|
+
const tempPath = join(tempDir, `screenshot-${randomUUID()}.${format}`);
|
|
39
|
+
|
|
40
|
+
// Write to temp file
|
|
41
|
+
writeFileSync(tempPath, buffer);
|
|
42
|
+
|
|
43
|
+
// Add to Steam library
|
|
44
|
+
const handle = client.screenshots.addScreenshotToLibrary(tempPath, null, width, height);
|
|
45
|
+
|
|
46
|
+
// Delete temp file after a delay to allow Steam to process it
|
|
47
|
+
setTimeout(() => {
|
|
48
|
+
try {
|
|
49
|
+
unlinkSync(tempPath);
|
|
50
|
+
rmdirSync(tempDir);
|
|
51
|
+
} catch {
|
|
52
|
+
// Ignore cleanup errors
|
|
53
|
+
}
|
|
54
|
+
}, 5000);
|
|
55
|
+
|
|
56
|
+
return handle;
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* @param {Object} json
|
|
61
|
+
* @param {import('ws').WebSocket} ws
|
|
62
|
+
* @param {Omit<import('@pipelab/steamworks.js').Client, "init" | "runCallbacks">} client
|
|
63
|
+
*/
|
|
64
|
+
export default async (json, ws, client) => {
|
|
65
|
+
await handleSteamRequest(client, json, ws, saveScreenshotHandler);
|
|
66
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { handleSteamRequest } from "./utils.js";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Core Steam workshop state 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 state result
|
|
8
|
+
*/
|
|
9
|
+
const stateHandler = async (client, json) => {
|
|
10
|
+
const { itemId } = json.body;
|
|
11
|
+
|
|
12
|
+
const itemIdBigInt = BigInt(itemId);
|
|
13
|
+
|
|
14
|
+
const result = client.workshop.state(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, stateHandler);
|
|
26
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { handleSteamRequest } from "./utils.js";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Core Steam workshop subscribe 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 subscribe result
|
|
8
|
+
*/
|
|
9
|
+
const subscribeHandler = async (client, json) => {
|
|
10
|
+
const { itemId } = json.body;
|
|
11
|
+
|
|
12
|
+
const itemIdBigInt = BigInt(itemId);
|
|
13
|
+
|
|
14
|
+
const result = await client.workshop.subscribe(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, subscribeHandler);
|
|
26
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { handleSteamRequest } from "./utils.js";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Core Steam workshop unsubscribe 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 unsubscribe result
|
|
8
|
+
*/
|
|
9
|
+
const unsubscribeHandler = async (client, json) => {
|
|
10
|
+
const { itemId } = json.body;
|
|
11
|
+
|
|
12
|
+
const itemIdBigInt = BigInt(itemId);
|
|
13
|
+
|
|
14
|
+
const result = await client.workshop.unsubscribe(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, unsubscribeHandler);
|
|
26
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { handleSteamRequest } from "./utils.js";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Core Steam workshop update 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 update result
|
|
8
|
+
*/
|
|
9
|
+
const updateItemHandler = async (client, json) => {
|
|
10
|
+
const { itemId, updateDetails, appID } = json.body;
|
|
11
|
+
|
|
12
|
+
const itemIdBigInt = BigInt(itemId);
|
|
13
|
+
|
|
14
|
+
const result = await client.workshop.updateItem(itemIdBigInt, updateDetails, appID);
|
|
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, updateItemHandler);
|
|
26
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { handleSteamRequest } from "./utils.js";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Core Steam leaderboard upload 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 upload result
|
|
8
|
+
*/
|
|
9
|
+
const uploadScoreHandler = async (client, json) => {
|
|
10
|
+
const { body } = json;
|
|
11
|
+
const { name, score, type, metadata } = body;
|
|
12
|
+
|
|
13
|
+
const leaderboard = await client.leaderboards.findLeaderboard(name);
|
|
14
|
+
|
|
15
|
+
const result = await client.leaderboards.uploadScore(leaderboard, score, type, metadata);
|
|
16
|
+
|
|
17
|
+
return result;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* @param {import('@pipelab/core').MakeInputOutput<import('@pipelab/core').SteamRaw, 'input'>} json
|
|
22
|
+
* @param {import('ws').WebSocket} ws
|
|
23
|
+
* @param {Omit<import('@pipelab/steamworks.js').Client, "init" | "runCallbacks">} client
|
|
24
|
+
*/
|
|
25
|
+
export default async (json, ws, client) => {
|
|
26
|
+
await handleSteamRequest(client, json, ws, uploadScoreHandler);
|
|
27
|
+
};
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Checks if the Steam client is available and properly initialized
|
|
3
|
+
* @param {Object} client - The Steam client instance to check
|
|
4
|
+
* @returns {Object|null} Returns an error object if client is not available, null if available
|
|
5
|
+
*/
|
|
6
|
+
function checkSteamClient(client) {
|
|
7
|
+
if (client === undefined || client === null) {
|
|
8
|
+
return {
|
|
9
|
+
success: false,
|
|
10
|
+
error: "Steam client is not initialized or available",
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
return null;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Enhanced Steam request handler that combines client validation with response formatting
|
|
19
|
+
* @param {import('@pipelab/steamworks.js').Client} client - The Steam client instance
|
|
20
|
+
* @param {Object} json - The JSON request object containing url, correlationId, and body
|
|
21
|
+
* @param {import('ws').WebSocket} ws - The WebSocket connection
|
|
22
|
+
* @param {Function} handlerFunction - The handler function to execute if client is valid
|
|
23
|
+
* @param {boolean} useRawErrorFormat - Whether to use raw error format (default: false)
|
|
24
|
+
* @returns {Promise<void>} A promise that resolves when the request is handled
|
|
25
|
+
*/
|
|
26
|
+
function handleSteamRequest(client, json, ws, handlerFunction, useRawErrorFormat = false) {
|
|
27
|
+
// Check if Steam client is initialized
|
|
28
|
+
const clientError = checkSteamClient(client);
|
|
29
|
+
if (clientError) {
|
|
30
|
+
const errorResult = {
|
|
31
|
+
url: json.url,
|
|
32
|
+
correlationId: json.correlationId,
|
|
33
|
+
body: useRawErrorFormat
|
|
34
|
+
? {
|
|
35
|
+
data: null,
|
|
36
|
+
success: false,
|
|
37
|
+
error: clientError.error,
|
|
38
|
+
}
|
|
39
|
+
: clientError,
|
|
40
|
+
};
|
|
41
|
+
ws.send(JSON.stringify(errorResult));
|
|
42
|
+
return Promise.resolve();
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// Execute the handler function and format the response
|
|
46
|
+
return Promise.resolve(handlerFunction(client, json))
|
|
47
|
+
.then((result) => {
|
|
48
|
+
const steamResult = {
|
|
49
|
+
url: json.url,
|
|
50
|
+
correlationId: json.correlationId,
|
|
51
|
+
body: {
|
|
52
|
+
data: result,
|
|
53
|
+
success: true,
|
|
54
|
+
},
|
|
55
|
+
};
|
|
56
|
+
ws.send(JSON.stringify(steamResult, (_, v) => (typeof v === "bigint" ? v.toString() : v)));
|
|
57
|
+
})
|
|
58
|
+
.catch((error) => {
|
|
59
|
+
console.error("Error in Steam handler:", error);
|
|
60
|
+
const errorResult = {
|
|
61
|
+
url: json.url,
|
|
62
|
+
correlationId: json.correlationId,
|
|
63
|
+
body: useRawErrorFormat
|
|
64
|
+
? {
|
|
65
|
+
data: null,
|
|
66
|
+
success: false,
|
|
67
|
+
error: error.message || "Unknown error occurred",
|
|
68
|
+
}
|
|
69
|
+
: {
|
|
70
|
+
success: false,
|
|
71
|
+
error: error.message || "Unknown error occurred",
|
|
72
|
+
},
|
|
73
|
+
};
|
|
74
|
+
ws.send(JSON.stringify(errorResult));
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export { checkSteamClient, handleSteamRequest };
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
|
|
3
|
+
import { app } from "electron";
|
|
4
|
+
import { join } from "path";
|
|
5
|
+
|
|
6
|
+
import slash from "slash";
|
|
7
|
+
import { getAppName } from "../../utils.js";
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* @param {import('@pipelab/core').MakeInputOutput<import('@pipelab/core').MessagePaths, 'input'>} json
|
|
11
|
+
* @param {import('ws').WebSocket} ws
|
|
12
|
+
* @param {ElectronAppConfig.Config} config
|
|
13
|
+
*/
|
|
14
|
+
export default (json, ws, config) => {
|
|
15
|
+
try {
|
|
16
|
+
const name = json.body.name;
|
|
17
|
+
|
|
18
|
+
let folder;
|
|
19
|
+
|
|
20
|
+
const { env } = process;
|
|
21
|
+
// windows linux
|
|
22
|
+
const { APPDATA, LOCALAPPDATA, XDG_DATA_HOME, XDG_CONFIG_HOME } = env;
|
|
23
|
+
const appDataBackup = app.getPath("appData");
|
|
24
|
+
const localAppData = LOCALAPPDATA ?? XDG_DATA_HOME ?? appDataBackup;
|
|
25
|
+
const appData = APPDATA ?? XDG_CONFIG_HOME ?? appDataBackup;
|
|
26
|
+
|
|
27
|
+
const appNameFolder = getAppName(config);
|
|
28
|
+
|
|
29
|
+
const localUserData = join(localAppData, appNameFolder);
|
|
30
|
+
const userData = join(appData, appNameFolder);
|
|
31
|
+
|
|
32
|
+
if (name === "app") {
|
|
33
|
+
folder = app.getAppPath();
|
|
34
|
+
} else if (name === "project") {
|
|
35
|
+
folder = join(app.getAppPath(), "src", "app"); // path to construct files
|
|
36
|
+
} else if (name === "localAppData") {
|
|
37
|
+
folder = localAppData;
|
|
38
|
+
} else if (name === "localUserData") {
|
|
39
|
+
folder = localUserData;
|
|
40
|
+
} else if (name === "userData") {
|
|
41
|
+
folder = userData;
|
|
42
|
+
} else {
|
|
43
|
+
folder = app.getPath(name);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* @type {import('@pipelab/core').MakeInputOutput<import('@pipelab/core').MessagePaths, 'output'>}
|
|
48
|
+
*/
|
|
49
|
+
const userFolderResult = {
|
|
50
|
+
url: json.url,
|
|
51
|
+
correlationId: json.correlationId,
|
|
52
|
+
body: {
|
|
53
|
+
data: slash(folder),
|
|
54
|
+
},
|
|
55
|
+
};
|
|
56
|
+
ws.send(JSON.stringify(userFolderResult));
|
|
57
|
+
} catch (e) {
|
|
58
|
+
console.error("e", e);
|
|
59
|
+
/**
|
|
60
|
+
* @type {import('@pipelab/core').MakeInputOutput<import('@pipelab/core').MessagePaths, 'output'>}
|
|
61
|
+
*/
|
|
62
|
+
const userFolderResult = {
|
|
63
|
+
url: json.url,
|
|
64
|
+
correlationId: json.correlationId,
|
|
65
|
+
body: {
|
|
66
|
+
error: e.message,
|
|
67
|
+
},
|
|
68
|
+
};
|
|
69
|
+
ws.send(JSON.stringify(userFolderResult));
|
|
70
|
+
}
|
|
71
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @param {import('@pipelab/core').MakeInputOutput<import('@pipelab/core').MessageWindowMaximize, 'input'>} json
|
|
3
|
+
* @param {import('ws').WebSocket} ws
|
|
4
|
+
* @param {import('electron').BrowserWindow} mainWindow
|
|
5
|
+
*/
|
|
6
|
+
export default async (json, ws, mainWindow) => {
|
|
7
|
+
mainWindow.maximize();
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* @type {import('@pipelab/core').MakeInputOutput<import('@pipelab/core').MessageWindowMaximize, 'output'>}
|
|
11
|
+
*/
|
|
12
|
+
const maximizeResult = {
|
|
13
|
+
correlationId: json.correlationId,
|
|
14
|
+
url: json.url,
|
|
15
|
+
body: {
|
|
16
|
+
success: true,
|
|
17
|
+
},
|
|
18
|
+
};
|
|
19
|
+
ws.send(JSON.stringify(maximizeResult));
|
|
20
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @param {import('@pipelab/core').MakeInputOutput<import('@pipelab/core').MessageWindowMinimize, 'input'>} json
|
|
3
|
+
* @param {import('ws').WebSocket} ws
|
|
4
|
+
* @param {import('electron').BrowserWindow} mainWindow
|
|
5
|
+
*/
|
|
6
|
+
export default async (json, ws, mainWindow) => {
|
|
7
|
+
mainWindow.minimize();
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* @type {import('@pipelab/core').MakeInputOutput<import('@pipelab/core').MessageWindowMinimize, 'output'>}
|
|
11
|
+
*/
|
|
12
|
+
const minimizeResult = {
|
|
13
|
+
correlationId: json.correlationId,
|
|
14
|
+
url: json.url,
|
|
15
|
+
body: {
|
|
16
|
+
success: true,
|
|
17
|
+
},
|
|
18
|
+
};
|
|
19
|
+
ws.send(JSON.stringify(minimizeResult));
|
|
20
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @param {import('@pipelab/core').MakeInputOutput<import('@pipelab/core').MessageRequestAttention, 'input'>} json
|
|
3
|
+
* @param {import('ws').WebSocket} ws
|
|
4
|
+
* @param {import('electron').BrowserWindow} mainWindow
|
|
5
|
+
*/
|
|
6
|
+
export default async (json, ws, mainWindow) => {
|
|
7
|
+
mainWindow.flashFrame(true);
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* @type {import('@pipelab/core').MakeInputOutput<import('@pipelab/core').MessageRequestAttention, 'output'>}
|
|
11
|
+
*/
|
|
12
|
+
const requestAttentionResult = {
|
|
13
|
+
correlationId: json.correlationId,
|
|
14
|
+
url: json.url,
|
|
15
|
+
body: {
|
|
16
|
+
success: true,
|
|
17
|
+
},
|
|
18
|
+
};
|
|
19
|
+
ws.send(JSON.stringify(requestAttentionResult));
|
|
20
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @param {import('@pipelab/core').MakeInputOutput<import('@pipelab/core').MessageWindowRestore, 'input'>} json
|
|
3
|
+
* @param {import('ws').WebSocket} ws
|
|
4
|
+
* @param {import('electron').BrowserWindow} mainWindow
|
|
5
|
+
*/
|
|
6
|
+
export default async (json, ws, mainWindow) => {
|
|
7
|
+
mainWindow.restore();
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* @type {import('@pipelab/core').MakeInputOutput<import('@pipelab/core').MessageWindowRestore, 'output'>}
|
|
11
|
+
*/
|
|
12
|
+
const restoreResult = {
|
|
13
|
+
correlationId: json.correlationId,
|
|
14
|
+
url: json.url,
|
|
15
|
+
body: {
|
|
16
|
+
success: true,
|
|
17
|
+
},
|
|
18
|
+
};
|
|
19
|
+
ws.send(JSON.stringify(restoreResult));
|
|
20
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @param {import('@pipelab/core').MakeInputOutput<import('@pipelab/core').MessageSetAlwaysOnTop, 'input'>} json
|
|
3
|
+
* @param {import('ws').WebSocket} ws
|
|
4
|
+
* @param {import('electron').BrowserWindow} mainWindow
|
|
5
|
+
*/
|
|
6
|
+
export default async (json, ws, mainWindow) => {
|
|
7
|
+
mainWindow.setAlwaysOnTop(true);
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* @type {import('@pipelab/core').MakeInputOutput<import('@pipelab/core').MessageSetAlwaysOnTop, 'output'>}
|
|
11
|
+
*/
|
|
12
|
+
const setAlwaysOnTopResult = {
|
|
13
|
+
correlationId: json.correlationId,
|
|
14
|
+
url: json.url,
|
|
15
|
+
body: {
|
|
16
|
+
success: true,
|
|
17
|
+
},
|
|
18
|
+
};
|
|
19
|
+
ws.send(JSON.stringify(setAlwaysOnTopResult));
|
|
20
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @param {import('@pipelab/core').MakeInputOutput<import('@pipelab/core').MessageSetFullscreen, 'input'>} json
|
|
3
|
+
* @param {import('ws').WebSocket} ws
|
|
4
|
+
* @param {import('electron').BrowserWindow} mainWindow
|
|
5
|
+
*/
|
|
6
|
+
export default async (json, ws, mainWindow) => {
|
|
7
|
+
if (json.body.value === "fullscreen") {
|
|
8
|
+
mainWindow.setFullScreen(true);
|
|
9
|
+
} else if (json.body.value === "normal") {
|
|
10
|
+
mainWindow.setFullScreen(false);
|
|
11
|
+
} else {
|
|
12
|
+
throw new Error("Unsupported value ");
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* @type {import('@pipelab/core').MakeInputOutput<import('@pipelab/core').MessageSetFullscreen, 'output'>}
|
|
17
|
+
*/
|
|
18
|
+
const showsetFullscreenResult = {
|
|
19
|
+
correlationId: json.correlationId,
|
|
20
|
+
url: json.url,
|
|
21
|
+
body: {
|
|
22
|
+
success: true,
|
|
23
|
+
},
|
|
24
|
+
};
|
|
25
|
+
ws.send(JSON.stringify(showsetFullscreenResult));
|
|
26
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @param {import('@pipelab/core').MakeInputOutput<import('@pipelab/core').MessageSetHeight, 'input'>} json
|
|
3
|
+
* @param {import('ws').WebSocket} ws
|
|
4
|
+
* @param {import('electron').BrowserWindow} mainWindow
|
|
5
|
+
*/
|
|
6
|
+
export default async (json, ws, mainWindow) => {
|
|
7
|
+
const [width] = mainWindow.getSize();
|
|
8
|
+
mainWindow.setSize(width, json.body.value);
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* @type {import('@pipelab/core').MakeInputOutput<import('@pipelab/core').MessageSetHeight, 'output'>}
|
|
12
|
+
*/
|
|
13
|
+
const setHeightResult = {
|
|
14
|
+
correlationId: json.correlationId,
|
|
15
|
+
url: json.url,
|
|
16
|
+
body: {
|
|
17
|
+
success: true,
|
|
18
|
+
},
|
|
19
|
+
};
|
|
20
|
+
ws.send(JSON.stringify(setHeightResult));
|
|
21
|
+
};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @param {Object} json
|
|
3
|
+
* @param {string} json.correlationId
|
|
4
|
+
* @param {string} json.url
|
|
5
|
+
* @param {{ ignore: boolean, forward?: boolean }} json.body
|
|
6
|
+
* @param {import('ws').WebSocket} ws
|
|
7
|
+
* @param {import('electron').BrowserWindow} mainWindow
|
|
8
|
+
*/
|
|
9
|
+
export default async (json, ws, mainWindow) => {
|
|
10
|
+
<<<<<<< HEAD:assets/electron/template/app/src/handlers/window/set-ignore-mouse-events.js
|
|
11
|
+
const { ignore, forward } = json.body
|
|
12
|
+
|
|
13
|
+
mainWindow.setIgnoreMouseEvents(ignore, { forward })
|
|
14
|
+
=======
|
|
15
|
+
const { ignore, forward } = json.body;
|
|
16
|
+
|
|
17
|
+
mainWindow.setIgnoreMouseEvents(ignore, { forward });
|
|
18
|
+
>>>>>>> origin/feature/monorepo:assets/asset-electron/template/src/handlers/window/set-ignore-mouse-events.js
|
|
19
|
+
|
|
20
|
+
const result = {
|
|
21
|
+
correlationId: json.correlationId,
|
|
22
|
+
url: json.url,
|
|
23
|
+
body: {
|
|
24
|
+
<<<<<<< HEAD:assets/electron/template/app/src/handlers/window/set-ignore-mouse-events.js
|
|
25
|
+
success: true
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
ws.send(JSON.stringify(result))
|
|
29
|
+
}
|
|
30
|
+
=======
|
|
31
|
+
success: true,
|
|
32
|
+
},
|
|
33
|
+
};
|
|
34
|
+
ws.send(JSON.stringify(result));
|
|
35
|
+
};
|
|
36
|
+
>>>>>>> origin/feature/monorepo:assets/asset-electron/template/src/handlers/window/set-ignore-mouse-events.js
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @param {import('@pipelab/core').MakeInputOutput<import('@pipelab/core').MessageSetMaximumSize, 'input'>} json
|
|
3
|
+
* @param {import('ws').WebSocket} ws
|
|
4
|
+
* @param {import('electron').BrowserWindow} mainWindow
|
|
5
|
+
*/
|
|
6
|
+
export default async (json, ws, mainWindow) => {
|
|
7
|
+
mainWindow.setMaximumSize(json.body.width, json.body.height);
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* @type {import('@pipelab/core').MakeInputOutput<import('@pipelab/core').MessageSetMaximumSize, 'output'>}
|
|
11
|
+
*/
|
|
12
|
+
const setMaximumSizeResult = {
|
|
13
|
+
correlationId: json.correlationId,
|
|
14
|
+
url: json.url,
|
|
15
|
+
body: {
|
|
16
|
+
success: true,
|
|
17
|
+
},
|
|
18
|
+
};
|
|
19
|
+
ws.send(JSON.stringify(setMaximumSizeResult));
|
|
20
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @param {import('@pipelab/core').MakeInputOutput<import('@pipelab/core').MessageSetMinimumSize, 'input'>} json
|
|
3
|
+
* @param {import('ws').WebSocket} ws
|
|
4
|
+
* @param {import('electron').BrowserWindow} mainWindow
|
|
5
|
+
*/
|
|
6
|
+
export default async (json, ws, mainWindow) => {
|
|
7
|
+
mainWindow.setMinimumSize(json.body.width, json.body.height);
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* @type {import('@pipelab/core').MakeInputOutput<import('@pipelab/core').MessageSetMinimumSize, 'output'>}
|
|
11
|
+
*/
|
|
12
|
+
const setMinimumSizeResult = {
|
|
13
|
+
correlationId: json.correlationId,
|
|
14
|
+
url: json.url,
|
|
15
|
+
body: {
|
|
16
|
+
success: true,
|
|
17
|
+
},
|
|
18
|
+
};
|
|
19
|
+
ws.send(JSON.stringify(setMinimumSizeResult));
|
|
20
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @param {import('@pipelab/core').MakeInputOutput<import('@pipelab/core').MessageSetResizable, 'input'>} json
|
|
3
|
+
* @param {import('ws').WebSocket} ws
|
|
4
|
+
* @param {import('electron').BrowserWindow} mainWindow
|
|
5
|
+
*/
|
|
6
|
+
export default async (json, ws, mainWindow) => {
|
|
7
|
+
mainWindow.setResizable(true);
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* @type {import('@pipelab/core').MakeInputOutput<import('@pipelab/core').MessageSetResizable, 'output'>}
|
|
11
|
+
*/
|
|
12
|
+
const setResizableResult = {
|
|
13
|
+
correlationId: json.correlationId,
|
|
14
|
+
url: json.url,
|
|
15
|
+
body: {
|
|
16
|
+
success: true,
|
|
17
|
+
},
|
|
18
|
+
};
|
|
19
|
+
ws.send(JSON.stringify(setResizableResult));
|
|
20
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @param {import('@pipelab/core').MakeInputOutput<import('@pipelab/core').MessageSetTitle, 'input'>} json
|
|
3
|
+
* @param {import('ws').WebSocket} ws
|
|
4
|
+
* @param {import('electron').BrowserWindow} mainWindow
|
|
5
|
+
*/
|
|
6
|
+
export default async (json, ws, mainWindow) => {
|
|
7
|
+
mainWindow.setTitle(json.body.value);
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* @type {import('@pipelab/core').MakeInputOutput<import('@pipelab/core').MessageSetTitle, 'output'>}
|
|
11
|
+
*/
|
|
12
|
+
const setTitleResult = {
|
|
13
|
+
correlationId: json.correlationId,
|
|
14
|
+
url: json.url,
|
|
15
|
+
body: {
|
|
16
|
+
success: true,
|
|
17
|
+
},
|
|
18
|
+
};
|
|
19
|
+
ws.send(JSON.stringify(setTitleResult));
|
|
20
|
+
};
|