dsh-lan-guard 0.4.6 → 0.6.0
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/CHANGELOG.md +77 -0
- package/README.md +42 -5
- package/README.zh.md +44 -5
- package/lib/client.js +29 -1
- package/lib/client.js.map +1 -1
- package/lib/index.d.ts +15 -0
- package/lib/index.js +255 -3
- package/package.json +7 -6
package/lib/index.d.ts
CHANGED
|
@@ -119,6 +119,19 @@ interface LanGuardConfigShape {
|
|
|
119
119
|
* clipping overflowing content.
|
|
120
120
|
*/
|
|
121
121
|
mobileScrollFix: boolean;
|
|
122
|
+
/**
|
|
123
|
+
* Whether the served index un-hides DSH's own turn-navigation rail on narrow
|
|
124
|
+
* screens (default FALSE — the only off-by-default mobile patch).
|
|
125
|
+
*
|
|
126
|
+
* DSH renders that rail on a phone but hides it with its own container query
|
|
127
|
+
* (`@container (max-width: 900px)`), so the plugin can bring the PC behaviour
|
|
128
|
+
* to the phone with a scoped stylesheet instead of reimplementing it. It stays
|
|
129
|
+
* off by default because it changes a visual DSH deliberately removed, the
|
|
130
|
+
* rail's 24×10px marks are below the touch-target size the rest of this
|
|
131
|
+
* plugin holds itself to, and this cut has not been through on-device
|
|
132
|
+
* acceptance yet. Applies to the next page load.
|
|
133
|
+
*/
|
|
134
|
+
mobileTurnRail: boolean;
|
|
122
135
|
/** Visitor-side gate configuration. */
|
|
123
136
|
auth: AuthConfigShape;
|
|
124
137
|
/** Transport security configuration. */
|
|
@@ -181,6 +194,8 @@ interface LiveSwitches {
|
|
|
181
194
|
mobileCompat(): boolean;
|
|
182
195
|
/** Whether the served index carries the narrow-screen scroll correction. */
|
|
183
196
|
mobileScrollFix(): boolean;
|
|
197
|
+
/** Whether the served index un-hides DSH's own turn-navigation rail on narrow screens. */
|
|
198
|
+
mobileTurnRail(): boolean;
|
|
184
199
|
/** Whether an unnamed device must pair before it is let in. */
|
|
185
200
|
requirePairing(): boolean;
|
|
186
201
|
/** Whether a paired device still needs the operator's approval (F9). */
|
package/lib/index.js
CHANGED
|
@@ -88,6 +88,7 @@ const Config = z.object({
|
|
|
88
88
|
socketWatchdog: z.boolean().default(true).volatile(),
|
|
89
89
|
mobileCompat: z.boolean().default(true).volatile(),
|
|
90
90
|
mobileScrollFix: z.boolean().default(true).volatile(),
|
|
91
|
+
mobileTurnRail: z.boolean().default(false).volatile(),
|
|
91
92
|
auth: z.object({
|
|
92
93
|
enabled: z.boolean().default(true),
|
|
93
94
|
mode: z.union([
|
|
@@ -156,6 +157,7 @@ function liveSwitches(rawConfig, resolved) {
|
|
|
156
157
|
socketWatchdog: () => readField(root.socketWatchdog, resolved.socketWatchdog),
|
|
157
158
|
mobileCompat: () => readField(root.mobileCompat, resolved.mobileCompat),
|
|
158
159
|
mobileScrollFix: () => readField(root.mobileScrollFix, resolved.mobileScrollFix),
|
|
160
|
+
mobileTurnRail: () => readField(root.mobileTurnRail, resolved.mobileTurnRail),
|
|
159
161
|
mode: () => readField(root.auth === void 0 ? void 0 : auth.mode, resolved.auth.mode),
|
|
160
162
|
adminPolicy: () => readField(root.auth === void 0 ? void 0 : auth.adminPolicy, resolved.auth.adminPolicy),
|
|
161
163
|
adminProtection: () => readField(root.auth === void 0 ? void 0 : auth.adminProtection, resolved.auth.adminProtection),
|
|
@@ -176,6 +178,7 @@ function staticSwitches(config) {
|
|
|
176
178
|
socketWatchdog: () => config.socketWatchdog,
|
|
177
179
|
mobileCompat: () => config.mobileCompat,
|
|
178
180
|
mobileScrollFix: () => config.mobileScrollFix,
|
|
181
|
+
mobileTurnRail: () => config.mobileTurnRail,
|
|
179
182
|
mode: () => config.auth.mode,
|
|
180
183
|
adminPolicy: () => config.auth.adminPolicy,
|
|
181
184
|
adminProtection: () => config.auth.adminProtection,
|
|
@@ -297,7 +300,8 @@ function unwrapVolatileInput(input) {
|
|
|
297
300
|
"answerHeartbeat",
|
|
298
301
|
"socketWatchdog",
|
|
299
302
|
"mobileCompat",
|
|
300
|
-
"mobileScrollFix"
|
|
303
|
+
"mobileScrollFix",
|
|
304
|
+
"mobileTurnRail"
|
|
301
305
|
]) {
|
|
302
306
|
const value = result[key];
|
|
303
307
|
if (isVolatileLike(value)) result[key] = value.get();
|
|
@@ -351,6 +355,7 @@ function parseConfig(input, profileDir) {
|
|
|
351
355
|
socketWatchdog: readField(resolved.socketWatchdog, true),
|
|
352
356
|
mobileCompat: readField(resolved.mobileCompat, true),
|
|
353
357
|
mobileScrollFix: readField(resolved.mobileScrollFix, true),
|
|
358
|
+
mobileTurnRail: readField(resolved.mobileTurnRail, false),
|
|
354
359
|
auth: {
|
|
355
360
|
enabled: readField(rawAuth.enabled, true),
|
|
356
361
|
mode: readField(rawAuth.mode, "token_and_password"),
|
|
@@ -670,6 +675,7 @@ var AuthManager = class {
|
|
|
670
675
|
socketWatchdog: true,
|
|
671
676
|
mobileCompat: true,
|
|
672
677
|
mobileScrollFix: true,
|
|
678
|
+
mobileTurnRail: false,
|
|
673
679
|
auth: options.auth,
|
|
674
680
|
tls: {
|
|
675
681
|
mode: "off",
|
|
@@ -3226,6 +3232,246 @@ function injectMobileScrollFix(html) {
|
|
|
3226
3232
|
if (html.includes("/*dsh-lan-guard:mobile-scroll*/")) return html;
|
|
3227
3233
|
return insertAfterHead(html, mobileScrollFixScript());
|
|
3228
3234
|
}
|
|
3235
|
+
/** Marker proving the mobile turn-rail patch was injected. */
|
|
3236
|
+
const MOBILE_TURN_RAIL_MARKER = "/*dsh-lan-guard:mobile-turn-rail*/";
|
|
3237
|
+
/** Id of the phone preview card the touch layer renders. */
|
|
3238
|
+
const TURN_RAIL_CARD_ID = "lg-turn-card";
|
|
3239
|
+
/**
|
|
3240
|
+
* The phone-only touch layer for the turn rail.
|
|
3241
|
+
*
|
|
3242
|
+
* The official rail is a HOVER design: the preview bubble is driven by
|
|
3243
|
+
* `onPointerMove` / `onFocus` on each mark, so on a touch screen it can never
|
|
3244
|
+
* be read — a tap goes straight to `onClick` (navigate) and there is no hover
|
|
3245
|
+
* state at all. Measured 2026-10-06 on DSH 0.2.1-alpha.1 / iPhone viewport:
|
|
3246
|
+
* the marks are 28×10px with the pitch locked to 10px inside DSH's own
|
|
3247
|
+
* JavaScript, so "tap the right one" is also a precision problem.
|
|
3248
|
+
*
|
|
3249
|
+
* This layer therefore ADDS a gesture instead of changing the existing one:
|
|
3250
|
+
*
|
|
3251
|
+
* - a plain tap still does exactly what it did (the official click navigates);
|
|
3252
|
+
* - holding a mark for ~320ms opens a readable card with that turn's own
|
|
3253
|
+
* preview text (prompt + response), pulled from the official component by
|
|
3254
|
+
* focusing the mark — which is precisely what hovering does on the desktop,
|
|
3255
|
+
* only it survives the finger lifting;
|
|
3256
|
+
* - the card carries ◀ / ▶ steppers and one big jump button, so the turn you
|
|
3257
|
+
* want never depends on hitting a 10px tick;
|
|
3258
|
+
* - dragging (which scrolls the rail natively, `touch-action: pan-y`) or moving
|
|
3259
|
+
* more than 12px cancels the long press, so scrolling is untouched;
|
|
3260
|
+
* - the click that a held touch still emits is swallowed once, so holding never
|
|
3261
|
+
* navigates by accident.
|
|
3262
|
+
*
|
|
3263
|
+
* Every entry point is wrapped, and any failure leaves the rail exactly as the
|
|
3264
|
+
* official code left it. Rendered in DSH's own tokens so light/dark follow.
|
|
3265
|
+
*
|
|
3266
|
+
* @returns the ES5 body of the touch layer; callers embed it in the payload.
|
|
3267
|
+
*/
|
|
3268
|
+
function mobileTurnRailTouchScript() {
|
|
3269
|
+
return `
|
|
3270
|
+
/* --- touch preview layer: hovering is not a gesture a phone has --- */
|
|
3271
|
+
(function(){
|
|
3272
|
+
if(!(S.matchMedia&&S.matchMedia('(pointer: coarse)').matches))return;
|
|
3273
|
+
var CARD_ID="${TURN_RAIL_CARD_ID}";
|
|
3274
|
+
var card=null,titleEl=null,bodyEl=null,jumpEl=null,prevEl=null,nextEl=null,closeEl=null;
|
|
3275
|
+
var nav=null,mark=null,armed=false,armY=0,timer=0,lastY=0;
|
|
3276
|
+
function one(sel,root){try{return (root||doc).querySelector(sel)}catch(e){return null}}
|
|
3277
|
+
function navOf(node){try{return node&&node.closest?node.closest(SEL):null}catch(e){return null}}
|
|
3278
|
+
function marks(){return nav?nav.querySelectorAll("button"):[]}
|
|
3279
|
+
function el(tag,style,text){
|
|
3280
|
+
var node=doc.createElement(tag);
|
|
3281
|
+
if(style)node.style.cssText=style;
|
|
3282
|
+
if(text)node.textContent=text;
|
|
3283
|
+
return node;
|
|
3284
|
+
}
|
|
3285
|
+
var BTN="border:0;border-radius:9px;font:inherit;font-weight:600;min-height:38px;"
|
|
3286
|
+
+"background:var(--dsw-alias-fill-tsp-secondary,rgba(0,0,0,.06));"
|
|
3287
|
+
+"color:var(--dsw-alias-label-primary,#111);pointer-events:auto;padding:0 10px";
|
|
3288
|
+
function build(){
|
|
3289
|
+
if(card)return;
|
|
3290
|
+
card=el("div",'position:fixed;left:12px;right:44px;top:76px;z-index:2147483645;display:none;'
|
|
3291
|
+
+"box-sizing:border-box;padding:10px 12px 12px;border-radius:14px;pointer-events:none;"
|
|
3292
|
+
+"background:var(--dsw-alias-bg-layer-1,#fff);color:var(--dsw-alias-label-primary,#111);"
|
|
3293
|
+
+"box-shadow:var(--dsw-elevation-panel,0 10px 30px rgba(0,0,0,.22));"
|
|
3294
|
+
+"border:.5px solid var(--dsw-alias-border-l2,rgba(0,0,0,.14));"
|
|
3295
|
+
+'font:13px/1.45 -apple-system,BlinkMacSystemFont,"PingFang SC","Hiragino Sans GB",sans-serif');
|
|
3296
|
+
card.id=CARD_ID;
|
|
3297
|
+
var head=el("div","display:flex;align-items:flex-start;gap:8px");
|
|
3298
|
+
titleEl=el("div","flex:1;min-width:0;font-weight:600;overflow:hidden;text-overflow:ellipsis;white-space:nowrap");
|
|
3299
|
+
closeEl=el("button",BTN+"min-width:34px;padding:0 8px;flex:none","✕");
|
|
3300
|
+
closeEl.type="button";
|
|
3301
|
+
head.appendChild(titleEl);head.appendChild(closeEl);
|
|
3302
|
+
bodyEl=el("div","margin-top:4px;color:var(--dsw-alias-label-secondary,#666);"
|
|
3303
|
+
+"white-space:pre-wrap;word-break:break-word;overflow:hidden;"
|
|
3304
|
+
+"display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:5");
|
|
3305
|
+
var row=el("div","display:flex;gap:8px;margin-top:8px");
|
|
3306
|
+
prevEl=el("button",BTN+"flex:none;min-width:44px","◀");
|
|
3307
|
+
nextEl=el("button",BTN+"flex:none;min-width:44px","▶");
|
|
3308
|
+
jumpEl=el("button",BTN+"flex:1;background:var(--dsw-alias-state-business-primary,#3964fe);color:#fff");
|
|
3309
|
+
prevEl.type="button";nextEl.type="button";jumpEl.type="button";
|
|
3310
|
+
row.appendChild(prevEl);row.appendChild(jumpEl);row.appendChild(nextEl);
|
|
3311
|
+
card.appendChild(head);card.appendChild(bodyEl);card.appendChild(row);
|
|
3312
|
+
(doc.body||doc.documentElement).appendChild(card);
|
|
3313
|
+
closeEl.addEventListener("click",function(ev){ev.stopPropagation();hide()});
|
|
3314
|
+
prevEl.addEventListener("click",function(ev){ev.stopPropagation();step(-1)});
|
|
3315
|
+
nextEl.addEventListener("click",function(ev){ev.stopPropagation();step(1)});
|
|
3316
|
+
jumpEl.addEventListener("click",function(ev){
|
|
3317
|
+
ev.stopPropagation();ev.preventDefault();
|
|
3318
|
+
var m=mark;hide();
|
|
3319
|
+
if(m){try{m.click()}catch(e){}}
|
|
3320
|
+
});
|
|
3321
|
+
}
|
|
3322
|
+
function hide(){
|
|
3323
|
+
armed=false;mark=null;
|
|
3324
|
+
if(card)card.style.display="none";
|
|
3325
|
+
try{if(nav)nav.removeAttribute("data-lg-turn-card")}catch(e){}
|
|
3326
|
+
}
|
|
3327
|
+
/** The official bubble is what we read; it must not also float under the finger. */
|
|
3328
|
+
function own(){try{if(nav)nav.setAttribute("data-lg-turn-card","1")}catch(e){}}
|
|
3329
|
+
function paint(){
|
|
3330
|
+
if(!card||!mark)return;
|
|
3331
|
+
var label="";
|
|
3332
|
+
try{label=mark.getAttribute("aria-label")||""}catch(e){}
|
|
3333
|
+
var tip=nav?one('[role="tooltip"]',nav):null;
|
|
3334
|
+
var prompt="",reply="";
|
|
3335
|
+
if(tip&&tip.children){
|
|
3336
|
+
if(tip.children[0])prompt=tip.children[0].textContent||"";
|
|
3337
|
+
if(tip.children[1])reply=tip.children[1].textContent||"";
|
|
3338
|
+
}
|
|
3339
|
+
titleEl.textContent=prompt||label||"轮次";
|
|
3340
|
+
bodyEl.textContent=reply;
|
|
3341
|
+
bodyEl.style.display=reply?"block":"none";
|
|
3342
|
+
jumpEl.textContent=label||"跳转";
|
|
3343
|
+
var vh=S.innerHeight||0;card.style.top=(lastY<vh*0.45?Math.round(vh*0.45):76)+"px";
|
|
3344
|
+
card.style.display="block";
|
|
3345
|
+
own();
|
|
3346
|
+
}
|
|
3347
|
+
function focusMark(node){
|
|
3348
|
+
if(!node)return;
|
|
3349
|
+
mark=node;
|
|
3350
|
+
try{node.focus({preventScroll:true})}catch(e){try{node.focus()}catch(e2){}}
|
|
3351
|
+
paint();
|
|
3352
|
+
// React commits the official tooltip on a later frame; re-read once it has.
|
|
3353
|
+
try{requestAnimationFrame(function(){requestAnimationFrame(function(){
|
|
3354
|
+
if(card&&card.style.display!=="none"&&mark===node)paint()
|
|
3355
|
+
})})}catch(e){}
|
|
3356
|
+
}
|
|
3357
|
+
function step(dir){
|
|
3358
|
+
var all=marks(),i=-1,k=0;
|
|
3359
|
+
for(k=0;k<all.length;k++){if(all[k]===mark){i=k;break}}
|
|
3360
|
+
var j=i+dir;
|
|
3361
|
+
if(j>=0&&j<all.length){focusMark(all[j]);return}
|
|
3362
|
+
var sc=nav?nav.firstElementChild:null;
|
|
3363
|
+
if(sc){sc.scrollTop+=dir*30;try{requestAnimationFrame(function(){
|
|
3364
|
+
var l2=marks();if(!l2.length)return;
|
|
3365
|
+
focusMark(dir<0?l2[l2.length-1]:l2[0]);
|
|
3366
|
+
})}catch(e){}}
|
|
3367
|
+
}
|
|
3368
|
+
function swallowNextClick(){
|
|
3369
|
+
var handler=function(ev){
|
|
3370
|
+
try{if(card&&card.contains(ev.target))return}catch(e){}
|
|
3371
|
+
try{ev.stopPropagation();ev.preventDefault()}catch(e){}
|
|
3372
|
+
try{doc.removeEventListener("click",handler,true)}catch(e){}
|
|
3373
|
+
};
|
|
3374
|
+
try{doc.addEventListener("click",handler,true)}catch(e){}
|
|
3375
|
+
setTimeout(function(){try{doc.removeEventListener("click",handler,true)}catch(e){}},900);
|
|
3376
|
+
}
|
|
3377
|
+
function open(node){
|
|
3378
|
+
nav=navOf(node)||nav;
|
|
3379
|
+
if(!nav)return;
|
|
3380
|
+
lastY=armY;
|
|
3381
|
+
build();
|
|
3382
|
+
focusMark(node);
|
|
3383
|
+
swallowNextClick();
|
|
3384
|
+
log("turn preview: "+(node.getAttribute("aria-label")||""));
|
|
3385
|
+
}
|
|
3386
|
+
function onDown(ev){
|
|
3387
|
+
try{
|
|
3388
|
+
if(card&&card.style.display==="block"&&!card.contains(ev.target))hide();
|
|
3389
|
+
var node=ev.target;
|
|
3390
|
+
if(!node||node.tagName!=="BUTTON")return;
|
|
3391
|
+
var found=navOf(node);
|
|
3392
|
+
if(!found)return;
|
|
3393
|
+
nav=found;armed=true;armY=ev.clientY;lastY=ev.clientY;
|
|
3394
|
+
clearTimeout(timer);
|
|
3395
|
+
timer=setTimeout(function(){if(!armed)return;armed=false;open(node)},320);
|
|
3396
|
+
}catch(e){}
|
|
3397
|
+
}
|
|
3398
|
+
function onMove(ev){
|
|
3399
|
+
try{
|
|
3400
|
+
if(!armed)return;
|
|
3401
|
+
if(Math.abs(ev.clientY-armY)>16){armed=false;clearTimeout(timer)}
|
|
3402
|
+
}catch(e){}
|
|
3403
|
+
}
|
|
3404
|
+
function cancel(){armed=false;clearTimeout(timer)}
|
|
3405
|
+
doc.addEventListener("pointerdown",onDown,true);
|
|
3406
|
+
doc.addEventListener("pointermove",onMove,true);
|
|
3407
|
+
doc.addEventListener("pointerup",cancel,true);
|
|
3408
|
+
doc.addEventListener("pointercancel",cancel,true);
|
|
3409
|
+
log("touch preview layer ready");
|
|
3410
|
+
})();
|
|
3411
|
+
`;
|
|
3412
|
+
}
|
|
3413
|
+
/**
|
|
3414
|
+
* Un-hide DSH's own turn-navigation rail on narrow screens (opt-in, default OFF).
|
|
3415
|
+
*
|
|
3416
|
+
* The rail is NOT missing on a phone — it is rendered, virtualised and wired up,
|
|
3417
|
+
* and exactly one official rule hides it:
|
|
3418
|
+
* `@container (max-width: 900px) { .frame { display: none } }` in
|
|
3419
|
+
* `ui-chat/src/client/chat/TurnNavigator.module.css` (the container is the chat
|
|
3420
|
+
* frame, ~327px wide on a 390px phone). Measured 2026-10-06 against
|
|
3421
|
+
* DSH 0.2.1-alpha.1: the `<nav>` is in the DOM with `display:none` and the
|
|
3422
|
+
* virtualiser renders zero marks until something un-hides it; after a
|
|
3423
|
+
* `display:block` override the rail comes up fully working (marks, active mark,
|
|
3424
|
+
* load-and-jump) with no page errors.
|
|
3425
|
+
*
|
|
3426
|
+
* Why a stylesheet and not a reimplementation: the turn data
|
|
3427
|
+
* (`ui-chat`'s `navigation.items()`) is package-internal, so a plugin cannot
|
|
3428
|
+
* rebuild the rail — but it does not have to. Un-hiding reuses the official
|
|
3429
|
+
* component, its history paging, its active-mark follow and its previews.
|
|
3430
|
+
*
|
|
3431
|
+
* Deliberately conservative, in the same spirit as the scroll fix:
|
|
3432
|
+
*
|
|
3433
|
+
* - the override lives in a `@media (max-width: 1023px)` block, so a desktop
|
|
3434
|
+
* window is never touched;
|
|
3435
|
+
* - the selector is attribute-based (`nav[aria-label="轮次导航"]` /
|
|
3436
|
+
* `"Turn navigation"`) plus one structural fallback, because a CSS-module
|
|
3437
|
+
* class name is hashed; both are display-only except the labelled one, which
|
|
3438
|
+
* also nudges the rail into the chat frame's right gutter (`right:2px`,
|
|
3439
|
+
* `width:24px`) so it stops overlapping the message column;
|
|
3440
|
+
* - it SELF-CHECKS: if the rail is found but stays invisible while the override
|
|
3441
|
+
* is applied, the style is removed again and the page is left byte-identical
|
|
3442
|
+
* to stock (`mobileTurnRail: "reverted"` in the page's patch ledger);
|
|
3443
|
+
* - it never touches anything but the rail itself: no inline styles on `html`,
|
|
3444
|
+
* `body` or `#root`, no new buttons, no scroll containers, no listeners.
|
|
3445
|
+
*
|
|
3446
|
+
* Known limit: the rail's mark pitch is fixed at 10px in JavaScript
|
|
3447
|
+
* (`TURN_SPACING_PX`, `measureElement: () => 10`), so CSS cannot grow the 28×10px
|
|
3448
|
+
* marks into 44px touch targets without making neighbours overlap. That is why
|
|
3449
|
+
* this patch ships a second, phone-only half — {@link mobileTurnRailTouchScript}
|
|
3450
|
+
* — which gives the rail a gesture it can actually be operated with (hold to
|
|
3451
|
+
* preview, steppers to pick the exact turn) instead of relying on precision.
|
|
3452
|
+
*
|
|
3453
|
+
* The rail itself only ever moves inside the chat frame's right gutter: at
|
|
3454
|
+
* `right:4px` / `width:28px` it starts exactly where the message column ends, so
|
|
3455
|
+
* it can never cover text.
|
|
3456
|
+
*
|
|
3457
|
+
* `?lgdiag=1` adds a small report panel (`#lgtr`) that survives a phone with no
|
|
3458
|
+
* attached debugger.
|
|
3459
|
+
*
|
|
3460
|
+
* @returns one inline `<script>` element.
|
|
3461
|
+
*/
|
|
3462
|
+
function mobileTurnRailScript() {
|
|
3463
|
+
return `<script>${MOBILE_TURN_RAIL_MARKER}(function(){try{var S=self,doc=document;var flags=globalThis.${PATCHES_GLOBAL};if(flags&&flags.mobileTurnRail===true)return;globalThis.${PATCHES_GLOBAL}=Object.assign({},flags,{mobileTurnRail:true});var diag=false;try{diag=/[?&]lgdiag/.test((S.location&&S.location.search)||"")}catch(e){}var lines=[];function log(s){lines.push(s);if(!diag)return;try{var p=doc.getElementById("lgtr");if(!p){p=doc.createElement("pre");p.id="lgtr";p.style.cssText="position:fixed;left:0;bottom:0;right:0;max-height:30%;z-index:2147483646;background:rgba(0,0,0,.9);color:#7cf;font:10px/1.3 monospace;padding:6px;margin:0;overflow:auto;white-space:pre-wrap;pointer-events:none";(doc.body||doc.documentElement).appendChild(p)}p.textContent="[lan-guard 轮次导航诊断]"+String.fromCharCode(10)+lines.join(String.fromCharCode(10))}catch(e){}}var SEL="nav[aria-label=\\"轮次导航\\"],nav[aria-label=\\"Turn navigation\\"]";if(!doc.getElementById("lg-turn-rail")){var st=doc.createElement("style");st.id="lg-turn-rail";st.appendChild(doc.createTextNode("@media (max-width: 1023px){"+SEL+"{display:block!important;right:4px!important;width:28px!important;touch-action:pan-y;-webkit-touch-callout:none}"+"nav[aria-label=\\"轮次导航\\"] button::before,nav[aria-label=\\"Turn navigation\\"] button::before{height:3px!important}"+"nav[aria-label=\\"轮次导航\\"][data-lg-turn-card] [role=\\"tooltip\\"],nav[aria-label=\\"Turn navigation\\"][data-lg-turn-card] [role=\\"tooltip\\"]{display:none!important}"+"div:has(>div [data-chat-flow])>div>nav{display:block!important}"+"}"));(doc.head||doc.documentElement).appendChild(st)}var narrow=false;try{narrow=!!(S.matchMedia&&S.matchMedia("(max-width: 1023px)").matches)}catch(e){}log("narrow="+narrow);var tries=0,misses=0,done=false;function rail(){try{return doc.querySelector(SEL)}catch(e){return null}}function visible(n){try{var cs=getComputedStyle(n),r=n.getBoundingClientRect();return cs.display!=="none"&&r.width>1&&r.height>1}catch(e){return false}}function revert(){try{var s=doc.getElementById("lg-turn-rail");if(s&&s.parentNode)s.parentNode.removeChild(s)}catch(e){}globalThis.${PATCHES_GLOBAL}=Object.assign({},globalThis.${PATCHES_GLOBAL},{mobileTurnRail:"reverted"});}function run(){if(done)return;if(!narrow){done=true;return}var n=rail();if(!n){if(++tries>8){log("no turn rail yet (style kept for the next session)");done=true}return}if(visible(n)){var r=n.getBoundingClientRect();log("turn rail visible "+Math.round(r.width)+"x"+Math.round(r.height)+" at x"+Math.round(r.x));done=true;return}if(++misses>=3){log("override lost -> reverted (stock page)");revert();done=true}}log("style installed");run();var t=setInterval(function(){if(done){clearInterval(t);return}run()},1500);try{` + mobileTurnRailTouchScript() + "}catch(e){}}catch(e){}})()<\/script>";
|
|
3464
|
+
}
|
|
3465
|
+
/**
|
|
3466
|
+
* Insert the narrow-screen turn-rail override.
|
|
3467
|
+
*
|
|
3468
|
+
* @param html - the index body as DSH rendered it.
|
|
3469
|
+
* @returns the body with the override inserted.
|
|
3470
|
+
*/
|
|
3471
|
+
function injectMobileTurnRail(html) {
|
|
3472
|
+
if (html.includes("/*dsh-lan-guard:mobile-turn-rail*/")) return html;
|
|
3473
|
+
return insertAfterHead(html, mobileTurnRailScript());
|
|
3474
|
+
}
|
|
3229
3475
|
/**
|
|
3230
3476
|
* The mobile compatibility shims, in one inline script.
|
|
3231
3477
|
*
|
|
@@ -3333,6 +3579,7 @@ function registerIndexPatches(options) {
|
|
|
3333
3579
|
let out = html;
|
|
3334
3580
|
if (options.switches.mobileCompat()) out = injectMobileCompat(out);
|
|
3335
3581
|
if (options.switches.mobileScrollFix()) out = injectMobileScrollFix(out);
|
|
3582
|
+
if (options.switches.mobileTurnRail()) out = injectMobileTurnRail(out);
|
|
3336
3583
|
if (options.switches.socketWatchdog()) out = injectSocketWatchdog(out);
|
|
3337
3584
|
if (options.switches.settingsUnlock()) out = injectSettingsUnlock(out);
|
|
3338
3585
|
return out;
|
|
@@ -3409,7 +3656,8 @@ function sanitizePreferencePatch(patch) {
|
|
|
3409
3656
|
"answerHeartbeat",
|
|
3410
3657
|
"socketWatchdog",
|
|
3411
3658
|
"mobileCompat",
|
|
3412
|
-
"mobileScrollFix"
|
|
3659
|
+
"mobileScrollFix",
|
|
3660
|
+
"mobileTurnRail"
|
|
3413
3661
|
]) {
|
|
3414
3662
|
if (!Object.hasOwn(source, key)) continue;
|
|
3415
3663
|
if (typeof source[key] !== "boolean") throw new PreferenceError(`${key} must be a boolean`);
|
|
@@ -3460,6 +3708,7 @@ function toSettingsPatch(values) {
|
|
|
3460
3708
|
if (values.socketWatchdog !== void 0) patch.socketWatchdog = values.socketWatchdog;
|
|
3461
3709
|
if (values.mobileCompat !== void 0) patch.mobileCompat = values.mobileCompat;
|
|
3462
3710
|
if (values.mobileScrollFix !== void 0) patch.mobileScrollFix = values.mobileScrollFix;
|
|
3711
|
+
if (values.mobileTurnRail !== void 0) patch.mobileTurnRail = values.mobileTurnRail;
|
|
3463
3712
|
if (values.requirePairing !== void 0) auth.requirePairing = values.requirePairing;
|
|
3464
3713
|
if (values.requireApproval !== void 0) auth.requireApproval = values.requireApproval;
|
|
3465
3714
|
if (values.mode !== void 0) auth.mode = values.mode;
|
|
@@ -3597,6 +3846,7 @@ function registerManagementRoutes(options) {
|
|
|
3597
3846
|
socketWatchdog: options.switches.socketWatchdog(),
|
|
3598
3847
|
mobileCompat: options.switches.mobileCompat(),
|
|
3599
3848
|
mobileScrollFix: options.switches.mobileScrollFix(),
|
|
3849
|
+
mobileTurnRail: options.switches.mobileTurnRail(),
|
|
3600
3850
|
mode: options.switches.mode(),
|
|
3601
3851
|
adminPolicy: options.switches.adminPolicy(),
|
|
3602
3852
|
adminProtection: options.switches.adminProtection(),
|
|
@@ -4024,7 +4274,8 @@ function registerManagementRoutes(options) {
|
|
|
4024
4274
|
}));
|
|
4025
4275
|
/**
|
|
4026
4276
|
* Index patches: the remote settings-page unlock, the mobile compatibility
|
|
4027
|
-
* shims
|
|
4277
|
+
* shims, the narrow-screen scroll correction, the narrow-screen turn-rail
|
|
4278
|
+
* override and the client-side socket watchdog.
|
|
4028
4279
|
*
|
|
4029
4280
|
* DSH disables its OFFICIAL settings surface for any page whose address bar
|
|
4030
4281
|
* is not loopback, which is every device arriving through this gateway; the
|
|
@@ -4039,6 +4290,7 @@ function registerManagementRoutes(options) {
|
|
|
4039
4290
|
settingsUnlock: () => options.switches.settingsUnlock(),
|
|
4040
4291
|
mobileCompat: () => options.switches.mobileCompat(),
|
|
4041
4292
|
mobileScrollFix: () => options.switches.mobileScrollFix(),
|
|
4293
|
+
mobileTurnRail: () => options.switches.mobileTurnRail(),
|
|
4042
4294
|
socketWatchdog: () => options.switches.socketWatchdog()
|
|
4043
4295
|
},
|
|
4044
4296
|
logger
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-lan-guard",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"description": "DSH web plugin: expose the official desktop Web UI to the local network through a gated reverse proxy, without touching DSH's own loopback binding.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -70,7 +70,8 @@
|
|
|
70
70
|
"0.1.7-rc.2": "compatible",
|
|
71
71
|
"0.1.7-rc.1": "compatible",
|
|
72
72
|
"0.2.0-rc.1": "compatible",
|
|
73
|
-
"0.2.0-rc.2": "compatible"
|
|
73
|
+
"0.2.0-rc.2": "compatible",
|
|
74
|
+
"0.2.1-alpha.1": "compatible"
|
|
74
75
|
}
|
|
75
76
|
}
|
|
76
77
|
},
|
|
@@ -91,10 +92,10 @@
|
|
|
91
92
|
"reverse-proxy"
|
|
92
93
|
],
|
|
93
94
|
"devDependencies": {
|
|
94
|
-
"@deepseek-ai/cordis": "
|
|
95
|
-
"@deepseek-ai/dsh-client-connection": "0.2.
|
|
96
|
-
"@deepseek-ai/dsh-host-webserver": "0.2.
|
|
97
|
-
"@deepseek-ai/schemastery": "
|
|
95
|
+
"@deepseek-ai/cordis": "4.0.5-alpha.1",
|
|
96
|
+
"@deepseek-ai/dsh-client-connection": "0.2.1-alpha.1",
|
|
97
|
+
"@deepseek-ai/dsh-host-webserver": "0.2.1-alpha.1",
|
|
98
|
+
"@deepseek-ai/schemastery": "3.18.5-alpha.1",
|
|
98
99
|
"@types/node": "^26.2.0",
|
|
99
100
|
"@types/qrcode": "^1.5.6",
|
|
100
101
|
"@types/react": "^18.3.31",
|