dsh-chat-embed 0.6.14 → 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 +6 -5
- package/client.js +605 -199
- package/package.json +1 -1
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__'
|
|
@@ -843,21 +845,38 @@ let activeCtx = undefined
|
|
|
843
845
|
// Active tab
|
|
844
846
|
// ------------------------------------------------------------------
|
|
845
847
|
|
|
846
|
-
|
|
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) {
|
|
847
863
|
try {
|
|
848
864
|
if (typeof localStorage === 'undefined' || localStorage === null) return DEFAULT_PROVIDER
|
|
849
|
-
const stored = localStorage.getItem(
|
|
865
|
+
const stored = localStorage.getItem(activeStorageKey(seat))
|
|
850
866
|
return findProvider(stored) === undefined ? DEFAULT_PROVIDER : stored
|
|
851
867
|
} catch (error) {
|
|
852
868
|
return DEFAULT_PROVIDER
|
|
853
869
|
}
|
|
854
870
|
}
|
|
855
871
|
|
|
856
|
-
/**
|
|
857
|
-
|
|
872
|
+
/**
|
|
873
|
+
* @param {string} id
|
|
874
|
+
* @param {'main' | 'right' | undefined} [seat]
|
|
875
|
+
*/
|
|
876
|
+
function storeActive(id, seat) {
|
|
858
877
|
try {
|
|
859
878
|
if (typeof localStorage === 'undefined' || localStorage === null) return
|
|
860
|
-
localStorage.setItem(
|
|
879
|
+
localStorage.setItem(activeStorageKey(seat), id)
|
|
861
880
|
} catch (error) {
|
|
862
881
|
void error
|
|
863
882
|
}
|
|
@@ -1003,32 +1022,40 @@ let activeCtx = undefined
|
|
|
1003
1022
|
enabledIds = normalizeEnabled(tabOrder.filter((entryId) => entryId === id || isEnabled(entryId)))
|
|
1004
1023
|
} else {
|
|
1005
1024
|
enabledIds = enabledIds.filter((entryId) => entryId !== id)
|
|
1006
|
-
const
|
|
1007
|
-
|
|
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
|
+
}
|
|
1008
1029
|
}
|
|
1009
1030
|
storeEnabled()
|
|
1010
1031
|
|
|
1011
|
-
if (on === false &&
|
|
1032
|
+
if (on === false && (activeBySeat.main === id || activeBySeat.right === id)) {
|
|
1012
1033
|
const next = firstEnabled()
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
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
|
+
}
|
|
1016
1040
|
notify()
|
|
1017
|
-
void ensureActiveGuest()
|
|
1018
1041
|
return true
|
|
1019
1042
|
}
|
|
1020
1043
|
notify()
|
|
1021
|
-
if (on)
|
|
1044
|
+
if (on) {
|
|
1045
|
+
void ensureActiveGuest('main')
|
|
1046
|
+
void ensureActiveGuest('right')
|
|
1047
|
+
}
|
|
1022
1048
|
return true
|
|
1023
1049
|
}
|
|
1024
1050
|
|
|
1025
1051
|
/** Move the active tab to a still-enabled provider when it was hidden. */
|
|
1026
1052
|
function reconcileActive() {
|
|
1027
|
-
if (isEnabled(state.active)) return
|
|
1028
1053
|
const next = findProvider(firstEnabled())
|
|
1029
1054
|
if (next === undefined) return
|
|
1030
|
-
|
|
1031
|
-
|
|
1055
|
+
for (const seat of ['main', 'right']) {
|
|
1056
|
+
if (isEnabled(activeBySeat[seat])) continue
|
|
1057
|
+
assignSeatActive(seat, next.id)
|
|
1058
|
+
}
|
|
1032
1059
|
}
|
|
1033
1060
|
|
|
1034
1061
|
/**
|
|
@@ -1057,15 +1084,35 @@ let activeCtx = undefined
|
|
|
1057
1084
|
|
|
1058
1085
|
/** @type {{ active: string, surface: { host: any } }} */
|
|
1059
1086
|
const state = {
|
|
1060
|
-
active: readStoredActive(),
|
|
1087
|
+
active: readStoredActive('main'),
|
|
1061
1088
|
surface: { host: null },
|
|
1062
1089
|
}
|
|
1063
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
|
+
|
|
1064
1108
|
reconcileActive()
|
|
1065
1109
|
|
|
1066
|
-
/**
|
|
1067
|
-
|
|
1068
|
-
|
|
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)])
|
|
1069
1116
|
if (provider !== undefined && isEnabled(provider.id)) return provider
|
|
1070
1117
|
const fallback = findProvider(firstEnabled())
|
|
1071
1118
|
return fallback !== undefined ? fallback : PROVIDERS[0]
|
|
@@ -1117,8 +1164,8 @@ let activeCtx = undefined
|
|
|
1117
1164
|
* @param {any} provider
|
|
1118
1165
|
* @returns {string}
|
|
1119
1166
|
*/
|
|
1120
|
-
function startUrlFor(provider) {
|
|
1121
|
-
const remembered = lastUrls.get(provider.id)
|
|
1167
|
+
function startUrlFor(provider, seat) {
|
|
1168
|
+
const remembered = lastUrls.get(seatOf(seat) + ':' + provider.id)
|
|
1122
1169
|
if (typeof remembered !== 'string' || remembered === '') return provider.url
|
|
1123
1170
|
if (!remembered.startsWith(provider.origin)) return provider.url
|
|
1124
1171
|
if (!isLiveUrl(remembered)) return provider.url
|
|
@@ -1126,11 +1173,21 @@ let activeCtx = undefined
|
|
|
1126
1173
|
return remembered
|
|
1127
1174
|
}
|
|
1128
1175
|
|
|
1129
|
-
/**
|
|
1130
|
-
|
|
1131
|
-
|
|
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)
|
|
1132
1187
|
if (record === undefined) {
|
|
1133
1188
|
record = {
|
|
1189
|
+
id,
|
|
1190
|
+
seat: which,
|
|
1134
1191
|
element: undefined,
|
|
1135
1192
|
lease: undefined,
|
|
1136
1193
|
partition: undefined,
|
|
@@ -1153,14 +1210,17 @@ let activeCtx = undefined
|
|
|
1153
1210
|
handoff: '',
|
|
1154
1211
|
selfTest: '',
|
|
1155
1212
|
}
|
|
1156
|
-
guests.set(
|
|
1213
|
+
guests.set(key, record)
|
|
1157
1214
|
}
|
|
1158
1215
|
return record
|
|
1159
1216
|
}
|
|
1160
1217
|
|
|
1161
|
-
/**
|
|
1162
|
-
|
|
1163
|
-
|
|
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)
|
|
1164
1224
|
return { phase: record.phase, detail: record.detail }
|
|
1165
1225
|
}
|
|
1166
1226
|
|
|
@@ -1168,9 +1228,10 @@ let activeCtx = undefined
|
|
|
1168
1228
|
* @param {string} id
|
|
1169
1229
|
* @param {string} phase
|
|
1170
1230
|
* @param {string} [detail]
|
|
1231
|
+
* @param {'main' | 'right' | undefined} [seat]
|
|
1171
1232
|
*/
|
|
1172
|
-
function setPhase(id, phase, detail) {
|
|
1173
|
-
const record = guestRecord(id)
|
|
1233
|
+
function setPhase(id, phase, detail, seat) {
|
|
1234
|
+
const record = guestRecord(id, seat)
|
|
1174
1235
|
if (record.phase === phase && record.detail === (detail === undefined ? '' : detail)) return
|
|
1175
1236
|
record.phase = phase
|
|
1176
1237
|
record.detail = detail === undefined ? '' : detail
|
|
@@ -1324,29 +1385,57 @@ let activeCtx = undefined
|
|
|
1324
1385
|
}
|
|
1325
1386
|
}
|
|
1326
1387
|
|
|
1327
|
-
/**
|
|
1328
|
-
|
|
1329
|
-
|
|
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)
|
|
1330
1413
|
if (record.layer !== undefined && record.layer !== null && record.layer.isConnected !== false) {
|
|
1331
1414
|
return record.layer
|
|
1332
1415
|
}
|
|
1333
|
-
const host =
|
|
1416
|
+
const host = guestHome(which)
|
|
1334
1417
|
if (host === null || host === undefined) return undefined
|
|
1335
1418
|
const layer = document.createElement('div')
|
|
1336
1419
|
layer.className = 'dce-guest-layer'
|
|
1337
1420
|
layer.setAttribute('data-provider', provider.id)
|
|
1338
|
-
layer.setAttribute('data-
|
|
1421
|
+
layer.setAttribute('data-seat', which)
|
|
1422
|
+
layer.setAttribute('data-active', provider.id === activeBySeat[which] ? 'true' : 'false')
|
|
1339
1423
|
host.appendChild(layer)
|
|
1340
1424
|
record.layer = layer
|
|
1341
1425
|
return layer
|
|
1342
1426
|
}
|
|
1343
1427
|
|
|
1344
|
-
/**
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
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'
|
|
1350
1439
|
if (record.layer.getAttribute('data-active') !== want) record.layer.setAttribute('data-active', want)
|
|
1351
1440
|
}
|
|
1352
1441
|
}
|
|
@@ -1357,10 +1446,11 @@ let activeCtx = undefined
|
|
|
1357
1446
|
* @param {string} id
|
|
1358
1447
|
* @returns {Promise<void>}
|
|
1359
1448
|
*/
|
|
1360
|
-
async function mountGuest(id) {
|
|
1449
|
+
async function mountGuest(id, seat) {
|
|
1450
|
+
const which = seatOf(seat)
|
|
1361
1451
|
const provider = findProvider(id)
|
|
1362
1452
|
if (provider === undefined) return
|
|
1363
|
-
const record = guestRecord(id)
|
|
1453
|
+
const record = guestRecord(id, which)
|
|
1364
1454
|
|
|
1365
1455
|
if (record.mounting === true) return
|
|
1366
1456
|
if (record.element !== undefined && record.element !== null) {
|
|
@@ -1369,7 +1459,7 @@ let activeCtx = undefined
|
|
|
1369
1459
|
dropGuest(record)
|
|
1370
1460
|
}
|
|
1371
1461
|
|
|
1372
|
-
const layer = layerFor(provider)
|
|
1462
|
+
const layer = layerFor(provider, which)
|
|
1373
1463
|
if (layer === undefined) return
|
|
1374
1464
|
|
|
1375
1465
|
record.mounting = true
|
|
@@ -1379,11 +1469,11 @@ let activeCtx = undefined
|
|
|
1379
1469
|
try {
|
|
1380
1470
|
const bridge = desktopBrowser()
|
|
1381
1471
|
if (bridge === undefined) {
|
|
1382
|
-
setPhase(id, PHASE.UNSUPPORTED, '')
|
|
1472
|
+
setPhase(id, PHASE.UNSUPPORTED, '', which)
|
|
1383
1473
|
return
|
|
1384
1474
|
}
|
|
1385
1475
|
|
|
1386
|
-
setPhase(id, PHASE.ACQUIRING, '')
|
|
1476
|
+
setPhase(id, PHASE.ACQUIRING, '', which)
|
|
1387
1477
|
let lease
|
|
1388
1478
|
let partition
|
|
1389
1479
|
try {
|
|
@@ -1395,11 +1485,11 @@ let activeCtx = undefined
|
|
|
1395
1485
|
throw new Error('desktop shell returned no partition')
|
|
1396
1486
|
}
|
|
1397
1487
|
} catch (error) {
|
|
1398
|
-
if (generation === record.generation) setPhase(id, PHASE.FAILED, messageOf(error))
|
|
1488
|
+
if (generation === record.generation) setPhase(id, PHASE.FAILED, messageOf(error), which)
|
|
1399
1489
|
return
|
|
1400
1490
|
}
|
|
1401
1491
|
|
|
1402
|
-
log('info', 'lease acquired', { provider: id, partition: shortId(partition) })
|
|
1492
|
+
log('info', 'lease acquired', { provider: id, seat: which, partition: shortId(partition) })
|
|
1403
1493
|
|
|
1404
1494
|
// Teardown or reload happened while the lease was in flight.
|
|
1405
1495
|
if (generation !== record.generation) {
|
|
@@ -1420,12 +1510,12 @@ let activeCtx = undefined
|
|
|
1420
1510
|
element.style.cssText = 'display:inline-flex;width:100%;height:100%;border:0;background:transparent;'
|
|
1421
1511
|
|
|
1422
1512
|
const handlers = {
|
|
1423
|
-
ready: (event) => onGuestReady(id, event),
|
|
1424
|
-
failed: (event) => onGuestFailed(id, event),
|
|
1425
|
-
navigate: (event) => onGuestNavigated(id, event !== undefined && event !== null ? event.url : ''),
|
|
1426
|
-
navigateInPage: (event) => onGuestLocation(id, event !== undefined && event !== null ? event.url : ''),
|
|
1427
|
-
stop: () => onGuestStopped(id),
|
|
1428
|
-
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),
|
|
1429
1519
|
}
|
|
1430
1520
|
element.addEventListener('dom-ready', handlers.ready)
|
|
1431
1521
|
element.addEventListener('did-fail-load', handlers.failed)
|
|
@@ -1443,13 +1533,13 @@ let activeCtx = undefined
|
|
|
1443
1533
|
record.mounts += 1
|
|
1444
1534
|
// A mount is a fresh document load. Printing the count makes "one page
|
|
1445
1535
|
// in the tab" distinguishable from "the tab was rebuilt" in the ring.
|
|
1446
|
-
log('info', 'guest mounted', { provider: id, mount: record.mounts })
|
|
1536
|
+
log('info', 'guest mounted', { provider: id, seat: which, mount: record.mounts })
|
|
1447
1537
|
|
|
1448
1538
|
try {
|
|
1449
1539
|
layer.appendChild(element)
|
|
1450
1540
|
} catch (error) {
|
|
1451
1541
|
dropGuest(record)
|
|
1452
|
-
setPhase(id, PHASE.FAILED, messageOf(error))
|
|
1542
|
+
setPhase(id, PHASE.FAILED, messageOf(error), which)
|
|
1453
1543
|
return
|
|
1454
1544
|
}
|
|
1455
1545
|
|
|
@@ -1457,12 +1547,12 @@ let activeCtx = undefined
|
|
|
1457
1547
|
// so a reload or teardown cannot leave a listener behind.
|
|
1458
1548
|
if (typeof bridge.onOpenRequested === 'function') {
|
|
1459
1549
|
try {
|
|
1460
|
-
record.popupOff = bridge.onOpenRequested(lease, (url) => onGuestPopup(id, url))
|
|
1550
|
+
record.popupOff = bridge.onOpenRequested(lease, (url) => onGuestPopup(id, url, which))
|
|
1461
1551
|
} catch (error) {
|
|
1462
1552
|
record.popupOff = undefined
|
|
1463
1553
|
}
|
|
1464
1554
|
}
|
|
1465
|
-
setPhase(id, PHASE.NAVIGATING, '')
|
|
1555
|
+
setPhase(id, PHASE.NAVIGATING, '', which)
|
|
1466
1556
|
} finally {
|
|
1467
1557
|
record.mounting = false
|
|
1468
1558
|
syncLayers()
|
|
@@ -1480,11 +1570,12 @@ let activeCtx = undefined
|
|
|
1480
1570
|
* @param {any} element
|
|
1481
1571
|
* @returns {Promise<void>}
|
|
1482
1572
|
*/
|
|
1483
|
-
async function navigateGuest(id, element) {
|
|
1573
|
+
async function navigateGuest(id, element, seat) {
|
|
1574
|
+
const which = seatOf(seat)
|
|
1484
1575
|
const provider = findProvider(id)
|
|
1485
1576
|
if (provider === undefined) return
|
|
1486
|
-
const record = guestRecord(id)
|
|
1487
|
-
const target = startUrlFor(provider)
|
|
1577
|
+
const record = guestRecord(id, which)
|
|
1578
|
+
const target = startUrlFor(provider, which)
|
|
1488
1579
|
const deadline = Date.now() + NAVIGATE_TIMEOUT_MS
|
|
1489
1580
|
let issued = 0
|
|
1490
1581
|
|
|
@@ -1492,8 +1583,8 @@ let activeCtx = undefined
|
|
|
1492
1583
|
if (element !== record.element) return
|
|
1493
1584
|
const landed = guestUrl(element)
|
|
1494
1585
|
if (isLiveUrl(landed)) {
|
|
1495
|
-
if (landed !== '') lastUrls.set(id, landed)
|
|
1496
|
-
setPhase(id, PHASE.READY, '')
|
|
1586
|
+
if (landed !== '') lastUrls.set(which + ':' + id, landed)
|
|
1587
|
+
setPhase(id, PHASE.READY, '', which)
|
|
1497
1588
|
return
|
|
1498
1589
|
}
|
|
1499
1590
|
const loading = guestLoading(element)
|
|
@@ -1514,34 +1605,34 @@ let activeCtx = undefined
|
|
|
1514
1605
|
await delay(NAVIGATE_RETRY_MS)
|
|
1515
1606
|
}
|
|
1516
1607
|
if (element !== record.element) return
|
|
1517
|
-
setPhase(id, PHASE.FAILED, 'navigation-timeout')
|
|
1608
|
+
setPhase(id, PHASE.FAILED, 'navigation-timeout', which)
|
|
1518
1609
|
}
|
|
1519
1610
|
|
|
1520
1611
|
/**
|
|
1521
1612
|
* @param {string} id
|
|
1522
1613
|
* @param {any} event
|
|
1523
1614
|
*/
|
|
1524
|
-
function onGuestReady(id, event) {
|
|
1525
|
-
const record = guestRecord(id)
|
|
1615
|
+
function onGuestReady(id, event, seat) {
|
|
1616
|
+
const record = guestRecord(id, seat)
|
|
1526
1617
|
const element =
|
|
1527
1618
|
event !== undefined && event !== null && event.currentTarget !== undefined ? event.currentTarget : record.element
|
|
1528
1619
|
if (element === undefined || element !== record.element) return
|
|
1529
1620
|
if (record.navigated) return
|
|
1530
1621
|
record.navigated = true
|
|
1531
|
-
void navigateGuest(id, element)
|
|
1622
|
+
void navigateGuest(id, element, seat)
|
|
1532
1623
|
}
|
|
1533
1624
|
|
|
1534
1625
|
/**
|
|
1535
1626
|
* @param {string} id
|
|
1536
1627
|
* @param {any} event
|
|
1537
1628
|
*/
|
|
1538
|
-
function onGuestFailed(id, event) {
|
|
1539
|
-
const record = guestRecord(id)
|
|
1629
|
+
function onGuestFailed(id, event, seat) {
|
|
1630
|
+
const record = guestRecord(id, seat)
|
|
1540
1631
|
const element =
|
|
1541
1632
|
event !== undefined && event !== null && event.currentTarget !== undefined ? event.currentTarget : record.element
|
|
1542
1633
|
if (element === undefined || element !== record.element) return
|
|
1543
1634
|
if (event !== undefined && event !== null && event.errorCode === -3) return
|
|
1544
|
-
setPhase(id, PHASE.FAILED, 'load-failed')
|
|
1635
|
+
setPhase(id, PHASE.FAILED, 'load-failed', seat)
|
|
1545
1636
|
log('warn', 'guest failed to load', { provider: id })
|
|
1546
1637
|
}
|
|
1547
1638
|
|
|
@@ -1551,11 +1642,11 @@ let activeCtx = undefined
|
|
|
1551
1642
|
* @param {string} id
|
|
1552
1643
|
* @param {string} url
|
|
1553
1644
|
*/
|
|
1554
|
-
function onGuestLocation(id, url) {
|
|
1555
|
-
const record = guestRecord(id)
|
|
1645
|
+
function onGuestLocation(id, url, seat) {
|
|
1646
|
+
const record = guestRecord(id, seat)
|
|
1556
1647
|
if (typeof url === 'string' && url !== '') {
|
|
1557
1648
|
record.lastUrl = url
|
|
1558
|
-
lastUrls.set(id, url)
|
|
1649
|
+
lastUrls.set(seatOf(seat) + ':' + id, url)
|
|
1559
1650
|
}
|
|
1560
1651
|
}
|
|
1561
1652
|
|
|
@@ -1600,13 +1691,13 @@ let activeCtx = undefined
|
|
|
1600
1691
|
*
|
|
1601
1692
|
* @param {string} id
|
|
1602
1693
|
*/
|
|
1603
|
-
function onGuestStopped(id) {
|
|
1604
|
-
const record = guestRecord(id)
|
|
1694
|
+
function onGuestStopped(id, seat) {
|
|
1695
|
+
const record = guestRecord(id, seat)
|
|
1605
1696
|
const element = record.element
|
|
1606
1697
|
if (element === undefined || element === null) return
|
|
1607
1698
|
const url = guestUrl(element)
|
|
1608
1699
|
record.lastUrl = url
|
|
1609
|
-
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)
|
|
1610
1701
|
record.lastEvent = 'did-stop-loading'
|
|
1611
1702
|
|
|
1612
1703
|
// Google's popup-handoff page cannot finish without an opener: return to
|
|
@@ -1630,7 +1721,7 @@ let activeCtx = undefined
|
|
|
1630
1721
|
record.reloadTimer = setTimeout(() => {
|
|
1631
1722
|
record.reloadTimer = undefined
|
|
1632
1723
|
if (record.element !== element) return
|
|
1633
|
-
void reloadGuest(id)
|
|
1724
|
+
void reloadGuest(id, seat)
|
|
1634
1725
|
}, TIMINGS.oauthRecoveryReloadMs)
|
|
1635
1726
|
return
|
|
1636
1727
|
}
|
|
@@ -1645,10 +1736,10 @@ let activeCtx = undefined
|
|
|
1645
1736
|
*
|
|
1646
1737
|
* @param {string} id
|
|
1647
1738
|
*/
|
|
1648
|
-
function onGuestCrashed(id) {
|
|
1649
|
-
const record = guestRecord(id)
|
|
1739
|
+
function onGuestCrashed(id, seat) {
|
|
1740
|
+
const record = guestRecord(id, seat)
|
|
1650
1741
|
if (record.element === undefined || record.element === null) return
|
|
1651
|
-
setPhase(id, PHASE.FAILED, 'renderer-gone')
|
|
1742
|
+
setPhase(id, PHASE.FAILED, 'renderer-gone', seat)
|
|
1652
1743
|
record.lastEvent = 'renderer-gone'
|
|
1653
1744
|
log('error', 'renderer gone', { provider: id })
|
|
1654
1745
|
notify()
|
|
@@ -1665,8 +1756,8 @@ let activeCtx = undefined
|
|
|
1665
1756
|
* @param {string} id
|
|
1666
1757
|
* @param {string} url
|
|
1667
1758
|
*/
|
|
1668
|
-
function onGuestPopup(id, url) {
|
|
1669
|
-
const record = guestRecord(id)
|
|
1759
|
+
function onGuestPopup(id, url, seat) {
|
|
1760
|
+
const record = guestRecord(id, seat)
|
|
1670
1761
|
const element = record.element
|
|
1671
1762
|
if (element === undefined || element === null) return
|
|
1672
1763
|
if (typeof url !== 'string' || url.indexOf('https://') !== 0) return
|
|
@@ -1692,8 +1783,8 @@ let activeCtx = undefined
|
|
|
1692
1783
|
* @param {string} id
|
|
1693
1784
|
* @param {string} url
|
|
1694
1785
|
*/
|
|
1695
|
-
function onGuestNavigated(id, url) {
|
|
1696
|
-
const record = guestRecord(id)
|
|
1786
|
+
function onGuestNavigated(id, url, seat) {
|
|
1787
|
+
const record = guestRecord(id, seat)
|
|
1697
1788
|
const provider = findProvider(id)
|
|
1698
1789
|
if (provider === undefined) return
|
|
1699
1790
|
const host = hostOf(url)
|
|
@@ -1710,7 +1801,7 @@ let activeCtx = undefined
|
|
|
1710
1801
|
if (record.oauthPending !== true) return
|
|
1711
1802
|
if (host !== hostOf(provider.origin)) return
|
|
1712
1803
|
record.oauthPending = false
|
|
1713
|
-
scheduleOAuthRecovery(id, provider)
|
|
1804
|
+
scheduleOAuthRecovery(id, provider, seat)
|
|
1714
1805
|
}
|
|
1715
1806
|
|
|
1716
1807
|
/** @param {GuestRecord} record */
|
|
@@ -1751,8 +1842,8 @@ let activeCtx = undefined
|
|
|
1751
1842
|
* @param {string} id
|
|
1752
1843
|
* @param {object} provider
|
|
1753
1844
|
*/
|
|
1754
|
-
function scheduleOAuthRecovery(id, provider) {
|
|
1755
|
-
const record = guestRecord(id)
|
|
1845
|
+
function scheduleOAuthRecovery(id, provider, seat) {
|
|
1846
|
+
const record = guestRecord(id, seat)
|
|
1756
1847
|
clearRecoveryTimer(record)
|
|
1757
1848
|
|
|
1758
1849
|
record.recoveryTimer = setTimeout(() => {
|
|
@@ -1799,21 +1890,23 @@ let activeCtx = undefined
|
|
|
1799
1890
|
* @param {string} id
|
|
1800
1891
|
* @returns {Promise<void>}
|
|
1801
1892
|
*/
|
|
1802
|
-
async function reloadGuest(id) {
|
|
1803
|
-
const
|
|
1804
|
-
|
|
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 })
|
|
1805
1897
|
record.generation += 1
|
|
1806
1898
|
dropGuest(record)
|
|
1807
|
-
setPhase(id, PHASE.IDLE, '')
|
|
1808
|
-
await mountGuest(id)
|
|
1899
|
+
setPhase(id, PHASE.IDLE, '', which)
|
|
1900
|
+
await mountGuest(id, which)
|
|
1809
1901
|
}
|
|
1810
1902
|
/** Release every guest; used on plugin unload. */
|
|
1811
1903
|
/** @param {string} [reason] */
|
|
1812
1904
|
function destroyGuests(reason) {
|
|
1813
|
-
for (const
|
|
1905
|
+
for (const record of guests.values()) {
|
|
1814
1906
|
record.generation += 1
|
|
1815
1907
|
dropGuest(record, reason)
|
|
1816
|
-
|
|
1908
|
+
record.phase = PHASE.IDLE
|
|
1909
|
+
record.detail = ''
|
|
1817
1910
|
if (record.layer !== undefined && record.layer !== null) {
|
|
1818
1911
|
try {
|
|
1819
1912
|
if (record.layer.parentNode !== null && record.layer.parentNode !== undefined) {
|
|
@@ -1825,6 +1918,8 @@ let activeCtx = undefined
|
|
|
1825
1918
|
record.layer = undefined
|
|
1826
1919
|
}
|
|
1827
1920
|
}
|
|
1921
|
+
discardPark()
|
|
1922
|
+
notify()
|
|
1828
1923
|
}
|
|
1829
1924
|
|
|
1830
1925
|
/** @param {{left:number,top:number,width:number,height:number}} rect @returns {string} */
|
|
@@ -1888,15 +1983,18 @@ let activeCtx = undefined
|
|
|
1888
1983
|
*/
|
|
1889
1984
|
/**
|
|
1890
1985
|
* A guest element cannot move between hosts (Electron destroys the
|
|
1891
|
-
* WebContents with its DOM)
|
|
1892
|
-
*
|
|
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.
|
|
1893
1990
|
*
|
|
1894
1991
|
* @param {any} host
|
|
1895
1992
|
*/
|
|
1896
|
-
function dropGuestsOutside(host) {
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
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
|
|
1900
1998
|
const element = record.element
|
|
1901
1999
|
const inside = typeof host.contains === 'function' ? host.contains(element) : false
|
|
1902
2000
|
if (inside) continue
|
|
@@ -1925,17 +2023,308 @@ let activeCtx = undefined
|
|
|
1925
2023
|
if (patch !== undefined && patch !== null && patch.host !== undefined) setHost(patch.host)
|
|
1926
2024
|
}
|
|
1927
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
|
+
|
|
1928
2282
|
function resolveInlineHost() {
|
|
1929
|
-
const
|
|
1930
|
-
const
|
|
1931
|
-
if (
|
|
1932
|
-
|
|
1933
|
-
|
|
1934
|
-
|
|
1935
|
-
|
|
1936
|
-
|
|
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')
|
|
1937
2296
|
}
|
|
1938
|
-
|
|
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()
|
|
1939
2328
|
}
|
|
1940
2329
|
|
|
1941
2330
|
/** @param {'main' | 'right'} seat @returns {boolean} */
|
|
@@ -1980,7 +2369,9 @@ let activeCtx = undefined
|
|
|
1980
2369
|
const zeroSized = hostArea(host) <= 0
|
|
1981
2370
|
if (!zeroSized || (chosen && seat === 'main')) return seat
|
|
1982
2371
|
}
|
|
1983
|
-
|
|
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
|
|
1984
2375
|
}
|
|
1985
2376
|
|
|
1986
2377
|
/**
|
|
@@ -2015,10 +2406,21 @@ let activeCtx = undefined
|
|
|
2015
2406
|
|
|
2016
2407
|
function openRightTab() {
|
|
2017
2408
|
try {
|
|
2018
|
-
|
|
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
|
+
}
|
|
2019
2416
|
} catch (error) {
|
|
2020
2417
|
void error
|
|
2021
2418
|
}
|
|
2419
|
+
try {
|
|
2420
|
+
openRightTabImpl()
|
|
2421
|
+
} catch (error) {
|
|
2422
|
+
log('warn', 'right sidebar did not open', { detail: messageOf(error) })
|
|
2423
|
+
}
|
|
2022
2424
|
}
|
|
2023
2425
|
|
|
2024
2426
|
/** @returns {string} a live self-test of the hosting seat and its box. */
|
|
@@ -2057,12 +2459,13 @@ let activeCtx = undefined
|
|
|
2057
2459
|
host: rect(host === undefined || host === null ? undefined : host.getBoundingClientRect()),
|
|
2058
2460
|
visible: true,
|
|
2059
2461
|
guest: (() => {
|
|
2060
|
-
|
|
2061
|
-
|
|
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' }
|
|
2062
2465
|
}
|
|
2063
|
-
const webviews =
|
|
2064
|
-
const layers =
|
|
2065
|
-
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"]')
|
|
2066
2469
|
const inner = document.querySelector('.dce-inline')
|
|
2067
2470
|
return {
|
|
2068
2471
|
present: webviews.length > 0,
|
|
@@ -2070,7 +2473,11 @@ let activeCtx = undefined
|
|
|
2070
2473
|
layers: layers.length,
|
|
2071
2474
|
active: active.length,
|
|
2072
2475
|
surfaceMounted: inner !== null && inner !== undefined,
|
|
2073
|
-
hostBox: rect(
|
|
2476
|
+
hostBox: rect(
|
|
2477
|
+
host === undefined || host === null || typeof host.getBoundingClientRect !== 'function'
|
|
2478
|
+
? undefined
|
|
2479
|
+
: host.getBoundingClientRect(),
|
|
2480
|
+
),
|
|
2074
2481
|
}
|
|
2075
2482
|
})(),
|
|
2076
2483
|
right: rightSidebarStatus(),
|
|
@@ -2498,9 +2905,8 @@ let activeCtx = undefined
|
|
|
2498
2905
|
|
|
2499
2906
|
/** @returns {'on' | 'off' | 'unknown'} what the mounted guests actually received */
|
|
2500
2907
|
function livePartitionState() {
|
|
2501
|
-
for (const
|
|
2502
|
-
|
|
2503
|
-
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
|
|
2504
2910
|
return record.partition.startsWith('persist:') ? 'on' : 'off'
|
|
2505
2911
|
}
|
|
2506
2912
|
return 'unknown'
|
|
@@ -2911,18 +3317,19 @@ let activeCtx = undefined
|
|
|
2911
3317
|
*
|
|
2912
3318
|
* @returns {Promise<void>}
|
|
2913
3319
|
*/
|
|
2914
|
-
function ensureActiveGuest() {
|
|
2915
|
-
const
|
|
2916
|
-
const
|
|
3320
|
+
function ensureActiveGuest(seat) {
|
|
3321
|
+
const which = seatOf(seat)
|
|
3322
|
+
const provider = activeProvider(which)
|
|
3323
|
+
const record = guestRecord(provider.id, which)
|
|
2917
3324
|
// A guest whose element was detached with its seat is gone (Electron drops
|
|
2918
3325
|
// the WebContents with the DOM), so a live element is the only reason to
|
|
2919
3326
|
// skip the rebuild.
|
|
2920
3327
|
const element = record.element
|
|
2921
3328
|
if (element !== undefined && element !== null && element.isConnected !== false) return Promise.resolve()
|
|
2922
3329
|
if (record.mounting === true) return Promise.resolve()
|
|
2923
|
-
|
|
2924
|
-
if (
|
|
2925
|
-
return mountGuest(provider.id)
|
|
3330
|
+
const home = guestHome(which)
|
|
3331
|
+
if (home === null || home === undefined) return Promise.resolve()
|
|
3332
|
+
return mountGuest(provider.id, which)
|
|
2926
3333
|
}
|
|
2927
3334
|
|
|
2928
3335
|
/**
|
|
@@ -2932,17 +3339,17 @@ let activeCtx = undefined
|
|
|
2932
3339
|
* @param {string} id
|
|
2933
3340
|
* @returns {Promise<void>}
|
|
2934
3341
|
*/
|
|
2935
|
-
function setActive(id) {
|
|
3342
|
+
function setActive(id, seat) {
|
|
3343
|
+
const which = seatOf(seat)
|
|
2936
3344
|
const provider = findProvider(id)
|
|
2937
3345
|
if (provider === undefined) return Promise.resolve()
|
|
2938
3346
|
if (!isEnabled(provider.id)) return Promise.resolve()
|
|
2939
|
-
if (
|
|
2940
|
-
|
|
2941
|
-
|
|
2942
|
-
syncLayers()
|
|
3347
|
+
if (activeBySeat[which] !== provider.id) {
|
|
3348
|
+
assignSeatActive(which, provider.id)
|
|
3349
|
+
syncLayers(which)
|
|
2943
3350
|
}
|
|
2944
3351
|
notify()
|
|
2945
|
-
return ensureActiveGuest()
|
|
3352
|
+
return ensureActiveGuest(which)
|
|
2946
3353
|
}
|
|
2947
3354
|
|
|
2948
3355
|
// ------------------------------------------------------------------
|
|
@@ -2998,6 +3405,19 @@ let activeCtx = undefined
|
|
|
2998
3405
|
'.dce-button-primary{border-color:currentColor;color:var(--dsw-alias-button-primary-fill,#4c6ef5)}',
|
|
2999
3406
|
'.dce-surface{position:absolute;inset:0;display:flex;min-height:0}',
|
|
3000
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}',
|
|
3001
3421
|
'.dce-guest-layer{position:absolute;inset:0;display:none;min-width:0;min-height:0}',
|
|
3002
3422
|
'.dce-guest-layer[data-active="true"]{display:flex}',
|
|
3003
3423
|
'.dce-guest{display:inline-flex;flex:1 1 auto;width:100%;height:100%;border:0;background:transparent}',
|
|
@@ -3098,8 +3518,9 @@ let activeCtx = undefined
|
|
|
3098
3518
|
* @param {(key: string) => string} t
|
|
3099
3519
|
* @param {{ phase: string, detail: string }} snapshot
|
|
3100
3520
|
* @param {() => void} [onRetry]
|
|
3521
|
+
* @param {string} [url]
|
|
3101
3522
|
*/
|
|
3102
|
-
function hintCard(title, body, t, snapshot, onRetry) {
|
|
3523
|
+
function hintCard(title, body, t, snapshot, onRetry, url) {
|
|
3103
3524
|
return h(
|
|
3104
3525
|
'div',
|
|
3105
3526
|
{ className: 'dce-card', role: 'status' },
|
|
@@ -3112,15 +3533,16 @@ let activeCtx = undefined
|
|
|
3112
3533
|
onRetry === undefined
|
|
3113
3534
|
? null
|
|
3114
3535
|
: h('button', { type: 'button', className: 'dce-button dce-button-primary', onClick: onRetry }, t('retry')),
|
|
3115
|
-
h('button', { type: 'button', className: 'dce-button', onClick: openInBrowser }, t('openInBrowser')),
|
|
3536
|
+
h('button', { type: 'button', className: 'dce-button', onClick: () => openInBrowser(url) }, t('openInBrowser')),
|
|
3116
3537
|
),
|
|
3117
3538
|
)
|
|
3118
3539
|
}
|
|
3119
3540
|
|
|
3120
3541
|
/** Open the active service in the system browser. */
|
|
3121
|
-
function openInBrowser() {
|
|
3542
|
+
function openInBrowser(url) {
|
|
3543
|
+
const target = typeof url === 'string' && url !== '' ? url : activeProvider().url
|
|
3122
3544
|
try {
|
|
3123
|
-
window.open(
|
|
3545
|
+
window.open(target, '_blank', 'noopener,noreferrer')
|
|
3124
3546
|
} catch (error) {
|
|
3125
3547
|
void error
|
|
3126
3548
|
}
|
|
@@ -3247,9 +3669,9 @@ let activeCtx = undefined
|
|
|
3247
3669
|
/**
|
|
3248
3670
|
* The left-navigation page: the chat itself, hosted by the center panel.
|
|
3249
3671
|
*
|
|
3250
|
-
* The center panel is torn down whenever another panel is selected
|
|
3251
|
-
*
|
|
3252
|
-
*
|
|
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.
|
|
3253
3675
|
*/
|
|
3254
3676
|
function ChatCenterPage() {
|
|
3255
3677
|
return h(ChatSurface, { seat: 'main' })
|
|
@@ -3258,8 +3680,8 @@ let activeCtx = undefined
|
|
|
3258
3680
|
/** The right sidebar tab's chip title. */
|
|
3259
3681
|
function ChatRightTitle() {
|
|
3260
3682
|
useStore()
|
|
3261
|
-
const provider = activeProvider()
|
|
3262
|
-
const phase = getStatus().phase
|
|
3683
|
+
const provider = activeProvider('right')
|
|
3684
|
+
const phase = getStatus('right').phase
|
|
3263
3685
|
return h(
|
|
3264
3686
|
'span',
|
|
3265
3687
|
{ className: 'dce-right-title' },
|
|
@@ -3293,9 +3715,10 @@ let activeCtx = undefined
|
|
|
3293
3715
|
function ChatSurface(props) {
|
|
3294
3716
|
const t = translator(props)
|
|
3295
3717
|
useStore()
|
|
3296
|
-
const
|
|
3718
|
+
const seatName = props !== undefined && props !== null && props.seat === 'right' ? 'right' : 'main'
|
|
3719
|
+
const snapshot = getStatus(seatName)
|
|
3297
3720
|
|
|
3298
|
-
const provider = activeProvider()
|
|
3721
|
+
const provider = activeProvider(seatName)
|
|
3299
3722
|
const hostRef = React.useRef(null)
|
|
3300
3723
|
const listRef = React.useRef(null)
|
|
3301
3724
|
/** @type {React.MutableRefObject<{ id: string, startX: number, active: boolean } | undefined>} */
|
|
@@ -3306,61 +3729,41 @@ let activeCtx = undefined
|
|
|
3306
3729
|
const [, bumpDrag] = React.useState(0)
|
|
3307
3730
|
const repaintDrag = () => bumpDrag((value) => value + 1)
|
|
3308
3731
|
|
|
3309
|
-
|
|
3310
|
-
|
|
3311
|
-
//
|
|
3312
|
-
// seats can exist at a time (the right sidebar needs a Session surface),
|
|
3313
|
-
// 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.
|
|
3314
3735
|
useMountEffect(() => {
|
|
3315
|
-
const visible = seatName === 'main' || props.active !== false
|
|
3316
|
-
if (visible) preferSeat(seatName)
|
|
3317
|
-
return undefined
|
|
3318
|
-
}, [])
|
|
3319
|
-
|
|
3320
|
-
// `preferredSeat === seatName` must count as hosting even before this seat
|
|
3321
|
-
// is registered: the registration effect only runs once the viewport is
|
|
3322
|
-
// committed, so requiring a registered host first would deadlock.
|
|
3323
|
-
const hostingSeat = inlineSeat()
|
|
3324
|
-
const hosting =
|
|
3325
|
-
hostingSeat === undefined ||
|
|
3326
|
-
hostingSeat === seatName ||
|
|
3327
|
-
preferredSeat === seatName ||
|
|
3328
|
-
// A selected right tab is a user request too: it must render its
|
|
3329
|
-
// viewport so it can register and take the guests over.
|
|
3330
|
-
(seatName === 'right' && props.active === true)
|
|
3331
|
-
React.useEffect(() => {
|
|
3332
3736
|
const node = hostRef.current
|
|
3333
|
-
if (
|
|
3737
|
+
if (node === null || node === undefined) return undefined
|
|
3334
3738
|
inlineHosts[seatName] = node
|
|
3335
|
-
if (
|
|
3336
|
-
|
|
3739
|
+
if (seatName === 'main') {
|
|
3740
|
+
resolveInlineHost()
|
|
3741
|
+
} else if (hostArea(node) >= 2 && props.active !== false) {
|
|
3742
|
+
void ensureActiveGuest('right')
|
|
3743
|
+
}
|
|
3337
3744
|
notify()
|
|
3338
|
-
// A collapsed right tab is 0×0 and must not steal the page; when the user
|
|
3339
|
-
// expands the column the tab gets a box, and that is the moment to hand
|
|
3340
|
-
// the guests over. The observer only re-runs the seat choice.
|
|
3341
3745
|
let ro
|
|
3342
|
-
if (typeof ResizeObserver === 'function'
|
|
3746
|
+
if (typeof ResizeObserver === 'function') {
|
|
3343
3747
|
ro = new ResizeObserver(() => {
|
|
3344
|
-
if (
|
|
3748
|
+
if (seatName === 'main') {
|
|
3749
|
+
resolveInlineHost()
|
|
3750
|
+
return
|
|
3751
|
+
}
|
|
3752
|
+
if (props.active === false || hostArea(node) < 2) return
|
|
3753
|
+
void ensureActiveGuest('right')
|
|
3345
3754
|
})
|
|
3346
3755
|
ro.observe(node)
|
|
3347
3756
|
}
|
|
3348
3757
|
return () => {
|
|
3349
3758
|
if (ro !== undefined) ro.disconnect()
|
|
3350
3759
|
if (inlineHosts[seatName] === node) inlineHosts[seatName] = null
|
|
3351
|
-
if (
|
|
3352
|
-
|
|
3760
|
+
if (seatName === 'main') {
|
|
3761
|
+
stowPark()
|
|
3762
|
+
if (parkIsLive() !== true) destroySeat('main', 'no viewport')
|
|
3763
|
+
}
|
|
3353
3764
|
notify()
|
|
3354
3765
|
}
|
|
3355
|
-
}, [
|
|
3356
|
-
|
|
3357
|
-
// Selecting the right tab hands the chat to that column, so the panel the
|
|
3358
|
-
// user is actually looking at is the one that shows it.
|
|
3359
|
-
React.useEffect(() => {
|
|
3360
|
-
if (seatName !== 'right' || props.active === false) return undefined
|
|
3361
|
-
if (preferredSeat !== 'right') preferSeat('right')
|
|
3362
|
-
return undefined
|
|
3363
|
-
}, [props.active])
|
|
3766
|
+
}, [])
|
|
3364
3767
|
|
|
3365
3768
|
// Pointer-driven tab reordering. Dragging is armed on pointerdown and
|
|
3366
3769
|
// only starts after a small threshold, so a plain click still selects.
|
|
@@ -3591,9 +3994,9 @@ let activeCtx = undefined
|
|
|
3591
3994
|
})
|
|
3592
3995
|
}
|
|
3593
3996
|
const onReload = () => {
|
|
3594
|
-
void reloadGuest(provider.id)
|
|
3997
|
+
void reloadGuest(provider.id, seatName)
|
|
3595
3998
|
}
|
|
3596
|
-
const record = guestRecord(provider.id)
|
|
3999
|
+
const record = guestRecord(provider.id, seatName)
|
|
3597
4000
|
|
|
3598
4001
|
// The status strip only earns its space while something is happening or
|
|
3599
4002
|
// wrong; a healthy tab shows nothing but its tabs. A pending patch is
|
|
@@ -3622,6 +4025,9 @@ let activeCtx = undefined
|
|
|
3622
4025
|
'data-visible': 'true',
|
|
3623
4026
|
'data-mode': 'inline',
|
|
3624
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',
|
|
3625
4031
|
'data-build': BUILD,
|
|
3626
4032
|
'aria-hidden': 'false',
|
|
3627
4033
|
},
|
|
@@ -3656,7 +4062,7 @@ let activeCtx = undefined
|
|
|
3656
4062
|
className: 'dce-tab',
|
|
3657
4063
|
'data-tab-id': entry.id,
|
|
3658
4064
|
'data-active': entry.id === provider.id ? 'true' : 'false',
|
|
3659
|
-
'data-failed': guestRecord(entry.id).phase === PHASE.FAILED ? 'true' : 'false',
|
|
4065
|
+
'data-failed': guestRecord(entry.id, seatName).phase === PHASE.FAILED ? 'true' : 'false',
|
|
3660
4066
|
'data-dragging':
|
|
3661
4067
|
dragRef.current !== undefined &&
|
|
3662
4068
|
dragRef.current.active === true &&
|
|
@@ -3675,7 +4081,7 @@ let activeCtx = undefined
|
|
|
3675
4081
|
suppressClickRef.current = false
|
|
3676
4082
|
return
|
|
3677
4083
|
}
|
|
3678
|
-
void setActive(entry.id)
|
|
4084
|
+
void setActive(entry.id, seatName)
|
|
3679
4085
|
},
|
|
3680
4086
|
},
|
|
3681
4087
|
entry.label,
|
|
@@ -4037,10 +4443,10 @@ let activeCtx = undefined
|
|
|
4037
4443
|
{ className: 'dce-surface' },
|
|
4038
4444
|
h('div', { className: 'dce-viewport', ref: hostRef }),
|
|
4039
4445
|
snapshot.phase === PHASE.UNSUPPORTED
|
|
4040
|
-
? hintCard(t('statusUnsupported'), t('unsupportedHint'), t, snapshot)
|
|
4446
|
+
? hintCard(t('statusUnsupported'), t('unsupportedHint'), t, snapshot, undefined, provider.url)
|
|
4041
4447
|
: null,
|
|
4042
4448
|
snapshot.phase === PHASE.FAILED
|
|
4043
|
-
? hintCard(t('statusFailed'), t('failedHint'), t, snapshot, onReload)
|
|
4449
|
+
? hintCard(t('statusFailed'), t('failedHint'), t, snapshot, onReload, provider.url)
|
|
4044
4450
|
: null,
|
|
4045
4451
|
record.oauthBlocked
|
|
4046
4452
|
? h(
|