Skip to content

Commit

Permalink
WIP: Rust lib - fpfss sync p1
Browse files Browse the repository at this point in the history
  • Loading branch information
colin969 committed Feb 6, 2024
1 parent f0e5c26 commit f9d90cf
Show file tree
Hide file tree
Showing 18 changed files with 923 additions and 2,763 deletions.
2,329 changes: 178 additions & 2,151 deletions package-lock.json

Large diffs are not rendered by default.

267 changes: 132 additions & 135 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,135 +1,132 @@
{
"name": "flashpoint-launcher",
"version": "12.2.1",
"description": "A desktop application used to browse, manage and play games from Flashpoint Archive",
"main": "build/main/index.js",
"config": {
"forceUpdate": 1,
"installed": false
},
"scripts": {
"start": "electron ./build/main/index.js",
"start-logger": "electron ./build/main/index.js logger=true",
"build": "gulp build",
"watch": "gulp watch",
"pack": "gulp pack",
"snapshot": "cross-env-shell PACK_PLATFORM=win32 PACK_ARCH=ia32 NODE_ENV=production \"npm run build && npm run pack\"",
"test": "jest",
"lint": "eslint ./src/**/*.{ts,tsx} ./gulpfile.js",
"nexusPack": "gulp nexusPack",
"pack:linux": "cross-env PACK_PLATFORM=linux PACK_ARCH=x64 gulp pack",
"pack:win32": "cross-env PACK_PLATFORM=win32 PACK_ARCH=ia32 gulp pack",
"pack:darwin": "cross-env PACK_PLATFORM=darwin PACK_ARCH=x64 gulp pack",
"pack:all": "cross-env PACK_PLATFORM=all PACK_ARCH=all gulp pack",
"release": "cross-env-shell NODE_ENV=production PUBLISH=true \"npm run build && npm run pack\"",
"release:linux": "cross-env-shell NODE_ENV=production PUBLISH=true \"npm run build && npm run pack:linux\"",
"release:win32": "cross-env-shell NODE_ENV=production PUBLISH=true \"npm run build && npm run pack:win32\"",
"release:darwin": "cross-env-shell NODE_ENV=production PUBLISH=true \"npm run build && npm run pack:darwin\"",
"release:all": "cross-env-shell NODE_ENV=production PUBLISH=true \"npm run build && npm run pack:all\"",
"postinstall": "electron-builder install-app-deps & gulp extInstall",
"clean": "gulp clean"
},
"author": {
"name": "Jesper Gustafsson",
"email": "[email protected]"
},
"license": "MIT",
"dependencies": {
"@electron/remote": "2.0.8",
"@fortawesome/fontawesome-svg-core": "1.2.36",
"@fortawesome/free-solid-svg-icons": "5.15.4",
"@fortawesome/react-fontawesome": "0.1.18",
"@types/react-virtualized": "^9.21.21",
"axios": "1.3.4",
"better-sqlite3": "9.2.2",
"connected-react-router": "6.9.2",
"electron-updater": "4.3.1",
"electron-util": "0.14.2",
"fast-xml-parser": "3.16.0",
"follow-redirects": "1.14.8",
"fs-extra": "8.1.0",
"lodash": "^4.17.21",
"mime": "2.4.4",
"minimist": "^1.2.7",
"node-7z": "1.1.1",
"ps-tree": "1.2.0",
"react": "17.0.2",
"react-color": "2.18.0",
"react-datepicker": "4.8.0",
"react-dom": "17.0.2",
"react-keybind": "0.9.4",
"react-markdown": "7.0.1",
"react-redux": "7.2.8",
"react-router-dom": "5.1.2",
"react-virtualized-reactv17": "9.23.0",
"redux": "4.0.5",
"redux-devtools-extension": "2.13.8",
"reflect-metadata": "0.1.10",
"remark-gfm": "2.0.0",
"tail": "2.0.3",
"terminate": "^2.6.1",
"typeorm": "0.3.19",
"typesafe-actions": "4.4.2",
"uuid": "3.3.2",
"uuid-validate": "0.0.3",
"which": "1.3.1",
"ws": "7.4.6",
"yaml": "2.1.0",
"zod": "^3.22.2"
},
"devDependencies": {
"@kayahr/jest-electron-runner": "^29.3.1",
"@swc/cli": "0.1.61",
"@swc/core": "1.3.35",
"@types/better-sqlite3": "7.5.0",
"@types/follow-redirects": "1.8.0",
"@types/fs-extra": "8.1.0",
"@types/jest": "27.5.1",
"@types/lodash": "^4.14.192",
"@types/mime": "2.0.1",
"@types/minimist": "^1.2.2",
"@types/node": "14.14.31",
"@types/ps-tree": "1.1.2",
"@types/react": "17.0.2",
"@types/react-color": "3.0.1",
"@types/react-datepicker": "4.8.0",
"@types/react-dom": "17.0.2",
"@types/react-redux": "7.1.7",
"@types/react-router-dom": "5.1.7",
"@types/tail": "2.0.0",
"@types/uuid": "3.4.5",
"@types/uuid-validate": "0.0.1",
"@types/which": "1.3.2",
"@types/ws": "6.0.3",
"@typescript-eslint/eslint-plugin": "6.18.0",
"@typescript-eslint/parser": "6.18.0",
"cargo-cp-artifact": "^0.1",
"chokidar": "^3.5.3",
"coveralls": "3.1.0",
"cross-env": "7.0.2",
"electron": "19.1.9",
"electron-builder": "23.6.0",
"eslint": "8.33.0",
"eslint-plugin-jsdoc": "^48.0.2",
"eslint-plugin-only-warn": "1.1.0",
"eslint-plugin-react": "7.32.2",
"gulp": "4.0.2",
"jest": "29.4.2",
"lefthook": "^1.5.5",
"swc-loader": "0.2.3",
"ts-jest": "29.0.5",
"ts-loader": "9.4.1",
"ts-node": "10.8.0",
"ts-transform-paths": "^2.0.3",
"tsconfig-paths-webpack-plugin": "3.2.0",
"tslint": "5.18.0",
"tswc": "^1.1.1",
"ttypescript": "^1.5.15",
"typescript": "4.6.2",
"webpack": "5.74.0",
"webpack-cli": "4.10.0"
},
"optionalDependencies": {
"fsevents": "2.1.3"
}
}
{
"name": "flashpoint-launcher",
"version": "12.2.1",
"description": "A desktop application used to browse, manage and play games from Flashpoint Archive",
"main": "build/main/index.js",
"config": {
"forceUpdate": 1,
"installed": false
},
"scripts": {
"start": "electron ./build/main/index.js --remote-debugging-port=9224",
"start-logger": "electron ./build/main/index.js logger=true",
"build": "gulp build",
"watch": "gulp watch",
"pack": "gulp pack",
"snapshot": "cross-env-shell PACK_PLATFORM=win32 PACK_ARCH=ia32 NODE_ENV=production \"npm run build && npm run pack\"",
"test": "jest",
"lint": "eslint ./src/**/*.{ts,tsx} ./gulpfile.js",
"nexusPack": "gulp nexusPack",
"pack:linux": "cross-env PACK_PLATFORM=linux PACK_ARCH=x64 gulp pack",
"pack:win32": "cross-env PACK_PLATFORM=win32 PACK_ARCH=ia32 gulp pack",
"pack:darwin": "cross-env PACK_PLATFORM=darwin PACK_ARCH=x64 gulp pack",
"pack:all": "cross-env PACK_PLATFORM=all PACK_ARCH=all gulp pack",
"release": "cross-env-shell NODE_ENV=production PUBLISH=true \"npm run build && npm run pack\"",
"release:linux": "cross-env-shell NODE_ENV=production PUBLISH=true \"npm run build && npm run pack:linux\"",
"release:win32": "cross-env-shell NODE_ENV=production PUBLISH=true \"npm run build && npm run pack:win32\"",
"release:darwin": "cross-env-shell NODE_ENV=production PUBLISH=true \"npm run build && npm run pack:darwin\"",
"release:all": "cross-env-shell NODE_ENV=production PUBLISH=true \"npm run build && npm run pack:all\"",
"postinstall": "electron-builder install-app-deps & gulp extInstall",
"clean": "gulp clean"
},
"author": {
"name": "Jesper Gustafsson",
"email": "[email protected]"
},
"license": "MIT",
"dependencies": {
"@electron/remote": "2.0.8",
"@fortawesome/fontawesome-svg-core": "1.2.36",
"@fortawesome/free-solid-svg-icons": "5.15.4",
"@fortawesome/react-fontawesome": "0.1.18",
"@types/react-virtualized": "^9.21.21",
"axios": "1.3.4",
"connected-react-router": "6.9.2",
"electron-updater": "4.3.1",
"electron-util": "0.14.2",
"fast-xml-parser": "3.16.0",
"follow-redirects": "1.14.8",
"fs-extra": "8.1.0",
"lodash": "^4.17.21",
"mime": "2.4.4",
"minimist": "^1.2.7",
"node-7z": "1.1.1",
"ps-tree": "1.2.0",
"react": "17.0.2",
"react-color": "2.18.0",
"react-datepicker": "4.8.0",
"react-dom": "17.0.2",
"react-keybind": "0.9.4",
"react-markdown": "7.0.1",
"react-redux": "7.2.8",
"react-router-dom": "5.1.2",
"react-virtualized-reactv17": "9.23.0",
"redux": "4.0.5",
"redux-devtools-extension": "2.13.8",
"reflect-metadata": "0.1.10",
"remark-gfm": "2.0.0",
"tail": "2.0.3",
"terminate": "^2.6.1",
"typesafe-actions": "4.4.2",
"uuid": "3.3.2",
"uuid-validate": "0.0.3",
"which": "1.3.1",
"ws": "7.4.6",
"yaml": "2.1.0",
"zod": "^3.22.2"
},
"devDependencies": {
"@kayahr/jest-electron-runner": "^29.3.1",
"@swc/cli": "0.1.61",
"@swc/core": "1.3.35",
"@types/follow-redirects": "1.8.0",
"@types/fs-extra": "8.1.0",
"@types/jest": "27.5.1",
"@types/lodash": "^4.14.192",
"@types/mime": "2.0.1",
"@types/minimist": "^1.2.2",
"@types/node": "14.14.31",
"@types/ps-tree": "1.1.2",
"@types/react": "17.0.2",
"@types/react-color": "3.0.1",
"@types/react-datepicker": "4.8.0",
"@types/react-dom": "17.0.2",
"@types/react-redux": "7.1.7",
"@types/react-router-dom": "5.1.7",
"@types/tail": "2.0.0",
"@types/uuid": "3.4.5",
"@types/uuid-validate": "0.0.1",
"@types/which": "1.3.2",
"@types/ws": "6.0.3",
"@typescript-eslint/eslint-plugin": "6.18.0",
"@typescript-eslint/parser": "6.18.0",
"cargo-cp-artifact": "^0.1",
"chokidar": "^3.5.3",
"coveralls": "3.1.0",
"cross-env": "7.0.2",
"electron": "19.1.9",
"electron-builder": "23.6.0",
"eslint": "8.33.0",
"eslint-plugin-jsdoc": "^48.0.2",
"eslint-plugin-only-warn": "1.1.0",
"eslint-plugin-react": "7.32.2",
"gulp": "4.0.2",
"jest": "29.4.2",
"lefthook": "^1.5.5",
"swc-loader": "0.2.3",
"ts-jest": "29.0.5",
"ts-loader": "9.4.1",
"ts-node": "10.8.0",
"ts-transform-paths": "^2.0.3",
"tsconfig-paths-webpack-plugin": "3.2.0",
"tslint": "5.18.0",
"tswc": "^1.1.1",
"ttypescript": "^1.5.15",
"typescript": "4.6.2",
"webpack": "5.74.0",
"webpack-cli": "4.10.0"
},
"optionalDependencies": {
"fsevents": "2.1.3"
}
}
2 changes: 2 additions & 0 deletions src/back/SocketServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,8 @@ export class SocketServer {
return;
}

console.log(parsed_data);

const [msg, msg_error] = validate_socket_message<any>(parsed_data);

if (!msg || msg_error) {
Expand Down
8 changes: 4 additions & 4 deletions src/back/download.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ export async function downloadGameData(gameDataId: number, dataPacksFolderPath:
// GameData real, find an available source
for (const source of sources) {
try {
const fullUrl = new URL(`${gameData.gameId}-${gameData.dateAdded.getTime()}.zip`, source.arguments[0]).href;
const tempPath = path.join(dataPacksFolderPath, `${gameData.gameId}-${gameData.dateAdded.getTime()}.zip.temp`);
const fullUrl = new URL(`${gameData.gameId}-${new Date(gameData.dateAdded).getTime()}.zip`, source.arguments[0]).href;
const tempPath = path.join(dataPacksFolderPath, `${gameData.gameId}-${new Date(gameData.dateAdded).getTime()}.zip.temp`);
await downloadFile(fullUrl, tempPath, abortSignal, onProgress, onDetails);
// Check hash of download
const hash = crypto.createHash('sha256');
Expand Down Expand Up @@ -69,7 +69,7 @@ export async function importGameDataSkipHash(gameId: string, filePath: string, d
}
// Copy file
const dateAdded = new Date();
const newFilename = existingGameData ? `${gameId}-${existingGameData.dateAdded.getTime()}.zip` : `${gameId}-${dateAdded.getTime()}.zip`;
const newFilename = existingGameData ? `${gameId}-${new Date(existingGameData.dateAdded).getTime()}.zip` : `${gameId}-${dateAdded.getTime()}.zip`;
const newPath = path.join(dataPacksFolderPath, newFilename);
await fs.promises.copyFile(filePath, newPath);
if (existingGameData) {
Expand All @@ -81,7 +81,7 @@ export async function importGameDataSkipHash(gameId: string, filePath: string, d
title: 'Data Pack',
gameId: gameId,
size: stats.size,
dateAdded,
dateAdded: dateAdded.toISOString(),
presentOnDisk: true,
path: newFilename,
sha256,
Expand Down
9 changes: 0 additions & 9 deletions src/back/extensions/NodeInterceptor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import { IExtension, IExtensionManifest } from '@shared/extensions/interfaces';
import { ILogEntry } from '@shared/Log/interface';
import * as flashpoint from 'flashpoint-launcher';
import { createApiFactory } from './ApiImplementation';
import * as Database from 'better-sqlite3';
// eslint-disable-next-line @typescript-eslint/no-var-requires

type LoadFunction = {
Expand Down Expand Up @@ -133,11 +132,3 @@ export class FPLNodeModuleFactory implements INodeModuleFactory {
return this._defaultApiImpl;
}
}

export class SqliteInterceptorFactory implements INodeModuleFactory {
public readonly nodeModuleName = 'better-sqlite3';

public load(_request: string): any {
return Database;
}
}
12 changes: 5 additions & 7 deletions src/back/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ import { ExtensionService } from './extensions/ExtensionService';
import {
FPLNodeModuleFactory,
INodeModuleFactory,
SqliteInterceptorFactory,
installNodeInterceptor,
registerInterceptor
} from './extensions/NodeInterceptor';
Expand Down Expand Up @@ -701,11 +700,11 @@ async function initialize() {
// Populate unique values
state.suggestions = {
tags: [],
playMode: [],
platforms: [],
status: [],
applicationPath: [],
library: [],
playMode: await fpDatabase.findAllGamePlayModes(),
platforms: (await fpDatabase.findAllPlatforms()).map(p => p.name),
status: await fpDatabase.findAllGameStatuses(),
applicationPath: await fpDatabase.findAllGameApplicationPaths(),
library: await fpDatabase.findAllGameLibraries(),
};

// Check for Flashpoint Manager Updates
Expand Down Expand Up @@ -814,7 +813,6 @@ async function initialize() {
state,
),
state.moduleInterceptor);
registerInterceptor(new SqliteInterceptorFactory(), state.moduleInterceptor);
installNodeInterceptor(state.moduleInterceptor)
.then(async () => {
// Load each extension
Expand Down
Loading

0 comments on commit f9d90cf

Please sign in to comment.