@linxin666/dsh-remote-web-ui 0.3.3 → 0.3.5
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/assets/mobile-service-worker.js +1 -2
- package/lib/client.js +95 -6
- package/lib/client.js.map +1 -1
- package/lib/index.js +122 -8
- package/lib/mobile.js +2 -6
- package/lib/mobile.js.map +1 -1
- package/lib/types/client/FenceNotice.d.ts +12 -9
- package/lib/types/client/FenceNotice.d.ts.map +1 -1
- package/lib/types/client/FenceNotice.js +67 -2
- package/lib/types/client/PluginSettingsCard.d.ts +2 -0
- package/lib/types/client/PluginSettingsCard.d.ts.map +1 -1
- package/lib/types/client/PluginSettingsCard.js +2 -2
- package/lib/types/client/locales.d.ts +12 -0
- package/lib/types/client/locales.d.ts.map +1 -1
- package/lib/types/client/locales.js +12 -0
- package/lib/types/dsh-home.d.ts.map +1 -1
- package/lib/types/dsh-home.js +9 -3
- package/lib/types/index.d.ts.map +1 -1
- package/lib/types/index.js +24 -2
- package/lib/types/mobile/api.d.ts.map +1 -1
- package/lib/types/mobile/api.js +2 -3
- package/lib/types/mobile-api.d.ts +14 -0
- package/lib/types/mobile-api.d.ts.map +1 -1
- package/lib/types/mobile-api.js +53 -1
- package/lib/types/mobile-routes.d.ts.map +1 -1
- package/lib/types/mobile-routes.js +25 -2
- package/package.json +3 -1
- package/src/client/FenceNotice.tsx +81 -1
- package/src/client/PluginSettingsCard.tsx +4 -2
- package/src/client/locales.ts +12 -0
- package/src/client/remote.module.css +72 -4
- package/src/client/settings-card.module.css +5 -0
- package/src/dsh-home.ts +9 -3
- package/src/index.ts +26 -2
- package/src/mobile/api.ts +2 -3
- package/src/mobile-api.ts +59 -0
- package/src/mobile-routes.ts +24 -2
|
@@ -1,22 +1,25 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Unpaired-desktop notice: a full-page blocking surface rendered when the remote channel
|
|
3
|
-
* (see remote-channel.ts) refuses a call because this desktop browser has no
|
|
4
|
-
* live paired-device cookie. Retires automatically once a gated call
|
|
5
|
-
* succeeds (the channel reports pairing) or when the channel itself is
|
|
6
|
-
* torn down (requirePairingForLan off / plugin disabled), so it never
|
|
7
|
-
* outlives the unpaired state it describes.
|
|
8
|
-
*/
|
|
9
1
|
import type { TranslateNS } from '@deepseek-ai/dsh-client-ui-slots';
|
|
10
2
|
/** Notice props: localized copy. */
|
|
11
3
|
export interface FenceNoticeProps {
|
|
12
4
|
t: TranslateNS<'remote'>;
|
|
13
5
|
/** Retry after the user has opened a freshly issued computer pairing link. */
|
|
14
6
|
onRetry: () => void;
|
|
7
|
+
/** Optional custom pairing acceptor for testing / dependency injection. */
|
|
8
|
+
onAccept?: (token: string) => Promise<{
|
|
9
|
+
ok: true;
|
|
10
|
+
} | {
|
|
11
|
+
ok: false;
|
|
12
|
+
code: 'invalid' | 'used' | 'forbidden';
|
|
13
|
+
}>;
|
|
15
14
|
}
|
|
15
|
+
/**
|
|
16
|
+
* Extract a pairing token from either a raw token string or a copied pairing link URL.
|
|
17
|
+
*/
|
|
18
|
+
export declare function extractPairToken(input: string): string | undefined;
|
|
16
19
|
/**
|
|
17
20
|
* Render the unpaired blocking page.
|
|
18
21
|
* @param props - localized copy.
|
|
19
22
|
* @returns the notice element.
|
|
20
23
|
*/
|
|
21
|
-
export declare function FenceNotice({ t, onRetry }: FenceNoticeProps): import("react").JSX.Element;
|
|
24
|
+
export declare function FenceNotice({ t, onRetry, onAccept }: FenceNoticeProps): import("react").JSX.Element;
|
|
22
25
|
//# sourceMappingURL=FenceNotice.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FenceNotice.d.ts","sourceRoot":"","sources":["../../../src/client/FenceNotice.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"FenceNotice.d.ts","sourceRoot":"","sources":["../../../src/client/FenceNotice.tsx"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kCAAkC,CAAA;AAInE,oCAAoC;AACpC,MAAM,WAAW,gBAAgB;IAC/B,CAAC,EAAE,WAAW,CAAC,QAAQ,CAAC,CAAA;IACxB,8EAA8E;IAC9E,OAAO,EAAE,MAAM,IAAI,CAAA;IACnB,2EAA2E;IAC3E,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC;QAAE,EAAE,EAAE,IAAI,CAAA;KAAE,GAAG;QAAE,EAAE,EAAE,KAAK,CAAC;QAAC,IAAI,EAAE,SAAS,GAAG,MAAM,GAAG,WAAW,CAAA;KAAE,CAAC,CAAA;CAC5G;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAWlE;AAED;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,EAAE,CAAC,EAAE,OAAO,EAAE,QAAqB,EAAE,EAAE,gBAAgB,+BAgFlF"}
|
|
@@ -1,10 +1,75 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
* Unpaired-desktop notice: a full-page blocking surface rendered when the remote channel
|
|
4
|
+
* (see remote-channel.ts) refuses a call because this desktop browser has no
|
|
5
|
+
* live paired-device cookie. Retires automatically once a gated call
|
|
6
|
+
* succeeds (the channel reports pairing) or when the channel itself is
|
|
7
|
+
* torn down (requirePairingForLan off / plugin disabled), so it never
|
|
8
|
+
* outlives the unpaired state it describes.
|
|
9
|
+
*/
|
|
10
|
+
import { useState } from 'react';
|
|
11
|
+
import { acceptPair } from "./pair-api.js";
|
|
2
12
|
import css from './remote.module.css';
|
|
13
|
+
/**
|
|
14
|
+
* Extract a pairing token from either a raw token string or a copied pairing link URL.
|
|
15
|
+
*/
|
|
16
|
+
export function extractPairToken(input) {
|
|
17
|
+
const trimmed = input.trim();
|
|
18
|
+
if (trimmed === '')
|
|
19
|
+
return undefined;
|
|
20
|
+
try {
|
|
21
|
+
const url = new URL(trimmed);
|
|
22
|
+
const token = url.searchParams.get('pair');
|
|
23
|
+
if (token !== null && token !== '')
|
|
24
|
+
return token;
|
|
25
|
+
}
|
|
26
|
+
catch {
|
|
27
|
+
// Plain token string
|
|
28
|
+
}
|
|
29
|
+
return trimmed;
|
|
30
|
+
}
|
|
3
31
|
/**
|
|
4
32
|
* Render the unpaired blocking page.
|
|
5
33
|
* @param props - localized copy.
|
|
6
34
|
* @returns the notice element.
|
|
7
35
|
*/
|
|
8
|
-
export function FenceNotice({ t, onRetry }) {
|
|
9
|
-
|
|
36
|
+
export function FenceNotice({ t, onRetry, onAccept = acceptPair }) {
|
|
37
|
+
const [tokenInput, setTokenInput] = useState('');
|
|
38
|
+
const [submitting, setSubmitting] = useState(false);
|
|
39
|
+
const [errorMsg, setErrorMsg] = useState(undefined);
|
|
40
|
+
const handleSubmit = async (event) => {
|
|
41
|
+
event.preventDefault();
|
|
42
|
+
const token = extractPairToken(tokenInput);
|
|
43
|
+
if (!token)
|
|
44
|
+
return;
|
|
45
|
+
setSubmitting(true);
|
|
46
|
+
setErrorMsg(undefined);
|
|
47
|
+
try {
|
|
48
|
+
const result = await onAccept(token);
|
|
49
|
+
if (result.ok) {
|
|
50
|
+
onRetry();
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
if (result.code === 'invalid') {
|
|
54
|
+
setErrorMsg(t('fence.unpaired.tokenInvalid'));
|
|
55
|
+
}
|
|
56
|
+
else if (result.code === 'used') {
|
|
57
|
+
setErrorMsg(t('fence.unpaired.tokenUsed'));
|
|
58
|
+
}
|
|
59
|
+
else {
|
|
60
|
+
setErrorMsg(t('fence.unpaired.tokenFailed'));
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
catch {
|
|
64
|
+
setErrorMsg(t('fence.unpaired.tokenFailed'));
|
|
65
|
+
}
|
|
66
|
+
finally {
|
|
67
|
+
setSubmitting(false);
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
return (_jsx("div", { className: css.fencePage, role: "dialog", "aria-modal": "true", "aria-labelledby": "remote-fence-title", children: _jsxs("main", { className: css.fenceCard, "data-dsh-plugin": "remote-web-ui", children: [_jsx("div", { className: css.fenceMark, "aria-hidden": "true", children: "\u00D7" }), _jsx("p", { className: css.fenceEyebrow, children: t('fence.unpaired.eyebrow') }), _jsx("h1", { id: "remote-fence-title", className: css.fenceTitle, children: t('fence.unpaired.title') }), _jsx("p", { className: css.fenceDetail, children: t('fence.unpaired.hint') }), _jsxs("ol", { className: css.fenceSteps, children: [_jsx("li", { children: t('fence.unpaired.stepDesktop') }), _jsx("li", { children: t('fence.unpaired.stepLink') }), _jsx("li", { children: t('fence.unpaired.stepOpen') })] }), _jsxs("form", { className: css.fenceForm, onSubmit: handleSubmit, children: [_jsxs("div", { className: css.fenceInputRow, children: [_jsx("input", { type: "text", className: css.fenceInput, placeholder: t('fence.unpaired.tokenPlaceholder'), value: tokenInput, onChange: event => {
|
|
71
|
+
setTokenInput(event.target.value);
|
|
72
|
+
if (errorMsg !== undefined)
|
|
73
|
+
setErrorMsg(undefined);
|
|
74
|
+
}, disabled: submitting, "aria-label": t('fence.unpaired.tokenPlaceholder') }), _jsx("button", { className: css.fencePairButton, type: "submit", disabled: submitting || tokenInput.trim() === '', children: submitting ? t('fence.unpaired.pairing') : t('fence.unpaired.pairAction') })] }), errorMsg !== undefined && (_jsx("p", { className: css.fenceError, role: "alert", children: errorMsg }))] }), _jsx("button", { className: css.fenceRetry, type: "button", onClick: onRetry, children: t('fence.unpaired.retry') }), _jsx("p", { className: css.fenceFootnote, children: t('fence.unpaired.footnote') })] }) }));
|
|
10
75
|
}
|
|
@@ -22,6 +22,8 @@ export interface PluginSettingsCardProps<TKey extends string = string> {
|
|
|
22
22
|
titleKey: TKey;
|
|
23
23
|
/** Locale key of the line describing what this plugin's settings govern. */
|
|
24
24
|
descriptionKey: TKey;
|
|
25
|
+
/** Optional rich header description rendered instead of the plain t(descriptionKey) text (the plain text stays as the tooltip). */
|
|
26
|
+
descriptionNode?: ReactNode;
|
|
25
27
|
/** The card's form state: availability, writability, and what a save would do. */
|
|
26
28
|
state: CardShell;
|
|
27
29
|
/** Write every staged edit. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PluginSettingsCard.d.ts","sourceRoot":"","sources":["../../../src/client/PluginSettingsCard.tsx"],"names":[],"mappings":"AACA;;;;;;;GAOG;AAEH,OAAO,EAAiF,KAAK,SAAS,EAAE,MAAM,OAAO,CAAA;AACrH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAA;AAGnD,oGAAoG;AACpG,eAAO,MAAM,cAAc,kMAUjB,CAAA;AAEV,6CAA6C;AAC7C,MAAM,MAAM,WAAW,GAAG,CAAC,OAAO,cAAc,CAAC,CAAC,MAAM,CAAC,CAAA;AAEzD,oEAAoE;AACpE,MAAM,MAAM,eAAe,CAAC,IAAI,SAAS,MAAM,GAAG,MAAM,IAAI,IAAI,GAAG,WAAW,CAAA;AAE9E,wDAAwD;AACxD,MAAM,WAAW,uBAAuB,CAAC,IAAI,SAAS,MAAM,GAAG,MAAM;IACnE,0CAA0C;IAC1C,CAAC,EAAE,CAAC,GAAG,EAAE,eAAe,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,KAAK,MAAM,CAAA;IACnF,uCAAuC;IACvC,QAAQ,EAAE,IAAI,CAAA;IACd,4EAA4E;IAC5E,cAAc,EAAE,IAAI,CAAA;IACpB,kFAAkF;IAClF,KAAK,EAAE,SAAS,CAAA;IAChB,+BAA+B;IAC/B,MAAM,EAAE,MAAM,IAAI,CAAA;IAClB,8BAA8B;IAC9B,SAAS,EAAE,MAAM,IAAI,CAAA;IACrB;;;OAGG;IACH,WAAW,CAAC,EAAE,OAAO,CAAA;IACrB;;;;OAIG;IACH,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB;;;;OAIG;IACH,UAAU,CAAC,EAAE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AAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAA;IAC9B,oEAAoE;IACpE,OAAO,EAAE,MAAM,IAAI,CAAA;CACpB;AAED,kHAAkH;AAClH,wBAAgB,UAAU,CAAC,KAAK,EAAE,UAAU,GAAG;IAC7C,yEAAyE;IACzE,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,kDAAkD;IAClD,WAAW,CAAC,EAAE,MAAM,CAAA;CACrB,+BAqCA;AAUD,UAAU,YAAY;IACpB,KAAK,EAAE,MAAM,CAAA;IACb,KAAK,EAAE,MAAM,CAAA;CACd;AAID;;;;;;;;GAQG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE;IACjC,EAAE,EAAE,MAAM,CAAA;IACV,OAAO,EAAE,aAAa,CAAC,YAAY,CAAC,CAAA;IACpC,KAAK,EAAE,MAAM,CAAA;IACb,QAAQ,EAAE,OAAO,CAAA;IACjB,OAAO,EAAE,OAAO,CAAA;IAChB,MAAM,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAA;CAC/B,+BA2KA;AAED,0CAA0C;AAC1C,wBAAgB,YAAY,CAAC,KAAK,EAAE,UAAU,GAAG;IAC/C,mCAAmC;IACnC,YAAY,EAAE,MAAM,CAAA;IACpB,8BAA8B;IAC9B,OAAO,EAAE,MAAM,CAAA;IACf,+BAA+B;IAC/B,QAAQ,EAAE,MAAM,CAAA;CACjB,+BAoCA;AAED,sDAAsD;AACtD,wBAAgB,WAAW,CAAC,KAAK,EAAE,UAAU,GAAG;IAC9C,oEAAoE;IACpE,YAAY,EAAE,MAAM,CAAA;IACpB,mEAAmE;IACnE,OAAO,EAAE,aAAa,CAAC;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC,CAAA;CACzD,+BAkCA"}
|
|
@@ -40,8 +40,8 @@ export function PluginSettingsCard(props) {
|
|
|
40
40
|
// With alwaysOpen the nav entry already provides the selection, so the
|
|
41
41
|
// header is a static title row instead of a disclosure button.
|
|
42
42
|
const header = alwaysOpen === true
|
|
43
|
-
? (_jsxs("div", { className: css.headerStatic, children: [_jsxs("span", { className: css.headText, children: [_jsx("span", { className: css.name, title: title, children: title }), _jsx("span", { className: css.description, title: description, children: description })] }), state.dirty ? _jsx("span", { className: css.pending, title: props.t('settings.unsaved'), children: props.t('settings.unsaved') }) : null] }))
|
|
44
|
-
: (_jsxs("button", { type: "button", className: css.header, "aria-expanded": open, "aria-label": `${props.t(open ? 'settings.collapse' : 'settings.expand')}: ${title}`, onClick: () => { setOpen(!open); }, children: [_jsxs("span", { className: css.headText, children: [_jsx("span", { className: css.name, title: title, children: title }), _jsx("span", { className: css.description, title: description, children: description })] }), state.dirty ? _jsx("span", { className: css.pending, title: props.t('settings.unsaved'), children: props.t('settings.unsaved') }) : null, _jsx("svg", { width: "14", height: "14", viewBox: "0 0 14 14", fill: "none", xmlns: "http://www.w3.org/2000/svg", className: open ? `${css.chevron} ${css.chevronOpen}` : css.chevron, children: _jsx("path", { d: "M11.8486 5.5L11.4238 5.92383L8.69727 8.65137C8.44157 8.90706 8.21562 9.13382 8.01172 9.29785C7.79912 9.46883 7.55595 9.61756 7.25 9.66602C7.08435 9.69222 6.91565 9.69222 6.75 9.66602C6.44405 9.61756 6.20088 9.46883 5.98828 9.29785C5.78438 9.13382 5.55843 8.90706 5.30273 8.65137L2.57617 5.92383L2.15137 5.5L3 4.65137L3.42383 5.07617L6.15137 7.80273C6.42595 8.07732 6.59876 8.24849 6.74023 8.3623C6.87291 8.46904 6.92272 8.47813 6.9375 8.48047C6.97895 8.48703 7.02105 8.48703 7.0625 8.48047C7.07728 8.47813 7.12709 8.46904 7.25977 8.3623C7.40124 8.24849 7.57405 8.07732 7.84863 7.80273L10.5762 5.07617L11 4.65137L11.8486 5.5Z", fill: "currentColor" }) })] }));
|
|
43
|
+
? (_jsxs("div", { className: css.headerStatic, children: [_jsxs("span", { className: css.headText, children: [_jsx("span", { className: css.name, title: title, children: title }), _jsx("span", { className: css.description, title: description, children: props.descriptionNode ?? description })] }), state.dirty ? _jsx("span", { className: css.pending, title: props.t('settings.unsaved'), children: props.t('settings.unsaved') }) : null] }))
|
|
44
|
+
: (_jsxs("button", { type: "button", className: css.header, "aria-expanded": open, "aria-label": `${props.t(open ? 'settings.collapse' : 'settings.expand')}: ${title}`, onClick: () => { setOpen(!open); }, children: [_jsxs("span", { className: css.headText, children: [_jsx("span", { className: css.name, title: title, children: title }), _jsx("span", { className: css.description, title: description, children: props.descriptionNode ?? description })] }), state.dirty ? _jsx("span", { className: css.pending, title: props.t('settings.unsaved'), children: props.t('settings.unsaved') }) : null, _jsx("svg", { width: "14", height: "14", viewBox: "0 0 14 14", fill: "none", xmlns: "http://www.w3.org/2000/svg", className: open ? `${css.chevron} ${css.chevronOpen}` : css.chevron, children: _jsx("path", { d: "M11.8486 5.5L11.4238 5.92383L8.69727 8.65137C8.44157 8.90706 8.21562 9.13382 8.01172 9.29785C7.79912 9.46883 7.55595 9.61756 7.25 9.66602C7.08435 9.69222 6.91565 9.69222 6.75 9.66602C6.44405 9.61756 6.20088 9.46883 5.98828 9.29785C5.78438 9.13382 5.55843 8.90706 5.30273 8.65137L2.57617 5.92383L2.15137 5.5L3 4.65137L3.42383 5.07617L6.15137 7.80273C6.42595 8.07732 6.59876 8.24849 6.74023 8.3623C6.87291 8.46904 6.92272 8.47813 6.9375 8.48047C6.97895 8.48703 7.02105 8.48703 7.0625 8.48047C7.07728 8.47813 7.12709 8.46904 7.25977 8.3623C7.40124 8.24849 7.57405 8.07732 7.84863 7.80273L10.5762 5.07617L11 4.65137L11.8486 5.5Z", fill: "currentColor" }) })] }));
|
|
45
45
|
// The namespace exists but the Host does not serve it to this client (the
|
|
46
46
|
// official settings allowlist omits third-party namespaces): show a card
|
|
47
47
|
// that explains the gap instead of vanishing, so a missing card never
|
|
@@ -36,6 +36,12 @@ export declare const zh: {
|
|
|
36
36
|
'fence.unpaired.stepLink': string;
|
|
37
37
|
'fence.unpaired.stepOpen': string;
|
|
38
38
|
'fence.unpaired.retry': string;
|
|
39
|
+
'fence.unpaired.tokenPlaceholder': string;
|
|
40
|
+
'fence.unpaired.pairAction': string;
|
|
41
|
+
'fence.unpaired.pairing': string;
|
|
42
|
+
'fence.unpaired.tokenInvalid': string;
|
|
43
|
+
'fence.unpaired.tokenUsed': string;
|
|
44
|
+
'fence.unpaired.tokenFailed': string;
|
|
39
45
|
'fence.unpaired.footnote': string;
|
|
40
46
|
'posture.exposed': string;
|
|
41
47
|
'posture.exposedHint': string;
|
|
@@ -178,6 +184,12 @@ export declare const en: {
|
|
|
178
184
|
'fence.unpaired.stepLink': string;
|
|
179
185
|
'fence.unpaired.stepOpen': string;
|
|
180
186
|
'fence.unpaired.retry': string;
|
|
187
|
+
'fence.unpaired.tokenPlaceholder': string;
|
|
188
|
+
'fence.unpaired.pairAction': string;
|
|
189
|
+
'fence.unpaired.pairing': string;
|
|
190
|
+
'fence.unpaired.tokenInvalid': string;
|
|
191
|
+
'fence.unpaired.tokenUsed': string;
|
|
192
|
+
'fence.unpaired.tokenFailed': string;
|
|
181
193
|
'fence.unpaired.footnote': string;
|
|
182
194
|
'posture.exposed': string;
|
|
183
195
|
'posture.exposedHint': string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"locales.d.ts","sourceRoot":"","sources":["../../../src/client/locales.ts"],"names":[],"mappings":"AAAA,uEAAuE;AAEvE,mEAAmE;AACnE,eAAO,MAAM,EAAE
|
|
1
|
+
{"version":3,"file":"locales.d.ts","sourceRoot":"","sources":["../../../src/client/locales.ts"],"names":[],"mappings":"AAAA,uEAAuE;AAEvE,mEAAmE;AACnE,eAAO,MAAM,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAgJmB,CAAA;AAElC,sCAAsC;AACtC,MAAM,MAAM,SAAS,GAAG,MAAM,OAAO,EAAE,CAAA;AAEvC,wDAAwD;AACxD,MAAM,MAAM,eAAe,GAAG,SAAS,CAAA;AAEvC,mEAAmE;AACnE,eAAO,MAAM,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAgJsB,CAAA"}
|
|
@@ -36,6 +36,12 @@ export const zh = {
|
|
|
36
36
|
'fence.unpaired.stepLink': '在“设备配对”中复制电脑配对链接。',
|
|
37
37
|
'fence.unpaired.stepOpen': '在当前浏览器打开该链接,完成授权后即可进入。',
|
|
38
38
|
'fence.unpaired.retry': '重新检测',
|
|
39
|
+
'fence.unpaired.tokenPlaceholder': '或在此直接粘贴配对链接 / Token',
|
|
40
|
+
'fence.unpaired.pairAction': '立即配对',
|
|
41
|
+
'fence.unpaired.pairing': '配对中…',
|
|
42
|
+
'fence.unpaired.tokenInvalid': '配对链接或 Token 无效已过期',
|
|
43
|
+
'fence.unpaired.tokenUsed': '该配对链接已被使用',
|
|
44
|
+
'fence.unpaired.tokenFailed': '配对失败,请检查网络或重新获取链接',
|
|
39
45
|
'fence.unpaired.footnote': '请勿使用他人提供的配对链接;管理员可随时取消此设备的授权。',
|
|
40
46
|
'posture.exposed': '/api 通道对未配对设备敞开',
|
|
41
47
|
'posture.exposedHint': '以下来源的请求未经配对即可访问完整桌面 API:{hosts}。请移除对应来源的 --trusted-host(配对机制已覆盖远程访问),或改为仅绑定 127.0.0.1 并使用隧道。',
|
|
@@ -176,6 +182,12 @@ export const en = {
|
|
|
176
182
|
'fence.unpaired.stepLink': 'Copy the computer pairing link under Pair a device.',
|
|
177
183
|
'fence.unpaired.stepOpen': 'Open that link in this browser. After authorization, the workspace will become available.',
|
|
178
184
|
'fence.unpaired.retry': 'Check again',
|
|
185
|
+
'fence.unpaired.tokenPlaceholder': 'Or paste pairing link / token here',
|
|
186
|
+
'fence.unpaired.pairAction': 'Pair Now',
|
|
187
|
+
'fence.unpaired.pairing': 'Pairing…',
|
|
188
|
+
'fence.unpaired.tokenInvalid': 'Pairing link or token is invalid or expired',
|
|
189
|
+
'fence.unpaired.tokenUsed': 'This pairing link has already been used',
|
|
190
|
+
'fence.unpaired.tokenFailed': 'Pairing failed, please check network or issue a new link',
|
|
179
191
|
'fence.unpaired.footnote': 'Do not use pairing links from people you do not trust. An administrator can revoke this device at any time.',
|
|
180
192
|
'posture.exposed': 'The /api channel is open to unpaired devices',
|
|
181
193
|
'posture.exposedHint': 'Requests from {hosts} reach the full desktop API without pairing. Remove --trusted-host for them (pairing already covers remote access), or bind loopback only and use the tunnel.',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dsh-home.d.ts","sourceRoot":"","sources":["../../src/dsh-home.ts"],"names":[],"mappings":"AACA;;;;GAIG;
|
|
1
|
+
{"version":3,"file":"dsh-home.d.ts","sourceRoot":"","sources":["../../src/dsh-home.ts"],"names":[],"mappings":"AACA;;;;GAIG;AAMH,+DAA+D;AAC/D,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,GAAE,MAAkB,GAAG,MAAM,CAMzE;AAED;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,GAAG,GAAE,MAAM,CAAC,UAAwB,EAAE,IAAI,GAAE,MAAkB,GAAG,MAAM,CAUrG;AAED,gEAAgE;AAChE,wBAAgB,OAAO,IAAI,MAAM,CAEhC"}
|
package/lib/types/dsh-home.js
CHANGED
|
@@ -6,12 +6,15 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import { homedir } from 'node:os';
|
|
8
8
|
import { isAbsolute, join } from 'node:path';
|
|
9
|
+
import { isAbsolute as posixIsAbsolute, join as posixJoin } from 'node:path/posix';
|
|
9
10
|
/** Expand a leading ~ (or ~user) in a path, platform-style. */
|
|
10
11
|
export function expandHome(path, home = homedir()) {
|
|
12
|
+
const isPosix = home.startsWith('/');
|
|
13
|
+
const j = isPosix ? posixJoin : join;
|
|
11
14
|
if (path === '~')
|
|
12
15
|
return home;
|
|
13
16
|
if (path.startsWith('~/') || path.startsWith('~\\'))
|
|
14
|
-
return
|
|
17
|
+
return j(home, path.slice(2));
|
|
15
18
|
return path;
|
|
16
19
|
}
|
|
17
20
|
/**
|
|
@@ -21,12 +24,15 @@ export function expandHome(path, home = homedir()) {
|
|
|
21
24
|
* @returns the absolute DSH home path.
|
|
22
25
|
*/
|
|
23
26
|
export function resolveDshHome(env = process.env, home = homedir()) {
|
|
27
|
+
const isPosix = home.startsWith('/');
|
|
28
|
+
const j = isPosix ? posixJoin : join;
|
|
29
|
+
const isAbs = isPosix ? posixIsAbsolute : isAbsolute;
|
|
24
30
|
const raw = env.DSH_HOME;
|
|
25
31
|
if (raw !== undefined && raw.trim() !== '') {
|
|
26
32
|
const expanded = expandHome(raw.trim(), home);
|
|
27
|
-
return
|
|
33
|
+
return isAbs(expanded) ? expanded : j(process.cwd(), expanded);
|
|
28
34
|
}
|
|
29
|
-
return
|
|
35
|
+
return j(home, '.dsh');
|
|
30
36
|
}
|
|
31
37
|
/** Resolve the DSH home directory from the live environment. */
|
|
32
38
|
export function dshHome() {
|
package/lib/types/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAKH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,WAAW,CAAA;AAChD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAElD,OAAO,CAAC,MAAM,aAAa,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAKH,OAAO,KAAK,EAAE,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AAA;CAClB;AAED,eAAO,MAAM,MAAM,EAAE,CAAC,CAAC,MAAM,CAY3B,CAAA;AAKF;;;;GAIG;AACH,KAAK,cAAc,GAAG,QAAQ,CAAC,IAAI,CAAC,MAAM,EAAE,eAAe,GAAG,aAAa,CAAC,CAAC,GAAG;IAC9E,aAAa,EAAE,MAAM,GAAG,SAAS,CAAA;IACjC,WAAW,EAAE,MAAM,CAAA;CACpB,CAAA;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,QAAQ,EAAE,IAAI,CAC5C,cAAc,EACd,YAAY,GAAG,gBAAgB,GAAG,YAAY,GAAG,cAAc,GAAG,YAAY,GAAG,aAAa,CAC/F,GAAG,aAAa,CAShB;AAED,4EAA4E;AAC5E,wBAAgB,kBAAkB,CAAC,IAAI,GAAE,MAAkB,GAAG,MAAM,CAEnE;AAiBD;;;;GAIG;AACH,eAAO,MAAM,KAAK,kBAAuD,CAAA;AAEzE,iBAAS,SAAS,CAAC,GAAG,EAAE,OAAO,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAwVtD"}
|
package/lib/types/index.js
CHANGED
|
@@ -33,7 +33,7 @@ import { UUID_POLYFILL_SCRIPT } from "./uuid-polyfill.js";
|
|
|
33
33
|
/** Stable cordis plugin name. */
|
|
34
34
|
export const name = 'remote-web-ui';
|
|
35
35
|
/** Services required before the pairing surfaces can mount. */
|
|
36
|
-
export const inject = ['webServer', 'apiProxy'];
|
|
36
|
+
export const inject = ['webServer', 'apiProxy', 'commands', 'agents'];
|
|
37
37
|
/**
|
|
38
38
|
* Settings namespace of the remote-control capability — the section the web
|
|
39
39
|
* settings surface edits. Spelled here rather than imported: the browser
|
|
@@ -266,7 +266,25 @@ function applyImpl(ctx, config) {
|
|
|
266
266
|
...makeRoutes({ service, lanAddresses, requirePairingForLan: () => resolve().requirePairingForLan }),
|
|
267
267
|
...makeMobileRoutes(),
|
|
268
268
|
...(apiProxy !== undefined
|
|
269
|
-
? makeMobileApiRoutes({
|
|
269
|
+
? makeMobileApiRoutes({
|
|
270
|
+
service,
|
|
271
|
+
apiProxy,
|
|
272
|
+
pendingTracker: new PendingTracker(),
|
|
273
|
+
mobileEnterToSend: () => resolve().mobileEnterToSend,
|
|
274
|
+
commandDispatcher: ctx.commands !== undefined && ctx.agents !== undefined
|
|
275
|
+
? {
|
|
276
|
+
async execute(sessionId, line, signal) {
|
|
277
|
+
const agent = ctx.agents.get(sessionId);
|
|
278
|
+
if (agent === undefined)
|
|
279
|
+
return { error: 'session-not-found' };
|
|
280
|
+
const execution = await ctx.commands.execute(agent, line, [], signal);
|
|
281
|
+
if (execution === undefined)
|
|
282
|
+
return { error: 'unknown-command' };
|
|
283
|
+
return { ok: true, result: execution.result };
|
|
284
|
+
},
|
|
285
|
+
}
|
|
286
|
+
: undefined,
|
|
287
|
+
})
|
|
270
288
|
: []),
|
|
271
289
|
...(apiProxy !== undefined ? makePairedModelCatalogRoutes({ service, apiProxy, lanAddresses }) : []),
|
|
272
290
|
// The remote desktop channel: policy-gated `/remote` prefix that
|
|
@@ -339,6 +357,10 @@ function applyImpl(ctx, config) {
|
|
|
339
357
|
return false;
|
|
340
358
|
return isPairedDeviceRequest(service, request);
|
|
341
359
|
});
|
|
360
|
+
if (lanAddresses.length > 0) {
|
|
361
|
+
const urls = lanAddresses.map(ip => `http://${ip}:${String(ctx.webServer.port)}/m/`).join(' , ');
|
|
362
|
+
console.log(`remote-web-ui: mobile UI reachable on LAN at ${urls}`);
|
|
363
|
+
}
|
|
342
364
|
const sync = () => {
|
|
343
365
|
const value = resolve();
|
|
344
366
|
service.config = pairingConfigOf(value);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../../src/mobile/api.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,8CAA8C,CAAA;AACjF,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kDAAkD,CA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ash command line (e.g. `/permission workspace-write`). */
|
|
49
49
|
export async function sendCommand(sessionId, line) {
|
|
50
|
-
return await callUnary('
|
|
50
|
+
return await callUnary('mobile.command', {
|
|
51
51
|
sessionId,
|
|
52
|
-
|
|
53
|
-
content: [{ type: 'text', text: line }],
|
|
52
|
+
line,
|
|
54
53
|
});
|
|
55
54
|
}
|
|
56
55
|
/**
|
|
@@ -37,6 +37,20 @@ export interface MobileApiDeps {
|
|
|
37
37
|
mobileEnterToSend: () => boolean;
|
|
38
38
|
/** SSE keep-alive ping cadence for the mux stream (default 15000 ms; test seam). */
|
|
39
39
|
eventsHeartbeatMs?: number;
|
|
40
|
+
/**
|
|
41
|
+
* Optional command dispatcher for executing slash commands on the mobile
|
|
42
|
+
* surface. When absent, `mobile.command` returns an error; the mobile UI
|
|
43
|
+
* can still fall back to `session.prompt` (which sends the line to the
|
|
44
|
+
* model, not the command registry).
|
|
45
|
+
*/
|
|
46
|
+
commandDispatcher?: {
|
|
47
|
+
execute(sessionId: string, line: string, signal: AbortSignal): Promise<{
|
|
48
|
+
ok: true;
|
|
49
|
+
result: unknown;
|
|
50
|
+
} | {
|
|
51
|
+
error: string;
|
|
52
|
+
}>;
|
|
53
|
+
};
|
|
40
54
|
}
|
|
41
55
|
/** Mobile API route paths. */
|
|
42
56
|
export declare const MOBILE_API_PATHS: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mobile-api.d.ts","sourceRoot":"","sources":["../../src/mobile-api.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAGH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,iCAAiC,CAAA;AAC/D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gCAAgC,CAAA;AAG9D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAA;AACzD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,cAAc,CAAA;
|
|
1
|
+
{"version":3,"file":"mobile-api.d.ts","sourceRoot":"","sources":["../../src/mobile-api.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAGH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,iCAAiC,CAAA;AAC/D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gCAAgC,CAAA;AAG9D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAA;AACzD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,cAAc,CAAA;AAgElD,iCAAiC;AACjC,MAAM,WAAW,aAAa;IAC5B,uDAAuD;IACvD,OAAO,EAAE,cAAc,CAAA;IACvB,0DAA0D;IAC1D,QAAQ,EAAE,QAAQ,CAAA;IAClB,2BAA2B;IAC3B,cAAc,EAAE,cAAc,CAAA;IAC9B,kEAAkE;IAClE,iBAAiB,EAAE,MAAM,OAAO,CAAA;IAChC,oFAAoF;IACpF,iBAAiB,CAAC,EAAE,MAAM,CAAA;IAC1B;;;;;OAKG;IACH,iBAAiB,CAAC,EAAE;QAClB,OAAO,CACL,SAAS,EAAE,MAAM,EACjB,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,WAAW,GAClB,OAAO,CAAC;YAAE,EAAE,EAAE,IAAI,CAAC;YAAC,MAAM,EAAE,OAAO,CAAA;SAAE,GAAG;YAAE,KAAK,EAAE,MAAM,CAAA;SAAE,CAAC,CAAA;KAC9D,CAAA;CACF;AAED,8BAA8B;AAC9B,eAAO,MAAM,gBAAgB;;CAEnB,CAAA;AAOV;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,aAAa,GAAG,QAAQ,EAAE,CA2NnE"}
|
package/lib/types/mobile-api.js
CHANGED
|
@@ -55,6 +55,8 @@ const MOBILE_ALLOWLIST = new Set([
|
|
|
55
55
|
const MOBILE_PREFERENCES_METHOD = 'mobile.preferences';
|
|
56
56
|
const MOBILE_PENDING_METHOD = 'mobile.pending';
|
|
57
57
|
const MOBILE_RESPOND_METHOD = 'mobile.respond';
|
|
58
|
+
/** Execute a slash command through the host command registry (#1125). */
|
|
59
|
+
const MOBILE_COMMAND_METHOD = 'mobile.command';
|
|
58
60
|
/** One session.list page (thin phones load incrementally). */
|
|
59
61
|
const SESSION_PAGE_SIZE = 20;
|
|
60
62
|
/** SSE keep-alive ping cadence for the live mux stream (single connection). */
|
|
@@ -130,7 +132,8 @@ export function makeMobileApiRoutes(deps) {
|
|
|
130
132
|
const method = pathname.slice(MOBILE_API_METHOD_PREFIX.length);
|
|
131
133
|
const local = method === MOBILE_PREFERENCES_METHOD
|
|
132
134
|
|| method === MOBILE_PENDING_METHOD
|
|
133
|
-
|| method === MOBILE_RESPOND_METHOD
|
|
135
|
+
|| method === MOBILE_RESPOND_METHOD
|
|
136
|
+
|| method === MOBILE_COMMAND_METHOD;
|
|
134
137
|
if (!MOBILE_ALLOWLIST.has(method) && !local) {
|
|
135
138
|
writeJson(res, 403, { ok: false, error: { code: 'forbidden', message: `method ${method} is not exposed to the mobile surface` } });
|
|
136
139
|
return;
|
|
@@ -188,6 +191,55 @@ export function makeMobileApiRoutes(deps) {
|
|
|
188
191
|
});
|
|
189
192
|
}
|
|
190
193
|
}
|
|
194
|
+
else if (method === MOBILE_COMMAND_METHOD) {
|
|
195
|
+
const payload = parsed.payload;
|
|
196
|
+
const sessionId = payload?.sessionId;
|
|
197
|
+
const line = payload?.line;
|
|
198
|
+
if (typeof sessionId !== 'string' || typeof line !== 'string') {
|
|
199
|
+
writeJson(res, 200, {
|
|
200
|
+
type: 'server-response',
|
|
201
|
+
rpcId,
|
|
202
|
+
result: { ok: false, error: { code: 'bad-request', message: 'missing sessionId or line' } },
|
|
203
|
+
});
|
|
204
|
+
}
|
|
205
|
+
else if (deps.commandDispatcher === undefined) {
|
|
206
|
+
writeJson(res, 200, {
|
|
207
|
+
type: 'server-response',
|
|
208
|
+
rpcId,
|
|
209
|
+
result: { ok: false, error: { code: 'unavailable', message: 'command dispatcher is not available' } },
|
|
210
|
+
});
|
|
211
|
+
}
|
|
212
|
+
else {
|
|
213
|
+
try {
|
|
214
|
+
const abort = new AbortController();
|
|
215
|
+
res.on('close', () => { if (!res.writableEnded)
|
|
216
|
+
abort.abort(); });
|
|
217
|
+
const outcome = await deps.commandDispatcher.execute(sessionId, line, abort.signal);
|
|
218
|
+
if ('error' in outcome) {
|
|
219
|
+
writeJson(res, 200, {
|
|
220
|
+
type: 'server-response',
|
|
221
|
+
rpcId,
|
|
222
|
+
result: { ok: false, error: { code: outcome.error, message: outcome.error } },
|
|
223
|
+
});
|
|
224
|
+
}
|
|
225
|
+
else {
|
|
226
|
+
writeJson(res, 200, {
|
|
227
|
+
type: 'server-response',
|
|
228
|
+
rpcId,
|
|
229
|
+
result: { ok: true, value: { matched: true, result: outcome.result } },
|
|
230
|
+
});
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
catch (error) {
|
|
234
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
235
|
+
writeJson(res, 200, {
|
|
236
|
+
type: 'server-response',
|
|
237
|
+
rpcId,
|
|
238
|
+
result: { ok: false, error: { code: 'internal', message } },
|
|
239
|
+
});
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
}
|
|
191
243
|
return;
|
|
192
244
|
}
|
|
193
245
|
try {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mobile-routes.d.ts","sourceRoot":"","sources":["../../src/mobile-routes.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;
|
|
1
|
+
{"version":3,"file":"mobile-routes.d.ts","sourceRoot":"","sources":["../../src/mobile-routes.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAOH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,iCAAiC,CAAA;AAwH/D;;;GAGG;AACH,wBAAgB,gBAAgB,IAAI,QAAQ,EAAE,CA8F7C"}
|
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
import { readFile } from 'node:fs/promises';
|
|
8
8
|
import { existsSync } from 'node:fs';
|
|
9
9
|
import { fileURLToPath } from 'node:url';
|
|
10
|
+
import { gzipSync } from 'node:zlib';
|
|
10
11
|
const MOBILE_ROOT = '/m/';
|
|
11
12
|
const MOBILE_BUNDLE_URL = '/m/mobile.js';
|
|
12
13
|
const MOBILE_MANIFEST_URL = '/m/manifest.webmanifest';
|
|
@@ -132,7 +133,8 @@ export function makeMobileRoutes() {
|
|
|
132
133
|
// The bundle is immutable for the process lifetime (a rebuild requires a
|
|
133
134
|
// host restart), so the body is read from disk once, not per phone.
|
|
134
135
|
let bundleBody;
|
|
135
|
-
|
|
136
|
+
let bundleGzip;
|
|
137
|
+
const handleBundle = async (req, res) => {
|
|
136
138
|
if (bundleBody === undefined) {
|
|
137
139
|
const path = mobileBundlePath();
|
|
138
140
|
if (!existsSync(path)) {
|
|
@@ -141,13 +143,34 @@ export function makeMobileRoutes() {
|
|
|
141
143
|
}
|
|
142
144
|
try {
|
|
143
145
|
bundleBody = await readFile(path, 'utf8');
|
|
146
|
+
bundleGzip = gzipSync(Buffer.from(bundleBody, 'utf8'));
|
|
144
147
|
}
|
|
145
148
|
catch {
|
|
146
149
|
writeStatic(res, 500, 'text/plain', 'failed to read the mobile bundle');
|
|
147
150
|
return;
|
|
148
151
|
}
|
|
149
152
|
}
|
|
150
|
-
|
|
153
|
+
const acceptEncoding = req.headers['accept-encoding'] ?? '';
|
|
154
|
+
const acceptsGzip = typeof acceptEncoding === 'string' && acceptEncoding.includes('gzip') && bundleGzip !== undefined;
|
|
155
|
+
if (acceptsGzip) {
|
|
156
|
+
res.writeHead(200, {
|
|
157
|
+
'content-type': 'text/javascript; charset=utf-8',
|
|
158
|
+
'content-encoding': 'gzip',
|
|
159
|
+
'cache-control': 'no-cache',
|
|
160
|
+
vary: 'Accept-Encoding',
|
|
161
|
+
'referrer-policy': 'no-referrer',
|
|
162
|
+
});
|
|
163
|
+
res.end(bundleGzip);
|
|
164
|
+
}
|
|
165
|
+
else {
|
|
166
|
+
res.writeHead(200, {
|
|
167
|
+
'content-type': 'text/javascript; charset=utf-8',
|
|
168
|
+
'cache-control': 'no-cache',
|
|
169
|
+
vary: 'Accept-Encoding',
|
|
170
|
+
'referrer-policy': 'no-referrer',
|
|
171
|
+
});
|
|
172
|
+
res.end(bundleBody);
|
|
173
|
+
}
|
|
151
174
|
};
|
|
152
175
|
let workerBody;
|
|
153
176
|
const handleWorker = async (_req, res) => {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@linxin666/dsh-remote-web-ui",
|
|
3
3
|
"description": "Scan-to-pair mobile and PC remote control for the dsh web GUI: QR entry beside the settings button, one-time pairing tokens, a gated /remote/api desktop channel, live device status, and revocable sessions",
|
|
4
|
-
"version": "0.3.
|
|
4
|
+
"version": "0.3.5",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"engines": {
|
|
7
7
|
"node": "^22.19.0 || >=24.0.0"
|
|
@@ -75,6 +75,8 @@
|
|
|
75
75
|
"@deepseek-ai/dsh-host-webserver": "^0.1.1-rc.2",
|
|
76
76
|
"@deepseek-ai/dsh-invariants": "^0.1.1-rc.2",
|
|
77
77
|
"@deepseek-ai/dsh-settings": "^0.1.1-rc.2",
|
|
78
|
+
"@deepseek-ai/dsh-agent": "^0.1.1-rc.2",
|
|
79
|
+
"@deepseek-ai/dsh-commands": "^0.1.1-rc.2",
|
|
78
80
|
"@testing-library/dom": "^10.4.1",
|
|
79
81
|
"@testing-library/react": "^16.3.2",
|
|
80
82
|
"@types/node": "^22.20.0",
|