diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..94f480d --- /dev/null +++ b/.gitattributes @@ -0,0 +1 @@ +* text=auto eol=lf \ No newline at end of file diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index edbf742..ebdf03a 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -6,10 +6,10 @@ on: workflow_dispatch: inputs: version: - description: "版本号(例如 1.2.3 或 v1.2.3)" + description: '版本号(例如 1.2.3 或 v1.2.3)' required: false build: - description: "构建命令标记(build:win|build:mac|build:linux|build:unpack|build:all)" + description: '构建命令标记(build:win|build:mac|build:linux|build:unpack|build:all)' required: false permissions: diff --git a/ai_ref/disposable.md b/ai_ref/disposable.md index e87a7d4..f2f3877 100644 --- a/ai_ref/disposable.md +++ b/ai_ref/disposable.md @@ -7,7 +7,7 @@ - 为什么我们需要可逆的插件系统? - Cordis 是如何实现资源安全的? -::: + ::: Koishi 的一切都从 Cordis 开始。但我想大部分 Koishi 的开发者都不知道 Cordis 是什么。如果让我来定义的话,Cordis 是一个**元框架 (Meta Framework)**,即一个用于构建框架的框架。 @@ -112,8 +112,8 @@ function serve(port: number) { return () => server.close() } -const dispose = serve(80) // 监听端口 80 -dispose() // 回收副作用 +const dispose = serve(80) // 监听端口 80 +dispose() // 回收副作用 ``` 在这个例子中,`serve()` 函数将会创建一个服务器并且监听 `port` 端口。同时,调用该函数也会返回一个新的函数,用于取消该端口的监听。 @@ -123,7 +123,7 @@ dispose() // 回收副作用 - $\mathcal{C}\times\mathfrak{F}$ 对应着全局环境 (我们稍后会提到全局环境的坏处,但不影响这里的理解) - `port` 对应于上面的 $\text{X}$,由于我们可以使用柯里化,所以在数学模型中并不需要考虑它 -::: + ::: 为什么需要引入这个 $\text{effect}$ 和 $\mathcal{C}\times\mathfrak{F}$ 呢?它的作用是将副作用从函数的返回值中分离出来,从而实现副作用的回收。只需定义 $\text{restore}$ 变换 (不难发现它确实是 $\text{effect}$ 的逆操作): @@ -142,9 +142,9 @@ function serve(port: number) { collectEffect(() => server.close()) } -serve(80) // 监听端口 80 并记录副作用 -serve(443) // 监听端口 443 并记录副作用 -restore() // 回收所有副作用 +serve(80) // 监听端口 80 并记录副作用 +serve(443) // 监听端口 443 并记录副作用 +restore() // 回收所有副作用 ``` 当副作用被记录到全局环境时,$\mathcal{C}\times\mathfrak{F}$ 也就变成了一个更大的 $\mathcal{C}$。我们便可以这样定义: diff --git a/ai_ref/work_plan.md b/ai_ref/work_plan.md index 2ad1b01..d9de645 100644 --- a/ai_ref/work_plan.md +++ b/ai_ref/work_plan.md @@ -91,4 +91,3 @@ - 本计划不包含“引入插件系统/插件化框架”的任何概念与实现。 - 本计划不包含“删除 hosting 目录”。它会被保留;仅确保不再作为主路径依赖。 - 本计划优先保证现有功能可用与类型安全,然后再做进一步抽象与模块扩展。 - diff --git a/scripts/ci/apply-version.mjs b/scripts/ci/apply-version.mjs index 87606b2..8370732 100644 --- a/scripts/ci/apply-version.mjs +++ b/scripts/ci/apply-version.mjs @@ -1,7 +1,9 @@ import fs from 'fs' import path from 'path' -const version = String(process.argv[2] || '').trim().replace(/^v/i, '') +const version = String(process.argv[2] || '') + .trim() + .replace(/^v/i, '') if (!version) { process.stderr.write('缺少版本号参数,例如:node scripts/ci/apply-version.mjs 1.2.3\n') process.exit(1) @@ -17,4 +19,3 @@ const pkgPath = path.join(process.cwd(), 'package.json') const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf-8')) pkg.version = version fs.writeFileSync(pkgPath, `${JSON.stringify(pkg, null, 2)}\n`, 'utf-8') - diff --git a/scripts/ci/parse-commit.mjs b/scripts/ci/parse-commit.mjs index 6ff5598..e734af5 100644 --- a/scripts/ci/parse-commit.mjs +++ b/scripts/ci/parse-commit.mjs @@ -88,4 +88,3 @@ if (process.env.GITHUB_OUTPUT) { } else { process.stdout.write(`${JSON.stringify(outputs, null, 2)}\n`) } - diff --git a/src/renderer/src/utils/color.ts b/src/renderer/src/utils/color.ts index 7bac7e1..91b1291 100644 --- a/src/renderer/src/utils/color.ts +++ b/src/renderer/src/utils/color.ts @@ -1,11 +1,7 @@ function hexToRgb(hex: string): [number, number, number] { const result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex) return result - ? [ - parseInt(result[1], 16), - parseInt(result[2], 16), - parseInt(result[3], 16) - ] + ? [parseInt(result[1], 16), parseInt(result[2], 16), parseInt(result[3], 16)] : [0, 0, 0] } diff --git a/themes/amber.json b/themes/amber.json index 56ab3f5..ba3885d 100644 --- a/themes/amber.json +++ b/themes/amber.json @@ -23,4 +23,3 @@ } } } - diff --git a/themes/cyan.json b/themes/cyan.json index d3ad460..0488f82 100644 --- a/themes/cyan.json +++ b/themes/cyan.json @@ -23,4 +23,3 @@ } } } - diff --git a/themes/green.json b/themes/green.json index 6fbc448..8e9bf9f 100644 --- a/themes/green.json +++ b/themes/green.json @@ -23,4 +23,3 @@ } } } - diff --git a/themes/pastel.json b/themes/pastel.json index 2fcb240..072e184 100644 --- a/themes/pastel.json +++ b/themes/pastel.json @@ -23,4 +23,3 @@ } } } - diff --git a/themes/purple.json b/themes/purple.json index ca7ad32..f31f9d1 100644 --- a/themes/purple.json +++ b/themes/purple.json @@ -23,4 +23,3 @@ } } } -