dsh-chat-embed 0.6.11 → 0.6.12
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 +1 -0
- package/client.js +60 -14
- package/docs/architecture.md +1 -1
- package/docs/publishing.md +3 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -330,6 +330,7 @@ node scripts/release.mjs 0.6.7 --summary "..." --dry-run # 只看计划
|
|
|
330
330
|
|
|
331
331
|
| 版本 | 变化 |
|
|
332
332
|
| --- | --- |
|
|
333
|
+
| `0.6.12` | 修掉同一页面每次挂载加载两三次的问题:navigateGuest 每 350ms 重发 location.href,而 getURL() 在提交前一直是 about:blank,第二次赋值取消了正在进行的加载;改为加载中只等不重发,上限从 5 次尝试改为 20 秒期限(慢站点以前会直接判定失败)。另加 guest mounted / guest dropped 诊断日志 |
|
|
333
334
|
| `0.6.11` | 补丁前的可写性判断从「不要尝试写入」改为「先执行,真被系统拒绝再给提权命令」:access(W_OK) 在 Windows 上可能误判,不该据此跳过尝试;并说明 DSH 授权弹窗与 Windows 提权是两条不同的闸 |
|
|
334
335
|
| `0.6.10` | 修好「重启保持登录」整条链路:开关不再因 ctx 作用域错误静默失败、变成可双向切换(开启/还原)、设置菜单两行合一、预填任务说明重写;Host 半补上 inject 依赖,探针路由与 agent 工具终于生效 |
|
|
335
336
|
| `0.6.9` | 设置菜单把「跨重启保持登录」与「检查补丁配置」合成一行(滑动开关 + 确认弹窗 + 新会话引导);发版改用 OIDC Trusted Publishing,不再保存 npm 令牌,并附带 provenance |
|
package/client.js
CHANGED
|
@@ -115,7 +115,7 @@ window.__ModuleLoader__.load({
|
|
|
115
115
|
let activeCtx = undefined
|
|
116
116
|
|
|
117
117
|
/** Build identity, surfaced in the panel so a packaged app can be diagnosed. */
|
|
118
|
-
const BUILD = '0.6.
|
|
118
|
+
const BUILD = '0.6.12'
|
|
119
119
|
|
|
120
120
|
/** Where a re-applied instance finds the one it must take over from. */
|
|
121
121
|
const INSTANCE_KEY = '__DSH_CHAT_EMBED_INSTANCE__'
|
|
@@ -210,6 +210,8 @@ let activeCtx = undefined
|
|
|
210
210
|
/** The first `dom-ready` can beat the shell's lease registration. */
|
|
211
211
|
const NAVIGATE_RETRY_MS = 350
|
|
212
212
|
const NAVIGATE_MAX_ATTEMPTS = 5
|
|
213
|
+
/** How long a mount may wait for the site to commit before failing. */
|
|
214
|
+
const NAVIGATE_TIMEOUT_MS = 20000
|
|
213
215
|
|
|
214
216
|
/**
|
|
215
217
|
* How long to wait after an OAuth roundtrip lands back on the site before
|
|
@@ -1167,7 +1169,11 @@ let activeCtx = undefined
|
|
|
1167
1169
|
}
|
|
1168
1170
|
|
|
1169
1171
|
/** @param {GuestRecord} record */
|
|
1170
|
-
|
|
1172
|
+
/**
|
|
1173
|
+
* @param {GuestRecord} record
|
|
1174
|
+
* @param {string} [reason] why this guest is being torn down
|
|
1175
|
+
*/
|
|
1176
|
+
function dropGuest(record, reason) {
|
|
1171
1177
|
const element = record.element
|
|
1172
1178
|
const lease = record.lease
|
|
1173
1179
|
const handlers = record.handlers
|
|
@@ -1187,6 +1193,12 @@ let activeCtx = undefined
|
|
|
1187
1193
|
// `oauthBlocked` is deliberately kept: the explanation must survive the
|
|
1188
1194
|
// recovery reload that replaces the stuck guest.
|
|
1189
1195
|
|
|
1196
|
+
if (element !== undefined && element !== null) {
|
|
1197
|
+
let owner = 'unknown'
|
|
1198
|
+
for (const [id, candidate] of guests) if (candidate === record) owner = id
|
|
1199
|
+
log('info', 'guest dropped', { provider: owner, reason: reason === undefined ? 'unspecified' : reason })
|
|
1200
|
+
}
|
|
1201
|
+
|
|
1190
1202
|
if (record.reloadTimer !== undefined) {
|
|
1191
1203
|
try {
|
|
1192
1204
|
clearTimeout(record.reloadTimer)
|
|
@@ -1266,6 +1278,24 @@ let activeCtx = undefined
|
|
|
1266
1278
|
}
|
|
1267
1279
|
}
|
|
1268
1280
|
|
|
1281
|
+
/**
|
|
1282
|
+
* Whether the guest is still loading a document.
|
|
1283
|
+
*
|
|
1284
|
+
* `location.href` must not be reassigned while this is true: a second assign
|
|
1285
|
+
* cancels the navigation in flight and the page starts from zero.
|
|
1286
|
+
*
|
|
1287
|
+
* @param {any} element
|
|
1288
|
+
* @returns {boolean | undefined} undefined when the shell offers no answer
|
|
1289
|
+
*/
|
|
1290
|
+
function guestLoading(element) {
|
|
1291
|
+
if (element === undefined || element === null || typeof element.isLoading !== 'function') return undefined
|
|
1292
|
+
try {
|
|
1293
|
+
return element.isLoading() === true
|
|
1294
|
+
} catch (error) {
|
|
1295
|
+
return undefined
|
|
1296
|
+
}
|
|
1297
|
+
}
|
|
1298
|
+
|
|
1269
1299
|
/** @param {object} provider */
|
|
1270
1300
|
function layerFor(provider) {
|
|
1271
1301
|
const record = guestRecord(provider.id)
|
|
@@ -1383,6 +1413,9 @@ let activeCtx = undefined
|
|
|
1383
1413
|
record.navigated = false
|
|
1384
1414
|
record.handlers = handlers
|
|
1385
1415
|
record.mounts += 1
|
|
1416
|
+
// A mount is a fresh document load. Printing the count makes "one page
|
|
1417
|
+
// in the tab" distinguishable from "the tab was rebuilt" in the ring.
|
|
1418
|
+
log('info', 'guest mounted', { provider: id, mount: record.mounts })
|
|
1386
1419
|
|
|
1387
1420
|
try {
|
|
1388
1421
|
layer.appendChild(element)
|
|
@@ -1423,22 +1456,34 @@ let activeCtx = undefined
|
|
|
1423
1456
|
const provider = findProvider(id)
|
|
1424
1457
|
if (provider === undefined) return
|
|
1425
1458
|
const record = guestRecord(id)
|
|
1459
|
+
const target = startUrlFor(provider)
|
|
1460
|
+
const deadline = Date.now() + NAVIGATE_TIMEOUT_MS
|
|
1461
|
+
let issued = 0
|
|
1426
1462
|
|
|
1427
|
-
|
|
1428
|
-
if (element !== record.element) return
|
|
1429
|
-
try {
|
|
1430
|
-
await element.executeJavaScript('location.href = ' + JSON.stringify(startUrlFor(provider)) + ';')
|
|
1431
|
-
} catch (error) {
|
|
1432
|
-
// The guest document is not executing yet; keep trying.
|
|
1433
|
-
}
|
|
1434
|
-
await delay(NAVIGATE_RETRY_MS)
|
|
1463
|
+
while (Date.now() < deadline) {
|
|
1435
1464
|
if (element !== record.element) return
|
|
1436
1465
|
const landed = guestUrl(element)
|
|
1437
1466
|
if (isLiveUrl(landed)) {
|
|
1438
|
-
if (
|
|
1467
|
+
if (landed !== '') lastUrls.set(id, landed)
|
|
1439
1468
|
setPhase(id, PHASE.READY, '')
|
|
1440
1469
|
return
|
|
1441
1470
|
}
|
|
1471
|
+
const loading = guestLoading(element)
|
|
1472
|
+
// Assigning location.href while a navigation is already running cancels
|
|
1473
|
+
// it and starts over: that is what made every mount load the page two or
|
|
1474
|
+
// three times. Wait for the one in flight instead of restarting it.
|
|
1475
|
+
if (loading === true) {
|
|
1476
|
+
await delay(NAVIGATE_RETRY_MS)
|
|
1477
|
+
continue
|
|
1478
|
+
}
|
|
1479
|
+
if (issued >= NAVIGATE_MAX_ATTEMPTS) break
|
|
1480
|
+
issued += 1
|
|
1481
|
+
try {
|
|
1482
|
+
await element.executeJavaScript('location.href = ' + JSON.stringify(target) + ';')
|
|
1483
|
+
} catch (error) {
|
|
1484
|
+
// The guest document is not executing yet; keep trying.
|
|
1485
|
+
}
|
|
1486
|
+
await delay(NAVIGATE_RETRY_MS)
|
|
1442
1487
|
}
|
|
1443
1488
|
if (element !== record.element) return
|
|
1444
1489
|
setPhase(id, PHASE.FAILED, 'navigation-timeout')
|
|
@@ -1735,10 +1780,11 @@ let activeCtx = undefined
|
|
|
1735
1780
|
await mountGuest(id)
|
|
1736
1781
|
}
|
|
1737
1782
|
/** Release every guest; used on plugin unload. */
|
|
1738
|
-
|
|
1783
|
+
/** @param {string} [reason] */
|
|
1784
|
+
function destroyGuests(reason) {
|
|
1739
1785
|
for (const [id, record] of guests) {
|
|
1740
1786
|
record.generation += 1
|
|
1741
|
-
dropGuest(record)
|
|
1787
|
+
dropGuest(record, reason)
|
|
1742
1788
|
setPhase(id, PHASE.IDLE, '')
|
|
1743
1789
|
if (record.layer !== undefined && record.layer !== null) {
|
|
1744
1790
|
try {
|
|
@@ -1856,7 +1902,7 @@ let activeCtx = undefined
|
|
|
1856
1902
|
const chosen = seat === undefined ? null : inlineHosts[seat]
|
|
1857
1903
|
if (chosen !== state.surface.host) log('info', 'host resolved', { seat: seat === undefined ? 'none' : seat })
|
|
1858
1904
|
setHost(chosen)
|
|
1859
|
-
if (chosen === null) destroyGuests()
|
|
1905
|
+
if (chosen === null) destroyGuests('no viewport')
|
|
1860
1906
|
else {
|
|
1861
1907
|
dropGuestsOutside(chosen)
|
|
1862
1908
|
void ensureActiveGuest()
|
package/docs/architecture.md
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
本文记录 `client.js` 里每一条**反直觉**的实现决策、支撑它的证据,以及升级桌面壳时必须重新验证的清单。
|
|
4
4
|
|
|
5
5
|
目标运行环境:**`@deepseek-ai/dsh-desktop 0.2.2-rc.1`(Electron / Chromium)**。
|
|
6
|
-
当前实现:**v0.6.
|
|
6
|
+
当前实现:**v0.6.12**(`client.js` 约 3985 行,85 项契约测试)。
|
|
7
7
|
|
|
8
8
|
> **架构一句话**:聊天页直接渲染在**席位的布局盒**里(`.dce-panel.dce-inline`,`width/height:100%`),几何完全交给 CSS;席位只有两个 —— 中央主面板(`main`)和右栏聊天 tab —— 二者互斥,**哪边点哪边接管**,切换时 guest 重建一次并回到上次会话。
|
|
9
9
|
|
package/docs/publishing.md
CHANGED
|
@@ -137,8 +137,8 @@ Get-FileHash $env:TEMP\check\dsh-chat-embed-<版本>.tgz -Algorithm SHA256
|
|
|
137
137
|
| --- | --- |
|
|
138
138
|
| 仓库 | <https://github.com/poluce/dsh-chat-embed> |
|
|
139
139
|
| Release | <https://github.com/poluce/dsh-chat-embed/releases> |
|
|
140
|
-
| 分发包 | `dsh-chat-embed-0.6.
|
|
141
|
-
| npm | `dsh-chat-embed@0.6.
|
|
140
|
+
| 分发包 | `dsh-chat-embed-0.6.12.tgz`(16 个文件,约 70 kB) |
|
|
141
|
+
| npm | `dsh-chat-embed@0.6.12`(<https://www.npmjs.com/package/dsh-chat-embed>,维护者 `poluce_auto`) |
|
|
142
142
|
| 商店图标 | `assets/icon-180.png`(180×180 PNG) |
|
|
143
143
|
| 商店截图 | `assets/screenshots/` + 仓库根 `screenshots.json`(6 张) |
|
|
144
144
|
|
|
@@ -157,7 +157,7 @@ dsh plugin --profile desktop add git+https://github.com/poluce/dsh-chat-embed.gi
|
|
|
157
157
|
|
|
158
158
|
1. 注册账号并完成邮箱验证:<https://www.npmjs.com/signup>;
|
|
159
159
|
2. 本机登录:`npm login`(浏览器确认或一次性密码;开了 2FA 输入验证码);
|
|
160
|
-
3. 发布:`npm publish`(`prepack` 自动跑门禁;包名 `dsh-chat-embed` 已发布 `0.6.
|
|
160
|
+
3. 发布:`npm publish`(`prepack` 自动跑门禁;包名 `dsh-chat-embed` 已发布 `0.6.12`);
|
|
161
161
|
4. 使用者随后只需:`dsh plugin --profile desktop add dsh-chat-embed`。
|
|
162
162
|
|
|
163
163
|
## 发布前后检查项
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-chat-embed",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.12",
|
|
4
4
|
"author": "poluce <fishsummer@126.com>",
|
|
5
5
|
"description": "Multi-tab AI chat embed for the DeepSeek Harness desktop app: DeepSeek, 豆包, ChatGPT, MiniMax, Kimi, Gemini and Grok, each signed in separately.",
|
|
6
6
|
"type": "module",
|