dsh-remote-plugin 0.7.3 → 0.7.4
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/apk/dsh-remote.apk +0 -0
- package/gateway.cjs +144 -76
- package/index.mjs +24 -9
- package/package.json +1 -1
- package/public/admin.js +15 -2
- package/public/app.js +161 -71
- package/public/desktop/desktop.html +8 -2
- package/public/desktop/desktop.js +188 -77
- package/public/history.js +11 -4
- package/public/index.html +1 -0
- package/public/network.js +56 -0
- package/public/plugin.js +8 -1
- package/public/update.json +8 -8
- package/public/version.json +1 -1
package/public/history.js
CHANGED
|
@@ -15,6 +15,13 @@
|
|
|
15
15
|
}
|
|
16
16
|
return [...next.values()].sort((a,b) => a.seq-b.seq)
|
|
17
17
|
}
|
|
18
|
+
function insertSorted(entries, entry) {
|
|
19
|
+
if (!entries.length || entries[entries.length-1].seq < entry.seq) { entries.push(entry); return }
|
|
20
|
+
let low=0,high=entries.length
|
|
21
|
+
while(low<high){const middle=(low+high)>>>1;if(entries[middle].seq<entry.seq)low=middle+1;else high=middle}
|
|
22
|
+
if(entries[low]?.seq===entry.seq)entries[low]=entry
|
|
23
|
+
else entries.splice(low,0,entry)
|
|
24
|
+
}
|
|
18
25
|
class HistoryView {
|
|
19
26
|
constructor(box, options) {
|
|
20
27
|
this.box=box; this.options=options; this.entries=[]; this.start=0; this.end=0; this.nodes=new Map(); this.reading=false; this.suppress=false; this.frame=0; this.pendingOlder=false
|
|
@@ -35,11 +42,11 @@
|
|
|
35
42
|
return null
|
|
36
43
|
}
|
|
37
44
|
set(entries, {reset=false, follow=false, live='', hasMore=false, loading=false, emptyLabel=''}={}) {
|
|
38
|
-
if(!reset&&entries.length===this.entries.length&&entries.every((entry,i)=>entry===this.entries[i])&&hasMore===this.hasMore&&loading===this.loading&&(this.end===entries.length?live:'')===this.liveHtml){this.
|
|
45
|
+
if(!reset&&entries.length===this.entries.length&&entries.every((entry,i)=>entry===this.entries[i])&&hasMore===this.hasMore&&loading===this.loading&&(this.end===entries.length?live:'')===this.liveHtml){this.more.disabled=loading;this.more.textContent=loading?this.options.loadingLabel():this.options.olderLabel();this.domChanged=false;this.options.changed?.(this);return}
|
|
39
46
|
if(Date.now()<this.intentUntil)this.reading=this.box.scrollHeight-this.box.scrollTop-this.box.clientHeight>=180
|
|
40
47
|
const oldWidth=this.end-this.start
|
|
41
48
|
const anchor=this.anchor(), oldStart=this.entries[this.start]?.seq, oldEnd=this.entries[Math.max(this.start,this.end-1)]?.seq
|
|
42
|
-
this.entries=entries; this.hasMore=hasMore; this.loading=loading
|
|
49
|
+
this.entries=entries.slice(); this.hasMore=hasMore; this.loading=loading
|
|
43
50
|
if(reset || !this.end){this.end=entries.length;this.start=Math.max(0,this.end-WINDOW_SIZE);this.reading=false}
|
|
44
51
|
else if((follow || !this.reading) && this.end>=this.previousLength){this.end=entries.length;this.start=Math.max(0,this.end-WINDOW_SIZE)}
|
|
45
52
|
else {
|
|
@@ -154,7 +161,7 @@
|
|
|
154
161
|
}
|
|
155
162
|
async function cacheRemove(scope,id) {const key=cacheKey(scope,id);try{localStorage.removeItem(key)}catch{};const db=await openDatabase();if(db)try{db.transaction('history','readwrite').objectStore('history').delete(key)}catch{}}
|
|
156
163
|
async function cacheClear() {cacheEpoch++;try{for(const key of Object.keys(localStorage))if(key.includes(':session:')||key.endsWith(':cache-index')||/^(history|sessions)Cache/.test(key))localStorage.removeItem(key)}catch{};const db=await openDatabase();if(db)await new Promise(resolve=>{try{const tx=db.transaction('history','readwrite');tx.objectStore('history').clear();tx.oncomplete=tx.onabort=tx.onerror=()=>resolve()}catch{resolve()}})}
|
|
157
|
-
const api={HistoryView,reconcile,signature,cacheLoad,cacheSave,cacheRemove,cacheClear,decodeLegacy,WINDOW_SIZE}
|
|
164
|
+
const api={HistoryView,reconcile,insertSorted,signature,cacheLoad,cacheSave,cacheRemove,cacheClear,decodeLegacy,WINDOW_SIZE}
|
|
158
165
|
if(typeof module!=='undefined'&&module.exports)module.exports=api
|
|
159
166
|
else root.DshHistory=api
|
|
160
|
-
})(typeof window==='undefined'?globalThis:window)
|
|
167
|
+
})(typeof window==='undefined'?globalThis:window)
|
package/public/index.html
CHANGED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/* Small transport policy and independent fallback channels. No dependencies. */
|
|
2
|
+
'use strict';
|
|
3
|
+
;(function(root){
|
|
4
|
+
let measuredLatency=0
|
|
5
|
+
function mode(){try{return ['auto','weak','normal'].includes(root.localStorage.getItem('dshNetworkModeV1'))?root.localStorage.getItem('dshNetworkModeV1'):'auto'}catch{return 'auto'}}
|
|
6
|
+
function profile(){
|
|
7
|
+
const selected=mode(),connection=root.navigator?.connection
|
|
8
|
+
const weak=selected==='weak'||selected==='auto'&&(!!connection?.saveData||/^(slow-2g|2g|3g)$/.test(connection?.effectiveType||'')||connection?.rtt>=500||connection?.downlink>0&&connection.downlink<0.8||measuredLatency>=800)
|
|
9
|
+
return {weak,historyPageSize:weak?20:60,readTimeout:weak?90000:45000,pingTimeout:weak?12000:6000,pollTimeout:weak?45000:30000}
|
|
10
|
+
}
|
|
11
|
+
function setMode(value){if(!['auto','weak','normal'].includes(value))return;try{root.localStorage.setItem('dshNetworkModeV1',value)}catch{};return profile()}
|
|
12
|
+
class PollLoop {
|
|
13
|
+
constructor(options){this.options=options;this.jobs={};this.setTimer=options.setTimer||setTimeout;this.clearTimer=options.clearTimer||clearTimeout}
|
|
14
|
+
stop(){for(const job of Object.values(this.jobs)){job.controller.abort();this.clearTimer(job.timer)}this.jobs={}}
|
|
15
|
+
tick(){
|
|
16
|
+
if(!this.options.active()){this.stop();return Promise.resolve()}
|
|
17
|
+
const pending=[]
|
|
18
|
+
for(const kind of ['mux','host']){
|
|
19
|
+
const previous=this.jobs[kind]
|
|
20
|
+
if(previous?.identity.valid())continue
|
|
21
|
+
previous?.controller.abort();this.clearTimer(previous?.timer)
|
|
22
|
+
const job={identity:this.options.capture(),controller:new AbortController(),failures:0}
|
|
23
|
+
this.jobs[kind]=job;pending.push(this.run(kind,job))
|
|
24
|
+
}
|
|
25
|
+
return Promise.all(pending)
|
|
26
|
+
}
|
|
27
|
+
async run(kind,job){
|
|
28
|
+
let delay
|
|
29
|
+
try{delay=await this.options.read(kind,job.controller.signal)}catch{}
|
|
30
|
+
if(this.jobs[kind]!==job||!job.identity.valid()||!this.options.active()||job.controller.signal.aborted)return
|
|
31
|
+
if(Number.isFinite(delay)){job.failures=0;delay=Math.max(100,delay)}
|
|
32
|
+
else{job.failures++;delay=Math.min(30000,4000*2**Math.min(job.failures-1,3))}
|
|
33
|
+
job.timer=this.setTimer(()=>{job.timer=null;if(this.jobs[kind]===job&&job.identity.valid()&&this.options.active())void this.run(kind,job)},delay)
|
|
34
|
+
job.timer?.unref?.()
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
function preferences(){
|
|
38
|
+
const panel=root.document?.getElementById('settings-page-general');if(!panel)return
|
|
39
|
+
let row=root.document.getElementById('network-preferences')
|
|
40
|
+
if(!row){
|
|
41
|
+
row=root.document.createElement('div');row.id='network-preferences';row.className=panel.classList.contains('ds-settings')?'ds-setting-row':'setting-row'
|
|
42
|
+
const copy=root.document.createElement('div'),title=root.document.createElement('div'),detail=root.document.createElement('div'),select=root.document.createElement('select')
|
|
43
|
+
title.dataset.networkTitle='';detail.dataset.networkDetail='';detail.className='muted';select.id='network-mode';select.className='setting-select'
|
|
44
|
+
for(const value of ['auto','weak','normal']){const option=root.document.createElement('option');option.value=value;select.append(option)}
|
|
45
|
+
copy.append(title,detail);row.append(copy,select);panel.append(row)
|
|
46
|
+
select.addEventListener('change',()=>{setMode(select.value);root.enhanceCustomSelect?.(select)})
|
|
47
|
+
}
|
|
48
|
+
const english=root.I18N?.lang==='en'
|
|
49
|
+
row.querySelector('[data-network-title]').textContent=english?'Network mode':'网络模式'
|
|
50
|
+
row.querySelector('[data-network-detail]').textContent=english?'Weak mode loads fewer history entries and allows longer read waits. Sending is never retried automatically.':'弱网模式减少每页历史条数、延长读取等待;发送操作不会自动重试。'
|
|
51
|
+
const select=row.querySelector('select');select.setAttribute('aria-label',english?'Network mode':'网络模式');['auto','weak','normal'].forEach((v,i)=>select.options[i].textContent=(english?['Automatic','Weak network','Standard']:['自动判断','弱网优先','标准模式'])[i]);select.value=mode();root.enhanceCustomSelect?.(select);root.syncCustomSelect?.(select)
|
|
52
|
+
}
|
|
53
|
+
const api={profile,setMode,PollLoop,observeLatency:ms=>{if(Number.isFinite(ms))measuredLatency=ms},preferences}
|
|
54
|
+
if(typeof module!=='undefined'&&module.exports)module.exports=api
|
|
55
|
+
else{root.DshNetwork=api;root.document.addEventListener('DOMContentLoaded',()=>{preferences();new MutationObserver(preferences).observe(root.document.documentElement,{attributes:true,attributeFilter:['lang']})})}
|
|
56
|
+
})(typeof window==='undefined'?globalThis:window)
|
package/public/plugin.js
CHANGED
|
@@ -121,9 +121,16 @@ function render(st) {
|
|
|
121
121
|
$('plugin-error').classList.add('hidden')
|
|
122
122
|
}
|
|
123
123
|
|
|
124
|
+
let stateLoadPromise = null
|
|
124
125
|
async function load() {
|
|
126
|
+
if (stateLoadPromise) return stateLoadPromise
|
|
127
|
+
stateLoadPromise = readState().finally(() => { stateLoadPromise = null })
|
|
128
|
+
return stateLoadPromise
|
|
129
|
+
}
|
|
130
|
+
async function readState() {
|
|
125
131
|
try {
|
|
126
|
-
const res = await fetch(`${API}/state`, { headers: { 'x-dsh-remote-client': 'plugin' }
|
|
132
|
+
const res = await fetch(`${API}/state`, { headers: { 'x-dsh-remote-client': 'plugin' },
|
|
133
|
+
signal: typeof AbortSignal !== 'undefined' && typeof AbortSignal.timeout === 'function' ? AbortSignal.timeout(10000) : undefined })
|
|
127
134
|
if (!res.ok) throw new Error('HTTP ' + res.status)
|
|
128
135
|
render(await res.json())
|
|
129
136
|
} catch (e) {
|
package/public/update.json
CHANGED
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "0.7.
|
|
2
|
+
"version": "0.7.4",
|
|
3
3
|
"apkUrl": "dsh-remote.apk",
|
|
4
|
-
"sha256": "
|
|
5
|
-
"releasedAt": "2026-10-
|
|
6
|
-
"notes": "
|
|
4
|
+
"sha256": "f93204df1925757cbc515de583a37756073fb9d43a38479c03898526703a66cc",
|
|
5
|
+
"releasedAt": "2026-10-11T04:32:44.536Z",
|
|
6
|
+
"notes": "修复 Windows Desktop 进程核验拖慢健康检查和管理页的问题:后台缓存并合并探测,测速与首页检测使用存活检查,控制操作仍实时核验身份。修复管理代理超时误报认证失败、操作进度参数丢失、状态轮询竞态及禁用后仍探测 Desktop 崩溃日志。修复桌面对话切换时消息发错会话、压缩状态串会话、归档关闭新会话、服务器切换串用 WS 票据、同源会话导出认证、Desktop 管理页网关地址以及不同本地 IP 同号端口误判。同步修复手机端共享的票据、命令与导出逻辑。继续修复连接切换后旧模型、审批、队列和压缩状态残留,测速覆盖手动选择,新建会话跳错服务器,目标编辑串会话,以及工作台绑定和模型密钥保存串服务器。桌面发送失败保留草稿并避免重复提交。优化实时历史插入、事件列表刷新和子代理查询,修复桌面实时消息被误判无变化;连接切换可立即开始新轮询,旧结果不会覆盖新状态。加强弱网传输:历史与前端资源按需 gzip 压缩、ETag 缓存验证,双通道独立长轮询避免互相阻塞,弱网模式减少历史分页并延长只读等待;Android 后台支持 gzip。修复桌面首次连接依赖系统 prompt 的问题。Android 已完成构建,尚未手机真机验收;本次不提供 HarmonyOS HAP。",
|
|
7
7
|
"history": [
|
|
8
|
+
{
|
|
9
|
+
"version": "0.7.4",
|
|
10
|
+
"notes": "修复 Windows Desktop 进程核验拖慢健康检查和管理页的问题:后台缓存并合并探测,测速与首页检测使用存活检查,控制操作仍实时核验身份。修复管理代理超时误报认证失败、操作进度参数丢失、状态轮询竞态及禁用后仍探测 Desktop 崩溃日志。修复桌面对话切换时消息发错会话、压缩状态串会话、归档关闭新会话、服务器切换串用 WS 票据、同源会话导出认证、Desktop 管理页网关地址以及不同本地 IP 同号端口误判。同步修复手机端共享的票据、命令与导出逻辑。继续修复连接切换后旧模型、审批、队列和压缩状态残留,测速覆盖手动选择,新建会话跳错服务器,目标编辑串会话,以及工作台绑定和模型密钥保存串服务器。桌面发送失败保留草稿并避免重复提交。优化实时历史插入、事件列表刷新和子代理查询,修复桌面实时消息被误判无变化;连接切换可立即开始新轮询,旧结果不会覆盖新状态。加强弱网传输:历史与前端资源按需 gzip 压缩、ETag 缓存验证,双通道独立长轮询避免互相阻塞,弱网模式减少历史分页并延长只读等待;Android 后台支持 gzip。修复桌面首次连接依赖系统 prompt 的问题。Android 已完成构建,尚未手机真机验收;本次不提供 HarmonyOS HAP。"
|
|
11
|
+
},
|
|
8
12
|
{
|
|
9
13
|
"version": "0.7.3",
|
|
10
14
|
"notes": "修复手机对话页输入栏下方空白,标题与工作区独立显示,操作集中到更多菜单。主页系统链路自动检测和重试,新增分段仪表、拖尾扫描与平滑状态切换。对话历史先显示本地缓存,再后台核对云端内容;一致时保留消息与阅读位置,修复持续上翻导致的卡顿,隐藏无意义的标题事件。插件详情原地展开,清理重复入口,完善 DSH Desktop 插件管理。新增 Windows Desktop 远程启动与重启(实验性),以及网关、受控 DSH 与 Desktop 的限次崩溃恢复;本机轮转记录诊断日志,用户可预览并自行选择通过现有反馈通道上传摘要。加强敏感目录访问、设备权限、配对与系统备份保护,新增离线贡献者致谢,更新现有 Capacitor 至 8.5.3。Android 已完成构建与浏览器验收,尚未手机真机验收;本次不提供 HarmonyOS HAP,新增 WebUI 功能尚未同步鸿蒙。"
|
|
@@ -40,10 +44,6 @@
|
|
|
40
44
|
{
|
|
41
45
|
"version": "0.6.22",
|
|
42
46
|
"notes": "0.6.22:斜杠命令统一后台受理并显示运行状态与耗时,/compact 不再受两分钟请求等待限制;/export 可在手机保存到系统下载目录、在浏览器按下载设置保存会话 ZIP;修复命令桥接超时后被误作为普通消息发送的问题。首次有多条未读公告时改为单一分页窗口,可左右切换,确认一次即可全部标为已读。"
|
|
43
|
-
},
|
|
44
|
-
{
|
|
45
|
-
"version": "0.6.21",
|
|
46
|
-
"notes": "0.6.21:左上角 DSH Remote 名称可展开服务器组快捷切换抽屉,当前组、组内服务器数量和管理入口一目了然,手机与桌面端均可一键切换;修复部分新版 DSH 命令执行成功返回 void 时被误判为未执行、继而把 /命令作为普通文本发送的问题,同时兼容旧版三参数、新版四参数及默认参数签名。"
|
|
47
47
|
}
|
|
48
48
|
]
|
|
49
49
|
}
|
package/public/version.json
CHANGED