dsh-bash-terminal-ts 0.9.2 → 0.9.4
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 +9 -0
- package/dist/client.core.js +184 -6
- package/dist/client.js +184 -6
- package/dsh.plugin.json +1 -1
- package/lib/client.js +184 -6
- package/package.json +1 -1
- package/src/client.tsx +2 -0
- package/src/webterminals/browser/star-row-copy.ts +258 -0
- package/agent-presets/standard-win-payload/agent.cordis.yml +0 -271
- package/agent-presets/standard-win-payload/preset.yml +0 -2
- package/lib/payload.d.ts +0 -72
- package/lib/payload.js +0 -279
package/lib/client.js
CHANGED
|
@@ -38,9 +38,9 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
38
38
|
));
|
|
39
39
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
40
40
|
|
|
41
|
-
// node_modules
|
|
41
|
+
// node_modules/@xterm/addon-fit/lib/addon-fit.js
|
|
42
42
|
var require_addon_fit = __commonJS({
|
|
43
|
-
"node_modules
|
|
43
|
+
"node_modules/@xterm/addon-fit/lib/addon-fit.js"(exports, module2) {
|
|
44
44
|
!(function(e, t) {
|
|
45
45
|
"object" == typeof exports && "object" == typeof module2 ? module2.exports = t() : "function" == typeof define && define.amd ? define([], t) : "object" == typeof exports ? exports.FitAddon = t() : e.FitAddon = t();
|
|
46
46
|
})(self, (() => (() => {
|
|
@@ -74,9 +74,9 @@ var require_addon_fit = __commonJS({
|
|
|
74
74
|
}
|
|
75
75
|
});
|
|
76
76
|
|
|
77
|
-
// node_modules
|
|
77
|
+
// node_modules/@xterm/xterm/lib/xterm.js
|
|
78
78
|
var require_xterm = __commonJS({
|
|
79
|
-
"node_modules
|
|
79
|
+
"node_modules/@xterm/xterm/lib/xterm.js"(exports, module2) {
|
|
80
80
|
!(function(e, t) {
|
|
81
81
|
if ("object" == typeof exports && "object" == typeof module2) module2.exports = t();
|
|
82
82
|
else if ("function" == typeof define && define.amd) define([], t);
|
|
@@ -7176,7 +7176,7 @@ var import_react2 = require("react");
|
|
|
7176
7176
|
var import_addon_fit = __toESM(require_addon_fit(), 1);
|
|
7177
7177
|
var import_xterm = __toESM(require_xterm(), 1);
|
|
7178
7178
|
|
|
7179
|
-
// node_modules
|
|
7179
|
+
// node_modules/@xterm/xterm/css/xterm.css
|
|
7180
7180
|
var xterm_default = `/**
|
|
7181
7181
|
* Copyright (c) 2014 The xterm.js authors. All rights reserved.
|
|
7182
7182
|
* Copyright (c) 2012-2013, Christopher Jeffrey (MIT License)
|
|
@@ -7742,6 +7742,181 @@ function MultiShellTerminal(props) {
|
|
|
7742
7742
|
] });
|
|
7743
7743
|
}
|
|
7744
7744
|
|
|
7745
|
+
// src/webterminals/browser/star-row-copy.ts
|
|
7746
|
+
var REPO_URL = "https://github.com/drscrewdriver/dsh-bash-terminal-ts";
|
|
7747
|
+
var STAR_NS = "bash-terminal";
|
|
7748
|
+
var STAR_VARIANT = "S";
|
|
7749
|
+
var STAR_COPY = {
|
|
7750
|
+
zh: { ask: "\u89C9\u5F97\u7701\u4E8B\u4E86\uFF1F\u4E00\u9897 Star \u8BA9\u5DE5\u5177\u88AB\u66F4\u591A\u4EBA\u770B\u89C1" },
|
|
7751
|
+
en: { ask: "Finding it handy? A star helps more people discover this tool" },
|
|
7752
|
+
ja: { ask: "\u4FBF\u5229\u3067\u3057\u305F\u3089\u2B50\u3067\u3001\u3053\u306E\u30C4\u30FC\u30EB\u304C\u3082\u3063\u3068\u5C4A\u304D\u307E\u3059" },
|
|
7753
|
+
ko: { ask: "\uC720\uC6A9\uD588\uB2E4\uBA74 \u2B50 \uD558\uB098\uB85C \uB354 \uB9CE\uC740 \uC0AC\uC6A9\uC790\uC5D0\uAC8C \uB2FF\uC2B5\uB2C8\uB2E4" },
|
|
7754
|
+
fr: { ask: "Utile ? Une \xE9toile aide cet outil \xE0 \xEAtre d\xE9couvert" },
|
|
7755
|
+
de: { ask: "N\xFCtzlich? Ein Stern hilft dem Tool, gesehen zu werden" },
|
|
7756
|
+
it: { ask: "Ti \xE8 utile? Una stella aiuta questo tool a farsi scoprire" },
|
|
7757
|
+
ru: { ask: "\u041F\u0440\u0438\u0433\u043E\u0434\u0438\u043B\u043E\u0441\u044C? \u0417\u0432\u0435\u0437\u0434\u0430 \u043F\u043E\u043C\u043E\u0436\u0435\u0442 \u0431\u043E\u043B\u044C\u0448\u0435\u043C\u0443 \u0447\u0438\u0441\u043B\u0443 \u043B\u044E\u0434\u0435\u0439 \u0443\u0437\u043D\u0430\u0442\u044C \u043E tool" },
|
|
7758
|
+
es: { ask: "\xBFTe resulta \xFAtil? Una estrella ayuda a que m\xE1s gente lo descubra" },
|
|
7759
|
+
pt: { ask: "Achou \xFAtil? Uma estrela ajuda mais pessoas a descobrir a ferramenta" }
|
|
7760
|
+
};
|
|
7761
|
+
var STAR_LANGS = ["zh", "en", "ja", "ko", "fr", "de", "it", "ru", "es", "pt"];
|
|
7762
|
+
var GITHUB_MARK_PATH = "M12 .297c-6.63 0-12 5.373-12 12 0 5.303 3.438 9.8 8.205 11.385.6.113.82-.258.82-.577 0-.285-.01-1.04-.015-2.04-3.338.724-4.042-1.61-4.042-1.61C4.422 18.07 3.633 17.7 3.633 17.7c-1.087-.744.084-.729.084-.729 1.205.084 1.838 1.236 1.838 1.236 1.07 1.835 2.809 1.305 3.495.998.108-.776.417-1.305.76-1.605-2.665-.3-5.466-1.332 -5.466-5.93 0-1.31.465-2.38 1.235-3.22-.135-.303-.54-1.523.105-3.176 0 0 1.005-.322 3.3 1.23.96-.267 1.98-.399 3-.405 1.02.006 2.04.138 3 .405 2.28-1.552 3.285-1.23 3.285-1.23.645 1.653.24 2.873.12 3.176.765.84 1.23 1.91 1.23 3.22 0 4.61-2.805 5.625-5.475 5.92.42.36.81 1.096.81 2.22 0 1.606-.015 2.896-.015 3.286 0 .315.21.69.825.57C20.565 22.092 24 17.592 24 12.297c0-6.627-5.373-12-12-12";
|
|
7763
|
+
var STYLE_ID = "dsh-star-row-style";
|
|
7764
|
+
var STYLE_CSS = [
|
|
7765
|
+
".dsh-star-row{display:flex;align-items:center;gap:7px;font-size:12px;",
|
|
7766
|
+
"line-height:1.5;color:inherit;text-decoration:none;opacity:.72;padding:3px 0;",
|
|
7767
|
+
"margin-top:6px;min-width:0;flex-wrap:wrap}",
|
|
7768
|
+
".dsh-star-row:hover{opacity:1;text-decoration:underline}",
|
|
7769
|
+
".dsh-star-row svg{width:14px;height:14px;flex:none;display:block}",
|
|
7770
|
+
".dsh-star-row .dsh-star-ask{opacity:.85;font-weight:400}"
|
|
7771
|
+
].join("");
|
|
7772
|
+
function pickLang() {
|
|
7773
|
+
const tag = typeof document !== "undefined" && document.documentElement.lang || "";
|
|
7774
|
+
const low = tag.toLowerCase();
|
|
7775
|
+
for (const cand of STAR_LANGS) {
|
|
7776
|
+
if (low.startsWith(cand)) return STAR_COPY[cand];
|
|
7777
|
+
}
|
|
7778
|
+
return STAR_COPY.en;
|
|
7779
|
+
}
|
|
7780
|
+
var STAR_VERSION = "0.9.3";
|
|
7781
|
+
var STAR_FOOT_COPY = {
|
|
7782
|
+
zh: { ask: "\u89C9\u5F97\u597D\u7528\uFF1F", star: "\u53BB GitHub \u70B9\u4E2A Star", issue: "\u53CD\u9988\u5EFA\u8BAE / \u63D0 issue" },
|
|
7783
|
+
en: { ask: "Finding it useful?", star: "Star on GitHub", issue: "Feedback / open an issue" },
|
|
7784
|
+
ja: { ask: "\u304A\u5F79\u306B\u7ACB\u3063\u3066\u3044\u307E\u3059\u304B\uFF1F", star: "GitHub \u3067\u30B9\u30BF\u30FC", issue: "\u3054\u610F\u898B\u30FB\u4E0D\u5177\u5408\u5831\u544A" },
|
|
7785
|
+
ko: { ask: "\uC720\uC6A9\uD55C\uAC00\uC694?", star: "GitHub \uC5D0\uC11C \uC2A4\uD0C0", issue: "\uD53C\uB4DC\uBC31 / \uC774\uC288 \uC5F4\uAE30" },
|
|
7786
|
+
fr: { ask: "Utile ?", star: "Une \xE9toile sur GitHub", issue: "Retour / ouvrir un ticket" },
|
|
7787
|
+
de: { ask: "Hilfreich?", star: "Stern auf GitHub", issue: "Feedback / Issue \xF6ffnen" },
|
|
7788
|
+
it: { ask: "Ti \xE8 utile?", star: "Stella su GitHub", issue: "Feedback / apri una issue" },
|
|
7789
|
+
ru: { ask: "\u041F\u043E\u043B\u0435\u0437\u043D\u043E?", star: "\u0417\u0432\u0435\u0437\u0434\u0430 \u043D\u0430 GitHub", issue: "\u041E\u0442\u0437\u044B\u0432 / \u043E\u0442\u043A\u0440\u044B\u0442\u044C issue" },
|
|
7790
|
+
es: { ask: "\xBFTe resulta \xFAtil?", star: "Danos una estrella", issue: "Sugerencias / abrir issue" },
|
|
7791
|
+
pt: { ask: "Achou \xFAtil?", star: "D\xEA uma estrela no GitHub", issue: "Feedback / abrir uma issue" }
|
|
7792
|
+
};
|
|
7793
|
+
var STAR_FOOT_STYLE_ID = "dsh-star-foot-style";
|
|
7794
|
+
var STAR_FOOT_STYLE = [
|
|
7795
|
+
".dsh-star-foot{display:flex;align-items:center;gap:6px;flex-wrap:wrap;",
|
|
7796
|
+
"font-size:12px;line-height:1.6;color:inherit;opacity:.72;margin-top:10px}",
|
|
7797
|
+
".dsh-star-foot:hover{opacity:1}",
|
|
7798
|
+
".dsh-star-foot .dsh-star-ver{opacity:.6;font-variant-numeric:tabular-nums}",
|
|
7799
|
+
".dsh-star-foot .dsh-star-dot{opacity:.4}",
|
|
7800
|
+
".dsh-star-foot a{color:inherit;text-decoration:none}",
|
|
7801
|
+
".dsh-star-foot a:hover{text-decoration:underline}"
|
|
7802
|
+
].join("");
|
|
7803
|
+
function starLang() {
|
|
7804
|
+
const tag = typeof document !== "undefined" && document.documentElement.lang || "";
|
|
7805
|
+
const low = tag.toLowerCase();
|
|
7806
|
+
for (const cand of STAR_LANGS) if (low.startsWith(cand)) return cand;
|
|
7807
|
+
return "en";
|
|
7808
|
+
}
|
|
7809
|
+
var STAR_DISMISS_KEY = "dsh.star." + STAR_NS + ".v2.dismissed";
|
|
7810
|
+
var STAR_DISMISS_KEY_V1 = "dsh.star." + STAR_NS + ".dismissed";
|
|
7811
|
+
function starDismissed() {
|
|
7812
|
+
try {
|
|
7813
|
+
if (localStorage.getItem(STAR_DISMISS_KEY_V1) !== null) {
|
|
7814
|
+
localStorage.removeItem(STAR_DISMISS_KEY_V1);
|
|
7815
|
+
}
|
|
7816
|
+
return localStorage.getItem(STAR_DISMISS_KEY) === "1";
|
|
7817
|
+
} catch {
|
|
7818
|
+
return false;
|
|
7819
|
+
}
|
|
7820
|
+
}
|
|
7821
|
+
function starDismiss() {
|
|
7822
|
+
try {
|
|
7823
|
+
localStorage.setItem(STAR_DISMISS_KEY, "1");
|
|
7824
|
+
} catch {
|
|
7825
|
+
}
|
|
7826
|
+
}
|
|
7827
|
+
function injectFootStyle(d) {
|
|
7828
|
+
if (d.getElementById(STAR_FOOT_STYLE_ID)) return;
|
|
7829
|
+
const style = d.createElement("style");
|
|
7830
|
+
style.id = STAR_FOOT_STYLE_ID;
|
|
7831
|
+
style.textContent = STAR_FOOT_STYLE;
|
|
7832
|
+
d.head.appendChild(style);
|
|
7833
|
+
}
|
|
7834
|
+
function footItem(d, tag, text, href) {
|
|
7835
|
+
const el = d.createElement(tag);
|
|
7836
|
+
el.className = "dsh-star-ask";
|
|
7837
|
+
if (tag === "a" && href) {
|
|
7838
|
+
const a = el;
|
|
7839
|
+
a.href = href;
|
|
7840
|
+
a.target = "_blank";
|
|
7841
|
+
a.rel = "noopener noreferrer";
|
|
7842
|
+
}
|
|
7843
|
+
el.textContent = text;
|
|
7844
|
+
return el;
|
|
7845
|
+
}
|
|
7846
|
+
function footDot(d) {
|
|
7847
|
+
const dot = d.createElement("span");
|
|
7848
|
+
dot.className = "dsh-star-dot";
|
|
7849
|
+
dot.textContent = "\xB7";
|
|
7850
|
+
return dot;
|
|
7851
|
+
}
|
|
7852
|
+
function extendedStarRow(neutral, d) {
|
|
7853
|
+
if (STAR_VARIANT !== "S") return null;
|
|
7854
|
+
if (starDismissed()) return null;
|
|
7855
|
+
injectFootStyle(d);
|
|
7856
|
+
const copy = STAR_FOOT_COPY[starLang()] ?? STAR_FOOT_COPY.en;
|
|
7857
|
+
const issuesUrl = REPO_URL.replace(/\/+$/, "") + "/issues/new";
|
|
7858
|
+
const row = d.createElement("div");
|
|
7859
|
+
row.className = "dsh-star-foot";
|
|
7860
|
+
const ver = d.createElement("span");
|
|
7861
|
+
ver.className = "dsh-star-ver";
|
|
7862
|
+
ver.textContent = "v" + STAR_VERSION;
|
|
7863
|
+
row.appendChild(ver);
|
|
7864
|
+
row.appendChild(footDot(d));
|
|
7865
|
+
row.appendChild(footItem(d, "span", copy.ask));
|
|
7866
|
+
const star = footItem(d, "a", "\u2B50 " + copy.star, REPO_URL);
|
|
7867
|
+
const issue = footItem(d, "a", "\u{1F4AC} " + copy.issue, issuesUrl);
|
|
7868
|
+
row.appendChild(star);
|
|
7869
|
+
row.appendChild(footDot(d));
|
|
7870
|
+
row.appendChild(issue);
|
|
7871
|
+
const collapse = () => {
|
|
7872
|
+
starDismiss();
|
|
7873
|
+
if (row.parentNode) {
|
|
7874
|
+
neutral.className = "dsh-star-row";
|
|
7875
|
+
row.parentNode.replaceChild(neutral, row);
|
|
7876
|
+
}
|
|
7877
|
+
};
|
|
7878
|
+
star.addEventListener("click", collapse);
|
|
7879
|
+
issue.addEventListener("click", collapse);
|
|
7880
|
+
return row;
|
|
7881
|
+
}
|
|
7882
|
+
function mountStarRow(doc) {
|
|
7883
|
+
const d = doc ?? document;
|
|
7884
|
+
if (!d.getElementById(STYLE_ID)) {
|
|
7885
|
+
const tag = d.createElement("style");
|
|
7886
|
+
tag.id = STYLE_ID;
|
|
7887
|
+
tag.textContent = STYLE_CSS;
|
|
7888
|
+
d.head.appendChild(tag);
|
|
7889
|
+
}
|
|
7890
|
+
const match = REPO_URL.match(/github\.com\/([^/]+\/[^/#?]+)/);
|
|
7891
|
+
const repo = match ? match[1] : "drscrewdriver";
|
|
7892
|
+
const a = d.createElement("a");
|
|
7893
|
+
a.className = "dsh-star-row";
|
|
7894
|
+
a.href = REPO_URL;
|
|
7895
|
+
a.target = "_blank";
|
|
7896
|
+
a.rel = "noreferrer";
|
|
7897
|
+
a.dataset.starNs = STAR_NS;
|
|
7898
|
+
const svg = d.createElementNS("http://www.w3.org/2000/svg", "svg");
|
|
7899
|
+
svg.setAttribute("viewBox", "0 0 24 24");
|
|
7900
|
+
svg.setAttribute("aria-hidden", "true");
|
|
7901
|
+
const path = d.createElementNS("http://www.w3.org/2000/svg", "path");
|
|
7902
|
+
path.setAttribute("fill", "currentColor");
|
|
7903
|
+
path.setAttribute("d", GITHUB_MARK_PATH);
|
|
7904
|
+
svg.appendChild(path);
|
|
7905
|
+
a.appendChild(svg);
|
|
7906
|
+
const label = d.createElement("span");
|
|
7907
|
+
label.textContent = repo;
|
|
7908
|
+
a.appendChild(label);
|
|
7909
|
+
const row = extendedStarRow(a, d);
|
|
7910
|
+
if (row) return row;
|
|
7911
|
+
if (STAR_VARIANT === "A") {
|
|
7912
|
+
const ask = d.createElement("span");
|
|
7913
|
+
ask.className = "dsh-star-ask";
|
|
7914
|
+
ask.textContent = pickLang().ask;
|
|
7915
|
+
a.appendChild(ask);
|
|
7916
|
+
}
|
|
7917
|
+
return a;
|
|
7918
|
+
}
|
|
7919
|
+
|
|
7745
7920
|
// src/client.tsx
|
|
7746
7921
|
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
7747
7922
|
var SETTINGS_NS = "settings.bash-terminal";
|
|
@@ -7995,7 +8170,10 @@ function ShellDockSection() {
|
|
|
7995
8170
|
function SettingsBody() {
|
|
7996
8171
|
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_jsx_runtime3.Fragment, { children: [
|
|
7997
8172
|
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(ShellPreferenceRow, {}),
|
|
7998
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(ShellDockSection, {})
|
|
8173
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(ShellDockSection, {}),
|
|
8174
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { ref: (node) => {
|
|
8175
|
+
if (node && !node.firstChild) node.appendChild(mountStarRow());
|
|
8176
|
+
} })
|
|
7999
8177
|
] });
|
|
8000
8178
|
}
|
|
8001
8179
|
var hostSettingsSurface = "unknown";
|
package/package.json
CHANGED
package/src/client.tsx
CHANGED
|
@@ -37,6 +37,7 @@ import { ShellPicker } from "./webterminals/browser/shell-picker";
|
|
|
37
37
|
import { switchableRows } from "./webterminals/browser/xterm";
|
|
38
38
|
import { post, readConfig, readLegacyConfig, writeDefaultShell, writeLegacyDefault } from "./webterminals/browser/api";
|
|
39
39
|
import type { CatalogEntry, ConfigSnapshot } from "./webterminals/browser/api";
|
|
40
|
+
import { mountStarRow } from './webterminals/browser/star-row-copy'
|
|
40
41
|
|
|
41
42
|
const SETTINGS_NS = "settings.bash-terminal";
|
|
42
43
|
const SHELLS = ["powershell", "gitbash", "msys2", "wsl", "niu"] as const;
|
|
@@ -468,6 +469,7 @@ function SettingsBody() {
|
|
|
468
469
|
<>
|
|
469
470
|
<ShellPreferenceRow />
|
|
470
471
|
<ShellDockSection />
|
|
472
|
+
<span ref={(node: HTMLElement | null) => { if (node && !node.firstChild) node.appendChild(mountStarRow()) }} />
|
|
471
473
|
</>
|
|
472
474
|
);
|
|
473
475
|
}
|
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* star-row 真源(面板 star 快车道行,v1)——纯 DOM 实现,零依赖。
|
|
3
|
+
*
|
|
4
|
+
* 副本约束:生成文件名 star-row-copy.ts,头部须保留 /** 块注释,单行 ≤140
|
|
5
|
+
* 字宽(sidebar-fold 仓 lint 门禁:max-line + file-header)。
|
|
6
|
+
*
|
|
7
|
+
* 契约(对齐 panel-star-row spec):
|
|
8
|
+
* - 渲染一行 <a>:GitHub 单色 SVG + `owner/name`;variant A 追加一句工程话术;
|
|
9
|
+
* - 整行即链接(A/L 档),新标签页打开;不做弹窗、不做按钮交互;
|
|
10
|
+
* - 文案内嵌 10 语,按 `document.documentElement.lang` 前缀自选
|
|
11
|
+
* (同 sidebar-fold `pickDictionary` 口径),不依赖宿主 locale 服务,
|
|
12
|
+
* 避免逐仓动字典文件;
|
|
13
|
+
* - 样式一次性注入 <style data-dsh-star-row>,色随 currentColor,深浅主题自适应;
|
|
14
|
+
* - 副本由 _tools/star-row/sync.mjs 生成到各仓 `src/client/star-row-copy.ts`
|
|
15
|
+
* (文件名含 copy,locale 守卫豁免规则命中),改副本无效,改真源后重跑 sync。
|
|
16
|
+
*
|
|
17
|
+
* 每仓生成时在文件头部烘焙 REPO_URL / STAR_NS / STAR_VARIANT 三个常量。
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
/** 生成段:REPO_URL / STAR_NS / STAR_VARIANT 由 sync 注入。 */
|
|
21
|
+
// STAR-CONSTS:BEGIN — generated by _tools/star-row/sync.mjs; edit the real source instead
|
|
22
|
+
const REPO_URL = "https://github.com/drscrewdriver/dsh-bash-terminal-ts";
|
|
23
|
+
const STAR_NS = "bash-terminal";
|
|
24
|
+
const STAR_VARIANT = "S" as "S" | "A" | "L";
|
|
25
|
+
// STAR-CONSTS:END
|
|
26
|
+
|
|
27
|
+
/** zh 为键集真理源;10 语与 sidebar-fold/manage-session 同集合。 */
|
|
28
|
+
const STAR_COPY: Record<string, { ask: string }> = {
|
|
29
|
+
zh: { ask: "觉得省事了?一颗 Star 让工具被更多人看见" },
|
|
30
|
+
en: { ask: "Finding it handy? A star helps more people discover this tool" },
|
|
31
|
+
ja: { ask: "便利でしたら⭐で、このツールがもっと届きます" },
|
|
32
|
+
ko: { ask: "유용했다면 ⭐ 하나로 더 많은 사용자에게 닿습니다" },
|
|
33
|
+
fr: { ask: "Utile ? Une étoile aide cet outil à être découvert" },
|
|
34
|
+
de: { ask: "Nützlich? Ein Stern hilft dem Tool, gesehen zu werden" },
|
|
35
|
+
it: { ask: "Ti è utile? Una stella aiuta questo tool a farsi scoprire" },
|
|
36
|
+
ru: { ask: "Пригодилось? Звезда поможет большему числу людей узнать о tool" },
|
|
37
|
+
es: { ask: "¿Te resulta útil? Una estrella ayuda a que más gente lo descubra" },
|
|
38
|
+
pt: { ask: "Achou útil? Uma estrela ajuda mais pessoas a descobrir a ferramenta" },
|
|
39
|
+
};
|
|
40
|
+
const STAR_LANGS = ["zh", "en", "ja", "ko", "fr", "de", "it", "ru", "es", "pt"];
|
|
41
|
+
|
|
42
|
+
/** GitHub mark(Simple Icons / octicon 轮廓,24 视口),fill 随 currentColor。 */
|
|
43
|
+
const GITHUB_MARK_PATH =
|
|
44
|
+
"M12 .297c-6.63 0-12 5.373-12 12 0 5.303 3.438 9.8 8.205 11.385.6.113.82-.258.82-.577" +
|
|
45
|
+
" 0-.285-.01-1.04-.015-2.04-3.338.724-4.042-1.61-4.042-1.61C4.422 18.07 3.633 17.7" +
|
|
46
|
+
" 3.633 17.7c-1.087-.744.084-.729.084-.729 1.205.084 1.838 1.236 1.838 1.236 1.07" +
|
|
47
|
+
" 1.835 2.809 1.305 3.495.998.108-.776.417-1.305.76-1.605-2.665-.3-5.466-1.332" +
|
|
48
|
+
" -5.466-5.93 0-1.31.465-2.38 1.235-3.22-.135-.303-.54-1.523.105-3.176 0 0" +
|
|
49
|
+
" 1.005-.322 3.3 1.23.96-.267 1.98-.399 3-.405 1.02.006 2.04.138 3 .405 2.28-1.552" +
|
|
50
|
+
" 3.285-1.23 3.285-1.23.645 1.653.24 2.873.12 3.176.765.84 1.23 1.91 1.23 3.22 0" +
|
|
51
|
+
" 4.61-2.805 5.625-5.475 5.92.42.36.81 1.096.81 2.22 0 1.606-.015 2.896-.015" +
|
|
52
|
+
" 3.286 0 .315.21.69.825.57C20.565 22.092 24 17.592 24 12.297c0-6.627-5.373-12-12-12";
|
|
53
|
+
|
|
54
|
+
const STYLE_ID = "dsh-star-row-style";
|
|
55
|
+
const STYLE_CSS = [
|
|
56
|
+
".dsh-star-row{display:flex;align-items:center;gap:7px;font-size:12px;",
|
|
57
|
+
"line-height:1.5;color:inherit;text-decoration:none;opacity:.72;padding:3px 0;",
|
|
58
|
+
"margin-top:6px;min-width:0;flex-wrap:wrap}",
|
|
59
|
+
".dsh-star-row:hover{opacity:1;text-decoration:underline}",
|
|
60
|
+
".dsh-star-row svg{width:14px;height:14px;flex:none;display:block}",
|
|
61
|
+
".dsh-star-row .dsh-star-ask{opacity:.85;font-weight:400}",
|
|
62
|
+
].join("");
|
|
63
|
+
|
|
64
|
+
function pickLang(): { ask: string } {
|
|
65
|
+
const tag = (typeof document !== "undefined" && document.documentElement.lang) || "";
|
|
66
|
+
const low = tag.toLowerCase();
|
|
67
|
+
for (const cand of STAR_LANGS) {
|
|
68
|
+
if (low.startsWith(cand)) return STAR_COPY[cand]!;
|
|
69
|
+
}
|
|
70
|
+
return STAR_COPY.en!;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// STAR:EXTENDED:BEGIN — S 档专用段(v2:一行页脚 = 版本 · 问句 · ⭐ star · 💬 issue)。
|
|
74
|
+
// 学产品页脚的写法:**不建按钮、不画边框、不留关闭钮**,整行只有两个 <a>。
|
|
75
|
+
// 旧 S 档(≤2.0.25)把 GitHub 链接 + 长话术 + ★ 胶囊 + × 胶囊四个元素挤在一行并压一条
|
|
76
|
+
// 顶部分割线:★ 与整行链接同义(都开仓库页)、× 是负向首因,用户先想关掉而不是点星。
|
|
77
|
+
// v2 收成截图那种一段式:版本打头(sync 从各仓 package.json 烘进来,--check 即版本哨兵),
|
|
78
|
+
// 短问句「觉得好用?」只问不讲道理,两个动作(star / 开 issue)都是纯文字链接。
|
|
79
|
+
// 关闭态:点过任一链接即自动收成中性一行(localStorage `dsh.star.<ns>.v2.dismissed=1`),
|
|
80
|
+
// 不再提供可见的 ×;旧键(≤2.0.25 把点星误写成关闭)读到即清、**不迁值**。
|
|
81
|
+
// 文案 10 语随 documentElement.lang;本段由 sync 对 A/L 副本整段剥除。
|
|
82
|
+
|
|
83
|
+
// STAR-VER:BEGIN — generated by sync.mjs from <repo>/package.json; edit the real source instead
|
|
84
|
+
const STAR_VERSION = "0.9.3";
|
|
85
|
+
// STAR-VER:END
|
|
86
|
+
|
|
87
|
+
const STAR_FOOT_COPY: Record<string, { ask: string; star: string; issue: string }> = {
|
|
88
|
+
zh: { ask: "觉得好用?", star: "去 GitHub 点个 Star", issue: "反馈建议 / 提 issue" },
|
|
89
|
+
en: { ask: "Finding it useful?", star: "Star on GitHub", issue: "Feedback / open an issue" },
|
|
90
|
+
ja: { ask: "お役に立っていますか?", star: "GitHub でスター", issue: "ご意見・不具合報告" },
|
|
91
|
+
ko: { ask: "유용한가요?", star: "GitHub 에서 스타", issue: "피드백 / 이슈 열기" },
|
|
92
|
+
fr: { ask: "Utile ?", star: "Une étoile sur GitHub", issue: "Retour / ouvrir un ticket" },
|
|
93
|
+
de: { ask: "Hilfreich?", star: "Stern auf GitHub", issue: "Feedback / Issue öffnen" },
|
|
94
|
+
it: { ask: "Ti è utile?", star: "Stella su GitHub", issue: "Feedback / apri una issue" },
|
|
95
|
+
ru: { ask: "Полезно?", star: "Звезда на GitHub", issue: "Отзыв / открыть issue" },
|
|
96
|
+
es: { ask: "¿Te resulta útil?", star: "Danos una estrella", issue: "Sugerencias / abrir issue" },
|
|
97
|
+
pt: { ask: "Achou útil?", star: "Dê uma estrela no GitHub", issue: "Feedback / abrir uma issue" },
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
const STAR_FOOT_STYLE_ID = "dsh-star-foot-style";
|
|
101
|
+
const STAR_FOOT_STYLE = [
|
|
102
|
+
".dsh-star-foot{display:flex;align-items:center;gap:6px;flex-wrap:wrap;",
|
|
103
|
+
"font-size:12px;line-height:1.6;color:inherit;opacity:.72;margin-top:10px}",
|
|
104
|
+
".dsh-star-foot:hover{opacity:1}",
|
|
105
|
+
".dsh-star-foot .dsh-star-ver{opacity:.6;font-variant-numeric:tabular-nums}",
|
|
106
|
+
".dsh-star-foot .dsh-star-dot{opacity:.4}",
|
|
107
|
+
".dsh-star-foot a{color:inherit;text-decoration:none}",
|
|
108
|
+
".dsh-star-foot a:hover{text-decoration:underline}",
|
|
109
|
+
].join("");
|
|
110
|
+
|
|
111
|
+
/** 宿主语言标签归一:取 `documentElement.lang` 的前缀,命中 STAR_LANGS 即用。 */
|
|
112
|
+
function starLang(): string {
|
|
113
|
+
const tag = (typeof document !== "undefined" && document.documentElement.lang) || "";
|
|
114
|
+
const low = tag.toLowerCase();
|
|
115
|
+
for (const cand of STAR_LANGS) if (low.startsWith(cand)) return cand;
|
|
116
|
+
return "en";
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/** 关闭态新键(v2)。**必须换键**:≤2.0.25 把「点 ★」误写成了关闭,旧键里的 1 是误判产物。 */
|
|
120
|
+
const STAR_DISMISS_KEY = "dsh.star." + STAR_NS + ".v2.dismissed";
|
|
121
|
+
/** 旧键(脏数据源):读到即清掉,**不迁值**——迁过来等于把旧 bug 固化。 */
|
|
122
|
+
const STAR_DISMISS_KEY_V1 = "dsh.star." + STAR_NS + ".dismissed";
|
|
123
|
+
|
|
124
|
+
/** 是否已被用户点掉话术(隐私模式下读失败按未关闭处理,只影响本次会话)。 */
|
|
125
|
+
function starDismissed(): boolean {
|
|
126
|
+
try {
|
|
127
|
+
// 一次性清旧键:旧版点 ★ 就写 1,凡中招的用户会被它永久按成裸链接。
|
|
128
|
+
if (localStorage.getItem(STAR_DISMISS_KEY_V1) !== null) {
|
|
129
|
+
localStorage.removeItem(STAR_DISMISS_KEY_V1);
|
|
130
|
+
}
|
|
131
|
+
return localStorage.getItem(STAR_DISMISS_KEY) === "1";
|
|
132
|
+
} catch {
|
|
133
|
+
return false;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/** 记住关闭态(隐私模式写失败不报错,话术本次隐藏、刷新复活)。 */
|
|
138
|
+
function starDismiss(): void {
|
|
139
|
+
try {
|
|
140
|
+
localStorage.setItem(STAR_DISMISS_KEY, "1");
|
|
141
|
+
} catch {
|
|
142
|
+
/* noop */
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/** 一次性注入页脚样式。 */
|
|
147
|
+
function injectFootStyle(d: Document): void {
|
|
148
|
+
if (d.getElementById(STAR_FOOT_STYLE_ID)) return;
|
|
149
|
+
const style = d.createElement("style");
|
|
150
|
+
style.id = STAR_FOOT_STYLE_ID;
|
|
151
|
+
style.textContent = STAR_FOOT_STYLE;
|
|
152
|
+
d.head.appendChild(style);
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
/** 页脚里的一段:可点即 <a>,纯文字即 <span>。 */
|
|
156
|
+
function footItem(d: Document, tag: "a" | "span", text: string, href?: string): HTMLElement {
|
|
157
|
+
const el = d.createElement(tag);
|
|
158
|
+
el.className = "dsh-star-ask";
|
|
159
|
+
if (tag === "a" && href) {
|
|
160
|
+
const a = el as HTMLAnchorElement;
|
|
161
|
+
a.href = href;
|
|
162
|
+
a.target = "_blank";
|
|
163
|
+
a.rel = "noopener noreferrer";
|
|
164
|
+
}
|
|
165
|
+
el.textContent = text;
|
|
166
|
+
return el;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
/** 分隔点。 */
|
|
170
|
+
function footDot(d: Document): HTMLElement {
|
|
171
|
+
const dot = d.createElement("span");
|
|
172
|
+
dot.className = "dsh-star-dot";
|
|
173
|
+
dot.textContent = "·";
|
|
174
|
+
return dot;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
/**
|
|
178
|
+
* S 档:一行页脚;非 S 档或已关掉过话术时返回 null(走裸链接原路径)。
|
|
179
|
+
* 点过任一链接 → 记关闭 + 换回中性一行,链接本身照常跳转(不 preventDefault)。
|
|
180
|
+
*/
|
|
181
|
+
function extendedStarRow(neutral: HTMLAnchorElement, d: Document): HTMLElement | null {
|
|
182
|
+
if (STAR_VARIANT !== "S") return null;
|
|
183
|
+
if (starDismissed()) return null;
|
|
184
|
+
injectFootStyle(d);
|
|
185
|
+
const copy = STAR_FOOT_COPY[starLang()] ?? STAR_FOOT_COPY.en!;
|
|
186
|
+
const issuesUrl = REPO_URL.replace(/\/+$/, "") + "/issues/new";
|
|
187
|
+
const row = d.createElement("div");
|
|
188
|
+
row.className = "dsh-star-foot";
|
|
189
|
+
|
|
190
|
+
const ver = d.createElement("span");
|
|
191
|
+
ver.className = "dsh-star-ver";
|
|
192
|
+
ver.textContent = "v" + STAR_VERSION;
|
|
193
|
+
row.appendChild(ver);
|
|
194
|
+
row.appendChild(footDot(d));
|
|
195
|
+
row.appendChild(footItem(d, "span", copy.ask));
|
|
196
|
+
const star = footItem(d, "a", "⭐ " + copy.star, REPO_URL);
|
|
197
|
+
const issue = footItem(d, "a", "💬 " + copy.issue, issuesUrl);
|
|
198
|
+
row.appendChild(star);
|
|
199
|
+
row.appendChild(footDot(d));
|
|
200
|
+
row.appendChild(issue);
|
|
201
|
+
|
|
202
|
+
// 点过就收敛:话术只打扰一次,链接段以后一直留着(和 v1 的 dismissed 语义一致)。
|
|
203
|
+
const collapse = (): void => {
|
|
204
|
+
starDismiss();
|
|
205
|
+
if (row.parentNode) {
|
|
206
|
+
neutral.className = "dsh-star-row";
|
|
207
|
+
row.parentNode.replaceChild(neutral, row);
|
|
208
|
+
}
|
|
209
|
+
};
|
|
210
|
+
star.addEventListener("click", collapse);
|
|
211
|
+
issue.addEventListener("click", collapse);
|
|
212
|
+
return row;
|
|
213
|
+
}
|
|
214
|
+
// STAR:EXTENDED:END
|
|
215
|
+
/** 在目标文档上建出快车道行(一次性注入样式)。纯 DOM,React 仓经 ref 回调挂载。 */
|
|
216
|
+
export function mountStarRow(doc?: Document): HTMLElement {
|
|
217
|
+
const d = doc ?? document;
|
|
218
|
+
if (!d.getElementById(STYLE_ID)) {
|
|
219
|
+
const tag = d.createElement("style");
|
|
220
|
+
tag.id = STYLE_ID;
|
|
221
|
+
tag.textContent = STYLE_CSS;
|
|
222
|
+
d.head.appendChild(tag);
|
|
223
|
+
}
|
|
224
|
+
const match = REPO_URL.match(/github\.com\/([^/]+\/[^/#?]+)/);
|
|
225
|
+
const repo = match ? match[1]! : "drscrewdriver";
|
|
226
|
+
const a = d.createElement("a");
|
|
227
|
+
a.className = "dsh-star-row";
|
|
228
|
+
a.href = REPO_URL;
|
|
229
|
+
a.target = "_blank";
|
|
230
|
+
a.rel = "noreferrer";
|
|
231
|
+
a.dataset.starNs = STAR_NS;
|
|
232
|
+
|
|
233
|
+
const svg = d.createElementNS("http://www.w3.org/2000/svg", "svg");
|
|
234
|
+
svg.setAttribute("viewBox", "0 0 24 24");
|
|
235
|
+
svg.setAttribute("aria-hidden", "true");
|
|
236
|
+
const path = d.createElementNS("http://www.w3.org/2000/svg", "path");
|
|
237
|
+
path.setAttribute("fill", "currentColor");
|
|
238
|
+
path.setAttribute("d", GITHUB_MARK_PATH);
|
|
239
|
+
svg.appendChild(path);
|
|
240
|
+
a.appendChild(svg);
|
|
241
|
+
|
|
242
|
+
const label = d.createElement("span");
|
|
243
|
+
label.textContent = repo;
|
|
244
|
+
a.appendChild(label);
|
|
245
|
+
// STAR:EXTENDED:BEGIN — S 档在此接管(A/L 副本由 sync 剥除本段)
|
|
246
|
+
const row = extendedStarRow(a, d);
|
|
247
|
+
if (row) return row;
|
|
248
|
+
// STAR:EXTENDED:END
|
|
249
|
+
|
|
250
|
+
if (STAR_VARIANT === "A") {
|
|
251
|
+
const ask = d.createElement("span");
|
|
252
|
+
ask.className = "dsh-star-ask";
|
|
253
|
+
ask.textContent = pickLang().ask;
|
|
254
|
+
a.appendChild(ask);
|
|
255
|
+
}
|
|
256
|
+
// L 档:仅中性仓库链接,无话术。S 档细条在后续批次扩展。
|
|
257
|
+
return a;
|
|
258
|
+
}
|