hostlet 0.0.0-stage → 0.1.0-alpha.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.
Files changed (512) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +233 -2
  3. package/bin/hostlet.js +61 -0
  4. package/console/app/api.js +1223 -0
  5. package/console/app/boot.js +165 -0
  6. package/console/app/cards.js +222 -0
  7. package/console/app/compose-quote.js +127 -0
  8. package/console/app/config-form.js +727 -0
  9. package/console/app/document-drafts.js +62 -0
  10. package/console/app/document-tools.mjs +67 -0
  11. package/console/app/documents.js +106 -0
  12. package/console/app/pages.js +6483 -0
  13. package/console/app/plugins.js +509 -0
  14. package/console/app/preview-tools.js +172 -0
  15. package/console/app/reference-labels.js +118 -0
  16. package/console/app/selection.js +372 -0
  17. package/console/app/store.js +57 -0
  18. package/console/app/text-anchor.js +26 -0
  19. package/console/app/topic-local.js +322 -0
  20. package/console/app/topic-nav.js +414 -0
  21. package/console/app/topic-status.js +109 -0
  22. package/console/app/views.js +43 -0
  23. package/console/apple-touch-icon.png +0 -0
  24. package/console/avatars/agy.svg +34 -0
  25. package/console/avatars/alhena.svg +36 -0
  26. package/console/avatars/castor.svg +38 -0
  27. package/console/avatars/claude.svg +34 -0
  28. package/console/avatars/codex.svg +34 -0
  29. package/console/avatars/devin.svg +34 -0
  30. package/console/avatars/echo.svg +34 -0
  31. package/console/avatars/kimi.svg +33 -0
  32. package/console/avatars/opencode.svg +33 -0
  33. package/console/avatars/pinion.svg +34 -0
  34. package/console/avatars/sprocket.svg +34 -0
  35. package/console/avatars/vela.svg +44 -0
  36. package/console/avatars/wasat.svg +38 -0
  37. package/console/clients/agy.svg +1 -0
  38. package/console/clients/claude.svg +1 -0
  39. package/console/clients/codex.svg +1 -0
  40. package/console/clients/devin.svg +1 -0
  41. package/console/clients/kimi.svg +1 -0
  42. package/console/clients/opencode.svg +1 -0
  43. package/console/favicon.ico +0 -0
  44. package/console/favicon.svg +16 -0
  45. package/console/index.html +99 -0
  46. package/console/pdl/engine/README.md +13 -0
  47. package/console/pdl/engine/anchor.js +195 -0
  48. package/console/pdl/engine/core.js +1340 -0
  49. package/console/pdl/engine/frame.js +1252 -0
  50. package/console/pdl/engine/i18n.js +67 -0
  51. package/console/pdl/engine/pdl-check.js +102 -0
  52. package/console/pdl/engine/pdl-doc.js +353 -0
  53. package/console/pdl/engine/pdl-view.js +280 -0
  54. package/console/pdl/engine/pdl.js +1064 -0
  55. package/console/pdl/engine/platform.js +18 -0
  56. package/console/pdl/engine/proj.js +279 -0
  57. package/console/pdl/engine/theme.js +176 -0
  58. package/console/pdl/engine/tree.js +171 -0
  59. package/console/pdl/engine/units.js +546 -0
  60. package/console/pdl/library/README.md +28 -0
  61. package/console/pdl/library/blocks.js +1512 -0
  62. package/console/pdl/library/buttons.js +86 -0
  63. package/console/pdl/library/capsules.js +130 -0
  64. package/console/pdl/library/charts.js +287 -0
  65. package/console/pdl/library/code.js +98 -0
  66. package/console/pdl/library/css/base.css +12 -0
  67. package/console/pdl/library/css/blocks.css +98 -0
  68. package/console/pdl/library/css/capsules.css +42 -0
  69. package/console/pdl/library/css/catalog-page.css +24 -0
  70. package/console/pdl/library/css/chat.css +100 -0
  71. package/console/pdl/library/css/composer-top.css +145 -0
  72. package/console/pdl/library/css/controls.css +195 -0
  73. package/console/pdl/library/css/drag.css +29 -0
  74. package/console/pdl/library/css/edit-layout.css +93 -0
  75. package/console/pdl/library/css/floating-window.css +30 -0
  76. package/console/pdl/library/css/hover.css +50 -0
  77. package/console/pdl/library/css/label-search.css +37 -0
  78. package/console/pdl/library/css/layers.css +43 -0
  79. package/console/pdl/library/css/library-parts.css +33 -0
  80. package/console/pdl/library/css/library.css +117 -0
  81. package/console/pdl/library/css/member-select.css +34 -0
  82. package/console/pdl/library/css/message.css +72 -0
  83. package/console/pdl/library/css/page.css +104 -0
  84. package/console/pdl/library/css/parts.css +338 -0
  85. package/console/pdl/library/css/responsive.css +40 -0
  86. package/console/pdl/library/css/roles.css +28 -0
  87. package/console/pdl/library/css/rows.css +231 -0
  88. package/console/pdl/library/css/settings-rows.css +37 -0
  89. package/console/pdl/library/css/shell.css +59 -0
  90. package/console/pdl/library/css/stream.css +296 -0
  91. package/console/pdl/library/css/theme-calculator.css +18 -0
  92. package/console/pdl/library/css/thumb-choice.css +69 -0
  93. package/console/pdl/library/css/tweaks.css +16 -0
  94. package/console/pdl/library/css/widgets.css +211 -0
  95. package/console/pdl/library/css/workbench.css +59 -0
  96. package/console/pdl/library/feedback.js +83 -0
  97. package/console/pdl/library/floating-window.mjs +100 -0
  98. package/console/pdl/library/fold.js +238 -0
  99. package/console/pdl/library/format.js +53 -0
  100. package/console/pdl/library/frames.js +123 -0
  101. package/console/pdl/library/icons.js +165 -0
  102. package/console/pdl/library/identity.js +149 -0
  103. package/console/pdl/library/inputs.js +801 -0
  104. package/console/pdl/library/label-search.js +214 -0
  105. package/console/pdl/library/markdown-text.js +115 -0
  106. package/console/pdl/library/markdown.js +150 -0
  107. package/console/pdl/library/media-viewer.js +293 -0
  108. package/console/pdl/library/member-select.mjs +32 -0
  109. package/console/pdl/library/message.js +105 -0
  110. package/console/pdl/library/motion.js +56 -0
  111. package/console/pdl/library/overlays.js +165 -0
  112. package/console/pdl/library/page.js +142 -0
  113. package/console/pdl/library/plugin-form.js +154 -0
  114. package/console/pdl/library/registry.js +198 -0
  115. package/console/pdl/library/rows.js +523 -0
  116. package/console/pdl/library/shell.js +151 -0
  117. package/console/pdl/library/stream.js +58 -0
  118. package/console/pdl/library/tabs.js +259 -0
  119. package/console/pdl/library/theme-calculator.js +300 -0
  120. package/console/pdl/library/widgets.js +114 -0
  121. package/console/pdl/load-order.json +74 -0
  122. package/console/pdl/platform/README.md +3 -0
  123. package/console/pdl/platform/rich-markdown.mjs +17 -0
  124. package/console/pdl/platform/web-links.js +26 -0
  125. package/console/pdl/platform/web.js +80 -0
  126. package/console/sdk-browser/mentions.d.mts +16 -0
  127. package/console/sdk-browser/mentions.mjs +84 -0
  128. package/console/theme/assets.js +21 -0
  129. package/console/theme/theme.json +9417 -0
  130. package/console/theme/tokens.json +444 -0
  131. package/dist/core/a2a.d.ts +288 -0
  132. package/dist/core/a2a.js +2197 -0
  133. package/dist/core/address.d.ts +34 -0
  134. package/dist/core/address.js +33 -0
  135. package/dist/core/approval-inputs.d.ts +17 -0
  136. package/dist/core/approval-inputs.js +70 -0
  137. package/dist/core/archive.d.ts +19 -0
  138. package/dist/core/archive.js +135 -0
  139. package/dist/core/attachments.d.ts +17 -0
  140. package/dist/core/attachments.js +143 -0
  141. package/dist/core/blocked-handoffs.d.ts +132 -0
  142. package/dist/core/blocked-handoffs.js +349 -0
  143. package/dist/core/config-schema.d.ts +124 -0
  144. package/dist/core/config-schema.js +192 -0
  145. package/dist/core/config.d.ts +117 -0
  146. package/dist/core/config.js +638 -0
  147. package/dist/core/disk-usage.d.ts +26 -0
  148. package/dist/core/disk-usage.js +83 -0
  149. package/dist/core/documents.d.ts +9 -0
  150. package/dist/core/documents.js +48 -0
  151. package/dist/core/entry.d.ts +316 -0
  152. package/dist/core/entry.js +711 -0
  153. package/dist/core/home.d.ts +76 -0
  154. package/dist/core/home.js +449 -0
  155. package/dist/core/i18n.d.ts +36 -0
  156. package/dist/core/i18n.js +458 -0
  157. package/dist/core/instances.d.ts +224 -0
  158. package/dist/core/instances.js +1272 -0
  159. package/dist/core/members.d.ts +190 -0
  160. package/dist/core/members.js +358 -0
  161. package/dist/core/mentions.d.ts +12 -0
  162. package/dist/core/mentions.js +49 -0
  163. package/dist/core/messages.d.ts +876 -0
  164. package/dist/core/messages.js +916 -0
  165. package/dist/core/notices.d.ts +88 -0
  166. package/dist/core/notices.js +54 -0
  167. package/dist/core/ops.d.ts +117 -0
  168. package/dist/core/ops.js +146 -0
  169. package/dist/core/package.d.ts +2 -0
  170. package/dist/core/package.js +14 -0
  171. package/dist/core/parts.d.ts +25 -0
  172. package/dist/core/parts.js +119 -0
  173. package/dist/core/plugins/catalog.d.ts +14 -0
  174. package/dist/core/plugins/catalog.js +54 -0
  175. package/dist/core/plugins/external.d.ts +7 -0
  176. package/dist/core/plugins/external.js +921 -0
  177. package/dist/core/plugins/index.d.ts +5 -0
  178. package/dist/core/plugins/index.js +51 -0
  179. package/dist/core/plugins/npm.d.ts +12 -0
  180. package/dist/core/plugins/npm.js +99 -0
  181. package/dist/core/plugins/plugin-manifest.d.ts +12 -0
  182. package/dist/core/plugins/plugin-manifest.js +231 -0
  183. package/dist/core/push.d.ts +22 -0
  184. package/dist/core/push.js +63 -0
  185. package/dist/core/resource.d.ts +77 -0
  186. package/dist/core/resource.js +48 -0
  187. package/dist/core/spawn.d.ts +12 -0
  188. package/dist/core/spawn.js +30 -0
  189. package/dist/core/storage-inventory.d.ts +118 -0
  190. package/dist/core/storage-inventory.js +279 -0
  191. package/dist/core/storage.d.ts +45 -0
  192. package/dist/core/storage.js +602 -0
  193. package/dist/core/store.d.ts +15 -0
  194. package/dist/core/store.js +33 -0
  195. package/dist/core/topic-index.d.ts +19 -0
  196. package/dist/core/topic-index.js +70 -0
  197. package/dist/core/topic-ops.d.ts +139 -0
  198. package/dist/core/topic-ops.js +507 -0
  199. package/dist/core/topic-status.d.ts +32 -0
  200. package/dist/core/topic-status.js +105 -0
  201. package/dist/core/topics.d.ts +327 -0
  202. package/dist/core/topics.js +786 -0
  203. package/dist/core/turn-clients.d.ts +1 -0
  204. package/dist/core/turn-clients.js +5 -0
  205. package/dist/core/types.d.ts +2866 -0
  206. package/dist/core/types.js +166 -0
  207. package/dist/core/util.d.ts +10 -0
  208. package/dist/core/util.js +47 -0
  209. package/dist/main.d.ts +12 -0
  210. package/dist/main.js +82 -0
  211. package/dist/plugins/adapter-acp/index.d.ts +3 -0
  212. package/dist/plugins/adapter-acp/index.js +57 -0
  213. package/dist/plugins/adapter-acp/plugin.yaml +100 -0
  214. package/dist/plugins/adapter-agy/command.d.ts +9 -0
  215. package/dist/plugins/adapter-agy/command.js +34 -0
  216. package/dist/plugins/adapter-agy/index.d.ts +5 -0
  217. package/dist/plugins/adapter-agy/index.js +65 -0
  218. package/dist/plugins/adapter-agy/quota.d.ts +2 -0
  219. package/dist/plugins/adapter-agy/quota.js +155 -0
  220. package/dist/plugins/adapter-agy/terminal.d.ts +6 -0
  221. package/dist/plugins/adapter-agy/terminal.js +132 -0
  222. package/dist/plugins/adapter-agy/version.d.ts +9 -0
  223. package/dist/plugins/adapter-agy/version.js +17 -0
  224. package/dist/plugins/adapter-claude/index.d.ts +43 -0
  225. package/dist/plugins/adapter-claude/index.js +412 -0
  226. package/dist/plugins/adapter-claude/quota.d.ts +14 -0
  227. package/dist/plugins/adapter-claude/quota.js +103 -0
  228. package/dist/plugins/adapter-codex/index.d.ts +4 -0
  229. package/dist/plugins/adapter-codex/index.js +688 -0
  230. package/dist/plugins/adapter-codex/responses-model.d.ts +9 -0
  231. package/dist/plugins/adapter-codex/responses-model.js +82 -0
  232. package/dist/plugins/adapter-kimi/index.d.ts +4 -0
  233. package/dist/plugins/adapter-kimi/index.js +51 -0
  234. package/dist/plugins/adapter-kimi/quota.d.ts +3 -0
  235. package/dist/plugins/adapter-kimi/quota.js +171 -0
  236. package/dist/plugins/adapter-opencode/index.d.ts +12 -0
  237. package/dist/plugins/adapter-opencode/index.js +64 -0
  238. package/dist/plugins/annotations/console/cards.css +189 -0
  239. package/dist/plugins/annotations/console/cards.mjs +439 -0
  240. package/dist/plugins/annotations/console/pdl.json +52 -0
  241. package/dist/plugins/annotations/console/view.mjs +241 -0
  242. package/dist/plugins/annotations/console/window.mjs +219 -0
  243. package/dist/plugins/annotations/followups.d.ts +51 -0
  244. package/dist/plugins/annotations/followups.js +112 -0
  245. package/dist/plugins/annotations/index.d.ts +3 -0
  246. package/dist/plugins/annotations/index.js +298 -0
  247. package/dist/plugins/annotations/plugin.yaml +3 -0
  248. package/dist/plugins/ask-choice/index.d.ts +9 -0
  249. package/dist/plugins/ask-choice/index.js +24 -0
  250. package/dist/plugins/ask-choice/plugin.yaml +2 -0
  251. package/dist/plugins/background/index.d.ts +2 -0
  252. package/dist/plugins/background/index.js +398 -0
  253. package/dist/plugins/background/plugin.yaml +7 -0
  254. package/dist/plugins/builtin.json +37 -0
  255. package/dist/plugins/cards/console/pdl.json +516 -0
  256. package/dist/plugins/cards/console/view.mjs +67 -0
  257. package/dist/plugins/cards/index.d.ts +8 -0
  258. package/dist/plugins/cards/index.js +627 -0
  259. package/dist/plugins/cards/plugin.yaml +3 -0
  260. package/dist/plugins/console/browser.d.ts +2 -0
  261. package/dist/plugins/console/browser.js +115 -0
  262. package/dist/plugins/console/console/pdl.json +38 -0
  263. package/dist/plugins/console/console/view.mjs +26 -0
  264. package/dist/plugins/console/index.d.ts +4 -0
  265. package/dist/plugins/console/index.js +94 -0
  266. package/dist/plugins/console/picker.d.ts +2 -0
  267. package/dist/plugins/console/picker.js +48 -0
  268. package/dist/plugins/console/plugin.yaml +3 -0
  269. package/dist/plugins/console/topic-view.d.ts +3 -0
  270. package/dist/plugins/console/topic-view.js +388 -0
  271. package/dist/plugins/handoff/index.d.ts +2 -0
  272. package/dist/plugins/handoff/index.js +147 -0
  273. package/dist/plugins/handoff/plugin.yaml +8 -0
  274. package/dist/plugins/host-api/index.d.ts +7 -0
  275. package/dist/plugins/host-api/index.js +310 -0
  276. package/dist/plugins/host-api/plugin.yaml +2 -0
  277. package/dist/plugins/host-api/signing.d.ts +63 -0
  278. package/dist/plugins/host-api/signing.js +427 -0
  279. package/dist/plugins/host-api/skills/host-ops/SKILL.md +28 -0
  280. package/dist/plugins/host-api/skills/hostlet-plugin-dev/SKILL.md +38 -0
  281. package/dist/plugins/inbox/index.d.ts +15 -0
  282. package/dist/plugins/inbox/index.js +161 -0
  283. package/dist/plugins/inbox/plugin.yaml +2 -0
  284. package/dist/plugins/keys/account-directories.d.ts +18 -0
  285. package/dist/plugins/keys/account-directories.js +86 -0
  286. package/dist/plugins/keys/account-storage.d.ts +18 -0
  287. package/dist/plugins/keys/account-storage.js +112 -0
  288. package/dist/plugins/keys/console/pdl.json +710 -0
  289. package/dist/plugins/keys/console/view.mjs +619 -0
  290. package/dist/plugins/keys/index.d.ts +7 -0
  291. package/dist/plugins/keys/index.js +842 -0
  292. package/dist/plugins/keys/login-link.d.ts +2 -0
  293. package/dist/plugins/keys/login-link.js +15 -0
  294. package/dist/plugins/keys/plugin.yaml +3 -0
  295. package/dist/plugins/keys/quota-history.d.ts +91 -0
  296. package/dist/plugins/keys/quota-history.js +420 -0
  297. package/dist/plugins/mcp/console/pdl.json +412 -0
  298. package/dist/plugins/mcp/console/view.mjs +207 -0
  299. package/dist/plugins/mcp/index.d.ts +7 -0
  300. package/dist/plugins/mcp/index.js +494 -0
  301. package/dist/plugins/mcp/plugin.yaml +3 -0
  302. package/dist/plugins/member-health/index.d.ts +2 -0
  303. package/dist/plugins/member-health/index.js +478 -0
  304. package/dist/plugins/member-health/plugin.yaml +2 -0
  305. package/dist/plugins/memory/capabilities.d.ts +10 -0
  306. package/dist/plugins/memory/capabilities.js +70 -0
  307. package/dist/plugins/memory/console/pdl.json +459 -0
  308. package/dist/plugins/memory/console/view.mjs +254 -0
  309. package/dist/plugins/memory/corpus.d.ts +60 -0
  310. package/dist/plugins/memory/corpus.js +521 -0
  311. package/dist/plugins/memory/engines/fts-tree-diversity.d.ts +8 -0
  312. package/dist/plugins/memory/engines/fts-tree-diversity.js +49 -0
  313. package/dist/plugins/memory/engines/fts-tree-text.d.ts +12 -0
  314. package/dist/plugins/memory/engines/fts-tree-text.js +93 -0
  315. package/dist/plugins/memory/engines/fts-tree.d.ts +4 -0
  316. package/dist/plugins/memory/engines/fts-tree.js +387 -0
  317. package/dist/plugins/memory/engines/search.d.ts +9 -0
  318. package/dist/plugins/memory/engines/search.js +35 -0
  319. package/dist/plugins/memory/index.d.ts +3 -0
  320. package/dist/plugins/memory/index.js +465 -0
  321. package/dist/plugins/memory/notes.d.ts +22 -0
  322. package/dist/plugins/memory/notes.js +140 -0
  323. package/dist/plugins/memory/plugin.yaml +23 -0
  324. package/dist/plugins/model-profiles/index.d.ts +2 -0
  325. package/dist/plugins/model-profiles/index.js +919 -0
  326. package/dist/plugins/model-profiles/plugin.yaml +13 -0
  327. package/dist/plugins/model-profiles/review-source.d.ts +11 -0
  328. package/dist/plugins/model-profiles/review-source.js +640 -0
  329. package/dist/plugins/model-profiles/rules.d.ts +132 -0
  330. package/dist/plugins/model-profiles/rules.js +767 -0
  331. package/dist/plugins/model-profiles/skills/model-profile/SKILL.md +60 -0
  332. package/dist/plugins/model-profiles/sources.d.ts +61 -0
  333. package/dist/plugins/model-profiles/sources.js +375 -0
  334. package/dist/plugins/model-profiles/storage.d.ts +104 -0
  335. package/dist/plugins/model-profiles/storage.js +352 -0
  336. package/dist/plugins/model-profiles/types.d.ts +187 -0
  337. package/dist/plugins/model-profiles/types.js +12 -0
  338. package/dist/plugins/model-profiles/wakeup.d.ts +29 -0
  339. package/dist/plugins/model-profiles/wakeup.js +390 -0
  340. package/dist/plugins/models/index.d.ts +2 -0
  341. package/dist/plugins/models/index.js +63 -0
  342. package/dist/plugins/models/plugin.yaml +8 -0
  343. package/dist/plugins/ops/collector.d.ts +22 -0
  344. package/dist/plugins/ops/collector.js +48 -0
  345. package/dist/plugins/ops/config.d.ts +11 -0
  346. package/dist/plugins/ops/config.js +13 -0
  347. package/dist/plugins/ops/console/pdl.json +676 -0
  348. package/dist/plugins/ops/console/view.mjs +700 -0
  349. package/dist/plugins/ops/index.d.ts +3 -0
  350. package/dist/plugins/ops/index.js +20 -0
  351. package/dist/plugins/ops/journal.d.ts +7 -0
  352. package/dist/plugins/ops/journal.js +109 -0
  353. package/dist/plugins/ops/metrics.d.ts +3 -0
  354. package/dist/plugins/ops/metrics.js +81 -0
  355. package/dist/plugins/ops/plugin.yaml +63 -0
  356. package/dist/plugins/ops/samples.d.ts +54 -0
  357. package/dist/plugins/ops/samples.js +100 -0
  358. package/dist/plugins/ops/trace.d.ts +3 -0
  359. package/dist/plugins/ops/trace.js +104 -0
  360. package/dist/plugins/ops/usage.d.ts +2 -0
  361. package/dist/plugins/ops/usage.js +152 -0
  362. package/dist/plugins/plans/acceptance.d.ts +284 -0
  363. package/dist/plugins/plans/acceptance.js +247 -0
  364. package/dist/plugins/plans/blocked.d.ts +25 -0
  365. package/dist/plugins/plans/blocked.js +66 -0
  366. package/dist/plugins/plans/console/pdl.json +639 -0
  367. package/dist/plugins/plans/console/view.d.mts +2 -0
  368. package/dist/plugins/plans/console/view.mjs +855 -0
  369. package/dist/plugins/plans/dependencies.d.ts +5 -0
  370. package/dist/plugins/plans/dependencies.js +21 -0
  371. package/dist/plugins/plans/index.d.ts +72 -0
  372. package/dist/plugins/plans/index.js +2057 -0
  373. package/dist/plugins/plans/plugin.yaml +44 -0
  374. package/dist/plugins/plans/progress.d.ts +82 -0
  375. package/dist/plugins/plans/progress.js +516 -0
  376. package/dist/plugins/prompt/index.d.ts +8 -0
  377. package/dist/plugins/prompt/index.js +361 -0
  378. package/dist/plugins/prompt/plugin.yaml +2 -0
  379. package/dist/plugins/recovery/console/pdl.json +50 -0
  380. package/dist/plugins/recovery/console/view.mjs +46 -0
  381. package/dist/plugins/recovery/index.d.ts +9 -0
  382. package/dist/plugins/recovery/index.js +454 -0
  383. package/dist/plugins/recovery/plugin.yaml +9 -0
  384. package/dist/plugins/recovery/probe.d.ts +11 -0
  385. package/dist/plugins/recovery/probe.js +128 -0
  386. package/dist/plugins/restart/console/pdl.json +112 -0
  387. package/dist/plugins/restart/console/view.mjs +85 -0
  388. package/dist/plugins/restart/index.d.ts +10 -0
  389. package/dist/plugins/restart/index.js +669 -0
  390. package/dist/plugins/restart/plugin.yaml +9 -0
  391. package/dist/plugins/restart/scope.d.ts +6 -0
  392. package/dist/plugins/restart/scope.js +44 -0
  393. package/dist/plugins/schedule/console/pdl.json +696 -0
  394. package/dist/plugins/schedule/console/view.mjs +398 -0
  395. package/dist/plugins/schedule/events.d.ts +76 -0
  396. package/dist/plugins/schedule/events.js +158 -0
  397. package/dist/plugins/schedule/index.d.ts +32 -0
  398. package/dist/plugins/schedule/index.js +1199 -0
  399. package/dist/plugins/schedule/plugin.yaml +26 -0
  400. package/dist/plugins/schedule/when.d.ts +14 -0
  401. package/dist/plugins/schedule/when.js +83 -0
  402. package/dist/plugins/sessions/console/pdl.json +259 -0
  403. package/dist/plugins/sessions/console/view.mjs +355 -0
  404. package/dist/plugins/sessions/index.d.ts +3 -0
  405. package/dist/plugins/sessions/index.js +126 -0
  406. package/dist/plugins/sessions/participants.d.ts +28 -0
  407. package/dist/plugins/sessions/participants.js +83 -0
  408. package/dist/plugins/sessions/plugin.yaml +3 -0
  409. package/dist/plugins/signals/console/pdl.json +802 -0
  410. package/dist/plugins/signals/console/view.mjs +284 -0
  411. package/dist/plugins/signals/content.d.ts +31 -0
  412. package/dist/plugins/signals/content.js +151 -0
  413. package/dist/plugins/signals/index.d.ts +2 -0
  414. package/dist/plugins/signals/index.js +601 -0
  415. package/dist/plugins/signals/plugin.yaml +32 -0
  416. package/dist/plugins/signals/skills/signal-sources/SKILL.md +27 -0
  417. package/dist/plugins/skills/console/pdl.json +254 -0
  418. package/dist/plugins/skills/console/view.mjs +204 -0
  419. package/dist/plugins/skills/index.d.ts +11 -0
  420. package/dist/plugins/skills/index.js +567 -0
  421. package/dist/plugins/skills/install.d.ts +69 -0
  422. package/dist/plugins/skills/install.js +265 -0
  423. package/dist/plugins/skills/plugin.yaml +24 -0
  424. package/dist/plugins/skills/safety-scan.d.ts +17 -0
  425. package/dist/plugins/skills/safety-scan.js +78 -0
  426. package/dist/plugins/skills/skills/skill-ops/SKILL.md +29 -0
  427. package/dist/plugins/terminal/console/pdl.json +115 -0
  428. package/dist/plugins/terminal/console/view.mjs +178 -0
  429. package/dist/plugins/terminal/index.d.ts +3 -0
  430. package/dist/plugins/terminal/index.js +204 -0
  431. package/dist/plugins/terminal/plugin.yaml +2 -0
  432. package/dist/plugins/tools/index.d.ts +3 -0
  433. package/dist/plugins/tools/index.js +458 -0
  434. package/dist/plugins/tools/plugin.yaml +2 -0
  435. package/dist/plugins/tools/token.d.ts +61 -0
  436. package/dist/plugins/tools/token.js +179 -0
  437. package/dist/plugins/topic-tools/index.d.ts +9 -0
  438. package/dist/plugins/topic-tools/index.js +29 -0
  439. package/dist/plugins/topic-tools/plugin.yaml +2 -0
  440. package/dist/plugins/topic-tools/skills/topic-tidy/SKILL.md +108 -0
  441. package/dist/plugins/works/console/pdl.json +120 -0
  442. package/dist/plugins/works/console/view.mjs +91 -0
  443. package/dist/plugins/works/document-words.d.ts +50 -0
  444. package/dist/plugins/works/document-words.js +27 -0
  445. package/dist/plugins/works/editors.d.ts +3 -0
  446. package/dist/plugins/works/editors.js +162 -0
  447. package/dist/plugins/works/events.d.ts +58 -0
  448. package/dist/plugins/works/events.js +82 -0
  449. package/dist/plugins/works/files.d.ts +23 -0
  450. package/dist/plugins/works/files.js +53 -0
  451. package/dist/plugins/works/index.d.ts +9 -0
  452. package/dist/plugins/works/index.js +1088 -0
  453. package/dist/plugins/works/plugin.yaml +9 -0
  454. package/dist/plugins/works/preview.d.ts +10 -0
  455. package/dist/plugins/works/preview.js +30 -0
  456. package/dist/plugins/works/project.d.ts +3 -0
  457. package/dist/plugins/works/project.js +245 -0
  458. package/dist/plugins/works/resource.d.ts +28 -0
  459. package/dist/plugins/works/resource.js +71 -0
  460. package/dist/plugins/works/retention.d.ts +36 -0
  461. package/dist/plugins/works/retention.js +295 -0
  462. package/dist/plugins/works/skills/works-ops/SKILL.md +14 -0
  463. package/dist/plugins/works/viewers.d.ts +13 -0
  464. package/dist/plugins/works/viewers.js +87 -0
  465. package/dist/plugins/works/web/anchors.js +94 -0
  466. package/dist/plugins/works/web/document-edit.js +245 -0
  467. package/dist/plugins/works/web/preview-bridge.js +142 -0
  468. package/dist/plugins/works/web/reading-position.js +74 -0
  469. package/dist/plugins/works/web/view.html +1118 -0
  470. package/dist/runtime/runtime.d.ts +210 -0
  471. package/dist/runtime/runtime.js +338 -0
  472. package/dist/sdk/adapter-kit.d.ts +1 -0
  473. package/dist/sdk/adapter-kit.js +1 -0
  474. package/dist/sdk/client.d.ts +163 -0
  475. package/dist/sdk/client.js +43 -0
  476. package/dist/sdk/contracts.d.ts +1263 -0
  477. package/dist/sdk/contracts.js +1 -0
  478. package/dist/sdk/index.d.ts +57 -0
  479. package/dist/sdk/index.js +27 -0
  480. package/dist/sdk/source-choice.d.ts +40 -0
  481. package/dist/sdk/source-choice.js +217 -0
  482. package/dist/sdk/topic-text.d.ts +5 -0
  483. package/dist/sdk/topic-text.js +26 -0
  484. package/dist/sdk/transport.d.ts +12 -0
  485. package/dist/sdk/transport.js +34 -0
  486. package/node_modules/@hostlet/adapter-kit/dist/acp.d.ts +88 -0
  487. package/node_modules/@hostlet/adapter-kit/dist/acp.js +674 -0
  488. package/node_modules/@hostlet/adapter-kit/dist/command.d.ts +18 -0
  489. package/node_modules/@hostlet/adapter-kit/dist/command.js +39 -0
  490. package/node_modules/@hostlet/adapter-kit/dist/index.d.ts +8 -0
  491. package/node_modules/@hostlet/adapter-kit/dist/index.js +6 -0
  492. package/node_modules/@hostlet/adapter-kit/dist/models.d.ts +29 -0
  493. package/node_modules/@hostlet/adapter-kit/dist/models.js +108 -0
  494. package/node_modules/@hostlet/adapter-kit/dist/quota.d.ts +3 -0
  495. package/node_modules/@hostlet/adapter-kit/dist/quota.js +4 -0
  496. package/node_modules/@hostlet/adapter-kit/dist/rpc.d.ts +29 -0
  497. package/node_modules/@hostlet/adapter-kit/dist/rpc.js +84 -0
  498. package/node_modules/@hostlet/adapter-kit/dist/upstream-failure.d.ts +5 -0
  499. package/node_modules/@hostlet/adapter-kit/dist/upstream-failure.js +37 -0
  500. package/node_modules/@hostlet/adapter-kit/package.json +16 -0
  501. package/node_modules/@hostlet/platform/dist/desktop.d.ts +16 -0
  502. package/node_modules/@hostlet/platform/dist/desktop.js +276 -0
  503. package/node_modules/@hostlet/platform/dist/files.d.ts +24 -0
  504. package/node_modules/@hostlet/platform/dist/files.js +113 -0
  505. package/node_modules/@hostlet/platform/dist/index.d.ts +6 -0
  506. package/node_modules/@hostlet/platform/dist/index.js +4 -0
  507. package/node_modules/@hostlet/platform/dist/paths.d.ts +4 -0
  508. package/node_modules/@hostlet/platform/dist/paths.js +9 -0
  509. package/node_modules/@hostlet/platform/dist/process.d.ts +45 -0
  510. package/node_modules/@hostlet/platform/dist/process.js +297 -0
  511. package/node_modules/@hostlet/platform/package.json +14 -0
  512. package/package.json +60 -4
@@ -0,0 +1,86 @@
1
+ /* 边界:一个含义一个组件、不为接口定制、不按位置推导样式 */
2
+ /* 按钮类:按钮、标签胶囊、开关、分段、下拉按钮、展开箭头、复制 */
3
+ 'use strict';
4
+ /* ───────────── Small components ───────────── */
5
+ /* 按钮(组件库):四种样式(solid / soft / danger solid / danger soft)在 core.css 里声明;默认 soft,调用方只说这一个按钮是什么:o.primary 一组里的主操作(solid);o.danger 危险(danger soft,和 primary 一起 = 最后一步的破坏性确认,danger solid);
6
+ o.link 文中的链接(强调色字);o.iconOnly 只有图标(墨色,悬停强调色);o.pressed 开关(开关规则)。尺寸三档:m(默认)/ s(sm)/ xs(行内的小图标按钮:提示胶囊、标签页上的固定和关闭) */
7
+ function btn(label, o) {
8
+ o = o || {};
9
+ if (o.busy) o = Object.assign({}, o, { icon: o.icon || 'refresh', data: (o.data || '') + ' aria-busy="true"' }); /* 进行中:按钮自己的图标转起来(没有图标的用刷新图标),不能再点(core.css) */
10
+ const cls = 'btn' + (o.link ? ' btn-text' : '') + (o.size === 'xs' ? ' btn-xs' : o.sm ? ' btn-sm' : '') + (o.iconOnly ? ' btn-icon' : '') + (o.danger ? ' danger' : '') + (o.cls ? ' ' + o.cls : ''), pri = o.primary ? ' data-primary' : '';
11
+ const body = o.html != null ? o.html : o.iconOnly ? '' : o.link && !o.why ? btnLinkText(label, o) : h(label);
12
+ /* 停用而且说了原因(why):不用原生 disabled(原生停用的按钮不发悬停事件,提示出不来),而是 aria-disabled + 原因在悬停提示里(不弹提示条) */
13
+ if (o.why) return '<button type="button" class="' + cls + '"' + pri + ' aria-disabled="true" data-tip="' + h(o.why) + '"' + (o.iconOnly ? ' aria-label="' + h(o.aria || label) + '"' : '') + (o.icon ? libActAttr(o.act, o.data, o.icon) : '') + '>' + (o.icon ? icon(libActIcon(o.act, o.data, o.icon)) : '') + body + '</button>';
14
+ return '<button type="' + (o.submit ? 'submit' : 'button') + '" class="' + cls + '"' + pri + (o.act ? ' data-act="' + o.act + '"' : '') + (o.data || '') + (o.disabled ? ' disabled' : '') + (o.pressed != null ? ' aria-pressed="' + o.pressed + '"' : '') + (o.iconOnly ? ' aria-label="' + h(o.aria || label) + '" data-tip="' + h(o.tip || label) + '"' : '') + (o.note ? ' data-note="' + o.note + '"' : '') + (o.icon ? libActAttr(o.act, o.data, o.icon) : '') + '>' + (o.icon ? icon(libActIcon(o.act, o.data, o.icon)) : '') + body + '</button>';
15
+ }
16
+ /* 文字链接按钮的字:放不下时省略(被截断的字悬停看全文是引擎的通用规则) */
17
+ function btnLinkText(label, o) { return '<span class="pdl-ellipsis">' + h(label) + '</span>'; }
18
+ /* 可复制的值(组件库,唯一的一个):值 + 末尾的复制图标(只有图标)。图标的提示说复制的是什么(label,比如“复制路径”);值自己的提示可以说别的(tip,比如只读的规则)。
19
+ 点图标复制 v(默认就是显示的值);field 让值可以在只读输入框中聚焦、选择。 */
20
+ function copyValue(o) {
21
+ const v = o.v != null && o.v !== '' ? o.v : o.value, mono = o.mono ? ' mono' : '', tip = o.tip ? ' data-tip="' + h(o.tip) + '"' : '';
22
+ const copy = btn(o.label, { iconOnly: true, icon: 'copy', sm: true, act: 'copy', data: argAttrs({ v: v, msg: tc('control.copied', v) }) });
23
+ if (o.field) return '<span class="copyv copyv-field combo"><input type="text" class="input' + mono + '" readonly value="' + h(o.value) + '" aria-label="' + h(o.fieldLabel ?? o.label) + '"' + tip + '>' + copy + '</span>';
24
+ return '<span class="copyv"' + (o.tail ? ' data-tail' : '') + '><span class="copyv-v' + mono + '"' + tip + '>' +
25
+ (o.tail ? '<bdi dir="ltr">' + h(o.value) + '</bdi>' : h(o.value)) + '</span>' + copy + '</span>';
26
+ }
27
+ /* 标签自带的移除按钮(标签这个组件的一部分):从选择里拿掉用 close(×);真正删除数据用 delete(垃圾桶) */
28
+ function chipX(act, data, label, glyph) { return '<button type="button" class="chip-x" data-act="' + act + '"' + (data || '') + libActAttr(act, data, glyph || 'close') + ' aria-label="' + h(label || tc('common.remove')) + '" data-tip="' + h(label || tc('common.remove')) + '">' + icon(libActIcon(act, data, glyph || 'close'), 12) + '</button>'; }
29
+ /* 标签(组件库唯一的画法):PDL 的 chip 控件、消息上的标签、标签编辑器、只读的一列值、阶段进度、流程节点、筛选标签、认领行都画它,不各写一份。
30
+ 文字类参数(label / kind / faint / tip / lead / tail)是已转义的 HTML;thumb 是图片地址,优先于 icon 字形;tint 是色调槽位或 #hex(有才画色点);
31
+ act + data:整个标签可点(button,pressed 写 aria-pressed,check 时选中多一个勾);disabled:停用的原因(button + aria-disabled,同按钮的停用规则);
32
+ x:标签自带的移除按钮(chipX 画好的)——能点又能移除时点名字打开、× 移除;cls / attrs:钩子类名和额外属性(行为用,不挑样子) */
33
+ function chipHtml(o) {
34
+ const x = o.x || '', more = (o.tip ? ' data-tip="' + o.tip + '"' : '') + (o.tone ? ' data-tone="' + h(o.tone) + '"' : '') + (o.attrs || ''), cls = 'chip' + (o.cls ? ' ' + o.cls : '');
35
+ const body = (o.tint !== undefined ? tintDot(o.tint) : '') + (o.check && o.pressed ? icon('check', 12) : '') + (o.lead || '') + (o.thumb ? '<img class="chip-thumb" src="' + h(o.thumb) + '" alt="" draggable="false">' : o.icon ? icon(o.icon, 13) : '') + (o.kind ? '<b class="mono vw-11">' + o.kind + '</b>' : '') + (o.ellip ? '<span class="pdl-ellipsis vw-w220">' + o.label + '</span>' : (o.label || '')) + (o.faint ? '<span class="faint">' + o.faint + '</span>' : '') + (o.tail || '');
36
+ const pr = o.pressed != null ? ' aria-pressed="' + !!o.pressed + '"' : '';
37
+ if (o.act && x) return '<span class="' + cls + '"' + more + '><button type="button" class="chip-main" data-act="' + o.act + '"' + (o.data || '') + '>' + body + '</button>' + x + '</span>'; /* 能点开又能移除:点名字打开,× 移除 */
38
+ if (o.disabled) return '<button type="button" class="' + cls + '" aria-disabled="true" data-tip="' + h(o.disabled) + '"' + (o.tone ? ' data-tone="' + h(o.tone) + '"' : '') + (o.attrs || '') + pr + '>' + body + '</button>';
39
+ return o.act ? '<button type="button" class="' + cls + '" data-act="' + o.act + '"' + (o.data || '') + more + pr + '>' + body + x + '</button>' : '<span class="' + cls + '"' + more + '>' + body + x + '</span>';
40
+ }
41
+ /* PDL 里声明了 ⋯ 菜单的节点(type: more / prop: menu / 行的 ⋯)画出来的元素都带这个标记:右键找菜单主人只认它(见下面的 contextmenu) */
42
+ const MENU_DECL = ' data-menu-decl';
43
+ /* ⋯ 的档位(PDL size):s 和行里的小按钮一样高(默认),m 和同一行的普通按钮一样高;高度是按钮的控件高度 token */
44
+ function moreBtn(key, data, label, size) { return btn(label || tc('common.moreActions'), { iconOnly: true, icon: 'more', act: 'menu', data: ' data-menu="' + key + '"' + (data || '') + MENU_DECL, sm: size !== 'm' }); }
45
+ /* 开关:label 是它的名字——只给读屏,开关旁边不写字(开关本身就表达了开 / 关,不写「启用」「已启用」);要说明的写 tip(提示) */
46
+ function sw(on, act, data, label, disabled) { return swBtn(on, act, data, label, disabled); }
47
+ function swBtn(on, act, data, label, disabled) { return '<button' + (disabled ? ' disabled' : '') + ' type="button" class="switch" role="switch" aria-checked="' + (on ? 'true' : 'false') + '" aria-label="' + h(label || tc('control.enable')) + '" data-act="' + act + '"' + (data || '') + '><span></span></button>'; }
48
+ /* 开关的开 / 关过渡(组件库,所有开关共用一处):点下去先在原节点上翻 aria-checked,过渡就在这个节点上开始;
49
+ 紧跟着的整页重画由引擎的节点复用留住这个节点(reuseHold),不换成一个已经在终态的新节点 */
50
+ document.addEventListener('click', function (e) {
51
+ const el = e.target.closest && e.target.closest('.switch'); if (!el || el.disabled || el.closest('.layer-covered, .edit-layout')) return;
52
+ el.setAttribute('aria-checked', String(el.getAttribute('aria-checked') !== 'true')); getComputedStyle(el.firstElementChild || el).transform; /* 原地翻过来,过渡从这一帧开始 */
53
+ reuseHold(el);
54
+ }, true);
55
+ /* 分段控件 */
56
+ function seg(items, act, kind, label, data) {
57
+ return segBar(items.map(function (it) { return segButton(it, it.active, act, data); }).join(''), kind, label);
58
+ }
59
+ function segBar(html, kind, label) {
60
+ return '<div class="' + (kind || 'seg') + '" role="group"' + (label ? ' aria-label="' + h(label) + '"' : '') + '>' + html + '</div>';
61
+ }
62
+ function segButton(it, active, act, data) {
63
+ const g = it.g != null && it.g !== '' ? ' data-g="' + h(it.g) + '"' : '';
64
+ return '<button type="button" aria-pressed="' + !!active + '"' + (it.why ? ' aria-disabled="true" data-tip="' + h(it.why) + '"' : ' data-act="' + h(act) + '"' + (data || '')) + g + ' data-v="' + h(it.v) + '">' + h(it.label) + (it.count != null ? qty(it.count, it.warn) : '') + '</button>';
65
+ }
66
+
67
+ /* 返回:通用组件。工作台的“‹ 来源”、区域被占用时的“‹ 返回”都用它 */
68
+ /* 展开指示(组件库,唯一一个):分组、树、手风琴、工作台折叠段、过程记录的“展开”都用它——向右的箭头,展开时转 90°(由所在按钮的 aria-expanded 或 data-open 决定,开关只改属性)。
69
+ 内容折叠(消息中间 / 底部折叠、排队“还有 N 条”)是另一个角色,用 foldTg */
70
+ function twisty(open) { return '<span class="tw" data-open="' + !!open + '" aria-hidden="true">' + icon('right', 14) + '</span>'; } /* 展开指示只有一个尺寸 */
71
+ /* 下拉按钮:文字 + ▾,点开菜单 menu(pressed 表示筛选生效中) */
72
+ function dropBtn(label, menu, o) { o = o || {}; return '<button type="button" class="pdl-menu-button" data-act="' + (o.act || 'menu') + '" data-menu="' + menu + '"' + (o.pressed ? ' aria-pressed="true"' : '') + (o.tip ? ' data-tip="' + h(o.tip) + '"' : '') + '><span class="pdl-ellipsis">' + h(label) + '</span>' + icon('down', 12) + '</button>'; }
73
+ /* 可滚动列表的容器(二级栏里的对话列表) */
74
+ /* 现有筛选下拉按钮的 PDL 入口;菜单和文案声明在主题里。 */
75
+ PDL_COMPONENTS.dropBtn = function (p, sc, root) { return dropBtn(pv(p.label, sc, root), menuLive(pvMenu(p.items, sc, root)), { tip: pv(p.tip, sc, root), pressed: pv(p.pressed, sc, root) }); };
76
+ PDL_COMPONENTS.dropBtn.catalog = { g: 'basics', props: { label: '$.label', items: [{ label: '$.title', act: 'noop' }] } };
77
+ function copyFlash(el) {
78
+ const g = el && el.querySelector && el.querySelector('svg'); if (!g) return;
79
+ const was = g.outerHTML, sz = g.getAttribute('width') || 14;
80
+ el.setAttribute('data-copied', ''); g.outerHTML = icon('check', +sz);
81
+ setTimeout(function () { if (!el.isConnected) return; el.removeAttribute('data-copied'); const c = el.querySelector('svg'); if (c) c.outerHTML = was; }, ms('--hold-copied'));
82
+ }
83
+
84
+ /* { act, args } → data-act + data-*(操作的统一写法) */
85
+ function wgAct(a) { return a ? actAttrs(a.act, a.args) : ''; }
86
+ /* 一个图标按钮:{ label, icon, act, args, pressed, tip, primary } */
@@ -0,0 +1,130 @@
1
+ /* 边界:一个含义一个组件、不为接口定制、不按位置推导样式 */
2
+ /* 胶囊:执行道和状态的胶囊、胶囊堆 */
3
+ 'use strict';
4
+
5
+
6
+ /* 胶囊:收起时范围刚好是一个圆(只露 lead),悬停展开成两端半圆的长条,露出 body。
7
+ lead 和 body 都是内容(通常是身份 + 状态 + 操作),由使用方按胶囊的规则选择:收起时只给头像。
8
+ 展开浮在上层,不挤开旁边的元素;离开后停 --reveal-hold 再收回。
9
+ o: { lead, body, actions, act, data, tip, cls, style } */
10
+ function capsule(o) {
11
+ /* dir: 'right'(默认,向右展开)| 'left'(底贴住右边,内容从头像左侧长出来)——胶囊朝它所在的那一侧展开;
12
+ 有展开内容时不再加原生提示(展开的内容就是提示),只留给读屏的 aria-label */
13
+ const body = (o.body || '') + (o.actions || '');
14
+ const tip = o.tip ? (body ? ' aria-label="' + h(o.tip) + '"' : ' data-tip="' + h(o.tip) + '"') : '';
15
+ const action = o.act ? ' data-act="' + o.act + '"' + (o.data || '') : '';
16
+ /* 有多个操作时,让头像和行尾按钮各自接受键盘焦点;点文字仍执行打开动作。 */
17
+ const leadButton = o.act && o.actions;
18
+ const lead = leadButton ? '<button type="button" class="cap-lead"' + action + tip + '>' + o.lead + '</button>' : '<span class="cap-lead">' + o.lead + '</span>';
19
+ return '<div class="cap' + (o.dir === 'left' ? ' cap-left' : '') + (o.cls ? ' ' + o.cls : '') + '"' + (o.style ? ' style="' + o.style + '"' : '') + action + (leadButton ? '' : ' tabindex="0"' + (o.act ? ' role="button"' : '') + tip) + '>' +
20
+ '<span class="cap-pill">' + lead + (body ? '<span class="cap-x">' + body + '</span>' : '') + '</span></div>';
21
+ }
22
+
23
+ /* 胶囊堆叠:几个胶囊叠在一起,每项占一个固定的位、压住相邻一项的一半,只露头像。向右长的(输入框、左边消息下面)后一项压前一项,生长端的最后一项完整露出;
24
+ 向左长的(你的消息下面,dir: 'left')镜像:前一项压后一项。悬停一项:它升到最上层、只有它自己向生长方向打开文字(名字 状态 时间;头像在贴住的那一端,向左长的头像在右——布局镜像,文字仍从左往右读),
25
+ 盖住生长方向上的邻居;位置不重排,同一时刻只有一项展开。
26
+ 展开的层浮在上面(浮层层级),可以盖住旁边的元素;静止时按正常排版占位,不和邻居重叠。size:s(消息下面)| m(输入框上) */
27
+ function capStack(items, o) {
28
+ o = o || {}; if (!items.length) return '';
29
+ return '<span class="rstack' + (o.dir === 'left' ? ' end' : '') + (o.size === 'm' ? ' m' : '') + '" style="--n:' + items.length + '"' + (o.label ? ' aria-label="' + h(o.label) + '"' : '') + '><span class="rstack-in">' +
30
+ items.map(function (it, i) { return capsule(Object.assign({}, it, { dir: o.dir, style: (it.style ? it.style + ';' : '') + '--z:' + (o.dir === 'left' ? items.length - i : i + 1) })); }).join('') + '</span></span>';
31
+ }
32
+
33
+ /* 横向滚动道里的胶囊(组件库):道会裁掉展开层,所以悬停时把胶囊本体(.cap-pill)作为 popover 显示在顶层,锚在自己的胶囊上——节点不搬、不留占位。
34
+ 展开态是胶囊本体上的 data-hot(指针在上面),展开 / 收起的过渡照常由样式驱动;离开后去掉 data-hot(样式里收起先停 --reveal-hold),收完再退出顶层。
35
+ 最后悬停的在最上层(重新进入顶层)。悬停中的胶囊按位置键(loopKey,和节拍同一个)记在 CAP_HOT,收回的计时按键找到当时的那个胶囊。
36
+ 整页重画把节点移出过文档时浏览器会关掉它的顶层状态(不发事件):没在顶层的本体就是普通的胶囊本体(样式不藏它),指针一动就重新进入顶层 */
37
+ const CAP_TOP = '.scroll-x .cap', CAP_HOT = {}; /* 位置键 → 收回的计时(0 = 指针还在上面) */
38
+ function capPill(cap) { return cap && cap.querySelector(':scope > .cap-pill'); }
39
+ /* 普通胶囊伸到滚动区的可见边;进入顶层的胶囊伸到视口边。 */
40
+ function capFit(cap) {
41
+ const pill = capPill(cap), { left, right } = cap.getBoundingClientRect();
42
+ const viewport = document.documentElement.clientWidth, scroll = !cap.matches(CAP_TOP) && cap.closest('.scroll');
43
+ const bounds = scroll ? scroll.getBoundingClientRect() : { left: 0, right: viewport };
44
+ const room = cap.classList.contains('cap-left') ? right - Math.max(0, bounds.left) : Math.min(viewport, bounds.right) - left;
45
+ pill.style.setProperty('--cap-room', Math.max(0, room) + 'px');
46
+ }
47
+ function capLeave(cap) {
48
+ const k = loopKey(cap), pl = capPill(cap);
49
+ pl.removeAttribute('data-hot');
50
+ clearTimeout(CAP_HOT[k]);
51
+ CAP_HOT[k] = setTimeout(function () { delete CAP_HOT[k]; const c = capFind(k); if (c && !c.contains(document.activeElement)) capOff(c); }, ms('--reveal-hold') + ms('--dur-med'));
52
+ }
53
+ function capLift(cap, hot) {
54
+ const pl = capPill(cap); if (!pl) return;
55
+ if (pl.matches(':popover-open')) pl.hidePopover(); /* 已经在顶层:重新进入,升到最上面 */
56
+ pl.setAttribute('popover', 'manual'); pl.showPopover();
57
+ pl.toggleAttribute('data-hot', hot);
58
+ }
59
+ function capOff(cap) { const pl = capPill(cap); if (!pl) return; pl.removeAttribute('data-hot'); if (pl.matches(':popover-open')) pl.hidePopover(); pl.removeAttribute('popover'); }
60
+ function capFind(k) { return Array.prototype.find.call(document.querySelectorAll(CAP_TOP), function (c) { return loopKey(c) === k; }); }
61
+ document.addEventListener('pointerover', function (e) {
62
+ if (e.target.closest && e.target.closest('.edit-layout')) return; /* 编辑布局是只读的:悬停不展开(看 body 上的 edit-layout) */
63
+ const cap = e.target.closest ? e.target.closest('.cap') : null; if (!cap || cap.contains(e.relatedTarget)) return;
64
+ capFit(cap);
65
+ if (!cap.matches(CAP_TOP)) return;
66
+ const k = loopKey(cap); clearTimeout(CAP_HOT[k]); CAP_HOT[k] = 0;
67
+ capLift(cap, true);
68
+ });
69
+ document.addEventListener('pointerout', function (e) {
70
+ const cap = e.target.closest ? e.target.closest(CAP_TOP) : null;
71
+ if (cap && !cap.contains(e.relatedTarget)) capLeave(cap);
72
+ });
73
+ document.addEventListener('focusin', function (e) {
74
+ const el = e.target, cap = el.closest('.cap');
75
+ if (!cap || S.editLayout) return;
76
+ if (!cap.contains(e.relatedTarget)) {
77
+ capFit(cap);
78
+ if (cap.matches(CAP_TOP) && !capPill(cap).matches(':popover-open')) capLift(cap, false);
79
+ }
80
+ if (el.matches(':focus-visible')) {
81
+ const text = (el.matches('.cap-lead') ? cap : el).querySelector('.cap-text');
82
+ if (text) tipArm(text);
83
+ }
84
+ });
85
+ document.addEventListener('focusout', function (e) {
86
+ const cap = e.target.closest(CAP_TOP);
87
+ if (cap && !cap.contains(e.relatedTarget) && !capPill(cap).hasAttribute('data-hot')) capLeave(cap);
88
+ });
89
+ window.addEventListener('resize', function () {
90
+ document.querySelectorAll('.cap:is(:hover, :focus-within, .tap-on, .rstack.tap-on .tap-cap, :has(> .cap-pill:is([data-hot], :focus-within)))').forEach(capFit);
91
+ });
92
+ /* 指针点了展开层里的东西:动作照常执行,展开层立刻收回;键盘可继续走到下一个操作。 */
93
+ document.addEventListener('click', function (e) { const cap = e.target.closest ? e.target.closest(CAP_TOP) : null; if (!cap || !e.detail) return; const k = loopKey(cap); setTimeout(function () { clearTimeout(CAP_HOT[k]); delete CAP_HOT[k]; const c = capFind(k); if (c) capOff(c); }, 0); });
94
+
95
+ /* ───────── 消息卡片(msgFrame):消息流里每条消息的外壳,组件库组件 ─────────
96
+ 节点模板只绑定字段、给出正文块;外壳的结构只在这里:
97
+ frame msg(含作者行的消息或自己的气泡)| line(系统类卡片)| day(日期分隔)| typing(正在回复)| bare(原样)
98
+ who time badges quote 作者行(quote = 回复引用 replyRef 的数据 { mid, from, text, state },点了跳到原文)
99
+ card bubble(正文包在卡片里)| none(正文块自己就是卡片,如来信、提问)
100
+ body 卡片里的内容;below 卡片下方(批注、过程记录)
101
+ delivery 投递状态胶囊({ who, state, time, detail, open: { act, args } });点击只执行声明的打开动作
102
+ tags chips 你的消息上方的标签和引用
103
+ icon title 系统类卡片
104
+ emph 跳转强调(卡片边框闪一圈主题色);picking / picked 多选
105
+ acts 消息工具条(来自“消息操作”插槽),side 决定靠哪边 */
106
+ /* 投递状态(A 发给 B,A 的消息下方):已投递 B · 时间 / 已读 B · 时间;B 处理中时胶囊持续闪烁,直到 B 这一轮进入终态。
107
+ 悬停不显示正文(正文就在当前消息里)。胶囊朝它所在的一侧展开(猫的消息向右,你的消息向左) */
108
+ /* 投递状态的文案:已投递 → 已读;处理中“收到,正在回…”;核对中 / 没确认收到 / 没送到 */
109
+ /* 投递状态的字在文案包 delivery 里(键和接口的投递状态同名) */
110
+ /* 目标是对话的胶囊(跨对话投递):收起只露对话图标;悬停展开“已投递 → 对话名 · 时间”;点了跳到目标对话里的那一条 */
111
+ function capThread(d, dir, verb) {
112
+ if (typeof d.time === 'number') d = Object.assign({}, d, { time: FORMATS.hm(d.time) });
113
+ return capsule({ dir: dir, cls: 'cap-sm cap-thread ' + (d.state || ''), act: 'msgJump', data: ' data-mid="' + h(d.mid || '') + '" data-t="' + h(d.thread) + '"', tip: verb + ' ' + d.title + (d.time ? ' · ' + d.time : ''),
114
+ lead: '<span class="cap-ic">' + icon('chat', 11) + '</span>', body: '<span class="cap-state">' + h(verb) + '</span> <b>' + h(d.title) + '</b>' + (d.time ? ' <span class="num faint">· ' + h(d.time) + '</span>' : '') });
115
+ }
116
+ function capText(html) { return '<span class="cap-text">' + html + '</span>'; }
117
+ /* 状态胶囊(一个组件,两档大小:size 'l' 在输入框上、默认 s 在消息下方):输入框左上角“正在执行的成员”、你的消息下方的投递 / 已读、成员 A 发给 B 时 A 消息下方 B 的收到 / 已读 / 处理中,都是它。
118
+ 只有文字随场景不同;头像、执行中的扩散圈(同一动效、同一节拍)、叠放、展开方式都一样。展开后的一行永远是 [头像] 名字 状态 时间(st 可以带标记时 html 为真) */
119
+ function capWho(d, st, extra, html, size) {
120
+ if (typeof d.time === 'number') d = Object.assign({}, d, { time: FORMATS.hm(d.time) });
121
+ const w = whoInfo(d.who), stTxt = html ? st.replace(/<[^>]+>/g, '') : st;
122
+ /* 执行中 / 卡住画在头像上:头像组件自己从成员的实时执行状态读,调用方不传 */
123
+ return { cls: (size === 'm' ? 'cap-m' : 'cap-sm') + ' scap ' + (extra || ''), style: whoVar(d.who), tip: w.name + ' ' + stTxt + (d.time ? ' · ' + d.time : ''),
124
+ lead: whoAva(d.who, { size: size === 'm' ? 'm' : 's', tip: false, live: d.live }), body: capText('<b>' + h(w.name) + '</b>' + (w.handle ? ' <span class="faint">' + h(w.handle) + '</span>' : '') + ' <span class="cap-state">' + (html ? st : h(st)) + '</span>' + (d.time ? ' <span class="num faint">' + h(d.time) + '</span>' : '')) };
125
+ }
126
+ /* ───────── 目录登记:这个文件里的组件 ───────── */
127
+ Object.assign(LIB_CATALOG, {
128
+ capsule: { g: 'identity', inline: true, via: ['type:capsules', 'type:notices', 'prop:delivery', 'prop:recv'], ex: function (s) { const r = s.runners[0]; return capsule(capWho({ who: r.who }, r.state, '', false, 'm')); } },
129
+ capStack: { g: 'identity', inline: true, via: ['type:capsules', 'prop:delivery'], ex: function (s) { return capStack(s.runners.concat([{ who: s.extraRunner.who, state: s.statusText.info }]).map(function (r) { return capWho({ who: r.who }, r.state); }), { label: s.title }); } }
130
+ });
@@ -0,0 +1,287 @@
1
+ /* 边界:一个含义一个组件、不为接口定制、不按位置推导样式 */
2
+ /* 图表:关系图、柱状图 */
3
+ 'use strict';
4
+
5
+ /* ───────── 关系图:节点 + 连线(SVG),可选图例和拖动平移 ─────────
6
+ { label, view: [x, y, w, h], nodes: [{ id, x, y, text, tip, shape: 'card'|'bubble', tone, on, dim, hub, act, args }],
7
+ edges: [{ from: [x, y], to: [x, y], via: [[x, y]], dash, arrow }], legend: { items: [{ tone, label }], tail }, pan: { act }, scroll, empty }
8
+ item:节点字段的模板(prefix / limit 是文字前缀 / 截断长度);edge:连线字段的模板。
9
+ 没给节点坐标时按卡片网格摆放,zoom / offset 是用户的缩放和平移状态;给了 view / 坐标的照用。scroll 保留节点可读大小,视口可滚动和拖动。
10
+ card:圆角块 + 状态点 + 名字(依赖图);bubble:圆 + 名字在下(知识图谱)。拖动平移结束时执行 pan.act(带 x / y) */
11
+ function graphNode(n) {
12
+ const cls = 'g-node ' + (n.shape || 'card') + (n.on ? ' on' : '') + (n.dim ? ' dim' : '') + (n.hub ? ' hub' : '');
13
+ const open = '<g class="' + cls + '"' + wgAct(n) + ' role="button" tabindex="0" aria-label="' + h(n.tip || n.text) + '">';
14
+ if (n.shape === 'bubble') return open + '<circle cx="' + n.x + '" cy="' + n.y + '" r="' + (n.hub ? 24 : 15) + '"/><text x="' + n.x + '" y="' + (n.y + 40) + '" text-anchor="middle">' + h(n.text) + '</text></g>';
15
+ return open + '<title>' + h(n.tip || n.text) + '</title><rect x="' + (n.x - 70) + '" y="' + (n.y - 18) + '" width="146" height="36" rx="8"/><circle class="g-st ' + (n.tone || 'idle') + '" cx="' + (n.x - 56) + '" cy="' + n.y + '" r="4"/>' +
16
+ '<foreignObject x="' + (n.x - 46) + '" y="' + (n.y - 18) + '" width="112" height="36"><div class="g-card-text" xmlns="http://www.w3.org/1999/xhtml">' + h(n.text) + '</div></foreignObject></g>';
17
+ }
18
+ function graphEdge({ from, to, via, dash, arrow }) {
19
+ const stroke = dash ? ' stroke-dasharray="' + dash + '"' : '';
20
+ let line;
21
+ if (via?.length) {
22
+ const points = [from, ...via, to];
23
+ let path = 'M ' + from.join(' ');
24
+ for (let i = 1; i < points.length - 1; i++) {
25
+ const [x, y] = points[i];
26
+ const toward = function ([px, py]) {
27
+ const distance = Math.hypot(px - x, py - y);
28
+ const fraction = distance > 12 ? 6 / distance : .5;
29
+ return [x + (px - x) * fraction, y + (py - y) * fraction].join(' ');
30
+ };
31
+ path += ' L ' + toward(points[i - 1]) + ' Q ' + x + ' ' + y + ' ' + toward(points[i + 1]);
32
+ }
33
+ line = '<path class="g-curve" d="' + path + ' L ' + to.join(' ') + '"' + stroke + '/>';
34
+ } else {
35
+ line = '<line x1="' + from[0] + '" y1="' + from[1] + '" x2="' + to[0] + '" y2="' + to[1] + '"' + stroke + '/>';
36
+ }
37
+ if (!arrow) return line;
38
+ const start = via?.at(-1) ?? from;
39
+ const angle = Math.atan2(to[1] - start[1], to[0] - start[0]) * 180 / Math.PI;
40
+ return line + '<path class="g-arrow" d="M -6 -4 L 0 0 -6 4" transform="translate(' + to.join(' ') + ') rotate(' + angle + ')"/>';
41
+ }
42
+ PDL_COMPONENTS.graph = function (g, sc, root) {
43
+ const nodes = pvList(g.nodes, sc, root).map(function (data, i) {
44
+ const n = g.item ? Object.assign({}, data, pvArgsObj(g.item, data, root), { args: pvArgsObj(g.item.args, data, root) }) : Object.assign({}, data);
45
+ if (g.item && g.item.limit) n.text = String(n.text).slice(0, g.item.limit);
46
+ if (g.item && g.item.prefix) n.text = tc('graph.nodeText', pv(g.item.prefix, data, root), n.text);
47
+ if (n.x == null) n.x = 75 + i % 3 * 155;
48
+ if (n.y == null) n.y = 40 + Math.floor(i / 3) * 70;
49
+ return n;
50
+ }), pos = {}; nodes.forEach(function (n) { pos[n.id] = [n.x, n.y]; });
51
+ const edges = pvList(g.edges, sc, root).map(function (data) {
52
+ const e = g.edge ? pvArgsObj(g.edge, data, root) : data;
53
+ return { ...e, from: typeof e.from === 'string' ? pos[e.from] : e.from, to: typeof e.to === 'string' ? pos[e.to] : e.to };
54
+ });
55
+ const legend = g.legend ? '<p class="vw-label g-legend">' + (g.item ? pvItems(g.legend.items, sc, root) : g.legend.items).map(function (x) { return '<span>' + lrDot(x.tone) + h(x.label) + '</span>'; }).join('') + (g.legend.tail ? '<span>· ' + (g.item ? pvText(g.legend.tail, sc, root) : h(g.legend.tail)) + '</span>' : '') + '</p>' : '';
56
+ if (!nodes.length) return legend + emptyState((g.item ? pv(g.empty, sc, root) : g.empty) || '');
57
+ const zoom = pv(g.zoom, sc, root) || 1, offset = pv(g.offset, sc, root) || [0, 0], view = pv(g.view, sc, root) || [-offset[0], -offset[1], 460 / zoom, Math.max(160, 20 + Math.ceil(nodes.length / 3) * 70) / zoom];
58
+ const size = g.scroll ? ' style="--graph-width:' + Number(view[2]) + 'px"' : '';
59
+ const role = nodes.some(function (n) { return n.act; }) ? 'group' : 'img';
60
+ const svg = '<svg class="graph' + (g.pan ? ' pan' : '') + '" viewBox="' + view.join(' ') + '"' + size + ' role="' + role + '" aria-label="' + (g.item ? pvText(g.label, sc, root) : h(g.label)) + '"' + (g.pan ? ' data-pan="' + h(g.pan.act) + '"' : '') + '>' +
61
+ edges.map(graphEdge).join('') +
62
+ nodes.map(graphNode).join('') + '</svg>';
63
+ return legend + '<div class="group g-wrap' + (g.scroll ? ' g-scroll scroll vw-scroll' : '') + '">' + svg + '</div>';
64
+ };
65
+ /* 平移过程中只改视口位置,配置了 pan.act 的图在松手时保存 viewBox。 */
66
+ (function () {
67
+ let drag = null;
68
+ document.addEventListener('pointerdown', function (e) {
69
+ const g = e.target.closest?.('svg.graph');
70
+ if (!g || e.button !== 0 || drag?.moved) return;
71
+ drag = null;
72
+ const start = { pointer: e.pointerId, x: e.clientX, y: e.clientY };
73
+ if (g.dataset.pan) {
74
+ if (e.target.closest('.g-node')) return;
75
+ const vb = g.getAttribute('viewBox').split(' ').map(Number);
76
+ drag = { ...start, vb: vb, scale: vb[2] / g.getBoundingClientRect().width, el: g };
77
+ return;
78
+ }
79
+ const box = g.closest('.g-scroll');
80
+ if (e.pointerType !== 'mouse' || !box || (box.scrollWidth <= box.clientWidth && box.scrollHeight <= box.clientHeight)) return;
81
+ drag = { ...start, el: box, left: box.scrollLeft, top: box.scrollTop, moved: false };
82
+ });
83
+ document.addEventListener('pointermove', function (e) {
84
+ if (!drag || drag.pointer !== e.pointerId) return;
85
+ if (!drag.el.isConnected || (e.pointerType === 'mouse' && !(e.buttons & 1))) { end(e); return; }
86
+ const dx = e.clientX - drag.x, dy = e.clientY - drag.y;
87
+ if (drag.vb) {
88
+ const x = drag.vb[0] - dx * drag.scale, y = drag.vb[1] - dy * drag.scale;
89
+ drag.el.setAttribute('viewBox', [x, y, drag.vb[2], drag.vb[3]].join(' ')); drag.at = [x, y];
90
+ return;
91
+ }
92
+ if (!drag.moved) {
93
+ // 一旦形成拖动,释放目标为滚动容器。未达到距离时仍可点击节点。
94
+ if (Math.max(Math.abs(dx), Math.abs(dy)) < 5) return;
95
+ drag.el.setPointerCapture(e.pointerId);
96
+ drag.el.classList.add('g-dragging');
97
+ drag.moved = true;
98
+ }
99
+ drag.el.scrollLeft = drag.left - dx;
100
+ drag.el.scrollTop = drag.top - dy;
101
+ });
102
+ function end(e) {
103
+ if (!drag || drag.pointer !== e.pointerId) return;
104
+ const d = drag; drag = null;
105
+ if (d.moved) d.el.classList.remove('g-dragging');
106
+ if (e.type === 'pointerup' && d.at) actFn(d.el.dataset.pan)?.({ x: d.at[0], y: d.at[1] });
107
+ }
108
+ for (const type of ['pointerup', 'pointercancel', 'lostpointercapture']) document.addEventListener(type, end);
109
+ })();
110
+
111
+ /* ───────── 柱状图:一组按天 / 按项的柱,柱里可以叠一段 ─────────
112
+ { label, max, items: [{ label, value, part, tip }] };from / item 可声明 label / tip。part:叠在柱子底部的那一段(同一单位) */
113
+ PDL_COMPONENTS.bars = function (p, sc, root) {
114
+ const xs = pvList(p.from || p.items, sc, root), max = pv(p.max, sc, root) || Math.max.apply(null, xs.map(function (d) { return d.value; }).concat([1]));
115
+ return '<div class="group bars" role="img" aria-label="' + (p.item ? pvText(p.label, sc, root) : h(p.label)) + '">' + xs.map(function (d) {
116
+ const tip = p.item ? pvText(p.item.tip, d, root) : h(d.tip || '');
117
+ const label = p.item ? pvText(p.item.label, d, root) : h(d.label);
118
+ return '<div' + (tip ? ' data-tip="' + tip + '"' : '') + '><span style="--u-height:' + Math.round(d.value / max * 100) + '%" class="u-v-height">'
119
+ + '<i style="--u-height:' + (d.value ? Math.round((d.part || 0) / d.value * 100) : 0) + '%" class="u-v-height"></i></span>'
120
+ + '<em class="pdl-ellipsis">' + label + '</em></div>';
121
+ }).join('') + '</div>';
122
+ };
123
+ /* ───────── 折线图:时间序列百分比,可在窗口重置处断开为虚线过渡 ─────────
124
+ { label, min, max, xMin, xMax, xLabels, yLabels, series: [{ name, color, points: [{ x, y, tip, reset }] }], empty } */
125
+ PDL_COMPONENTS.lineChart = function (p) {
126
+ const series = Array.isArray(p.series) ? p.series : [];
127
+ const all = [];
128
+ series.forEach(function (s) { (s.points || []).forEach(function (point) { if (Number.isFinite(point.x) && Number.isFinite(point.y)) all.push(point); }); });
129
+ if (!all.length) return emptyState(p.empty || '');
130
+ const palette = [
131
+ 'oklch(0.62 0.17 250)', 'oklch(0.62 0.17 145)', 'oklch(0.64 0.18 35)',
132
+ 'oklch(0.58 0.16 305)', 'oklch(0.62 0.14 195)', 'oklch(0.56 0.16 15)'
133
+ ];
134
+ const width = 600, height = 176, left = 40, right = 12, top = 10, bottom = 26;
135
+ const plotW = width - left - right, plotH = height - top - bottom;
136
+ const min = Number.isFinite(p.min) ? Number(p.min) : 0;
137
+ const max = Number.isFinite(p.max) ? Number(p.max) : 100;
138
+ let xMin = Number.isFinite(p.xMin) ? Number(p.xMin) : Math.min.apply(null, all.map(function (point) { return point.x; }));
139
+ let xMax = Number.isFinite(p.xMax) ? Number(p.xMax) : Math.max.apply(null, all.map(function (point) { return point.x; }));
140
+ if (xMax <= xMin) { xMin -= 1; xMax += 1; }
141
+ const xOf = function (x) { return left + (x - xMin) / (xMax - xMin) * plotW; };
142
+ const yOf = function (y) { return top + (1 - (Math.max(min, Math.min(max, y)) - min) / (max - min || 1)) * plotH; };
143
+ const yTicks = Array.isArray(p.yLabels) && p.yLabels.length ? p.yLabels : [
144
+ { value: max, label: max + '%' }, { value: min + (max - min) / 2, label: Math.round(min + (max - min) / 2) + '%' }, { value: min, label: min + '%' }
145
+ ];
146
+ const xLabels = Array.isArray(p.xLabels) ? p.xLabels : [];
147
+ const xText = function (label, x, anchor) {
148
+ return label == null || label === '' ? '' : '<text class="lchart-axis" x="' + x.toFixed(1) + '" y="' + (height - 6) + '" text-anchor="' + anchor + '">' + h(label) + '</text>';
149
+ };
150
+ let svg = '<svg class="lchart-svg" viewBox="0 0 ' + width + ' ' + height + '" role="img" aria-label="' + h(p.label || '') + '">';
151
+ yTicks.forEach(function (tick) {
152
+ const y = yOf(tick.value);
153
+ svg += '<line class="lchart-grid" x1="' + left + '" y1="' + y.toFixed(1) + '" x2="' + (width - right) + '" y2="' + y.toFixed(1) + '"/>'
154
+ + '<text class="lchart-axis" x="' + (left - 5) + '" y="' + (y + 3).toFixed(1) + '" text-anchor="end">' + h(tick.label) + '</text>';
155
+ });
156
+ svg += xText(xLabels[0], left, 'start') + xText(xLabels[1], left + plotW / 2, 'middle') + xText(xLabels[2], width - right, 'end');
157
+ series.forEach(function (one, seriesIndex) {
158
+ const color = one.color || palette[seriesIndex % palette.length];
159
+ const points = (one.points || []).filter(function (point) { return Number.isFinite(point.x) && Number.isFinite(point.y); })
160
+ .sort(function (a, b) { return a.x - b.x; });
161
+ if (!points.length) return;
162
+ const xy = function (point) { return xOf(point.x).toFixed(2) + ',' + yOf(point.y).toFixed(2); };
163
+ let run = [points[0]];
164
+ const finish = function () {
165
+ if (run.length > 1) svg += '<polyline class="lchart-line" style="stroke:' + h(color) + '" points="' + run.map(xy).join(' ') + '"/>';
166
+ };
167
+ for (let index = 1; index < points.length; index++) {
168
+ const point = points[index];
169
+ if (point.reset) {
170
+ const prior = points[index - 1];
171
+ svg += '<line class="lchart-reset" x1="' + xOf(prior.x).toFixed(2) + '" y1="' + yOf(prior.y).toFixed(2) + '" x2="' + xOf(point.x).toFixed(2) + '" y2="' + yOf(point.y).toFixed(2) + '"/>';
172
+ finish();
173
+ run = [point];
174
+ } else run.push(point);
175
+ }
176
+ finish();
177
+ let dots = points;
178
+ if (points.length > 80) {
179
+ const step = (points.length - 1) / 79;
180
+ const chosen = new Set();
181
+ for (let index = 0; index < 80; index++) chosen.add(Math.round(index * step));
182
+ points.forEach(function (point, index) { if (point.reset) chosen.add(index); });
183
+ dots = points.filter(function (_, index) { return chosen.has(index); });
184
+ }
185
+ dots.forEach(function (point) {
186
+ svg += '<circle class="lchart-dot" cx="' + xOf(point.x).toFixed(2) + '" cy="' + yOf(point.y).toFixed(2) + '" r="2.2" style="fill:' + h(color) + '"><title>' + h(point.tip || '') + '</title></circle>';
187
+ });
188
+ });
189
+ svg += '</svg>';
190
+ const legend = '<div class="lchart-legend">' + series.map(function (one, index) {
191
+ const color = one.color || palette[index % palette.length];
192
+ return '<span><i class="lchart-swatch" style="background:' + h(color) + '"></i>' + h(one.name || '') + '</span>';
193
+ }).join('') + '</div>';
194
+ return '<div class="lchart">' + legend + svg + '</div>';
195
+ };
196
+ PDL_COMPONENTS.lineChart.catalog = {
197
+ g: 'workbench',
198
+ props: {
199
+ label: '$.label', min: { lit: 0 }, max: { lit: 100 }, xLabels: { lit: ['24h 前', '12h 前', '现在'] },
200
+ series: { lit: [
201
+ { name: '5 小时窗口', points: [{ x: 1, y: 12, tip: '12%' }, { x: 2, y: 38, tip: '38%' }, { x: 3, y: 8, tip: '重置后 8%', reset: true }, { x: 4, y: 21, tip: '21%' }] },
202
+ { name: '7 天窗口', points: [{ x: 1, y: 30, tip: '30%' }, { x: 4, y: 52, tip: '52%' }] }
203
+ ] }
204
+ }
205
+ };
206
+ PDL_COMPONENTS.graph.catalog = { g: 'workbench', props: '$.graph' };
207
+ PDL_COMPONENTS.bars.catalog = { g: 'workbench', props: '$.quota.bars' };
208
+
209
+ /* A shared horizontal time scale. Each row supplies its offset and width as fractions of that scale. */
210
+ PDL_COMPONENTS.waterfall = function (p) {
211
+ const fraction = value => Math.max(0, Math.min(1, Number(value) || 0)) * 100;
212
+ return '<ol class="waterfall" aria-label="' + h(p.label) + '">' + p.items.map(function (row) {
213
+ const depth = Math.max(0, Math.min(8, Number(row.depth) || 0));
214
+ const tip = row.detail ? row.label + '\n' + row.detail : row.label;
215
+ return '<li data-tip="' + h(tip) + '"><span class="waterfall-label pdl-ellipsis" style="--depth:' + depth + '">' + h(row.label) + '</span>'
216
+ + '<span class="waterfall-track" aria-hidden="true"><i' + (row.failed ? ' class="failed"' : '') + ' style="left:' + fraction(row.offset)
217
+ + '%;width:' + fraction(row.width) + '%"></i></span><span class="num">' + h(row.value) + '</span>'
218
+ + '<span class="sr">' + h(row.detail) + '</span></li>';
219
+ }).join('') + '</ol>';
220
+ };
221
+
222
+ /* Ring charts for single values and grouped quotas. */
223
+ function ringColor(pct, at) {
224
+ const p = Math.max(0, Math.min(100, Number(pct) || 0));
225
+ const eff = at > 0 && at < 100 ? Math.min(100, Math.round(p * 100 / at)) : p;
226
+ let hue, l, c;
227
+ if (eff <= 50) {
228
+ const t = eff / 50;
229
+ hue = 152 - t * 62;
230
+ l = 0.62 - t * 0.02;
231
+ c = 0.15 + t * 0.02;
232
+ } else if (eff <= 80) {
233
+ const t = (eff - 50) / 30;
234
+ hue = 90 - t * 50;
235
+ l = 0.60 - t * 0.06;
236
+ c = 0.17 + t * 0.04;
237
+ } else {
238
+ const t = (eff - 80) / 20;
239
+ hue = 40 - t * 20;
240
+ l = 0.54 - t * 0.09;
241
+ c = 0.21 + t * 0.02;
242
+ }
243
+ return 'oklch(' + l.toFixed(3) + ' ' + c.toFixed(3) + ' ' + Math.round(hue) + ')';
244
+ }
245
+ function ringHtml(g, inspect) {
246
+ if (!g) return '';
247
+ const has = g.num != null;
248
+ const pct = has ? Math.max(0, Math.min(100, Math.round(g.num))) : 0;
249
+ const circ = 84.823;
250
+ const dash = (pct / 100 * circ).toFixed(2);
251
+ const label = has ? String(pct) : '—';
252
+ const color = has && pct > 0 ? (g.color || ringColor(pct, g.at)) : '';
253
+ const tip = g.tip ? ' data-tip="' + h(g.tip) + '"' : '';
254
+ return '<span class="hl-ring"' + (pct >= 100 ? ' data-full' : '') + (has ? '' : ' data-empty') +
255
+ tip + (inspect ? ' role="img" tabindex="0"' : '') + (g.aria ? ' aria-label="' + h(g.aria) + '"' : '') + '>' +
256
+ '<svg class="hl-ring-svg" viewBox="0 0 32 32" aria-hidden="true">' +
257
+ '<circle class="hl-ring-track" cx="16" cy="16" r="13.5"/>' +
258
+ (pct > 0 ? '<circle class="hl-ring-arc" cx="16" cy="16" r="13.5" stroke-dasharray="' + dash + ' ' + circ + '" style="stroke:' + color + '"/>' : '') +
259
+ '</svg><span class="hl-ring-v num">' + label + '</span></span>';
260
+ }
261
+ PDL_COMPONENTS.hlGauge = function (p) { return ringHtml(p); };
262
+ PDL_COMPONENTS.hlMemberQuotas = function (q) {
263
+ return '<span class="hl-member-quotas" data-member-quota="' + h(q.id) + '" data-act="">' +
264
+ q.rings.map(function (ring) { return ringHtml(ring, true); }).join('') + '</span>';
265
+ };
266
+ PDL_COMPONENTS.hlQuotas = function (q) {
267
+ if (!q) return '';
268
+ const groups = Array.isArray(q) ? q : (q.groups || []);
269
+ const qLabel = tc('hl.run.quotaLabel');
270
+ if (!groups.length) {
271
+ const tip = tc(q.loading ? 'hl.run.quotaLoading' : 'hl.run.quotaUnavailable');
272
+ return '<dl class="kvg hl-quotas"><dt data-tip="' + h(qLabel) + '">' + h(qLabel) + '</dt><dd><div class="hl-quota-items">' +
273
+ '<div class="hl-quota-item" data-tip="' + h(tip) + '">' +
274
+ ringHtml({ num: null, tip: tip, aria: tip }) + '</div></div></dd></dl>';
275
+ }
276
+ return '<dl class="kvg hl-quotas"><dt data-tip="' + h(qLabel) + '">' + h(qLabel) + '</dt><dd><div class="hl-quota-list">' +
277
+ groups.map(function (g) {
278
+ return '<div class="hl-quota-group">' +
279
+ (g.title ? '<div class="hl-quota-gtitle">' + h(g.title) + '</div>' : '') +
280
+ '<div class="hl-quota-items">' + g.items.map(function (it) {
281
+ const detail = it.resetIn ? '<span class="hl-quota-reset num">Reset: ' + h(it.resetIn) + '</span>' :
282
+ (it.name ? '<span class="hl-quota-reset">' + h(it.name) + '</span>' : '');
283
+ return '<div class="hl-quota-item" data-tip="' + h(it.tip) + '">' +
284
+ ringHtml(it.gauge) + detail + '</div>';
285
+ }).join('') + '</div></div>';
286
+ }).join('') + '</div></dd></dl>';
287
+ };