dsh-ziwei 0.0.0-stage → 1.3.2
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/CHANGELOG.md +181 -0
- package/LICENSE +28 -0
- package/README.md +367 -2
- package/THIRD_PARTY_NOTICES.md +76 -0
- package/build.mjs +74 -0
- package/client.js +4376 -0
- package/cordis.patch.yml +4 -0
- package/docs/ui-contract/README.md +117 -0
- package/docs/ui-contract/audit-baseline.json +17 -0
- package/docs/ui-contract/design.md +270 -0
- package/docs/ui-contract/layout.md +442 -0
- package/docs/ui-contract/tokens.md +249 -0
- package/engine-built.js +1163 -0
- package/icon.svg +7 -0
- package/index.js +908 -0
- package/locale/en.json +6 -0
- package/locale/zh.json +6 -0
- package/package.json +82 -4
- package/scripts/audit-ui.mjs +946 -0
- package/scripts/vendor-lunar-data.mjs +90 -0
- package/src/engine-core.js +1163 -0
- package/src/lunar-data.js +14 -0
- package/src/ziwei-core.js +508 -0
- package/verify/all.mjs +63 -0
- package/verify/cases.mjs +28 -0
- package/verify/diff-runner.mjs +142 -0
- package/verify/exports.mjs +61 -0
- package/verify/fixtures/paipan-reference.json +4761 -0
- package/verify/pack.mjs +81 -0
- package/verify/routes-auth.mjs +212 -0
- package/verify/runner-path.mjs +37 -0
- package/verify/sse-hang.mjs +286 -0
- package/verify/ui-contract.mjs +83 -0
- package/verify/verify-tools.mjs +207 -0
- package/verify/verify.mjs +596 -0
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
# Third-Party Notices / 第三方作品声明
|
|
2
|
+
|
|
3
|
+
本项目(Zi Wei Dou Shu Workbench,紫微斗数工作台)以 **MIT** 许可证发布,见 [LICENSE](./LICENSE)。
|
|
4
|
+
下列第三方作品按各自许可证被使用;本文件不改变、也不扩大其许可条款。
|
|
5
|
+
|
|
6
|
+
> 机器可校验标记(`scripts/release-pack.mjs` 会检查):`solarlunar`、`ISC`、`yize`、`3.1.0`。
|
|
7
|
+
> 修改本文件时请保留这三段(solarlunar 许可全文 / 参考实现声明 / 图标字体声明)的结构。
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
## 1. solarlunar 3.1.0 — ISC(数据表来源,必附全文)
|
|
12
|
+
|
|
13
|
+
- 上游项目:<https://github.com/yize/solarlunar>
|
|
14
|
+
- 版本:`3.1.0`(本项目实际抽取的版本)
|
|
15
|
+
- 用途:构建脚本 `build.mjs` 从该包的 ESM 产物 `dist/solarlunar.esm.js` 中**抽取数据表**,
|
|
16
|
+
注入到构建产物 `engine-built.js` 与 `client.js`:
|
|
17
|
+
- `lunarInfo`:农历年数据表,201 项;
|
|
18
|
+
- `lTermInfo`:二十四节气数据表,201 项。
|
|
19
|
+
构建脚本会校验两项均为 201 项,数量不符直接失败。
|
|
20
|
+
- 许可:ISC。按 ISC 条款,以下版权声明与许可全文必须随任何副本分发。
|
|
21
|
+
|
|
22
|
+
```text
|
|
23
|
+
ISC License
|
|
24
|
+
|
|
25
|
+
Copyright (c) 2015, yize
|
|
26
|
+
|
|
27
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
28
|
+
purpose with or without fee is hereby granted, provided that the above
|
|
29
|
+
copyright notice and this permission notice appear in all copies.
|
|
30
|
+
|
|
31
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
32
|
+
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
33
|
+
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
34
|
+
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
35
|
+
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
36
|
+
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
37
|
+
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
---
|
|
41
|
+
|
|
42
|
+
## 2. 算法对照与验证参考(未复制代码)
|
|
43
|
+
|
|
44
|
+
以下项目只作为排盘输出的逐字段对照/交叉核对基准。本项目的引擎与数据表为独立实现,
|
|
45
|
+
**未复制**其源代码;因此不附其许可证全文,仅按学术与工程惯例致谢(MIT 要求保留的是
|
|
46
|
+
被复制/实质性使用部分的版权声明,本项目未复制)。
|
|
47
|
+
|
|
48
|
+
- **iztro 2.6.1**(MIT,Copyright (c) 2023 All Contributors)— <https://github.com/SylarLong/iztro>
|
|
49
|
+
用途:`src/engine-core.js` / `src/ziwei-core.js` 的安星结果与 iztro 逐字段对齐验证
|
|
50
|
+
(庙旺表曾按其逐格校正)。仅作验证基准,运行时不需要该依赖。
|
|
51
|
+
- **lunar-lite 0.2.8**(MIT,Copyright (c) 2023 Sylar)— <https://github.com/SylarLong/lunar-lite>
|
|
52
|
+
用途:农历转换的交叉核对参考。仅作验证参考,未打包其代码、运行时不需要该依赖。
|
|
53
|
+
|
|
54
|
+
若后续维护者从上述项目复制了任何代码或数据片段,必须把对应的 MIT 许可全文补到本节。
|
|
55
|
+
|
|
56
|
+
---
|
|
57
|
+
|
|
58
|
+
## 3. 图标与字体
|
|
59
|
+
|
|
60
|
+
- `icon.svg`:本项目自绘几何图形(同心圆 + 星形路径 + 圆点),随仓库许可证发布。
|
|
61
|
+
**TODO(作者确认)**:若该图标曾参考/改编自第三方素材,请在此补上该素材的来源与许可证。
|
|
62
|
+
- 字体:本项目**未打包任何字体文件**。界面使用 DSH 主题字体变量与系统字体栈
|
|
63
|
+
(`var(--dsh-font-family-text-default, -apple-system, BlinkMacSystemFont, "PingFang SC", …)`),
|
|
64
|
+
不涉及字体授权。
|
|
65
|
+
|
|
66
|
+
---
|
|
67
|
+
|
|
68
|
+
## 4. 内容与声明
|
|
69
|
+
|
|
70
|
+
- 紫微斗数安星规则基于明代公版典籍《紫微斗数全书》,属公有领域的方法与规则;
|
|
71
|
+
本项目的人设、报告结构、提示词与代码为作者原创(来源产品为作者内部实现,未随仓库分发)。
|
|
72
|
+
- 本项目不包含任何商业命理产品的素材、报告模板或授权内容。
|
|
73
|
+
|
|
74
|
+
---
|
|
75
|
+
|
|
76
|
+
*本文件随 npm 分发包一起发布(发布脚本会把本文件加入包内文件清单)。*
|
package/build.mjs
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
// 构建脚本:把农历/节气数据表注入引擎,并组装客户端插件。
|
|
2
|
+
//
|
|
3
|
+
// 可重建性:数据表已随仓库 vendored 到 src/lunar-data.js(由
|
|
4
|
+
// scripts/vendor-lunar-data.mjs 从 solarlunar@3.1.0 抽取,ISC),
|
|
5
|
+
// 因此干净 clone 不依赖包外的 .ref/ 也能构建;.ref/ 仅作为再生成数据表时的来源。
|
|
6
|
+
import { readFileSync, writeFileSync } from 'node:fs';
|
|
7
|
+
import { dirname, join } from 'node:path';
|
|
8
|
+
import { fileURLToPath } from 'node:url';
|
|
9
|
+
|
|
10
|
+
const root = dirname(fileURLToPath(import.meta.url)); // ziwei-workbench/
|
|
11
|
+
const srcDir = join(root, 'src');
|
|
12
|
+
|
|
13
|
+
function extractFromRef(name) {
|
|
14
|
+
const refEsm = join(root, '..', '.ref', 'solarlunar-pkg', 'dist', 'solarlunar.esm.js');
|
|
15
|
+
const esm = readFileSync(refEsm, 'utf8');
|
|
16
|
+
const m = esm.match(new RegExp('var ' + name + ' = \\[([\\s\\S]*?)\\];'));
|
|
17
|
+
if (!m) throw new Error('cannot find ' + name + ' in ' + refEsm);
|
|
18
|
+
return m[1]
|
|
19
|
+
.replace(/\/\*\*?[\s\S]*?\*\//g, '')
|
|
20
|
+
.replace(/\/\/[^\n]*/g, '')
|
|
21
|
+
.replace(/\s+/g, ' ')
|
|
22
|
+
.replace(/,\s*\]/g, ']')
|
|
23
|
+
.trim();
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
let lunarInfo;
|
|
27
|
+
let lTermInfo;
|
|
28
|
+
try {
|
|
29
|
+
const data = await import('./src/lunar-data.js');
|
|
30
|
+
lunarInfo = data.LUNAR_INFO;
|
|
31
|
+
lTermInfo = data.LTERM_INFO;
|
|
32
|
+
} catch (error) {
|
|
33
|
+
console.warn(`[build] src/lunar-data.js 不可用(${error.message}),回退到 .ref/ 抽取`);
|
|
34
|
+
lunarInfo = extractFromRef('lunarInfo');
|
|
35
|
+
lTermInfo = extractFromRef('lTermInfo');
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// 校验行数
|
|
39
|
+
const liCount = (lunarInfo.match(/0x/g) || []).length;
|
|
40
|
+
const ltCount = (lTermInfo.match(/'[^']+'/g) || []).length;
|
|
41
|
+
console.log(`lunarInfo entries: ${liCount} (expect 201), lTermInfo entries: ${ltCount} (expect 201)`);
|
|
42
|
+
if (liCount !== 201 || ltCount !== 201) throw new Error('data table extraction failed');
|
|
43
|
+
|
|
44
|
+
const engine = readFileSync(join(srcDir, 'engine-core.js'), 'utf8')
|
|
45
|
+
.replace('/*__LUNAR_INFO__*/', lunarInfo)
|
|
46
|
+
.replace('/*__LTERM_INFO__*/', lTermInfo);
|
|
47
|
+
|
|
48
|
+
const zcore = readFileSync(join(srcDir, 'ziwei-core.js'), 'utf8');
|
|
49
|
+
const ui = readFileSync(join(srcDir, 'ui-pro.js'), 'utf8');
|
|
50
|
+
|
|
51
|
+
// 引擎单独文件(供 Node 测试与 host 沙箱): 带数据
|
|
52
|
+
writeFileSync(join(root, 'engine-built.js'), engine);
|
|
53
|
+
|
|
54
|
+
// client.js = 懒加载内核包装 + 引擎 + 紫微师内核 + UI。
|
|
55
|
+
//
|
|
56
|
+
// 官方契约(cordis-plugin-development/references/ui-plugin.md):
|
|
57
|
+
// "Keep factories free of side effects... module-body side effects run at
|
|
58
|
+
// materialization (factory(require) → exports)."
|
|
59
|
+
// 所以引擎/内核算在 __ziweiBootstrapKernel() 里,由 UI factory 首次物化时调用;
|
|
60
|
+
// bundle 加载期只注册 factory,不解析执行 226KB 的引擎,也不提前写 window 全局。
|
|
61
|
+
const KERNEL_HEAD = `/* 懒加载内核:bundle 加载期只注册 factory;引擎/内核在首次物化时求值。
|
|
62
|
+
* 官方契约见 dsh-agent-preset/skills/cordis-plugin-development/references/ui-plugin.md
|
|
63
|
+
* 与 practices.md(module-body side effects run at materialization)。
|
|
64
|
+
* 防回归:verify/verify.mjs 断言求值前 window.ZWEngine 不存在。 */
|
|
65
|
+
function __ziweiBootstrapKernel() {
|
|
66
|
+
if (typeof window !== 'undefined' && window.ZWEngine && window.ZWCore) return;
|
|
67
|
+
`;
|
|
68
|
+
const KERNEL_TAIL = `
|
|
69
|
+
}
|
|
70
|
+
`;
|
|
71
|
+
|
|
72
|
+
writeFileSync(join(root, 'client.js'), KERNEL_HEAD + engine + '\n' + zcore + KERNEL_TAIL + ui);
|
|
73
|
+
|
|
74
|
+
console.log('built: engine-built.js, client.js');
|