feat(source): 外部音源迁 src/ 并新增 source-simple 进程内直载
- apis/source(.ivm).ts → src/source(.ivm).ts(音源属服务端职责,不入 SDK) - 新增 src/source-simple.ts:sources/*.mjs 进程内直载(getMusicUrl 极简契约), 与 *.js 的 IVM 沙箱(globalThis.lx 契约)按扩展名混排候选链,失败降权冷却 - server 挂载决策:SOURCE_ENABLED 非 0/false 启用,/url 取流分流到外部音源; 音源模式下登录态不参与取流,自动续期不启动(手动 /login/refresh 仍可用) - 新增 src/env.ts(.env 最先加载)与 test/source-simple-test.ts(并入 pnpm test)
This commit is contained in:
1 parent
66d06ef48a
commit
96f6a7fe91
13 files changed
+570
-94
No files matched your search
+16
@@ -0,0 +1,16 @@
|
||||
// .env 加载器(副作用模块):读取项目根目录 .env,已存在的环境变量优先于文件值。
|
||||
// 必须作为入口的第一个 import —— server.ts 在模块体内读取 SOURCE_ENABLED/PORT 等,
|
||||
// 而 ESM 静态 import 按声明顺序求值,晚于任何本模块代码。
|
||||
// .env 不入库(见 .gitignore),缺失时静默跳过。
|
||||
import { existsSync } from 'node:fs'
|
||||
import { fileURLToPath } from 'node:url'
|
||||
import { dirname, join } from 'node:path'
|
||||
|
||||
const envPath = join(dirname(fileURLToPath(import.meta.url)), '../.env')
|
||||
if (existsSync(envPath)) {
|
||||
try {
|
||||
process.loadEnvFile(envPath)
|
||||
} catch (err) {
|
||||
console.warn(`[env] .env 解析失败,已忽略: ${err instanceof Error ? err.message : err}`)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user