dsh-plugin-marketplace 0.3.0 → 0.3.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/LICENSE +21 -21
- package/README.md +7 -0
- package/README.zh.md +5 -0
- package/client.js +45 -23
- package/package.json +1 -1
package/LICENSE
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2026 Scorp1o117
|
|
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.
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Scorp1o117
|
|
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
CHANGED
|
@@ -56,6 +56,13 @@ therefore require DSH `0.1.0-rc.7` or newer. DSH `0.1.0-rc.6` users must pin
|
|
|
56
56
|
`dsh-plugin-marketplace@0.2.6`, the last release carrying the legacy
|
|
57
57
|
settings-allowlist compatibility patch.
|
|
58
58
|
|
|
59
|
+
DSH `0.1.2-rc.1` removed the client-side `connection.api` (the legacy settings
|
|
60
|
+
RPC face); version 0.3.1 therefore writes through the bound `settingsScope`'s
|
|
61
|
+
own `mutate` (hosts older than `0.1.2-rc.1` still use the legacy channel).
|
|
62
|
+
Note: when dsh web is opened from a non-loopback origin (a LAN IP, say), DSH
|
|
63
|
+
keeps settings writes process-local, so install / AI-explain requests never
|
|
64
|
+
reach the host.
|
|
65
|
+
|
|
59
66
|
## How it works
|
|
60
67
|
|
|
61
68
|
| Layer | File | Role |
|
package/README.zh.md
CHANGED
|
@@ -46,6 +46,11 @@ DSH `0.1.0-rc.7` 起会公开全部已注册的 settings 命名空间,插件
|
|
|
46
46
|
请锁定 `dsh-plugin-marketplace@0.2.6`;这是最后一个包含旧 settings 白名单兼容
|
|
47
47
|
补丁的版本。
|
|
48
48
|
|
|
49
|
+
DSH `0.1.2-rc.1` 移除了客户端的 `connection.api`(旧 settings RPC 入口),
|
|
50
|
+
`0.3.1` 起改用 `settingsScope` 自带的 `mutate` 写入(`0.1.2-rc.1` 之前的主机仍走
|
|
51
|
+
旧通道)。注意:非本机回环(如局域网 IP)访问 dsh web 时,DSH 的设置写入是
|
|
52
|
+
进程本地的,安装 / AI 解释请求不会到达宿主。
|
|
53
|
+
|
|
49
54
|
## 实现方式
|
|
50
55
|
|
|
51
56
|
| 层 | 文件 | 作用 |
|
package/client.js
CHANGED
|
@@ -82,7 +82,7 @@ window.__ModuleLoader__.load({
|
|
|
82
82
|
aiExplain: "🤖 AI 解释",
|
|
83
83
|
aiExplaining: "AI 解释中,请稍候…",
|
|
84
84
|
aiExplainErr: "AI 解释失败:{msg}",
|
|
85
|
-
notExposed: "
|
|
85
|
+
notExposed: "无法写入插件市场的设置通道:DSH 版本过旧(需 0.1.0-rc.7+)、宿主半端未挂载,或当前页面不是本机回环访问;请通过 127.0.0.1 打开 dsh web 后重试。"
|
|
86
86
|
};
|
|
87
87
|
var en = {
|
|
88
88
|
nav: "Plugin Marketplace",
|
|
@@ -113,7 +113,7 @@ window.__ModuleLoader__.load({
|
|
|
113
113
|
aiExplain: "🤖 AI Explain",
|
|
114
114
|
aiExplaining: "AI is explaining…",
|
|
115
115
|
aiExplainErr: "AI explain failed: {msg}",
|
|
116
|
-
notExposed: "
|
|
116
|
+
notExposed: "The plugin-marketplace settings channel is not writable here: the DSH version is too old (0.1.0-rc.7+ required), the host half is not mounted, or this page is not a loopback connection. Open dsh web via 127.0.0.1 and try again."
|
|
117
117
|
};
|
|
118
118
|
|
|
119
119
|
// ── GitHub API ────────────────────────────────────────────────────────
|
|
@@ -184,6 +184,38 @@ window.__ModuleLoader__.load({
|
|
|
184
184
|
return promise;
|
|
185
185
|
}
|
|
186
186
|
|
|
187
|
+
// ── settings write channel ────────────────────────────────────────────
|
|
188
|
+
/**
|
|
189
|
+
* Write one namespace field through whichever settings channel this host
|
|
190
|
+
* exposes. dsh 0.1.2-rc.1 dropped `connection.api` (the old raw settings
|
|
191
|
+
* RPC); there the bound scope's own `mutate` (the remote.settings RPC) is
|
|
192
|
+
* the only write path. Older hosts (0.1.0-rc.7 / 0.1.1.x) have no public
|
|
193
|
+
* scope mutate but keep `connection.api`, whose structured error responses
|
|
194
|
+
* the UI can show verbatim. Always resolves `{ok, error?}` — refused or
|
|
195
|
+
* failed writes surface as a result, never as a rejection.
|
|
196
|
+
*/
|
|
197
|
+
function writeField(scope, api, field, value) {
|
|
198
|
+
if (scope && typeof scope.mutate === "function") {
|
|
199
|
+
return scope.mutate([{ op: "set", path: [field], value: value }]).then(function () {
|
|
200
|
+
// A refused write leaves the namespace view absent (the scope folds
|
|
201
|
+
// the outcome into its snapshot before the promise settles).
|
|
202
|
+
var snap = scope.getSnapshot();
|
|
203
|
+
if (!snap || snap.status !== "ready") return { ok: false, error: { code: "settings-not-exposed" } };
|
|
204
|
+
return { ok: true };
|
|
205
|
+
}, function (e) {
|
|
206
|
+
return { ok: false, error: { message: String(e && e.message || e) } };
|
|
207
|
+
});
|
|
208
|
+
}
|
|
209
|
+
return api.settings.mutate({
|
|
210
|
+
ns: "plugin-marketplace",
|
|
211
|
+
ops: [{ op: "set", path: [field], value: value }]
|
|
212
|
+
}).then(function (response) {
|
|
213
|
+
return (response && response.result) ? response.result : { ok: false, error: { message: "malformed settings response" } };
|
|
214
|
+
}, function (e) {
|
|
215
|
+
return { ok: false, error: { message: String(e && e.message || e) } };
|
|
216
|
+
});
|
|
217
|
+
}
|
|
218
|
+
|
|
187
219
|
// ── components ────────────────────────────────────────────────────────
|
|
188
220
|
function PluginCard(props) {
|
|
189
221
|
return h("li", null,
|
|
@@ -305,33 +337,21 @@ window.__ModuleLoader__.load({
|
|
|
305
337
|
};
|
|
306
338
|
var onInstall = react.useCallback(function (pkg) {
|
|
307
339
|
set(function (prev) { return Object.assign({}, prev, { installError: null }); });
|
|
308
|
-
api.
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
}).then(function (response) {
|
|
312
|
-
if (!response.result.ok) {
|
|
313
|
-
var detail = response.result.error || {};
|
|
314
|
-
set(function (prev) { return Object.assign({}, prev, { installError: mutateError(detail, "unknown") }); });
|
|
340
|
+
writeField(scope, api, "install", { pkg: pkg, ts: Date.now() }).then(function (result) {
|
|
341
|
+
if (!result.ok) {
|
|
342
|
+
set(function (prev) { return Object.assign({}, prev, { installError: mutateError(result.error, "unknown") }); });
|
|
315
343
|
}
|
|
316
|
-
}).catch(function (e) {
|
|
317
|
-
set(function (prev) { return Object.assign({}, prev, { installError: String(e && e.message || e) }); });
|
|
318
344
|
});
|
|
319
|
-
}, [api, t]);
|
|
345
|
+
}, [scope, api, t]);
|
|
320
346
|
// AI-explain request: the host answers over the same settings channel.
|
|
321
347
|
var onExplain = react.useCallback(function (repo, desc, readme) {
|
|
322
348
|
set(function (prev) { return Object.assign({}, prev, { explainError: null }); });
|
|
323
|
-
api.
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
}).then(function (response) {
|
|
327
|
-
if (!response.result.ok) {
|
|
328
|
-
var detail = response.result.error || {};
|
|
329
|
-
set(function (prev) { return Object.assign({}, prev, { explainError: mutateError(detail, "unknown") }); });
|
|
349
|
+
writeField(scope, api, "aiExplain", { repo: repo, desc: desc, readme: readme, ts: Date.now() }).then(function (result) {
|
|
350
|
+
if (!result.ok) {
|
|
351
|
+
set(function (prev) { return Object.assign({}, prev, { explainError: mutateError(result.error, "unknown") }); });
|
|
330
352
|
}
|
|
331
|
-
}).catch(function (e) {
|
|
332
|
-
set(function (prev) { return Object.assign({}, prev, { explainError: String(e && e.message || e) }); });
|
|
333
353
|
});
|
|
334
|
-
}, [api, t]);
|
|
354
|
+
}, [scope, api, t]);
|
|
335
355
|
var load = react.useCallback(function (q, sort, page, append) {
|
|
336
356
|
set(function (prev) { return Object.assign({}, prev, { loading: true, error: null }); });
|
|
337
357
|
fetchPage(q, sort, page).then(function (out) {
|
|
@@ -414,7 +434,9 @@ window.__ModuleLoader__.load({
|
|
|
414
434
|
var t = ctx.locale.bind(NS);
|
|
415
435
|
ctx.effect(function () { return ctx.locale.register(NS, { zh: zh, en: en }); }, "dsh-plugin-marketplace: dictionaries");
|
|
416
436
|
var scope = ctx.settingsScope.bind({ namespace: "plugin-marketplace" });
|
|
417
|
-
|
|
437
|
+
// dsh 0.1.2-rc.1 dropped connection.api; only older hosts still carry
|
|
438
|
+
// the raw settings face there. writeField picks whichever exists.
|
|
439
|
+
var api = (ctx.connection && ctx.connection.api) ? ctx.connection.api : null;
|
|
418
440
|
ctx.slots.inject("settings.section", function () {
|
|
419
441
|
return ctx.slots.register({
|
|
420
442
|
name: "settings.section",
|