hiwork-core 0.0.21 → 0.0.22

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 CHANGED
@@ -142,7 +142,7 @@ function browserLoginViewOf(value) {
142
142
  if (loginMode === "form") return { loginMode, browserLoginUrl: void 0, browserLoginPending: false };
143
143
  return { loginMode, browserLoginUrl: authorizeUrlOf(value), browserLoginPending: browserLoginPendingOf(value) };
144
144
  }
145
- function openAuthorizeUrl(url) {
145
+ function openExternalUrl(url) {
146
146
  if (url === void 0 || url === "") return;
147
147
  if (typeof window === "undefined") return;
148
148
  let protocol;
@@ -154,6 +154,9 @@ function openAuthorizeUrl(url) {
154
154
  if (protocol !== "https:" && protocol !== "http:") return;
155
155
  window.open(url, "_blank", "noopener,noreferrer");
156
156
  }
157
+ function openAuthorizeUrl(url) {
158
+ openExternalUrl(url);
159
+ }
157
160
  async function requestBrowserLogin(scope) {
158
161
  await scope.set("browserLoginRequest", { at: (/* @__PURE__ */ new Date()).toISOString() });
159
162
  }
@@ -1318,6 +1321,64 @@ function removeStaleHeroGreeting(doc) {
1318
1321
  for (const stale of Array.from(doc.querySelectorAll("[data-hiwork-hero-greeting]"))) stale.remove();
1319
1322
  }
1320
1323
 
1324
+ // src/client/manual-link.ts
1325
+ var MANUAL_URL = "https://hiworkapp.hivery.cn/manual.html";
1326
+ var MANUAL_STYLE_ID = "hiwork-core-manual-style";
1327
+ var MANUAL_STYLE = `
1328
+ [data-hiwork-core-manual-entry]{box-sizing:border-box;flex:none;display:inline-flex;align-items:center;justify-content:center;width:28px;height:28px;margin-left:auto;padding:0;border:0;border-radius:999px;background:transparent;color:var(--dsw-alias-label-tertiary,#71717a);font-family:inherit;font-size:14px;line-height:1;font-weight:600;cursor:pointer;user-select:none;transition:background .16s ease,color .16s ease}
1329
+ [data-hiwork-core-manual-entry]:hover{background:var(--dsw-alias-interactive-bg-hover,rgba(24,24,27,.06));color:var(--dsw-alias-label-secondary,#3f3f46)}
1330
+ [data-hiwork-core-manual-entry]:focus-visible{outline:2px solid var(--dsw-alias-button-info-fill,#4c8dff);outline-offset:2px}
1331
+ body[data-ds-dark-theme] [data-hiwork-core-manual-entry]{color:var(--dsw-alias-label-tertiary,#9ba3b4)}
1332
+ body[data-ds-dark-theme] [data-hiwork-core-manual-entry]:hover{background:var(--dsw-alias-interactive-bg-hover,rgba(255,255,255,.08));color:var(--dsw-alias-label-secondary,#a6adb8)}
1333
+ @media (prefers-reduced-motion: reduce){[data-hiwork-core-manual-entry]{transition:none}}
1334
+ `;
1335
+ function ensureManualStyle(doc) {
1336
+ if (doc.getElementById(MANUAL_STYLE_ID) !== null) return;
1337
+ if (doc.head === null) return;
1338
+ const style = doc.createElement("style");
1339
+ style.id = MANUAL_STYLE_ID;
1340
+ style.textContent = MANUAL_STYLE;
1341
+ doc.head.append(style);
1342
+ }
1343
+ function openManual() {
1344
+ openExternalUrl(MANUAL_URL);
1345
+ }
1346
+ function findManualMount(doc) {
1347
+ const hero = doc.querySelector('[data-phase="hero"]');
1348
+ if (hero === null) return null;
1349
+ return hero.querySelector('[class*="_heroWorkspaceRow"]');
1350
+ }
1351
+ function buildButton(doc) {
1352
+ const button = doc.createElement("button");
1353
+ button.dataset.hiworkCoreManualEntry = "";
1354
+ button.type = "button";
1355
+ button.title = "\u4F7F\u7528\u624B\u518C";
1356
+ button.setAttribute("aria-label", "\u4F7F\u7528\u624B\u518C");
1357
+ button.append(doc.createTextNode("?"));
1358
+ button.addEventListener("click", (event) => {
1359
+ event.preventDefault();
1360
+ event.stopPropagation();
1361
+ openManual();
1362
+ });
1363
+ return button;
1364
+ }
1365
+ function removeStaleManualEntry(doc) {
1366
+ for (const stale of Array.from(doc.querySelectorAll("[data-hiwork-core-manual-entry]"))) {
1367
+ stale.remove();
1368
+ }
1369
+ }
1370
+ function decorateManualEntry(doc) {
1371
+ const row = findManualMount(doc);
1372
+ if (row === null) {
1373
+ removeStaleManualEntry(doc);
1374
+ return;
1375
+ }
1376
+ const existing = row.querySelector(":scope > [data-hiwork-core-manual-entry]");
1377
+ if (existing !== null) return;
1378
+ removeStaleManualEntry(doc);
1379
+ row.append(buildButton(doc));
1380
+ }
1381
+
1321
1382
  // src/client/daily-card.ts
1322
1383
  var DAILY_CARD_STYLE_ID = "dcu-daily-card-style";
1323
1384
  var DAILY_MAIN_FONT_SIZE_MAX = 64;
@@ -1608,6 +1669,7 @@ function observeHeroDecorations(doc, quotes) {
1608
1669
  };
1609
1670
  ensureDailyCardStyle(doc);
1610
1671
  ensureHeroStyle(doc);
1672
+ ensureManualStyle(doc);
1611
1673
  let applying = false;
1612
1674
  let frame;
1613
1675
  let lastDailyDay = -1;
@@ -1620,6 +1682,7 @@ function observeHeroDecorations(doc, quotes) {
1620
1682
  if (today !== lastDailyDay) lastDailyDay = today;
1621
1683
  decorateDailyCard(doc, quotes);
1622
1684
  decorateHeroGreeting(doc);
1685
+ decorateManualEntry(doc);
1623
1686
  } finally {
1624
1687
  applying = false;
1625
1688
  }
@@ -1752,6 +1815,8 @@ var footStyle = { margin: "2px 0 0", fontSize: 11, color: INK_CAPTION, textAlign
1752
1815
  var browserHintStyle = { margin: 0, fontSize: 12, lineHeight: 1.6, color: INK_CAPTION, textAlign: "center" };
1753
1816
  var browserActionsStyle = { display: "flex", alignItems: "center", justifyContent: "center", gap: 18 };
1754
1817
  var toggleStyle = { ...linkButton, alignSelf: "center", fontSize: 12.5 };
1818
+ var footBlockStyle = { display: "flex", flexDirection: "column", alignItems: "center", gap: 4 };
1819
+ var manualLinkStyle = { ...linkButton, fontWeight: 500 };
1755
1820
  function describeLoginError(error) {
1756
1821
  if (error === void 0) return void 0;
1757
1822
  if (error.code === "GATEWAY_UNREACHABLE") return "\u7F51\u5173\u6682\u65F6\u4E0D\u53EF\u7528\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5\uFF0C\u6216\u6539\u7528\u8D26\u53F7\u5BC6\u7801\u767B\u5F55";
@@ -1887,7 +1952,10 @@ function LoginGateModal(props) {
1887
1952
  browserLogin,
1888
1953
  form,
1889
1954
  showBrowserLogin && formVisible ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("button", { "data-hiwork-core-secondary": true, "data-hiwork-core-form-collapse": true, type: "button", style: toggleStyle, onClick: () => setFormOpen(false), children: "\u6536\u8D77\u8D26\u53F7\u5BC6\u7801\u767B\u5F55" }) : null,
1890
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { style: footStyle, children: "\u4F01\u4E1A\u7EDF\u4E00\u8EAB\u4EFD\u8BA4\u8BC1 \xB7 LDAP" })
1955
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { style: footBlockStyle, children: [
1956
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { style: footStyle, children: "\u4F01\u4E1A\u7EDF\u4E00\u8EAB\u4EFD\u8BA4\u8BC1 \xB7 LDAP" }),
1957
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("button", { "data-hiwork-core-secondary": true, "data-hiwork-core-manual-login": true, type: "button", style: manualLinkStyle, onClick: openManual, children: "\u4F7F\u7528\u624B\u518C" })
1958
+ ] })
1891
1959
  ] })
1892
1960
  ] })
1893
1961
  ] });
package/lib/index.js CHANGED
@@ -3137,7 +3137,7 @@ function isUnloading(ctx) {
3137
3137
  }
3138
3138
 
3139
3139
  // src/version.ts
3140
- var PKG_VERSION = false ? "dev" : "0.0.21";
3140
+ var PKG_VERSION = false ? "dev" : "0.0.22";
3141
3141
 
3142
3142
  // src/ai-router-client.ts
3143
3143
  var AUTH_AUTHORIZE_PATH = "/api/auth/authorize";
@@ -158,8 +158,16 @@ export declare function browserLoginViewOf(value: AiRouterCardSettings | undefin
158
158
  browserLoginPending: boolean;
159
159
  };
160
160
  /**
161
- * 打开授权页(渲染层职责):桌面端 `shell.openExternal` 路由接管 https 外链,桌面端无需改动。
162
- * 命名空间值可被任意写入,因此只放行 http(s),其余静默忽略。
161
+ * 在系统浏览器里打开外链(渲染层职责):桌面端 `shell.openExternal` 路由接管 https 外链,
162
+ * 桌面端无需改动。
163
+ *
164
+ * 只放行 http(s):调用方给的可能是命名空间里被任意写入的值,也可能是将来变成用户可填的常量,
165
+ * `javascript:` / `file:` 之类一律静默忽略。URL 非法同样 no-op —— 外链打开失败不该抛错打断调用方。
166
+ * @param url - 目标地址;缺省 / 非 http(s) / 非法时为 no-op。
167
+ */
168
+ export declare function openExternalUrl(url: string | undefined): void;
169
+ /**
170
+ * 打开授权页。
163
171
  * @param url - Host 回写的授权页 URL;缺省 / 非法时为 no-op。
164
172
  */
165
173
  export declare function openAuthorizeUrl(url: string | undefined): void;
@@ -72,8 +72,10 @@ export declare function decorateDailyCard(doc: Document, quotes: DailyQuoteSourc
72
72
  export declare function removeStaleDailyCard(doc: Document): void;
73
73
  /**
74
74
  * 观察新建任务 hero 页并装饰同页组件:每日一句(服务端下发)+ hero 问候语轮换
75
- * (见 hero-greeting.ts)。DOM 变更按帧合并,避免流式输出时每个 token 都全文档扫描;
76
- * 页面完全空闲跨午夜时 MutationObserver 不会触发,靠周期轮询兜底换日(本地日变更
77
- * 触发重新拉取,服务端日期随之更新)。返回卸载清理函数。
75
+ * (见 hero-greeting.ts)+ 输入框右上方居右的「使用手册」问号按钮(见 manual-link.ts)。
76
+ * DOM 变更按帧合并,避免流式输出时每个 token 都全文档扫描;页面完全空闲跨午夜时
77
+ * MutationObserver 不会触发,靠周期轮询兜底换日(本地日变更触发重新拉取,服务端日期
78
+ * 随之更新)。三个装饰共用一个观察循环,不各自起 MutationObserver。
79
+ * 返回卸载清理函数。
78
80
  */
79
81
  export declare function observeHeroDecorations(doc: Document, quotes: DailyQuoteSource): () => void;
@@ -0,0 +1,35 @@
1
+ /**
2
+ * 使用手册地址 —— **全仓唯一一处**写死这个域名的地方(与 pms-client 的 PMS_BASE_URL 同一约定)。
3
+ *
4
+ * 为什么固定而不是配置项:官网是组织自建且只有这一个生产部署,做成设置项只会多一个能填错、
5
+ * 又没人能集中改的地方;真要换部署,改这一个常量、发一版即可。**任何别处都不许再写这个域名**
6
+ * (包括错误消息、日志、文档示例之外的代码),否则「唯一的基址」立刻变成两处能漂移的真相。
7
+ */
8
+ export declare const MANUAL_URL = "https://hiworkapp.hivery.cn/manual.html";
9
+ export declare const MANUAL_STYLE_ID = "hiwork-core-manual-style";
10
+ /**
11
+ * 问号按钮:28×28 的圆形热区、无边框(与输入框自身的图标按钮同语言),hover 才浮出一层浅底。
12
+ * `margin-left:auto` 是「居右」的全部机制——该行是 flex 容器,自动外边距吃掉剩余空间。
13
+ * `flex:none` 保证窄窗口下被两个 chip 挤扁时不至于缩成一个点。
14
+ */
15
+ export declare const MANUAL_STYLE = "\n[data-hiwork-core-manual-entry]{box-sizing:border-box;flex:none;display:inline-flex;align-items:center;justify-content:center;width:28px;height:28px;margin-left:auto;padding:0;border:0;border-radius:999px;background:transparent;color:var(--dsw-alias-label-tertiary,#71717a);font-family:inherit;font-size:14px;line-height:1;font-weight:600;cursor:pointer;user-select:none;transition:background .16s ease,color .16s ease}\n[data-hiwork-core-manual-entry]:hover{background:var(--dsw-alias-interactive-bg-hover,rgba(24,24,27,.06));color:var(--dsw-alias-label-secondary,#3f3f46)}\n[data-hiwork-core-manual-entry]:focus-visible{outline:2px solid var(--dsw-alias-button-info-fill,#4c8dff);outline-offset:2px}\nbody[data-ds-dark-theme] [data-hiwork-core-manual-entry]{color:var(--dsw-alias-label-tertiary,#9ba3b4)}\nbody[data-ds-dark-theme] [data-hiwork-core-manual-entry]:hover{background:var(--dsw-alias-interactive-bg-hover,rgba(255,255,255,.08));color:var(--dsw-alias-label-secondary,#a6adb8)}\n@media (prefers-reduced-motion: reduce){[data-hiwork-core-manual-entry]{transition:none}}\n";
16
+ export declare function ensureManualStyle(doc: Document): void;
17
+ /** 在系统浏览器里打开使用手册(桌面端 shell 接管 https 外链)。 */
18
+ export declare function openManual(): void;
19
+ /**
20
+ * hero 页里 workspace 行的定位:只在 `[data-phase="hero"]` 下找。
21
+ * 类名后缀稳定、前缀是构建哈希,故按 `*=` 匹配(同 daily-card 的 `[class$="_headline"]`)。
22
+ * 行本身缺失(非 hero 页 / 宿主改版)→ null,调用方只做清理。
23
+ */
24
+ export declare function findManualMount(doc: Document): HTMLElement | null;
25
+ /** 清掉非 hero 状态下(以及行被重建后)残留的按钮节点。 */
26
+ export declare function removeStaleManualEntry(doc: Document): void;
27
+ /**
28
+ * 幂等装饰:把问号按钮挂到 hero 输入框那一行的末尾(`margin-left:auto` 使其居右)。
29
+ *
30
+ * 已挂着且仍在该行内 → 不动(宿主流式重渲染时不做无谓的摘挂,避免按钮闪一下);
31
+ * 行不在场(会话记录页 / 登录门禁 / 宿主未渲染)→ 清掉残留。
32
+ * 只在**最后一个**子节点插入:宿主自己的 chip 顺序不受影响,将来它再往行里加东西,
33
+ * 我们的按钮仍在右侧。
34
+ */
35
+ export declare function decorateManualEntry(doc: Document): void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hiwork-core",
3
- "version": "0.0.21",
3
+ "version": "0.0.22",
4
4
  "type": "module",
5
5
  "description": "HiWork 企业统一登录与模型自动供给插件(ai-router 网关登录,Web 表单,无 CLI 认证)",
6
6
  "license": "UNLICENSED",