docs: add discussion and认知修正 about gitea runner and sql.js migration

This commit is contained in:
2026-04-11 02:40:14 +08:00
parent 81f524bee1
commit 0170dedd0e
4 changed files with 97 additions and 3 deletions

View File

@@ -13,6 +13,7 @@
},
"devDependencies": {
"@types/bun": "latest",
"@types/node": "^25.6.0",
},
"peerDependencies": {
"typescript": "^5",
@@ -98,7 +99,7 @@
"@types/bun": ["@types/bun@1.2.20", "", { "dependencies": { "bun-types": "1.2.20" } }, "sha512-dX3RGzQ8+KgmMw7CsW4xT5ITBSCrSbfHc36SNT31EOUg/LA9JWq0VDdEXDRSe1InVWpd2yLUM1FUF/kEOyTzYA=="],
"@types/node": ["@types/node@24.3.0", "", { "dependencies": { "undici-types": "~7.10.0" } }, "sha512-aPTXCrfwnDLj4VvXrm+UUCQjNEvJgNA8s5F1cvwQU+3KNltTOkBm1j30uNLyqqPNe7gE3KFzImYoZEfLhp4Yow=="],
"@types/node": ["@types/node@25.6.0", "", { "dependencies": { "undici-types": "~7.19.0" } }, "sha512-+qIYRKdNYJwY3vRCZMdJbPLJAtGjQBudzZzdzwQYkEPQd+PJGixUL5QfvCLDaULoLv+RhT3LDkwEfKaAkgSmNQ=="],
"@types/react": ["@types/react@19.1.11", "", { "dependencies": { "csstype": "^3.0.2" } }, "sha512-lr3jdBw/BGj49Eps7EvqlUaoeA0xpj3pc0RoJkHpYaCHkVK7i28dKyImLQb3JVlqs3aYSXf7qYuWOW/fgZnTXQ=="],
@@ -212,7 +213,7 @@
"typescript": ["typescript@5.9.2", "", { "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" } }, "sha512-CWBzXQrc/qOkhidw1OzBTQuYRbfyxDXJMVJ1XNwUHGROVmuaeiEm3OslpZ1RV96d7SKKjZKrSJu3+t/xlw3R9A=="],
"undici-types": ["undici-types@7.10.0", "", {}, "sha512-t5Fy/nfn+14LuOc2KNYg75vZqClpAiqscVvMygNnlsHBFpSXdJaYtXMcdNLpl/Qvc3P2cB3s6lOV51nqsFq4ag=="],
"undici-types": ["undici-types@7.19.2", "", {}, "sha512-qYVnV5OEm2AW8cJMCpdV20CDyaN3g0AjDlOGf1OW4iaDEx8MwdtChUp4zu4H0VP3nDRF/8RKWH+IPp9uW0YGZg=="],
"utif2": ["utif2@4.1.0", "", { "dependencies": { "pako": "^1.0.11" } }, "sha512-+oknB9FHrJ7oW7A2WZYajOcv4FcDR4CfoGB0dPNfxbi4GO05RRnFmt5oa23+9w32EanrYcSJWspUiJkLMs+37w=="],
@@ -232,10 +233,14 @@
"@opentui/core/marked": ["marked@17.0.1", "", { "bin": { "marked": "bin/marked.js" } }, "sha512-boeBdiS0ghpWcSwoNm/jJBwdpFaMnZWRzjA6SkUMYb40SVaN1x7mmfGKp0jvexGcx+7y2La5zRZsYFZI6Qpypg=="],
"bun-types/@types/node": ["@types/node@24.3.0", "", { "dependencies": { "undici-types": "~7.10.0" } }, "sha512-aPTXCrfwnDLj4VvXrm+UUCQjNEvJgNA8s5F1cvwQU+3KNltTOkBm1j30uNLyqqPNe7gE3KFzImYoZEfLhp4Yow=="],
"image-q/@types/node": ["@types/node@16.9.1", "", {}, "sha512-QpLcX9ZSsq3YYUUnD3nFDY8H7wctAhQj/TFKL8Ya8v5fMm3CFXxo8zStsLAl780ltoYoo1WvKUVGBQK+1ifr7g=="],
"pixelmatch/pngjs": ["pngjs@6.0.0", "", {}, "sha512-TRzzuFRRmEoSW/p1KVAmiOgPco2Irlah+bGFCeNfJXxxYGwSw7YwAOAcd7X28K/m5bjBWKsC29KyoMfHbypayg=="],
"react-devtools-core/ws": ["ws@7.5.10", "", { "peerDependencies": { "bufferutil": "^4.0.1", "utf-8-validate": "^5.0.2" }, "optionalPeers": ["bufferutil", "utf-8-validate"] }, "sha512-+dbF1tHwZpXcbOJdVOkzLDxZP1ailvSxM6ZweXTegylPny803bFhA+vqBYw4s31NSAk4S2Qz+AKXK9a4wkdjcQ=="],
"bun-types/@types/node/undici-types": ["undici-types@7.10.0", "", {}, "sha512-t5Fy/nfn+14LuOc2KNYg75vZqClpAiqscVvMygNnlsHBFpSXdJaYtXMcdNLpl/Qvc3P2cB3s6lOV51nqsFq4ag=="],
}
}

View File

@@ -2,6 +2,36 @@
All notable changes to this project will be documented in this file.
## 认知修正
### 1. Bun 编译与 native 模块
Bun 的 `bun build --compile` 无法正确处理 native 模块(如 `@libsql/client`),运行时会报错 "Cannot find module"。这是 Bun 1.3.4+ 的已知 bug。
**解决方案**:使用纯 JS 实现的 `sql.js` 替代 `@libsql/client`,可正常编译运行。
### 2. Gitea Actions 镜像问题
自定义镜像默认未安装 git需要在 workflow 中手动安装:
```yaml
- name: Install git
run: apt-get update && apt-get install -y git
```
### 3. Release 自动生成 changelog
在 workflow 中使用 git log 生成变更记录:
```bash
PREV_TAG=$(git describe --tags --abbrev=0 HEAD^ 2>/dev/null || echo "")
CHANGES=$(git log --pretty=format:"- %s (%h)" "$PREV_TAG..HEAD" 2>/dev/null || echo "")
```
### 4. Gitea 发布二进制文件的限制
由于 runner 运行在 Linux 环境,无法直接编译 Windows/macOS 可执行文件。如需跨平台发布,考虑:
- 使用 Go/Rust 等支持交叉编译的语言
- 或仅发布源代码压缩包
---
## [0.1.0] - 2026-04-11
### Added

View File

@@ -52,6 +52,64 @@
1. **Multi-select feature**: Double-click selection mode experience is not ideal, keyboard modifier key approach couldn't be implemented
2. **TypeScript type errors**: Some type errors in NoteEditor (bold attribute doesn't exist, etc.)
## Gitea Runner and Release Workflow
### Runner Configuration
- **Image**: `hub.gaomia.site/titor/bun:latest` (based on Debian bookworm with Bun installed)
- **Default label**: `ubuntu-latest`
- **Issue**: Custom image doesn't have git pre-installed
**Solution**: Install git in workflow:
```yaml
- name: Install git
run: apt-get update && apt-get install -y git
```
### Release Workflow (Auto-changelog)
Trigger on push tag (`v*`):
1. Clone repository using token
2. Install dependencies: `bun install`
3. Build: `bun run build`
4. Create release and upload source archive:
```bash
TAG_NAME="${GITHUB_REF#refs/tags/}"
PREV_TAG=$(git describe --tags --abbrev=0 HEAD^ 2>/dev/null || echo "")
CHANGES=$(git log --pretty=format:"- %s (%h)" "$PREV_TAG..HEAD" 2>/dev/null || echo "")
# Create release via Gitea API
curl -X POST "https://hub.gaomia.site/api/v1/repos/titor/mio/releases" \
-H "Authorization: token ${GITEA_TOKEN}" \
-d "{\"tag_name\":\"${TAG_NAME}\",\"name\":\"${TAG_NAME}\",\"body\":\"${CHANGES}\"}"
```
### Cross-platform Build Limitation
- Bun's `bun build --compile` runs on Linux runner → can only produce Linux executable
- Cannot compile Windows/macOS binaries on Linux environment
- Workaround: Publish source code archive instead of binaries
### Bun Compilation Bug with Native Modules
**Problem**: Using `@libsql/client` (native SQLite binding) causes runtime error:
```
error: Cannot find module '@libsql/win32-x64-msvc' from 'B:\~BUN\root\mio.exe'
```
This is a known bug in Bun 1.3.4+ with native modules.
**Solution**: Replace `@libsql/client` with `sql.js` (pure JavaScript SQLite implementation):
1. Replace dependency in package.json
2. Rewrite db.ts to use sql.js API (async initialization, different query syntax)
3. Update all function calls in index.tsx and NoteEditor.tsx
Result: `bun build --compile` works correctly on all platforms.
## Build Instructions
```bash

View File

@@ -8,7 +8,8 @@
"build": "bun build src/index.tsx --compile --outfile mio.exe"
},
"devDependencies": {
"@types/bun": "latest"
"@types/bun": "latest",
"@types/node": "^25.6.0"
},
"peerDependencies": {
"typescript": "^5"