dsh-plugin-upgrader 1.0.0 → 1.0.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 +28 -0
- package/README.en.md +52 -21
- package/README.md +57 -20
- package/lib/client.js +959 -0
- package/lib/host/bundle.d.ts +52 -0
- package/lib/host/bundle.d.ts.map +1 -0
- package/lib/host/bundle.js +73 -0
- package/lib/host/bundle.js.map +1 -0
- package/lib/host/http.d.ts +46 -0
- package/lib/host/http.d.ts.map +1 -0
- package/lib/host/http.js +104 -0
- package/lib/host/http.js.map +1 -0
- package/lib/host/install.d.ts +71 -0
- package/lib/host/install.d.ts.map +1 -0
- package/lib/host/install.js +161 -0
- package/lib/host/install.js.map +1 -0
- package/lib/host/manager.d.ts +151 -0
- package/lib/host/manager.d.ts.map +1 -0
- package/lib/host/manager.js +28 -0
- package/lib/host/manager.js.map +1 -0
- package/lib/host/overview.d.ts +52 -0
- package/lib/host/overview.d.ts.map +1 -0
- package/lib/host/overview.js +109 -0
- package/lib/host/overview.js.map +1 -0
- package/lib/host/registry.d.ts +116 -0
- package/lib/host/registry.d.ts.map +1 -0
- package/lib/host/registry.js +177 -0
- package/lib/host/registry.js.map +1 -0
- package/lib/host/repo.d.ts +62 -0
- package/lib/host/repo.d.ts.map +1 -0
- package/lib/host/repo.js +102 -0
- package/lib/host/repo.js.map +1 -0
- package/lib/host/version.d.ts +67 -0
- package/lib/host/version.d.ts.map +1 -0
- package/lib/host/version.js +114 -0
- package/lib/host/version.js.map +1 -0
- package/lib/index.d.ts +12 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +254 -0
- package/lib/index.js.map +1 -0
- package/package.json +32 -14
- package/screenshots/history.png +0 -0
- package/screenshots/selection.png +0 -0
- package/screenshots.json +0 -4
- package/src/client.js +0 -1136
- package/src/index.js +0 -275
- package/src/lib/bundle.js +0 -64
- package/src/lib/http.js +0 -93
- package/src/lib/install.js +0 -163
- package/src/lib/overview.js +0 -108
- package/src/lib/registry.js +0 -188
- package/src/lib/repo.js +0 -91
- package/src/lib/version.js +0 -107
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,33 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 1.0.1 — 2026-10-23
|
|
4
|
+
|
|
5
|
+
- **Rewritten in TypeScript.** The whole project is now typed; `pnpm run typecheck`
|
|
6
|
+
covers both the host program and the tests.
|
|
7
|
+
- **The browser half is split into modules** (`src/client/`) instead of one 1100-line
|
|
8
|
+
file: components, copy, styles, hooks, api and formatting each live on their own.
|
|
9
|
+
esbuild bundles them back into the single `lib/client.js` the DSH client loader
|
|
10
|
+
expects.
|
|
11
|
+
- **A real build step.** `pnpm run build` runs `tsc` for the host half and `esbuild`
|
|
12
|
+
for the client half; `lib/` is the published artifact and is git-ignored.
|
|
13
|
+
- **`pnpm run dev` watches both halves.** `tsc --watch` keeps `lib/index.js` and
|
|
14
|
+
`lib/host/**` current while the esbuild context rebuilds `lib/client.js`; a failed
|
|
15
|
+
client build keeps the last good file on disk instead of truncating it.
|
|
16
|
+
- **pnpm replaces npm** as the package manager (`packageManager` is pinned);
|
|
17
|
+
`pnpm-lock.yaml` is the lockfile CI installs from.
|
|
18
|
+
- `pnpm run check` now means typecheck + build + test, and CI runs it on every push.
|
|
19
|
+
- **The row checkbox is drawn by the plugin.** `<input type="checkbox">` rendered
|
|
20
|
+
unchecked in the Harness window even when its `checked` state was set (the tick was
|
|
21
|
+
painted by the native control the app's WebView never drew), so selection looked
|
|
22
|
+
broken while the selection bar still counted the rows. The box is now a styled
|
|
23
|
+
element driven by `aria-checked`, and it looks identical on every platform.
|
|
24
|
+
- **A 4.9× smaller package.** The published tarball drops from 196.5 KB to 50.4 KB
|
|
25
|
+
because `files` no longer ships `screenshots/` (130 KB of storefront images),
|
|
26
|
+
`screenshots.json`, `RELEASING.md` or `src/**/*.ts` — none of them are read at
|
|
27
|
+
runtime, and the sources are on GitHub. Sourcemaps *are* shipped now: every
|
|
28
|
+
`lib/*.js` ends with a `sourceMappingURL` comment, so leaving the maps out only
|
|
29
|
+
produced 404s in the consumer's devtools.
|
|
30
|
+
|
|
3
31
|
## 1.0.0
|
|
4
32
|
|
|
5
33
|
First public release.
|
package/README.en.md
CHANGED
|
@@ -115,41 +115,72 @@ spinning forever.
|
|
|
115
115
|
|
|
116
116
|
```
|
|
117
117
|
dsh-plugin-upgrader/
|
|
118
|
-
├── src/
|
|
119
|
-
│ ├── index.
|
|
120
|
-
│ ├──
|
|
121
|
-
│
|
|
122
|
-
│
|
|
123
|
-
│
|
|
124
|
-
│
|
|
125
|
-
│
|
|
126
|
-
│
|
|
127
|
-
│
|
|
128
|
-
│
|
|
118
|
+
├── src/ sources (TypeScript)
|
|
119
|
+
│ ├── index.ts host entry: route registration, job scheduling
|
|
120
|
+
│ ├── host/ host-side logic (Node, no DOM)
|
|
121
|
+
│ │ ├── overview.ts assembles the overview payload
|
|
122
|
+
│ │ ├── registry.ts packument fetch / shaping, GitHub tag lists
|
|
123
|
+
│ │ ├── install.ts one install step plus enabled-state restore
|
|
124
|
+
│ │ ├── bundle.ts bundle metadata (source kind, i18n fields, icons)
|
|
125
|
+
│ │ ├── repo.ts repository URL normalisation
|
|
126
|
+
│ │ ├── version.ts semver comparison, release links
|
|
127
|
+
│ │ ├── http.ts loopback guard, JSON read/write
|
|
128
|
+
│ │ └── manager.ts the minimal host pluginManager type contract
|
|
129
|
+
│ └── client/ browser side (modules, bundled into one file)
|
|
130
|
+
│ ├── index.ts createPlugin(require): slot registration entry
|
|
131
|
+
│ ├── components/ Tab / PluginRow / VersionLine / JobPanel
|
|
132
|
+
│ ├── copy.ts zh / en strings
|
|
133
|
+
│ ├── styles.ts scoped CSS
|
|
134
|
+
│ ├── hooks.ts locale subscription, overview fetching
|
|
135
|
+
│ ├── api.ts fetch wrappers, job polling
|
|
136
|
+
│ ├── format.ts versions / dates / external links
|
|
137
|
+
│ ├── env.ts minimal window typings
|
|
138
|
+
│ └── types.ts payload types
|
|
139
|
+
├── lib/ build output (git-ignored, produced by `pnpm run build`)
|
|
140
|
+
│ ├── index.js host entry (tsc output)
|
|
141
|
+
│ ├── host/*.js host modules plus .d.ts
|
|
142
|
+
│ └── client.js the browser bundle, wrapped in __ModuleLoader__
|
|
143
|
+
├── scripts/build.mjs build: tsc for the host, esbuild for the client (--watch = dev)
|
|
144
|
+
├── test/ node:test unit tests (.ts, stripped natively by Node 24)
|
|
129
145
|
├── locale/ (reserved) language files
|
|
130
146
|
├── assets/icon.svg icon
|
|
131
|
-
├── test/ node:test unit tests
|
|
132
147
|
├── cordis.patch.yml bundle registration
|
|
133
148
|
└── package.json
|
|
134
149
|
```
|
|
135
150
|
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
151
|
+
The browser half is split into `.ts` modules, but esbuild bundles it back into a
|
|
152
|
+
single `lib/client.js` wrapped in `window.__ModuleLoader__.load({ id, factory(require) { … } })`.
|
|
153
|
+
At runtime it can only `require` modules the host provides (`react`), not its own
|
|
154
|
+
siblings, so the split happens in the sources only.
|
|
139
155
|
|
|
140
156
|
## Development
|
|
141
157
|
|
|
158
|
+
Dependencies are managed with pnpm (`packageManager` is pinned in `package.json`,
|
|
159
|
+
and CI uses pnpm too):
|
|
160
|
+
|
|
142
161
|
```bash
|
|
143
|
-
|
|
144
|
-
|
|
162
|
+
pnpm install # installs dependencies (runs prepare → one build)
|
|
163
|
+
pnpm run dev # watch src/, rebuild the host and the client on save
|
|
164
|
+
pnpm run build # tsc for the host + esbuild for the client → lib/
|
|
165
|
+
pnpm run typecheck # tsc over src and test
|
|
166
|
+
pnpm test # node:test unit tests (.ts runs directly)
|
|
167
|
+
pnpm run check # all of the above (typecheck + build + test)
|
|
145
168
|
```
|
|
146
169
|
|
|
147
|
-
The host half lives in `src/index.
|
|
148
|
-
`/api/plugin-upgrader`), the browser half in `src/client.
|
|
170
|
+
The host half lives in `src/index.ts` (a `webServer` prefix route at
|
|
171
|
+
`/api/plugin-upgrader`), the browser half in `src/client/index.ts` (registering the
|
|
149
172
|
`plugins.tab` slot).
|
|
150
173
|
|
|
151
|
-
|
|
152
|
-
|
|
174
|
+
`pnpm run dev` runs two watchers side by side: `tsc --watch` owns `lib/index.js`
|
|
175
|
+
and `lib/host/**`, esbuild owns `lib/client.js`, so neither overwrites the other.
|
|
176
|
+
esbuild only strips types, it does not check them — run `pnpm run typecheck` after
|
|
177
|
+
editing the browser half.
|
|
178
|
+
|
|
179
|
+
Either way the profile's `link:` points at this directory but loads `lib/`, not
|
|
180
|
+
`src/`, so the build has to run. `pnpm run dev` keeps the output current, but the
|
|
181
|
+
plugin itself does **not** hot-reload — reload it without restarting the app by
|
|
182
|
+
calling `pluginManager.setBundleEnabled(name, false)` and then
|
|
183
|
+
`setBundleEnabled(name, true)`.
|
|
153
184
|
|
|
154
185
|
## License
|
|
155
186
|
|
package/README.md
CHANGED
|
@@ -99,39 +99,76 @@ dsh plugin --profile web add "$PWD"
|
|
|
99
99
|
|
|
100
100
|
```
|
|
101
101
|
dsh-plugin-upgrader/
|
|
102
|
-
├── src/
|
|
103
|
-
│ ├── index.
|
|
104
|
-
│ ├──
|
|
105
|
-
│
|
|
106
|
-
│
|
|
107
|
-
│
|
|
108
|
-
│
|
|
109
|
-
│
|
|
110
|
-
│
|
|
111
|
-
│
|
|
112
|
-
│
|
|
102
|
+
├── src/ 源码(TypeScript)
|
|
103
|
+
│ ├── index.ts 宿主端入口:路由注册、job 调度
|
|
104
|
+
│ ├── host/ 宿主端逻辑(Node,无 DOM)
|
|
105
|
+
│ │ ├── overview.ts 组装 overview 载荷
|
|
106
|
+
│ │ ├── registry.ts registry packument 拉取 / 裁剪、GitHub tag 列表
|
|
107
|
+
│ │ ├── install.ts 单步安装 + enabled 状态恢复
|
|
108
|
+
│ │ ├── bundle.ts 插件元数据(来源分类、多语言字段、图标)
|
|
109
|
+
│ │ ├── repo.ts 仓库 URL 归一化
|
|
110
|
+
│ │ ├── version.ts semver 比较、发布页链接
|
|
111
|
+
│ │ ├── http.ts 回环校验、JSON 读写
|
|
112
|
+
│ │ └── manager.ts 宿主 pluginManager 服务的最小类型契约
|
|
113
|
+
│ └── client/ 浏览器端(拆成模块,由 esbuild 打成一个文件)
|
|
114
|
+
│ ├── index.ts createPlugin(require):槽位注册入口
|
|
115
|
+
│ ├── components/ Tab / PluginRow / VersionLine / JobPanel
|
|
116
|
+
│ ├── copy.ts zh / en 文案
|
|
117
|
+
│ ├── styles.ts 作用域 CSS
|
|
118
|
+
│ ├── hooks.ts locale 订阅、overview 拉取
|
|
119
|
+
│ ├── api.ts fetch 封装、job 轮询
|
|
120
|
+
│ ├── format.ts 版本号 / 日期 / 外部链接
|
|
121
|
+
│ ├── env.ts window 上的最小类型声明
|
|
122
|
+
│ └── types.ts 载荷类型
|
|
123
|
+
├── lib/ 构建产物(git 忽略,`pnpm run build` 生成)
|
|
124
|
+
│ ├── index.js 宿主端入口(tsc 输出)
|
|
125
|
+
│ ├── host/*.js 宿主端模块 + .d.ts
|
|
126
|
+
│ └── client.js 浏览器端单文件 bundle(含 __ModuleLoader__ 包装)
|
|
127
|
+
├── scripts/build.mjs 构建脚本:tsc 编译宿主端 + esbuild 打包 client(加 --watch 即 dev)
|
|
128
|
+
├── test/ node:test 单元测试(.ts,Node 24 直接剥离类型)
|
|
113
129
|
├── locale/ (保留)语言包
|
|
114
130
|
├── assets/icon.svg 图标
|
|
115
|
-
├── test/ node:test 单元测试
|
|
116
131
|
├── cordis.patch.yml bundle 注册
|
|
117
132
|
└── package.json
|
|
118
133
|
```
|
|
119
134
|
|
|
120
|
-
`
|
|
121
|
-
|
|
135
|
+
浏览器端虽然拆成了多个 `.ts` 模块,但最终由 esbuild 打成一个 `lib/client.js`,
|
|
136
|
+
外面套上 `window.__ModuleLoader__.load({ id, factory(require) { … } })`。
|
|
137
|
+
运行时它只能 `require('react')` 这类由宿主提供的模块,不能 require 自己的其它文件,
|
|
138
|
+
所以「拆模块」只发生在源码层,产物仍然是单文件。
|
|
122
139
|
|
|
123
140
|
## 开发
|
|
124
141
|
|
|
142
|
+
本项目用 pnpm 管理依赖(`package.json` 里钉了 `packageManager`,CI 也用 pnpm):
|
|
143
|
+
|
|
125
144
|
```bash
|
|
126
|
-
|
|
127
|
-
|
|
145
|
+
pnpm install # 安装依赖(会自动跑 prepare → 构建一次)
|
|
146
|
+
pnpm run dev # 监听 src/,宿主端和浏览器端改完即编译(Ctrl+C 停止)
|
|
147
|
+
pnpm run build # tsc 编译宿主端 + esbuild 打包 client → lib/
|
|
148
|
+
pnpm run typecheck # tsc 检查 src 和 test
|
|
149
|
+
pnpm test # node:test 单元测试(.ts 直接运行)
|
|
150
|
+
pnpm run check # 以上全部(typecheck + build + test)
|
|
128
151
|
```
|
|
129
152
|
|
|
130
|
-
宿主端在 `src/index.
|
|
131
|
-
浏览器端在 `src/client.
|
|
153
|
+
宿主端在 `src/index.ts`(`webServer` 前缀路由 `/api/plugin-upgrader`),
|
|
154
|
+
浏览器端在 `src/client/index.ts`(注册 `plugins.tab` 槽位)。
|
|
155
|
+
|
|
156
|
+
`pnpm run dev` 会并行跑两个监听器:`tsc --watch` 负责 `lib/index.js` 和
|
|
157
|
+
`lib/host/**`,esbuild 负责 `lib/client.js`,两者输出互不覆盖。注意 esbuild
|
|
158
|
+
打包时会直接剥掉类型而不做检查,所以改浏览器端时顺手跑一次 `pnpm run typecheck`。
|
|
159
|
+
|
|
160
|
+
改完代码后必须重新构建(profile 里的 `link:` 指向本目录,但加载的是 `lib/`,
|
|
161
|
+
不是 `src/`)。`pnpm run dev` 已经替你重建了产物,但**插件本身不会热更新**——
|
|
162
|
+
要让宿主重新加载本插件,无需重启应用:先 `pluginManager.setBundleEnabled(name, false)`
|
|
163
|
+
再 `setBundleEnabled(name, true)`。
|
|
164
|
+
|
|
165
|
+
## 发布
|
|
132
166
|
|
|
133
|
-
|
|
134
|
-
|
|
167
|
+
见 [RELEASING.md](./RELEASING.md)。首次手动发一次,之后打 `v*` tag 由 CI 通过 npm trusted publishing 自动发布:
|
|
168
|
+
|
|
169
|
+
```bash
|
|
170
|
+
pnpm publish --access public # 仅首次
|
|
171
|
+
```
|
|
135
172
|
|
|
136
173
|
## 许可
|
|
137
174
|
|