Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ jobs:
cache: npm
- name: Install dependencies
run: npm ci
- name: Typecheck
run: npm run typecheck
- name: Check
run: npm run check
- name: Test
run: npm test
- name: Build
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ resources/bin
csdn-blog.md
updater-server/.vercel
.env
.vitest/
12 changes: 8 additions & 4 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ map data providers, an AI globe assistant ("EOQ agent"), and teaching/drawing to

**Pinned versions — do not bump casually:**

- `vite@^7` — electron-vite@5 peer range tops out at vite 7.
- `typescript@5.9.x` — pinned TypeScript version (`tsconfig.node.json` + `tsconfig.web.json`).
- `vite-plus` — Vite+ provides Vite 8 through the npm alias for `vite` (`@voidzero-dev/vite-plus-core`). Keep the `devDependencies` alias and the `overrides` entry aligned when upgrading Vite+.
- `typescript@^7` — the native TypeScript compiler (`tsconfig.node.json` + `tsconfig.web.json`). TypeScript 7 has no stable JS API yet, so tests that compile or parse source import TypeScript 6 from `@typescript/typescript6`. Type checking runs in `npm run check` through Vite+, so don't call `tsc` from scripts: `@typescript/typescript6` also links a TypeScript 6 `tsc` into `node_modules/.bin`.
- `@base-ui/react@^1.9` + `tailwindcss@^4.3` + `lucide-react` — headless Base UI primitives wrapped in `src/renderer/src/components/ui/` following [DESIGN.md](./DESIGN.md) monochrome Light/Dark tokens. Do not reintroduce `antd` or `@ant-design/*`.
- Electron binaries must be installed manually with the npmmirror mirror:
`ELECTRON_MIRROR="https://npmmirror.com/mirrors/electron/" node node_modules/electron/install.js`
Expand Down Expand Up @@ -95,10 +95,14 @@ npm run dev # electron-vite dev server + app
npm run build # production build
npm run fetch:ffmpeg # pinned LGPL FFmpeg for Windows or Linux into resources/bin
npm run build:linux # AppImage + deb for Linux x64 and arm64
npm run typecheck # tsc (node) + tsc (web)
npm test # node:test unit tests (tests/*.test.mjs), run by CI
npm run check # vp check: lint and type checks (format is off for now), run by CI
npm test # Vitest unit tests through Vite+ (tests/*.test.mjs), run by CI
```

Vite+ config lives in `vite.config.mts`, on top of the `@liangmi/vp-config` preset. Rules that don't fit GuEarth are turned off there with a reason. Disable a rule inline only with `// oxlint-disable-next-line <rule> -- <reason>`. Import test APIs from `vite-plus/test`, not `vitest`.

Vitest uses native Node.js imports (`experimental.viteModuleRunner: false` in `vite.config.mts`), so the `module.registerHooks` fixtures in the tests can load React components and simulate filesystem failures.

## Docs

- https://ant.design/llms.txt
Expand Down
20 changes: 9 additions & 11 deletions electron.vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { cpSync, createReadStream, existsSync, statSync } from 'fs'
import { extname, join, resolve, sep } from 'path'
import { cpSync, createReadStream, existsSync, statSync } from 'node:fs'
import { extname, join, resolve, sep } from 'node:path'
import { defineConfig } from 'electron-vite'
import type { Connect, Plugin } from 'vite'
import react from '@vitejs/plugin-react'
Expand All @@ -22,8 +22,8 @@ const cesiumMimeTypes: Record<string, string> = {

const serveCesiumAsset: Connect.NextHandleFunction = (req, res, next) => {
const assetPath = resolve(cesiumBuild, `.${(req.url ?? '/').split('?')[0]}`)
if (!assetPath.startsWith(cesiumBuild + sep)) return next()
if (!existsSync(assetPath) || !statSync(assetPath).isFile()) return next()
if (!assetPath.startsWith(cesiumBuild + sep)) { next(); return;}
if (!existsSync(assetPath) || !statSync(assetPath).isFile()) { next(); return;}
res.setHeader('Content-Type', cesiumMimeTypes[extname(assetPath).toLowerCase()] ?? 'application/octet-stream')
res.setHeader('Cache-Control', 'no-cache')
createReadStream(assetPath).pipe(res)
Expand All @@ -37,7 +37,7 @@ function cesiumStaticPlugin(): Plugin {
},
writeBundle(options) {
const outDir = options.dir
if (!outDir) return
if (!outDir) {return}
for (const dir of cesiumDirs) {
cpSync(join(cesiumBuild, dir), join(outDir, 'cesium', dir), { recursive: true })
}
Expand All @@ -49,7 +49,7 @@ export default defineConfig({
main: {
build: {
externalizeDeps: false,
rollupOptions: {
rolldownOptions: {
external: ['koffi'],
input: {
index: resolve('src/main/index.ts'),
Expand All @@ -72,16 +72,14 @@ export default defineConfig({
},
plugins: [react(), tailwindcss(), cesiumStaticPlugin()],
build: {
rollupOptions: {
rolldownOptions: {
input: {
index: resolve('src/renderer/index.html'),
offscreen: resolve('src/renderer/offscreen.html')
},
output: {
manualChunks(id) {
const normalizedId = id.replaceAll('\\', '/')
if (normalizedId.includes('/node_modules/cesium/') || normalizedId.includes('/node_modules/@cesium/')) return 'cesium'
return undefined
codeSplitting: {
groups: [{ name: 'cesium', test: /[\\/]node_modules[\\/]@?cesium[\\/]/ }]
}
}
}
Expand Down
Loading