@artenx/dshb 0.1.57 → 0.1.58
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/lib/client.js +200 -57
- package/lib/client.js.map +1 -1
- package/package.json +1 -1
package/lib/client.js
CHANGED
|
@@ -1040,6 +1040,13 @@ window.__ModuleLoader__.load({
|
|
|
1040
1040
|
});
|
|
1041
1041
|
}
|
|
1042
1042
|
//#endregion
|
|
1043
|
+
//#region src/client/mobile-layout.ts
|
|
1044
|
+
const MOBILE_QUERY = "(max-width: 1023px) and (any-pointer: coarse), (max-width: 767px) and (hover: none)";
|
|
1045
|
+
const UPSTREAM_DRAWER_QUERY = "(max-width: 767px)";
|
|
1046
|
+
function shouldUseUpstreamDrawer(viewportWidth, stylesAvailable) {
|
|
1047
|
+
return stylesAvailable && viewportWidth < 768;
|
|
1048
|
+
}
|
|
1049
|
+
//#endregion
|
|
1043
1050
|
//#region src/client/mobile.tsx
|
|
1044
1051
|
/**
|
|
1045
1052
|
* dshb 移动端屏幕适配(参考 dsh-web-mobile 实现,仅保留页面适配与目录抽屉
|
|
@@ -1051,7 +1058,6 @@ window.__ModuleLoader__.load({
|
|
|
1051
1058
|
* ctx.layout.toggleSidebar()。窄屏判定与上游一致(<1024 且粗指针,避免桌面
|
|
1052
1059
|
* 小窗误触发)。
|
|
1053
1060
|
*/
|
|
1054
|
-
const MOBILE_QUERY = "(max-width: 1023px) and (pointer: coarse)";
|
|
1055
1061
|
/** 纯视口宽度判定:与放宽后的 MOBILE_CSS 媒体查询一致(不依赖 pointer 类型)。 */
|
|
1056
1062
|
const NARROW_QUERY = "(max-width: 1023px)";
|
|
1057
1063
|
const FRAME_ATTR = "data-dshb-mobile";
|
|
@@ -1061,7 +1067,7 @@ window.__ModuleLoader__.load({
|
|
|
1061
1067
|
常报 pointer:fine,绑定 coarse 会让全部窄屏修复失效。抽屉相关选择器都挂在
|
|
1062
1068
|
[data-dshb-mobile] 标记上,标记由 JS 的 coarse 判定添加,故放宽 CSS 不会误开抽屉。 */
|
|
1063
1069
|
@media (max-width: 1023px) {
|
|
1064
|
-
html, body { touch-action:
|
|
1070
|
+
html, body { touch-action: manipulation !important; overscroll-behavior-x: none !important; -webkit-text-size-adjust: 100% !important; text-size-adjust: 100% !important; }
|
|
1065
1071
|
|
|
1066
1072
|
[${FRAME_ATTR}="frame"] {
|
|
1067
1073
|
box-sizing: border-box !important;
|
|
@@ -1069,20 +1075,28 @@ window.__ModuleLoader__.load({
|
|
|
1069
1075
|
grid-template-columns: minmax(0, 1fr) 0 0 !important;
|
|
1070
1076
|
padding-top: env(safe-area-inset-top, 0px) !important;
|
|
1071
1077
|
}
|
|
1078
|
+
[${FRAME_ATTR}="frame-native"] {
|
|
1079
|
+
box-sizing: border-box !important;
|
|
1080
|
+
padding-top: env(safe-area-inset-top, 0px) !important;
|
|
1081
|
+
padding-left: env(safe-area-inset-left, 0px) !important;
|
|
1082
|
+
padding-right: env(safe-area-inset-right, 0px) !important;
|
|
1083
|
+
}
|
|
1072
1084
|
|
|
1073
1085
|
/* 侧边栏列 -> 抽屉:默认移出屏幕,展开(无 collapsed)时滑入 */
|
|
1074
1086
|
[${FRAME_ATTR}="frame"] > :first-child {
|
|
1075
1087
|
position: absolute !important;
|
|
1076
1088
|
inset: 0 auto 0 0 !important;
|
|
1089
|
+
box-sizing: border-box;
|
|
1077
1090
|
width: max-content;
|
|
1078
|
-
|
|
1091
|
+
min-width: min(280px, 92vw);
|
|
1092
|
+
max-width: min(92vw, 380px);
|
|
1079
1093
|
z-index: 40 !important;
|
|
1080
1094
|
transform: translateX(-110%);
|
|
1081
1095
|
transition: transform .28s ease-in-out;
|
|
1082
1096
|
background: var(--dsw-alias-bg-base, #ffffff);
|
|
1083
|
-
padding
|
|
1097
|
+
padding: max(env(safe-area-inset-top, 0px), 12px) max(env(safe-area-inset-right, 0px), 12px) max(env(safe-area-inset-bottom, 0px), 12px) max(env(safe-area-inset-left, 0px), 12px) !important;
|
|
1084
1098
|
border-right: none !important;
|
|
1085
|
-
touch-action:
|
|
1099
|
+
touch-action: manipulation !important;
|
|
1086
1100
|
}
|
|
1087
1101
|
[${FRAME_ATTR}="frame"]:not([${COLLAPSED_ATTR}]) > :first-child { transform: none !important; }
|
|
1088
1102
|
@media (prefers-reduced-motion: reduce) {
|
|
@@ -1095,12 +1109,15 @@ window.__ModuleLoader__.load({
|
|
|
1095
1109
|
/* 对话区:去桌面滚动条占位,收窄 gutter,字号降一档 */
|
|
1096
1110
|
[data-phase] [class*="_scrollBody"] { scrollbar-gutter: auto !important; scrollbar-width: none; }
|
|
1097
1111
|
[data-phase] [class*="_scrollBody"]::-webkit-scrollbar { display: none !important; width: 0; height: 0; }
|
|
1098
|
-
[data-phase] [class*="_scroll"]:not([class*="_scrollBody"]):has(p) { padding-left: 20px; padding-right: 20px; font-size: 15px !important; }
|
|
1112
|
+
[data-phase] [class*="_scroll"]:not([class*="_scrollBody"]):has(p) { padding-left: clamp(12px, 4vw, 20px); padding-right: clamp(12px, 4vw, 20px); font-size: 15px !important; }
|
|
1099
1113
|
[data-phase] [class*="_scroll"]:not([class*="_scrollBody"]):has(p) p,
|
|
1100
1114
|
[data-phase] [class*="_scroll"]:not([class*="_scrollBody"]):has(p) li,
|
|
1101
1115
|
[data-phase] [class*="_scroll"]:not([class*="_scrollBody"]):has(p) [class*="_text_"] { font-size: 15px !important; }
|
|
1116
|
+
[data-phase] p, [data-phase] li { overflow-wrap: anywhere; }
|
|
1102
1117
|
[data-phase] table { width: 100%; max-width: 100%; }
|
|
1103
1118
|
[data-phase] th, [data-phase] td { max-width: none; min-width: 0; }
|
|
1119
|
+
[data-phase] [class*="tableScroll"] { max-width: 100% !important; overflow-x: auto !important; overscroll-behavior-x: contain; -webkit-overflow-scrolling: touch; touch-action: manipulation !important; }
|
|
1120
|
+
[data-phase] [class*="tableScroll"]::-webkit-scrollbar { display: none !important; }
|
|
1104
1121
|
[data-phase] [class*="_scroll"]:not([class*="_scrollBody"]) img { width: auto !important; max-width: 100% !important; height: auto !important; max-height: 220px !important; }
|
|
1105
1122
|
[data-phase] [class*="_userStack"], [data-phase] [class*="_userStack"] [class*="_bubble"] { box-sizing: border-box; width: fit-content; max-width: 100%; }
|
|
1106
1123
|
[data-phase] [class*="_actions"] { overflow: hidden; }
|
|
@@ -1132,7 +1149,7 @@ window.__ModuleLoader__.load({
|
|
|
1132
1149
|
/* footer 容器各项间距 16px 偏松 */
|
|
1133
1150
|
[data-phase] [class*="_root"][class*="osXY9a"] { gap: 8px !important; }
|
|
1134
1151
|
/* footer 统计行窄屏可横向滑动看全,不溢出页面 */
|
|
1135
|
-
[data-phase] [class*="_actions"] { max-width: 100% !important; overflow-x: auto !important; scrollbar-width: none; touch-action:
|
|
1152
|
+
[data-phase] [class*="_actions"] { max-width: 100% !important; overflow-x: auto !important; overscroll-behavior-x: contain; scrollbar-width: none; touch-action: manipulation !important; }
|
|
1136
1153
|
[data-phase] [class*="_actions"]::-webkit-scrollbar { display: none; }
|
|
1137
1154
|
|
|
1138
1155
|
/* 模型切换菜单:名称完整展示,长名称在菜单项内换行。 */
|
|
@@ -1173,9 +1190,10 @@ window.__ModuleLoader__.load({
|
|
|
1173
1190
|
min-width: 0 !important;
|
|
1174
1191
|
max-width: 100% !important;
|
|
1175
1192
|
overflow-x: auto !important;
|
|
1193
|
+
overscroll-behavior-x: contain;
|
|
1176
1194
|
-webkit-overflow-scrolling: touch;
|
|
1177
1195
|
scrollbar-width: none;
|
|
1178
|
-
touch-action:
|
|
1196
|
+
touch-action: manipulation !important;
|
|
1179
1197
|
}
|
|
1180
1198
|
[data-phase] [class*="resultBlockText"]::-webkit-scrollbar,
|
|
1181
1199
|
[data-phase] [class*="payload"]::-webkit-scrollbar,
|
|
@@ -1191,9 +1209,10 @@ window.__ModuleLoader__.load({
|
|
|
1191
1209
|
min-width: 0 !important;
|
|
1192
1210
|
max-width: 100% !important;
|
|
1193
1211
|
overflow-x: auto !important;
|
|
1212
|
+
overscroll-behavior-x: contain;
|
|
1194
1213
|
-webkit-overflow-scrolling: touch;
|
|
1195
1214
|
scrollbar-width: none;
|
|
1196
|
-
touch-action:
|
|
1215
|
+
touch-action: manipulation !important;
|
|
1197
1216
|
}
|
|
1198
1217
|
[data-phase] [class*="jsonPayload"]::-webkit-scrollbar,
|
|
1199
1218
|
[data-phase] [class*="jsonPreview"]::-webkit-scrollbar,
|
|
@@ -1214,9 +1233,10 @@ window.__ModuleLoader__.load({
|
|
|
1214
1233
|
min-width: 0 !important;
|
|
1215
1234
|
max-width: 100% !important;
|
|
1216
1235
|
overflow-x: auto !important;
|
|
1236
|
+
overscroll-behavior-x: contain;
|
|
1217
1237
|
-webkit-overflow-scrolling: touch;
|
|
1218
1238
|
scrollbar-width: none;
|
|
1219
|
-
touch-action:
|
|
1239
|
+
touch-action: manipulation !important;
|
|
1220
1240
|
}
|
|
1221
1241
|
/* xterm uses a transparent helper textarea for all terminal input. Keep it
|
|
1222
1242
|
focusable and non-zero-sized so mobile browsers can present their keyboard. */
|
|
@@ -1243,7 +1263,7 @@ window.__ModuleLoader__.load({
|
|
|
1243
1263
|
max-width: 100% !important;
|
|
1244
1264
|
overflow-x: auto !important;
|
|
1245
1265
|
overscroll-behavior-x: contain;
|
|
1246
|
-
touch-action:
|
|
1266
|
+
touch-action: manipulation !important;
|
|
1247
1267
|
}
|
|
1248
1268
|
[data-phase] [class*="_prompt_1gdtu_"],
|
|
1249
1269
|
[data-phase] [class*="_promptLine_1gdtu_"],
|
|
@@ -1263,9 +1283,10 @@ window.__ModuleLoader__.load({
|
|
|
1263
1283
|
[data-phase] [class*="_copyButton_1gdtu_"] { position: sticky !important; right: 0; }
|
|
1264
1284
|
[data-phase] [class*="_output_1gdtu_"] {
|
|
1265
1285
|
overflow-x: auto !important;
|
|
1286
|
+
overscroll-behavior-x: contain;
|
|
1266
1287
|
-webkit-overflow-scrolling: touch;
|
|
1267
1288
|
scrollbar-width: none;
|
|
1268
|
-
touch-action:
|
|
1289
|
+
touch-action: manipulation !important;
|
|
1269
1290
|
}
|
|
1270
1291
|
[data-phase] [class*="_output_1gdtu_"]::-webkit-scrollbar { display: none !important; }
|
|
1271
1292
|
[data-phase] [class*="_line_1gdtu_"] {
|
|
@@ -1278,7 +1299,7 @@ window.__ModuleLoader__.load({
|
|
|
1278
1299
|
[data-phase] [class*="_copyButton_"] { touch-action: manipulation !important; }
|
|
1279
1300
|
[data-phase] [class*="_copyAnchor_"],
|
|
1280
1301
|
[data-phase] [class*="_body_1ye18_"],
|
|
1281
|
-
[data-phase] [class*="_root_4qrvp_"] { touch-action:
|
|
1302
|
+
[data-phase] [class*="_root_4qrvp_"] { touch-action: manipulation !important; }
|
|
1282
1303
|
|
|
1283
1304
|
/* 上下文用量弹窗(ContextMeter .JObwrW_panel):上游 dsh-client-ui-trajectory 的
|
|
1284
1305
|
[class*="panel"] 全局规则给它加了 max-width:100%!important,命中本弹窗,使宽度
|
|
@@ -1286,7 +1307,7 @@ window.__ModuleLoader__.load({
|
|
|
1286
1307
|
.JObwrW_panel { max-width: none !important; overflow-x: visible !important; }
|
|
1287
1308
|
|
|
1288
1309
|
/* 头部:标题省略,tab 条横向滚动 */
|
|
1289
|
-
[${FRAME_ATTR}="frame"] [data-phase] header { padding-left: 44px; padding-right: 8px; }
|
|
1310
|
+
[${FRAME_ATTR}="frame"] [data-phase] header { padding-left: calc(44px + env(safe-area-inset-left, 0px)); padding-right: max(8px, env(safe-area-inset-right, 0px)); }
|
|
1290
1311
|
[${FRAME_ATTR}="frame"] [data-phase] header [class*="_crumbs"] { flex: 1 1 0; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap !important; }
|
|
1291
1312
|
[${FRAME_ATTR}="frame"] [data-phase] header [role="tablist"] { flex-wrap: nowrap; gap: 0 16px; overflow-x: auto; overscroll-behavior-x: contain; scrollbar-width: none; }
|
|
1292
1313
|
[${FRAME_ATTR}="frame"] [data-phase] header [role="tablist"]::-webkit-scrollbar { display: none; }
|
|
@@ -1295,10 +1316,10 @@ window.__ModuleLoader__.load({
|
|
|
1295
1316
|
/* 设置对话框:窄屏近全宽 sheet(排除导出等普通对话框与目录选择器) */
|
|
1296
1317
|
[aria-modal="true"]:has(> :first-child > :last-child > button):not(:has([role="navigation"])):not(:has([class*="ZuhsRW"])) {
|
|
1297
1318
|
position: absolute !important;
|
|
1298
|
-
left: 8px !important;
|
|
1319
|
+
left: max(8px, env(safe-area-inset-left, 0px)) !important;
|
|
1299
1320
|
top: calc(env(safe-area-inset-top, 0px) + 12px) !important;
|
|
1300
|
-
width: calc(100vw -
|
|
1301
|
-
max-width: calc(100vw -
|
|
1321
|
+
width: calc(100vw - max(8px, env(safe-area-inset-left, 0px)) - max(8px, env(safe-area-inset-right, 0px))) !important;
|
|
1322
|
+
max-width: calc(100vw - max(8px, env(safe-area-inset-left, 0px)) - max(8px, env(safe-area-inset-right, 0px))) !important;
|
|
1302
1323
|
height: auto !important;
|
|
1303
1324
|
max-height: calc(100dvh - 24px - env(safe-area-inset-top, 0px)) !important;
|
|
1304
1325
|
flex-direction: column !important;
|
|
@@ -1316,6 +1337,11 @@ window.__ModuleLoader__.load({
|
|
|
1316
1337
|
[aria-modal="true"]:has(> :first-child > :last-child > button):not(:has([role="navigation"])):not(:has([class*="ZuhsRW"])) > :first-child > :first-child { display: none !important; }
|
|
1317
1338
|
[aria-modal="true"] [class*="_navList"] { flex: 1 1 auto; min-width: 0; flex-direction: row !important; flex-wrap: wrap; gap: 6px; overflow: visible; }
|
|
1318
1339
|
[aria-modal="true"] [class*="_navList"] > button { flex-shrink: 0; white-space: nowrap; }
|
|
1340
|
+
@media (max-width: 600px) {
|
|
1341
|
+
[aria-modal="true"] [class*="_navList"] { flex-wrap: nowrap !important; overflow-x: auto !important; overscroll-behavior-x: contain; scrollbar-width: none; -webkit-overflow-scrolling: touch; touch-action: manipulation !important; }
|
|
1342
|
+
[aria-modal="true"] [class*="_navList"]::-webkit-scrollbar { display: none !important; }
|
|
1343
|
+
[aria-modal="true"] [class*="_navList"] > button { min-height: 44px; padding: 8px 12px; }
|
|
1344
|
+
}
|
|
1319
1345
|
/* 外观模式卡片横排 */
|
|
1320
1346
|
[aria-modal="true"] [class*="_cubeRow"] { gap: 6px; }
|
|
1321
1347
|
[aria-modal="true"] [class*="_cubeRow"] > * { flex: 1 1 0; flex-direction: row !important; align-items: center; justify-content: center; gap: 6px; padding: 10px 8px; min-height: 0; }
|
|
@@ -1327,12 +1353,12 @@ window.__ModuleLoader__.load({
|
|
|
1327
1353
|
/* 切换按钮:固定头部左侧 */
|
|
1328
1354
|
[${FRAME_ATTR}="toggle"] {
|
|
1329
1355
|
position: absolute !important;
|
|
1330
|
-
left: 8px !important;
|
|
1331
|
-
top: 12px !important;
|
|
1356
|
+
left: max(8px, env(safe-area-inset-left, 0px)) !important;
|
|
1357
|
+
top: calc(env(safe-area-inset-top, 0px) + 12px) !important;
|
|
1332
1358
|
z-index: 2 !important;
|
|
1333
1359
|
display: inline-flex !important;
|
|
1334
1360
|
align-items: center; justify-content: center;
|
|
1335
|
-
width:
|
|
1361
|
+
width: 36px; height: 36px;
|
|
1336
1362
|
padding: 0; border: none; background: none; cursor: pointer; color: inherit;
|
|
1337
1363
|
-webkit-tap-highlight-color: transparent;
|
|
1338
1364
|
}
|
|
@@ -1345,13 +1371,15 @@ window.__ModuleLoader__.load({
|
|
|
1345
1371
|
inset: -7px;
|
|
1346
1372
|
}
|
|
1347
1373
|
[class*="_iconButton"] { position: relative !important; }
|
|
1374
|
+
[data-phase] button, [data-phase] [role="button"], [aria-modal="true"] button { -webkit-tap-highlight-color: transparent; touch-action: manipulation !important; }
|
|
1375
|
+
[data-phase] button:active:not(:disabled), [data-phase] [role="button"]:active, [aria-modal="true"] button:active:not(:disabled) { opacity: .72; }
|
|
1348
1376
|
|
|
1349
1377
|
/* 首页/hero(无活跃会话,session header 不存在)的抽屉切换 FAB:
|
|
1350
1378
|
浮在顶部相机带下方,避免与 hero 头部内容重叠 */
|
|
1351
1379
|
[${FRAME_ATTR}="fab"] {
|
|
1352
1380
|
position: absolute !important;
|
|
1353
1381
|
top: calc(env(safe-area-inset-top, 0px) + 72px) !important;
|
|
1354
|
-
left: 10px !important;
|
|
1382
|
+
left: max(10px, env(safe-area-inset-left, 0px)) !important;
|
|
1355
1383
|
z-index: 21 !important;
|
|
1356
1384
|
display: inline-flex !important;
|
|
1357
1385
|
align-items: center; justify-content: center;
|
|
@@ -1375,10 +1403,13 @@ window.__ModuleLoader__.load({
|
|
|
1375
1403
|
/* 底部安全区(iPhone home 条):viewport-fit=cover 后浏览器 UI 退出底部,
|
|
1376
1404
|
home 指示条叠在 composer / 抽屉 / 设置 sheet 上,遮挡发送按钮与会话列表末项。 */
|
|
1377
1405
|
[class*="composerSeat"], [data-composer-seat] {
|
|
1406
|
+
box-sizing: border-box;
|
|
1378
1407
|
padding-bottom: max(env(safe-area-inset-bottom, 0px), 4px) !important;
|
|
1408
|
+
padding-left: env(safe-area-inset-left, 0px) !important;
|
|
1409
|
+
padding-right: env(safe-area-inset-right, 0px) !important;
|
|
1379
1410
|
}
|
|
1380
1411
|
[${FRAME_ATTR}="frame"] > :first-child {
|
|
1381
|
-
padding-bottom: env(safe-area-inset-bottom, 0px) !important;
|
|
1412
|
+
padding-bottom: max(env(safe-area-inset-bottom, 0px), 12px) !important;
|
|
1382
1413
|
}
|
|
1383
1414
|
[aria-modal="true"]:has(> :first-child > :last-child > button):not(:has([role="navigation"])):not(:has([class*="ZuhsRW"])) {
|
|
1384
1415
|
max-height: calc(100dvh - 24px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px)) !important;
|
|
@@ -1388,11 +1419,19 @@ window.__ModuleLoader__.load({
|
|
|
1388
1419
|
}
|
|
1389
1420
|
|
|
1390
1421
|
/* 会话行触控高度 */
|
|
1391
|
-
[class*="sessionRow"] { min-height:
|
|
1422
|
+
[class*="sessionRow"] { min-height: 48px !important; }
|
|
1423
|
+
|
|
1424
|
+
@media (max-height: 500px) and (orientation: landscape) {
|
|
1425
|
+
[aria-modal="true"]:has(> :first-child > :last-child > button):not(:has([role="navigation"])):not(:has([class*="ZuhsRW"])) {
|
|
1426
|
+
top: max(8px, env(safe-area-inset-top, 0px)) !important;
|
|
1427
|
+
max-height: calc(100dvh - max(8px, env(safe-area-inset-top, 0px)) - max(8px, env(safe-area-inset-bottom, 0px))) !important;
|
|
1428
|
+
}
|
|
1429
|
+
[${FRAME_ATTR}="fab"] { width: 40px; height: 40px; }
|
|
1430
|
+
}
|
|
1392
1431
|
}
|
|
1393
1432
|
|
|
1394
|
-
/*
|
|
1395
|
-
@media (min-width: 1024px), (pointer: fine) {
|
|
1433
|
+
/* 桌面或精细指针且支持悬停的窄窗:隐藏切换按钮 */
|
|
1434
|
+
@media (min-width: 1024px), (max-width: 1023px) and (hover: hover) and (pointer: fine) and (any-pointer: fine) {
|
|
1396
1435
|
[${FRAME_ATTR}="toggle"], [${FRAME_ATTR}="fab"] { display: none !important; }
|
|
1397
1436
|
}
|
|
1398
1437
|
`;
|
|
@@ -1410,14 +1449,15 @@ window.__ModuleLoader__.load({
|
|
|
1410
1449
|
* centerCol 固定 grid-area:1/2,dshb 的 minmax(0,1fr) 0 0 会把第 2 列压成
|
|
1411
1450
|
* 0 宽,会话区整体移出屏幕(手机白屏根因)。
|
|
1412
1451
|
*/
|
|
1413
|
-
let
|
|
1452
|
+
let upstreamDrawerStylesAvailable = false;
|
|
1414
1453
|
function upstreamHandlesDrawer() {
|
|
1415
|
-
if (
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1454
|
+
if (!upstreamDrawerStylesAvailable) {
|
|
1455
|
+
for (const tag of document.querySelectorAll("style")) if ((tag.textContent ?? "").includes("data-sidebar-drawer")) {
|
|
1456
|
+
upstreamDrawerStylesAvailable = true;
|
|
1457
|
+
break;
|
|
1458
|
+
}
|
|
1419
1459
|
}
|
|
1420
|
-
return
|
|
1460
|
+
return shouldUseUpstreamDrawer(window.innerWidth, upstreamDrawerStylesAvailable);
|
|
1421
1461
|
}
|
|
1422
1462
|
/** viewport-fit=cover:让 safe-area-inset 生效,内容避开刘海/状态栏。 */
|
|
1423
1463
|
function installViewport(ctx) {
|
|
@@ -1478,9 +1518,11 @@ window.__ModuleLoader__.load({
|
|
|
1478
1518
|
else clear();
|
|
1479
1519
|
};
|
|
1480
1520
|
narrow.addEventListener("change", onChange);
|
|
1521
|
+
window.addEventListener("resize", ensure);
|
|
1481
1522
|
return () => {
|
|
1482
1523
|
mo.disconnect();
|
|
1483
1524
|
narrow.removeEventListener("change", onChange);
|
|
1525
|
+
window.removeEventListener("resize", ensure);
|
|
1484
1526
|
clear();
|
|
1485
1527
|
};
|
|
1486
1528
|
}, "dshb-mobile: frame marker");
|
|
@@ -1539,11 +1581,13 @@ window.__ModuleLoader__.load({
|
|
|
1539
1581
|
document.addEventListener("keydown", onKeyDown, true);
|
|
1540
1582
|
document.addEventListener("click", onClick, true);
|
|
1541
1583
|
narrow.addEventListener("change", sync);
|
|
1584
|
+
window.addEventListener("resize", sync);
|
|
1542
1585
|
return () => {
|
|
1543
1586
|
mo.disconnect();
|
|
1544
1587
|
document.removeEventListener("keydown", onKeyDown, true);
|
|
1545
1588
|
document.removeEventListener("click", onClick, true);
|
|
1546
1589
|
narrow.removeEventListener("change", sync);
|
|
1590
|
+
window.removeEventListener("resize", sync);
|
|
1547
1591
|
backdrop?.remove();
|
|
1548
1592
|
};
|
|
1549
1593
|
}, "dshb-mobile: drawer interactions");
|
|
@@ -1890,19 +1934,40 @@ window.__ModuleLoader__.load({
|
|
|
1890
1934
|
/** 目录抽屉切换按钮(仅切换,不含文件浏览/日志导出等功能按钮)。 */
|
|
1891
1935
|
function DrawerToggle({ toggleSidebar }) {
|
|
1892
1936
|
const [native, setNative] = (0, react.useState)(upstreamHandlesDrawer());
|
|
1937
|
+
const [expanded, setExpanded] = (0, react.useState)(false);
|
|
1893
1938
|
(0, react.useEffect)(() => {
|
|
1894
|
-
|
|
1895
|
-
const
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
|
|
1939
|
+
const drawerQuery = window.matchMedia(UPSTREAM_DRAWER_QUERY);
|
|
1940
|
+
const sync = () => setNative(upstreamHandlesDrawer());
|
|
1941
|
+
const timer = window.setTimeout(sync, 600);
|
|
1942
|
+
drawerQuery.addEventListener("change", sync);
|
|
1943
|
+
window.addEventListener("resize", sync);
|
|
1944
|
+
return () => {
|
|
1945
|
+
window.clearTimeout(timer);
|
|
1946
|
+
drawerQuery.removeEventListener("change", sync);
|
|
1947
|
+
window.removeEventListener("resize", sync);
|
|
1948
|
+
};
|
|
1949
|
+
}, []);
|
|
1950
|
+
(0, react.useEffect)(() => {
|
|
1951
|
+
const sync = () => {
|
|
1952
|
+
const frame = getFrame();
|
|
1953
|
+
setExpanded(frame !== null && !frame.hasAttribute(COLLAPSED_ATTR));
|
|
1954
|
+
};
|
|
1955
|
+
sync();
|
|
1956
|
+
const observer = new MutationObserver(sync);
|
|
1957
|
+
observer.observe(document.documentElement, {
|
|
1958
|
+
attributes: true,
|
|
1959
|
+
attributeFilter: [COLLAPSED_ATTR],
|
|
1960
|
+
subtree: true
|
|
1961
|
+
});
|
|
1962
|
+
return () => observer.disconnect();
|
|
1963
|
+
}, []);
|
|
1900
1964
|
if (native) return null;
|
|
1901
1965
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
1902
1966
|
type: "button",
|
|
1903
1967
|
"data-dshb-mobile": "toggle",
|
|
1904
|
-
"aria-label": "打开目录",
|
|
1905
|
-
|
|
1968
|
+
"aria-label": expanded ? "关闭目录" : "打开目录",
|
|
1969
|
+
"aria-expanded": expanded,
|
|
1970
|
+
title: expanded ? "关闭目录" : "打开目录",
|
|
1906
1971
|
onClick: () => toggleSidebar(),
|
|
1907
1972
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("svg", {
|
|
1908
1973
|
width: "16",
|
|
@@ -1975,9 +2040,11 @@ window.__ModuleLoader__.load({
|
|
|
1975
2040
|
]
|
|
1976
2041
|
});
|
|
1977
2042
|
narrow.addEventListener("change", sync);
|
|
2043
|
+
window.addEventListener("resize", sync);
|
|
1978
2044
|
return () => {
|
|
1979
2045
|
mo.disconnect();
|
|
1980
2046
|
narrow.removeEventListener("change", sync);
|
|
2047
|
+
window.removeEventListener("resize", sync);
|
|
1981
2048
|
fab?.remove();
|
|
1982
2049
|
};
|
|
1983
2050
|
}, "dshb-mobile: hero fab");
|
|
@@ -2008,8 +2075,8 @@ window.__ModuleLoader__.load({
|
|
|
2008
2075
|
}
|
|
2009
2076
|
//#endregion
|
|
2010
2077
|
//#region src/client/menu-position.ts
|
|
2011
|
-
function shouldForceMenuPosition(side, supportsAnchorPositioning) {
|
|
2012
|
-
return !supportsAnchorPositioning || side === "top";
|
|
2078
|
+
function shouldForceMenuPosition(side, supportsAnchorPositioning, forceAll = false) {
|
|
2079
|
+
return forceAll || !supportsAnchorPositioning || side === "top";
|
|
2013
2080
|
}
|
|
2014
2081
|
function computeMenuPosition(anchor, menu, side, align, viewport, gap = 8, margin = 8) {
|
|
2015
2082
|
let left = anchor.left;
|
|
@@ -2047,41 +2114,63 @@ window.__ModuleLoader__.load({
|
|
|
2047
2114
|
height: rect.height
|
|
2048
2115
|
};
|
|
2049
2116
|
}
|
|
2117
|
+
function setStyleIfChanged(element, property, value) {
|
|
2118
|
+
if (element.style.getPropertyValue(property) === value) return;
|
|
2119
|
+
element.style.setProperty(property, value);
|
|
2120
|
+
}
|
|
2050
2121
|
function installMenuAnchorFallback() {
|
|
2051
2122
|
const anchorPositioningSupported = supportsAnchorPositioning();
|
|
2123
|
+
const mobile = window.matchMedia(MOBILE_QUERY);
|
|
2052
2124
|
const anchors = /* @__PURE__ */ new WeakMap();
|
|
2125
|
+
const resizeObserver = typeof ResizeObserver === "undefined" ? void 0 : new ResizeObserver(() => schedule());
|
|
2053
2126
|
let raf = 0;
|
|
2054
|
-
const
|
|
2055
|
-
const
|
|
2056
|
-
|
|
2127
|
+
const findFallbackTrigger = (side) => {
|
|
2128
|
+
const expanded = Array.from(document.querySelectorAll("button[aria-haspopup=\"menu\"][aria-expanded=\"true\"]")).filter((element) => element.getClientRects().length > 0);
|
|
2129
|
+
const outsideMenu = expanded.filter((element) => element.closest("[role=\"menu\"]") === null);
|
|
2130
|
+
const insideMenu = expanded.filter((element) => element.closest("[role=\"menu\"]") !== null);
|
|
2131
|
+
if (side === "left" || side === "right") return insideMenu.at(-1) ?? outsideMenu.at(-1);
|
|
2132
|
+
return outsideMenu.at(-1) ?? insideMenu.at(-1);
|
|
2133
|
+
};
|
|
2134
|
+
const findAnchor = (menu, side) => {
|
|
2057
2135
|
const name = menu.style.getPropertyValue("position-anchor").trim();
|
|
2058
|
-
|
|
2059
|
-
|
|
2136
|
+
const cached = anchors.get(menu);
|
|
2137
|
+
if (cached?.isConnected && (!name || cached.style.getPropertyValue("anchor-name").trim() === name)) return cached;
|
|
2138
|
+
if (name) for (const element of Array.from(document.querySelectorAll("[style]"))) {
|
|
2060
2139
|
if (element.style.getPropertyValue("anchor-name").trim() !== name) continue;
|
|
2061
2140
|
anchors.set(menu, element);
|
|
2062
2141
|
return element;
|
|
2063
2142
|
}
|
|
2143
|
+
const trigger = findFallbackTrigger(side);
|
|
2144
|
+
if (trigger) anchors.set(menu, trigger);
|
|
2145
|
+
return trigger;
|
|
2064
2146
|
};
|
|
2065
2147
|
const positionMenu = (menu) => {
|
|
2066
2148
|
if (menu.getAttribute("aria-hidden") === "true") return;
|
|
2067
|
-
const
|
|
2149
|
+
const side = menu.dataset.anchorSide ?? "bottom";
|
|
2150
|
+
const anchor = findAnchor(menu, side);
|
|
2068
2151
|
if (!anchor) return;
|
|
2069
2152
|
const target = anchor.matches("button") ? anchor : anchor.querySelector("button") ?? anchor;
|
|
2070
|
-
const side = menu.dataset.anchorSide ?? "bottom";
|
|
2071
2153
|
const align = menu.dataset.anchorAlign ?? "start";
|
|
2072
2154
|
const position = computeMenuPosition(toRect(target), toRect(menu), side, align, {
|
|
2073
2155
|
width: window.innerWidth,
|
|
2074
2156
|
height: window.innerHeight
|
|
2075
2157
|
});
|
|
2076
|
-
menu
|
|
2077
|
-
menu
|
|
2078
|
-
menu
|
|
2079
|
-
menu
|
|
2158
|
+
setStyleIfChanged(menu, "position", "fixed");
|
|
2159
|
+
setStyleIfChanged(menu, "left", `${position.left}px`);
|
|
2160
|
+
setStyleIfChanged(menu, "top", `${position.top}px`);
|
|
2161
|
+
setStyleIfChanged(menu, "bottom", "auto");
|
|
2162
|
+
setStyleIfChanged(menu, "right", "auto");
|
|
2163
|
+
setStyleIfChanged(menu, "position-anchor", "none");
|
|
2164
|
+
setStyleIfChanged(menu, "position-area", "none");
|
|
2165
|
+
setStyleIfChanged(menu, "position-try-fallbacks", "none");
|
|
2166
|
+
setStyleIfChanged(menu, "align-self", "auto");
|
|
2167
|
+
setStyleIfChanged(menu, "justify-self", "auto");
|
|
2080
2168
|
menu.setAttribute(POSITIONED_ATTRIBUTE, "");
|
|
2081
2169
|
};
|
|
2082
2170
|
const positionAll = () => {
|
|
2083
2171
|
for (const menu of Array.from(document.querySelectorAll("[role=\"menu\"][data-anchor-side]"))) {
|
|
2084
|
-
if (!shouldForceMenuPosition(menu.dataset.anchorSide ?? "bottom", anchorPositioningSupported)) continue;
|
|
2172
|
+
if (!shouldForceMenuPosition(menu.dataset.anchorSide ?? "bottom", anchorPositioningSupported, mobile.matches)) continue;
|
|
2173
|
+
resizeObserver?.observe(menu);
|
|
2085
2174
|
positionMenu(menu);
|
|
2086
2175
|
}
|
|
2087
2176
|
};
|
|
@@ -2095,16 +2184,34 @@ window.__ModuleLoader__.load({
|
|
|
2095
2184
|
const observer = new MutationObserver(schedule);
|
|
2096
2185
|
observer.observe(document.body, {
|
|
2097
2186
|
childList: true,
|
|
2098
|
-
subtree: true
|
|
2187
|
+
subtree: true,
|
|
2188
|
+
attributes: true,
|
|
2189
|
+
attributeFilter: [
|
|
2190
|
+
"style",
|
|
2191
|
+
"data-anchor-side",
|
|
2192
|
+
"data-anchor-align",
|
|
2193
|
+
"role",
|
|
2194
|
+
"aria-hidden",
|
|
2195
|
+
"aria-expanded",
|
|
2196
|
+
"aria-haspopup",
|
|
2197
|
+
"aria-controls"
|
|
2198
|
+
]
|
|
2099
2199
|
});
|
|
2100
2200
|
window.addEventListener("scroll", schedule, true);
|
|
2101
2201
|
window.addEventListener("resize", schedule);
|
|
2202
|
+
document.addEventListener("transitionend", schedule, true);
|
|
2203
|
+
document.addEventListener("animationend", schedule, true);
|
|
2204
|
+
mobile.addEventListener("change", schedule);
|
|
2102
2205
|
schedule();
|
|
2103
2206
|
return () => {
|
|
2104
2207
|
observer.disconnect();
|
|
2208
|
+
resizeObserver?.disconnect();
|
|
2105
2209
|
if (raf !== 0) cancelAnimationFrame(raf);
|
|
2106
2210
|
window.removeEventListener("scroll", schedule, true);
|
|
2107
2211
|
window.removeEventListener("resize", schedule);
|
|
2212
|
+
document.removeEventListener("transitionend", schedule, true);
|
|
2213
|
+
document.removeEventListener("animationend", schedule, true);
|
|
2214
|
+
mobile.removeEventListener("change", schedule);
|
|
2108
2215
|
for (const menu of Array.from(document.querySelectorAll(`[${POSITIONED_ATTRIBUTE}]`))) {
|
|
2109
2216
|
menu.style.removeProperty("position");
|
|
2110
2217
|
menu.style.removeProperty("left");
|
|
@@ -3026,6 +3133,9 @@ window.__ModuleLoader__.load({
|
|
|
3026
3133
|
}
|
|
3027
3134
|
//#endregion
|
|
3028
3135
|
//#region src/client/workspace-node-badge-model.ts
|
|
3136
|
+
function isRemoteNodeType(type) {
|
|
3137
|
+
return type === "remote-ssh" || type === "remote-docker";
|
|
3138
|
+
}
|
|
3029
3139
|
function normalizeWorkspacePath(path) {
|
|
3030
3140
|
const collapsed = path.replace(/\\/g, "/").replace(/\/+/g, "/");
|
|
3031
3141
|
const trimmed = collapsed.length > 1 ? collapsed.replace(/\/+$/, "") : collapsed;
|
|
@@ -3176,6 +3286,24 @@ window.__ModuleLoader__.load({
|
|
|
3176
3286
|
label: ""
|
|
3177
3287
|
};
|
|
3178
3288
|
}
|
|
3289
|
+
function directRowChild(row, classPart) {
|
|
3290
|
+
return Array.from(row.children).find((child) => child instanceof HTMLElement && child.className.includes(classPart));
|
|
3291
|
+
}
|
|
3292
|
+
function replaceWorkspaceFolder(state) {
|
|
3293
|
+
return state.kind === "bound" && isRemoteNodeType(state.node.type);
|
|
3294
|
+
}
|
|
3295
|
+
function hideWorkspaceFolder(row) {
|
|
3296
|
+
const folder = directRowChild(row, "folder");
|
|
3297
|
+
if (!folder) return;
|
|
3298
|
+
folder.setAttribute("data-dshb-workspace-folder-hidden", "");
|
|
3299
|
+
folder.style.setProperty("display", "none", "important");
|
|
3300
|
+
}
|
|
3301
|
+
function restoreWorkspaceFolder(row) {
|
|
3302
|
+
const folder = directRowChild(row, "folder");
|
|
3303
|
+
if (!folder) return;
|
|
3304
|
+
folder.removeAttribute("data-dshb-workspace-folder-hidden");
|
|
3305
|
+
folder.style.removeProperty("display");
|
|
3306
|
+
}
|
|
3179
3307
|
function badgeSignature(state) {
|
|
3180
3308
|
if (state.kind === "unbound") return "unbound";
|
|
3181
3309
|
if (state.kind === "missing-node") return JSON.stringify([
|
|
@@ -3258,20 +3386,31 @@ window.__ModuleLoader__.load({
|
|
|
3258
3386
|
const applyRowBadge = (row, state) => {
|
|
3259
3387
|
const existing = row.querySelector(`:scope > [${BADGE_ATTRIBUTE}]`);
|
|
3260
3388
|
if (state.kind === "unbound") {
|
|
3389
|
+
restoreWorkspaceFolder(row);
|
|
3261
3390
|
if (existing && activeBadge === existing) hideTooltip();
|
|
3262
3391
|
existing?.remove();
|
|
3263
3392
|
row.removeAttribute(SIGNATURE_ATTRIBUTE);
|
|
3264
3393
|
return;
|
|
3265
3394
|
}
|
|
3266
|
-
const signature = badgeSignature(state);
|
|
3267
|
-
if (existing && row.getAttribute(SIGNATURE_ATTRIBUTE) === signature) return;
|
|
3268
3395
|
const anchor = row.querySelector("[class*=\"projectText\"]");
|
|
3269
3396
|
if (!anchor || anchor.parentElement !== row) {
|
|
3397
|
+
restoreWorkspaceFolder(row);
|
|
3270
3398
|
if (existing && activeBadge === existing) hideTooltip();
|
|
3271
3399
|
existing?.remove();
|
|
3272
3400
|
row.removeAttribute(SIGNATURE_ATTRIBUTE);
|
|
3273
3401
|
return;
|
|
3274
3402
|
}
|
|
3403
|
+
const replaceFolder = replaceWorkspaceFolder(state);
|
|
3404
|
+
const folder = directRowChild(row, "folder");
|
|
3405
|
+
const chevron = directRowChild(row, "chevron");
|
|
3406
|
+
const before = replaceFolder ? folder ?? chevron ?? anchor : anchor;
|
|
3407
|
+
if (replaceFolder) hideWorkspaceFolder(row);
|
|
3408
|
+
else restoreWorkspaceFolder(row);
|
|
3409
|
+
const signature = badgeSignature(state);
|
|
3410
|
+
if (existing && row.getAttribute(SIGNATURE_ATTRIBUTE) === signature) {
|
|
3411
|
+
if (existing.nextElementSibling !== before) row.insertBefore(existing, before);
|
|
3412
|
+
return;
|
|
3413
|
+
}
|
|
3275
3414
|
const hadFocus = existing === document.activeElement;
|
|
3276
3415
|
if (existing && activeBadge === existing) hideTooltip();
|
|
3277
3416
|
existing?.remove();
|
|
@@ -3310,7 +3449,7 @@ window.__ModuleLoader__.load({
|
|
|
3310
3449
|
hideTooltip();
|
|
3311
3450
|
}
|
|
3312
3451
|
});
|
|
3313
|
-
row.insertBefore(badge,
|
|
3452
|
+
row.insertBefore(badge, before);
|
|
3314
3453
|
row.setAttribute(SIGNATURE_ATTRIBUTE, signature);
|
|
3315
3454
|
if (hadFocus) badge.focus();
|
|
3316
3455
|
};
|
|
@@ -3383,6 +3522,10 @@ window.__ModuleLoader__.load({
|
|
|
3383
3522
|
tooltip?.remove();
|
|
3384
3523
|
for (const badge of Array.from(document.querySelectorAll(`[${BADGE_ATTRIBUTE}]`))) badge.remove();
|
|
3385
3524
|
for (const row of Array.from(document.querySelectorAll(`[${SIGNATURE_ATTRIBUTE}]`))) row.removeAttribute(SIGNATURE_ATTRIBUTE);
|
|
3525
|
+
for (const folder of Array.from(document.querySelectorAll("[data-dshb-workspace-folder-hidden]"))) {
|
|
3526
|
+
folder.removeAttribute("data-dshb-workspace-folder-hidden");
|
|
3527
|
+
folder.style.removeProperty("display");
|
|
3528
|
+
}
|
|
3386
3529
|
style.remove();
|
|
3387
3530
|
};
|
|
3388
3531
|
}
|