fix: resolve issues with dependency upgrades
This commit is contained in:
+10
-14
@@ -3,26 +3,21 @@ import { FlatCompat } from "@eslint/eslintrc"
|
||||
import js from "@eslint/js"
|
||||
import eslintConfigPrettier from "eslint-config-prettier"
|
||||
import jsdoc from "eslint-plugin-jsdoc"
|
||||
import reactJsxRuntime from "eslint-plugin-react/configs/jsx-runtime.js"
|
||||
import reactRecommended from "eslint-plugin-react/configs/recommended.js"
|
||||
import react from "eslint-plugin-react"
|
||||
import globals from "globals"
|
||||
import { dirname } from "node:path"
|
||||
import { fileURLToPath } from "node:url"
|
||||
import ts from "typescript-eslint"
|
||||
|
||||
const __filename = fileURLToPath(import.meta.url)
|
||||
const __dirname = dirname(__filename)
|
||||
|
||||
// @ts-expect-error: FlatCompat is not properly typed
|
||||
const compat = new FlatCompat({
|
||||
baseDirectory: __dirname,
|
||||
baseDirectory: import.meta.dirname,
|
||||
})
|
||||
|
||||
/** @type {import('eslint').Linter.FlatConfig[]} */
|
||||
/** @type {import('eslint').Linter.Config[]} */
|
||||
export default [
|
||||
js.configs.recommended,
|
||||
reactRecommended,
|
||||
reactJsxRuntime,
|
||||
...compat.extends("plugin:react-hooks/recommended", "plugin:@typescript-eslint/recommended"),
|
||||
react.configs.flat.recommended,
|
||||
react.configs.flat['jsx-runtime'],
|
||||
...compat.extends("plugin:react-hooks/recommended"),
|
||||
.../** @type {import('eslint').Linter.Config[]} */ (ts.configs.recommended),
|
||||
jsdoc.configs["flat/recommended-typescript-error"],
|
||||
{
|
||||
languageOptions: {
|
||||
@@ -31,7 +26,8 @@ export default [
|
||||
...globals.browser,
|
||||
},
|
||||
parserOptions: {
|
||||
project: "./tsconfig.json",
|
||||
projectService: true,
|
||||
tsconfigRootDir: import.meta.dirname,
|
||||
},
|
||||
},
|
||||
rules: {
|
||||
|
||||
Generated
+4566
-2243
File diff suppressed because it is too large
Load Diff
+37
-37
@@ -11,58 +11,58 @@
|
||||
"license": "MPL-2.0",
|
||||
"main": ".webpack/main.cjs",
|
||||
"dependencies": {
|
||||
"@reduxjs/toolkit": "^1.9.7",
|
||||
"adm-zip": "^0.5.10",
|
||||
"debug": "^4.3.4",
|
||||
"electron-updater": "^6.1.4",
|
||||
"@reduxjs/toolkit": "^2.2.7",
|
||||
"adm-zip": "^0.5.16",
|
||||
"debug": "^4.3.6",
|
||||
"electron-updater": "^6.2.1",
|
||||
"electron-window-state": "5.0.3",
|
||||
"immer": "^10.0.3",
|
||||
"moment": "^2.29.4",
|
||||
"immer": "^10.1.1",
|
||||
"moment": "^2.30.1",
|
||||
"mousetrap": "1.6.5",
|
||||
"optolith-character-schema": "^0.0.3",
|
||||
"optolith-database-schema": "^0.16.8",
|
||||
"react": "^18.2.0",
|
||||
"react-dom": "^18.2.0",
|
||||
"react-markdown": "^9.0.0",
|
||||
"react-redux": "^8.1.3",
|
||||
"react": "^18.3.1",
|
||||
"react-dom": "^18.3.1",
|
||||
"react-markdown": "^9.0.1",
|
||||
"react-redux": "^9.1.2",
|
||||
"rehype-raw": "^7.0.0",
|
||||
"remark-breaks": "^4.0.0",
|
||||
"remark-gfm": "^4.0.0",
|
||||
"semver": "^7.5.4"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@electron/notarize": "^2.1.0",
|
||||
"@eslint/eslintrc": "^2.1.2",
|
||||
"@eslint/js": "^8.52.0",
|
||||
"@electron/notarize": "^2.4.0",
|
||||
"@eslint/eslintrc": "^3.1.0",
|
||||
"@eslint/js": "^9.9.1",
|
||||
"@rspack/cli": "^1.0.0",
|
||||
"@rspack/core": "^1.0.0",
|
||||
"@types/mousetrap": "^1.6.13",
|
||||
"@types/node": "^20.8.10",
|
||||
"@types/react": "^18.2.33",
|
||||
"@types/react-dom": "^18.2.14",
|
||||
"@types/react-redux": "^7.1.28",
|
||||
"@types/semver": "^7.5.4",
|
||||
"@types/ssh2-sftp-client": "^9.0.2",
|
||||
"@typescript-eslint/eslint-plugin": "^6.9.1",
|
||||
"@typescript-eslint/parser": "^6.9.1",
|
||||
"css-loader": "^6.8.1",
|
||||
"electron": "^27.0.3",
|
||||
"@types/mousetrap": "^1.6.15",
|
||||
"@types/node": "^22.5.1",
|
||||
"@types/react": "^18.3.5",
|
||||
"@types/react-dom": "^18.3.0",
|
||||
"@types/react-redux": "^7.1.33",
|
||||
"@types/semver": "^7.5.8",
|
||||
"@types/ssh2-sftp-client": "^9.0.4",
|
||||
"css-loader": "^7.1.2",
|
||||
"electron": "^32.0.1",
|
||||
"electron-builder": "^24.6.4",
|
||||
"eslint-config-prettier": "^9.0.0",
|
||||
"eslint-plugin-jsdoc": "^46.8.2",
|
||||
"eslint-plugin-react": "^7.33.2",
|
||||
"eslint-plugin-react-hooks": "^4.6.0",
|
||||
"eslint-plugin-tsdoc": "^0.2.17",
|
||||
"glob": "^10.3.10",
|
||||
"globals": "^13.23.0",
|
||||
"optolith-tsjsonschemamd": "^0.9.4",
|
||||
"eslint-config-prettier": "^9.1.0",
|
||||
"eslint-plugin-jsdoc": "^50.2.2",
|
||||
"eslint-plugin-react": "^7.35.0",
|
||||
"eslint-plugin-react-hooks": "^4.6.2",
|
||||
"eslint-plugin-tsdoc": "^0.3.0",
|
||||
"glob": "^11.0.0",
|
||||
"globals": "^15.9.0",
|
||||
"html-webpack-plugin": "^5.6.0",
|
||||
"optolith-tsjsonschemamd": "^0.10.7",
|
||||
"resolve-url-loader": "^5.0.0",
|
||||
"sass": "^1.69.5",
|
||||
"sass-loader": "^13.3.2",
|
||||
"ssh2-sftp-client": "^9.1.0",
|
||||
"sass": "^1.77.8",
|
||||
"sass-loader": "^16.0.1",
|
||||
"ssh2-sftp-client": "^11.0.0",
|
||||
"standard-version": "^9.5.0",
|
||||
"tsx": "^3.14.0",
|
||||
"typescript": "^5.2.2"
|
||||
"tsx": "^4.19.0",
|
||||
"typescript": "^5.2.2",
|
||||
"typescript-eslint": "^8.3.0"
|
||||
},
|
||||
"scripts": {
|
||||
"prerelease:win": "set NODE_ENV=development && node ./build/build.js --win --prerelease",
|
||||
|
||||
+24
-10
@@ -1,7 +1,6 @@
|
||||
// @ts-check
|
||||
|
||||
import { dirname, resolve } from "node:path"
|
||||
import { fileURLToPath } from "node:url"
|
||||
import { resolve } from "node:path"
|
||||
import { getOptimization } from "./rspack.optimization.js"
|
||||
import { rendererPlugins } from "./rspack.plugins.js"
|
||||
import { rules } from "./rspack.rules.js"
|
||||
@@ -18,7 +17,7 @@ const createRendererConfig = (name, mode) => [
|
||||
entry: {
|
||||
[`renderer_${name}`]: `./src/${name}_window/index.tsx`,
|
||||
},
|
||||
target: "electron27-renderer",
|
||||
target: "electron-renderer",
|
||||
optimization: getOptimization(`renderer_${name}`),
|
||||
module: {
|
||||
rules: rules,
|
||||
@@ -28,11 +27,15 @@ const createRendererConfig = (name, mode) => [
|
||||
conditionNames: ["browser", "default", "import", "require"],
|
||||
},
|
||||
output: {
|
||||
path: resolve(dirname(fileURLToPath(import.meta.url)), ".webpack"),
|
||||
path: resolve(import.meta.dirname, ".webpack"),
|
||||
filename: "[name].js",
|
||||
globalObject: "globalThis",
|
||||
},
|
||||
plugins: rendererPlugins(mode),
|
||||
externals: {
|
||||
"electron/renderer": "commonjs electron/renderer",
|
||||
"electron/common": "commonjs electron/common",
|
||||
},
|
||||
externalsPresets: {
|
||||
electronRenderer: true,
|
||||
},
|
||||
@@ -45,7 +48,7 @@ const createRendererConfig = (name, mode) => [
|
||||
entry: {
|
||||
[`renderer_${name}_preload`]: `./src/${name}_window_preload/index.ts`,
|
||||
},
|
||||
target: "electron27-preload",
|
||||
target: "electron-preload",
|
||||
module: {
|
||||
rules: rules,
|
||||
},
|
||||
@@ -53,9 +56,16 @@ const createRendererConfig = (name, mode) => [
|
||||
symlinks: false,
|
||||
},
|
||||
output: {
|
||||
path: resolve(dirname(fileURLToPath(import.meta.url)), ".webpack"),
|
||||
path: resolve(import.meta.dirname, ".webpack"),
|
||||
filename: "[name].cjs",
|
||||
},
|
||||
externals: {
|
||||
"electron/renderer": "commonjs electron/renderer",
|
||||
"electron/common": "commonjs electron/common",
|
||||
},
|
||||
externalsPresets: {
|
||||
electronPreload: true,
|
||||
},
|
||||
},
|
||||
]
|
||||
|
||||
@@ -74,7 +84,7 @@ export default () => {
|
||||
entry: {
|
||||
main: "./src/main/index.ts",
|
||||
},
|
||||
target: "electron27-main",
|
||||
target: "electron-main",
|
||||
optimization: getOptimization("main"),
|
||||
module: {
|
||||
rules: rules,
|
||||
@@ -83,9 +93,13 @@ export default () => {
|
||||
symlinks: false,
|
||||
},
|
||||
output: {
|
||||
path: resolve(dirname(fileURLToPath(import.meta.url)), ".webpack"),
|
||||
path: resolve(import.meta.dirname, ".webpack"),
|
||||
filename: "[name].cjs",
|
||||
},
|
||||
externals: {
|
||||
"electron/main": "commonjs electron/main",
|
||||
"electron/common": "commonjs electron/common",
|
||||
},
|
||||
externalsPresets: {
|
||||
electronMain: true,
|
||||
},
|
||||
@@ -96,7 +110,7 @@ export default () => {
|
||||
entry: {
|
||||
database: "./src/database/index.ts",
|
||||
},
|
||||
target: "electron27-main",
|
||||
target: "electron-main",
|
||||
optimization: getOptimization("database"),
|
||||
module: {
|
||||
rules: rules,
|
||||
@@ -105,7 +119,7 @@ export default () => {
|
||||
symlinks: false,
|
||||
},
|
||||
output: {
|
||||
path: resolve(dirname(fileURLToPath(import.meta.url)), ".webpack"),
|
||||
path: resolve(import.meta.dirname, ".webpack"),
|
||||
filename: "[name].cjs",
|
||||
},
|
||||
externalsPresets: {
|
||||
|
||||
+2
-1
@@ -1,6 +1,7 @@
|
||||
// @ts-check
|
||||
|
||||
import rspack from "@rspack/core"
|
||||
import HtmlWebpackPlugin from "html-webpack-plugin"
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -8,7 +9,7 @@ import rspack from "@rspack/core"
|
||||
* @returns {import("@rspack/core").Configuration["plugins"]}
|
||||
*/
|
||||
export const rendererPlugins = (mode) => [
|
||||
new rspack.HtmlRspackPlugin({
|
||||
new HtmlWebpackPlugin({
|
||||
filename: "[name].html",
|
||||
template: "./src/template.html",
|
||||
}),
|
||||
|
||||
+3
-1
@@ -11,7 +11,9 @@ export const rules = [
|
||||
exclude: [/node_modules/],
|
||||
loader: "builtin:swc-loader",
|
||||
resolve: {
|
||||
extensions: [".ts", ".tsx", ".js"],
|
||||
extensionAlias: {
|
||||
'.js': ['.tsx', '.ts', 'jsx', '.js'],
|
||||
},
|
||||
},
|
||||
options: {
|
||||
jsc: {
|
||||
|
||||
@@ -1,11 +1,18 @@
|
||||
import { Action, AnyAction } from "redux"
|
||||
import { Action, UnknownAction } from "redux"
|
||||
import { ThunkAction, ThunkDispatch } from "redux-thunk"
|
||||
import { AppStateRecord } from "../Models/AppState"
|
||||
|
||||
export type ReduxAction<R = void, D extends Action = AnyAction> =
|
||||
ThunkAction<R, AppStateRecord, undefined, D>
|
||||
export type ReduxAction<R = void, D extends Action = UnknownAction> = ThunkAction<
|
||||
R,
|
||||
AppStateRecord,
|
||||
undefined,
|
||||
D
|
||||
>
|
||||
|
||||
export type ReduxActions<R = void, D extends Action = AnyAction> = ReduxAction<R, D> | D
|
||||
export type ReduxActions<R = void, D extends Action = UnknownAction> = ReduxAction<R, D> | D
|
||||
|
||||
export type ReduxDispatch<A extends Action = AnyAction> =
|
||||
ThunkDispatch<AppStateRecord, undefined, A>
|
||||
export type ReduxDispatch<A extends Action = UnknownAction> = ThunkDispatch<
|
||||
AppStateRecord,
|
||||
undefined,
|
||||
A
|
||||
>
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
import { AnyAction } from "redux"
|
||||
import { UnknownAction } from "redux"
|
||||
import { Record } from "../../Data/Record"
|
||||
import { AppState } from "../Models/AppState"
|
||||
import { reduceReducersCWithInter } from "../Utilities/reduceReducers"
|
||||
import { appPostReducer } from "./appPostReducer"
|
||||
import { appSlicesReducer } from "./appSlicesReducer"
|
||||
|
||||
export const appReducer =
|
||||
reduceReducersCWithInter<Record<AppState>, AnyAction> (appSlicesReducer, appPostReducer)
|
||||
export const appReducer = reduceReducersCWithInter<Record<AppState>, UnknownAction>(
|
||||
appSlicesReducer,
|
||||
appPostReducer,
|
||||
)
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import { Action, AnyAction } from "redux"
|
||||
import { Action, UnknownAction } from "redux"
|
||||
import { over } from "../../Data/Lens"
|
||||
import { foldr, OrderedSet } from "../../Data/OrderedSet"
|
||||
import { makeLenses, Omit, Record, RecordBase, RecordCreator, RecordIBase } from "../../Data/Record"
|
||||
|
||||
export type ReducerM<S = any, A extends Action = AnyAction> = (action: A) => (mstate: S) => S
|
||||
export type ReducerM<S = any, A extends Action = UnknownAction> = (action: A) => (mstate: S) => S
|
||||
|
||||
type ReducerRecord<S extends RecordBase, A extends Action = any> = {
|
||||
[K in keyof S]: ReducerM<S[K], A>
|
||||
@@ -26,17 +26,16 @@ type ReducerRecord<S extends RecordBase, A extends Action = any> = {
|
||||
* - `L`: Lenses for all slices.
|
||||
*/
|
||||
export const combineReducerRecord =
|
||||
<S extends RecordIBase<Name>, A extends Action = any, Name extends string = S["@@name"]>
|
||||
(x: RecordCreator<S>) =>
|
||||
<S extends RecordIBase<Name>, A extends Action = any, Name extends string = S["@@name"]>(
|
||||
x: RecordCreator<S>,
|
||||
) =>
|
||||
(reducers: Required<ReducerRecord<Omit<S, "@@name">>>) => {
|
||||
const xL = makeLenses (x)
|
||||
const xL = makeLenses(x)
|
||||
|
||||
const reducer =
|
||||
(action: A) =>
|
||||
(mstate: Record<S>) =>
|
||||
foldr ((key: keyof Omit<S, "@@name">) => over (xL [key]) (reducers [key] (action)))
|
||||
(mstate)
|
||||
(x .keys as OrderedSet<keyof Omit<S, "@@name">>)
|
||||
const reducer = (action: A) => (mstate: Record<S>) =>
|
||||
foldr((key: keyof Omit<S, "@@name">) => over(xL[key])(reducers[key](action)))(mstate)(
|
||||
x.keys as OrderedSet<keyof Omit<S, "@@name">>,
|
||||
)
|
||||
|
||||
reducer.default = x.default
|
||||
reducer.A = x.A
|
||||
|
||||
+41
-47
@@ -1,4 +1,4 @@
|
||||
import { Action, AnyAction } from "redux"
|
||||
import { Action, UnknownAction } from "redux"
|
||||
import { flip, ident } from "../../Data/Function"
|
||||
import { set } from "../../Data/Lens"
|
||||
import { cons, elem, empty, List, uncons } from "../../Data/List"
|
||||
@@ -14,16 +14,14 @@ export interface UndoState<S> {
|
||||
future: List<S>
|
||||
}
|
||||
|
||||
export const createUndoState =
|
||||
<S> (x: S) => fromDefault ("UndoState")
|
||||
<UndoState<S>> ({
|
||||
past: List.empty,
|
||||
present: x,
|
||||
future: List.empty,
|
||||
})
|
||||
export const createUndoState = <S>(x: S) =>
|
||||
fromDefault("UndoState")<UndoState<S>>({
|
||||
past: List.empty,
|
||||
present: x,
|
||||
future: List.empty,
|
||||
})
|
||||
|
||||
export type UndoReducer<S, A> =
|
||||
(state: UndoState<S>, action: A) => UndoState<S>
|
||||
export type UndoReducer<S, A> = (state: UndoState<S>, action: A) => UndoState<S>
|
||||
|
||||
/**
|
||||
* `undo :: [ActionTypes] -> [ActionTypes] -> s -> (a -> s -> s) -> a -> s -> s`
|
||||
@@ -42,48 +40,44 @@ export type UndoReducer<S, A> =
|
||||
export const undo =
|
||||
(resetActionTypes: List<string>) =>
|
||||
(ignoreActionTypes: List<string>) =>
|
||||
<S>
|
||||
(defaultState: S) =>
|
||||
<A extends Action = AnyAction>
|
||||
(reducer: (action: A) => (state: S) => S) => {
|
||||
const L = createUndoState (defaultState)
|
||||
<S>(defaultState: S) =>
|
||||
<A extends Action = UnknownAction>(reducer: (action: A) => (state: S) => S) => {
|
||||
const L = createUndoState(defaultState)
|
||||
|
||||
const LL = makeLenses (L)
|
||||
const LL = makeLenses(L)
|
||||
|
||||
const undoHandler =
|
||||
(action: A): ident<Record<UndoState<S>>> =>
|
||||
state => {
|
||||
if (action.type === ActionTypes.UNDO) {
|
||||
return maybe
|
||||
(state)
|
||||
((unconsed: Pair<S, List<S>>) => L ({
|
||||
past: snd (unconsed),
|
||||
return maybe(state)((unconsed: Pair<S, List<S>>) =>
|
||||
L({
|
||||
past: snd(unconsed),
|
||||
// @ts-ignore
|
||||
present: fst (unconsed),
|
||||
future: cons (L.A.future (state)) (L.A.present (state)),
|
||||
}))
|
||||
(uncons (L.A.past (state)))
|
||||
present: fst(unconsed),
|
||||
future: cons(L.A.future(state))(L.A.present(state)),
|
||||
}),
|
||||
)(uncons(L.A.past(state)))
|
||||
}
|
||||
|
||||
if (action.type === ActionTypes.REDO) {
|
||||
return maybe
|
||||
(state)
|
||||
((unconsed: Pair<S, List<S>>) => L ({
|
||||
past: cons (L.A.past (state)) (L.A.present (state)),
|
||||
return maybe(state)((unconsed: Pair<S, List<S>>) =>
|
||||
L({
|
||||
past: cons(L.A.past(state))(L.A.present(state)),
|
||||
// @ts-ignore
|
||||
present: fst (unconsed),
|
||||
future: snd (unconsed),
|
||||
}))
|
||||
(uncons (L.A.future (state)))
|
||||
present: fst(unconsed),
|
||||
future: snd(unconsed),
|
||||
}),
|
||||
)(uncons(L.A.future(state)))
|
||||
}
|
||||
|
||||
const newPresent = reducer (action) (L.A.present (state))
|
||||
const newPresent = reducer(action)(L.A.present(state))
|
||||
|
||||
if (L.A.present (state) === newPresent) {
|
||||
if (elem (action.type) (resetActionTypes)) {
|
||||
return L ({
|
||||
if (L.A.present(state) === newPresent) {
|
||||
if (elem(action.type)(resetActionTypes)) {
|
||||
return L({
|
||||
// @ts-ignore
|
||||
present: L.A.present (state),
|
||||
present: L.A.present(state),
|
||||
past: empty,
|
||||
future: empty,
|
||||
})
|
||||
@@ -92,8 +86,8 @@ export const undo =
|
||||
return state
|
||||
}
|
||||
|
||||
if (elem (action.type) (resetActionTypes)) {
|
||||
return L ({
|
||||
if (elem(action.type)(resetActionTypes)) {
|
||||
return L({
|
||||
// @ts-ignore
|
||||
present: newPresent,
|
||||
past: empty,
|
||||
@@ -101,12 +95,12 @@ export const undo =
|
||||
})
|
||||
}
|
||||
|
||||
if (elem (action.type) (ignoreActionTypes)) {
|
||||
return set (LL.present) (newPresent) (state)
|
||||
if (elem(action.type)(ignoreActionTypes)) {
|
||||
return set(LL.present)(newPresent)(state)
|
||||
}
|
||||
|
||||
return L ({
|
||||
past: cons (L.AL.past (state)) (L.AL.present (state)),
|
||||
return L({
|
||||
past: cons(L.AL.past(state))(L.AL.present(state)),
|
||||
// @ts-ignore
|
||||
present: newPresent,
|
||||
future: empty,
|
||||
@@ -116,7 +110,7 @@ export const undo =
|
||||
undoHandler.default = L.default
|
||||
undoHandler.A = L.A
|
||||
undoHandler.AL = L.AL
|
||||
undoHandler.L = makeLenses (L)
|
||||
undoHandler.L = makeLenses(L)
|
||||
|
||||
return undoHandler
|
||||
}
|
||||
@@ -125,15 +119,15 @@ export const undo =
|
||||
* Calls `undo` without having any `ActionTypes` to reset history or to not
|
||||
* change history after an action has been dispatched.
|
||||
*/
|
||||
export const undoSimple = undo (empty) (empty)
|
||||
export const undoSimple = undo(empty)(empty)
|
||||
|
||||
/**
|
||||
* Calls `undo` only with `ActionTypes` to reset history.
|
||||
*/
|
||||
export const undoR = flip (undo) (empty)
|
||||
export const undoR = flip(undo)(empty)
|
||||
|
||||
/**
|
||||
* Calls `undo` only `ActionTypes` to not change history after an action has
|
||||
* been dispatched.
|
||||
*/
|
||||
export const undoI = undo (empty)
|
||||
export const undoI = undo(empty)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import Debug from "debug"
|
||||
import { join } from "node:path"
|
||||
import { parentPort } from "node:process"
|
||||
import process from "node:process"
|
||||
import type * as databaseSchema from "optolith-database-schema"
|
||||
import { getAbsoluteCachePaths, getAbsoluteEntityPaths } from "./contents/src/config.js"
|
||||
const debug = Debug("util:database")
|
||||
@@ -17,7 +17,7 @@ import("optolith-database-schema")
|
||||
})
|
||||
const cache = await db.getCache(getAbsoluteCachePaths(root))
|
||||
debug("database loaded")
|
||||
parentPort.postMessage({ raw, cache })
|
||||
process.send?.({ raw, cache })
|
||||
})
|
||||
.catch(err => {
|
||||
debug("database error: %O", err)
|
||||
|
||||
+17
-7
@@ -1,6 +1,7 @@
|
||||
import Debug from "debug"
|
||||
import { Menu, MenuItemConstructorOptions, app, ipcMain, utilityProcess } from "electron"
|
||||
import { autoUpdater } from "electron-updater"
|
||||
import { app, ipcMain, Menu, MenuItemConstructorOptions } from "electron/main"
|
||||
import { fork } from "node:child_process"
|
||||
import { readFile } from "node:fs/promises"
|
||||
import { join } from "node:path"
|
||||
import type { Database } from "../database/index.ts"
|
||||
@@ -17,12 +18,21 @@ app.setAppUserModelId("lukasobermann.optolith")
|
||||
const isMac = process.platform === "darwin"
|
||||
|
||||
debug("loading database ...")
|
||||
const databaseProcess = utilityProcess.fork(join(__dirname, "./database.cjs"), [app.getAppPath()])
|
||||
const databaseLoading = new Promise<Database>(resolve => {
|
||||
databaseProcess.on("message", (message: Database) => {
|
||||
debug("database received")
|
||||
resolve(message)
|
||||
})
|
||||
const databaseLoading = new Promise<Database>((resolve, reject) => {
|
||||
try {
|
||||
const args = [app.getAppPath()]
|
||||
debug(join(__dirname, "database.cjs"))
|
||||
const databaseProcess = fork(join(__dirname, "database.cjs"), args)
|
||||
.on("spawn", () => debug("database spawned"))
|
||||
.on("message", (message: Database) => {
|
||||
debug("database received")
|
||||
databaseProcess.kill()
|
||||
resolve(message)
|
||||
})
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
reject(error)
|
||||
}
|
||||
})
|
||||
|
||||
const runAsync =
|
||||
|
||||
@@ -106,12 +106,12 @@ export const createMainWindow = async (database: Database) => {
|
||||
systemLocale: app.getLocale(),
|
||||
}
|
||||
|
||||
mainWindow.webContents.send("initial-setup", initialSetupEventMessage)
|
||||
|
||||
ipcMain.once("initial-setup-done", () => {
|
||||
debug("initial setup done")
|
||||
mainWindow?.show()
|
||||
})
|
||||
|
||||
mainWindow.webContents.send("initial-setup", initialSetupEventMessage)
|
||||
} else {
|
||||
mainWindow.focus()
|
||||
}
|
||||
|
||||
+6
-6
@@ -44,13 +44,13 @@ export const DerivedCharacteristicsListItem: FC<Props> = props => {
|
||||
const handleAddMaxEnergyPoint = useCallback(() => {
|
||||
switch (id) {
|
||||
case DCId.LifePoints:
|
||||
dispatch(incrementLifePoints)
|
||||
dispatch(incrementLifePoints())
|
||||
break
|
||||
case DCId.ArcaneEnergy:
|
||||
dispatch(incrementArcaneEnergy)
|
||||
dispatch(incrementArcaneEnergy())
|
||||
break
|
||||
case DCId.KarmaPoints:
|
||||
dispatch(incrementKarmaPoints)
|
||||
dispatch(incrementKarmaPoints())
|
||||
break
|
||||
default:
|
||||
break
|
||||
@@ -60,13 +60,13 @@ export const DerivedCharacteristicsListItem: FC<Props> = props => {
|
||||
const handleRemoveMaxEnergyPoint = useCallback(() => {
|
||||
switch (id) {
|
||||
case DCId.LifePoints:
|
||||
dispatch(decrementLifePoints)
|
||||
dispatch(decrementLifePoints())
|
||||
break
|
||||
case DCId.ArcaneEnergy:
|
||||
dispatch(decrementArcaneEnergy)
|
||||
dispatch(decrementArcaneEnergy())
|
||||
break
|
||||
case DCId.KarmaPoints:
|
||||
dispatch(decrementKarmaPoints)
|
||||
dispatch(decrementKarmaPoints())
|
||||
break
|
||||
default:
|
||||
break
|
||||
|
||||
+2
-2
@@ -124,10 +124,10 @@ export const DerivedCharacteristicsListItemPermanent: FC<Props> = props => {
|
||||
case DCId.LifePoints:
|
||||
break
|
||||
case DCId.ArcaneEnergy:
|
||||
dispatch(decrementArcaneEnergyBoughtBack)
|
||||
dispatch(decrementArcaneEnergyBoughtBack())
|
||||
break
|
||||
case DCId.KarmaPoints:
|
||||
dispatch(decrementKarmaPointsBoughtBack)
|
||||
dispatch(decrementKarmaPointsBoughtBack())
|
||||
break
|
||||
default:
|
||||
assertExhaustive(id)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { ActionCreatorWithPayload, AnyAction, Draft, createAction } from "@reduxjs/toolkit"
|
||||
import { ActionCreatorWithPayload, Draft, UnknownAction, createAction } from "@reduxjs/toolkit"
|
||||
import { ImprovementCost } from "../../shared/domain/adventurePoints/improvementCost.ts"
|
||||
import { cachedAdventurePointsForActivatable } from "../../shared/domain/adventurePoints/ratedEntry.ts"
|
||||
import { ActivatableRated, ActivatableRatedMap } from "../../shared/domain/rated/ratedEntry.ts"
|
||||
@@ -44,7 +44,7 @@ export type ActivatableRatedSlice<N extends string, E extends string> = {
|
||||
/**
|
||||
* The reducer that handles the actions.
|
||||
*/
|
||||
reducer: Reducer<CharacterState, AnyAction, [database: DatabaseState]>
|
||||
reducer: Reducer<CharacterState, UnknownAction, [database: DatabaseState]>
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { ActionCreatorWithPayload, AnyAction, Draft, createAction } from "@reduxjs/toolkit"
|
||||
import { ActionCreatorWithPayload, Draft, UnknownAction, createAction } from "@reduxjs/toolkit"
|
||||
import { ImprovementCost } from "../../shared/domain/adventurePoints/improvementCost.ts"
|
||||
import { cachedAdventurePointsForActivatableWithEnhancements } from "../../shared/domain/adventurePoints/ratedEntry.ts"
|
||||
import { RegistrationMethod } from "../../shared/domain/dependencies/registrationHelpers.ts"
|
||||
@@ -48,7 +48,7 @@ export type ActivatableRatedWithEnhancementsSlice<N extends string, E extends st
|
||||
/**
|
||||
* The reducer that handles the actions.
|
||||
*/
|
||||
reducer: Reducer<CharacterState, AnyAction, [database: DatabaseState]>
|
||||
reducer: Reducer<CharacterState, UnknownAction, [database: DatabaseState]>
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { ActionCreatorWithPayload, AnyAction, Draft, createAction } from "@reduxjs/toolkit"
|
||||
import { ActionCreatorWithPayload, Draft, UnknownAction, createAction } from "@reduxjs/toolkit"
|
||||
import { AdventurePointsValue } from "optolith-database-schema/types/_Activatable"
|
||||
import { ActivatableIdentifier } from "optolith-database-schema/types/_IdentifierGroup"
|
||||
import { getCost } from "../../shared/domain/activatable/activatableActive.ts"
|
||||
@@ -51,7 +51,7 @@ export type ActivatableSlice<N extends string, E extends string> = {
|
||||
/**
|
||||
* The reducer that handles the actions.
|
||||
*/
|
||||
reducer: DraftReducer<CharacterState, AnyAction, [database: DatabaseState]>
|
||||
reducer: DraftReducer<CharacterState, UnknownAction, [database: DatabaseState]>
|
||||
}
|
||||
|
||||
const tagToNamespace = {
|
||||
@@ -219,7 +219,7 @@ export const createActivatableSlice = <
|
||||
.map(x => x.id),
|
||||
})
|
||||
|
||||
const reducer: DraftReducer<CharacterState, AnyAction, [database: DatabaseState]> = (
|
||||
const reducer: DraftReducer<CharacterState, UnknownAction, [database: DatabaseState]> = (
|
||||
state,
|
||||
action,
|
||||
database,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { AnyAction, createAction } from "@reduxjs/toolkit"
|
||||
import { UnknownAction, createAction } from "@reduxjs/toolkit"
|
||||
import { createDynamicActivatable } from "../../shared/domain/activatable/activatableEntry.ts"
|
||||
import { Character } from "../../shared/domain/character.ts"
|
||||
import {
|
||||
@@ -1139,7 +1139,7 @@ const generalCharacterReducer: DraftReducer<CharacterState> = (state, action) =>
|
||||
*/
|
||||
export const characterReducer = reduceDraftReducers<
|
||||
CharacterState,
|
||||
AnyAction,
|
||||
UnknownAction,
|
||||
[database: DatabaseState]
|
||||
>(
|
||||
generalCharacterReducer,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { ActionCreatorWithPayload, AnyAction, Draft, createAction } from "@reduxjs/toolkit"
|
||||
import { ActionCreatorWithPayload, Draft, UnknownAction, createAction } from "@reduxjs/toolkit"
|
||||
import { ImprovementCost } from "../../shared/domain/adventurePoints/improvementCost.ts"
|
||||
import { cachedAdventurePoints } from "../../shared/domain/adventurePoints/ratedEntry.ts"
|
||||
import { Rated, RatedMap } from "../../shared/domain/rated/ratedEntry.ts"
|
||||
@@ -33,7 +33,7 @@ export type RatedSlice<N extends string, E extends string> = {
|
||||
/**
|
||||
* The reducer that handles the actions.
|
||||
*/
|
||||
reducer: DraftReducer<CharacterState, AnyAction, [database: DatabaseState]>
|
||||
reducer: DraftReducer<CharacterState, UnknownAction, [database: DatabaseState]>
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -68,7 +68,7 @@ export const createRatedSlice = <N extends string, E extends string>(config: {
|
||||
`${config.namespace}/decrement${config.entityName}`,
|
||||
)
|
||||
|
||||
const reducer: DraftReducer<CharacterState, AnyAction, [database: DatabaseState]> = (
|
||||
const reducer: DraftReducer<CharacterState, UnknownAction, [database: DatabaseState]> = (
|
||||
state,
|
||||
action,
|
||||
database,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { ActionCreatorWithPayload, AnyAction, Draft, createAction } from "@reduxjs/toolkit"
|
||||
import { ActionCreatorWithPayload, Draft, UnknownAction, createAction } from "@reduxjs/toolkit"
|
||||
import { TinyActivatableMap } from "../../shared/domain/activatable/activatableEntry.ts"
|
||||
import { Reducer, createImmerReducer } from "../../shared/utils/redux.ts"
|
||||
import { CharacterState } from "./characterSlice.ts"
|
||||
@@ -25,7 +25,7 @@ export type TinyActivatableSlice<N extends string, E extends string> = {
|
||||
/**
|
||||
* The reducer that handles the actions.
|
||||
*/
|
||||
reducer: Reducer<CharacterState, AnyAction>
|
||||
reducer: Reducer<CharacterState, UnknownAction>
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { FC, useCallback, useEffect } from "react"
|
||||
import { addKeybinding, removeKeybinding } from "../../../App/Utilities/Keybindings.ts"
|
||||
import { addKeybinding, removeKeybinding } from "../../utils/keybindings.ts"
|
||||
import { Dialog } from "../dialog/Dialog.tsx"
|
||||
import { InputKeyEvent, TextField } from "../textField/TextField.tsx"
|
||||
|
||||
|
||||
@@ -358,6 +358,8 @@ ul.list-wrapper {
|
||||
.custom-cost {
|
||||
position: relative;
|
||||
|
||||
--distance: -1px;
|
||||
|
||||
&::after,
|
||||
&::before {
|
||||
content: "";
|
||||
@@ -368,8 +370,6 @@ ul.list-wrapper {
|
||||
border-color: var(--accent-color);
|
||||
}
|
||||
|
||||
--distance: -1px;
|
||||
|
||||
&::after {
|
||||
bottom: var(--distance);
|
||||
right: var(--distance);
|
||||
|
||||
@@ -8,11 +8,11 @@
|
||||
-webkit-app-region: drag;
|
||||
padding: 1px 1px 0;
|
||||
|
||||
--windows-titlebar-close: #e81123;
|
||||
|
||||
&.empty {
|
||||
height: 16px;
|
||||
}
|
||||
|
||||
--windows-titlebar-close: #e81123;
|
||||
}
|
||||
|
||||
:root.blurred .titlebar-inner {
|
||||
|
||||
@@ -50,12 +50,12 @@ a {
|
||||
}
|
||||
|
||||
p {
|
||||
margin: 10px 0 0;
|
||||
|
||||
&:first-child {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
margin: 10px 0 0;
|
||||
|
||||
&.featured {
|
||||
font-weight: 500;
|
||||
color: var(--headings-color);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Action, AnyAction, OutputSelector, createSelector } from "@reduxjs/toolkit"
|
||||
import { Action, OutputSelector, UnknownAction, createSelector } from "@reduxjs/toolkit"
|
||||
import { Draft, isDraft, nothing, produce } from "immer"
|
||||
|
||||
type Indexed = { [key: string | number]: unknown }
|
||||
@@ -13,15 +13,15 @@ type Indexed = { [key: string | number]: unknown }
|
||||
export const createPropertySelector = <S, O extends Indexed, K extends keyof O>(
|
||||
selector: (state: S) => O | undefined,
|
||||
property: K,
|
||||
): OutputSelector<[typeof selector], O[K] | undefined, (obj: O) => O[K] | undefined> =>
|
||||
createSelector(selector, obj => obj?.[property])
|
||||
): OutputSelector<[typeof selector], O[K] | undefined> =>
|
||||
createSelector(selector, obj => (obj as O | undefined)?.[property])
|
||||
|
||||
/**
|
||||
* A reducer type with possible additional parameters.
|
||||
*/
|
||||
export type Reducer<
|
||||
S,
|
||||
A extends Action = AnyAction,
|
||||
A extends Action = UnknownAction,
|
||||
P extends unknown[] = [],
|
||||
IS extends S | undefined = S,
|
||||
> = (state: IS, action: A, ...additionalParams: P) => S
|
||||
@@ -45,7 +45,7 @@ const ensureDraftState = <S>(
|
||||
* state.
|
||||
*/
|
||||
export const reduceReducers =
|
||||
<S, A extends Action = AnyAction, P extends unknown[] = [], IS extends S | undefined = S>(
|
||||
<S, A extends Action = UnknownAction, P extends unknown[] = [], IS extends S | undefined = S>(
|
||||
initialReducer: Reducer<S, A, P, IS>,
|
||||
...reducers: Reducer<S, A, P>[]
|
||||
): Reducer<S, A, P, IS> =>
|
||||
@@ -58,7 +58,7 @@ export const reduceReducers =
|
||||
/**
|
||||
* A reducer type with possible additional parameters that uses Immer.
|
||||
*/
|
||||
export type DraftReducer<S, A extends Action = AnyAction, P extends unknown[] = []> = (
|
||||
export type DraftReducer<S, A extends Action = UnknownAction, P extends unknown[] = []> = (
|
||||
state: Draft<S>,
|
||||
action: A,
|
||||
...additionalParams: P
|
||||
@@ -68,7 +68,7 @@ export type DraftReducer<S, A extends Action = AnyAction, P extends unknown[] =
|
||||
* Chains multiple draft reducers together.
|
||||
*/
|
||||
export const reduceDraftReducers =
|
||||
<S, A extends Action = AnyAction, P extends unknown[] = []>(
|
||||
<S, A extends Action = UnknownAction, P extends unknown[] = []>(
|
||||
...reducers: DraftReducer<S, A, P>[]
|
||||
): DraftReducer<S, A, P> =>
|
||||
(state, action, ...additionalParams) => {
|
||||
@@ -89,7 +89,7 @@ type ValidReducerReturnType<State> =
|
||||
* @returns The enhanced reducing function.
|
||||
*/
|
||||
export const createImmerReducer =
|
||||
<S, A extends Action = AnyAction, P extends unknown[] = []>(
|
||||
<S, A extends Action = UnknownAction, P extends unknown[] = []>(
|
||||
reducer: (
|
||||
state: Draft<S>,
|
||||
action: A,
|
||||
|
||||
Reference in New Issue
Block a user