style: 移除多个文件末尾的空行并格式化代码

refactor(ci): 统一字符串引号风格为单引号
refactor(color): 简化数组返回语法
docs: 调整文档中的代码注释格式
chore: 添加.gitattributes文件配置行尾符
This commit is contained in:
Linkon
2026-01-18 19:43:26 +08:00
parent 8c48b35c08
commit 24e9e6f6f8
12 changed files with 14 additions and 23 deletions
+1
View File
@@ -0,0 +1 @@
* text=auto eol=lf
+2 -2
View File
@@ -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:
+7 -7
View File
@@ -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}$。我们便可以这样定义:
-1
View File
@@ -91,4 +91,3 @@
- 本计划不包含“引入插件系统/插件化框架”的任何概念与实现。
- 本计划不包含“删除 hosting 目录”。它会被保留;仅确保不再作为主路径依赖。
- 本计划优先保证现有功能可用与类型安全,然后再做进一步抽象与模块扩展。
+3 -2
View File
@@ -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')
-1
View File
@@ -88,4 +88,3 @@ if (process.env.GITHUB_OUTPUT) {
} else {
process.stdout.write(`${JSON.stringify(outputs, null, 2)}\n`)
}
+1 -5
View File
@@ -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]
}
-1
View File
@@ -23,4 +23,3 @@
}
}
}
-1
View File
@@ -23,4 +23,3 @@
}
}
}
-1
View File
@@ -23,4 +23,3 @@
}
}
}
-1
View File
@@ -23,4 +23,3 @@
}
}
}
-1
View File
@@ -23,4 +23,3 @@
}
}
}