Skip to content

Commit fc79d84

Browse files
authored
[TECH] Upgrade Electron and other Dev Dependencies (#1013)
* tech: updated dev dependencies part1 * i18n: update parser settings * husky: updated scripts * tech: upgrade dev deps part 2 * chore: lint * Revert "i18n: update parser settings" This reverts commit 6a3c451. * i18n: updated parser config * revert: upgrade typescript * chore: fix TS version until further upgrade * fix: fix all remaining typescript errors * chore: unused typings * chore: re-add proxy option to achievementState * chore: yarn.lock and fixed ts version * tech: update types packages * tech: upgrade electron to v32 * fix: windows build * chore: downgrade hp-ui * fix: codecheck again * chore: remove proxy from makeautoObservable --------- Co-authored-by: Flavio F Lima <flavioislima@users.noreply.github.com>
1 parent 0ed2e85 commit fc79d84

File tree

19 files changed

+14243
-14716
lines changed

19 files changed

+14243
-14716
lines changed

.husky/post-checkout

-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
#!/bin/bash
21
yarn setup

.husky/post-merge

-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
#!/bin/bash
21
yarn setup

.husky/pre-commit

-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
#!/bin/bash
21
#yarn lint-fix

.husky/pre-push

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
#!/bin/bash
2-
yarn codecheck && yarn lint
1+
yarn codecheck && yarn lint && yarn i18n --fail-on-update

i18next-parser.config.js

+17-7
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,18 @@ module.exports = {
1919
defaultNamespace: 'translation',
2020
// Default namespace used in your i18next config
2121

22-
defaultValue: '',
22+
defaultValue: null,
2323
// Default value to give to empty keys
2424

2525
failOnWarnings: false,
2626
// Exit with an exit code of 1 on warnings
2727

28+
// If you wish to customize options in internally used i18next instance, you can define an object with any
29+
// configuration property supported by i18next (https://www.i18next.com/overview/configuration-options).
30+
// { compatibilityJSON: 'v3' } can be used to generate v3 compatible plurals.
31+
// settings 'v3' since Weblate is also configured for v3 compatibility
32+
i18nextOptions: { compatibilityJSON: 'v3' },
33+
2834
indentation: 4,
2935
// Indentation of the catalog files
3036

@@ -47,10 +53,11 @@ module.exports = {
4753
attr: 'i18nKey', // Attribute for the keys
4854
lexer: 'JsxLexer'
4955
}
50-
]
56+
],
57+
default: ['JavascriptLexer']
5158
},
5259

53-
lineEnding: 'auto',
60+
lineEnding: 'match',
5461
// Control the line ending. See options at https://github.com/ryanve/eol
5562

5663
locales: ['en'],
@@ -65,16 +72,19 @@ module.exports = {
6572
// Supports JSON (.json) and YAML (.yml) file formats
6673
// Where to write the locale files relative to process.cwd()
6774

75+
// the problem with that is that we need all keys to have a default value otherwise they will be removed
76+
// resetDefaultValueLocale: 'en',
77+
// The locale to compare with default values to determine whether a default value has been changed.
78+
// If this is set and a default value differs from a translation in the specified locale, all entries
79+
// for that key across locales are reset to the default value, and existing translations are moved to
80+
// the `_old` file.
81+
6882
skipDefaultValues: false,
6983
// Whether to ignore default values.
7084

7185
sort: true,
7286
// Whether or not to sort the catalog
7387

74-
useKeysAsDefaultValue: false,
75-
// Whether to use the keys as the default value; ex. "Hello": "Hello", "World": "World"
76-
// This option takes precedence over the `defaultValue` and `skipDefaultValues` options
77-
7888
verbose: true
7989
// Display info about the parsing including some stat
8090
}

package.json

+37-36
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@
169169
"@fortawesome/react-fontawesome": "^0.1.18",
170170
"@hyperplay/chains": "^0.3.0",
171171
"@hyperplay/check-disk-space": "^3.5.2",
172-
"@hyperplay/ui": "^1.7.6",
172+
"@hyperplay/ui": "1.7.6",
173173
"@hyperplay/utils": "^0.0.16",
174174
"@mantine/carousel": "^7.5.1",
175175
"@mantine/core": "^7.5.1",
@@ -204,7 +204,7 @@
204204
"crc": "^4.1.1",
205205
"discord-rich-presence-typescript": "^0.0.8",
206206
"electron-store": "^8.0.1",
207-
"electron-updater": "^5.0.1",
207+
"electron-updater": "^6.2.1",
208208
"embla-carousel-autoplay": ">=7.0.0",
209209
"embla-carousel-react": ">=7.0.0",
210210
"ethers": "^6.12.1",
@@ -308,55 +308,54 @@
308308
]
309309
},
310310
"devDependencies": {
311-
"@babel/plugin-transform-arrow-functions": "^7.22.5",
312-
"@lavamoat/allow-scripts": "^3.0.2",
313-
"@lavamoat/preinstall-always-fail": "^2.0.0",
314-
"@playwright/test": "^1.43.1",
315-
"@testing-library/dom": "^7.31.0",
316-
"@testing-library/jest-dom": "^6.2.0",
317-
"@testing-library/react": "^14.0.0",
318-
"@testing-library/user-event": "^14.1.1",
319-
"@types/chrome": "^0.0.231",
311+
"@babel/plugin-transform-arrow-functions": "^7.24.7",
312+
"@lavamoat/allow-scripts": "^3.2.0",
313+
"@lavamoat/preinstall-always-fail": "^2.1.0",
314+
"@playwright/test": "^1.46.0",
315+
"@testing-library/dom": "^7.31.2",
316+
"@testing-library/jest-dom": "^6.4.8",
317+
"@testing-library/react": "^14.3.1",
318+
"@testing-library/user-event": "^14.5.2",
319+
"@types/chrome": "^0.0.269",
320320
"@types/classnames": "^2.3.1",
321-
"@types/i18next-fs-backend": "^1.1.2",
322-
"@types/ini": "^1.3.31",
323-
"@types/jest": "^29.5.11",
324-
"@types/node": "^17.0.25",
325-
"@types/plist": "^3.0.2",
321+
"@types/i18next-fs-backend": "^1.1.5",
322+
"@types/ini": "^1.3.34",
323+
"@types/jest": "^29.5.12",
324+
"@types/node": "^20.16.2",
325+
"@types/plist": "^3.0.5",
326326
"@types/react": "^18.0.24",
327327
"@types/react-dom": "^18.0.8",
328328
"@types/react-router-dom": "^5.3.3",
329-
"@types/supertest": "^2.0.12",
330-
"@types/tmp": "^0.2.3",
331-
"@types/ws": "^8.5.5",
332-
"@typescript-eslint/eslint-plugin": "^6.13.2",
333-
"@typescript-eslint/parser": "^6.13.2",
334-
"@valist/sdk": "^2.9.5",
335-
"@vitejs/plugin-react": "^2.2.0",
329+
"@types/tmp": "^0.2.6",
330+
"@types/ws": "^8.5.12",
331+
"@typescript-eslint/eslint-plugin": "^6.21.0",
332+
"@typescript-eslint/parser": "^6.21.0",
333+
"@valist/sdk": "^2.9.17",
334+
"@vitejs/plugin-react": "^4.3.1",
336335
"cross-env": "^7.0.3",
337-
"electron": "^28.0.0",
336+
"electron": "^32.0.1",
338337
"electron-builder": "^24.13.3",
339338
"electron-playwright-helpers": "^1.7.1",
340-
"electron-vite": "^2.1.0",
339+
"electron-vite": "^2.3.0",
341340
"eslint": "^8.13.0",
342341
"eslint-config-prettier": "^8.5.0",
343342
"eslint-plugin-import": "^2.26.0",
344343
"eslint-plugin-react": "^7.29.4",
345-
"fast-xml-parser": "^4.3.5",
346-
"husky": "^7.0.4",
347-
"i18next-parser": "^6.3.0",
344+
"fast-xml-parser": "^4.4.1",
345+
"husky": "^9.1.4",
346+
"i18next-parser": "^9.0.1",
348347
"jest": "^29.7.0",
349348
"pkg": "^5.8.1",
350-
"playwright": "^1.43.1",
351-
"prettier": "^2.6.2",
352-
"pretty-quick": "^3.1.3",
349+
"playwright": "^1.46.0",
350+
"prettier": "^2.8.8",
351+
"pretty-quick": "^4.0.0",
352+
"react-markdown": "^9.0.1",
353353
"sass": "^1.55.0",
354-
"supertest": "^6.2.4",
355-
"tmp": "^0.2.1",
354+
"tmp": "^0.2.3",
356355
"ts-jest": "^29.1.1",
357356
"type-fest": "^3.2.0",
358-
"typescript": "^5.3.2",
359-
"vite": "^5.2.8",
357+
"typescript": "5.3.3",
358+
"vite": "^5.4.0",
360359
"vite-plugin-svgr": "^2.2.2"
361360
},
362361
"optionalDependencies": {
@@ -394,7 +393,9 @@
394393
"viem>ws>bufferutil": true,
395394
"viem>ws>utf-8-validate": true,
396395
"@hyperplay/extension-importer>classic-level": true,
397-
"classic-level": false
396+
"classic-level": false,
397+
"i18next-parser>esbuild": false,
398+
"wagmi>@wagmi/connectors>@metamask/sdk>@metamask/sdk-communication-layer>utf-8-validate": false
398399
}
399400
}
400401
}

src/backend/config.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@ class GlobalConfigV0 extends GlobalConfig {
342342
} as AppSettings
343343
}
344344

345-
public setSetting(key: string, value: unknown) {
345+
public setSetting(key: keyof AppSettings, value: never) {
346346
const config = this.getSettings()
347347
const configStoreSettings = configStore.get_nodefault('settings') || config
348348
configStore.set('settings', { ...configStoreSettings, [key]: value })

src/backend/main.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ import './wiki_game_info/ipc_handler'
167167
import './recent_games/ipc_handler'
168168
import './metrics/ipc_handler'
169169
import 'backend/extension/provider'
170-
import 'backend/proxy/ipcHandlers.ts'
170+
import 'backend/proxy/ipcHandlers'
171171

172172
import './ipcHandlers'
173173
import './ipcHandlers/checkDiskSpace'
@@ -1137,7 +1137,7 @@ ipcMain.handle('refreshLibrary', async (e, library?) => {
11371137
} else {
11381138
const allRefreshPromises = []
11391139
for (const runner_i in libraryManagerMap) {
1140-
allRefreshPromises.push(libraryManagerMap[runner_i].refresh())
1140+
allRefreshPromises.push(libraryManagerMap[runner_i as Runner].refresh())
11411141
}
11421142
await Promise.allSettled(allRefreshPromises)
11431143
}

src/backend/storeManagers/gog/library.ts

+6-4
Original file line numberDiff line numberDiff line change
@@ -244,9 +244,11 @@ export async function refresh(): Promise<ExecResult> {
244244
for (const chunk of chunks) {
245245
const settled = await Promise.allSettled(chunk)
246246
const fulfilled = settled
247-
.filter((promise) => promise.status === 'fulfilled')
248-
//@ts-expect-error Typescript is confused about this filter statement, it's correct however
249-
.map((promise: PromiseFulfilledResult<GameInfo>) => promise.value)
247+
.filter(
248+
(promise): promise is PromiseFulfilledResult<GameInfo> =>
249+
promise.status === 'fulfilled'
250+
)
251+
.map((promise) => promise.value)
250252

251253
fulfilled.forEach((data: GameInfo) => {
252254
if (data?.app_name) {
@@ -924,7 +926,7 @@ export async function getProductApi(
924926
url.searchParams.set('expand', expand.join(','))
925927
}
926928

927-
const headers = {}
929+
const headers: Record<string, string> = {}
928930
if (access_token) {
929931
headers['Authorization'] = `Bearer ${access_token}`
930932
}

src/backend/storeManagers/hyperplay/games.ts

+15-4
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ import {
1010
ChannelReleaseMeta,
1111
SiweValues,
1212
UpdateArgs,
13-
WineCommandArgs
13+
WineCommandArgs,
14+
Runner
1415
} from '../../../common/types'
1516
import { hpLibraryStore } from './electronStore'
1617
import { sendFrontendMessage, getMainWindow } from 'backend/main_window'
@@ -254,8 +255,18 @@ export async function importGame(
254255
const channel = gameInfo.channels![
255256
installInfo.manifest.channelName!
256257
] as Channel
257-
const mainExe =
258-
channel.release_meta.platforms[installInfo.manifest.platform].executable
258+
// Accessing the platform data with type assertion
259+
const platformKey = installInfo.manifest
260+
.platform as keyof PlatformsMetaInterface
261+
const platformData = channel.release_meta.platforms[platformKey]
262+
if (!platformData || !platformData.executable) {
263+
logError(
264+
`Platform data not found for ${appName} in importGame`,
265+
LogPrefix.HyperPlay
266+
)
267+
return { stderr: '', stdout: '' }
268+
}
269+
const mainExe = platformData.executable
259270
const executable = path.join(pathName, mainExe)
260271

261272
if (!existsSync(executable)) {
@@ -295,7 +306,7 @@ export async function importGame(
295306
}
296307

297308
export async function runWineCommandOnGame(
298-
runner: string,
309+
runner: Runner,
299310
appName: string,
300311
{ commandParts, wait = false, protonVerb, startFolder }: WineCommandArgs
301312
): Promise<ExecResult> {

src/common/typedefs/ipcBridge.d.ts

+1
Original file line numberDiff line numberDiff line change
@@ -456,6 +456,7 @@ interface AsyncIPCFunctions extends HyperPlayAsyncIPCFunctions {
456456
appName: string
457457
) => Promise<number | undefined>
458458
pauseCurrentDownload: () => Promise<void>
459+
getQuestsForGame: (projectId: string) => Promise<Quest[]>
459460
}
460461

461462
// This is quite ugly & throws a lot of errors in a regular .ts file

src/frontend/SentryHandler/index.tsx

+1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ const SentryHandler = () => {
1919
? devSentryDsn
2020
: prodSentryDsn
2121
},
22+
// @ts-expect-error - not sure why is this failling
2223
reactInit
2324
)
2425
setInitialized(true)

src/frontend/components/UI/ChannelNameSelection/index.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export default function ChannelNameSelection({
2626
>
2727
{gameInfo?.channels !== undefined
2828
? Object.keys(gameInfo.channels).map((p, i) => {
29-
if (!gameInfo.channels) return <div>error</div>
29+
if (!gameInfo.channels) return <div key={p}>error</div>
3030
const channel_i = gameInfo.channels[p]
3131
return (
3232
<option value={p} key={i}>

src/frontend/components/UI/QuestsViewer/components/QuestDetailsWrapper/index.tsx

-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@ async function getRewardClaimGasEstimation(reward: Reward) {
6868
const viemChain = parseChainMetadataToViemChain(chainMetadata)
6969

7070
const publicClient = createPublicClient({
71-
// @ts-expect-error: chain types are valid
7271
chain: viemChain,
7372
transport: http()
7473
})

src/frontend/config.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,12 @@ import { Chain, hardhat, mainnet, polygon } from 'wagmi/chains'
33
import { chainMap, parseChainMetadataToViemChain } from '@hyperplay/chains'
44

55
let chainsToSupport: Chain[] = []
6-
const transports = {}
6+
const transports: { [key: number]: unknown } = {}
77

88
for (const chainId in chainMap) {
99
const chainMetadata = chainMap[chainId]
1010
try {
1111
const chain = parseChainMetadataToViemChain(chainMetadata)
12-
// @ts-expect-error: the function is valid, there is just a mismatch in the types due to different versions of viem
1312
chainsToSupport.push(chain)
1413
transports[chain.id] = http(chainMetadata.chain.rpc[0])
1514
// eslint-disable-next-line no-empty

src/frontend/screens/Library/index.tsx

+13-12
Original file line numberDiff line numberDiff line change
@@ -275,18 +275,19 @@ export default observer(function Library(): JSX.Element {
275275
/>
276276
)}
277277

278-
{libraryState.showFavourites && !libraryState.showFavouritesLibrary && (
279-
<>
280-
<h3 className={styles.libraryHeader}>
281-
{t('favourites', 'Favourites')}
282-
</h3>
283-
<GamesList
284-
library={libraryState.favourites}
285-
handleGameCardClick={handleModal}
286-
isFirstLane
287-
/>
288-
</>
289-
)}
278+
{libraryState.showFavourites &&
279+
!libraryState.showFavouritesLibrary && (
280+
<>
281+
<h3 className={styles.libraryHeader}>
282+
{t('favourites', 'Favourites')}
283+
</h3>
284+
<GamesList
285+
library={libraryState.favourites}
286+
handleGameCardClick={handleModal}
287+
isFirstLane
288+
/>
289+
</>
290+
)}
290291

291292
{libraryState.refreshing &&
292293
!libraryState.refreshingInTheBackground && (

src/frontend/state/AchievementState.ts

-1
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@ class AchievementState {
7777
{},
7878
{
7979
deep: true,
80-
proxy: false,
8180
name: 'AchievementState'
8281
}
8382
)

src/frontend/state/OverlayState.ts

-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ class OverlayState implements OverlayStateInterface {
2525
{},
2626
{
2727
deep: true,
28-
proxy: false,
2928
name: 'OverlayState'
3029
}
3130
)

0 commit comments

Comments
 (0)