ajout depot downloader, preparation des channels ipc

This commit is contained in:
MathieuG-P
2022-05-12 23:30:39 +02:00
parent f246d65576
commit cf7863b1f0
16 changed files with 219 additions and 12 deletions
@@ -0,0 +1,121 @@
{
"runtimeTarget": {
"name": ".NETCoreApp,Version=v6.0",
"signature": ""
},
"compilationOptions": {},
"targets": {
".NETCoreApp,Version=v6.0": {
"DepotDownloader/2.4.6": {
"dependencies": {
"SteamKit2": "2.4.1",
"protobuf-net": "3.0.101"
},
"runtime": {
"DepotDownloader.dll": {}
}
},
"Microsoft.NETCore.Platforms/5.0.0": {},
"Microsoft.Win32.Registry/5.0.0": {
"dependencies": {
"System.Security.AccessControl": "5.0.0",
"System.Security.Principal.Windows": "5.0.0"
}
},
"protobuf-net/3.0.101": {
"dependencies": {
"protobuf-net.Core": "3.0.101"
},
"runtime": {
"lib/net5.0/protobuf-net.dll": {
"assemblyVersion": "3.0.0.0",
"fileVersion": "3.0.101.59408"
}
}
},
"protobuf-net.Core/3.0.101": {
"runtime": {
"lib/net5.0/protobuf-net.Core.dll": {
"assemblyVersion": "3.0.0.0",
"fileVersion": "3.0.101.59408"
}
}
},
"SteamKit2/2.4.1": {
"dependencies": {
"Microsoft.Win32.Registry": "5.0.0",
"protobuf-net": "3.0.101"
},
"runtime": {
"lib/net6.0/SteamKit2.dll": {
"assemblyVersion": "2.4.1.0",
"fileVersion": "2.4.1.10"
}
}
},
"System.Security.AccessControl/5.0.0": {
"dependencies": {
"Microsoft.NETCore.Platforms": "5.0.0",
"System.Security.Principal.Windows": "5.0.0"
}
},
"System.Security.Principal.Windows/5.0.0": {}
}
},
"libraries": {
"DepotDownloader/2.4.6": {
"type": "project",
"serviceable": false,
"sha512": ""
},
"Microsoft.NETCore.Platforms/5.0.0": {
"type": "package",
"serviceable": true,
"sha512": "sha512-VyPlqzH2wavqquTcYpkIIAQ6WdenuKoFN0BdYBbCWsclXacSOHNQn66Gt4z5NBqEYW0FAPm5rlvki9ZiCij5xQ==",
"path": "microsoft.netcore.platforms/5.0.0",
"hashPath": "microsoft.netcore.platforms.5.0.0.nupkg.sha512"
},
"Microsoft.Win32.Registry/5.0.0": {
"type": "package",
"serviceable": true,
"sha512": "sha512-dDoKi0PnDz31yAyETfRntsLArTlVAVzUzCIvvEDsDsucrl33Dl8pIJG06ePTJTI3tGpeyHS9Cq7Foc/s4EeKcg==",
"path": "microsoft.win32.registry/5.0.0",
"hashPath": "microsoft.win32.registry.5.0.0.nupkg.sha512"
},
"protobuf-net/3.0.101": {
"type": "package",
"serviceable": true,
"sha512": "sha512-mLm8VGfGylp9q+rbJDp3uw0BOeNzfGENecVz/EYGlzq3ss7tfajGXHCMoZm/GxJ9vSn9pcK22UXWZnQ5GJQMjA==",
"path": "protobuf-net/3.0.101",
"hashPath": "protobuf-net.3.0.101.nupkg.sha512"
},
"protobuf-net.Core/3.0.101": {
"type": "package",
"serviceable": true,
"sha512": "sha512-gf9QIF0RlctfjmOjbE6eOyMulkNEsH7tHncjKj/4BTu9tkuTyrH3fv5I+35GnolJqKJ6fh9kYaezvNRL3t75+Q==",
"path": "protobuf-net.core/3.0.101",
"hashPath": "protobuf-net.core.3.0.101.nupkg.sha512"
},
"SteamKit2/2.4.1": {
"type": "package",
"serviceable": true,
"sha512": "sha512-t9yptysn/2YY6KZaI123vOOnumS+ZCFcC6MhFEkTiQ04mdpZ/EWhk5RVY7jU36IQHyTQUXotmn7taKFCXMKp4g==",
"path": "steamkit2/2.4.1",
"hashPath": "steamkit2.2.4.1.nupkg.sha512"
},
"System.Security.AccessControl/5.0.0": {
"type": "package",
"serviceable": true,
"sha512": "sha512-dagJ1mHZO3Ani8GH0PHpPEe/oYO+rVdbQjvjJkBRNQkX4t0r1iaeGn8+/ybkSLEan3/slM0t59SVdHzuHf2jmw==",
"path": "system.security.accesscontrol/5.0.0",
"hashPath": "system.security.accesscontrol.5.0.0.nupkg.sha512"
},
"System.Security.Principal.Windows/5.0.0": {
"type": "package",
"serviceable": true,
"sha512": "sha512-t0MGLukB5WAVU9bO3MGzvlGnyJPgUlcwerXn1kzBRjwLKixT96XV0Uza41W49gVd8zEMFu9vQEFlv0IOrytICA==",
"path": "system.security.principal.windows/5.0.0",
"hashPath": "system.security.principal.windows.5.0.0.nupkg.sha512"
}
}
}
@@ -0,0 +1,13 @@
{
"runtimeOptions": {
"tfm": "net6.0",
"rollForward": "LatestMajor",
"framework": {
"name": "Microsoft.NETCore.App",
"version": "6.0.0"
},
"configProperties": {
"System.Reflection.Metadata.MetadataUpdater.IsSupported": false
}
}
}
Binary file not shown.
Binary file not shown.
+55
View File
@@ -0,0 +1,55 @@
// const script = path.join(path.dirname(__dirname), 'extraRessources', 'DepotDownloader', 'DepotDownloader.exe');;
// const intance = spawn(script, ['-username lekilleur618', '-manifest 4038188869828689801', '-depot 620981', '-app 620980', '-remember-password'], {cwd: "C:\\test", shell: true});
// intance.stdout.on('data', (data) =>{
// console.log(data.toString());
// if(data.toString().includes('Enter account password for')){
// intance.stdin.write('MmBopN8qez5gKFZX\n');
// }
// });
// intance.stderr.on('data', (data) => console.log(data.toString()));
// intance.on('message', (message) => {console.log(message.toString())});
import { ipcMain } from 'electron';
import path from 'path';
import { ChildProcessWithoutNullStreams, spawn } from 'child_process';
import { createFolderIfNotExist } from '../utils';
export interface InitDownloadInfoInterface {
cwd: string ,
folder: string,
app: string,
depot: string,
manifest: string,
username: string,
stay: boolean
}
const DEPOT_DOWNLOADER_EXE = 'DepotDownloader.exe';
const DEPOT_DOWNLOADER_PATH = path.join(path.dirname(__dirname), '..', 'extraResources', 'depot-downloader', DEPOT_DOWNLOADER_EXE);
let PROCESS: ChildProcessWithoutNullStreams;
ipcMain.on('bs-download.start', async (event, args: InitDownloadInfoInterface) => {
console.log(DEPOT_DOWNLOADER_PATH);
console.log(args.cwd);
createFolderIfNotExist(args.cwd);
PROCESS = spawn(DEPOT_DOWNLOADER_PATH, [`-app ${args.app}`, `-depot ${args.depot}`, `-manifest ${args.manifest}`, `-username ${args.username}`, `-dir ${args.folder}`, args.stay ? `-remember-password` : ''], {shell: true, cwd: args.cwd});
PROCESS.stdout.on('data', data => {
const out: string[] = data.toString().split('|');
console.log(out);
if(out[0] === "[Progress]"){ event.reply('bs-download.progress', out[1]); }
else if(out[0] === "[Password]" || out[0].includes('[Password]')){ event.reply('bs-download.ask-password'); }
else if(out[0] === "[any]"){ event.reply('bs-download.progress', out); }
});
PROCESS.stderr.on('data', (data) => {console.log(data.toString())});
});
ipcMain.on('bs-download.send-input', async (event, value: string) => {
if(PROCESS){ PROCESS.stdin.write(`${value}\n`); }
});
+1
View File
@@ -0,0 +1 @@
import './bs-download-ipcs';
+2
View File
@@ -135,3 +135,5 @@ app
});
})
.catch(console.log);
import './ipcs/custom-ipcs';
+3 -1
View File
@@ -1,6 +1,8 @@
import { contextBridge, ipcRenderer, IpcRendererEvent } from 'electron';
export type Channels = 'ipc-example';
export type Channels = 'bs-download.start'|'bs-download.send-input';
export type ReplyChannels = 'bs-download.ask-password';
contextBridge.exposeInMainWorld('electron', {
ipcRenderer: {
+4
View File
@@ -0,0 +1,4 @@
export function createFolderIfNotExist(path: string){
const [existsSync, mkdirSync] = [require('fs').existsSync, require('fs').mkdirSync];
if (!existsSync(path)){ mkdirSync(path); }
}
+6 -6
View File
@@ -1,13 +1,13 @@
import { createRoot } from 'react-dom/client';
import App from './App';
import { InitDownloadInfoInterface } from 'main/ipcs/bs-download-ipcs';
const container = document.getElementById('root')!;
const root = createRoot(container);
root.render(<App />);
// calling IPC exposed from preload script
window.electron.ipcRenderer.once('ipc-example', (arg) => {
// eslint-disable-next-line no-console
console.log(arg);
});
window.electron.ipcRenderer.sendMessage('ipc-example', ['ping']);
setTimeout(() => {
window.electron.ipcRenderer.sendMessage('bs-download.start', {app: '620980', depot: '620981', manifest: '6222769774084748916', stay: true, username: 'lekilleur618', folder: 'test2', cwd: 'C:\\test'} as InitDownloadInfoInterface);
}, 5000);
window.electron.ipcRenderer.on('bs-download.ask-password', () => console.log('omg popup password'));
+5 -5
View File
@@ -1,15 +1,15 @@
import { Channels } from 'main/preload';
import { Channels, ReplyChannels } from 'main/preload';
declare global {
interface Window {
electron: {
ipcRenderer: {
sendMessage(channel: Channels, args: unknown[]): void;
sendMessage(channel: Channels, args: any): void;
on(
channel: string,
func: (...args: unknown[]) => void
channel: ReplyChannels,
func: (...args: any) => void
): (() => void) | undefined;
once(channel: string, func: (...args: unknown[]) => void): void;
once(channel: ReplyChannels, func: (...args: any) => void): void;
};
};
}