dsh-lan-guard 0.7.7 → 0.7.9
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 +38 -0
- package/README.md +15 -11
- package/README.zh.md +15 -11
- package/lib/client.js +30 -13
- package/lib/client.js.map +1 -1
- package/lib/index.js +50 -5
- package/package.json +9 -7
package/lib/index.js
CHANGED
|
@@ -3264,6 +3264,36 @@ const MOBILE_TURN_RAIL_MARKER = "/*dsh-lan-guard:mobile-turn-rail*/";
|
|
|
3264
3264
|
/** Id of the phone preview card the touch layer renders. */
|
|
3265
3265
|
const TURN_RAIL_CARD_ID = "lg-turn-card";
|
|
3266
3266
|
/**
|
|
3267
|
+
* Selectors for the official rail.
|
|
3268
|
+
*
|
|
3269
|
+
* `nav[data-lg-turn-nav]` is the structural seat: when DSH adds a language that
|
|
3270
|
+
* {@link TURN_RAIL_LABELS} does not name yet, the scripts find the rail by its
|
|
3271
|
+
* `button[data-index]` marks, tag it, and every rule below starts applying to it
|
|
3272
|
+
* without a new release.
|
|
3273
|
+
*/
|
|
3274
|
+
const TURN_RAIL_NAV_SELECTORS = [...[
|
|
3275
|
+
"轮次导航",
|
|
3276
|
+
"Turn navigation",
|
|
3277
|
+
"ターン移動",
|
|
3278
|
+
"Navegación por turnos",
|
|
3279
|
+
"Navigation entre les tours",
|
|
3280
|
+
"Rundennavigation",
|
|
3281
|
+
"Навигация по ходам",
|
|
3282
|
+
"Navegação entre turnos"
|
|
3283
|
+
].map((label) => `nav[aria-label="${label}"]`), "nav[data-lg-turn-nav]"];
|
|
3284
|
+
/** The rail itself, for display and layout. */
|
|
3285
|
+
const TURN_RAIL_SELECTOR = TURN_RAIL_NAV_SELECTORS.join(",");
|
|
3286
|
+
/** Everything inside the rail: the touch-action/overscroll containment. */
|
|
3287
|
+
const TURN_RAIL_DESCENDANT_SELECTOR = TURN_RAIL_NAV_SELECTORS.map((selector) => `${selector} *`).join(",");
|
|
3288
|
+
/** The tick marks: one readable height instead of DSH's 2px hairline. */
|
|
3289
|
+
const TURN_RAIL_TICK_SELECTOR = TURN_RAIL_NAV_SELECTORS.map((selector) => `${selector} button[data-index]::before`).join(",");
|
|
3290
|
+
/** The official hover bubble, hidden while this plugin's card is open. */
|
|
3291
|
+
const TURN_RAIL_TOOLTIP_SELECTOR = TURN_RAIL_NAV_SELECTORS.map((selector) => `${selector}[data-lg-turn-card] [role="tooltip"]`).join(",");
|
|
3292
|
+
/** The hovered mark, promoted to a visible brand-coloured bar during a scrub. */
|
|
3293
|
+
const TURN_RAIL_PREVIEW_SELECTOR = TURN_RAIL_NAV_SELECTORS.map((selector) => `${selector}[data-lg-turn-card] button[class*="_markP"]::before`).join(",");
|
|
3294
|
+
/** Embed `text` as the body of a double-quoted JavaScript string literal. */
|
|
3295
|
+
const jsString = (text) => JSON.stringify(text).slice(1, -1);
|
|
3296
|
+
/**
|
|
3267
3297
|
* The phone-only touch layer for the turn rail.
|
|
3268
3298
|
*
|
|
3269
3299
|
* The official rail is a HOVER design: the preview bubble is driven by
|
|
@@ -3307,7 +3337,21 @@ function mobileTurnRailTouchScript() {
|
|
|
3307
3337
|
var tipObserver=null,navObserver=null,markObserver=null,tipNode=null,tipPoll=0,settleTimer=0;
|
|
3308
3338
|
var tipBaseline="",tipGeneration=0,tipCache={},cacheNav=null;
|
|
3309
3339
|
function one(sel,root){try{return (root||doc).querySelector(sel)}catch(e){return null}}
|
|
3310
|
-
function navOf(node){
|
|
3340
|
+
function navOf(node){
|
|
3341
|
+
try{
|
|
3342
|
+
var n=node&&node.closest?node.closest(SEL):null;
|
|
3343
|
+
if(n)return n;
|
|
3344
|
+
/* A language DSH added after this release: the rail is still the only
|
|
3345
|
+
<nav> whose marks carry data-index, so tag it and let the rules that
|
|
3346
|
+
list nav[data-lg-turn-nav] take over. */
|
|
3347
|
+
var c=node&&node.closest?node.closest('nav'):null;
|
|
3348
|
+
if(c&&c.querySelector&&c.querySelector('button[data-index]')){
|
|
3349
|
+
try{c.setAttribute('data-lg-turn-nav','1')}catch(e){}
|
|
3350
|
+
return c;
|
|
3351
|
+
}
|
|
3352
|
+
return null;
|
|
3353
|
+
}catch(e){return null}
|
|
3354
|
+
}
|
|
3311
3355
|
// Official TurnNavigator marks carry data-index; card controls do not.
|
|
3312
3356
|
function marks(){return nav?nav.querySelectorAll("button[data-index]"):[]}
|
|
3313
3357
|
function el(tag,style,text){
|
|
@@ -3747,9 +3791,10 @@ function mobileTurnRailTouchScript() {
|
|
|
3747
3791
|
*
|
|
3748
3792
|
* - the override lives in a `@media (max-width: 1023px)` block, so a desktop
|
|
3749
3793
|
* window is never touched;
|
|
3750
|
-
* - the selector is attribute-based (`nav[aria-label="
|
|
3751
|
-
*
|
|
3752
|
-
*
|
|
3794
|
+
* - the selector is attribute-based (`nav[aria-label="…"]`, one per UI language
|
|
3795
|
+
* DSH ships — eight as of 0.2.2, listed in {@link TURN_RAIL_LABELS}) plus a
|
|
3796
|
+
* structural fallback, because a CSS-module class name is hashed and DSH
|
|
3797
|
+
* localises the label; the labelled rule nudges the rail into the chat
|
|
3753
3798
|
* frame's right gutter (`right:4px`, `width:28px`) so it does not overlap the
|
|
3754
3799
|
* message column;
|
|
3755
3800
|
* - it SELF-CHECKS: if the rail is found but stays invisible while the override
|
|
@@ -3778,7 +3823,7 @@ function mobileTurnRailTouchScript() {
|
|
|
3778
3823
|
* @returns one inline `<script>` element.
|
|
3779
3824
|
*/
|
|
3780
3825
|
function mobileTurnRailScript() {
|
|
3781
|
-
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
|
|
3826
|
+
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=` + JSON.stringify(TURN_RAIL_SELECTOR) + ";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:none!important;-webkit-touch-callout:none;-webkit-user-drag:none;user-select:none;-webkit-user-select:none;overscroll-behavior:contain!important}\"+\"" + jsString(TURN_RAIL_DESCENDANT_SELECTOR) + "{touch-action:none!important;overscroll-behavior:contain!important}\"+\"html,body{overscroll-behavior-y:none!important}\"+\"" + jsString(TURN_RAIL_TICK_SELECTOR) + "{height:3px!important}\"+\"" + jsString(TURN_RAIL_TOOLTIP_SELECTOR) + "{visibility:hidden!important;opacity:0!important;pointer-events:none!important}\"+\"" + jsString(TURN_RAIL_PREVIEW_SELECTOR) + `{transform:translateY(-50%) scaleX(1)!important;background:var(--dsw-alias-state-business-primary,#3964fe)!important;opacity:1!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(){var n=null;try{n=doc.querySelector(SEL)}catch(e){}if(n)return n;try{var all=doc.querySelectorAll("nav");for(var i=0;i<all.length;i++){var c=all[i];if(c.querySelector&&c.querySelector("button[data-index]")){try{c.setAttribute("data-lg-turn-nav","1")}catch(e){}return c}}}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>";
|
|
3782
3827
|
}
|
|
3783
3828
|
/**
|
|
3784
3829
|
* Insert the narrow-screen turn-rail override.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-lan-guard",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.9",
|
|
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",
|
|
@@ -78,7 +78,9 @@
|
|
|
78
78
|
"0.2.1-alpha.5": "compatible",
|
|
79
79
|
"0.2.1-rc.2": "compatible",
|
|
80
80
|
"0.2.1-rc.3": "compatible",
|
|
81
|
-
"0.2.1-rc.4": "compatible"
|
|
81
|
+
"0.2.1-rc.4": "compatible",
|
|
82
|
+
"0.2.2-alpha.2": "compatible",
|
|
83
|
+
"0.2.2-alpha.3": "compatible"
|
|
82
84
|
}
|
|
83
85
|
}
|
|
84
86
|
},
|
|
@@ -99,17 +101,17 @@
|
|
|
99
101
|
"reverse-proxy"
|
|
100
102
|
],
|
|
101
103
|
"devDependencies": {
|
|
102
|
-
"@deepseek-ai/cordis": "4.0.
|
|
103
|
-
"@deepseek-ai/dsh-client-connection": "0.2.
|
|
104
|
-
"@deepseek-ai/dsh-host-webserver": "0.2.
|
|
105
|
-
"@deepseek-ai/schemastery": "3.18.
|
|
104
|
+
"@deepseek-ai/cordis": "4.0.6-alpha.2",
|
|
105
|
+
"@deepseek-ai/dsh-client-connection": "0.2.2-alpha.3",
|
|
106
|
+
"@deepseek-ai/dsh-host-webserver": "0.2.2-alpha.3",
|
|
107
|
+
"@deepseek-ai/schemastery": "3.18.6-alpha.2",
|
|
106
108
|
"@types/node": "^26.2.0",
|
|
107
109
|
"@types/qrcode": "^1.5.6",
|
|
108
110
|
"@types/react": "^18.3.31",
|
|
109
111
|
"tsdown": "^0.22.14",
|
|
110
112
|
"typescript": "^7.0.2",
|
|
111
113
|
"vitest": "^4.1.11",
|
|
112
|
-
"@deepseek-ai/dsh-scope": "0.2.
|
|
114
|
+
"@deepseek-ai/dsh-scope": "0.2.2-alpha.3"
|
|
113
115
|
},
|
|
114
116
|
"packageManager": "pnpm@10.33.1"
|
|
115
117
|
}
|