Skip to content

Commit

Permalink
improvements
Browse files Browse the repository at this point in the history
add recursive list file support
add gracefull error handling
handle missing common paths
reuse js vm
add overwrite copy prop
steam handle logged out state
update logo
disable minimize to tray
  • Loading branch information
Armaldio committed Jan 5, 2025
1 parent bbe7b17 commit 0b10304
Show file tree
Hide file tree
Showing 17 changed files with 354 additions and 214 deletions.
Binary file added assets/discord_white.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion assets/electron/template/app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"@electron-forge/plugin-auto-unpack-natives": "7.4.0",
"@electron-forge/plugin-fuses": "7.4.0",
"@electron/fuses": "1.8.0",
"@pipelab/core": "1.3.0",
"@pipelab/core": "1.3.2",
"electron": "32.1.2"
},
"keywords": [],
Expand Down
10 changes: 8 additions & 2 deletions assets/electron/template/app/src/handlers/fs/list.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// @ts-check

import { readdir } from 'node:fs/promises'
import { join } from 'node:path'

/**
* @param {import('@pipelab/core').MakeInputOutput<import('@pipelab/core').MessageListFiles, 'input'>} json
Expand All @@ -9,9 +10,12 @@ import { readdir } from 'node:fs/promises'
*/
export default async (json, ws, mainWindow) => {
const file = await readdir(json.body.path, {
withFileTypes: true
withFileTypes: true,
recursive: json.body.recursive
})

console.log('file', file)

/**
* @type {import('@pipelab/core').MakeInputOutput<import('@pipelab/core').MessageListFiles, 'output'>}
*/
Expand All @@ -22,7 +26,9 @@ export default async (json, ws, mainWindow) => {
success: true,
list: file.map((x) => ({
type: x.isDirectory() ? 'folder' : 'file',
name: x.name
name: x.name,
parent: x.parentPath,
path: join(x.parentPath, x.name)
}))
}
}
Expand Down
45 changes: 31 additions & 14 deletions assets/electron/template/app/src/handlers/fs/read.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,38 @@ import { readFile } from 'node:fs/promises'
* @param {import('electron').BrowserWindow} mainWindow
*/
export default async (json, ws, mainWindow) => {
const file = await readFile(json.body.path, {
encoding: json.body.encoding
})
try {
const file = await readFile(json.body.path, {
encoding: json.body.encoding
})

/**
* @type {import('@pipelab/core').MakeInputOutput<import('@pipelab/core').MessageReadFile, 'output'>}
*/
const readFileResult = {
correlationId: json.correlationId,
url: json.url,
body: {
success: true,
content: file,
/**
* @type {import('@pipelab/core').MakeInputOutput<import('@pipelab/core').MessageReadFile, 'output'>}
*/
const readFileResult = {
correlationId: json.correlationId,
url: json.url,
body: {
success: true,
content: file,
}
}
console.log('result', readFileResult)
ws.send(JSON.stringify(readFileResult))
} catch (e) {
console.error('e', e)
/**
* @type {import('@pipelab/core').MakeInputOutput<import('@pipelab/core').MessageReadFile, 'output'>}
*/
const readFileResult = {
correlationId: json.correlationId,
url: json.url,
body: {
success: false,
error: e.message,
}
}
console.log('result', readFileResult)
ws.send(JSON.stringify(readFileResult))
}
console.log('result', readFileResult)
ws.send(JSON.stringify(readFileResult))
}
50 changes: 38 additions & 12 deletions assets/electron/template/app/src/handlers/user/folder.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,43 @@ import { app } from 'electron'
* @param {import('electron').BrowserWindow} mainWindow
*/
export default (json, ws, mainWindow) => {
const userFolder = app.getPath(json.body.name);
/**
* @type {import('@pipelab/core').MakeInputOutput<import('@pipelab/core').MessagePaths, 'output'>}
*/
const userFolderResult = {
url: json.url,
correlationId: json.correlationId,
body: {
data: userFolder
try {
/** @type {Parameters<typeof app.getPath>[0] | 'app'} */
const name = json.body.name;

let folder;

if (name === 'app') {
folder = app.getAppPath();
} else {
folder = app.getPath(name);
}
};
console.log('result', userFolderResult)
ws.send(JSON.stringify(userFolderResult));

/**
* @type {import('@pipelab/core').MakeInputOutput<import('@pipelab/core').MessagePaths, 'output'>}
*/
const userFolderResult = {
url: json.url,
correlationId: json.correlationId,
body: {
data: folder
}
};
console.log('result', userFolderResult)
ws.send(JSON.stringify(userFolderResult));
} catch (e) {
console.error('e', e)
/**
* @type {import('@pipelab/core').MakeInputOutput<import('@pipelab/core').MessagePaths, 'output'>}
*/
const userFolderResult = {
url: json.url,
correlationId: json.correlationId,
body: {
error: e.message
}
};
console.log('result', userFolderResult)
ws.send(JSON.stringify(userFolderResult));
}
}
Loading

0 comments on commit 0b10304

Please sign in to comment.