Skip to content

Commit

Permalink
add lines for debugging
Browse files Browse the repository at this point in the history
  • Loading branch information
koji committed Jan 10, 2024
1 parent 58074dc commit 7199feb
Show file tree
Hide file tree
Showing 3 changed files with 98 additions and 36 deletions.
9 changes: 9 additions & 0 deletions app-shell-odd/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,15 @@ let rendererLogger: Logger
app.prependOnceListener('ready', startUp)
if (config.devtools) app.once('ready', installDevtools)

ipcMain.handle('file_manage_process', (event, data) => {
log.info(`preload.js is loaded`)
const file_list = data.file_list

Check warning on line 58 in app-shell-odd/src/main.ts

View workflow job for this annotation

GitHub Actions / js checks

Variable name `file_list` must match one of the following formats: camelCase, PascalCase, UPPER_CASE
const folder_name = data.folder_name

Check warning on line 59 in app-shell-odd/src/main.ts

View workflow job for this annotation

GitHub Actions / js checks

Variable name `folder_name` must match one of the following formats: camelCase, PascalCase, UPPER_CASE

log.info(`list: ${file_list}`)

Check warning on line 61 in app-shell-odd/src/main.ts

View workflow job for this annotation

GitHub Actions / js checks

Invalid type "any" of template literal expression
log.info(`folder: ${folder_name}`)
})

app.once('window-all-closed', () => {
log.debug('all windows closed, quitting the app')
app.quit()
Expand Down
8 changes: 7 additions & 1 deletion app-shell-odd/src/preload.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
// preload script for renderer process
// defines subset of Electron API that renderer process is allowed to access
// for security reasons
import { ipcRenderer } from 'electron'
import { ipcRenderer, contextBridge } from 'electron'

global.APP_SHELL_REMOTE = { ipcRenderer }

contextBridge.exposeInMainWorld('electron', {
path: path,
file_manage_process: async (data: any) =>
await ipcRenderer.invoke('file_manage_process', data),
})
117 changes: 82 additions & 35 deletions app-shell-odd/src/ui.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,57 +51,104 @@ export function createUi(dispatch: Dispatch): BrowserWindow {
log.debug('Creating main window', { options: WINDOW_OPTS })
log.info('before ready-to-show')

const mainWindow = new BrowserWindow(WINDOW_OPTS).once(
'ready-to-show',
() => {
log.debug('Main window ready to show')
log.info('before show')
mainWindow.show()
log.info('after show')
process.env.NODE_ENV !== 'development' &&
waitForRobotServerAndShowMainWIndow(dispatch)
}
)
const mainWindow = new BrowserWindow(WINDOW_OPTS)
mainWindow.show()
mainWindow.once('ready-to-show', () => {
log.debug('Main window ready to show')
log.info('before show')
mainWindow.show()
log.info('after show')
process.env.NODE_ENV !== 'development' &&
waitForRobotServerAndShowMainWIndow(dispatch)
})
log.info('after ready-to-show')

// test
mainWindow.webContents.on('will-navigate', () => {
log.info('will-navigate')
})

mainWindow.webContents.on('did-fail-load', () => {
log.info('did-fail-load')
})

mainWindow.webContents.on('did-fail-load', () => {
log.info('did-fail-load')
})

mainWindow.webContents.on('dom-ready', () => {
log.info('dom-ready')
})

mainWindow.webContents.on('did-create-window', () => {
log.info('did-create-window')
})
const pollWCStatus = (): void => {
log.info(`isCrashed: ${mainWindow.webContents.isCrashed()}`)
log.info(`isLoading: ${mainWindow.webContents.isLoading()}`)
log.info(
`isLoadingMainFrame: ${mainWindow.webContents.isLoadingMainFrame()}`
)
log.info(
`isWaitingForResponse: ${mainWindow.webContents.isWaitingForResponse()}`
)
log.info(`isDestroyed: ${mainWindow.webContents.isDestroyed()}`)
log.info(`isPainting: ${mainWindow.webContents.isPainting()}`)
log.info(`isOffscreen: ${mainWindow.webContents.isOffscreen()}`)
log.info(`isFocused: ${mainWindow.webContents.isFocused()}`)
if (!mainWindow.webContents.isWaitingForResponse()) {
setTimeout(pollWCStatus, 5000)
} else {
setTimeout(pollWCStatus, 100)

Check failure on line 87 in app-shell-odd/src/ui.ts

View workflow job for this annotation

GitHub Actions / js checks

'pollWCStatus' is assigned a value but never used
}
}

mainWindow.webContents.on(
'did-fail-load',
(
event,
errorCode,
errorDescription,
validatedURL,
isMainFrame,
frameProcessId,
frameRoutingId
) => {
log.info('did-fail-load', {
event,
errorCode,
errorDescription,
validatedURL,
isMainFrame,
frameProcessId,
frameRoutingId,
})
log.info(`did-fail-provisional-load ${errorCode}
`)
log.info(`did-fail-provisional-load ${validatedURL}
`)
log.info(`did-fail-provisional-load ${errorDescription}
`)
}
)

mainWindow.webContents.on('unresponsive', () => {
log.info('unresponsive')
mainWindow.webContents.reload()
})
mainWindow.webContents.on(
'did-fail-provisional-load',
(
event,
errorCode,
errorDescription,
validatedURL
// isMainFrame,
// frameProcessId,
// frameRoutingId
) => {
log.info(`did-fail-provisional-load ${errorCode}
`)
log.info(`did-fail-provisional-load ${validatedURL}
`)
log.info(`did-fail-provisional-load ${errorDescription}
`)
}
)

mainWindow.webContents.on('did-attach-webview', () => {
log.info('did-attach-webview')
log.info(`did-attach-webview`)
})

log.info('isCrashed', mainWindow.webContents.isCrashed())
const testUrl = 'https://google.com'

log.info('mainWindow', mainWindow)
log.info(`mainWindow: ${JSON.stringify(mainWindow, null, 4)}`)

log.info(`Loading ${url}`)
log.info(`Loading ${testUrl}`)
// eslint-disable-next-line @typescript-eslint/no-floating-promises
mainWindow
.loadURL(url, { extraHeaders: 'pragma: no-cache\n' })
.loadURL(testUrl, { extraHeaders: 'pragma: no-cache\n' })
.then(() => log.info('loadURL is fine'))
.catch((e: any) => log.info('load url error', e))
// open new windows (<a target="_blank" ...) in browser windows
Expand Down

0 comments on commit 7199feb

Please sign in to comment.