@linxin666/dsh-ssh 0.3.9 → 0.3.10
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 +58 -10
- package/lib/client.js.map +1 -1
- package/lib/types/client/mount.d.ts +4 -1
- package/lib/types/client/panel/helpers.d.ts +2 -0
- package/lib/types/client/sidebar-entry-core.d.ts +10 -0
- package/lib/types/client/sidebar-entry.d.ts +7 -1
- package/package.json +1 -1
- package/src/client/index.ts +8 -2
- package/src/client/mount.tsx +11 -1
- package/src/client/panel/helpers.ts +14 -0
- package/src/client/sidebar-entry-core.ts +33 -7
- package/src/client/sidebar-entry.ts +7 -1
package/lib/client.js
CHANGED
|
@@ -339,8 +339,20 @@ window.__ModuleLoader__.load({
|
|
|
339
339
|
function dictionary() {
|
|
340
340
|
return (typeof document !== "undefined" ? document.documentElement.lang : "zh").toLowerCase().startsWith("en") ? { ...en } : { ...zh };
|
|
341
341
|
}
|
|
342
|
+
/**
|
|
343
|
+
* SDK translate seat wired by the browser apply() once ctx.locale is bound
|
|
344
|
+
* (setRuntimeTranslate): reads the ACTIVE locale at call time, so plain-DOM
|
|
345
|
+
* surfaces follow a runtime language switch. The document-language pick stays
|
|
346
|
+
* as the unwired fallback (locale service absent, module-scope early callers).
|
|
347
|
+
*/
|
|
348
|
+
let runtimeT;
|
|
349
|
+
/** Wire the SDK translate seat; pass undefined to restore the document-language pick. */
|
|
350
|
+
function setRuntimeTranslate(t) {
|
|
351
|
+
runtimeT = t;
|
|
352
|
+
}
|
|
342
353
|
/** Translate a key with optional {name} template params (current language). */
|
|
343
354
|
function tt(key, values) {
|
|
355
|
+
if (runtimeT !== void 0) return runtimeT(key, values);
|
|
344
356
|
return t(dictionary(), key, values);
|
|
345
357
|
}
|
|
346
358
|
/** Human-readable error text from an unknown thrown value. */
|
|
@@ -15838,11 +15850,23 @@ window.__ModuleLoader__.load({
|
|
|
15838
15850
|
* @param controller - the panel controller driving the view.
|
|
15839
15851
|
* @param api - the SSH API client the tabs operate through.
|
|
15840
15852
|
* @param terminalFont - live terminal-font setting source (issue #577).
|
|
15853
|
+
* @param locale - locale-change source; when given, re-renders an open panel
|
|
15854
|
+
* on a Language switch.
|
|
15841
15855
|
* @returns disposer unmounting the tree and restoring the column.
|
|
15842
15856
|
*/
|
|
15843
|
-
function mountPanel(controller, api, terminalFont) {
|
|
15857
|
+
function mountPanel(controller, api, terminalFont, locale) {
|
|
15844
15858
|
let root;
|
|
15845
15859
|
let container;
|
|
15860
|
+
let unsubscribeLocale;
|
|
15861
|
+
try {
|
|
15862
|
+
unsubscribeLocale = locale?.subscribe(() => {
|
|
15863
|
+
if (root !== void 0) root.render(/* @__PURE__ */ (0, react_jsx_runtime.jsx)(SshPanel, {
|
|
15864
|
+
controller,
|
|
15865
|
+
api,
|
|
15866
|
+
terminalFont
|
|
15867
|
+
}));
|
|
15868
|
+
});
|
|
15869
|
+
} catch {}
|
|
15846
15870
|
const ensure = () => {
|
|
15847
15871
|
if (container !== void 0) {
|
|
15848
15872
|
if (container.isConnected) return;
|
|
@@ -15899,6 +15923,7 @@ window.__ModuleLoader__.load({
|
|
|
15899
15923
|
document.removeEventListener(ACTIVATE_EVENT, onOtherActivate);
|
|
15900
15924
|
waitObserver.disconnect();
|
|
15901
15925
|
unsubscribe();
|
|
15926
|
+
unsubscribeLocale?.();
|
|
15902
15927
|
document.documentElement.removeAttribute(ACTIVE_ATTR);
|
|
15903
15928
|
root?.unmount();
|
|
15904
15929
|
root = void 0;
|
|
@@ -15963,11 +15988,23 @@ window.__ModuleLoader__.load({
|
|
|
15963
15988
|
entry.setAttribute("data-dsh-part", "sidebar-entry");
|
|
15964
15989
|
}
|
|
15965
15990
|
entry.className = options.css["entry"] ?? "";
|
|
15966
|
-
|
|
15967
|
-
|
|
15968
|
-
|
|
15991
|
+
const labelSpan = document.createElement("span");
|
|
15992
|
+
labelSpan.className = options.css["entryLabel"] ?? "";
|
|
15993
|
+
const iconSpan = document.createElement("span");
|
|
15994
|
+
iconSpan.className = options.css["entryIcon"] ?? "";
|
|
15995
|
+
iconSpan.innerHTML = options.icon;
|
|
15996
|
+
entry.append(iconSpan, labelSpan);
|
|
15997
|
+
const applyLabel = () => {
|
|
15998
|
+
entry.setAttribute("aria-label", options.label());
|
|
15999
|
+
if (options.tooltip !== void 0) entry.setAttribute("title", options.tooltip());
|
|
16000
|
+
labelSpan.textContent = options.label();
|
|
16001
|
+
};
|
|
16002
|
+
applyLabel();
|
|
15969
16003
|
entry.addEventListener("click", options.onToggle);
|
|
15970
|
-
return
|
|
16004
|
+
return {
|
|
16005
|
+
entry,
|
|
16006
|
+
applyLabel
|
|
16007
|
+
};
|
|
15971
16008
|
}
|
|
15972
16009
|
/** Re-insert the entry after the New Session row (before the browser region). */
|
|
15973
16010
|
function placeEntry(root, entry, options) {
|
|
@@ -15990,9 +16027,13 @@ window.__ModuleLoader__.load({
|
|
|
15990
16027
|
*/
|
|
15991
16028
|
function mountSidebarEntry$1(options) {
|
|
15992
16029
|
if (typeof document !== "undefined" && document.querySelector(options.rowSelector) !== null) return () => {};
|
|
15993
|
-
const entry = createEntry(options);
|
|
16030
|
+
const { entry, applyLabel } = createEntry(options);
|
|
15994
16031
|
let root;
|
|
15995
16032
|
let placed = false;
|
|
16033
|
+
let unsubscribeRefresh;
|
|
16034
|
+
if (options.refresh !== void 0) try {
|
|
16035
|
+
unsubscribeRefresh = options.refresh.subscribe(applyLabel);
|
|
16036
|
+
} catch {}
|
|
15996
16037
|
const tryPlace = () => {
|
|
15997
16038
|
if (root !== void 0 && !root.isConnected) {
|
|
15998
16039
|
rootObserver.disconnect();
|
|
@@ -16041,6 +16082,7 @@ window.__ModuleLoader__.load({
|
|
|
16041
16082
|
return () => {
|
|
16042
16083
|
waitObserver.disconnect();
|
|
16043
16084
|
rootObserver.disconnect();
|
|
16085
|
+
unsubscribeRefresh?.();
|
|
16044
16086
|
unsubscribeActive?.();
|
|
16045
16087
|
entry.remove();
|
|
16046
16088
|
};
|
|
@@ -16055,9 +16097,11 @@ window.__ModuleLoader__.load({
|
|
|
16055
16097
|
* Mount the sidebar entry, waiting for the shell to render and self-healing
|
|
16056
16098
|
* on later React re-renders.
|
|
16057
16099
|
* @param controller - the panel controller the entry toggles.
|
|
16100
|
+
* @param locale - locale-change source; when given, re-applies the label on
|
|
16101
|
+
* a Language switch (the plain-DOM row otherwise keeps the mount-time copy).
|
|
16058
16102
|
* @returns disposer removing the entry and its observers.
|
|
16059
16103
|
*/
|
|
16060
|
-
function mountSidebarEntry(controller) {
|
|
16104
|
+
function mountSidebarEntry(controller, locale) {
|
|
16061
16105
|
return mountSidebarEntry$1({
|
|
16062
16106
|
rowAttribute: "data-dsh-ssh-entry",
|
|
16063
16107
|
rowSelector: ENTRY_SELECTOR,
|
|
@@ -16066,6 +16110,7 @@ window.__ModuleLoader__.load({
|
|
|
16066
16110
|
css: panel_module_css_default,
|
|
16067
16111
|
label: () => tt("entry.label"),
|
|
16068
16112
|
tooltip: () => tt("entry.tooltip"),
|
|
16113
|
+
refresh: locale === void 0 ? void 0 : { subscribe: (listener) => locale.subscribe(listener) },
|
|
16069
16114
|
onToggle: () => {
|
|
16070
16115
|
controller.toggle();
|
|
16071
16116
|
},
|
|
@@ -16085,7 +16130,7 @@ window.__ModuleLoader__.load({
|
|
|
16085
16130
|
/** The building package's version, when the bundle carries it. */
|
|
16086
16131
|
function bakedVersion() {
|
|
16087
16132
|
try {
|
|
16088
|
-
return "0.3.
|
|
16133
|
+
return "0.3.10";
|
|
16089
16134
|
} catch {
|
|
16090
16135
|
return;
|
|
16091
16136
|
}
|
|
@@ -16175,6 +16220,9 @@ window.__ModuleLoader__.load({
|
|
|
16175
16220
|
return () => {};
|
|
16176
16221
|
}
|
|
16177
16222
|
}, "dsh-ssh: dictionaries");
|
|
16223
|
+
try {
|
|
16224
|
+
setRuntimeTranslate(ctx.locale.bind(NS));
|
|
16225
|
+
} catch {}
|
|
16178
16226
|
const controller = new PanelController();
|
|
16179
16227
|
const api = new SshApi();
|
|
16180
16228
|
const scope = (ctx.get("webUiSettings") ?? ctx.settingsScope).bind({ namespace: SETTINGS_NS });
|
|
@@ -16187,8 +16235,8 @@ window.__ModuleLoader__.load({
|
|
|
16187
16235
|
};
|
|
16188
16236
|
const disposers = [];
|
|
16189
16237
|
try {
|
|
16190
|
-
disposers.push(mountSidebarEntry(controller));
|
|
16191
|
-
disposers.push(mountPanel(controller, api, terminalFont));
|
|
16238
|
+
disposers.push(mountSidebarEntry(controller, ctx.locale));
|
|
16239
|
+
disposers.push(mountPanel(controller, api, terminalFont, ctx.locale));
|
|
16192
16240
|
} catch (error) {
|
|
16193
16241
|
console.warn("[dsh-ssh] mount failed:", error);
|
|
16194
16242
|
}
|