dsh-cookie-cleaner 0.7.1 → 0.7.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/cordis.patch.yml CHANGED
@@ -1,5 +1,5 @@
1
- # Official bundle layer. `dsh plugin add` applies this into the profile.
2
- # Rows resolve by package name so the installed copy is what boots.
3
- - insert:
4
- - id: cookie-cleaner
5
- name: "dsh-cookie-cleaner"
1
+ # Official bundle layer. `dsh plugin add` applies this into the profile.
2
+ # Rows resolve by package name so the installed copy is what boots.
3
+ - insert:
4
+ - id: cookie-cleaner
5
+ name: "dsh-cookie-cleaner"
package/dsh.plugin.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "id": "dsh-cookie-cleaner",
3
- "version": "0.7.1",
3
+ "version": "0.7.2",
4
4
  "main": "./src/index.js",
5
5
  "description": "Cookie 清理器:解决桌面客户端启动报 `desktop welcome: Web authentication failed`(HTTP 431,随机端口致 dsh-auth-* cookie 堆积溢出请求头上限)的现象。只读播报 cookie 库里残留的本地登录凭据(dsh-auth-*,含请求头占用水位与距 431 阈值余量),随包分发「客户端完全退出后」可执行的清理命令(独占写锁 + .bak 备份,账号凭据/会话/插件配置不受影响);设置面可体检 profile 的 cordis.patch.yml 并一键修复 `connection.cookieMaxAgeDays`(cookie 有效期,可回滚)。",
6
6
  "engines": {
package/lib/client.js CHANGED
@@ -222,6 +222,215 @@ window.__ModuleLoader__.load({
222
222
  if (reply.value === void 0) throw new Error("empty reply value");
223
223
  return reply.value;
224
224
  }
225
+ // src/client/star-row-copy.ts
226
+ /**
227
+ * star-row 真源(面板 star 快车道行,v1)——纯 DOM 实现,零依赖。
228
+ *
229
+ * 副本约束:生成文件名 star-row-copy.ts,头部须保留 /** 块注释,单行 ≤140
230
+ * 字宽(sidebar-fold 仓 lint 门禁:max-line + file-header)。
231
+ *
232
+ * 契约(对齐 panel-star-row spec):
233
+ * - 渲染一行 <a>:GitHub 单色 SVG + `owner/name`;variant A 追加一句工程话术;
234
+ * - 整行即链接(A/L 档),新标签页打开;不做弹窗、不做按钮交互;
235
+ * - 文案内嵌 10 语,按 `document.documentElement.lang` 前缀自选
236
+ * (同 sidebar-fold `pickDictionary` 口径),不依赖宿主 locale 服务,
237
+ * 避免逐仓动字典文件;
238
+ * - 样式一次性注入 <style data-dsh-star-row>,色随 currentColor,深浅主题自适应;
239
+ * - 副本由 _tools/star-row/sync.mjs 生成到各仓 `src/client/star-row-copy.ts`
240
+ * (文件名含 copy,locale 守卫豁免规则命中),改副本无效,改真源后重跑 sync。
241
+ *
242
+ * 每仓生成时在文件头部烘焙 REPO_URL / STAR_NS / STAR_VARIANT 三个常量。
243
+ */
244
+ /** 生成段:REPO_URL / STAR_NS / STAR_VARIANT 由 sync 注入。 */
245
+ const REPO_URL = "https://github.com/drscrewdriver/dsh-cookie-cleaner";
246
+ const STAR_NS = "cookie-cleaner";
247
+ /** zh 为键集真理源;10 语与 sidebar-fold/manage-session 同集合。 */
248
+ const STAR_COPY = {
249
+ zh: { ask: "觉得省事了?一颗 Star 让工具被更多人看见" },
250
+ en: { ask: "Finding it handy? A star helps more people discover this tool" },
251
+ ja: { ask: "便利でしたら⭐で、このツールがもっと届きます" },
252
+ ko: { ask: "유용했다면 ⭐ 하나로 더 많은 사용자에게 닿습니다" },
253
+ fr: { ask: "Utile ? Une étoile aide cet outil à être découvert" },
254
+ de: { ask: "Nützlich? Ein Stern hilft dem Tool, gesehen zu werden" },
255
+ it: { ask: "Ti è utile? Una stella aiuta questo tool a farsi scoprire" },
256
+ ru: { ask: "Пригодилось? Звезда поможет большему числу людей узнать о tool" },
257
+ es: { ask: "¿Te resulta útil? Una estrella ayuda a que más gente lo descubra" },
258
+ pt: { ask: "Achou útil? Uma estrela ajuda mais pessoas a descobrir a ferramenta" }
259
+ };
260
+ const STAR_LANGS = [
261
+ "zh",
262
+ "en",
263
+ "ja",
264
+ "ko",
265
+ "fr",
266
+ "de",
267
+ "it",
268
+ "ru",
269
+ "es",
270
+ "pt"
271
+ ];
272
+ /** GitHub mark(Simple Icons / octicon 轮廓,24 视口),fill 随 currentColor。 */
273
+ 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";
274
+ const STYLE_ID = "dsh-star-row-style";
275
+ const STYLE_CSS = [
276
+ ".dsh-star-row{display:flex;align-items:center;gap:7px;font-size:12px;",
277
+ "line-height:1.5;color:inherit;text-decoration:none;opacity:.72;padding:3px 0;",
278
+ "margin-top:6px;min-width:0;flex-wrap:wrap}",
279
+ ".dsh-star-row:hover{opacity:1;text-decoration:underline}",
280
+ ".dsh-star-row svg{width:14px;height:14px;flex:none;display:block}",
281
+ ".dsh-star-row .dsh-star-ask{opacity:.85;font-weight:400}"
282
+ ].join("");
283
+ const STAR_CTA = {
284
+ zh: "留颗 Star",
285
+ en: "Star",
286
+ ja: "スター",
287
+ ko: "스타",
288
+ fr: "Star",
289
+ de: "Stern",
290
+ it: "Stella",
291
+ ru: "Звезда",
292
+ es: "Estrella",
293
+ pt: "Estrela"
294
+ };
295
+ /** 隐藏钮的可读名(★ 之外的独立动作,10 语同集)。 */
296
+ const STAR_HIDE = {
297
+ zh: "不再提示",
298
+ en: "Dismiss",
299
+ ja: "今後表示しない",
300
+ ko: "다시 보지 않기",
301
+ fr: "Masquer",
302
+ de: "Ausblenden",
303
+ it: "Nascondi",
304
+ ru: "Скрыть",
305
+ es: "Ocultar",
306
+ pt: "Ocultar"
307
+ };
308
+ const STAR_S_STYLE_ID = "dsh-star-row-s-style";
309
+ const STAR_S_STYLE = [
310
+ ".dsh-star-row-s{display:flex;align-items:center;gap:8px;flex-wrap:wrap;",
311
+ "font-size:12px;line-height:1.5;color:inherit;opacity:.75;margin-top:10px;",
312
+ "padding-top:8px;border-top:1px solid var(--dsw-alias-border-l2,currentColor)}",
313
+ ".dsh-star-row-s:hover{opacity:1}",
314
+ ".dsh-star-link{display:inline-flex;align-items:center;gap:6px;",
315
+ "color:inherit;text-decoration:none}",
316
+ ".dsh-star-link:hover{text-decoration:underline}",
317
+ ".dsh-star-link svg{width:14px;height:14px;flex:none;display:block}",
318
+ ".dsh-star-row-s .dsh-star-ask{opacity:.85;font-weight:400}",
319
+ ".dsh-star-cta,.dsh-star-hide{font:inherit;font-size:11px;line-height:1;",
320
+ "padding:4px 9px;border-radius:999px;border:1px solid currentColor;",
321
+ "background:transparent;color:inherit;cursor:pointer;flex:none;opacity:.7}",
322
+ ".dsh-star-hide{padding:4px 7px}",
323
+ ".dsh-star-cta:hover,.dsh-star-hide:hover{opacity:1}"
324
+ ].join("");
325
+ /** 宿主语言标签归一:取 `documentElement.lang` 的前缀,命中 STAR_LANGS 即用。 */
326
+ function starLang() {
327
+ const low = (typeof document !== "undefined" && document.documentElement.lang || "").toLowerCase();
328
+ for (const cand of STAR_LANGS) if (low.startsWith(cand)) return cand;
329
+ return "en";
330
+ }
331
+ /** 是否已被用户点掉话术(隐私模式下读失败按未关闭处理,只影响本次会话)。 */
332
+ function starDismissed() {
333
+ try {
334
+ return localStorage.getItem("dsh.star." + STAR_NS + ".dismissed") === "1";
335
+ } catch {
336
+ return false;
337
+ }
338
+ }
339
+ /** 记住关闭态(隐私模式写失败不报错,话术本次隐藏、刷新复活)。 */
340
+ function starDismiss() {
341
+ try {
342
+ localStorage.setItem("dsh.star." + STAR_NS + ".dismissed", "1");
343
+ } catch {}
344
+ }
345
+ /** 一次性注入 S 档样式。 */
346
+ function injectStarSStyle(d) {
347
+ if (d.getElementById(STAR_S_STYLE_ID)) return;
348
+ const style = d.createElement("style");
349
+ style.id = STAR_S_STYLE_ID;
350
+ style.textContent = STAR_S_STYLE;
351
+ d.head.appendChild(style);
352
+ }
353
+ /** 打开仓库页:桌面壳里 window.open 可能被拦,锚点 click 才是两条路径都通的写法。 */
354
+ function openRepo(d) {
355
+ const a = d.createElement("a");
356
+ a.href = REPO_URL;
357
+ a.target = "_blank";
358
+ a.rel = "noopener noreferrer";
359
+ a.click();
360
+ }
361
+ /** S 档扩充:把裸链接行升级成「链接 | 话术 | ★ CTA | × 隐藏」,非 S 档返回 null 走原路径。 */
362
+ function extendedStarRow(link, d) {
363
+ if (starDismissed()) return link;
364
+ injectStarSStyle(d);
365
+ link.className = "dsh-star-link";
366
+ const lang = starLang();
367
+ const row = d.createElement("div");
368
+ row.className = "dsh-star-row-s";
369
+ row.appendChild(link);
370
+ const ask = d.createElement("span");
371
+ ask.className = "dsh-star-ask";
372
+ ask.textContent = STAR_COPY[lang].ask;
373
+ row.appendChild(ask);
374
+ const cta = d.createElement("button");
375
+ cta.type = "button";
376
+ cta.className = "dsh-star-cta";
377
+ cta.textContent = "★ " + STAR_CTA[lang];
378
+ cta.addEventListener("click", (event) => {
379
+ event.preventDefault();
380
+ event.stopPropagation();
381
+ openRepo(d);
382
+ });
383
+ row.appendChild(cta);
384
+ const hide = d.createElement("button");
385
+ hide.type = "button";
386
+ hide.className = "dsh-star-hide";
387
+ hide.textContent = "×";
388
+ hide.title = STAR_HIDE[lang];
389
+ hide.setAttribute("aria-label", STAR_HIDE[lang]);
390
+ hide.addEventListener("click", (event) => {
391
+ event.preventDefault();
392
+ event.stopPropagation();
393
+ starDismiss();
394
+ if (row.parentNode) {
395
+ row.parentNode.replaceChild(link, row);
396
+ link.className = "dsh-star-row";
397
+ }
398
+ });
399
+ row.appendChild(hide);
400
+ return row;
401
+ }
402
+ /** 在目标文档上建出快车道行(一次性注入样式)。纯 DOM,React 仓经 ref 回调挂载。 */
403
+ function mountStarRow(doc) {
404
+ const d = doc ?? document;
405
+ if (!d.getElementById(STYLE_ID)) {
406
+ const tag = d.createElement("style");
407
+ tag.id = STYLE_ID;
408
+ tag.textContent = STYLE_CSS;
409
+ d.head.appendChild(tag);
410
+ }
411
+ const match = REPO_URL.match(/github\.com\/([^/]+\/[^/#?]+)/);
412
+ const repo = match ? match[1] : "drscrewdriver";
413
+ const a = d.createElement("a");
414
+ a.className = "dsh-star-row";
415
+ a.href = REPO_URL;
416
+ a.target = "_blank";
417
+ a.rel = "noreferrer";
418
+ a.dataset.starNs = STAR_NS;
419
+ const svg = d.createElementNS("http://www.w3.org/2000/svg", "svg");
420
+ svg.setAttribute("viewBox", "0 0 24 24");
421
+ svg.setAttribute("aria-hidden", "true");
422
+ const path = d.createElementNS("http://www.w3.org/2000/svg", "path");
423
+ path.setAttribute("fill", "currentColor");
424
+ path.setAttribute("d", GITHUB_MARK_PATH);
425
+ svg.appendChild(path);
426
+ a.appendChild(svg);
427
+ const label = d.createElement("span");
428
+ label.textContent = repo;
429
+ a.appendChild(label);
430
+ const row = extendedStarRow(a, d);
431
+ if (row) return row;
432
+ return a;
433
+ }
225
434
  // src/client/card.tsx
226
435
  /**
227
436
  * 面板卡片:体检 / 修复 / 回滚三个按钮 + P1-P12 明细。
@@ -714,7 +923,10 @@ window.__ModuleLoader__.load({
714
923
  color: "var(--dsw-color-muted)"
715
924
  },
716
925
  children: render(t("lastCheck"), { at: state.checkedAt })
717
- }) : null
926
+ }) : null,
927
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { ref: (node) => {
928
+ if (node && !node.firstChild) node.appendChild(mountStarRow());
929
+ } })
718
930
  ]
719
931
  });
720
932
  }