dsh-plugin-update-all 0.0.0-stage → 1.0.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/LICENSE +202 -0
- package/README.md +140 -2
- package/README.zh.md +88 -0
- package/client.js +786 -0
- package/cordis.patch.yml +3 -0
- package/icon.svg +12 -0
- package/index.js +10 -0
- package/locale/en.json +6 -0
- package/locale/zh.json +6 -0
- package/package.json +40 -4
- package/test/json.cjs +13 -0
- package/test/smoke.cjs +354 -0
- package/test/traditional.cjs +18 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
package/README.md
CHANGED
|
@@ -1,3 +1,141 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Update all
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Adds an **Updates** tab to the **Plugins** page. One run checks every installed plugin for a
|
|
4
|
+
compatible newer release and updates the outdated ones — no per-plugin version pages to open.
|
|
5
|
+
|
|
6
|
+
## Install from this directory
|
|
7
|
+
|
|
8
|
+
This directory *is* the plugin package: no build step, no dependencies, no registry publish. A DSH
|
|
9
|
+
that has never seen the plugin installs it from here alone.
|
|
10
|
+
|
|
11
|
+
1. **Plugins** → the **Add plugin** menu → **安装第三方插件** (*Install a third-party plugin*).
|
|
12
|
+
2. Put this directory into the spec field (包名或地址 / *Package name or address*), for example
|
|
13
|
+
`C:\Users\spark\workspace\dsh-plugin\dsh-plugin-update-all`.
|
|
14
|
+
3. **Check**, then **Install**. The bundle row appears as **全部更新 / Update all**, and its **更新**
|
|
15
|
+
tab joins the page; reload the page if the tab does not show up.
|
|
16
|
+
|
|
17
|
+
`package.json` declares `engines.dsh: ">=0.2.2-rc.3"`, the release whose `plugins.tab` slot and
|
|
18
|
+
`pluginManager` Remote this bundle is verified against. An older DSH refuses the install with a
|
|
19
|
+
version message instead of loading a half-working tab. Nothing is written outside this directory
|
|
20
|
+
and the target profile.
|
|
21
|
+
|
|
22
|
+
## Where it is
|
|
23
|
+
|
|
24
|
+
**Plugins** (sidebar) → the tab row under the page header → **更新** (*Updates*). The tab sits right
|
|
25
|
+
after **已安装** (*Installed*).
|
|
26
|
+
|
|
27
|
+
The page hides its own 刷新 / 添加插件 toolbar on every contributed tab, so this tab carries its own
|
|
28
|
+
controls: **检查更新** (or **重新检查**) and **全部更新(N)**. The tab checks as soon as it opens, so
|
|
29
|
+
the first thing you see is the result, not a button.
|
|
30
|
+
|
|
31
|
+
## How a run works
|
|
32
|
+
|
|
33
|
+
1. **Check** — the tab reads the profile's dependencies (`pluginManager.listBundles`) and asks the
|
|
34
|
+
registry for each one's newer versions (`pluginManager.listVersions`).
|
|
35
|
+
2. **Choose** — for every package it takes the newest listed version that declares a bundle,
|
|
36
|
+
accepts the running DSH version, and is neither deprecated nor a prerelease. The status line
|
|
37
|
+
counts what it found: `N 个可更新 · M 个已是最新 · K 个已跳过`, plus `X 个有新版本但无法更新` when a
|
|
38
|
+
package has a release the running DSH refuses.
|
|
39
|
+
3. **Confirm** — `全部更新(N)` opens a block naming the count and saying what an update does; a
|
|
40
|
+
second, focused button starts it. Nothing changes before that second click.
|
|
41
|
+
4. **Update, one at a time** — each package goes through `pluginManager.updateBundle` with the
|
|
42
|
+
registry that listed it. The Host removes the installed version, installs the target, and
|
|
43
|
+
installs the old version back when the target fails. Updates are serial because the Host
|
|
44
|
+
serializes profile changes on its profile lock. **停止后续** finishes the plugin that is updating
|
|
45
|
+
and then stops before the next one; the packages it never reached keep their own `已跳过` rows,
|
|
46
|
+
so the report still adds up.
|
|
47
|
+
5. **Report** — every package keeps its own row: updated, updated with a restart, failed (with the
|
|
48
|
+
Host's own words on a second line), or failed with the old version restored. A hint says what
|
|
49
|
+
still needs a page reload or a DSH restart.
|
|
50
|
+
|
|
51
|
+
## What it does not update
|
|
52
|
+
|
|
53
|
+
| State | Result shown |
|
|
54
|
+
|---|---|
|
|
55
|
+
| Registry version (`update: 'registry'`) | Updated |
|
|
56
|
+
| Git spec (`update: 'git'`) | Skipped: a Git update needs the target commit and spec, which this tab does not resolve. Update it from the plugin's page on the **已安装** view. |
|
|
57
|
+
| Local directory (`link:`) or tarball (`file:`) | Skipped: no registry owns it |
|
|
58
|
+
| Shipped by the DSH installation | Skipped: updated together with DSH |
|
|
59
|
+
| Official optional plugin | Skipped: not updated from a registry |
|
|
60
|
+
| `readOnlyReason` (DSH manages it) | Skipped |
|
|
61
|
+
| Package files missing, or no readable version | Skipped |
|
|
62
|
+
| Newer release needs a newer DSH, or is not a bundle / deprecated / prerelease | Listed as blocked, with the requirement it states — never called "up to date" |
|
|
63
|
+
| This bundle itself | Ignored: updating it would stop the tab running the update |
|
|
64
|
+
|
|
65
|
+
## Limitations
|
|
66
|
+
|
|
67
|
+
- **Sequential.** A run of twelve plugins takes as long as twelve updates. Stopping finishes the
|
|
68
|
+
plugin already updating; it cannot abort that one installation.
|
|
69
|
+
- **A page reload loads new client code.** Updated Host code applies through HMR, but the browser
|
|
70
|
+
keeps the modules it already loaded. Rows that say *restart* need a DSH restart.
|
|
71
|
+
- **A running update briefly stops that plugin.** With HMR the Host removes the installed version
|
|
72
|
+
before installing the target, exactly as the per-plugin update does.
|
|
73
|
+
- **Errors belong to their row.** One failure never aborts the rest of the run; the failed package
|
|
74
|
+
stays a candidate, so pressing `全部更新` again retries it.
|
|
75
|
+
- **Simplified Chinese copy.** The `zh` dictionary follows DSH's own `zh`, so the tab reads like the
|
|
76
|
+
page around it: 插件 / 已安装 / 发现 / 刷新 / 添加插件 / 安装源 / 检查于 / 视图. An English UI reads
|
|
77
|
+
the English dictionary instead.
|
|
78
|
+
|
|
79
|
+
## Architecture
|
|
80
|
+
|
|
81
|
+
```
|
|
82
|
+
dsh-plugin-update-all/
|
|
83
|
+
├── package.json bundle manifest: name, engines.dsh, patch row, `dsh.client` web declaration
|
|
84
|
+
├── cordis.patch.yml inserts the `update-all` row that carries the client half
|
|
85
|
+
├── index.js host half: an empty `apply()`; the feature is browser-only
|
|
86
|
+
├── client.js the whole browser half: the tab, its controller, its copy, its styles
|
|
87
|
+
├── locale/*.json Plugin Manager display metadata (title, description)
|
|
88
|
+
├── icon.svg the row icon
|
|
89
|
+
└── test/smoke.cjs headless harness for the browser half
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
`client.js` is one file by platform contract: a package's client entry and its chunks cannot
|
|
93
|
+
require each other synchronously, so the browser half is self-contained. Its sections, in order:
|
|
94
|
+
|
|
95
|
+
1. **Copy** — the `updateAll` dictionary in Simplified Chinese and English. Every visible string
|
|
96
|
+
goes through the Client locale service; `ctx.locale.bind('updateAll')` hands the component its
|
|
97
|
+
`t`.
|
|
98
|
+
2. **Host facts** — pure functions over the Remote's records: `installable`, `updateCandidate`
|
|
99
|
+
(the same policy the shipped Versions section uses), `skipReason` (which field decides each
|
|
100
|
+
skip: `readOnlyReason`, `availability`, `update`, `official`), `titleOf`, `describeUpdate`
|
|
101
|
+
(a `PluginUpdateResult` as a tone, a copy key, its parameters, a detail line, and whether the
|
|
102
|
+
new version runs).
|
|
103
|
+
3. **Controller** — one frozen snapshot plus subscribers, `load()` (the check pass, with a quiet
|
|
104
|
+
mode that re-reads without losing the results), and `updateAll()` (the serial pass, with a
|
|
105
|
+
stop request honored between plugins). It is created in `apply` and disposed with the plugin's
|
|
106
|
+
context.
|
|
107
|
+
4. **Rendering** — `PackageRow`, `statusOf`, `stepText`, `clockOf`, and `UpdateAllTab`, which reads
|
|
108
|
+
the controller through `useSyncExternalStore`. Styles are rendered with the tab as a `<style>`
|
|
109
|
+
element and use only `--dsw-alias-*` design tokens: `brand-primary` is the primary control
|
|
110
|
+
*fill*, so its label is `label-primary-foreground`; `bg-layer-1` equals the page background in
|
|
111
|
+
the light theme, so raised surfaces use `card-fill` and hovers use `interactive-bg-hover`.
|
|
112
|
+
5. **Plugin** — `inject: ['slots', 'locale', 'remote', 'remote.pluginManager']`, then the locale
|
|
113
|
+
dictionary, the controller, the `plugin-manager/update-state` listener, and the single
|
|
114
|
+
`ctx.slots.inject('plugins.tab', …)` registration.
|
|
115
|
+
|
|
116
|
+
No configuration: the tab reads the same profile the Plugins page manages, and there is nothing
|
|
117
|
+
to tune in `cordis.patch.yml`.
|
|
118
|
+
|
|
119
|
+
## What it reads and sends
|
|
120
|
+
|
|
121
|
+
- Reads: the profile's bundle list and versions (`listBundles`, `listVersions`), which the Plugins
|
|
122
|
+
page already reads.
|
|
123
|
+
- Sends: nothing. The only network traffic is the registry lookup and the package install the Host
|
|
124
|
+
performs for `updateBundle`.
|
|
125
|
+
- Turning the bundle off removes the tab and leaves the profile's plugins untouched.
|
|
126
|
+
|
|
127
|
+
## Development
|
|
128
|
+
|
|
129
|
+
`test/smoke.cjs` drives this client half headlessly: it loads `client.js` through a stub module
|
|
130
|
+
loader, stubs React with a tree-walking renderer, and runs the controller against a fake
|
|
131
|
+
`pluginManager` — check pass, every skip reason, every update outcome, the Host's step events,
|
|
132
|
+
stopping mid-run, and both dictionaries.
|
|
133
|
+
|
|
134
|
+
```sh
|
|
135
|
+
node test/smoke.cjs
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
Two smaller checks sit beside it: `node test/json.cjs package.json locale/en.json locale/zh.json`
|
|
139
|
+
parses the manifests and both dictionaries, and
|
|
140
|
+
`node test/traditional.cjs client.js locale/zh.json README.zh.md` fails when the Simplified copy
|
|
141
|
+
contains a Traditional-only character.
|
package/README.zh.md
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
# 全部更新
|
|
2
|
+
|
|
3
|
+
在「插件」页面加一个**更新**视图:一次检查所有已安装插件的可用新版本,并把需要更新的逐一更新,不必一个一个点进去看版本。
|
|
4
|
+
|
|
5
|
+
## 从这个目录安装
|
|
6
|
+
|
|
7
|
+
这个目录**就是**插件包本身:不需要构建、没有依赖、也不用发布到 npm。一个从来没装过它的 DSH,只靠这个目录就能装上。
|
|
8
|
+
|
|
9
|
+
1. **插件** → **添加插件** 菜单 → **安装第三方插件**。
|
|
10
|
+
2. 把本目录填进「包名或地址」,例如 `C:\Users\spark\workspace\dsh-plugin\dsh-plugin-update-all`。
|
|
11
|
+
3. 按**检查**,再按**安装**。列表里会出现 **全部更新**,页面也会多出**更新**视图;若没看到,重新加载页面。
|
|
12
|
+
|
|
13
|
+
`package.json` 声明了 `engines.dsh: ">=0.2.2-rc.3"`——这是本插件验证过的版本(依赖它的 `plugins.tab` slot 与 `pluginManager` Remote)。更旧的 DSH 会直接以版本信息拒绝安装,而不是装上一个半残的视图。除了这个目录和目标的 profile,不会写任何地方。
|
|
14
|
+
|
|
15
|
+
## 位置
|
|
16
|
+
|
|
17
|
+
侧栏 **插件** → 页面标题下方的视图行 → **更新**。它紧排在**已安装**后面。
|
|
18
|
+
|
|
19
|
+
「插件」页面在别人贡献的视图上会收起自己的 刷新 / 添加插件 工具栏,所以这个视图自带控件:**检查更新**(或**重新检查**)与**全部更新(N)**。视图一打开就自动检查,所以你第一眼看到的是结果,不是按钮。
|
|
20
|
+
|
|
21
|
+
## 一次更新的流程
|
|
22
|
+
|
|
23
|
+
1. **检查**:读出 profile 的依赖插件(`pluginManager.listBundles`),逐一问安装源有没有新版本(`pluginManager.listVersions`)。
|
|
24
|
+
2. **挑选**:只取同时满足「声明了 bundle、接受当前 DSH 版本、不是 deprecated、不是 prerelease」的最新版本。状态行显示 `N 个可更新 · M 个已是最新 · K 个已跳过`;若有「有新版本但目前无法更新」的插件,会另外列出它需要的 DSH 版本。
|
|
25
|
+
3. **确认**:按「全部更新(N)」会先出现一个区块,写明更新数量与更新会做什么,再按第二颗(自动取得焦点)的按钮才动手。
|
|
26
|
+
4. **逐一更新**:每一项都用 listing 的那个安装源调用 `pluginManager.updateBundle`。Host 会先移除旧版、安装目标版本,目标失败时再把旧版装回。更新是串行执行的,因为 Host 用 profile 文件锁串行化所有 profile 变更。**停止后续**会让当前这一项更新完,然后在下一项之前停下;没轮到的插件各自保留一行「已跳过」,所以报告仍然对得上。
|
|
27
|
+
5. **回报**:每一项都有自己的结果行——已更新、已更新但需重启、失败(Host 的原话显示在第二行)、或失败且已恢复到当前版本。下方会提示哪些项目需要重新加载页面或重启 DSH。
|
|
28
|
+
|
|
29
|
+
## 不会更新的东西
|
|
30
|
+
|
|
31
|
+
| 状态 | 显示结果 |
|
|
32
|
+
|---|---|
|
|
33
|
+
| 安装源版本(`update: 'registry'`) | 会更新 |
|
|
34
|
+
| Git spec(`update: 'git'`) | 跳过:Git 更新需要目标 commit 与 spec,这个视图不解析它。请到**已安装**视图打开该插件页面更新。 |
|
|
35
|
+
| 本地目录(`link:`)或 tarball(`file:`) | 跳过:不属于任何安装源 |
|
|
36
|
+
| DSH 安装本身附带的 bundle | 跳过:随 DSH 一并更新 |
|
|
37
|
+
| 官方可选插件 | 跳过:不从安装源更新 |
|
|
38
|
+
| `readOnlyReason`(由 DSH 管理) | 跳过 |
|
|
39
|
+
| 包文件缺失,或读不到版本 | 跳过 |
|
|
40
|
+
| 新版本需要更新版 DSH,或不是 plugin bundle、已弃用、只有测试版 | 列为「有新版本但无法更新」并写出它要求的版本,不会被说成「已是最新」 |
|
|
41
|
+
| 这个包自己 | 忽略:更新自己会中断正在跑更新的视图 |
|
|
42
|
+
|
|
43
|
+
## 限制
|
|
44
|
+
|
|
45
|
+
- **串行执行**:12 个插件就是 12 次更新的时间。「停止后续」只保证当前这一项不被中断,无法中止那一次安装。
|
|
46
|
+
- **新版界面要重新加载页面**:Host 端代码走 HMR,但浏览器已加载的模块不会自己换掉。标示「需重启」的项目要重启 DSH。
|
|
47
|
+
- **更新时该插件会短暂停止**:有 HMR 时 Host 会先移除旧版再装新版,跟逐个更新一样。
|
|
48
|
+
- **错误只属于那一行**:一项失败不会中断整批;失败的包仍是候选,再按一次「全部更新」就重试它。
|
|
49
|
+
- **简体中文文案**:`zh` 字典跟随 DSH 内置的 `zh`(插件 / 已安装 / 发现 / 刷新 / 添加插件 / 安装源 / 检查于 / 视图),英文界面则读英文字典。
|
|
50
|
+
|
|
51
|
+
## 架构
|
|
52
|
+
|
|
53
|
+
```
|
|
54
|
+
dsh-plugin-update-all/
|
|
55
|
+
├── package.json bundle manifest:名称、engines.dsh、patch row、`dsh.client` web 声明
|
|
56
|
+
├── cordis.patch.yml 插入 `update-all` row,带上 client 半
|
|
57
|
+
├── index.js Host 半:空的 `apply()`,功能全在浏览器端
|
|
58
|
+
├── client.js 整个浏览器端:视图、controller、文案、样式
|
|
59
|
+
├── locale/*.json Plugin Manager 显示用 metadata(标题、说明)
|
|
60
|
+
├── icon.svg row 图标
|
|
61
|
+
└── test/smoke.cjs 浏览器端的无头测试
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
`client.js` 依平台契约必须是单一文件:一个包的 client entry 与 chunk 不能互相同步 `require`,所以浏览器端是自成一体的。文件内依序分成五段:
|
|
65
|
+
|
|
66
|
+
1. **文案**:`updateAll` 字典(简体中文+英文)。所有可见文字都走 Client locale 服务,`ctx.locale.bind('updateAll')` 把 `t` 交给组件。
|
|
67
|
+
2. **Host 事实**:对 Remote 回传数据的纯函数——`installable`、`updateCandidate`(与内置 Versions 区块相同的政策)、`skipReason`(用 `readOnlyReason`、`availability`、`update`、`official` 决定每一种跳过原因)、`titleOf`、`describeUpdate`(把 `PluginUpdateResult` 转成 tone、文案 key、参数、第二行说明,以及「新版是否已生效」)。
|
|
68
|
+
3. **Controller**:一个 frozen snapshot 加订阅者、`load()`(检查流程,含 quiet 模式:重读列表但不丢掉结果)、`updateAll()`(串行更新,停止请求会在两个插件之间生效)。在 `apply` 创建,随 plugin context 一起销毁。
|
|
69
|
+
4. **渲染**:`PackageRow`、`statusOf`、`stepText`、`clockOf`、`UpdateAllTab`,透过 `useSyncExternalStore` 读 controller。样式以 `<style>` 元素随视图渲染,且只用 `--dsw-alias-*` 设计 token:`brand-primary` 是主按钮的**填色**(浅色近黑、深色近白),所以文字用 `label-primary-foreground`;`bg-layer-1` 在浅色主题等于页面底色,所以浮起面用 `card-fill`、hover 用 `interactive-bg-hover`。
|
|
70
|
+
5. **Plugin**:`inject: ['slots', 'locale', 'remote', 'remote.pluginManager']`,接着注册字典、controller、`plugin-manager/update-state` 监听,最后一笔 `ctx.slots.inject('plugins.tab', …)`。
|
|
71
|
+
|
|
72
|
+
没有可配置项:视图读的就是「插件」页面管理的那个 profile,`cordis.patch.yml` 没有需要调的参数。
|
|
73
|
+
|
|
74
|
+
## 读取与发送
|
|
75
|
+
|
|
76
|
+
- 读取:profile 的 bundle 列表与版本(`listBundles`、`listVersions`),与「插件」页面本来就读的一样。
|
|
77
|
+
- 发送:无。唯一的网络流量是安装源查询,以及 `updateBundle` 时 Host 自己执行的包安装。
|
|
78
|
+
- 关掉这个 bundle 只会拿掉视图,不会动到 profile 里的任何插件。
|
|
79
|
+
|
|
80
|
+
## 开发
|
|
81
|
+
|
|
82
|
+
`test/smoke.cjs` 会无头驱动这个浏览器端:透过 stub module loader 加载 `client.js`,用会走访元素树的假 React 渲染,并用假的 `pluginManager` 跑 controller——检查流程、每一种跳过原因、每一种更新结果、Host 的 step 事件、中途停止,以及两种语言字典。
|
|
83
|
+
|
|
84
|
+
```sh
|
|
85
|
+
node test/smoke.cjs
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
旁边还有两个小检查:`node test/json.cjs package.json locale/en.json locale/zh.json` 检查 manifest 与两份字典能否解析;`node test/traditional.cjs client.js locale/zh.json README.zh.md` 在简体文案里出现繁体专用字时失败。
|