Skip to content

Commit

Permalink
Release 2.0.105-b20
Browse files Browse the repository at this point in the history
  • Loading branch information
YeonV committed Dec 15, 2024
1 parent 99f7f63 commit 99df376
Show file tree
Hide file tree
Showing 8 changed files with 44 additions and 34 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ledfx",
"version": "2.0.105-b19",
"version": "2.0.105-b20",
"description": "LedFx v2 - BladeMOD!",
"author": "YeonV aka Blade",
"private": true,
Expand Down
12 changes: 6 additions & 6 deletions src/app/app/handlers.mts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export const handlers = async (
wind.webContents.send('fromMain', ['platform', process.platform])
break
case 'get-core-params':
if (isCC) {
if (isCC()) {
wind.webContents.send('fromMain', [
'coreParams',
coreParams[process.platform]
Expand All @@ -57,12 +57,12 @@ export const handlers = async (
}
break
case 'start-core':
if (isCC) {
if (isCC()) {
startInstance(wind, parameters.instance, subprocesses)
}
break
case 'start-core-instance':
if (isCC) {
if (isCC()) {
startInstance(
wind,
parameters.instance,
Expand All @@ -72,12 +72,12 @@ export const handlers = async (
}
break
case 'stop-core-instance':
if (isCC) {
if (isCC()) {
stopInstance(wind, parameters.instance, subprocesses)
}
break
case 'delete-core-instance':
if (isCC) {
if (isCC()) {
Object.entries(subprocesses).forEach(([name, subpy]) => {
if (name === parameters.instance) {
subpy.kill()
Expand All @@ -93,7 +93,7 @@ export const handlers = async (
}
break
case 'delete-core-params':
if (isCC) {
if (isCC()) {
store.set('coreParams', defaultCoreParams)
coreParams.darwin = defaultCoreParams.darwin
coreParams.win32 = defaultCoreParams.win32
Expand Down
30 changes: 19 additions & 11 deletions src/app/app/instances.mts
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,19 @@ export function stopInstance(
if (subprocesses[name]) {
subprocesses[name].running = false
sendStatus(wind, subprocesses, false, name)
subprocesses[name].kill()
try {
subprocesses[name].kill()
} catch (error) {
console.error(`Failed to kill subprocess ${name}:`, error)
}
}
}

export function startInstance(
wind: BrowserWindow,
name: string,
subprocesses: Subprocesses,
port: string = '8889'
port: string = '8888'
) {
try {
const subpy = startCore(wind, process.platform as IPlatform, name, port)
Expand All @@ -72,16 +76,20 @@ export function startInstance(
if (subprocesses[name]) {
subprocesses[name].running = false
}
if (wind && wind.webContents && !wind.isDestroyed() && subprocesses) {
// `subprocesses` is defined, proceed with calling `sendStatus`
try {
sendStatus(wind, subprocesses, false, name)
} catch (error) {
console.error(error)
try {
if (wind && wind.webContents && !wind.isDestroyed() && subprocesses) {
// `subprocesses` is defined, proceed with calling `sendStatus`
try {
sendStatus(wind, subprocesses, false, name)
} catch (error) {
console.error(error)
}
} else {
// `subprocesses` is not defined, handle this case as needed
console.error('subprocesses is not defined')
}
} else {
// `subprocesses` is not defined, handle this case as needed
console.error('subprocesses is not defined')
} catch (error) {
console.error('Error accessing window or subprocesses:', error)
}
})
subpy.on('error', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/app/app/utils/corePath.mts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const __dirname = path.dirname(__filename)
const corePath = (file: string) =>
path.join(
path.dirname(__dirname),
isDev ? '../extraResources' : '../../extraResources',
isDev ? '../../extraResources' : '../../../extraResources',
file
)

Expand Down
9 changes: 6 additions & 3 deletions src/app/app/utils/isCC.mts
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
/* eslint-disable prettier/prettier */
import fs from 'fs'
import corePath from './corePath.mjs'
import coreFile from './coreFile.mjs'

export const isCC = fs.existsSync(
corePath(coreFile[process.platform as 'darwin' | 'linux' | 'win32'])
)
export const isCC = () => {
return fs.existsSync(
corePath(coreFile[process.platform as 'darwin' | 'linux' | 'win32'])
)
}

export default isCC
2 changes: 1 addition & 1 deletion src/app/app/utils/startCore.mts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ function startCore(
wind: BrowserWindow,
platform: 'darwin' | 'linux' | 'win32',
instance = 'instance1',
port = '8889'
port = '8888'
) {
let subpy: ChildProcessWithoutNullStreams | null = null

Expand Down
7 changes: 3 additions & 4 deletions src/app/electron.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,7 @@ const ready = () =>
}
nativeTheme.themeSource = 'dark'
const thePath = process.env.PORTABLE_EXECUTABLE_DIR || path.resolve('.')

wind = isCC
wind = isCC()
? createWindow(win, { additionalArguments: ['integratedCore'] })
: createWindow(win)

Expand All @@ -65,8 +64,8 @@ const ready = () =>
}
return { action: 'allow' }
})
if (isCC) startInstance(wind, 'instance1', subprocesses)
createTray(isCC, wind, thePath, __dirname)
if (isCC()) startInstance(wind, 'instance1', subprocesses)
createTray(isCC(), wind, thePath, __dirname)
}

ipcMain.on(
Expand Down
14 changes: 7 additions & 7 deletions src/components/Dialogs/Instances.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ const Instances = ({
}
aria-label="delete"
onClick={(e) => {
handleStartCore(e, newPort || parseInt(port, 10) || 8889)
handleStartCore(e, newPort || parseInt(port, 10) || 8888)
}}
>
<PlayArrow />
Expand All @@ -242,7 +242,7 @@ const Instances = ({
}
aria-label="stop"
onClick={(e) => {
handleStopCore(e, newPort || parseInt(port, 10) || 8889)
handleStopCore(e, newPort || parseInt(port, 10) || 8888)
}}
>
<Stop />
Expand Down Expand Up @@ -313,7 +313,7 @@ const Instances = ({
handleDelete(
e,
parseInt(`${port}` || portRef.current?.value || '', 10) ||
8889
8888
)
}
/>
Expand All @@ -337,7 +337,7 @@ const Instances = ({
size="small"
aria-label="delete"
onClick={(e) => {
handleStartCore(e, newPort || parseInt(port, 10) || 8889)
handleStartCore(e, newPort || parseInt(port, 10) || 8888)
}}
>
<PlayArrow />
Expand All @@ -347,7 +347,7 @@ const Instances = ({
size="small"
aria-label="stop"
onClick={(e) => {
handleStopCore(e, newPort || parseInt(port, 10) || 8889)
handleStopCore(e, newPort || parseInt(port, 10) || 8888)
}}
>
<Stop />
Expand Down Expand Up @@ -434,7 +434,7 @@ const Instances = ({
? parseInt(portRef.current?.value, 10)
: newPort) ||
parseInt(port, 10) ||
8889
8888
)
if (portRef.current?.value) {
portRef.current.value = `${parseInt(portRef.current.value, 10) + 1}`
Expand Down Expand Up @@ -462,7 +462,7 @@ const Instances = ({
onConfirm={(e) =>
handleDelete(
e,
parseInt(`${port}` || portRef.current?.value || '', 10) || 8889
parseInt(`${port}` || portRef.current?.value || '', 10) || 8888
)
}
/> */}
Expand Down

0 comments on commit 99df376

Please sign in to comment.