dsh-plugin-workspace-move-top 0.2.0 → 0.2.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 -0
- package/README.md +21 -7
- package/README.zh-CN.md +29 -0
- package/client/client.js +12 -6
- package/dsh-plugin.naming.json +2 -2
- package/package.json +7 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Workspace Hub 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
CHANGED
|
@@ -1,15 +1,29 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Move to Top
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[中文说明](README.zh-CN.md)
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
Add **Move to top** to a DSH workspace's `…` menu. One click performs one reorder through the host's official `workspaceRegistry.insertBefore` API, just like a long manual drag.
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
- No stars, favorites, pinned categories, or automatic reordering.
|
|
8
|
+
- Move another workspace later and the previous one naturally moves down.
|
|
9
|
+
- Manual dragging remains yours; activation and synchronization never restore an old order.
|
|
10
|
+
- Works independently of Workspace Hub.
|
|
11
|
+
|
|
12
|
+
## Install
|
|
8
13
|
|
|
9
14
|
```sh
|
|
10
|
-
dsh plugin --profile desktop add dsh-plugin-workspace-move-top@0.2.
|
|
15
|
+
dsh plugin --profile desktop add dsh-plugin-workspace-move-top@0.2.1
|
|
11
16
|
```
|
|
12
17
|
|
|
13
|
-
|
|
18
|
+
## Compatibility and limits
|
|
19
|
+
|
|
20
|
+
Tested with **DSH 0.2.1-rc.5 on macOS**. This release targets that exact host version. Menu copy follows the browser language: Chinese or English.
|
|
21
|
+
|
|
22
|
+
The host has no workspace-menu extension slot, so the client uses the current workspace-row and menu DOM. If a future host changes that structure, the action may disappear. It must not reorder workspaces on its own. Windows and non-empty session-menu browser behavior have not been verified.
|
|
14
23
|
|
|
15
|
-
|
|
24
|
+
## Verify
|
|
25
|
+
|
|
26
|
+
```sh
|
|
27
|
+
npm ci
|
|
28
|
+
npm run check
|
|
29
|
+
```
|
package/README.zh-CN.md
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# 移到最上面
|
|
2
|
+
|
|
3
|
+
[English](README.md)
|
|
4
|
+
|
|
5
|
+
在 DSH 工作区 `…` 菜单中增加“移到最上面”。点击一次,通过官方 `workspaceRegistry.insertBefore` 接口完成一次排序,相当于替你完成一次长距离拖动。
|
|
6
|
+
|
|
7
|
+
- 没有星标、收藏区或自动归位。
|
|
8
|
+
- 之后把另一个项目移到第一,原来的自然退到第二。
|
|
9
|
+
- 仍可自由拖动;启动与同步时不恢复旧顺序。
|
|
10
|
+
- 不依赖工作区同步插件,可单独安装。
|
|
11
|
+
|
|
12
|
+
## 安装
|
|
13
|
+
|
|
14
|
+
```sh
|
|
15
|
+
dsh plugin --profile desktop add dsh-plugin-workspace-move-top@0.2.1
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## 兼容性与限制
|
|
19
|
+
|
|
20
|
+
已在 **macOS + DSH 0.2.1-rc.5** 验证,本版本精确对应该宿主。菜单根据浏览器语言显示中文或英文。
|
|
21
|
+
|
|
22
|
+
宿主没有工作区菜单扩展位,因此客户端使用当前工作区行和菜单 DOM。宿主改变该结构后,菜单项可能消失;插件不会因此自行排序。Windows 真机与非空会话菜单的浏览器行为尚未验证。
|
|
23
|
+
|
|
24
|
+
## 验证
|
|
25
|
+
|
|
26
|
+
```sh
|
|
27
|
+
npm ci
|
|
28
|
+
npm run check
|
|
29
|
+
```
|
package/client/client.js
CHANGED
|
@@ -6,6 +6,12 @@ window.__ModuleLoader__.load({
|
|
|
6
6
|
var exports = module.exports
|
|
7
7
|
var MENU_ITEM = 'data-wshub-move-top'
|
|
8
8
|
var API_PATH = 'api/plugins/wshub-workspace-move-top/move'
|
|
9
|
+
// Menu copy follows the host UI language (navigator.language). Backend error
|
|
10
|
+
// messages are shown verbatim; only our own prefix is localized.
|
|
11
|
+
var LANGUAGE = (typeof navigator !== 'undefined' && navigator && navigator.language) || ''
|
|
12
|
+
var LABELS = /^zh/i.test(LANGUAGE)
|
|
13
|
+
? { menu: '移到最上面', hint: '只调整一次顺序,之后仍可自由拖动', busy: '正在调整顺序…', done: '已移到最上面', failed: '调整失败:' }
|
|
14
|
+
: { menu: 'Move to top', hint: 'Moves this workspace once; you can still drag afterwards.', busy: 'Moving to top…', done: 'Moved to top', failed: 'Move failed: ' }
|
|
9
15
|
|
|
10
16
|
function apply(ctx) {
|
|
11
17
|
ctx.effect(function () {
|
|
@@ -40,7 +46,7 @@ window.__ModuleLoader__.load({
|
|
|
40
46
|
if (!id || busy) return
|
|
41
47
|
busy = true
|
|
42
48
|
button.disabled = true
|
|
43
|
-
button.title =
|
|
49
|
+
button.title = LABELS.busy
|
|
44
50
|
try {
|
|
45
51
|
var response = await fetch(API_PATH, {
|
|
46
52
|
method: 'POST',
|
|
@@ -49,7 +55,7 @@ window.__ModuleLoader__.load({
|
|
|
49
55
|
})
|
|
50
56
|
var result = await response.json().catch(function () { return null })
|
|
51
57
|
if (!response.ok || !result || result.ok !== true) throw new Error((result && result.message) || ('HTTP ' + response.status))
|
|
52
|
-
button.title =
|
|
58
|
+
button.title = LABELS.done
|
|
53
59
|
// Closing the native menu removes the extension row with it.
|
|
54
60
|
var trigger = document.activeElement
|
|
55
61
|
if (trigger && trigger.closest && trigger.closest('[data-row-key^="workspace:"]')) trigger.click()
|
|
@@ -58,7 +64,7 @@ window.__ModuleLoader__.load({
|
|
|
58
64
|
// DOM teardown is authoritative; the Host publishes the new order.
|
|
59
65
|
} catch (error) {
|
|
60
66
|
button.disabled = false
|
|
61
|
-
button.title =
|
|
67
|
+
button.title = LABELS.failed + (error instanceof Error ? error.message : String(error))
|
|
62
68
|
button.setAttribute('aria-label', button.title)
|
|
63
69
|
} finally {
|
|
64
70
|
busy = false
|
|
@@ -82,8 +88,8 @@ window.__ModuleLoader__.load({
|
|
|
82
88
|
button.dataset.wshubWorkspaceId = workspaceId
|
|
83
89
|
button.removeAttribute('class')
|
|
84
90
|
button.className = template.className
|
|
85
|
-
button.setAttribute('aria-label',
|
|
86
|
-
button.title =
|
|
91
|
+
button.setAttribute('aria-label', LABELS.menu)
|
|
92
|
+
button.title = LABELS.hint
|
|
87
93
|
var spans = template.querySelectorAll('span')
|
|
88
94
|
if (spans[0]) {
|
|
89
95
|
var icon = document.createElement('span')
|
|
@@ -94,7 +100,7 @@ window.__ModuleLoader__.load({
|
|
|
94
100
|
var label = document.createElement('span')
|
|
95
101
|
var labelTemplate = spans[1] || spans[0]
|
|
96
102
|
if (labelTemplate) label.className = labelTemplate.className
|
|
97
|
-
label.textContent =
|
|
103
|
+
label.textContent = LABELS.menu
|
|
98
104
|
button.appendChild(label)
|
|
99
105
|
button.addEventListener('click', function (event) {
|
|
100
106
|
event.preventDefault()
|
package/dsh-plugin.naming.json
CHANGED
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
"schemaVersion": 1,
|
|
3
3
|
"policy": "dsh-plugin-naming/v1",
|
|
4
4
|
"plugin": {
|
|
5
|
-
"namespace": "
|
|
5
|
+
"namespace": "dongsheng123132",
|
|
6
6
|
"name": "workspace-move-top",
|
|
7
|
-
"coordinate": "
|
|
7
|
+
"coordinate": "dongsheng123132/workspace-move-top",
|
|
8
8
|
"packageName": "dsh-plugin-workspace-move-top"
|
|
9
9
|
},
|
|
10
10
|
"names": {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-plugin-workspace-move-top",
|
|
3
|
-
"version": "0.2.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "0.2.1",
|
|
4
|
+
"description": "Move a workspace to the top once from its menu, without favorites or automatic reordering.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"main": "./lib/index.js",
|
|
@@ -19,18 +19,21 @@
|
|
|
19
19
|
"client/",
|
|
20
20
|
"cordis.patch.yml",
|
|
21
21
|
"README.md",
|
|
22
|
+
"README.zh-CN.md",
|
|
22
23
|
"dsh-plugin.naming.json"
|
|
23
24
|
],
|
|
24
25
|
"repository": {
|
|
25
26
|
"type": "git",
|
|
26
|
-
"url": "git+https://github.com/dongsheng123132/workspace-
|
|
27
|
+
"url": "git+https://github.com/dongsheng123132/dsh-workspace-plugins.git",
|
|
27
28
|
"directory": "plugins/dsh-workspace-move-top"
|
|
28
29
|
},
|
|
29
30
|
"dsh": {
|
|
30
31
|
"bundle": {
|
|
31
32
|
"patch": "./cordis.patch.yml"
|
|
32
33
|
},
|
|
33
|
-
"client": {
|
|
34
|
+
"client": {
|
|
35
|
+
"platform": "web"
|
|
36
|
+
}
|
|
34
37
|
},
|
|
35
38
|
"scripts": {
|
|
36
39
|
"build": "tsc -p tsconfig.json",
|