dsh-chat-embed 0.6.12 → 0.6.15
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 +104 -51
- package/client.js +1053 -363
- package/index.js +858 -134
- package/package.json +1 -4
- package/tools/shell-patch/shell-patch.cmd +66 -0
- package/tools/shell-patch/shell-patch.command +70 -0
- package/tools/shell-patch/shell-patch.mjs +1260 -0
- package/docs/architecture.md +0 -387
- package/docs/publishing.md +0 -188
- package/restore-shell-patch.cmd +0 -39
- package/tools/shell-patch/clean-cache.ps1 +0 -76
- package/tools/shell-patch/patch-asar.cjs +0 -272
- package/tools/shell-patch/watchdog.ps1 +0 -124
- package//346/270/205/347/220/206/350/201/212/345/244/251/347/274/223/345/255/230.cmd +0 -12
package/client.js
CHANGED
|
@@ -31,14 +31,16 @@
|
|
|
31
31
|
*
|
|
32
32
|
* Electron destroys a webview's WebContents as soon as the element leaves the
|
|
33
33
|
* DOM, and re-parenting does not help either: a move is a detach plus an
|
|
34
|
-
* attach.
|
|
35
|
-
*
|
|
36
|
-
*
|
|
34
|
+
* attach. The shell also unmounts the center panel whenever another panel is
|
|
35
|
+
* selected, so a guest that lived in that panel would be destroyed on every
|
|
36
|
+
* trip back to 「聊天」 and the status line would say 「正在打开」 again.
|
|
37
37
|
*
|
|
38
|
-
*
|
|
39
|
-
*
|
|
40
|
-
* so
|
|
41
|
-
*
|
|
38
|
+
* The two seats do not share a page. Each has its own webview. They do share
|
|
39
|
+
* a partition: both call `acquire(workspace)`, and the shell caches one
|
|
40
|
+
* partition per workspace, so a sign-in on either side is the sign-in for both.
|
|
41
|
+
* The left page lives in a park that is shown only while the chat panel is on
|
|
42
|
+
* screen. The right page lives inside the right column, so collapsing that
|
|
43
|
+
* column hides it instead of painting it over the conversation.
|
|
42
44
|
*
|
|
43
45
|
* ## Per-tab lifecycle
|
|
44
46
|
*
|
|
@@ -115,7 +117,7 @@ window.__ModuleLoader__.load({
|
|
|
115
117
|
let activeCtx = undefined
|
|
116
118
|
|
|
117
119
|
/** Build identity, surfaced in the panel so a packaged app can be diagnosed. */
|
|
118
|
-
const BUILD = '0.6.
|
|
120
|
+
const BUILD = '0.6.15'
|
|
119
121
|
|
|
120
122
|
/** Where a re-applied instance finds the one it must take over from. */
|
|
121
123
|
const INSTANCE_KEY = '__DSH_CHAT_EMBED_INSTANCE__'
|
|
@@ -276,24 +278,38 @@ let activeCtx = undefined
|
|
|
276
278
|
persistHint: 'Needs the shell patch; a plugin cannot change how the shell names partitions.',
|
|
277
279
|
persistRisk:
|
|
278
280
|
'Experimental: the patch rewrites the app.asar of the desktop shell and needs write access to its install folder. A shell update replaces it, so the patch has to be applied again.',
|
|
279
|
-
persistCheckHint: '
|
|
281
|
+
persistCheckHint: 'Click to apply the patch now; it asks you to quit DSH',
|
|
280
282
|
persistConfirmTitle: 'Turn on “login across restarts”?',
|
|
281
|
-
persistConfirmNote:
|
|
282
|
-
|
|
283
|
+
persistConfirmNote:
|
|
284
|
+
'The switch runs this script by itself. This copyable command is the fallback for when it cannot: run it, quit DSH when it says so, and it swaps the file.',
|
|
285
|
+
persistConfirmGo: 'Copy command',
|
|
283
286
|
persistConfirmCancel: 'Cancel',
|
|
284
287
|
persistOffTitle: 'Turn off "logins survive restarts"?',
|
|
285
288
|
persistOffBody: 'This removes the patch and puts the original app.asar back. Every restart will ask you to sign in again; flip the switch to undo.',
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
289
|
+
patchPending: 'Patch ready',
|
|
290
|
+
patchPendingHint:
|
|
291
|
+
'Quit DSH from the tray (right-click the tray icon → Quit). The archive is swapped and DSH reopens on its own. You do not have to quit immediately — the script waits up to 12 hours.',
|
|
292
|
+
patchNeedsAdmin: 'The install folder needs administrator rights, so it cannot run from here. Run the command below as administrator.',
|
|
293
|
+
patchNoInstall: 'No DSH desktop install was found, so there is no shell to patch. Open this panel in the desktop app.',
|
|
294
|
+
patchSame: 'Nothing to change: the shell archive is already in that state.',
|
|
295
|
+
patchNoRoute: 'This DSH build has no route for the switch yet; run the command below instead.',
|
|
296
|
+
patchStartFailed: 'The patch could not be started:',
|
|
297
|
+
patchScriptLabel: 'Script',
|
|
298
|
+
patchCommandLabel: 'Command',
|
|
299
|
+
patchScriptMissing: 'The patch script is not in this install (tools/shell-patch). The plugin may live elsewhere, or the package is incomplete.',
|
|
300
|
+
patchNoSite: 'This shell version has no patch site, so the script needs updating too; running it only reports that and changes nothing.',
|
|
301
|
+
patchRestartHint: 'Restart DSH afterwards for the change to take effect.',
|
|
302
|
+
cacheLabel: 'Cache',
|
|
303
|
+
cacheClear: 'Clear',
|
|
304
|
+
cacheClearing: 'Clearing…',
|
|
305
|
+
cacheKeepHint: 'Login across restarts is on: only disposable cache is removed. Sign-in data stays.',
|
|
306
|
+
cachePurgeHint: 'Login across restarts is off: this deletes the leftover sign-in data of these seven services.',
|
|
307
|
+
cachePurgeTitle: 'Delete leftover sign-in data?',
|
|
308
|
+
cachePurgeBody:
|
|
309
|
+
'The patch is off. This removes the seven partitions that belong to this panel, including their saved sign-ins. It does not touch DSH’s own sign-in, or any other partition.',
|
|
310
|
+
cachePurgeGo: 'Delete',
|
|
311
|
+
cacheUnavailable: 'unavailable',
|
|
312
|
+
cacheFailed: 'Could not clear:',
|
|
297
313
|
copyDiag: 'Copy diagnostics',
|
|
298
314
|
copied: 'Copied',
|
|
299
315
|
copyFailed: 'Copy failed',
|
|
@@ -370,23 +386,37 @@ let activeCtx = undefined
|
|
|
370
386
|
persistUnknown: '尚未检测',
|
|
371
387
|
persistHint: '需要桌面壳补丁;插件无法改变壳的分区命名。',
|
|
372
388
|
persistRisk: '实验性功能:补丁会改写桌面壳的 app.asar,需要安装目录的写权限;桌面壳升级会覆盖补丁,需要重新打一次。',
|
|
373
|
-
persistCheckHint: '
|
|
389
|
+
persistCheckHint: '点一下直接执行补丁,会请你退出 DSH',
|
|
374
390
|
persistConfirmTitle: '开启「重启保持登录」?',
|
|
375
|
-
persistConfirmNote:
|
|
376
|
-
|
|
391
|
+
persistConfirmNote:
|
|
392
|
+
'开关会自己运行这个脚本;只有它跑不起来时才需要下面这条命令:运行它,按提示退出 DSH,脚本会替换好文件。',
|
|
393
|
+
persistConfirmGo: '复制命令',
|
|
377
394
|
persistConfirmCancel: '取消',
|
|
378
395
|
persistOffTitle: '关闭「重启保持登录」?',
|
|
379
396
|
persistOffBody: '会撤掉补丁、恢复原版 app.asar。之后每次重启都要重新登录;想再开启,再点一次这个开关即可。',
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
397
|
+
patchPending: '补丁已就绪',
|
|
398
|
+
patchPendingHint: '请从托盘退出 DSH(右键托盘图标 →「退出」),退出后自动替换并重新打开。不必马上退出,脚本最多等 12 小时。',
|
|
399
|
+
patchNeedsAdmin: '安装目录需要管理员权限,这里没法直接执行。请以管理员身份运行下面的命令。',
|
|
400
|
+
patchNoInstall: '没有找到 DSH 桌面版安装目录,没有可以打补丁的壳。请在桌面版里打开本面板。',
|
|
401
|
+
patchSame: '不用改:桌面壳档案已经是这个状态。',
|
|
402
|
+
patchNoRoute: '这个 DSH 版本还没有提供开关用的通道;请改运行下面的命令。',
|
|
403
|
+
patchStartFailed: '没能启动补丁:',
|
|
404
|
+
patchScriptLabel: '脚本',
|
|
405
|
+
patchCommandLabel: '命令',
|
|
406
|
+
patchScriptMissing: '这个安装里找不到补丁脚本(tools/shell-patch)。插件可能装在别处,或包不完整。',
|
|
407
|
+
patchNoSite: '当前桌面壳版本里找不到补丁点,脚本也需要更新;运行它只会报告这一点,不会改动文件。',
|
|
408
|
+
patchRestartHint: '运行后请重新打开 DSH 使其生效。',
|
|
409
|
+
cacheLabel: '缓存',
|
|
410
|
+
cacheClear: '清空',
|
|
411
|
+
cacheClearing: '正在清空…',
|
|
412
|
+
cacheKeepHint: '重启保持登录已开启:只删除缓存,登录保留。',
|
|
413
|
+
cachePurgeHint: '重启保持登录已关闭:将删除这 7 个服务留下的登录数据。',
|
|
414
|
+
cachePurgeTitle: '删除残留登录?',
|
|
415
|
+
cachePurgeBody:
|
|
416
|
+
'补丁已关闭。这会删除本面板自己的 7 个分区,包括其中的登录。不会动 DSH 自己的登录,也不会动其他分区。',
|
|
417
|
+
cachePurgeGo: '删除',
|
|
418
|
+
cacheUnavailable: '无法测量',
|
|
419
|
+
cacheFailed: '没能清空:',
|
|
390
420
|
copyDiag: '复制诊断信息',
|
|
391
421
|
copied: '已复制',
|
|
392
422
|
copyFailed: '复制失败',
|
|
@@ -815,21 +845,38 @@ let activeCtx = undefined
|
|
|
815
845
|
// Active tab
|
|
816
846
|
// ------------------------------------------------------------------
|
|
817
847
|
|
|
818
|
-
|
|
848
|
+
/**
|
|
849
|
+
* @param {'main' | 'right' | undefined} [seat]
|
|
850
|
+
* @returns {'main' | 'right'}
|
|
851
|
+
*/
|
|
852
|
+
function seatOf(seat) {
|
|
853
|
+
return seat === 'right' ? 'right' : 'main'
|
|
854
|
+
}
|
|
855
|
+
|
|
856
|
+
/** @param {'main' | 'right' | undefined} [seat] @returns {string} */
|
|
857
|
+
function activeStorageKey(seat) {
|
|
858
|
+
return seatOf(seat) === 'right' ? ACTIVE_TAB_KEY + ':right' : ACTIVE_TAB_KEY
|
|
859
|
+
}
|
|
860
|
+
|
|
861
|
+
/** @param {'main' | 'right' | undefined} [seat] */
|
|
862
|
+
function readStoredActive(seat) {
|
|
819
863
|
try {
|
|
820
864
|
if (typeof localStorage === 'undefined' || localStorage === null) return DEFAULT_PROVIDER
|
|
821
|
-
const stored = localStorage.getItem(
|
|
865
|
+
const stored = localStorage.getItem(activeStorageKey(seat))
|
|
822
866
|
return findProvider(stored) === undefined ? DEFAULT_PROVIDER : stored
|
|
823
867
|
} catch (error) {
|
|
824
868
|
return DEFAULT_PROVIDER
|
|
825
869
|
}
|
|
826
870
|
}
|
|
827
871
|
|
|
828
|
-
/**
|
|
829
|
-
|
|
872
|
+
/**
|
|
873
|
+
* @param {string} id
|
|
874
|
+
* @param {'main' | 'right' | undefined} [seat]
|
|
875
|
+
*/
|
|
876
|
+
function storeActive(id, seat) {
|
|
830
877
|
try {
|
|
831
878
|
if (typeof localStorage === 'undefined' || localStorage === null) return
|
|
832
|
-
localStorage.setItem(
|
|
879
|
+
localStorage.setItem(activeStorageKey(seat), id)
|
|
833
880
|
} catch (error) {
|
|
834
881
|
void error
|
|
835
882
|
}
|
|
@@ -975,32 +1022,40 @@ let activeCtx = undefined
|
|
|
975
1022
|
enabledIds = normalizeEnabled(tabOrder.filter((entryId) => entryId === id || isEnabled(entryId)))
|
|
976
1023
|
} else {
|
|
977
1024
|
enabledIds = enabledIds.filter((entryId) => entryId !== id)
|
|
978
|
-
const
|
|
979
|
-
|
|
1025
|
+
for (const seat of ['main', 'right']) {
|
|
1026
|
+
const record = guests.get(seat + ':' + id)
|
|
1027
|
+
if (record !== undefined && record.element !== undefined && record.element !== null) dropGuest(record)
|
|
1028
|
+
}
|
|
980
1029
|
}
|
|
981
1030
|
storeEnabled()
|
|
982
1031
|
|
|
983
|
-
if (on === false &&
|
|
1032
|
+
if (on === false && (activeBySeat.main === id || activeBySeat.right === id)) {
|
|
984
1033
|
const next = firstEnabled()
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
1034
|
+
for (const seat of ['main', 'right']) {
|
|
1035
|
+
if (activeBySeat[seat] !== id) continue
|
|
1036
|
+
assignSeatActive(seat, next)
|
|
1037
|
+
syncLayers(seat)
|
|
1038
|
+
void ensureActiveGuest(seat)
|
|
1039
|
+
}
|
|
988
1040
|
notify()
|
|
989
|
-
void ensureActiveGuest()
|
|
990
1041
|
return true
|
|
991
1042
|
}
|
|
992
1043
|
notify()
|
|
993
|
-
if (on)
|
|
1044
|
+
if (on) {
|
|
1045
|
+
void ensureActiveGuest('main')
|
|
1046
|
+
void ensureActiveGuest('right')
|
|
1047
|
+
}
|
|
994
1048
|
return true
|
|
995
1049
|
}
|
|
996
1050
|
|
|
997
1051
|
/** Move the active tab to a still-enabled provider when it was hidden. */
|
|
998
1052
|
function reconcileActive() {
|
|
999
|
-
if (isEnabled(state.active)) return
|
|
1000
1053
|
const next = findProvider(firstEnabled())
|
|
1001
1054
|
if (next === undefined) return
|
|
1002
|
-
|
|
1003
|
-
|
|
1055
|
+
for (const seat of ['main', 'right']) {
|
|
1056
|
+
if (isEnabled(activeBySeat[seat])) continue
|
|
1057
|
+
assignSeatActive(seat, next.id)
|
|
1058
|
+
}
|
|
1004
1059
|
}
|
|
1005
1060
|
|
|
1006
1061
|
/**
|
|
@@ -1029,15 +1084,35 @@ let activeCtx = undefined
|
|
|
1029
1084
|
|
|
1030
1085
|
/** @type {{ active: string, surface: { host: any } }} */
|
|
1031
1086
|
const state = {
|
|
1032
|
-
active: readStoredActive(),
|
|
1087
|
+
active: readStoredActive('main'),
|
|
1033
1088
|
surface: { host: null },
|
|
1034
1089
|
}
|
|
1035
1090
|
|
|
1091
|
+
/** @type {{ main: string, right: string }} the selected tab on each seat */
|
|
1092
|
+
const activeBySeat = {
|
|
1093
|
+
main: state.active,
|
|
1094
|
+
right: readStoredActive('right'),
|
|
1095
|
+
}
|
|
1096
|
+
|
|
1097
|
+
/**
|
|
1098
|
+
* @param {'main' | 'right'} seat
|
|
1099
|
+
* @param {string} id
|
|
1100
|
+
*/
|
|
1101
|
+
function assignSeatActive(seat, id) {
|
|
1102
|
+
const which = seatOf(seat)
|
|
1103
|
+
activeBySeat[which] = id
|
|
1104
|
+
if (which === 'main') state.active = id
|
|
1105
|
+
storeActive(id, which)
|
|
1106
|
+
}
|
|
1107
|
+
|
|
1036
1108
|
reconcileActive()
|
|
1037
1109
|
|
|
1038
|
-
/**
|
|
1039
|
-
|
|
1040
|
-
|
|
1110
|
+
/**
|
|
1111
|
+
* @param {'main' | 'right' | undefined} [seat]
|
|
1112
|
+
* @returns {object} the active provider record for that seat.
|
|
1113
|
+
*/
|
|
1114
|
+
function activeProvider(seat) {
|
|
1115
|
+
const provider = findProvider(activeBySeat[seatOf(seat)])
|
|
1041
1116
|
if (provider !== undefined && isEnabled(provider.id)) return provider
|
|
1042
1117
|
const fallback = findProvider(firstEnabled())
|
|
1043
1118
|
return fallback !== undefined ? fallback : PROVIDERS[0]
|
|
@@ -1089,8 +1164,8 @@ let activeCtx = undefined
|
|
|
1089
1164
|
* @param {any} provider
|
|
1090
1165
|
* @returns {string}
|
|
1091
1166
|
*/
|
|
1092
|
-
function startUrlFor(provider) {
|
|
1093
|
-
const remembered = lastUrls.get(provider.id)
|
|
1167
|
+
function startUrlFor(provider, seat) {
|
|
1168
|
+
const remembered = lastUrls.get(seatOf(seat) + ':' + provider.id)
|
|
1094
1169
|
if (typeof remembered !== 'string' || remembered === '') return provider.url
|
|
1095
1170
|
if (!remembered.startsWith(provider.origin)) return provider.url
|
|
1096
1171
|
if (!isLiveUrl(remembered)) return provider.url
|
|
@@ -1098,11 +1173,21 @@ let activeCtx = undefined
|
|
|
1098
1173
|
return remembered
|
|
1099
1174
|
}
|
|
1100
1175
|
|
|
1101
|
-
/**
|
|
1102
|
-
|
|
1103
|
-
|
|
1176
|
+
/**
|
|
1177
|
+
* One record per seat. The two webviews share a partition, not a document.
|
|
1178
|
+
*
|
|
1179
|
+
* @param {string} id
|
|
1180
|
+
* @param {'main' | 'right' | undefined} [seat]
|
|
1181
|
+
* @returns {GuestRecord}
|
|
1182
|
+
*/
|
|
1183
|
+
function guestRecord(id, seat) {
|
|
1184
|
+
const which = seatOf(seat)
|
|
1185
|
+
const key = which + ':' + id
|
|
1186
|
+
let record = guests.get(key)
|
|
1104
1187
|
if (record === undefined) {
|
|
1105
1188
|
record = {
|
|
1189
|
+
id,
|
|
1190
|
+
seat: which,
|
|
1106
1191
|
element: undefined,
|
|
1107
1192
|
lease: undefined,
|
|
1108
1193
|
partition: undefined,
|
|
@@ -1125,14 +1210,17 @@ let activeCtx = undefined
|
|
|
1125
1210
|
handoff: '',
|
|
1126
1211
|
selfTest: '',
|
|
1127
1212
|
}
|
|
1128
|
-
guests.set(
|
|
1213
|
+
guests.set(key, record)
|
|
1129
1214
|
}
|
|
1130
1215
|
return record
|
|
1131
1216
|
}
|
|
1132
1217
|
|
|
1133
|
-
/**
|
|
1134
|
-
|
|
1135
|
-
|
|
1218
|
+
/**
|
|
1219
|
+
* @param {'main' | 'right' | undefined} [seat]
|
|
1220
|
+
* @returns {{ phase: string, detail: string }}
|
|
1221
|
+
*/
|
|
1222
|
+
function getStatus(seat) {
|
|
1223
|
+
const record = guestRecord(activeBySeat[seatOf(seat)], seat)
|
|
1136
1224
|
return { phase: record.phase, detail: record.detail }
|
|
1137
1225
|
}
|
|
1138
1226
|
|
|
@@ -1140,9 +1228,10 @@ let activeCtx = undefined
|
|
|
1140
1228
|
* @param {string} id
|
|
1141
1229
|
* @param {string} phase
|
|
1142
1230
|
* @param {string} [detail]
|
|
1231
|
+
* @param {'main' | 'right' | undefined} [seat]
|
|
1143
1232
|
*/
|
|
1144
|
-
function setPhase(id, phase, detail) {
|
|
1145
|
-
const record = guestRecord(id)
|
|
1233
|
+
function setPhase(id, phase, detail, seat) {
|
|
1234
|
+
const record = guestRecord(id, seat)
|
|
1146
1235
|
if (record.phase === phase && record.detail === (detail === undefined ? '' : detail)) return
|
|
1147
1236
|
record.phase = phase
|
|
1148
1237
|
record.detail = detail === undefined ? '' : detail
|
|
@@ -1296,29 +1385,57 @@ let activeCtx = undefined
|
|
|
1296
1385
|
}
|
|
1297
1386
|
}
|
|
1298
1387
|
|
|
1299
|
-
/**
|
|
1300
|
-
|
|
1301
|
-
|
|
1388
|
+
/**
|
|
1389
|
+
* Where a new guest layer is attached.
|
|
1390
|
+
*
|
|
1391
|
+
* Left pages live in the park so the chat panel can unmount without
|
|
1392
|
+
* destroying them. Right pages live in the column, so a collapse hides
|
|
1393
|
+
* them with the column instead of leaving a fixed box on the conversation.
|
|
1394
|
+
*
|
|
1395
|
+
* @param {'main' | 'right' | undefined} [seat]
|
|
1396
|
+
* @returns {any}
|
|
1397
|
+
*/
|
|
1398
|
+
function guestHome(seat) {
|
|
1399
|
+
if (seatOf(seat) === 'right') return inlineHosts.right
|
|
1400
|
+
const park = ensurePark()
|
|
1401
|
+
if (park !== undefined) return park
|
|
1402
|
+
if (inlineHosts.main !== null && inlineHosts.main !== undefined) return inlineHosts.main
|
|
1403
|
+
return state.surface.host
|
|
1404
|
+
}
|
|
1405
|
+
|
|
1406
|
+
/**
|
|
1407
|
+
* @param {object} provider
|
|
1408
|
+
* @param {'main' | 'right' | undefined} [seat]
|
|
1409
|
+
*/
|
|
1410
|
+
function layerFor(provider, seat) {
|
|
1411
|
+
const which = seatOf(seat)
|
|
1412
|
+
const record = guestRecord(provider.id, which)
|
|
1302
1413
|
if (record.layer !== undefined && record.layer !== null && record.layer.isConnected !== false) {
|
|
1303
1414
|
return record.layer
|
|
1304
1415
|
}
|
|
1305
|
-
const host =
|
|
1416
|
+
const host = guestHome(which)
|
|
1306
1417
|
if (host === null || host === undefined) return undefined
|
|
1307
1418
|
const layer = document.createElement('div')
|
|
1308
1419
|
layer.className = 'dce-guest-layer'
|
|
1309
1420
|
layer.setAttribute('data-provider', provider.id)
|
|
1310
|
-
layer.setAttribute('data-
|
|
1421
|
+
layer.setAttribute('data-seat', which)
|
|
1422
|
+
layer.setAttribute('data-active', provider.id === activeBySeat[which] ? 'true' : 'false')
|
|
1311
1423
|
host.appendChild(layer)
|
|
1312
1424
|
record.layer = layer
|
|
1313
1425
|
return layer
|
|
1314
1426
|
}
|
|
1315
1427
|
|
|
1316
|
-
/**
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1428
|
+
/**
|
|
1429
|
+
* Show only that seat's active layer. The other seat is not touched.
|
|
1430
|
+
*
|
|
1431
|
+
* @param {'main' | 'right' | undefined} [seat]
|
|
1432
|
+
*/
|
|
1433
|
+
function syncLayers(seat) {
|
|
1434
|
+
const which = seat === undefined ? undefined : seatOf(seat)
|
|
1435
|
+
for (const record of guests.values()) {
|
|
1436
|
+
if (which !== undefined && record.seat !== which) continue
|
|
1437
|
+
if (record.layer === undefined || record.layer === null) continue
|
|
1438
|
+
const want = record.id === activeBySeat[record.seat] ? 'true' : 'false'
|
|
1322
1439
|
if (record.layer.getAttribute('data-active') !== want) record.layer.setAttribute('data-active', want)
|
|
1323
1440
|
}
|
|
1324
1441
|
}
|
|
@@ -1329,10 +1446,11 @@ let activeCtx = undefined
|
|
|
1329
1446
|
* @param {string} id
|
|
1330
1447
|
* @returns {Promise<void>}
|
|
1331
1448
|
*/
|
|
1332
|
-
async function mountGuest(id) {
|
|
1449
|
+
async function mountGuest(id, seat) {
|
|
1450
|
+
const which = seatOf(seat)
|
|
1333
1451
|
const provider = findProvider(id)
|
|
1334
1452
|
if (provider === undefined) return
|
|
1335
|
-
const record = guestRecord(id)
|
|
1453
|
+
const record = guestRecord(id, which)
|
|
1336
1454
|
|
|
1337
1455
|
if (record.mounting === true) return
|
|
1338
1456
|
if (record.element !== undefined && record.element !== null) {
|
|
@@ -1341,7 +1459,7 @@ let activeCtx = undefined
|
|
|
1341
1459
|
dropGuest(record)
|
|
1342
1460
|
}
|
|
1343
1461
|
|
|
1344
|
-
const layer = layerFor(provider)
|
|
1462
|
+
const layer = layerFor(provider, which)
|
|
1345
1463
|
if (layer === undefined) return
|
|
1346
1464
|
|
|
1347
1465
|
record.mounting = true
|
|
@@ -1351,11 +1469,11 @@ let activeCtx = undefined
|
|
|
1351
1469
|
try {
|
|
1352
1470
|
const bridge = desktopBrowser()
|
|
1353
1471
|
if (bridge === undefined) {
|
|
1354
|
-
setPhase(id, PHASE.UNSUPPORTED, '')
|
|
1472
|
+
setPhase(id, PHASE.UNSUPPORTED, '', which)
|
|
1355
1473
|
return
|
|
1356
1474
|
}
|
|
1357
1475
|
|
|
1358
|
-
setPhase(id, PHASE.ACQUIRING, '')
|
|
1476
|
+
setPhase(id, PHASE.ACQUIRING, '', which)
|
|
1359
1477
|
let lease
|
|
1360
1478
|
let partition
|
|
1361
1479
|
try {
|
|
@@ -1367,11 +1485,11 @@ let activeCtx = undefined
|
|
|
1367
1485
|
throw new Error('desktop shell returned no partition')
|
|
1368
1486
|
}
|
|
1369
1487
|
} catch (error) {
|
|
1370
|
-
if (generation === record.generation) setPhase(id, PHASE.FAILED, messageOf(error))
|
|
1488
|
+
if (generation === record.generation) setPhase(id, PHASE.FAILED, messageOf(error), which)
|
|
1371
1489
|
return
|
|
1372
1490
|
}
|
|
1373
1491
|
|
|
1374
|
-
log('info', 'lease acquired', { provider: id, partition: shortId(partition) })
|
|
1492
|
+
log('info', 'lease acquired', { provider: id, seat: which, partition: shortId(partition) })
|
|
1375
1493
|
|
|
1376
1494
|
// Teardown or reload happened while the lease was in flight.
|
|
1377
1495
|
if (generation !== record.generation) {
|
|
@@ -1392,12 +1510,12 @@ let activeCtx = undefined
|
|
|
1392
1510
|
element.style.cssText = 'display:inline-flex;width:100%;height:100%;border:0;background:transparent;'
|
|
1393
1511
|
|
|
1394
1512
|
const handlers = {
|
|
1395
|
-
ready: (event) => onGuestReady(id, event),
|
|
1396
|
-
failed: (event) => onGuestFailed(id, event),
|
|
1397
|
-
navigate: (event) => onGuestNavigated(id, event !== undefined && event !== null ? event.url : ''),
|
|
1398
|
-
navigateInPage: (event) => onGuestLocation(id, event !== undefined && event !== null ? event.url : ''),
|
|
1399
|
-
stop: () => onGuestStopped(id),
|
|
1400
|
-
crash: () => onGuestCrashed(id),
|
|
1513
|
+
ready: (event) => onGuestReady(id, event, which),
|
|
1514
|
+
failed: (event) => onGuestFailed(id, event, which),
|
|
1515
|
+
navigate: (event) => onGuestNavigated(id, event !== undefined && event !== null ? event.url : '', which),
|
|
1516
|
+
navigateInPage: (event) => onGuestLocation(id, event !== undefined && event !== null ? event.url : '', which),
|
|
1517
|
+
stop: () => onGuestStopped(id, which),
|
|
1518
|
+
crash: () => onGuestCrashed(id, which),
|
|
1401
1519
|
}
|
|
1402
1520
|
element.addEventListener('dom-ready', handlers.ready)
|
|
1403
1521
|
element.addEventListener('did-fail-load', handlers.failed)
|
|
@@ -1415,13 +1533,13 @@ let activeCtx = undefined
|
|
|
1415
1533
|
record.mounts += 1
|
|
1416
1534
|
// A mount is a fresh document load. Printing the count makes "one page
|
|
1417
1535
|
// in the tab" distinguishable from "the tab was rebuilt" in the ring.
|
|
1418
|
-
log('info', 'guest mounted', { provider: id, mount: record.mounts })
|
|
1536
|
+
log('info', 'guest mounted', { provider: id, seat: which, mount: record.mounts })
|
|
1419
1537
|
|
|
1420
1538
|
try {
|
|
1421
1539
|
layer.appendChild(element)
|
|
1422
1540
|
} catch (error) {
|
|
1423
1541
|
dropGuest(record)
|
|
1424
|
-
setPhase(id, PHASE.FAILED, messageOf(error))
|
|
1542
|
+
setPhase(id, PHASE.FAILED, messageOf(error), which)
|
|
1425
1543
|
return
|
|
1426
1544
|
}
|
|
1427
1545
|
|
|
@@ -1429,12 +1547,12 @@ let activeCtx = undefined
|
|
|
1429
1547
|
// so a reload or teardown cannot leave a listener behind.
|
|
1430
1548
|
if (typeof bridge.onOpenRequested === 'function') {
|
|
1431
1549
|
try {
|
|
1432
|
-
record.popupOff = bridge.onOpenRequested(lease, (url) => onGuestPopup(id, url))
|
|
1550
|
+
record.popupOff = bridge.onOpenRequested(lease, (url) => onGuestPopup(id, url, which))
|
|
1433
1551
|
} catch (error) {
|
|
1434
1552
|
record.popupOff = undefined
|
|
1435
1553
|
}
|
|
1436
1554
|
}
|
|
1437
|
-
setPhase(id, PHASE.NAVIGATING, '')
|
|
1555
|
+
setPhase(id, PHASE.NAVIGATING, '', which)
|
|
1438
1556
|
} finally {
|
|
1439
1557
|
record.mounting = false
|
|
1440
1558
|
syncLayers()
|
|
@@ -1452,11 +1570,12 @@ let activeCtx = undefined
|
|
|
1452
1570
|
* @param {any} element
|
|
1453
1571
|
* @returns {Promise<void>}
|
|
1454
1572
|
*/
|
|
1455
|
-
async function navigateGuest(id, element) {
|
|
1573
|
+
async function navigateGuest(id, element, seat) {
|
|
1574
|
+
const which = seatOf(seat)
|
|
1456
1575
|
const provider = findProvider(id)
|
|
1457
1576
|
if (provider === undefined) return
|
|
1458
|
-
const record = guestRecord(id)
|
|
1459
|
-
const target = startUrlFor(provider)
|
|
1577
|
+
const record = guestRecord(id, which)
|
|
1578
|
+
const target = startUrlFor(provider, which)
|
|
1460
1579
|
const deadline = Date.now() + NAVIGATE_TIMEOUT_MS
|
|
1461
1580
|
let issued = 0
|
|
1462
1581
|
|
|
@@ -1464,8 +1583,8 @@ let activeCtx = undefined
|
|
|
1464
1583
|
if (element !== record.element) return
|
|
1465
1584
|
const landed = guestUrl(element)
|
|
1466
1585
|
if (isLiveUrl(landed)) {
|
|
1467
|
-
if (landed !== '') lastUrls.set(id, landed)
|
|
1468
|
-
setPhase(id, PHASE.READY, '')
|
|
1586
|
+
if (landed !== '') lastUrls.set(which + ':' + id, landed)
|
|
1587
|
+
setPhase(id, PHASE.READY, '', which)
|
|
1469
1588
|
return
|
|
1470
1589
|
}
|
|
1471
1590
|
const loading = guestLoading(element)
|
|
@@ -1486,34 +1605,34 @@ let activeCtx = undefined
|
|
|
1486
1605
|
await delay(NAVIGATE_RETRY_MS)
|
|
1487
1606
|
}
|
|
1488
1607
|
if (element !== record.element) return
|
|
1489
|
-
setPhase(id, PHASE.FAILED, 'navigation-timeout')
|
|
1608
|
+
setPhase(id, PHASE.FAILED, 'navigation-timeout', which)
|
|
1490
1609
|
}
|
|
1491
1610
|
|
|
1492
1611
|
/**
|
|
1493
1612
|
* @param {string} id
|
|
1494
1613
|
* @param {any} event
|
|
1495
1614
|
*/
|
|
1496
|
-
function onGuestReady(id, event) {
|
|
1497
|
-
const record = guestRecord(id)
|
|
1615
|
+
function onGuestReady(id, event, seat) {
|
|
1616
|
+
const record = guestRecord(id, seat)
|
|
1498
1617
|
const element =
|
|
1499
1618
|
event !== undefined && event !== null && event.currentTarget !== undefined ? event.currentTarget : record.element
|
|
1500
1619
|
if (element === undefined || element !== record.element) return
|
|
1501
1620
|
if (record.navigated) return
|
|
1502
1621
|
record.navigated = true
|
|
1503
|
-
void navigateGuest(id, element)
|
|
1622
|
+
void navigateGuest(id, element, seat)
|
|
1504
1623
|
}
|
|
1505
1624
|
|
|
1506
1625
|
/**
|
|
1507
1626
|
* @param {string} id
|
|
1508
1627
|
* @param {any} event
|
|
1509
1628
|
*/
|
|
1510
|
-
function onGuestFailed(id, event) {
|
|
1511
|
-
const record = guestRecord(id)
|
|
1629
|
+
function onGuestFailed(id, event, seat) {
|
|
1630
|
+
const record = guestRecord(id, seat)
|
|
1512
1631
|
const element =
|
|
1513
1632
|
event !== undefined && event !== null && event.currentTarget !== undefined ? event.currentTarget : record.element
|
|
1514
1633
|
if (element === undefined || element !== record.element) return
|
|
1515
1634
|
if (event !== undefined && event !== null && event.errorCode === -3) return
|
|
1516
|
-
setPhase(id, PHASE.FAILED, 'load-failed')
|
|
1635
|
+
setPhase(id, PHASE.FAILED, 'load-failed', seat)
|
|
1517
1636
|
log('warn', 'guest failed to load', { provider: id })
|
|
1518
1637
|
}
|
|
1519
1638
|
|
|
@@ -1523,11 +1642,11 @@ let activeCtx = undefined
|
|
|
1523
1642
|
* @param {string} id
|
|
1524
1643
|
* @param {string} url
|
|
1525
1644
|
*/
|
|
1526
|
-
function onGuestLocation(id, url) {
|
|
1527
|
-
const record = guestRecord(id)
|
|
1645
|
+
function onGuestLocation(id, url, seat) {
|
|
1646
|
+
const record = guestRecord(id, seat)
|
|
1528
1647
|
if (typeof url === 'string' && url !== '') {
|
|
1529
1648
|
record.lastUrl = url
|
|
1530
|
-
lastUrls.set(id, url)
|
|
1649
|
+
lastUrls.set(seatOf(seat) + ':' + id, url)
|
|
1531
1650
|
}
|
|
1532
1651
|
}
|
|
1533
1652
|
|
|
@@ -1572,13 +1691,13 @@ let activeCtx = undefined
|
|
|
1572
1691
|
*
|
|
1573
1692
|
* @param {string} id
|
|
1574
1693
|
*/
|
|
1575
|
-
function onGuestStopped(id) {
|
|
1576
|
-
const record = guestRecord(id)
|
|
1694
|
+
function onGuestStopped(id, seat) {
|
|
1695
|
+
const record = guestRecord(id, seat)
|
|
1577
1696
|
const element = record.element
|
|
1578
1697
|
if (element === undefined || element === null) return
|
|
1579
1698
|
const url = guestUrl(element)
|
|
1580
1699
|
record.lastUrl = url
|
|
1581
|
-
if (typeof url === 'string' && url !== '' && isLiveUrl(url)) lastUrls.set(id, url)
|
|
1700
|
+
if (typeof url === 'string' && url !== '' && isLiveUrl(url)) lastUrls.set(seatOf(seat) + ':' + id, url)
|
|
1582
1701
|
record.lastEvent = 'did-stop-loading'
|
|
1583
1702
|
|
|
1584
1703
|
// Google's popup-handoff page cannot finish without an opener: return to
|
|
@@ -1602,7 +1721,7 @@ let activeCtx = undefined
|
|
|
1602
1721
|
record.reloadTimer = setTimeout(() => {
|
|
1603
1722
|
record.reloadTimer = undefined
|
|
1604
1723
|
if (record.element !== element) return
|
|
1605
|
-
void reloadGuest(id)
|
|
1724
|
+
void reloadGuest(id, seat)
|
|
1606
1725
|
}, TIMINGS.oauthRecoveryReloadMs)
|
|
1607
1726
|
return
|
|
1608
1727
|
}
|
|
@@ -1617,10 +1736,10 @@ let activeCtx = undefined
|
|
|
1617
1736
|
*
|
|
1618
1737
|
* @param {string} id
|
|
1619
1738
|
*/
|
|
1620
|
-
function onGuestCrashed(id) {
|
|
1621
|
-
const record = guestRecord(id)
|
|
1739
|
+
function onGuestCrashed(id, seat) {
|
|
1740
|
+
const record = guestRecord(id, seat)
|
|
1622
1741
|
if (record.element === undefined || record.element === null) return
|
|
1623
|
-
setPhase(id, PHASE.FAILED, 'renderer-gone')
|
|
1742
|
+
setPhase(id, PHASE.FAILED, 'renderer-gone', seat)
|
|
1624
1743
|
record.lastEvent = 'renderer-gone'
|
|
1625
1744
|
log('error', 'renderer gone', { provider: id })
|
|
1626
1745
|
notify()
|
|
@@ -1637,8 +1756,8 @@ let activeCtx = undefined
|
|
|
1637
1756
|
* @param {string} id
|
|
1638
1757
|
* @param {string} url
|
|
1639
1758
|
*/
|
|
1640
|
-
function onGuestPopup(id, url) {
|
|
1641
|
-
const record = guestRecord(id)
|
|
1759
|
+
function onGuestPopup(id, url, seat) {
|
|
1760
|
+
const record = guestRecord(id, seat)
|
|
1642
1761
|
const element = record.element
|
|
1643
1762
|
if (element === undefined || element === null) return
|
|
1644
1763
|
if (typeof url !== 'string' || url.indexOf('https://') !== 0) return
|
|
@@ -1664,8 +1783,8 @@ let activeCtx = undefined
|
|
|
1664
1783
|
* @param {string} id
|
|
1665
1784
|
* @param {string} url
|
|
1666
1785
|
*/
|
|
1667
|
-
function onGuestNavigated(id, url) {
|
|
1668
|
-
const record = guestRecord(id)
|
|
1786
|
+
function onGuestNavigated(id, url, seat) {
|
|
1787
|
+
const record = guestRecord(id, seat)
|
|
1669
1788
|
const provider = findProvider(id)
|
|
1670
1789
|
if (provider === undefined) return
|
|
1671
1790
|
const host = hostOf(url)
|
|
@@ -1682,7 +1801,7 @@ let activeCtx = undefined
|
|
|
1682
1801
|
if (record.oauthPending !== true) return
|
|
1683
1802
|
if (host !== hostOf(provider.origin)) return
|
|
1684
1803
|
record.oauthPending = false
|
|
1685
|
-
scheduleOAuthRecovery(id, provider)
|
|
1804
|
+
scheduleOAuthRecovery(id, provider, seat)
|
|
1686
1805
|
}
|
|
1687
1806
|
|
|
1688
1807
|
/** @param {GuestRecord} record */
|
|
@@ -1723,8 +1842,8 @@ let activeCtx = undefined
|
|
|
1723
1842
|
* @param {string} id
|
|
1724
1843
|
* @param {object} provider
|
|
1725
1844
|
*/
|
|
1726
|
-
function scheduleOAuthRecovery(id, provider) {
|
|
1727
|
-
const record = guestRecord(id)
|
|
1845
|
+
function scheduleOAuthRecovery(id, provider, seat) {
|
|
1846
|
+
const record = guestRecord(id, seat)
|
|
1728
1847
|
clearRecoveryTimer(record)
|
|
1729
1848
|
|
|
1730
1849
|
record.recoveryTimer = setTimeout(() => {
|
|
@@ -1771,21 +1890,23 @@ let activeCtx = undefined
|
|
|
1771
1890
|
* @param {string} id
|
|
1772
1891
|
* @returns {Promise<void>}
|
|
1773
1892
|
*/
|
|
1774
|
-
async function reloadGuest(id) {
|
|
1775
|
-
const
|
|
1776
|
-
|
|
1893
|
+
async function reloadGuest(id, seat) {
|
|
1894
|
+
const which = seatOf(seat)
|
|
1895
|
+
const record = guestRecord(id, which)
|
|
1896
|
+
log('info', 'reload requested', { provider: id, seat: which })
|
|
1777
1897
|
record.generation += 1
|
|
1778
1898
|
dropGuest(record)
|
|
1779
|
-
setPhase(id, PHASE.IDLE, '')
|
|
1780
|
-
await mountGuest(id)
|
|
1899
|
+
setPhase(id, PHASE.IDLE, '', which)
|
|
1900
|
+
await mountGuest(id, which)
|
|
1781
1901
|
}
|
|
1782
1902
|
/** Release every guest; used on plugin unload. */
|
|
1783
1903
|
/** @param {string} [reason] */
|
|
1784
1904
|
function destroyGuests(reason) {
|
|
1785
|
-
for (const
|
|
1905
|
+
for (const record of guests.values()) {
|
|
1786
1906
|
record.generation += 1
|
|
1787
1907
|
dropGuest(record, reason)
|
|
1788
|
-
|
|
1908
|
+
record.phase = PHASE.IDLE
|
|
1909
|
+
record.detail = ''
|
|
1789
1910
|
if (record.layer !== undefined && record.layer !== null) {
|
|
1790
1911
|
try {
|
|
1791
1912
|
if (record.layer.parentNode !== null && record.layer.parentNode !== undefined) {
|
|
@@ -1797,6 +1918,8 @@ let activeCtx = undefined
|
|
|
1797
1918
|
record.layer = undefined
|
|
1798
1919
|
}
|
|
1799
1920
|
}
|
|
1921
|
+
discardPark()
|
|
1922
|
+
notify()
|
|
1800
1923
|
}
|
|
1801
1924
|
|
|
1802
1925
|
/** @param {{left:number,top:number,width:number,height:number}} rect @returns {string} */
|
|
@@ -1860,15 +1983,18 @@ let activeCtx = undefined
|
|
|
1860
1983
|
*/
|
|
1861
1984
|
/**
|
|
1862
1985
|
* A guest element cannot move between hosts (Electron destroys the
|
|
1863
|
-
* WebContents with its DOM)
|
|
1864
|
-
*
|
|
1986
|
+
* WebContents with its DOM). Used only when the persistent park is absent
|
|
1987
|
+
* (tests, or a shell frame we could not find): guests that are not inside
|
|
1988
|
+
* the new host are dropped and rebuilt there. With a park, guests stay put
|
|
1989
|
+
* and the park is shown or hidden instead.
|
|
1865
1990
|
*
|
|
1866
1991
|
* @param {any} host
|
|
1867
1992
|
*/
|
|
1868
|
-
function dropGuestsOutside(host) {
|
|
1869
|
-
|
|
1870
|
-
|
|
1871
|
-
if (record
|
|
1993
|
+
function dropGuestsOutside(host, seat) {
|
|
1994
|
+
const which = seatOf(seat)
|
|
1995
|
+
for (const record of guests.values()) {
|
|
1996
|
+
if (record.seat !== which) continue
|
|
1997
|
+
if (record.element === undefined || record.element === null) continue
|
|
1872
1998
|
const element = record.element
|
|
1873
1999
|
const inside = typeof host.contains === 'function' ? host.contains(element) : false
|
|
1874
2000
|
if (inside) continue
|
|
@@ -1897,17 +2023,308 @@ let activeCtx = undefined
|
|
|
1897
2023
|
if (patch !== undefined && patch !== null && patch.host !== undefined) setHost(patch.host)
|
|
1898
2024
|
}
|
|
1899
2025
|
|
|
2026
|
+
/**
|
|
2027
|
+
* Guest park. Created once, appended to `document.body`, never moved.
|
|
2028
|
+
* `hidden` keeps the webview in the document — the same trick the shell
|
|
2029
|
+
* uses for a keepMounted tab — so coming back is a reveal, not a reload.
|
|
2030
|
+
*
|
|
2031
|
+
* @type {any}
|
|
2032
|
+
*/
|
|
2033
|
+
let parkNode = undefined
|
|
2034
|
+
/** @type {'main' | 'right' | 'stowed'} */
|
|
2035
|
+
let parkMode = 'stowed'
|
|
2036
|
+
/** @type {any} */
|
|
2037
|
+
let anchorNode = undefined
|
|
2038
|
+
|
|
2039
|
+
/** @param {any} node @returns {any[]} */
|
|
2040
|
+
function childElements(node) {
|
|
2041
|
+
if (node === null || node === undefined) return []
|
|
2042
|
+
if (Array.isArray(node.children)) return node.children
|
|
2043
|
+
if (typeof node.children === 'object' && node.children !== null && typeof node.children.length === 'number') {
|
|
2044
|
+
try {
|
|
2045
|
+
return Array.from(node.children)
|
|
2046
|
+
} catch (error) {
|
|
2047
|
+
void error
|
|
2048
|
+
}
|
|
2049
|
+
}
|
|
2050
|
+
return []
|
|
2051
|
+
}
|
|
2052
|
+
|
|
2053
|
+
/**
|
|
2054
|
+
* @param {any} root
|
|
2055
|
+
* @param {string} name
|
|
2056
|
+
* @returns {any}
|
|
2057
|
+
*/
|
|
2058
|
+
function findByAttribute(root, name) {
|
|
2059
|
+
if (root === null || root === undefined) return undefined
|
|
2060
|
+
if (typeof root.querySelector === 'function') {
|
|
2061
|
+
try {
|
|
2062
|
+
const hit = root.querySelector('[' + name + ']')
|
|
2063
|
+
if (hit !== null && hit !== undefined) return hit
|
|
2064
|
+
} catch (error) {
|
|
2065
|
+
void error
|
|
2066
|
+
}
|
|
2067
|
+
}
|
|
2068
|
+
const stack = childElements(root).slice()
|
|
2069
|
+
while (stack.length > 0) {
|
|
2070
|
+
const node = stack.pop()
|
|
2071
|
+
if (node !== undefined && node !== null && typeof node.hasAttribute === 'function' && node.hasAttribute(name)) {
|
|
2072
|
+
return node
|
|
2073
|
+
}
|
|
2074
|
+
const kids = childElements(node)
|
|
2075
|
+
for (let index = kids.length - 1; index >= 0; index -= 1) stack.push(kids[index])
|
|
2076
|
+
}
|
|
2077
|
+
return undefined
|
|
2078
|
+
}
|
|
2079
|
+
|
|
2080
|
+
/**
|
|
2081
|
+
* The shell frame is present when the right column marker exists. Without
|
|
2082
|
+
* it (the contract tests, a page that is not the desktop shell) there is
|
|
2083
|
+
* no stable park, and guests stay in the seat viewport.
|
|
2084
|
+
*
|
|
2085
|
+
* @returns {boolean}
|
|
2086
|
+
*/
|
|
2087
|
+
function shellFramePresent() {
|
|
2088
|
+
const root = typeof document !== 'undefined' && document !== null ? document.body : undefined
|
|
2089
|
+
return findByAttribute(root, 'data-rightbar-col') !== undefined
|
|
2090
|
+
}
|
|
2091
|
+
|
|
2092
|
+
/** @returns {boolean} */
|
|
2093
|
+
function anchorReady() {
|
|
2094
|
+
try {
|
|
2095
|
+
return (
|
|
2096
|
+
typeof CSS !== 'undefined' &&
|
|
2097
|
+
CSS !== null &&
|
|
2098
|
+
typeof CSS.supports === 'function' &&
|
|
2099
|
+
CSS.supports('anchor-name: --dce')
|
|
2100
|
+
)
|
|
2101
|
+
} catch (error) {
|
|
2102
|
+
void error
|
|
2103
|
+
return false
|
|
2104
|
+
}
|
|
2105
|
+
}
|
|
2106
|
+
|
|
2107
|
+
/** @returns {boolean} */
|
|
2108
|
+
function parkIsLive() {
|
|
2109
|
+
return parkNode !== undefined && parkNode !== null && parkNode.isConnected !== false
|
|
2110
|
+
}
|
|
2111
|
+
|
|
2112
|
+
/**
|
|
2113
|
+
* @returns {any} the park element, or undefined when this page has no shell frame
|
|
2114
|
+
*/
|
|
2115
|
+
/**
|
|
2116
|
+
* Parent that outlives panel switches and is not a grid item of the frame.
|
|
2117
|
+
*
|
|
2118
|
+
* The frame is `display:grid`. An extra child there — even `position:fixed`
|
|
2119
|
+
* — is still a grid item in this shell and steals a track, which is why the
|
|
2120
|
+
* right column then refuses to open. `document.body` is outside that grid.
|
|
2121
|
+
* The corner radius is copied from the frame when the park is shown.
|
|
2122
|
+
*
|
|
2123
|
+
* @returns {any}
|
|
2124
|
+
*/
|
|
2125
|
+
function parkParent() {
|
|
2126
|
+
return document.body
|
|
2127
|
+
}
|
|
2128
|
+
|
|
2129
|
+
function ensurePark() {
|
|
2130
|
+
if (shellFramePresent() !== true) return undefined
|
|
2131
|
+
if (parkIsLive() === true) return parkNode
|
|
2132
|
+
const parent = parkParent()
|
|
2133
|
+
if (parent === null || parent === undefined) return undefined
|
|
2134
|
+
const node = document.createElement('div')
|
|
2135
|
+
node.className = 'dce-park'
|
|
2136
|
+
node.setAttribute('data-dce-park', 'true')
|
|
2137
|
+
node.setAttribute('hidden', '')
|
|
2138
|
+
parent.appendChild(node)
|
|
2139
|
+
parkNode = node
|
|
2140
|
+
parkMode = 'stowed'
|
|
2141
|
+
return node
|
|
2142
|
+
}
|
|
2143
|
+
|
|
2144
|
+
function clearAnchor() {
|
|
2145
|
+
if (anchorNode !== undefined && anchorNode !== null && typeof anchorNode.removeAttribute === 'function') {
|
|
2146
|
+
try {
|
|
2147
|
+
anchorNode.removeAttribute('data-dce-anchor')
|
|
2148
|
+
} catch (error) {
|
|
2149
|
+
void error
|
|
2150
|
+
}
|
|
2151
|
+
}
|
|
2152
|
+
anchorNode = undefined
|
|
2153
|
+
}
|
|
2154
|
+
|
|
2155
|
+
function stowPark() {
|
|
2156
|
+
if (parkNode === undefined || parkNode === null) return
|
|
2157
|
+
clearAnchor()
|
|
2158
|
+
parkNode.setAttribute('hidden', '')
|
|
2159
|
+
parkNode.setAttribute('data-mode', 'stowed')
|
|
2160
|
+
// A fixed box with no anchor falls back to covering the window and eats
|
|
2161
|
+
// the right-sidebar expand button. Zero the box, don't just rely on hidden.
|
|
2162
|
+
if (parkNode.style !== undefined && parkNode.style !== null) {
|
|
2163
|
+
parkNode.style.cssText = 'position:fixed;width:0;height:0;pointer-events:none'
|
|
2164
|
+
}
|
|
2165
|
+
if (parkMode !== 'stowed') {
|
|
2166
|
+
log('info', 'guests stowed', { reason: 'seat hidden' })
|
|
2167
|
+
parkMode = 'stowed'
|
|
2168
|
+
}
|
|
2169
|
+
}
|
|
2170
|
+
|
|
2171
|
+
/**
|
|
2172
|
+
* Show the park over the seat the user is looking at. The element itself
|
|
2173
|
+
* does not move; only its CSS box does.
|
|
2174
|
+
*
|
|
2175
|
+
* @param {'main' | 'right'} seat
|
|
2176
|
+
* @param {any} chosen
|
|
2177
|
+
* @param {any} park
|
|
2178
|
+
*/
|
|
2179
|
+
/**
|
|
2180
|
+
* @param {any} chosen
|
|
2181
|
+
* @returns {{ left: number, top: number, width: number, height: number } | undefined}
|
|
2182
|
+
*/
|
|
2183
|
+
function seatBox(chosen) {
|
|
2184
|
+
if (chosen === null || chosen === undefined || typeof chosen.getBoundingClientRect !== 'function') return undefined
|
|
2185
|
+
const box = chosen.getBoundingClientRect()
|
|
2186
|
+
if (box === undefined || box === null) return undefined
|
|
2187
|
+
return {
|
|
2188
|
+
left: box.left,
|
|
2189
|
+
top: box.top,
|
|
2190
|
+
width: box.width,
|
|
2191
|
+
height: box.height,
|
|
2192
|
+
}
|
|
2193
|
+
}
|
|
2194
|
+
|
|
2195
|
+
function revealPark(seat, chosen, park) {
|
|
2196
|
+
const box = seatBox(chosen)
|
|
2197
|
+
// A closed right column is 0×0. Showing the park then either covers the
|
|
2198
|
+
// expand button or hides the page the user is still looking at.
|
|
2199
|
+
if (box === undefined || box.width < 2 || box.height < 2) {
|
|
2200
|
+
stowPark()
|
|
2201
|
+
return
|
|
2202
|
+
}
|
|
2203
|
+
clearAnchor()
|
|
2204
|
+
park.removeAttribute('hidden')
|
|
2205
|
+
park.setAttribute('data-mode', seat)
|
|
2206
|
+
if (typeof chosen.setAttribute === 'function') {
|
|
2207
|
+
chosen.setAttribute('data-dce-anchor', 'true')
|
|
2208
|
+
anchorNode = chosen
|
|
2209
|
+
}
|
|
2210
|
+
// Always pin a real box. CSS anchor tracks a splitter with no JS, but an
|
|
2211
|
+
// unanchored fixed element covers the window — that is what made the
|
|
2212
|
+
// right sidebar's expand button unclickable. Inline pixels are the floor;
|
|
2213
|
+
// anchor overrides them only where the seat actually has a box.
|
|
2214
|
+
const radius = seat === 'main' ? contentRadius() : '0'
|
|
2215
|
+
if (park.style !== undefined && park.style !== null) {
|
|
2216
|
+
park.style.cssText =
|
|
2217
|
+
'position:fixed;z-index:1;pointer-events:auto;margin:0;top:' +
|
|
2218
|
+
box.top +
|
|
2219
|
+
'px;left:' +
|
|
2220
|
+
box.left +
|
|
2221
|
+
'px;width:' +
|
|
2222
|
+
box.width +
|
|
2223
|
+
'px;height:' +
|
|
2224
|
+
box.height +
|
|
2225
|
+
'px;border-radius:' +
|
|
2226
|
+
radius +
|
|
2227
|
+
' 0 0 0'
|
|
2228
|
+
}
|
|
2229
|
+
parkMode = seat
|
|
2230
|
+
}
|
|
2231
|
+
|
|
2232
|
+
/** @returns {string} */
|
|
2233
|
+
function contentRadius() {
|
|
2234
|
+
try {
|
|
2235
|
+
if (typeof getComputedStyle !== 'function') return '0'
|
|
2236
|
+
const overlay = typeof document.querySelector === 'function' ? document.querySelector('[data-shell-overlay]') : null
|
|
2237
|
+
const host =
|
|
2238
|
+
overlay !== null && overlay !== undefined && overlay.parentElement !== null && overlay.parentElement !== undefined
|
|
2239
|
+
? overlay.parentElement
|
|
2240
|
+
: document.documentElement
|
|
2241
|
+
if (host === null || host === undefined) return '0'
|
|
2242
|
+
const value = getComputedStyle(host).getPropertyValue('--dsh-windows-content-radius')
|
|
2243
|
+
return typeof value === 'string' && value.trim() !== '' ? value.trim() : '0'
|
|
2244
|
+
} catch (error) {
|
|
2245
|
+
void error
|
|
2246
|
+
return '0'
|
|
2247
|
+
}
|
|
2248
|
+
}
|
|
2249
|
+
|
|
2250
|
+
/**
|
|
2251
|
+
* @param {string | undefined} seat
|
|
2252
|
+
* @param {any} chosen
|
|
2253
|
+
* @returns {boolean | 'stowed'} true when the park is the guest home and showing
|
|
2254
|
+
*/
|
|
2255
|
+
function placePark(seat, chosen) {
|
|
2256
|
+
// The park is the left page only. A right column, a collapsed column, or
|
|
2257
|
+
// the conversation must never receive this box.
|
|
2258
|
+
if (seat !== 'main' || chosen === null || chosen === undefined || hostArea(chosen) < 2) {
|
|
2259
|
+
const live = parkIsLive()
|
|
2260
|
+
stowPark()
|
|
2261
|
+
return live === true ? 'stowed' : false
|
|
2262
|
+
}
|
|
2263
|
+
const park = ensurePark()
|
|
2264
|
+
if (park === undefined) return false
|
|
2265
|
+
revealPark('main', chosen, park)
|
|
2266
|
+
return true
|
|
2267
|
+
}
|
|
2268
|
+
|
|
2269
|
+
function discardPark() {
|
|
2270
|
+
clearAnchor()
|
|
2271
|
+
const node = parkNode
|
|
2272
|
+
parkNode = undefined
|
|
2273
|
+
parkMode = 'stowed'
|
|
2274
|
+
if (node === undefined || node === null) return
|
|
2275
|
+
try {
|
|
2276
|
+
if (node.parentNode !== null && node.parentNode !== undefined) node.parentNode.removeChild(node)
|
|
2277
|
+
} catch (error) {
|
|
2278
|
+
void error
|
|
2279
|
+
}
|
|
2280
|
+
}
|
|
2281
|
+
|
|
1900
2282
|
function resolveInlineHost() {
|
|
1901
|
-
const
|
|
1902
|
-
const
|
|
1903
|
-
if (
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
|
|
2283
|
+
const main = inlineHosts.main
|
|
2284
|
+
const visible = main !== null && main !== undefined && hostArea(main) >= 2
|
|
2285
|
+
if (visible) {
|
|
2286
|
+
const parked = placePark('main', main)
|
|
2287
|
+
setHost(main)
|
|
2288
|
+
if (parked !== true && parkIsLive() !== true) dropGuestsOutside(main, 'main')
|
|
2289
|
+
void ensureActiveGuest('main')
|
|
2290
|
+
} else {
|
|
2291
|
+
stowPark()
|
|
2292
|
+
setHost(null)
|
|
2293
|
+
// The left page stays in the park. Destroying it here is 「正在打开」
|
|
2294
|
+
// on the way back. Without a park there is nothing to hide.
|
|
2295
|
+
if (parkIsLive() !== true) destroySeat('main', 'no viewport')
|
|
1909
2296
|
}
|
|
1910
|
-
|
|
2297
|
+
const right = inlineHosts.right
|
|
2298
|
+
if (right !== null && right !== undefined && hostArea(right) >= 2) void ensureActiveGuest('right')
|
|
2299
|
+
return visible ? main : null
|
|
2300
|
+
}
|
|
2301
|
+
|
|
2302
|
+
/**
|
|
2303
|
+
* Drop one seat's guests. The other seat keeps its own page.
|
|
2304
|
+
*
|
|
2305
|
+
* @param {'main' | 'right'} seat
|
|
2306
|
+
* @param {string} [reason]
|
|
2307
|
+
*/
|
|
2308
|
+
function destroySeat(seat, reason) {
|
|
2309
|
+
const which = seatOf(seat)
|
|
2310
|
+
for (const record of guests.values()) {
|
|
2311
|
+
if (record.seat !== which) continue
|
|
2312
|
+
record.generation += 1
|
|
2313
|
+
dropGuest(record, reason)
|
|
2314
|
+
record.phase = PHASE.IDLE
|
|
2315
|
+
record.detail = ''
|
|
2316
|
+
if (record.layer !== undefined && record.layer !== null) {
|
|
2317
|
+
try {
|
|
2318
|
+
if (record.layer.parentNode !== null && record.layer.parentNode !== undefined) {
|
|
2319
|
+
record.layer.parentNode.removeChild(record.layer)
|
|
2320
|
+
}
|
|
2321
|
+
} catch (error) {
|
|
2322
|
+
void error
|
|
2323
|
+
}
|
|
2324
|
+
record.layer = undefined
|
|
2325
|
+
}
|
|
2326
|
+
}
|
|
2327
|
+
notify()
|
|
1911
2328
|
}
|
|
1912
2329
|
|
|
1913
2330
|
/** @param {'main' | 'right'} seat @returns {boolean} */
|
|
@@ -1952,7 +2369,9 @@ let activeCtx = undefined
|
|
|
1952
2369
|
const zeroSized = hostArea(host) <= 0
|
|
1953
2370
|
if (!zeroSized || (chosen && seat === 'main')) return seat
|
|
1954
2371
|
}
|
|
1955
|
-
|
|
2372
|
+
// A collapsed right tab stays mounted at 0×0. Treating it as the seat
|
|
2373
|
+
// stows the page and never gives the column a chance to open.
|
|
2374
|
+
return hidden !== undefined && hostArea(inlineHosts[hidden]) > 0 ? hidden : undefined
|
|
1956
2375
|
}
|
|
1957
2376
|
|
|
1958
2377
|
/**
|
|
@@ -1987,10 +2406,21 @@ let activeCtx = undefined
|
|
|
1987
2406
|
|
|
1988
2407
|
function openRightTab() {
|
|
1989
2408
|
try {
|
|
1990
|
-
|
|
2409
|
+
// The right column belongs to the conversation. A global panel (this
|
|
2410
|
+
// chat page included) unmounts that surface, and openTab then throws
|
|
2411
|
+
// "no session surface" — the click looks like the sidebar will not open.
|
|
2412
|
+
const layout = activeCtx !== undefined && typeof activeCtx.get === 'function' ? activeCtx.get('layout') : undefined
|
|
2413
|
+
if (layout !== undefined && layout !== null && typeof layout.selectPanel === 'function') {
|
|
2414
|
+
layout.selectPanel(null)
|
|
2415
|
+
}
|
|
1991
2416
|
} catch (error) {
|
|
1992
2417
|
void error
|
|
1993
2418
|
}
|
|
2419
|
+
try {
|
|
2420
|
+
openRightTabImpl()
|
|
2421
|
+
} catch (error) {
|
|
2422
|
+
log('warn', 'right sidebar did not open', { detail: messageOf(error) })
|
|
2423
|
+
}
|
|
1994
2424
|
}
|
|
1995
2425
|
|
|
1996
2426
|
/** @returns {string} a live self-test of the hosting seat and its box. */
|
|
@@ -2029,12 +2459,13 @@ let activeCtx = undefined
|
|
|
2029
2459
|
host: rect(host === undefined || host === null ? undefined : host.getBoundingClientRect()),
|
|
2030
2460
|
visible: true,
|
|
2031
2461
|
guest: (() => {
|
|
2032
|
-
|
|
2033
|
-
|
|
2462
|
+
const probe = parkIsLive() === true ? parkNode : host
|
|
2463
|
+
if (probe === undefined || probe === null || typeof probe.querySelectorAll !== 'function') {
|
|
2464
|
+
return { present: false, reason: parkIsLive() === true ? 'park has no query' : 'no inline host' }
|
|
2034
2465
|
}
|
|
2035
|
-
const webviews =
|
|
2036
|
-
const layers =
|
|
2037
|
-
const active =
|
|
2466
|
+
const webviews = probe.querySelectorAll('webview')
|
|
2467
|
+
const layers = probe.querySelectorAll('.dce-guest-layer')
|
|
2468
|
+
const active = probe.querySelectorAll('.dce-guest-layer[data-active="true"]')
|
|
2038
2469
|
const inner = document.querySelector('.dce-inline')
|
|
2039
2470
|
return {
|
|
2040
2471
|
present: webviews.length > 0,
|
|
@@ -2042,7 +2473,11 @@ let activeCtx = undefined
|
|
|
2042
2473
|
layers: layers.length,
|
|
2043
2474
|
active: active.length,
|
|
2044
2475
|
surfaceMounted: inner !== null && inner !== undefined,
|
|
2045
|
-
hostBox: rect(
|
|
2476
|
+
hostBox: rect(
|
|
2477
|
+
host === undefined || host === null || typeof host.getBoundingClientRect !== 'function'
|
|
2478
|
+
? undefined
|
|
2479
|
+
: host.getBoundingClientRect(),
|
|
2480
|
+
),
|
|
2046
2481
|
}
|
|
2047
2482
|
})(),
|
|
2048
2483
|
right: rightSidebarStatus(),
|
|
@@ -2175,7 +2610,8 @@ let activeCtx = undefined
|
|
|
2175
2610
|
const workspace = typeof ctx.get === 'function' ? ctx.get('uiWorkspace') : undefined
|
|
2176
2611
|
out.uiWorkspace = workspace !== undefined && workspace !== null
|
|
2177
2612
|
out.uiWorkspaceStartSession = out.uiWorkspace && typeof workspace.startSession === 'function'
|
|
2178
|
-
out.
|
|
2613
|
+
out.patchRunning = patchAction.running
|
|
2614
|
+
out.patchPending = patchAction.pending
|
|
2179
2615
|
out.activeCtx = activeCtx !== undefined && activeCtx !== null
|
|
2180
2616
|
out.probeLoaded = patchProbe.loaded
|
|
2181
2617
|
if (out.service) {
|
|
@@ -2469,9 +2905,8 @@ let activeCtx = undefined
|
|
|
2469
2905
|
|
|
2470
2906
|
/** @returns {'on' | 'off' | 'unknown'} what the mounted guests actually received */
|
|
2471
2907
|
function livePartitionState() {
|
|
2472
|
-
for (const
|
|
2473
|
-
|
|
2474
|
-
if (record === undefined || typeof record.partition !== 'string' || record.partition === '') continue
|
|
2908
|
+
for (const record of guests.values()) {
|
|
2909
|
+
if (typeof record.partition !== 'string' || record.partition === '') continue
|
|
2475
2910
|
return record.partition.startsWith('persist:') ? 'on' : 'off'
|
|
2476
2911
|
}
|
|
2477
2912
|
return 'unknown'
|
|
@@ -2517,6 +2952,21 @@ let activeCtx = undefined
|
|
|
2517
2952
|
return t('persistUnknown')
|
|
2518
2953
|
}
|
|
2519
2954
|
|
|
2955
|
+
/**
|
|
2956
|
+
* Compact size for the cache row. Unknown stays blank so the row can say
|
|
2957
|
+
* "unavailable" instead of pretending the cache is empty.
|
|
2958
|
+
*
|
|
2959
|
+
* @param {unknown} bytes
|
|
2960
|
+
* @returns {string}
|
|
2961
|
+
*/
|
|
2962
|
+
function formatCacheBytes(bytes) {
|
|
2963
|
+
const value = typeof bytes === 'number' ? bytes : Number(bytes)
|
|
2964
|
+
if (!Number.isFinite(value) || value < 0) return ''
|
|
2965
|
+
if (value >= 1024 * 1024) return (value / (1024 * 1024)).toFixed(1) + ' MB'
|
|
2966
|
+
if (value >= 1024) return (value / 1024).toFixed(1) + ' KB'
|
|
2967
|
+
return String(Math.round(value)) + ' B'
|
|
2968
|
+
}
|
|
2969
|
+
|
|
2520
2970
|
/**
|
|
2521
2971
|
* The clipboard copy behind "copy the patch instructions": what to run,
|
|
2522
2972
|
* where the tool is, and how to replace the archive safely.
|
|
@@ -2534,36 +2984,36 @@ let activeCtx = undefined
|
|
|
2534
2984
|
* @param {any} [probe]
|
|
2535
2985
|
* @returns {string}
|
|
2536
2986
|
*/
|
|
2537
|
-
function patchInstructions(t, probe) {
|
|
2987
|
+
function patchInstructions(t, probe, mode) {
|
|
2538
2988
|
const info = probe !== undefined && probe !== null ? probe : {}
|
|
2989
|
+
const action = mode === 'off' ? 'revert' : 'apply'
|
|
2539
2990
|
const command =
|
|
2540
|
-
typeof info
|
|
2541
|
-
? info
|
|
2542
|
-
: 'node tools/shell-patch/patch
|
|
2543
|
-
const lines = [
|
|
2544
|
-
lines.push('
|
|
2545
|
-
lines.push(' ' + command)
|
|
2546
|
-
lines.push(' 脚本会自动探测安装目录并逐字节校验,生成 app.asar.new。')
|
|
2547
|
-
lines.push('')
|
|
2548
|
-
lines.push('2) 完全退出 DSH 后替换(任选其一):')
|
|
2549
|
-
lines.push(' - 运行 tools/shell-patch/watchdog.ps1,退出瞬间自动替换;')
|
|
2550
|
-
lines.push(' - 手动把 resources\\app.asar.new 改名为 app.asar。')
|
|
2991
|
+
typeof info[action + 'Command'] === 'string' && info[action + 'Command'] !== ''
|
|
2992
|
+
? info[action + 'Command']
|
|
2993
|
+
: 'node tools/shell-patch/shell-patch.mjs ' + action
|
|
2994
|
+
const lines = []
|
|
2995
|
+
lines.push(t('persistLabel') + ':' + t('persistConfirmTitle'))
|
|
2551
2996
|
lines.push('')
|
|
2552
|
-
|
|
2997
|
+
if (typeof info.launcher === 'string' && info.launcher !== '') {
|
|
2998
|
+
lines.push(t('patchScriptLabel') + ': ' + info.launcher)
|
|
2999
|
+
}
|
|
3000
|
+
lines.push(t('patchCommandLabel') + ':')
|
|
3001
|
+
lines.push(' ' + command)
|
|
2553
3002
|
lines.push('')
|
|
2554
|
-
lines.push('
|
|
2555
|
-
lines.push('Windows 之外的安装目录请用 --resources 指定。')
|
|
3003
|
+
lines.push(t('patchRestartHint'))
|
|
2556
3004
|
return lines.join('\n')
|
|
2557
3005
|
}
|
|
2558
3006
|
|
|
2559
3007
|
/**
|
|
2560
|
-
*
|
|
2561
|
-
* half answers, so a renderer without Node access can still report where
|
|
2562
|
-
* the shell lives and whether the archive is writable.
|
|
3008
|
+
* State behind the "login across restarts" switch.
|
|
2563
3009
|
*
|
|
2564
|
-
*
|
|
3010
|
+
* Clicking it starts the patch script through the Host. `pending` means a
|
|
3011
|
+
* script is running and waiting for DSH to exit, so the panel stops
|
|
3012
|
+
* pretending a restart is still needed.
|
|
3013
|
+
*
|
|
3014
|
+
* @type {{ running: boolean, pending: boolean, action: string }}
|
|
2565
3015
|
*/
|
|
2566
|
-
const
|
|
3016
|
+
const patchAction = { running: false, pending: false, action: 'on' }
|
|
2567
3017
|
|
|
2568
3018
|
/** One-shot cache of the Host probe, so both actions read the same facts. */
|
|
2569
3019
|
const patchProbe = { loaded: false, value: undefined }
|
|
@@ -2612,118 +3062,137 @@ let activeCtx = undefined
|
|
|
2612
3062
|
}
|
|
2613
3063
|
|
|
2614
3064
|
/**
|
|
2615
|
-
*
|
|
3065
|
+
* What to tell the user when the action did not start.
|
|
2616
3066
|
*
|
|
2617
|
-
*
|
|
2618
|
-
*
|
|
2619
|
-
*
|
|
2620
|
-
|
|
2621
|
-
|
|
3067
|
+
* @param {(key: string) => string} t
|
|
3068
|
+
* @param {any} body the Host's answer, when there was one
|
|
3069
|
+
* @returns {string}
|
|
3070
|
+
*/
|
|
3071
|
+
function patchFallbackText(t, body) {
|
|
3072
|
+
const state = body !== undefined && body !== null && typeof body.state === 'string' ? body.state : ''
|
|
3073
|
+
const detail = body !== undefined && body !== null && typeof body.detail === 'string' ? body.detail : ''
|
|
3074
|
+
const lead =
|
|
3075
|
+
state === 'denied'
|
|
3076
|
+
? t('patchNeedsAdmin')
|
|
3077
|
+
: state === 'noapp'
|
|
3078
|
+
? t('patchNoInstall')
|
|
3079
|
+
: state === 'unsupported'
|
|
3080
|
+
? t('patchNoSite')
|
|
3081
|
+
: state === 'same'
|
|
3082
|
+
? t('patchSame')
|
|
3083
|
+
: t('patchNoRoute')
|
|
3084
|
+
return detail === '' ? lead : lead + ' ' + detail
|
|
3085
|
+
}
|
|
3086
|
+
|
|
3087
|
+
/**
|
|
3088
|
+
* Ask the Host to run the patch script — the switch's whole job.
|
|
3089
|
+
*
|
|
3090
|
+
* A click that can work does not open a dialog: the Host spawns the script,
|
|
3091
|
+
* the script waits for DSH to exit, swaps the archive, and starts DSH
|
|
3092
|
+
* again. The dialog is the fallback for the cases where nothing can be
|
|
3093
|
+
* started from here (an older Host without the route, an install folder
|
|
3094
|
+
* that needs administrator rights, a shell whose patch site moved, no
|
|
3095
|
+
* install at all), and it still carries the exact command, because a user
|
|
3096
|
+
* who cannot click their way out needs something to run.
|
|
2622
3097
|
*
|
|
2623
3098
|
* @param {(key: string) => string} t
|
|
2624
|
-
* @
|
|
3099
|
+
* @param {string} mode 'on' or 'off'
|
|
3100
|
+
* @returns {Promise<{ lead: string, script: string | undefined }>} `lead` is
|
|
3101
|
+
* empty when the script started; otherwise it explains the dialog
|
|
2625
3102
|
*/
|
|
2626
|
-
async function
|
|
2627
|
-
|
|
2628
|
-
|
|
2629
|
-
|
|
2630
|
-
|
|
2631
|
-
|
|
3103
|
+
async function startPatchAction(t, mode) {
|
|
3104
|
+
if (patchAction.running) return { lead: '', script: undefined }
|
|
3105
|
+
patchAction.running = true
|
|
3106
|
+
patchAction.action = mode
|
|
3107
|
+
notify()
|
|
3108
|
+
const action = mode === 'off' ? 'revert' : 'apply'
|
|
3109
|
+
let script
|
|
2632
3110
|
try {
|
|
2633
|
-
log('info', 'patch-
|
|
2634
|
-
const
|
|
2635
|
-
|
|
2636
|
-
|
|
2637
|
-
|
|
2638
|
-
|
|
2639
|
-
|
|
2640
|
-
|
|
2641
|
-
|
|
2642
|
-
|
|
2643
|
-
|
|
3111
|
+
log('info', 'patch-action: entered (' + action + ')')
|
|
3112
|
+
const probe = await fetchProbe()
|
|
3113
|
+
const info = probe !== undefined && probe !== null ? probe : {}
|
|
3114
|
+
if (probe !== undefined && probe !== null) {
|
|
3115
|
+
// The launcher is what a user double-clicks; a platform without one
|
|
3116
|
+
// still gets the script, which is the same thing with a command in
|
|
3117
|
+
// front of it.
|
|
3118
|
+
script =
|
|
3119
|
+
typeof info.launcher === 'string' && info.launcher !== ''
|
|
3120
|
+
? info.launcher
|
|
3121
|
+
: typeof info.script === 'string' && info.script !== ''
|
|
3122
|
+
? info.script
|
|
3123
|
+
: ''
|
|
3124
|
+
}
|
|
3125
|
+
const token = typeof info.token === 'string' ? info.token : ''
|
|
3126
|
+
if (token === '') {
|
|
3127
|
+
log('warn', 'patch-action: the Host has no action route yet')
|
|
3128
|
+
return { lead: t('patchNoRoute'), script }
|
|
2644
3129
|
}
|
|
2645
|
-
|
|
3130
|
+
// The carrier behind these routes answers GET/HEAD only, so the action
|
|
3131
|
+
// is a GET guarded by the token the probe just handed out.
|
|
3132
|
+
const controller = new AbortController()
|
|
3133
|
+
const timer = setTimeout(() => controller.abort(), 8000)
|
|
3134
|
+
let response
|
|
3135
|
+
try {
|
|
3136
|
+
response = await fetch('./dsh-chat-embed/patch?action=' + action + '&token=' + encodeURIComponent(token), {
|
|
3137
|
+
method: 'GET',
|
|
3138
|
+
headers: { accept: 'application/json' },
|
|
3139
|
+
cache: 'no-store',
|
|
3140
|
+
signal: controller.signal,
|
|
3141
|
+
})
|
|
3142
|
+
} finally {
|
|
3143
|
+
clearTimeout(timer)
|
|
3144
|
+
}
|
|
3145
|
+
let body
|
|
3146
|
+
try {
|
|
3147
|
+
body = await response.json()
|
|
3148
|
+
} catch (error) {
|
|
3149
|
+
log('warn', 'patch-action: the answer was not JSON: ' + messageOf(error))
|
|
3150
|
+
body = undefined
|
|
3151
|
+
}
|
|
3152
|
+
if (body !== undefined && body !== null && body.ok === true && body.state === 'started') {
|
|
3153
|
+
patchAction.pending = true
|
|
3154
|
+
log('info', 'patch-action: started ' + action)
|
|
3155
|
+
notify()
|
|
3156
|
+
return { lead: '', script }
|
|
3157
|
+
}
|
|
3158
|
+
log('warn', 'patch-action: not started (' + (body === undefined ? 'no body' : String(body.state)) + ')')
|
|
3159
|
+
return { lead: patchFallbackText(t, body), script }
|
|
3160
|
+
} catch (error) {
|
|
3161
|
+
log('error', 'patch-action: failed', messageOf(error))
|
|
3162
|
+
return { lead: t('patchStartFailed') + ' ' + messageOf(error), script }
|
|
3163
|
+
} finally {
|
|
3164
|
+
patchAction.running = false
|
|
2646
3165
|
notify()
|
|
3166
|
+
}
|
|
3167
|
+
}
|
|
3168
|
+
|
|
3169
|
+
async function copyPatchCommand(t, mode) {
|
|
3170
|
+
// No session, no agent: the script does the whole job, so all this has to
|
|
3171
|
+
// do is put its exact path and command on the clipboard. Every step is
|
|
3172
|
+
// logged and the reason comes back to the dialog, because a click that
|
|
3173
|
+
// does nothing is indistinguishable from a broken build.
|
|
3174
|
+
let failure = ''
|
|
3175
|
+
patchAction.running = true
|
|
3176
|
+
notify()
|
|
3177
|
+
try {
|
|
3178
|
+
log('info', 'patch-command: entered')
|
|
2647
3179
|
const probe = await fetchProbe()
|
|
2648
|
-
log('info', 'patch-
|
|
2649
|
-
const
|
|
2650
|
-
|
|
2651
|
-
|
|
2652
|
-
|
|
2653
|
-
// Hand the main area back to the conversation first.
|
|
2654
|
-
const layout = host !== undefined && typeof host.get === 'function' ? host.get('layout') : undefined
|
|
2655
|
-
if (layout !== undefined && layout !== null && typeof layout.selectPanel === 'function') {
|
|
2656
|
-
log('info', 'patch-check: releasing the main panel before opening the Session')
|
|
2657
|
-
layout.selectPanel(null)
|
|
2658
|
-
}
|
|
2659
|
-
log('info', 'patch-check: opening a Session with a ' + prompt.length + '-char draft')
|
|
2660
|
-
// 'replace', not 'append': the Workspace blank can already hold a draft
|
|
2661
|
-
// from another flow (the plugin-creation template, for one), and appending
|
|
2662
|
-
// would hand the agent two unrelated instructions at once.
|
|
2663
|
-
workspace.startSession(undefined, { prompt, whenDraftExists: 'replace' })
|
|
2664
|
-
log('info', 'patch-check: startSession returned')
|
|
3180
|
+
log('info', 'patch-command: probe ' + (probe === undefined || probe === null ? 'absent' : 'ok'))
|
|
3181
|
+
const text = patchInstructions(t, probe, mode)
|
|
3182
|
+
const copied = await copyText(text)
|
|
3183
|
+
log('info', 'patch-command: clipboard ' + (copied ? 'ok' : 'failed'))
|
|
3184
|
+
if (copied !== true) failure = t('copyFailed')
|
|
2665
3185
|
} catch (error) {
|
|
2666
3186
|
failure = messageOf(error)
|
|
2667
|
-
log('error', 'patch-
|
|
2668
|
-
void copyText(patchInstructions(t, patchProbe.value) + '\n' + t('copyFailed') + ': ' + failure)
|
|
3187
|
+
log('error', 'patch-command: failed', failure)
|
|
2669
3188
|
} finally {
|
|
2670
|
-
|
|
3189
|
+
patchAction.running = false
|
|
2671
3190
|
notify()
|
|
2672
3191
|
}
|
|
2673
3192
|
return failure
|
|
2674
3193
|
}
|
|
2675
3194
|
|
|
2676
|
-
/**
|
|
2677
|
-
* The draft for the other direction: put the original app.asar back.
|
|
2678
|
-
*
|
|
2679
|
-
* Turning the switch off is a real operation, not a dead end — the patch
|
|
2680
|
-
* kept a copy, so undoing it is a rename away.
|
|
2681
|
-
*
|
|
2682
|
-
* @param {(key: string) => string} t
|
|
2683
|
-
* @param {any} [probe]
|
|
2684
|
-
* @returns {string}
|
|
2685
|
-
*/
|
|
2686
|
-
function buildRestorePrompt(t, probe) {
|
|
2687
|
-
const info = probe !== undefined && probe !== null ? probe : {}
|
|
2688
|
-
const lines = [t('restoreTask')]
|
|
2689
|
-
if (typeof info.resources === 'string' && info.resources !== '') {
|
|
2690
|
-
lines.push('', t('patchTaskDir') + ': ' + info.resources)
|
|
2691
|
-
}
|
|
2692
|
-
if (typeof info.asar === 'string' && info.asar !== '') {
|
|
2693
|
-
lines.push('', t('restoreStepsTitle') + ':')
|
|
2694
|
-
lines.push(' 1. ' + info.asar + ' -> ' + info.asar + '.patched.bak')
|
|
2695
|
-
lines.push(' 2. ' + info.asar + '.orig -> ' + info.asar)
|
|
2696
|
-
}
|
|
2697
|
-
if (info.writable === false) lines.push('', t('patchTaskReadonly'))
|
|
2698
|
-
lines.push('', t('restoreWarning'))
|
|
2699
|
-
lines.push('', t('patchTaskVerify'))
|
|
2700
|
-
return lines.join('\n')
|
|
2701
|
-
}
|
|
2702
3195
|
|
|
2703
|
-
/**
|
|
2704
|
-
* The text dropped into the new Session's draft: what is already known, so
|
|
2705
|
-
* the agent starts from facts instead of asking the user to run something.
|
|
2706
|
-
*
|
|
2707
|
-
* @param {(key: string) => string} t
|
|
2708
|
-
* @param {any} probe
|
|
2709
|
-
* @returns {string}
|
|
2710
|
-
*/
|
|
2711
|
-
function buildPatchPrompt(t, probe) {
|
|
2712
|
-
const info = probe !== undefined && probe !== null ? probe : {}
|
|
2713
|
-
// The plugin already knows the state; the draft only says what to do about
|
|
2714
|
-
// it. Anything the patch script enforces itself (byte checks, quitting
|
|
2715
|
-
// first) does not belong here — that is a manual, not an instruction.
|
|
2716
|
-
const lines = [t('patchTask')]
|
|
2717
|
-
const command = typeof info.patchCommand === 'string' && info.patchCommand !== '' ? info.patchCommand : ''
|
|
2718
|
-
if (typeof info.resources === 'string' && info.resources !== '') {
|
|
2719
|
-
lines.push('', t('patchTaskDir') + ': ' + info.resources)
|
|
2720
|
-
}
|
|
2721
|
-
if (command !== '') lines.push('', t('patchTaskCommand') + ':', ' ' + command)
|
|
2722
|
-
if (info.writable === false) lines.push('', t('patchTaskReadonly'))
|
|
2723
|
-
if (info.patchSite === false) lines.push('', t('patchTaskNoSite'))
|
|
2724
|
-
lines.push('', t('patchTaskVerify'))
|
|
2725
|
-
return lines.join('\n')
|
|
2726
|
-
}
|
|
2727
3196
|
|
|
2728
3197
|
/** @returns {{ state: string, detail: string, seats: any[] }} */
|
|
2729
3198
|
function rightSidebarStatus() {
|
|
@@ -2848,18 +3317,19 @@ let activeCtx = undefined
|
|
|
2848
3317
|
*
|
|
2849
3318
|
* @returns {Promise<void>}
|
|
2850
3319
|
*/
|
|
2851
|
-
function ensureActiveGuest() {
|
|
2852
|
-
const
|
|
2853
|
-
const
|
|
3320
|
+
function ensureActiveGuest(seat) {
|
|
3321
|
+
const which = seatOf(seat)
|
|
3322
|
+
const provider = activeProvider(which)
|
|
3323
|
+
const record = guestRecord(provider.id, which)
|
|
2854
3324
|
// A guest whose element was detached with its seat is gone (Electron drops
|
|
2855
3325
|
// the WebContents with the DOM), so a live element is the only reason to
|
|
2856
3326
|
// skip the rebuild.
|
|
2857
3327
|
const element = record.element
|
|
2858
3328
|
if (element !== undefined && element !== null && element.isConnected !== false) return Promise.resolve()
|
|
2859
3329
|
if (record.mounting === true) return Promise.resolve()
|
|
2860
|
-
|
|
2861
|
-
if (
|
|
2862
|
-
return mountGuest(provider.id)
|
|
3330
|
+
const home = guestHome(which)
|
|
3331
|
+
if (home === null || home === undefined) return Promise.resolve()
|
|
3332
|
+
return mountGuest(provider.id, which)
|
|
2863
3333
|
}
|
|
2864
3334
|
|
|
2865
3335
|
/**
|
|
@@ -2869,17 +3339,17 @@ let activeCtx = undefined
|
|
|
2869
3339
|
* @param {string} id
|
|
2870
3340
|
* @returns {Promise<void>}
|
|
2871
3341
|
*/
|
|
2872
|
-
function setActive(id) {
|
|
3342
|
+
function setActive(id, seat) {
|
|
3343
|
+
const which = seatOf(seat)
|
|
2873
3344
|
const provider = findProvider(id)
|
|
2874
3345
|
if (provider === undefined) return Promise.resolve()
|
|
2875
3346
|
if (!isEnabled(provider.id)) return Promise.resolve()
|
|
2876
|
-
if (
|
|
2877
|
-
|
|
2878
|
-
|
|
2879
|
-
syncLayers()
|
|
3347
|
+
if (activeBySeat[which] !== provider.id) {
|
|
3348
|
+
assignSeatActive(which, provider.id)
|
|
3349
|
+
syncLayers(which)
|
|
2880
3350
|
}
|
|
2881
3351
|
notify()
|
|
2882
|
-
return ensureActiveGuest()
|
|
3352
|
+
return ensureActiveGuest(which)
|
|
2883
3353
|
}
|
|
2884
3354
|
|
|
2885
3355
|
// ------------------------------------------------------------------
|
|
@@ -2917,6 +3387,10 @@ let activeCtx = undefined
|
|
|
2917
3387
|
'.dce-icon-button:hover{background:var(--dsw-alias-interactive-bg-hover,rgba(127,127,127,.12))}',
|
|
2918
3388
|
'.dce-icon-button:focus-visible{outline:2px solid var(--dsw-alias-button-primary-fill,#4c6ef5);outline-offset:-2px}',
|
|
2919
3389
|
'.dce-status-bar{position:absolute;top:0;left:0;right:0;z-index:2;display:flex;align-items:center;gap:8px;box-sizing:border-box;padding:4px 10px;border-bottom:1px solid var(--dsw-alias-border-l1,rgba(127,127,127,.18));background:var(--dsw-alias-bg-base,#fff);font-size:12px}',
|
|
3390
|
+
// A pending patch keeps the tab bar pinned open, and the tab bar sits on
|
|
3391
|
+
// the same top edge with a higher z-index — so the strip has to move below
|
|
3392
|
+
// it or it is hidden by the very state it is reporting.
|
|
3393
|
+
'.dce-status-bar[data-patch-pending="true"]{top:33px;z-index:5;}',
|
|
2920
3394
|
'.dce-dot{flex:0 0 auto;width:8px;height:8px;border-radius:50%;background:var(--dsw-alias-label-tertiary,#9aa0a6)}',
|
|
2921
3395
|
'.dce-dot[data-phase="ready"]{background:var(--dsw-alias-state-success-primary,#2ea043)}',
|
|
2922
3396
|
'.dce-dot[data-phase="failed"]{background:var(--dsw-alias-state-error-primary,#d33)}',
|
|
@@ -2931,6 +3405,19 @@ let activeCtx = undefined
|
|
|
2931
3405
|
'.dce-button-primary{border-color:currentColor;color:var(--dsw-alias-button-primary-fill,#4c6ef5)}',
|
|
2932
3406
|
'.dce-surface{position:absolute;inset:0;display:flex;min-height:0}',
|
|
2933
3407
|
'.dce-viewport{position:absolute;inset:0;display:flex;min-width:0;min-height:0}',
|
|
3408
|
+
// The park outlives the panel. Anchor paints it over the seat that is
|
|
3409
|
+
// showing; `hidden` keeps the webview in the document. Chrome stays in
|
|
3410
|
+
// the seat (z-index 2) and the page area does not eat pointer events, so
|
|
3411
|
+
// the webview under it still receives them.
|
|
3412
|
+
'.dce-park{position:fixed;z-index:1;display:flex;min-width:0;min-height:0;overflow:hidden;pointer-events:auto;background:var(--dsw-alias-bg-base,#fff)}',
|
|
3413
|
+
'.dce-park[hidden]{display:none !important}',
|
|
3414
|
+
'.dce-park[data-mode="main"]{border-radius:var(--dsh-windows-content-radius,0) 0 0 0}',
|
|
3415
|
+
'.dce-park[data-mode="main"],.dce-park[data-mode="right"]{position:fixed;position-anchor:--dce-guest-seat;top:anchor(top);left:anchor(left);width:anchor(width);height:anchor(height);margin:0}',
|
|
3416
|
+
'.dce-viewport[data-dce-anchor="true"]{anchor-name:--dce-guest-seat}',
|
|
3417
|
+
'.dce-inline[data-parked="true"]{background:transparent;z-index:2;pointer-events:none}',
|
|
3418
|
+
'.dce-inline[data-parked="true"]>.dce-panel{background:transparent}',
|
|
3419
|
+
'.dce-inline[data-parked="true"] .dce-surface,.dce-inline[data-parked="true"] .dce-viewport{pointer-events:none;background:transparent}',
|
|
3420
|
+
'.dce-inline[data-parked="true"] .dce-hotzone,.dce-inline[data-parked="true"] .dce-tabs,.dce-inline[data-parked="true"] .dce-status-bar,.dce-inline[data-parked="true"] .dce-menu,.dce-inline[data-parked="true"] .dce-menu-scrim,.dce-inline[data-parked="true"] .dce-card,.dce-inline[data-parked="true"] .dce-confirm-scrim{pointer-events:auto}',
|
|
2934
3421
|
'.dce-guest-layer{position:absolute;inset:0;display:none;min-width:0;min-height:0}',
|
|
2935
3422
|
'.dce-guest-layer[data-active="true"]{display:flex}',
|
|
2936
3423
|
'.dce-guest{display:inline-flex;flex:1 1 auto;width:100%;height:100%;border:0;background:transparent}',
|
|
@@ -2952,6 +3439,9 @@ let activeCtx = undefined
|
|
|
2952
3439
|
'.dce-card[data-modal="true"]{z-index:8}',
|
|
2953
3440
|
'.dce-menu-item{display:flex;align-items:center;justify-content:flex-start;gap:8px;width:100%;box-sizing:border-box;padding:6px 8px;border:0;border-radius:6px;background:transparent;color:inherit;font-size:13px;text-align:left;cursor:pointer}',
|
|
2954
3441
|
'.dce-menu-item:hover{background:var(--dsw-alias-interactive-bg-hover,rgba(127,127,127,.12))}',
|
|
3442
|
+
'.dce-menu-action{flex:0 0 auto;border:0;border-radius:6px;padding:3px 8px;background:transparent;color:inherit;font-size:12px;cursor:pointer}',
|
|
3443
|
+
'.dce-menu-action:hover{background:var(--dsw-alias-interactive-bg-hover,rgba(127,127,127,.18))}',
|
|
3444
|
+
'.dce-menu-action:disabled{opacity:.45;cursor:default}',
|
|
2955
3445
|
'.dce-right-title{display:inline-flex;align-items:center;gap:6px;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}',
|
|
2956
3446
|
'.dce-right-dot{width:6px;height:6px;border-radius:50%;background:var(--dsw-alias-state-success-primary,#19a15f);flex:0 0 auto}',
|
|
2957
3447
|
'.dce-right-dot[data-phase="failed"]{background:var(--dsw-alias-state-error-primary,#d33)}',
|
|
@@ -3028,8 +3518,9 @@ let activeCtx = undefined
|
|
|
3028
3518
|
* @param {(key: string) => string} t
|
|
3029
3519
|
* @param {{ phase: string, detail: string }} snapshot
|
|
3030
3520
|
* @param {() => void} [onRetry]
|
|
3521
|
+
* @param {string} [url]
|
|
3031
3522
|
*/
|
|
3032
|
-
function hintCard(title, body, t, snapshot, onRetry) {
|
|
3523
|
+
function hintCard(title, body, t, snapshot, onRetry, url) {
|
|
3033
3524
|
return h(
|
|
3034
3525
|
'div',
|
|
3035
3526
|
{ className: 'dce-card', role: 'status' },
|
|
@@ -3042,15 +3533,16 @@ let activeCtx = undefined
|
|
|
3042
3533
|
onRetry === undefined
|
|
3043
3534
|
? null
|
|
3044
3535
|
: h('button', { type: 'button', className: 'dce-button dce-button-primary', onClick: onRetry }, t('retry')),
|
|
3045
|
-
h('button', { type: 'button', className: 'dce-button', onClick: openInBrowser }, t('openInBrowser')),
|
|
3536
|
+
h('button', { type: 'button', className: 'dce-button', onClick: () => openInBrowser(url) }, t('openInBrowser')),
|
|
3046
3537
|
),
|
|
3047
3538
|
)
|
|
3048
3539
|
}
|
|
3049
3540
|
|
|
3050
3541
|
/** Open the active service in the system browser. */
|
|
3051
|
-
function openInBrowser() {
|
|
3542
|
+
function openInBrowser(url) {
|
|
3543
|
+
const target = typeof url === 'string' && url !== '' ? url : activeProvider().url
|
|
3052
3544
|
try {
|
|
3053
|
-
window.open(
|
|
3545
|
+
window.open(target, '_blank', 'noopener,noreferrer')
|
|
3054
3546
|
} catch (error) {
|
|
3055
3547
|
void error
|
|
3056
3548
|
}
|
|
@@ -3177,9 +3669,9 @@ let activeCtx = undefined
|
|
|
3177
3669
|
/**
|
|
3178
3670
|
* The left-navigation page: the chat itself, hosted by the center panel.
|
|
3179
3671
|
*
|
|
3180
|
-
* The center panel is torn down whenever another panel is selected
|
|
3181
|
-
*
|
|
3182
|
-
*
|
|
3672
|
+
* The center panel is torn down whenever another panel is selected. The
|
|
3673
|
+
* guests do not live in this component — they live in the park — so coming
|
|
3674
|
+
* back shows the same page instead of navigating again.
|
|
3183
3675
|
*/
|
|
3184
3676
|
function ChatCenterPage() {
|
|
3185
3677
|
return h(ChatSurface, { seat: 'main' })
|
|
@@ -3188,8 +3680,8 @@ let activeCtx = undefined
|
|
|
3188
3680
|
/** The right sidebar tab's chip title. */
|
|
3189
3681
|
function ChatRightTitle() {
|
|
3190
3682
|
useStore()
|
|
3191
|
-
const provider = activeProvider()
|
|
3192
|
-
const phase = getStatus().phase
|
|
3683
|
+
const provider = activeProvider('right')
|
|
3684
|
+
const phase = getStatus('right').phase
|
|
3193
3685
|
return h(
|
|
3194
3686
|
'span',
|
|
3195
3687
|
{ className: 'dce-right-title' },
|
|
@@ -3223,9 +3715,10 @@ let activeCtx = undefined
|
|
|
3223
3715
|
function ChatSurface(props) {
|
|
3224
3716
|
const t = translator(props)
|
|
3225
3717
|
useStore()
|
|
3226
|
-
const
|
|
3718
|
+
const seatName = props !== undefined && props !== null && props.seat === 'right' ? 'right' : 'main'
|
|
3719
|
+
const snapshot = getStatus(seatName)
|
|
3227
3720
|
|
|
3228
|
-
const provider = activeProvider()
|
|
3721
|
+
const provider = activeProvider(seatName)
|
|
3229
3722
|
const hostRef = React.useRef(null)
|
|
3230
3723
|
const listRef = React.useRef(null)
|
|
3231
3724
|
/** @type {React.MutableRefObject<{ id: string, startX: number, active: boolean } | undefined>} */
|
|
@@ -3236,61 +3729,41 @@ let activeCtx = undefined
|
|
|
3236
3729
|
const [, bumpDrag] = React.useState(0)
|
|
3237
3730
|
const repaintDrag = () => bumpDrag((value) => value + 1)
|
|
3238
3731
|
|
|
3239
|
-
|
|
3240
|
-
|
|
3241
|
-
//
|
|
3242
|
-
// seats can exist at a time (the right sidebar needs a Session surface),
|
|
3243
|
-
// so the seat that just rendered is the one that owns the guests.
|
|
3732
|
+
// Each seat hosts its own page. Registering the viewport must not hand
|
|
3733
|
+
// the other seat's webview across, and a closed right column must not
|
|
3734
|
+
// paint anything onto the conversation.
|
|
3244
3735
|
useMountEffect(() => {
|
|
3245
|
-
const visible = seatName === 'main' || props.active !== false
|
|
3246
|
-
if (visible) preferSeat(seatName)
|
|
3247
|
-
return undefined
|
|
3248
|
-
}, [])
|
|
3249
|
-
|
|
3250
|
-
// `preferredSeat === seatName` must count as hosting even before this seat
|
|
3251
|
-
// is registered: the registration effect only runs once the viewport is
|
|
3252
|
-
// committed, so requiring a registered host first would deadlock.
|
|
3253
|
-
const hostingSeat = inlineSeat()
|
|
3254
|
-
const hosting =
|
|
3255
|
-
hostingSeat === undefined ||
|
|
3256
|
-
hostingSeat === seatName ||
|
|
3257
|
-
preferredSeat === seatName ||
|
|
3258
|
-
// A selected right tab is a user request too: it must render its
|
|
3259
|
-
// viewport so it can register and take the guests over.
|
|
3260
|
-
(seatName === 'right' && props.active === true)
|
|
3261
|
-
React.useEffect(() => {
|
|
3262
3736
|
const node = hostRef.current
|
|
3263
|
-
if (
|
|
3737
|
+
if (node === null || node === undefined) return undefined
|
|
3264
3738
|
inlineHosts[seatName] = node
|
|
3265
|
-
if (
|
|
3266
|
-
|
|
3739
|
+
if (seatName === 'main') {
|
|
3740
|
+
resolveInlineHost()
|
|
3741
|
+
} else if (hostArea(node) >= 2 && props.active !== false) {
|
|
3742
|
+
void ensureActiveGuest('right')
|
|
3743
|
+
}
|
|
3267
3744
|
notify()
|
|
3268
|
-
// A collapsed right tab is 0×0 and must not steal the page; when the user
|
|
3269
|
-
// expands the column the tab gets a box, and that is the moment to hand
|
|
3270
|
-
// the guests over. The observer only re-runs the seat choice.
|
|
3271
3745
|
let ro
|
|
3272
|
-
if (typeof ResizeObserver === 'function'
|
|
3746
|
+
if (typeof ResizeObserver === 'function') {
|
|
3273
3747
|
ro = new ResizeObserver(() => {
|
|
3274
|
-
if (
|
|
3748
|
+
if (seatName === 'main') {
|
|
3749
|
+
resolveInlineHost()
|
|
3750
|
+
return
|
|
3751
|
+
}
|
|
3752
|
+
if (props.active === false || hostArea(node) < 2) return
|
|
3753
|
+
void ensureActiveGuest('right')
|
|
3275
3754
|
})
|
|
3276
3755
|
ro.observe(node)
|
|
3277
3756
|
}
|
|
3278
3757
|
return () => {
|
|
3279
3758
|
if (ro !== undefined) ro.disconnect()
|
|
3280
3759
|
if (inlineHosts[seatName] === node) inlineHosts[seatName] = null
|
|
3281
|
-
if (
|
|
3282
|
-
|
|
3760
|
+
if (seatName === 'main') {
|
|
3761
|
+
stowPark()
|
|
3762
|
+
if (parkIsLive() !== true) destroySeat('main', 'no viewport')
|
|
3763
|
+
}
|
|
3283
3764
|
notify()
|
|
3284
3765
|
}
|
|
3285
|
-
}, [
|
|
3286
|
-
|
|
3287
|
-
// Selecting the right tab hands the chat to that column, so the panel the
|
|
3288
|
-
// user is actually looking at is the one that shows it.
|
|
3289
|
-
React.useEffect(() => {
|
|
3290
|
-
if (seatName !== 'right' || props.active === false) return undefined
|
|
3291
|
-
if (preferredSeat !== 'right') preferSeat('right')
|
|
3292
|
-
return undefined
|
|
3293
|
-
}, [props.active])
|
|
3766
|
+
}, [])
|
|
3294
3767
|
|
|
3295
3768
|
// Pointer-driven tab reordering. Dragging is armed on pointerdown and
|
|
3296
3769
|
// only starts after a small threshold, so a plain click still selects.
|
|
@@ -3371,8 +3844,21 @@ let activeCtx = undefined
|
|
|
3371
3844
|
const [barOpen, setBarOpen] = React.useState(false)
|
|
3372
3845
|
const [menuOpen, setMenuOpen] = React.useState(false)
|
|
3373
3846
|
const [confirmOpen, setConfirmOpen] = React.useState(false)
|
|
3847
|
+
const [cacheReport, setCacheReport] = React.useState(undefined)
|
|
3848
|
+
const [cacheBusy, setCacheBusy] = React.useState(false)
|
|
3849
|
+
const [cacheConfirm, setCacheConfirm] = React.useState(false)
|
|
3374
3850
|
const [confirmError, setConfirmError] = React.useState('')
|
|
3375
3851
|
const [confirmMode, setConfirmMode] = React.useState('on')
|
|
3852
|
+
// Why the dialog is open at all: the action could not start, and this
|
|
3853
|
+
// line says which reason applied. Empty on a dialog opened by a click
|
|
3854
|
+
// that never tried to start anything.
|
|
3855
|
+
const [confirmLead, setConfirmLead] = React.useState('')
|
|
3856
|
+
// The launcher path the dialog names. Three states, because "still
|
|
3857
|
+
// asking the Host" must not read as "this install has no script":
|
|
3858
|
+
// undefined the probe has not answered yet
|
|
3859
|
+
// '' it answered, and there is no launcher
|
|
3860
|
+
// '<path>' the file to double-click
|
|
3861
|
+
const [confirmScript, setConfirmScript] = React.useState(undefined)
|
|
3376
3862
|
|
|
3377
3863
|
/**
|
|
3378
3864
|
* Close the settings menu.
|
|
@@ -3383,6 +3869,68 @@ let activeCtx = undefined
|
|
|
3383
3869
|
const closeMenu = () => {
|
|
3384
3870
|
setMenuOpen(false)
|
|
3385
3871
|
}
|
|
3872
|
+
|
|
3873
|
+
/**
|
|
3874
|
+
* Ask the Host how much of this panel's partitions the clear button would
|
|
3875
|
+
* remove. Opening the menu is the event; nothing polls.
|
|
3876
|
+
*/
|
|
3877
|
+
const refreshCache = () => {
|
|
3878
|
+
const controller = new AbortController()
|
|
3879
|
+
const timer = setTimeout(() => controller.abort(), 4000)
|
|
3880
|
+
fetch('./dsh-chat-embed/cache', {
|
|
3881
|
+
method: 'GET',
|
|
3882
|
+
headers: { accept: 'application/json' },
|
|
3883
|
+
cache: 'no-store',
|
|
3884
|
+
signal: controller.signal,
|
|
3885
|
+
})
|
|
3886
|
+
.then((response) => (response.ok ? response.json() : undefined))
|
|
3887
|
+
.then((body) => {
|
|
3888
|
+
setCacheReport(body)
|
|
3889
|
+
})
|
|
3890
|
+
.catch((error) => {
|
|
3891
|
+
setCacheReport(undefined)
|
|
3892
|
+
log('warn', 'cache: size route did not answer: ' + messageOf(error))
|
|
3893
|
+
})
|
|
3894
|
+
.finally(() => {
|
|
3895
|
+
clearTimeout(timer)
|
|
3896
|
+
})
|
|
3897
|
+
}
|
|
3898
|
+
|
|
3899
|
+
/**
|
|
3900
|
+
* Start the script. The Host does not delete; the script re-reads the
|
|
3901
|
+
* archive and refuses to touch any partition that is not one of the seven.
|
|
3902
|
+
*/
|
|
3903
|
+
const requestCacheClear = () => {
|
|
3904
|
+
const info = cacheReport !== undefined && cacheReport !== null ? cacheReport : {}
|
|
3905
|
+
const token = typeof info.token === 'string' ? info.token : ''
|
|
3906
|
+
if (token === '' || cacheBusy) return
|
|
3907
|
+
setCacheBusy(true)
|
|
3908
|
+
setCacheConfirm(false)
|
|
3909
|
+
const controller = new AbortController()
|
|
3910
|
+
const timer = setTimeout(() => controller.abort(), 60000)
|
|
3911
|
+
fetch('./dsh-chat-embed/cache-clear?token=' + encodeURIComponent(token), {
|
|
3912
|
+
method: 'GET',
|
|
3913
|
+
headers: { accept: 'application/json' },
|
|
3914
|
+
cache: 'no-store',
|
|
3915
|
+
signal: controller.signal,
|
|
3916
|
+
})
|
|
3917
|
+
.then((response) => (response.ok ? response.json() : undefined))
|
|
3918
|
+
.then((body) => {
|
|
3919
|
+
if (body === undefined || body === null) {
|
|
3920
|
+
setCacheReport({ ...info, detail: t('cacheFailed') })
|
|
3921
|
+
return
|
|
3922
|
+
}
|
|
3923
|
+
setCacheReport({ ...info, ...body, token })
|
|
3924
|
+
})
|
|
3925
|
+
.catch((error) => {
|
|
3926
|
+
setCacheReport({ ...info, ok: false, detail: messageOf(error) })
|
|
3927
|
+
log('warn', 'cache: clear did not finish: ' + messageOf(error))
|
|
3928
|
+
})
|
|
3929
|
+
.finally(() => {
|
|
3930
|
+
clearTimeout(timer)
|
|
3931
|
+
setCacheBusy(false)
|
|
3932
|
+
})
|
|
3933
|
+
}
|
|
3386
3934
|
const [copyState, setCopyState] = React.useState('')
|
|
3387
3935
|
const barTimerRef = React.useRef(0)
|
|
3388
3936
|
const cancelBarTimer = () => {
|
|
@@ -3446,19 +3994,23 @@ let activeCtx = undefined
|
|
|
3446
3994
|
})
|
|
3447
3995
|
}
|
|
3448
3996
|
const onReload = () => {
|
|
3449
|
-
void reloadGuest(provider.id)
|
|
3997
|
+
void reloadGuest(provider.id, seatName)
|
|
3450
3998
|
}
|
|
3451
|
-
const record = guestRecord(provider.id)
|
|
3999
|
+
const record = guestRecord(provider.id, seatName)
|
|
3452
4000
|
|
|
3453
4001
|
// The status strip only earns its space while something is happening or
|
|
3454
|
-
// wrong; a healthy tab shows nothing but its tabs.
|
|
3455
|
-
|
|
4002
|
+
// wrong; a healthy tab shows nothing but its tabs. A pending patch is
|
|
4003
|
+
// "something is happening": the script is waiting for DSH to exit, and
|
|
4004
|
+
// the user has to quit it from the tray, so say so where they look.
|
|
4005
|
+
const patchPending = patchAction.pending
|
|
4006
|
+
const showStatus = patchPending || snapshot.phase !== PHASE.READY && snapshot.phase !== PHASE.IDLE
|
|
3456
4007
|
// A problem keeps the bar reachable without hunting for it.
|
|
3457
4008
|
const barVisible =
|
|
3458
4009
|
barOpen ||
|
|
3459
4010
|
menuOpen ||
|
|
3460
4011
|
record.diagOpen ||
|
|
3461
4012
|
record.oauthBlocked ||
|
|
4013
|
+
patchPending ||
|
|
3462
4014
|
snapshot.phase === PHASE.FAILED
|
|
3463
4015
|
const reloadTitle =
|
|
3464
4016
|
t('reload') +
|
|
@@ -3473,6 +4025,9 @@ let activeCtx = undefined
|
|
|
3473
4025
|
'data-visible': 'true',
|
|
3474
4026
|
'data-mode': 'inline',
|
|
3475
4027
|
'data-seat': seatName,
|
|
4028
|
+
// True on the first paint, not after an effect: otherwise the panel's
|
|
4029
|
+
// own background covers the park for a frame and the page looks late.
|
|
4030
|
+
'data-parked': seatName === 'main' && shellFramePresent() === true ? 'true' : 'false',
|
|
3476
4031
|
'data-build': BUILD,
|
|
3477
4032
|
'aria-hidden': 'false',
|
|
3478
4033
|
},
|
|
@@ -3507,7 +4062,7 @@ let activeCtx = undefined
|
|
|
3507
4062
|
className: 'dce-tab',
|
|
3508
4063
|
'data-tab-id': entry.id,
|
|
3509
4064
|
'data-active': entry.id === provider.id ? 'true' : 'false',
|
|
3510
|
-
'data-failed': guestRecord(entry.id).phase === PHASE.FAILED ? 'true' : 'false',
|
|
4065
|
+
'data-failed': guestRecord(entry.id, seatName).phase === PHASE.FAILED ? 'true' : 'false',
|
|
3511
4066
|
'data-dragging':
|
|
3512
4067
|
dragRef.current !== undefined &&
|
|
3513
4068
|
dragRef.current.active === true &&
|
|
@@ -3526,7 +4081,7 @@ let activeCtx = undefined
|
|
|
3526
4081
|
suppressClickRef.current = false
|
|
3527
4082
|
return
|
|
3528
4083
|
}
|
|
3529
|
-
void setActive(entry.id)
|
|
4084
|
+
void setActive(entry.id, seatName)
|
|
3530
4085
|
},
|
|
3531
4086
|
},
|
|
3532
4087
|
entry.label,
|
|
@@ -3570,7 +4125,10 @@ let activeCtx = undefined
|
|
|
3570
4125
|
'aria-expanded': menuOpen ? 'true' : 'false',
|
|
3571
4126
|
onClick: () => {
|
|
3572
4127
|
if (menuOpen) closeMenu()
|
|
3573
|
-
else
|
|
4128
|
+
else {
|
|
4129
|
+
setMenuOpen(true)
|
|
4130
|
+
refreshCache()
|
|
4131
|
+
}
|
|
3574
4132
|
openBar()
|
|
3575
4133
|
},
|
|
3576
4134
|
},
|
|
@@ -3630,16 +4188,83 @@ let activeCtx = undefined
|
|
|
3630
4188
|
'data-persist-open': 'true',
|
|
3631
4189
|
'aria-label': t('persistLabel'),
|
|
3632
4190
|
title: t('persistCheckHint'),
|
|
3633
|
-
disabled:
|
|
4191
|
+
disabled: patchAction.running,
|
|
3634
4192
|
onClick: () => {
|
|
3635
|
-
|
|
4193
|
+
// The switch is the control, not a question: a click that
|
|
4194
|
+
// can work starts the script straight away. The dialog is
|
|
4195
|
+
// the fallback, so it only opens when nothing started.
|
|
4196
|
+
const target = persistenceState() === 'on' ? 'off' : 'on'
|
|
4197
|
+
log('info', 'patch: restart-login switch -> ' + target)
|
|
3636
4198
|
closeMenu()
|
|
3637
|
-
|
|
3638
|
-
|
|
3639
|
-
|
|
4199
|
+
void startPatchAction(t, target).then(
|
|
4200
|
+
(outcome) => {
|
|
4201
|
+
if (outcome === undefined || outcome === null || outcome.lead === '') return
|
|
4202
|
+
setConfirmMode(target)
|
|
4203
|
+
setConfirmLead(outcome.lead)
|
|
4204
|
+
setConfirmScript(outcome.script)
|
|
4205
|
+
setConfirmOpen(true)
|
|
4206
|
+
notify()
|
|
4207
|
+
},
|
|
4208
|
+
(error) => {
|
|
4209
|
+
log('error', 'patch: startPatchAction rejected', messageOf(error))
|
|
4210
|
+
},
|
|
4211
|
+
)
|
|
3640
4212
|
},
|
|
3641
4213
|
}),
|
|
3642
4214
|
),
|
|
4215
|
+
h(
|
|
4216
|
+
'div',
|
|
4217
|
+
{ className: 'dce-menu-row', 'data-cache-row': 'true' },
|
|
4218
|
+
h(
|
|
4219
|
+
'span',
|
|
4220
|
+
{
|
|
4221
|
+
className: 'dce-menu-label',
|
|
4222
|
+
title:
|
|
4223
|
+
cacheReport !== undefined && cacheReport !== null && cacheReport.mode === 'keep'
|
|
4224
|
+
? t('cacheKeepHint')
|
|
4225
|
+
: cacheReport !== undefined && cacheReport !== null && cacheReport.mode === 'purge'
|
|
4226
|
+
? t('cachePurgeHint')
|
|
4227
|
+
: t('cacheUnavailable'),
|
|
4228
|
+
},
|
|
4229
|
+
t('cacheLabel') +
|
|
4230
|
+
' ' +
|
|
4231
|
+
(cacheReport === undefined || cacheReport === null || cacheReport.ok !== true
|
|
4232
|
+
? t('cacheUnavailable')
|
|
4233
|
+
: formatCacheBytes(cacheReport.bytes)),
|
|
4234
|
+
),
|
|
4235
|
+
h(
|
|
4236
|
+
'button',
|
|
4237
|
+
{
|
|
4238
|
+
type: 'button',
|
|
4239
|
+
className: 'dce-menu-action',
|
|
4240
|
+
'data-cache-clear': 'true',
|
|
4241
|
+
disabled:
|
|
4242
|
+
cacheBusy ||
|
|
4243
|
+
cacheReport === undefined ||
|
|
4244
|
+
cacheReport === null ||
|
|
4245
|
+
cacheReport.ok !== true ||
|
|
4246
|
+
cacheReport.bytes === 0,
|
|
4247
|
+
title:
|
|
4248
|
+
cacheReport !== undefined &&
|
|
4249
|
+
cacheReport !== null &&
|
|
4250
|
+
typeof cacheReport.detail === 'string' &&
|
|
4251
|
+
cacheReport.detail !== ''
|
|
4252
|
+
? t('cacheFailed') + ' ' + cacheReport.detail
|
|
4253
|
+
: cacheReport !== undefined && cacheReport !== null && cacheReport.mode === 'purge'
|
|
4254
|
+
? t('cachePurgeHint')
|
|
4255
|
+
: t('cacheKeepHint'),
|
|
4256
|
+
onClick: () => {
|
|
4257
|
+
if (cacheReport !== undefined && cacheReport !== null && cacheReport.mode === 'purge') {
|
|
4258
|
+
closeMenu()
|
|
4259
|
+
setCacheConfirm(true)
|
|
4260
|
+
return
|
|
4261
|
+
}
|
|
4262
|
+
requestCacheClear()
|
|
4263
|
+
},
|
|
4264
|
+
},
|
|
4265
|
+
cacheBusy ? t('cacheClearing') : t('cacheClear'),
|
|
4266
|
+
),
|
|
4267
|
+
),
|
|
3643
4268
|
h(
|
|
3644
4269
|
'button',
|
|
3645
4270
|
{
|
|
@@ -3699,10 +4324,14 @@ let activeCtx = undefined
|
|
|
3699
4324
|
{ className: 'dce-card-title' },
|
|
3700
4325
|
t(confirmMode === 'off' ? 'persistOffTitle' : 'persistConfirmTitle'),
|
|
3701
4326
|
),
|
|
4327
|
+
confirmLead === '' ? null : h('div', { className: 'dce-card-body', 'data-persist-lead': 'true' }, confirmLead),
|
|
3702
4328
|
h('div', { className: 'dce-card-body' }, t(confirmMode === 'off' ? 'persistOffBody' : 'persistRisk')),
|
|
3703
|
-
confirmMode === 'off'
|
|
4329
|
+
confirmMode === 'off' ? null : h('div', { className: 'dce-card-body' }, t('persistConfirmNote')),
|
|
4330
|
+
confirmScript === undefined
|
|
3704
4331
|
? null
|
|
3705
|
-
:
|
|
4332
|
+
: confirmScript === ''
|
|
4333
|
+
? h('div', { className: 'dce-card-body' }, t('patchScriptMissing'))
|
|
4334
|
+
: h('div', { className: 'dce-card-detail' }, confirmScript),
|
|
3706
4335
|
confirmError === '' ? null : h('div', { className: 'dce-card-detail' }, confirmError),
|
|
3707
4336
|
h(
|
|
3708
4337
|
'div',
|
|
@@ -3718,18 +4347,18 @@ let activeCtx = undefined
|
|
|
3718
4347
|
type: 'button',
|
|
3719
4348
|
className: 'dce-button dce-button-primary',
|
|
3720
4349
|
'data-persist-confirm': 'true',
|
|
3721
|
-
disabled:
|
|
4350
|
+
disabled: patchAction.running,
|
|
3722
4351
|
onClick: () => {
|
|
3723
4352
|
log('info', 'dialog: the confirm button was clicked')
|
|
3724
4353
|
setConfirmError('')
|
|
3725
|
-
void
|
|
4354
|
+
void copyPatchCommand(t, confirmMode).then(
|
|
3726
4355
|
(failure) => {
|
|
3727
4356
|
if (typeof failure === 'string' && failure !== '') setConfirmError(failure)
|
|
3728
4357
|
else setConfirmOpen(false)
|
|
3729
4358
|
},
|
|
3730
4359
|
(error) => {
|
|
3731
4360
|
const reason = messageOf(error)
|
|
3732
|
-
log('error', 'dialog:
|
|
4361
|
+
log('error', 'dialog: copyPatchCommand rejected', reason)
|
|
3733
4362
|
setConfirmError(reason)
|
|
3734
4363
|
},
|
|
3735
4364
|
)
|
|
@@ -3740,13 +4369,73 @@ let activeCtx = undefined
|
|
|
3740
4369
|
),
|
|
3741
4370
|
)
|
|
3742
4371
|
: null,
|
|
4372
|
+
cacheConfirm
|
|
4373
|
+
? h('div', {
|
|
4374
|
+
className: 'dce-confirm-scrim',
|
|
4375
|
+
onPointerDown: () => setCacheConfirm(false),
|
|
4376
|
+
})
|
|
4377
|
+
: null,
|
|
4378
|
+
cacheConfirm
|
|
4379
|
+
? h(
|
|
4380
|
+
'div',
|
|
4381
|
+
{
|
|
4382
|
+
className: 'dce-card',
|
|
4383
|
+
role: 'dialog',
|
|
4384
|
+
'aria-modal': 'true',
|
|
4385
|
+
'data-modal': 'true',
|
|
4386
|
+
'data-cache-confirm': 'true',
|
|
4387
|
+
'aria-label': t('cachePurgeTitle'),
|
|
4388
|
+
},
|
|
4389
|
+
h('div', { className: 'dce-card-title' }, t('cachePurgeTitle')),
|
|
4390
|
+
h('div', { className: 'dce-card-body' }, t('cachePurgeBody')),
|
|
4391
|
+
h(
|
|
4392
|
+
'div',
|
|
4393
|
+
{ className: 'dce-card-actions' },
|
|
4394
|
+
h(
|
|
4395
|
+
'button',
|
|
4396
|
+
{
|
|
4397
|
+
type: 'button',
|
|
4398
|
+
className: 'dce-button',
|
|
4399
|
+
'data-cache-cancel': 'true',
|
|
4400
|
+
onClick: () => setCacheConfirm(false),
|
|
4401
|
+
},
|
|
4402
|
+
t('persistConfirmCancel'),
|
|
4403
|
+
),
|
|
4404
|
+
h(
|
|
4405
|
+
'button',
|
|
4406
|
+
{
|
|
4407
|
+
type: 'button',
|
|
4408
|
+
className: 'dce-button dce-button-primary',
|
|
4409
|
+
'data-cache-confirm-go': 'true',
|
|
4410
|
+
disabled: cacheBusy,
|
|
4411
|
+
onClick: () => {
|
|
4412
|
+
requestCacheClear()
|
|
4413
|
+
},
|
|
4414
|
+
},
|
|
4415
|
+
t('cachePurgeGo'),
|
|
4416
|
+
),
|
|
4417
|
+
),
|
|
4418
|
+
)
|
|
4419
|
+
: null,
|
|
3743
4420
|
showStatus
|
|
3744
4421
|
? h(
|
|
3745
4422
|
'div',
|
|
3746
|
-
{ className: 'dce-status-bar' },
|
|
3747
|
-
h('span', {
|
|
3748
|
-
|
|
3749
|
-
|
|
4423
|
+
{ className: 'dce-status-bar', 'data-patch-pending': patchPending ? 'true' : 'false' },
|
|
4424
|
+
h('span', {
|
|
4425
|
+
className: 'dce-dot',
|
|
4426
|
+
'data-phase': patchPending ? 'pending' : snapshot.phase,
|
|
4427
|
+
'aria-hidden': true,
|
|
4428
|
+
}),
|
|
4429
|
+
h(
|
|
4430
|
+
'span',
|
|
4431
|
+
{ className: 'dce-status' },
|
|
4432
|
+
patchPending ? t('patchPending') : t(STATUS_KEY[snapshot.phase] || 'statusIdle'),
|
|
4433
|
+
),
|
|
4434
|
+
patchPending
|
|
4435
|
+
? h('span', { className: 'dce-diag' }, t('patchPendingHint'))
|
|
4436
|
+
: snapshot.detail === ''
|
|
4437
|
+
? null
|
|
4438
|
+
: h('span', { className: 'dce-diag' }, snapshot.detail),
|
|
3750
4439
|
)
|
|
3751
4440
|
: null,
|
|
3752
4441
|
h(
|
|
@@ -3754,10 +4443,10 @@ let activeCtx = undefined
|
|
|
3754
4443
|
{ className: 'dce-surface' },
|
|
3755
4444
|
h('div', { className: 'dce-viewport', ref: hostRef }),
|
|
3756
4445
|
snapshot.phase === PHASE.UNSUPPORTED
|
|
3757
|
-
? hintCard(t('statusUnsupported'), t('unsupportedHint'), t, snapshot)
|
|
4446
|
+
? hintCard(t('statusUnsupported'), t('unsupportedHint'), t, snapshot, undefined, provider.url)
|
|
3758
4447
|
: null,
|
|
3759
4448
|
snapshot.phase === PHASE.FAILED
|
|
3760
|
-
? hintCard(t('statusFailed'), t('failedHint'), t, snapshot, onReload)
|
|
4449
|
+
? hintCard(t('statusFailed'), t('failedHint'), t, snapshot, onReload, provider.url)
|
|
3761
4450
|
: null,
|
|
3762
4451
|
record.oauthBlocked
|
|
3763
4452
|
? h(
|
|
@@ -3977,16 +4666,17 @@ let activeCtx = undefined
|
|
|
3977
4666
|
updateSurface,
|
|
3978
4667
|
getLogging,
|
|
3979
4668
|
persistenceState,
|
|
4669
|
+
formatCacheBytes,
|
|
3980
4670
|
readPersistedSeen,
|
|
3981
4671
|
storePersistenceSeen,
|
|
3982
4672
|
livePartitionState,
|
|
3983
4673
|
patchInstructions,
|
|
3984
4674
|
fetchProbe,
|
|
3985
4675
|
patchProbe,
|
|
3986
|
-
|
|
3987
|
-
|
|
3988
|
-
|
|
3989
|
-
|
|
4676
|
+
patchAction,
|
|
4677
|
+
startPatchAction,
|
|
4678
|
+
patchFallbackText,
|
|
4679
|
+
copyPatchCommand,
|
|
3990
4680
|
setLogging,
|
|
3991
4681
|
clearLog,
|
|
3992
4682
|
readLogEntries,
|