4 Commits

Author SHA1 Message Date
3d7512ab79 add build commands 2024-01-09 13:38:48 +01:00
ad2b590281 feat: add logging 2024-01-09 11:51:26 +01:00
5fd5d68411 update packages 2024-01-08 15:32:56 +01:00
fb5383775b chore: update mdx-components 2024-01-08 11:58:04 +01:00
4 changed files with 245 additions and 2117 deletions

2323
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -15,19 +15,22 @@
"dev": "electron-vite dev",
"build": "npm run typecheck && electron-vite build",
"postinstall": "electron-builder install-app-deps",
"build:win": "npm run build && electron-builder --win --config",
"build:mac": "electron-vite build && electron-builder --mac --config",
"build:linux": "electron-vite build && electron-builder --linux --config"
"build:win": "electron-builder --win --config --x64",
"build:mac": "electron-builder --mac --config --x64",
"build:mac:arm": "electron-builder --mac --config --arm64",
"build:linux": "electron-builder --linux --config --x64",
"build:all": "npm run build && npm run build:win && npm run build:mac && npm run build:mac:arm && npm run build:linux"
},
"dependencies": {
"@electron-toolkit/preload": "^2.0.0",
"@electron-toolkit/utils": "^2.0.1",
"@fontsource/roboto": "^5.0.8",
"@it-incubator/md-bundler": "0.0.10",
"@it-incubator/mdx-components": "0.0.8",
"@it-incubator/ui-kit": "0.2.20",
"@it-incubator/mdx-components": "0.0.11",
"@it-incubator/ui-kit": "0.2.24",
"builtin-modules": "^3.3.0",
"chokidar": "^3.5.3",
"electron-log": "^5.0.3",
"electron-store": "^8.1.0",
"electron-updater": "^6.1.4",
"esbuild": "^0.19.5",

View File

@@ -2,6 +2,7 @@ import fs from 'fs'
import { is } from '@electron-toolkit/utils'
import { BrowserWindow, app, ipcMain } from 'electron'
import log from 'electron-log/main'
import { bundleMdxAndSend } from './bundle-mdx-and-send'
import { handleAppReady } from './handlers/handle-app-ready'
@@ -10,6 +11,11 @@ import { prepareAndSendDir } from './prepare-and-send-dir'
import { setupWatcher } from './setup-watcher'
import { store } from './store'
// Optional, initialize the logger for any renderer process
log.initialize()
log.info('Log from the main process')
let mainWindow: BrowserWindow | null = null
function setMainWindow(win: BrowserWindow) {
@@ -89,9 +95,12 @@ ipcMain.on('open-file', (_event, filePath) => {
process
.on('unhandledRejection', (reason, p) => {
console.error(reason, 'Unhandled Rejection at Promise', p)
log.error('Unhandled Rejection at Promise', reason, p)
console.error('Unhandled Rejection at Promise', reason, p)
})
.on('uncaughtException', err => {
log.error('Uncaught Exception', err)
// https://github.com/paulmillr/chokidar/issues/566
// this has been open for over 7 years, still hasn't been fixed.
// for some reason it doesn't even go into the chokidar error handler, so had to do it here
@@ -107,3 +116,5 @@ process
process.exit(1)
}
})
log.errorHandler.startCatching()

View File

@@ -38,7 +38,7 @@ export const TableOfContents = ({ tocMap }: Props) => {
const headingsObserver = headingsObserverRef.current
setTimeout(() => {
document.querySelectorAll('article :is(h1,h2,h3)').forEach(h => headingsObserver.observe(h))
document.querySelectorAll('article :is(h2,h3,h4)').forEach(h => headingsObserver.observe(h))
}, 100)
return () => {
@@ -53,13 +53,22 @@ export const TableOfContents = ({ tocMap }: Props) => {
// Disconnect and reconnect the observer to refresh it
headingsObserver.disconnect()
setTimeout(() => {
document.querySelectorAll('article :is(h1,h2,h3)').forEach(h => headingsObserver.observe(h))
document.querySelectorAll('article :is(h2,h3,h4)').forEach(h => headingsObserver.observe(h))
}, 100)
}
}, [tocMap])
const onLinkClick = (e: MouseEvent<HTMLAnchorElement>) => {
setCurrentHeading(e.currentTarget.getAttribute('href')!.replace('#', ''))
if (headingsObserverRef.current) {
const headingsObserver = headingsObserverRef.current
// Disconnect and reconnect the observer to refresh it
headingsObserver.disconnect()
setTimeout(() => {
document.querySelectorAll('article :is(h2,h3,h4)').forEach(h => headingsObserver.observe(h))
}, 100)
}
}
return (