dsh-ris-ide 1.7.0 → 1.7.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/README.md +3 -3
- package/lib/client-codemirror.js +18 -0
- package/lib/client.js +1192 -123
- package/lib/index.js +1555 -52
- package/lib/standalone/window.html +89 -14
- package/package.json +1 -1
- package/skills/dsh-ris-ide-debug/SKILL.md +2 -2
- package/test/client-viewer.test.mjs +589 -33
- package/test/clipboard.test.mjs +254 -0
- package/test/host-search.test.mjs +125 -1
- package/test/host-tail.test.mjs +198 -21
- package/test/windows.test.mjs +198 -0
|
@@ -64,6 +64,20 @@
|
|
|
64
64
|
function nudgeHolder() {
|
|
65
65
|
try { if (channel !== null) channel.postMessage({ type: 'focus' }) } catch (error) { /* closed */ }
|
|
66
66
|
}
|
|
67
|
+
/**
|
|
68
|
+
* Ask the browser to raise this window and report back whether it did.
|
|
69
|
+
*
|
|
70
|
+
* Chrome does not let a page raise a window another document opened, so the
|
|
71
|
+
* opener cannot tell success from silence. The window itself can: it calls
|
|
72
|
+
* focus() and then says whether it now HAS the document focus. The opener uses
|
|
73
|
+
* that ack to decide between "brought forward" and "open it for the user".
|
|
74
|
+
*/
|
|
75
|
+
function answerFocus() {
|
|
76
|
+
try { window.focus() } catch (error) { /* ignore */ }
|
|
77
|
+
var focused = false
|
|
78
|
+
try { focused = document.hasFocus() === true } catch (error) { focused = false }
|
|
79
|
+
try { if (channel !== null) channel.postMessage({ type: 'focus-ack', focused: focused }) } catch (error) { /* closed */ }
|
|
80
|
+
}
|
|
67
81
|
function button(label, onClick) {
|
|
68
82
|
var node = document.createElement('button')
|
|
69
83
|
node.type = 'button'
|
|
@@ -72,39 +86,86 @@
|
|
|
72
86
|
node.addEventListener('click', onClick)
|
|
73
87
|
return node
|
|
74
88
|
}
|
|
75
|
-
/**
|
|
89
|
+
/**
|
|
90
|
+
* Another window holds the lock: offer a choice, never close this one.
|
|
91
|
+
*
|
|
92
|
+
* Focusing another browser window is not reliably allowed (Chrome ignores a
|
|
93
|
+
* background window's focus()), so the two honest choices are: keep the old
|
|
94
|
+
* window and drop this one, or ask the old window to close itself (it was
|
|
95
|
+
* opened by script, so it may) and take over here.
|
|
96
|
+
*/
|
|
76
97
|
function showBlocked() {
|
|
77
98
|
claim.blocked = true
|
|
78
99
|
if (boot === null) { resolveClaim(false); return }
|
|
79
100
|
boot.textContent = ''
|
|
80
101
|
var text = document.createElement('div')
|
|
81
|
-
text.textContent = 'RIS-IDE
|
|
102
|
+
text.textContent = 'RIS-IDE 已在另一个窗口打开(一个工作空间只保留一个窗口)。'
|
|
82
103
|
var row = document.createElement('div')
|
|
83
104
|
row.style.marginTop = '10px'
|
|
84
|
-
// Focusing another browser window is not reliably allowed (Chrome may ignore
|
|
85
|
-
// a background window's focus()), so the honest action is to close this
|
|
86
|
-
// duplicate: the window that holds the lock is the one to keep.
|
|
87
105
|
row.appendChild(button('关闭这个窗口', function () {
|
|
88
106
|
nudgeHolder()
|
|
89
107
|
try { window.close() } catch (error) { /* already gone */ }
|
|
90
108
|
}))
|
|
91
|
-
row.appendChild(button('
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
109
|
+
row.appendChild(button('关闭旧窗口,在这里打开', function () {
|
|
110
|
+
text.textContent = '正在关闭旧窗口…'
|
|
111
|
+
row.textContent = ''
|
|
112
|
+
try { if (channel !== null) channel.postMessage({ type: 'close' }) } catch (error) { /* closed */ }
|
|
113
|
+
takeover()
|
|
96
114
|
}))
|
|
97
115
|
boot.appendChild(text)
|
|
98
116
|
boot.appendChild(row)
|
|
99
117
|
resolveClaim(false)
|
|
100
118
|
}
|
|
119
|
+
/** Boot here once the old window has let go of the lock (best effort, ~2 s). */
|
|
120
|
+
function takeover() {
|
|
121
|
+
var locksNow = typeof navigator !== 'undefined' ? navigator.locks : undefined
|
|
122
|
+
var deadline = Date.now() + 2000
|
|
123
|
+
function attempt() {
|
|
124
|
+
if (locksNow === undefined || typeof locksNow.request !== 'function') {
|
|
125
|
+
// Without Web Locks there is nothing to wait for.
|
|
126
|
+
startHere()
|
|
127
|
+
return
|
|
128
|
+
}
|
|
129
|
+
locksNow.request(key, { ifAvailable: true }, function (lock) {
|
|
130
|
+
if (lock !== null) {
|
|
131
|
+
claim.blocked = false
|
|
132
|
+
startHere()
|
|
133
|
+
return new Promise(function () { /* hold the lock here instead */ })
|
|
134
|
+
}
|
|
135
|
+
if (Date.now() >= deadline) {
|
|
136
|
+
if (boot !== null) boot.textContent = '旧窗口没有关闭(可能被浏览器阻止)。请手动关掉它后重试。'
|
|
137
|
+
return undefined
|
|
138
|
+
}
|
|
139
|
+
setTimeout(attempt, 150)
|
|
140
|
+
return undefined
|
|
141
|
+
}).catch(function () {
|
|
142
|
+
if (Date.now() >= deadline) return
|
|
143
|
+
setTimeout(attempt, 150)
|
|
144
|
+
})
|
|
145
|
+
}
|
|
146
|
+
attempt()
|
|
147
|
+
}
|
|
148
|
+
function startHere() {
|
|
149
|
+
claim.blocked = false
|
|
150
|
+
// The window that ends up running is the one that must hear "close"/"focus":
|
|
151
|
+
// installing the hooks here covers every route that boots a window (first
|
|
152
|
+
// claim, manual takeover, no-Web-Locks probe) - the old window's hooks die
|
|
153
|
+
// with it, so the NEW window has to carry them.
|
|
154
|
+
becomeHolder()
|
|
155
|
+
if (boot !== null) boot.textContent = '正在加载 RIS-IDE…'
|
|
156
|
+
if (typeof window.__risIdeBootPanel === 'function') window.__risIdeBootPanel()
|
|
157
|
+
}
|
|
158
|
+
/** The DSH page asked us to make room for a fresh window: close ourselves. */
|
|
159
|
+
function closeForOpener() {
|
|
160
|
+
try { window.close() } catch (error) { /* already gone */ }
|
|
161
|
+
}
|
|
101
162
|
function becomeHolder() {
|
|
102
163
|
if (channel === null) return
|
|
103
164
|
channel.onmessage = function (event) {
|
|
104
165
|
var data = event !== null && event !== undefined ? event.data : null
|
|
105
|
-
if (data
|
|
106
|
-
|
|
107
|
-
|
|
166
|
+
if (data === null || typeof data !== 'object') return
|
|
167
|
+
if (data.type === 'focus') answerFocus()
|
|
168
|
+
else if (data.type === 'close') closeForOpener()
|
|
108
169
|
}
|
|
109
170
|
}
|
|
110
171
|
var locks = typeof navigator !== 'undefined' ? navigator.locks : undefined
|
|
@@ -118,6 +179,7 @@
|
|
|
118
179
|
// moment; retry with a short backoff before declaring a second window.
|
|
119
180
|
if (attempt < 5) { setTimeout(tryClaim, 120 * attempt); return undefined }
|
|
120
181
|
showBlocked()
|
|
182
|
+
becomeHolder()
|
|
121
183
|
return undefined
|
|
122
184
|
}
|
|
123
185
|
becomeHolder()
|
|
@@ -126,7 +188,7 @@
|
|
|
126
188
|
return new Promise(function () { /* never resolves */ })
|
|
127
189
|
}).catch(function () {
|
|
128
190
|
if (attempt < 5) setTimeout(tryClaim, 120 * attempt)
|
|
129
|
-
else showBlocked()
|
|
191
|
+
else { showBlocked(); becomeHolder() }
|
|
130
192
|
})
|
|
131
193
|
}
|
|
132
194
|
tryClaim()
|
|
@@ -138,6 +200,16 @@
|
|
|
138
200
|
channel.onmessage = function (event) {
|
|
139
201
|
var data = event !== null && event !== undefined ? event.data : null
|
|
140
202
|
if (data === null || typeof data !== 'object') return
|
|
203
|
+
if (data.type === 'close') {
|
|
204
|
+
// The DSH page wants a fresh window: close ourselves to free the slot.
|
|
205
|
+
closeForOpener()
|
|
206
|
+
return
|
|
207
|
+
}
|
|
208
|
+
if (data.type === 'focus') {
|
|
209
|
+
// The DSH page found us in the host registry and asked us to come forward.
|
|
210
|
+
answerFocus()
|
|
211
|
+
return
|
|
212
|
+
}
|
|
141
213
|
if (data.type === 'ping') {
|
|
142
214
|
try { channel.postMessage({ type: 'pong' }) } catch (error) { /* ignore */ }
|
|
143
215
|
try { window.focus() } catch (error) { /* ignore */ }
|
|
@@ -217,6 +289,9 @@
|
|
|
217
289
|
cwd: cwd,
|
|
218
290
|
programId: programId,
|
|
219
291
|
debug: debug,
|
|
292
|
+
// Same name the DSH page computes for this workspace: the stream registers
|
|
293
|
+
// under it, and `window.open('', name)` finds this very window.
|
|
294
|
+
windowName: params.get('wname') || '',
|
|
220
295
|
})).then(function () {
|
|
221
296
|
// The panel paints itself; drop the loading overlay so it cannot swallow clicks.
|
|
222
297
|
boot.style.display = 'none'
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-ris-ide",
|
|
3
|
-
"version": "1.7.
|
|
3
|
+
"version": "1.7.2",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "RIS-IDE local dev panel for the DSH web GUI: live log tail, one-click start/stop of workspace programs, JDWP debugging, file tree + editor, and a standalone IDE window that carries no session history. · DSH 右侧栏本地开发面板:日志实时跟随、一键启停本地程序、Java 断点调试、文件树与编辑器、独立 IDE 窗口。",
|
|
6
6
|
"keywords": [
|
|
@@ -6,7 +6,7 @@ description: "用 ris_dev_* 工具操作本机 RIS-IDE/侧边栏开发面板:
|
|
|
6
6
|
# RIS-IDE 调试技能(dsh-ris-ide-debug)
|
|
7
7
|
|
|
8
8
|
> 这套命令由 `dsh-ris-ide` 插件注册,和侧边栏「RIS-IDE」面板**同一套扫描/启停/调试内核**。
|
|
9
|
-
> 你只能**选程序**(`id` / `name` / `path`),**永远不传命令**:启动命令由宿主按工作区内容(pom / package.json / `.dsh-ris-ide.json`)自己拼。
|
|
9
|
+
> 你只能**选程序**(`id` / `name` / `path`),**永远不传命令**:启动命令由宿主按工作区内容(pom / package.json / `.dsh-ris-ide/config.json`)自己拼。
|
|
10
10
|
|
|
11
11
|
## 0. 铁律(先读,避免踩坑)
|
|
12
12
|
|
|
@@ -127,7 +127,7 @@ ris_dev_stop { "name": "<program>" } # 真要停服
|
|
|
127
127
|
- 侧边栏「RIS-IDE」tab:左上是工作空间目录树(整个 cwd,点文件即打开)、左下控制台(每个程序的 `▶ / ■ / 🐞 / ▤` = start / stop / debug / logs),右上是源码(**打开即可编辑**,`Ctrl/Cmd+S` 保存,未保存页签带 `*`,关闭会提示保存;源码用侧边栏渲染器,Java 有语法高亮),右下是调试 + 实时日志。
|
|
128
128
|
- 调试区工具行:`🐞 ⏹ ⏸ ⏵ ⤵ ⤷ ⤴ ⟳ ⊟`,分别对应 start / stop / pause / resume / step(over/into/out) / poll / 折叠。
|
|
129
129
|
- 源码左侧细栏是**断点栏**:双击加断点、点红点删断点(追加/删除的就是 `breakpoint_add` / `breakpoint_remove`)。
|
|
130
|
-
- 顶栏显示**工作空间路径**、检索框、`📄` 打开 `.dsh-ris-ide.json`、`⚙` 生成/更新配置、`⟲` 还原布局尺寸。
|
|
130
|
+
- 顶栏显示**工作空间路径**、检索框、`📄` 打开 `.dsh-ris-ide/config.json`、`⚙` 生成/更新配置、`⟲` 还原布局尺寸。
|
|
131
131
|
|
|
132
132
|
## 5. 用户问「怎么装这个技能」时
|
|
133
133
|
|