dsh-union-search 0.19.1 → 0.19.2-rc.2
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 +234 -1
- package/package.json +1 -1
package/lib/client.js
CHANGED
|
@@ -36,6 +36,232 @@ let react = require("react");
|
|
|
36
36
|
react_jsx_runtime = __toESM(react_jsx_runtime, 1);
|
|
37
37
|
react = __toESM(react, 1);
|
|
38
38
|
|
|
39
|
+
// src/client/star-row-copy.ts
|
|
40
|
+
/**
|
|
41
|
+
* star-row 真源(面板 star 快车道行,v1)——纯 DOM 实现,零依赖。
|
|
42
|
+
*
|
|
43
|
+
* 副本约束:生成文件名 star-row-copy.ts,头部须保留 /** 块注释,单行 ≤140
|
|
44
|
+
* 字宽(sidebar-fold 仓 lint 门禁:max-line + file-header)。
|
|
45
|
+
*
|
|
46
|
+
* 契约(对齐 panel-star-row spec):
|
|
47
|
+
* - 渲染一行 <a>:GitHub 单色 SVG + `owner/name`;variant A 追加一句工程话术;
|
|
48
|
+
* - 整行即链接(A/L 档),新标签页打开;不做弹窗、不做按钮交互;
|
|
49
|
+
* - 文案内嵌 10 语,按 `document.documentElement.lang` 前缀自选
|
|
50
|
+
* (同 sidebar-fold `pickDictionary` 口径),不依赖宿主 locale 服务,
|
|
51
|
+
* 避免逐仓动字典文件;
|
|
52
|
+
* - 样式一次性注入 <style data-dsh-star-row>,色随 currentColor,深浅主题自适应;
|
|
53
|
+
* - 副本由 _tools/star-row/sync.mjs 生成到各仓 `src/client/star-row-copy.ts`
|
|
54
|
+
* (文件名含 copy,locale 守卫豁免规则命中),改副本无效,改真源后重跑 sync。
|
|
55
|
+
*
|
|
56
|
+
* 每仓生成时在文件头部烘焙 REPO_URL / STAR_NS / STAR_VARIANT 三个常量。
|
|
57
|
+
*/
|
|
58
|
+
/** 生成段:REPO_URL / STAR_NS / STAR_VARIANT 由 sync 注入。 */
|
|
59
|
+
const REPO_URL = "https://github.com/drscrewdriver/dsh-union-search";
|
|
60
|
+
const STAR_NS = "union-search";
|
|
61
|
+
const STAR_LANGS = [
|
|
62
|
+
"zh",
|
|
63
|
+
"en",
|
|
64
|
+
"ja",
|
|
65
|
+
"ko",
|
|
66
|
+
"fr",
|
|
67
|
+
"de",
|
|
68
|
+
"it",
|
|
69
|
+
"ru",
|
|
70
|
+
"es",
|
|
71
|
+
"pt"
|
|
72
|
+
];
|
|
73
|
+
/** GitHub mark(Simple Icons / octicon 轮廓,24 视口),fill 随 currentColor。 */
|
|
74
|
+
const 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";
|
|
75
|
+
const STYLE_ID = "dsh-star-row-style";
|
|
76
|
+
const STYLE_CSS = [
|
|
77
|
+
".dsh-star-row{display:flex;align-items:center;gap:7px;font-size:12px;",
|
|
78
|
+
"line-height:1.5;color:inherit;text-decoration:none;opacity:.72;padding:3px 0;",
|
|
79
|
+
"margin-top:6px;min-width:0;flex-wrap:wrap}",
|
|
80
|
+
".dsh-star-row:hover{opacity:1;text-decoration:underline}",
|
|
81
|
+
".dsh-star-row svg{width:14px;height:14px;flex:none;display:block}",
|
|
82
|
+
".dsh-star-row .dsh-star-ask{opacity:.85;font-weight:400}"
|
|
83
|
+
].join("");
|
|
84
|
+
const STAR_FOOT_COPY = {
|
|
85
|
+
zh: {
|
|
86
|
+
ask: "觉得好用?",
|
|
87
|
+
star: "去 GitHub 点个 Star",
|
|
88
|
+
issue: "反馈建议 / 提 issue"
|
|
89
|
+
},
|
|
90
|
+
en: {
|
|
91
|
+
ask: "Finding it useful?",
|
|
92
|
+
star: "Star on GitHub",
|
|
93
|
+
issue: "Feedback / open an issue"
|
|
94
|
+
},
|
|
95
|
+
ja: {
|
|
96
|
+
ask: "お役に立っていますか?",
|
|
97
|
+
star: "GitHub でスター",
|
|
98
|
+
issue: "ご意見・不具合報告"
|
|
99
|
+
},
|
|
100
|
+
ko: {
|
|
101
|
+
ask: "유용한가요?",
|
|
102
|
+
star: "GitHub 에서 스타",
|
|
103
|
+
issue: "피드백 / 이슈 열기"
|
|
104
|
+
},
|
|
105
|
+
fr: {
|
|
106
|
+
ask: "Utile ?",
|
|
107
|
+
star: "Une étoile sur GitHub",
|
|
108
|
+
issue: "Retour / ouvrir un ticket"
|
|
109
|
+
},
|
|
110
|
+
de: {
|
|
111
|
+
ask: "Hilfreich?",
|
|
112
|
+
star: "Stern auf GitHub",
|
|
113
|
+
issue: "Feedback / Issue öffnen"
|
|
114
|
+
},
|
|
115
|
+
it: {
|
|
116
|
+
ask: "Ti è utile?",
|
|
117
|
+
star: "Stella su GitHub",
|
|
118
|
+
issue: "Feedback / apri una issue"
|
|
119
|
+
},
|
|
120
|
+
ru: {
|
|
121
|
+
ask: "Полезно?",
|
|
122
|
+
star: "Звезда на GitHub",
|
|
123
|
+
issue: "Отзыв / открыть issue"
|
|
124
|
+
},
|
|
125
|
+
es: {
|
|
126
|
+
ask: "¿Te resulta útil?",
|
|
127
|
+
star: "Danos una estrella",
|
|
128
|
+
issue: "Sugerencias / abrir issue"
|
|
129
|
+
},
|
|
130
|
+
pt: {
|
|
131
|
+
ask: "Achou útil?",
|
|
132
|
+
star: "Dê uma estrela no GitHub",
|
|
133
|
+
issue: "Feedback / abrir uma issue"
|
|
134
|
+
}
|
|
135
|
+
};
|
|
136
|
+
const STAR_FOOT_STYLE_ID = "dsh-star-foot-style";
|
|
137
|
+
const STAR_FOOT_STYLE = [
|
|
138
|
+
".dsh-star-foot{display:flex;align-items:center;gap:6px;flex-wrap:wrap;",
|
|
139
|
+
"font-size:12px;line-height:1.6;color:inherit;opacity:.72;margin-top:10px}",
|
|
140
|
+
".dsh-star-foot:hover{opacity:1}",
|
|
141
|
+
".dsh-star-foot .dsh-star-ver{opacity:.6;font-variant-numeric:tabular-nums}",
|
|
142
|
+
".dsh-star-foot .dsh-star-dot{opacity:.4}",
|
|
143
|
+
".dsh-star-foot a{color:inherit;text-decoration:none}",
|
|
144
|
+
".dsh-star-foot a:hover{text-decoration:underline}"
|
|
145
|
+
].join("");
|
|
146
|
+
/** 宿主语言标签归一:取 `documentElement.lang` 的前缀,命中 STAR_LANGS 即用。 */
|
|
147
|
+
function starLang() {
|
|
148
|
+
const low = (typeof document !== "undefined" && document.documentElement.lang || "").toLowerCase();
|
|
149
|
+
for (const cand of STAR_LANGS) if (low.startsWith(cand)) return cand;
|
|
150
|
+
return "en";
|
|
151
|
+
}
|
|
152
|
+
/** 关闭态新键(v2)。**必须换键**:≤2.0.25 把「点 ★」误写成了关闭,旧键里的 1 是误判产物。 */
|
|
153
|
+
const STAR_DISMISS_KEY = "dsh.star." + STAR_NS + ".v2.dismissed";
|
|
154
|
+
/** 旧键(脏数据源):读到即清掉,**不迁值**——迁过来等于把旧 bug 固化。 */
|
|
155
|
+
const STAR_DISMISS_KEY_V1 = "dsh.star." + STAR_NS + ".dismissed";
|
|
156
|
+
/** 是否已被用户点掉话术(隐私模式下读失败按未关闭处理,只影响本次会话)。 */
|
|
157
|
+
function starDismissed() {
|
|
158
|
+
try {
|
|
159
|
+
if (localStorage.getItem(STAR_DISMISS_KEY_V1) !== null) localStorage.removeItem(STAR_DISMISS_KEY_V1);
|
|
160
|
+
return localStorage.getItem(STAR_DISMISS_KEY) === "1";
|
|
161
|
+
} catch {
|
|
162
|
+
return false;
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
/** 记住关闭态(隐私模式写失败不报错,话术本次隐藏、刷新复活)。 */
|
|
166
|
+
function starDismiss() {
|
|
167
|
+
try {
|
|
168
|
+
localStorage.setItem(STAR_DISMISS_KEY, "1");
|
|
169
|
+
} catch {}
|
|
170
|
+
}
|
|
171
|
+
/** 一次性注入页脚样式。 */
|
|
172
|
+
function injectFootStyle(d) {
|
|
173
|
+
if (d.getElementById(STAR_FOOT_STYLE_ID)) return;
|
|
174
|
+
const style = d.createElement("style");
|
|
175
|
+
style.id = STAR_FOOT_STYLE_ID;
|
|
176
|
+
style.textContent = STAR_FOOT_STYLE;
|
|
177
|
+
d.head.appendChild(style);
|
|
178
|
+
}
|
|
179
|
+
/** 页脚里的一段:可点即 <a>,纯文字即 <span>。 */
|
|
180
|
+
function footItem(d, tag, text, href) {
|
|
181
|
+
const el = d.createElement(tag);
|
|
182
|
+
el.className = "dsh-star-ask";
|
|
183
|
+
if (tag === "a" && href) {
|
|
184
|
+
const a = el;
|
|
185
|
+
a.href = href;
|
|
186
|
+
a.target = "_blank";
|
|
187
|
+
a.rel = "noopener noreferrer";
|
|
188
|
+
}
|
|
189
|
+
el.textContent = text;
|
|
190
|
+
return el;
|
|
191
|
+
}
|
|
192
|
+
/** 分隔点。 */
|
|
193
|
+
function footDot(d) {
|
|
194
|
+
const dot = d.createElement("span");
|
|
195
|
+
dot.className = "dsh-star-dot";
|
|
196
|
+
dot.textContent = "·";
|
|
197
|
+
return dot;
|
|
198
|
+
}
|
|
199
|
+
/**
|
|
200
|
+
* S 档:一行页脚;非 S 档或已关掉过话术时返回 null(走裸链接原路径)。
|
|
201
|
+
* 点过任一链接 → 记关闭 + 换回中性一行,链接本身照常跳转(不 preventDefault)。
|
|
202
|
+
*/
|
|
203
|
+
function extendedStarRow(neutral, d) {
|
|
204
|
+
if (starDismissed()) return null;
|
|
205
|
+
injectFootStyle(d);
|
|
206
|
+
const copy = STAR_FOOT_COPY[starLang()] ?? STAR_FOOT_COPY.en;
|
|
207
|
+
const issuesUrl = REPO_URL.replace(/\/+$/, "") + "/issues/new";
|
|
208
|
+
const row = d.createElement("div");
|
|
209
|
+
row.className = "dsh-star-foot";
|
|
210
|
+
const ver = d.createElement("span");
|
|
211
|
+
ver.className = "dsh-star-ver";
|
|
212
|
+
ver.textContent = "v0.19.2-rc.2";
|
|
213
|
+
row.appendChild(ver);
|
|
214
|
+
row.appendChild(footDot(d));
|
|
215
|
+
row.appendChild(footItem(d, "span", copy.ask));
|
|
216
|
+
const star = footItem(d, "a", "⭐ " + copy.star, REPO_URL);
|
|
217
|
+
const issue = footItem(d, "a", "💬 " + copy.issue, issuesUrl);
|
|
218
|
+
row.appendChild(star);
|
|
219
|
+
row.appendChild(footDot(d));
|
|
220
|
+
row.appendChild(issue);
|
|
221
|
+
const collapse = () => {
|
|
222
|
+
starDismiss();
|
|
223
|
+
if (row.parentNode) {
|
|
224
|
+
neutral.className = "dsh-star-row";
|
|
225
|
+
row.parentNode.replaceChild(neutral, row);
|
|
226
|
+
}
|
|
227
|
+
};
|
|
228
|
+
star.addEventListener("click", collapse);
|
|
229
|
+
issue.addEventListener("click", collapse);
|
|
230
|
+
return row;
|
|
231
|
+
}
|
|
232
|
+
/** 在目标文档上建出快车道行(一次性注入样式)。纯 DOM,React 仓经 ref 回调挂载。 */
|
|
233
|
+
function mountStarRow(doc) {
|
|
234
|
+
const d = doc ?? document;
|
|
235
|
+
if (!d.getElementById(STYLE_ID)) {
|
|
236
|
+
const tag = d.createElement("style");
|
|
237
|
+
tag.id = STYLE_ID;
|
|
238
|
+
tag.textContent = STYLE_CSS;
|
|
239
|
+
d.head.appendChild(tag);
|
|
240
|
+
}
|
|
241
|
+
const match = REPO_URL.match(/github\.com\/([^/]+\/[^/#?]+)/);
|
|
242
|
+
const repo = match ? match[1] : "drscrewdriver";
|
|
243
|
+
const a = d.createElement("a");
|
|
244
|
+
a.className = "dsh-star-row";
|
|
245
|
+
a.href = REPO_URL;
|
|
246
|
+
a.target = "_blank";
|
|
247
|
+
a.rel = "noreferrer";
|
|
248
|
+
a.dataset.starNs = STAR_NS;
|
|
249
|
+
const svg = d.createElementNS("http://www.w3.org/2000/svg", "svg");
|
|
250
|
+
svg.setAttribute("viewBox", "0 0 24 24");
|
|
251
|
+
svg.setAttribute("aria-hidden", "true");
|
|
252
|
+
const path = d.createElementNS("http://www.w3.org/2000/svg", "path");
|
|
253
|
+
path.setAttribute("fill", "currentColor");
|
|
254
|
+
path.setAttribute("d", GITHUB_MARK_PATH);
|
|
255
|
+
svg.appendChild(path);
|
|
256
|
+
a.appendChild(svg);
|
|
257
|
+
const label = d.createElement("span");
|
|
258
|
+
label.textContent = repo;
|
|
259
|
+
a.appendChild(label);
|
|
260
|
+
const row = extendedStarRow(a, d);
|
|
261
|
+
if (row) return row;
|
|
262
|
+
return a;
|
|
263
|
+
}
|
|
264
|
+
|
|
39
265
|
// src/client/ui.ts
|
|
40
266
|
const BRIDGE_PREFIX = "/api/dsh-union-search-settings";
|
|
41
267
|
const NS = "web-search-free";
|
|
@@ -3159,7 +3385,14 @@ function UnionSearchCard(props) {
|
|
|
3159
3385
|
}, "suggest-apply")
|
|
3160
3386
|
]
|
|
3161
3387
|
}, "test-all-suggest") : null]
|
|
3162
|
-
}, "test-all-results") : null
|
|
3388
|
+
}, "test-all-results") : null,
|
|
3389
|
+
react_jsx_runtime.jsx("div", {
|
|
3390
|
+
key: "star-row",
|
|
3391
|
+
style: { width: "100%" },
|
|
3392
|
+
ref: (n) => {
|
|
3393
|
+
if (n && !n.firstChild) n.appendChild(mountStarRow());
|
|
3394
|
+
}
|
|
3395
|
+
})
|
|
3163
3396
|
]
|
|
3164
3397
|
})]
|
|
3165
3398
|
})
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-union-search",
|
|
3
|
-
"version": "0.19.
|
|
3
|
+
"version": "0.19.2-rc.2",
|
|
4
4
|
"description": "Union web search for DeepSeek Harness (renamed from dsh-free-search): free keyless engines + many professional paid search APIs — 28 engines (Bing/DuckDuckGo/AnySearch/SearXNG multi-instance union/Exa/Tavily/Keenable/Firecrawl/Parallel keyless; Zhihu global/site via MCP and Perplexity/SerpBase/Serply/DeepSeek official/You.com/Baidu/Kimi/Aliyun/Doubao/Zhipu/Bocha/Metaso with key; OpenAI/Gemini/Claude/Grok model built-in search, explicit-only) + auto smart routing + global engine enable/disable & fallback priority + multi mode (parallel top-3 merge) + multi_search cross-source tool + failure-aware fallback + block system built-in search toggle + experimental free advance_fetch (no API key, no billing; host-twin GitHub-Flavored Markdown conversion + CSS selector/fields structured extraction) + time filtering + platform search + web_fetch, with web settings UI.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "lib/index.js",
|