@dsh-workbench/module-hello 0.3.11 → 1.0.0-beta.1
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 +9 -0
- package/LICENSE +21 -0
- package/README.md +80 -0
- package/package.json +17 -6
package/CHANGELOG.md
ADDED
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 dsh-workbench contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
# @dsh-workbench/module-hello
|
|
2
|
+
|
|
3
|
+
工作台里**最小的可安装模块**:装上面板多一张卡片,卸掉就没了。它同时是模块包的样板 ——
|
|
4
|
+
两个面各注册一次、卡片只有一个标题、没有工具、没有数据源,别的一概不掺。
|
|
5
|
+
|
|
6
|
+
拿来试装试卸最省事;想知道一个模块**必须**有什么,看它的文件比看文档快。
|
|
7
|
+
|
|
8
|
+
## 装
|
|
9
|
+
|
|
10
|
+
```bash
|
|
11
|
+
# 装进工作台的 profile(实例名按你自己的来,默认 workbench)
|
|
12
|
+
dsh plugin --profile workbench add @dsh-workbench/module-hello
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
也可以在 `:3081` 的「工作台模块市场」里找到它装。装完右栏多一张「示例模块」卡片,
|
|
16
|
+
标题下两行字,刷新按钮接好了但没有数据源 —— 按了只会重画。
|
|
17
|
+
|
|
18
|
+
卸掉:市场里卸,或 `dsh plugin --profile workbench remove @dsh-workbench/module-hello`。
|
|
19
|
+
|
|
20
|
+
## 它演示了什么
|
|
21
|
+
|
|
22
|
+
| 东西 | 在哪 | 说明 |
|
|
23
|
+
|---|---|---|
|
|
24
|
+
| 模块声明 | `package.json` 的 `dsh.workbench` | `apiVersion: 1`、单元 id `hello`、一张卡、零工具、不注入外壳服务 |
|
|
25
|
+
| 宿主面 | `src/host.ts` | 把 `{ unit: 'hello', mount }` 注册进外壳的 `workbenchUnits`;`routes` 空、`registerTools` 空 |
|
|
26
|
+
| 浏览器面 | `src/client.tsx` | 把 `{ unit, messages, card }` 注册进外壳;卡片用 kit 的 `Card` |
|
|
27
|
+
| 文案 | `src/messages.ts` | zh / en 两份字典,键名以前缀分域 |
|
|
28
|
+
| 接线 | `cordis.patch.yml` | 把自己插进 profile 的组合图 |
|
|
29
|
+
| 测试 | `src/plugin.test.ts` | 断言插件名、注入面、两个面各注册一次 |
|
|
30
|
+
|
|
31
|
+
两个面都只 `inject: ['workbenchUnits']` —— 外壳交出来的那个服务。宿主侧拿不到服务时打一条
|
|
32
|
+
warn 就退,不会把整个 entry 拖挂。
|
|
33
|
+
|
|
34
|
+
## 文件
|
|
35
|
+
|
|
36
|
+
```text
|
|
37
|
+
src/
|
|
38
|
+
host.ts 宿主面:注册单元
|
|
39
|
+
client.tsx 浏览器面:注册卡片
|
|
40
|
+
messages.ts 文案(zh / en)
|
|
41
|
+
plugin.test.ts 两个面的注册测试
|
|
42
|
+
scripts/smoke.mjs 构建后冒烟:产物能 require、导出齐全
|
|
43
|
+
cordis.patch.yml 把自己插进 profile 组合图
|
|
44
|
+
arch.config.mjs 一行:moduleArch()
|
|
45
|
+
eslint.config.mjs 两行:moduleLint()
|
|
46
|
+
client.js / dist/ 构建产物(不进 git,但必须进 npm 包)
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## 开发与门禁
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
pnpm install
|
|
53
|
+
pnpm build # dist/host.js + client.js
|
|
54
|
+
pnpm test # 单元测试
|
|
55
|
+
pnpm check # 十三条模块判据(契约 / 产物边界 / 源码边界 / 卡片渲染 / arch / lint …)
|
|
56
|
+
pnpm selfcheck # build + 产物冒烟
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
改了想马上看效果:重新 `pnpm build` 后刷新页面;宿主侧热换,不用重装。
|
|
60
|
+
|
|
61
|
+
## 想造自己的模块
|
|
62
|
+
|
|
63
|
+
别从这份抄起,跑工具链:
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
pnpm exec dsh-wb-module init my-unit --template diy
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
`diy` 模板有真数据源、五态卡片和填好的设计底稿。完整流程见
|
|
70
|
+
[模块 DIY 指引](../core/skills/workbench-module-diy/SKILL.md),
|
|
71
|
+
判据与工具见 [module-tools](../module-tools/README.md)。
|
|
72
|
+
|
|
73
|
+
## 相关文档
|
|
74
|
+
|
|
75
|
+
| 想了解 | 读 |
|
|
76
|
+
|---|---|
|
|
77
|
+
| 模块怎么写、怎么装、怎么验收 | [DIY 指引](../core/skills/workbench-module-diy/SKILL.md) |
|
|
78
|
+
| 构建、接线、注册的细节 | [BUILD.md](../core/skills/workbench-module-diy/BUILD.md) · [WIRING.md](../core/skills/workbench-module-diy/WIRING.md) |
|
|
79
|
+
| 十三条判据、模板、设计底稿 | [module-tools](../module-tools/README.md) |
|
|
80
|
+
| 契约类型与共享组件 | [shared](../shared/README.md) |
|
package/package.json
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dsh-workbench/module-hello",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "1.0.0-beta.1",
|
|
4
4
|
"description": "最小示例模块:装上后面板里多一张卡片,用来试装试卸。",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
7
7
|
".": "./dist/host.js",
|
|
8
8
|
"./client": "./client.js"
|
|
9
9
|
},
|
|
10
|
-
"//files": "和外壳同一条纪律:client.js 与 dist/ 是构建产物,npm 的兜底是 .gitignore,不显式列出就会漏。",
|
|
11
10
|
"files": [
|
|
12
11
|
"dist",
|
|
13
12
|
"client.js",
|
|
14
|
-
"cordis.patch.yml"
|
|
13
|
+
"cordis.patch.yml",
|
|
14
|
+
"CHANGELOG.md"
|
|
15
15
|
],
|
|
16
16
|
"dsh": {
|
|
17
17
|
"bundle": {
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
]
|
|
28
28
|
},
|
|
29
29
|
"workbench": {
|
|
30
|
-
"apiVersion":
|
|
30
|
+
"apiVersion": 2,
|
|
31
31
|
"unit": "hello",
|
|
32
32
|
"card": {
|
|
33
33
|
"titleKey": "hello.cardTitle",
|
|
@@ -59,18 +59,29 @@
|
|
|
59
59
|
"react": "^19.3.0",
|
|
60
60
|
"typescript": "5.9",
|
|
61
61
|
"vitest": "^5.0.2",
|
|
62
|
-
"@dsh-workbench/core": "0.
|
|
63
|
-
"@dsh-workbench/module-tools": "0.
|
|
62
|
+
"@dsh-workbench/core": "1.0.0-beta.1",
|
|
63
|
+
"@dsh-workbench/module-tools": "1.0.0-beta.1"
|
|
64
64
|
},
|
|
65
65
|
"publishConfig": {
|
|
66
66
|
"access": "public"
|
|
67
67
|
},
|
|
68
|
+
"license": "MIT",
|
|
69
|
+
"repository": {
|
|
70
|
+
"type": "git",
|
|
71
|
+
"url": "git+https://github.com/novaeth/dsh-workbench.git",
|
|
72
|
+
"directory": "packages/module-hello"
|
|
73
|
+
},
|
|
74
|
+
"homepage": "https://github.com/novaeth/dsh-workbench#readme",
|
|
75
|
+
"bugs": {
|
|
76
|
+
"url": "https://github.com/novaeth/dsh-workbench/issues"
|
|
77
|
+
},
|
|
68
78
|
"scripts": {
|
|
69
79
|
"build": "dsh-wb-module build",
|
|
70
80
|
"typecheck": "tsc --noEmit",
|
|
71
81
|
"selfcheck": "dsh-wb-module build && node scripts/smoke.mjs",
|
|
72
82
|
"test": "vitest run",
|
|
73
83
|
"check": "dsh-wb-module check",
|
|
84
|
+
"arch": "node ../module-tools/bin/dsh-wb-module.mjs check --only arch",
|
|
74
85
|
"lint": "dsh-wb-module lint"
|
|
75
86
|
}
|
|
76
87
|
}
|