@ssamurias/dsh-fish 1.0.8 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +368 -338
- package/CHANGELOG.md +113 -0
- package/README.md +377 -352
- package/RELEASE-NOTES-1.0.9.md +79 -0
- package/RELEASE-NOTES-1.1.0.md +55 -0
- package/docs//350/256/244/344/272/272/345/210/244/346/215/256.md +112 -0
- package/lib/appoint.js +106 -22
- package/lib/ask.js +2 -1
- package/lib/autobackup.js +4 -0
- package/lib/capture.js +16 -0
- package/lib/claim.js +103 -0
- package/lib/client/00-shell.js +630 -0
- package/lib/client/01-state-load.js +901 -0
- package/lib/client/02-actions.js +670 -0
- package/lib/client/03-widgets-header.js +721 -0
- package/lib/client/04-pressure-lab.js +891 -0
- package/lib/client/05-pressure-charts.js +431 -0
- package/lib/client/06-tab-status-grow.js +468 -0
- package/lib/client/07-tab-home-bili.js +610 -0
- package/lib/client/08-tab-memory-plugins.js +756 -0
- package/lib/client/09-tab-outing.js +710 -0
- package/lib/client/10-data-handlers.js +519 -0
- package/lib/client/11-tab-data-frame.js +749 -0
- package/lib/client/12-pressure-chip-mount.js +565 -0
- package/lib/client.js +477 -47
- package/lib/comment.js +18 -3
- package/lib/derive.js +262 -22
- package/lib/doing.js +31 -15
- package/lib/env.d.ts +224 -0
- package/lib/events.js +5 -2
- package/lib/guess.js +29 -0
- package/lib/health.js +75 -0
- package/lib/hear.js +67 -0
- package/lib/herpeople.js +159 -0
- package/lib/history.js +27 -5
- package/lib/home.js +12 -1
- package/lib/identity.js +23 -0
- package/lib/index.js +34 -18
- package/lib/look.js +3 -2
- package/lib/make.js +60 -12
- package/lib/markup.js +61 -23
- package/lib/observe-bili.js +334 -0
- package/lib/observe-config.js +223 -0
- package/lib/observe-data.js +522 -0
- package/lib/observe-home.js +384 -0
- package/lib/observe-http.js +250 -0
- package/lib/observe-outing.js +650 -0
- package/lib/observe-state.js +419 -0
- package/lib/observe-trip.js +286 -0
- package/lib/observe.js +99 -3574
- package/lib/people.js +514 -0
- package/lib/peopledoc.js +112 -0
- package/lib/persona.js +324 -42
- package/lib/restrict.js +74 -3
- package/lib/say.js +71 -1
- package/lib/scheduler.js +23 -3
- package/lib/schedules.js +97 -0
- package/lib/schema.js +11 -4
- package/lib/scrub.js +3 -3
- package/lib/selfdoc.js +19 -2
- package/lib/settings.js +112 -11
- package/lib/stance.js +47 -3
- package/lib/status.js +14 -5
- package/lib/sub.js +1 -1
- package/lib/tenant.js +35 -7
- package/lib/turns.js +51 -4
- package/lib/types.d.ts +515 -0
- package/lib/voices.js +3 -0
- package/lib/watch.js +1 -1
- package/lib/wiki.js +131 -25
- package/lib/works.js +120 -45
- package/package.json +1 -1
- package/scripts/build-client.mjs +83 -0
- package/scripts/sync-pressure-formulas.mjs +12 -15
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// @ts-check
|
|
3
|
+
/**
|
|
4
|
+
* scripts/build-client.mjs —— 把 `lib/client/*.js` 按序拼成浏览器单入口 `lib/client.js`
|
|
5
|
+
*
|
|
6
|
+
* 为什么这样拆而不引打包器:
|
|
7
|
+
* 1. 零依赖铁律(dependencies / peerDependencies / devDependencies 全空),不能引 esbuild / rollup;
|
|
8
|
+
* 2. 支持 `dsh plugin add "github:mochi-fish/dsh-fish"` 与 `link:` 源码直连,仓库里必须直接有可跑的 `lib/client.js`;
|
|
9
|
+
* 3. 宿主客户端加载器(`window.__ModuleLoader__.load`)按 `./client` 单脚本装载。
|
|
10
|
+
*
|
|
11
|
+
* 同时把服务端 `lib/session-pressure-formulas.js` 的共享公式自动嵌进 `// BEGIN shared pressure formulas` 槽位,
|
|
12
|
+
* 不再需要两处手抄同步。
|
|
13
|
+
*
|
|
14
|
+
* 用法:
|
|
15
|
+
* node scripts/build-client.mjs # 重新生成 lib/client.js
|
|
16
|
+
* node scripts/build-client.mjs --check # 只校验 lib/client.js 与分片源码是否逐字节一致(测试与 CI 用)
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
import fs from 'node:fs'
|
|
20
|
+
import path from 'node:path'
|
|
21
|
+
import { fileURLToPath } from 'node:url'
|
|
22
|
+
|
|
23
|
+
const ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..')
|
|
24
|
+
export const CLIENT_PARTS_DIR = path.join(ROOT, 'lib', 'client')
|
|
25
|
+
export const CLIENT_OUT_FILE = path.join(ROOT, 'lib', 'client.js')
|
|
26
|
+
export const FORMULAS_FILE = path.join(ROOT, 'lib', 'session-pressure-formulas.js')
|
|
27
|
+
export const FORMULAS_PLACEHOLDER = ' // {{SHARED_PRESSURE_FORMULAS}}'
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* 读取服务端 `session-pressure-formulas.js`(去掉末尾 `export {...}`),缩进 4 格嵌入客户端壳。
|
|
31
|
+
* @param {string} [root]
|
|
32
|
+
* @returns {string}
|
|
33
|
+
*/
|
|
34
|
+
export function renderSharedFormulas(root = ROOT) {
|
|
35
|
+
const raw = fs.readFileSync(path.join(root, 'lib', 'session-pressure-formulas.js'), 'utf8').replace(/\r\n/g, '\n')
|
|
36
|
+
const body = raw.split('\nexport {')[0].trimEnd()
|
|
37
|
+
const indented = body
|
|
38
|
+
.split('\n')
|
|
39
|
+
.map((line) => (line.length ? ` ${line}` : ''))
|
|
40
|
+
.join('\n')
|
|
41
|
+
return ` // BEGIN shared pressure formulas\n${indented}\n // END shared pressure formulas`
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* 按文件名顺序读取 `lib/client/*.js` 并拼出完整的 `lib/client.js` 源码(LF 换行)。
|
|
46
|
+
* @param {string} [root]
|
|
47
|
+
* @returns {{ code: string, parts: string[] }}
|
|
48
|
+
*/
|
|
49
|
+
export function buildClientSource(root = ROOT) {
|
|
50
|
+
const dir = path.join(root, 'lib', 'client')
|
|
51
|
+
const parts = fs.readdirSync(dir).filter((f) => /^\d{2}-.*\.js$/.test(f)).sort()
|
|
52
|
+
if (!parts.length) {
|
|
53
|
+
throw new Error(`lib/client/ 下没有找到客户端分片文件(${dir})`)
|
|
54
|
+
}
|
|
55
|
+
const chunks = parts.map((name) => {
|
|
56
|
+
const text = fs.readFileSync(path.join(dir, name), 'utf8').replace(/\r\n/g, '\n')
|
|
57
|
+
if (name === '00-shell.js') {
|
|
58
|
+
if (!text.includes(FORMULAS_PLACEHOLDER)) {
|
|
59
|
+
throw new Error(`lib/client/00-shell.js 缺少共享公式占位符:${FORMULAS_PLACEHOLDER}`)
|
|
60
|
+
}
|
|
61
|
+
return text.replace(FORMULAS_PLACEHOLDER, renderSharedFormulas(root))
|
|
62
|
+
}
|
|
63
|
+
return text
|
|
64
|
+
})
|
|
65
|
+
return { code: chunks.join('\n'), parts }
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
const isMain = process.argv[1] && path.resolve(process.argv[1]) === fileURLToPath(import.meta.url)
|
|
69
|
+
if (isMain) {
|
|
70
|
+
const checkOnly = process.argv.includes('--check')
|
|
71
|
+
const { code, parts } = buildClientSource(ROOT)
|
|
72
|
+
if (checkOnly) {
|
|
73
|
+
const current = fs.readFileSync(CLIENT_OUT_FILE, 'utf8').replace(/\r\n/g, '\n')
|
|
74
|
+
if (current !== code) {
|
|
75
|
+
console.error('✖ lib/client.js 与 lib/client/*.js 分片不一致。请运行:node scripts/build-client.mjs')
|
|
76
|
+
process.exit(1)
|
|
77
|
+
}
|
|
78
|
+
console.log(`✔ lib/client.js 与 ${parts.length} 个分片及共享公式逐字节一致。`)
|
|
79
|
+
} else {
|
|
80
|
+
fs.writeFileSync(CLIENT_OUT_FILE, code, 'utf8')
|
|
81
|
+
console.log(`✔ 已从 ${parts.length} 个分片生成 lib/client.js(${Buffer.byteLength(code, 'utf8')} 字节)。`)
|
|
82
|
+
}
|
|
83
|
+
}
|
|
@@ -1,17 +1,14 @@
|
|
|
1
|
-
|
|
1
|
+
// @ts-check
|
|
2
|
+
/**
|
|
3
|
+
* 兼容旧入口:把 `lib/session-pressure-formulas.js` 与 `lib/client/*.js` 一并拼回 `lib/client.js`。
|
|
4
|
+
*/
|
|
5
|
+
import { writeFile } from 'node:fs/promises'
|
|
6
|
+
import { readFileSync } from 'node:fs'
|
|
7
|
+
import { CLIENT_OUT_FILE, buildClientSource } from './build-client.mjs'
|
|
2
8
|
|
|
3
|
-
const
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const end = ' // END shared pressure formulas'
|
|
9
|
-
const first = original.indexOf(start)
|
|
10
|
-
const last = original.indexOf(end, first)
|
|
11
|
-
if (first < 0 || last < 0) throw new Error('Missing client formula markers')
|
|
12
|
-
const body = source.split('\n').map(line => line ? ' ' + line : '').join('\n')
|
|
13
|
-
const generated = original.slice(0, first) + start + '\n' + body + '\n' + original.slice(last)
|
|
14
|
-
if (generated !== original) {
|
|
15
|
-
if (process.argv.includes('--check')) throw new Error('Client formulas are out of sync')
|
|
16
|
-
await writeFile(client, generated)
|
|
9
|
+
const { code } = buildClientSource()
|
|
10
|
+
const original = readFileSync(CLIENT_OUT_FILE, 'utf8').replace(/\r\n/g, '\n')
|
|
11
|
+
if (code !== original) {
|
|
12
|
+
if (process.argv.includes('--check')) throw new Error('Client formulas or slices are out of sync')
|
|
13
|
+
await writeFile(CLIENT_OUT_FILE, code, 'utf8')
|
|
17
14
|
}
|