dsh-code-server-app 0.1.17 → 0.1.20

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 ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 jinsiyu
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
@@ -116,10 +116,11 @@ host 探测顺序:`<profile>\.code-server-app`(专用目录)> 插件包内 `node
116
116
  | 键 | 默认 | 说明 |
117
117
  |---|---|---|
118
118
  | `reserveComposer` | `true` | 窗口是否**保留输入框上方空间**:开启时窗口初始/拖动/缩放/最大化都止于输入栏上方(不遮挡 composer);关闭后允许盖住输入框(最大化到视口底) |
119
+ | `windowedOpen` | `false` | **窗口化打开**:开启后点击悬浮球在浏览器**新标签页**打开 code-server(自动启动并跟随当前工作区目录);关闭(默认)使用内部浮动窗口 |
119
120
 
120
- > 卡片改动经 `scope.watch` 实时生效(host 端 status API 同步返回 `reserveComposer`,
121
- > 客户端窗口立即重新 fit);无需重启 dsh。首次使用前需 **重启 dsh web** 让 host
122
- > 注册该设置命名空间(静态插件行加载)
121
+ > 卡片改动经 `scope.watch` 实时生效(host 端 status API 同步返回 `reserveComposer` 与
122
+ > `windowedOpen`,客户端立即生效);无需重启 dsh。**新增设置键后首次使用前需重启 dsh web**,
123
+ > 让 host 重新注册设置命名空间(schema 含新键),否则新键的保存与校验不生效。
123
124
 
124
125
  ## 配置(cordis.patch.yml 的 `config`,均有默认值)
125
126
 
@@ -0,0 +1,61 @@
1
+ // dshcs-open-file:DSH host 通过信号文件请求打开文件。
2
+ // host 写入 <user-data>/User/dshcs-open.json 后,本扩展在已连接的窗口中打开该文件。
3
+ // 信号路径优先取环境变量 DSHCS_OPEN_FILE_SIGNAL(host 注入);
4
+ // 取不到时用 context.globalStorageUri 推导(=<user-data>/User/globalStorage/<id> 的上两级)。
5
+ const fs = require('fs');
6
+ const vscode = require('vscode');
7
+
8
+ function signalPath(context) {
9
+ const envP = process.env.DSHCS_OPEN_FILE_SIGNAL;
10
+ if (typeof envP === 'string' && envP !== '') return envP;
11
+ try {
12
+ const user = vscode.Uri.joinPath(context.globalStorageUri, '..', '..');
13
+ return vscode.Uri.joinPath(user, 'dshcs-open.json').fsPath;
14
+ } catch {
15
+ return null;
16
+ }
17
+ }
18
+
19
+ let timer = null;
20
+ function processSignal(signal) {
21
+ let raw;
22
+ try {
23
+ raw = fs.readFileSync(signal, 'utf8');
24
+ } catch {
25
+ return; // 尚无信号
26
+ }
27
+ let file = null;
28
+ try {
29
+ file = JSON.parse(raw).file;
30
+ } catch {
31
+ return;
32
+ }
33
+ if (typeof file !== 'string' || file === '') return;
34
+ const uri = vscode.Uri.file(file);
35
+ vscode.window.showTextDocument(uri, { preview: false }).then(
36
+ () => {
37
+ try {
38
+ fs.unlinkSync(signal);
39
+ } catch {}
40
+ },
41
+ (err) => {
42
+ // 尚未有窗口连接(或打开失败):保留信号,轮询会重试
43
+ console.log('[dshcs-open-file] open failed, will retry:', err && err.message ? err.message : String(err));
44
+ },
45
+ );
46
+ }
47
+
48
+ function activate(context) {
49
+ const signal = signalPath(context);
50
+ if (signal === null) {
51
+ console.log('[dshcs-open-file] no signal path (env/globalStorage both unavailable)');
52
+ return;
53
+ }
54
+ console.log('[dshcs-open-file] watching ' + signal);
55
+ // 启动先处理一次,随后每 800ms 轮询(信号可能由 host 晚些写入)
56
+ processSignal(signal);
57
+ timer = setInterval(function () { processSignal(signal); }, 800);
58
+ context.subscriptions.push({ dispose: function () { clearInterval(timer); } });
59
+ }
60
+
61
+ exports.activate = activate;
@@ -0,0 +1,14 @@
1
+ {
2
+ "name": "dshcs-open-file",
3
+ "displayName": "DSH Code Server Open File",
4
+ "description": "Opens files requested by the DSH host through a signal file (dshcs-open.json).",
5
+ "version": "0.0.1",
6
+ "publisher": "dsh-code-server-app",
7
+ "engines": {
8
+ "vscode": "^1.80.0"
9
+ },
10
+ "activationEvents": [
11
+ "onStartupFinished"
12
+ ],
13
+ "main": "./extension.js"
14
+ }
Binary file
@@ -0,0 +1,4 @@
1
+ <svg width="100%" height="100%" viewBox="0 0 147 147" xmlns="http://www.w3.org/2000/svg">
2
+ <style>@media (prefers-color-scheme: dark) {* { fill: white; }}</style>
3
+ <path d="m42.4214,39.655c-24.4057,0 -42.1554,13.1721 -42.1554,33.845c0,20.5814 18.4892,33.845 42.1554,33.845c23.6662,0 38.1803,-11.6171 38.7349,-28.7225l-21.0777,-0.4574c-0.9244,9.3303 -9.1059,15.1845 -17.6572,15.1845c-11.7406,0 -20.4306,-7.5922 -20.4306,-19.8496c0,-12.2574 8.69,-19.9868 20.4306,-20.2155c8.5513,-0.183 16.9177,5.9457 17.4723,15.276l21.0777,-0.6403c-0.4622,-16.8311 -14.1442,-28.2652 -38.55,-28.2652zm48.8446,2l55.468,0l0,64.0311l-55.468,0l0,-64.0311z" clip-rule="evenodd" fill-rule="evenodd"/>
4
+ </svg>