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,165 @@
1
+ /* 边界:一个含义一个组件、不为接口定制、不按位置推导样式 */
2
+ /* 浮层:菜单、浮窗、对话框、模态框;引擎经组件库画的部件(ENGINE_PARTS)在这里登记 */
3
+ 'use strict';
4
+
5
+ /* ───────── 浮层(组件库):菜单、确认框、浮动小窗、提示 ───────── */
6
+ /* 浮层的壳(组件库唯一的一个):面(阴影、圆角)→ 可选的头(.float-head:标题 / 搜索 + 头上的操作 + ×)→ 里层滚动(.scroll.float-body)→ 可选的尾。
7
+ 菜单、弹出层、启动面板、全部标签、待办、插件小窗都是它,不各写一份头和身。
8
+ o = { cls:面的角色变体(menu / pop / ws-pop / inbox / plugin-float …,登记在 LIB_PARTS.surface),role(缺省 dialog),label,attrs,
9
+ head(头里的内容), body, foot, scroll(里层滚动的额外属性,比如限行数), bare(内容自己就是一块、不套滚动层:取色) } */
10
+ function floatHtml(o) {
11
+ return '<div class="' + o.cls + '" role="' + (o.role || 'dialog') + '"' + (o.label != null ? ' aria-label="' + h(o.label) + '"' : '') + (o.attrs || '') + '>' + (o.head ? '<div class="float-head" data-pop-handle>' + o.head + '</div>' : '') +
12
+ (o.bare ? o.body : '<div class="scroll float-body"' + (o.scroll || '') + '>' + o.body + '</div>') + (o.foot ? '<div class="float-foot">' + o.foot + '</div>' : '') + '</div>';
13
+ }
14
+ /* 既有浮层的 PDL 绑定:壳的角色和内容由声明给出,仍使用同一 floatHtml。 */
15
+ PDL_COMPONENTS.floatHtml = function (o, sc, root) { const label = pv(o.label, sc, root), pop = pv(o.close, sc, root); return floatHtml({ cls: pv(o.className, sc, root), label: label, head: pop ? '<span class="u-strong grow">' + h(label) + '</span>' + popX(pop) : '', body: pvBlocks(o.blocks, sc, root) }); }; /* close:弹窗名,头上是名字和 ×(弹窗声明了 exit x 时) */
16
+ PDL_COMPONENTS.floatHtml.catalog = { g: 'popups', props: { className: 'pop', label: '$.title', blocks: [{ type: 'text', text: '$.sub' }] } };
17
+ /* 菜单(⋯ 打开的那种):m = { k, items: [{ label, lead(前导内容:头像、图标,可选), act, data, danger, cur } | { hr } | { group }] };位置由锚定决定(触发元素是 --menu,见上面的锚定) */
18
+ function menuHtml(m) {
19
+ if (m.html) return floatHtml({ cls: 'menu', attrs: ' id="menu"', label: m.label || '', body: m.html, bare: true }); /* 菜单浮层里放一块组件库内容(取色) */
20
+ /* 分组:菜单项都作用在同一个对象上时不画分组名和分隔线;只有作用对象(范围)不同的项混在一起时,范围变化处画分隔线 + 范围名。
21
+ 数据里用 { scope: 名字 } 标出后面的项属于哪个范围;危险项只靠危险色,不单独隔开 */
22
+ let cur = '';
23
+ const rows = [];
24
+ /* 下拉的选项多(超过一屏)或能填自定义值时,菜单顶上有一个筛选框:只筛已有的选项(文字、说明、值) */
25
+ const q = (m.q || '').trim().toLowerCase(), filter = m.sel && m.items.length > MENU_ROWS;
26
+ m.items.forEach(function (it) { if (it.scope != null && it.label == null) cur = it.scope; else if (!q || (it.label + ' ' + (it.sub || '') + ' ' + (it.data && it.data.v || '')).toLowerCase().indexOf(q) >= 0) rows.push({ it: it, scope: cur }); });
27
+ const many = rows.some(function (r) { return r.scope !== rows[0].scope; });
28
+ return floatHtml({ cls: 'menu', role: 'menu', attrs: ' id="menu"' + (m.span ? ' data-span="' + m.span + '" style="--u-span:var(--span-' + m.span + ')"' : ''),
29
+ head: filter ? search('menu-q', tc('selectMenu.search'), m.q, 'menuQ') : '', scroll: scrollRows(MENU_ROWS, '--ctl-m'), body: rows.map(function (r, i) {
30
+ const it = r.it, d = Object.assign({}, m.k != null ? { k: m.k } : {}, it.data || {});
31
+ const head = many && (i === 0 || r.scope !== rows[i - 1].scope) ? (i ? '<div class="divider" role="separator"></div>' : '') + (r.scope ? lrSection(r.scope, '', { v: 'float' }) : '') : '';
32
+ const b = '<button type="button" role="menuitem" class="' + (it.danger ? 'danger' : '') + '"' + (it.cur ? ' aria-current="true"' : '') + (it.stay ? ' data-stay' : '') + (it.why ? ' aria-disabled="true" data-tip="' + h(it.why) + '"' : actAttrs(it.act, d)) + '>' + (it.lead ? it.lead + ' ' : '') + (it.sub ? '<span class="menu-t">' + h(it.label) + '<span class="menu-sub">' + h(it.sub) + '</span></span>' : h(it.label)) + '</button>';
33
+ /* 项末尾的删除(it.x = { act, args, label },下拉的选项声明的 remove):和项并排的图标按钮,悬停变危险色 */
34
+ /* 项末尾的说明(it.help):同一种行,尾巴是问号提示 */
35
+ return head + (it.x || it.help ? '<div class="menu-row">' + b + (it.x ? btn(it.x.label || tc('common.delete'), { iconOnly: true, sm: true, danger: true, icon: 'delete', act: it.x.act, data: argAttrs(it.x.args) }) : helpTip(it.help)) + '</div>' : b); /* 停用的项:没有动作,悬停说原因 */
36
+ }).join('') });
37
+ }
38
+ /* 确认框:d = { title, help, text, body, ok, danger, focus: 'cancel' | 'confirm' }。没有 ok 的是即时生效的窗口(里面的开关改了就算数):没有底部按钮,关闭只走 × / Esc / 点外面。遮罩、层级、拖动、Esc / × / 取消、默认焦点由弹窗框架给(PDL_POPUPS.dialog);
39
+ 默认焦点在“取消”(安全的那个),声明 focus: 'confirm' 时在确认按钮上,回车就按它 */
40
+ /* 一排按钮的声明(对话框 / 模态的底部、文档上的操作):数组的每一项是 [文字, btn 的选项],或 ['cancel', 弹窗名](取消,走弹窗的离开检查)、
41
+ ['done', 弹窗名](完成 = 关掉这个弹窗);字符串原样用(已经画好的)。应用只给声明,不调用组件 */
42
+ function btnsHtml(x) {
43
+ if (!Array.isArray(x)) return x || '';
44
+ return x.map(function (b) { return b[0] === 'cancel' ? popCancel(b[1]) : b[0] === 'done' ? btn(tc('common.done'), { primary: true, act: 'close', data: ' data-popup="' + b[1] + '"' }) : btn(b[0], b[1]); }).join('');
45
+ }
46
+ /* 对话框里正在填的值读回字段(引擎在重画前、输入时调用 dlgSync → 这里):每种字段的读法属于对话框组件——
47
+ 环境变量表展开时逐行读键和值;选项只读“自定义”那一格;标签、色板、头像、键值、文件自己管状态(通用动作直接改字段),不从页面读;其余按输入框 / 勾选框读 */
48
+ function dialogSync(d) {
49
+ if (d.doc && d.doc.edit) { const t = document.getElementById(d.doc.id); if (t) d.doc.text = t.value; } /* 可改的正文(文档对话框) */
50
+ (d.fields || []).forEach(function (f) {
51
+ if (!f.id) return;
52
+ if (f.env) { if (f.env.open) f.env.rows = f.env.rows.map(function (r, i) { const k = document.getElementById(f.id + '-k' + i), v = document.getElementById(f.id + '-v' + i); return [k ? k.value : r[0], v ? v.value : r[1]]; }); return; }
53
+ if (f.opts) { if (f.opts.custom) { const c = document.getElementById(f.opts.custom.id); if (c) f.opts.custom.value = c.value; } return; }
54
+ if (f.radios) { const r = document.querySelector('input[name="' + f.id + '"]:checked'); if (r) f.value = r.value; return; } /* 单选:重画(校验失败、提交中)后留在选中的那一项 */
55
+ if (f.type === 'switch' || f.chips || f.swatch || f.avatar || f.kv || f.file) return;
56
+ const el = document.getElementById(f.id); if (!el) return;
57
+ if (el.type === 'checkbox') f.checked = el.checked; else f.value = el.tagName === 'TEXTAREA' ? areaValue(el.value, areaBase(f)) : el.value;
58
+ });
59
+ }
60
+ /* 多行框会把换行统一成 \n:没改过的内容交回原文(保留 \r\n),改过才用框里的值 */
61
+ /* 原文:字段声明了 original 就用它,否则记下第一次读回之前的值;中途改过再改回,仍对照最初的原文 */
62
+ function areaBase(f) {
63
+ if (typeof f.original === 'string') return f.original;
64
+ if (f.areaBase === undefined) f.areaBase = f.value;
65
+ return f.areaBase;
66
+ }
67
+ function areaValue(value, original) {
68
+ return typeof original === 'string' && value === original.replace(/\r\n?/g, '\n') ? original : value;
69
+ }
70
+ function dialogHtml(d) {
71
+ /* rows:正文最多几行(容器自己声明;超出在正文里滚),不写就跟内容走;两种都不超出页面 */
72
+ /* noFieldFocus:正文里有自己的一套输入(比如“挂载规则”底部的添加框),刚打开时不要把焦点丢进去、把正文滚到底 */
73
+ /* key:画在哪个弹窗里(缺省是通用对话框 dialog;未保存确认 confirm、对话区的模态窗、主题计算器也是这个组件);alert:要你先回答才能继续(alertdialog);acts:底部按钮的声明(btnsHtml),代替 ok / 取消;
74
+ actions:标题行里 × 前面的操作(头:标题 · 空白 · 操作 · ×);modal: false 不是模态(没有遮罩的工具窗);form:表单名(通用对话框有 ok 提交时默认为 dialog);工具内容只用同一外壳,不隐式成为表单 */
75
+ const k = d.key || 'dialog', tid = 'dlg-t' + (d.key ? '-' + String(d.key).replace(/\W/g, '-') : ''), form = d.form || (!d.key && d.ok ? 'dialog' : ''), tag = form ? 'form' : 'section';
76
+ const body = typeof d.body === 'object' ? pvBlocks([d.body], d, d) : d.body;
77
+ const text = d.text && typeof d.text === 'object' ? pvParts(d.text.parts, d.text.data, d.text.data) : d.text; /* 写成片段的正文先画出来:画出来是空的就和没有正文一样 */ /* 声明的 PDL 正文每次按当前 VM 画,不在打开弹窗时存成一份旧 HTML。 */
78
+ return '<' + tag + ' class="dialog' + (d.wide ? ' dialog-wide' : '') + (d.layout === 'viewport' ? ' dialog-viewport' : d.layout === 'fill' ? ' dialog-fill' : d.layout === 'lightbox' ? ' dialog-lightbox' : '') + (d.span === 'full' ? ' dialog-full' : '') + '"' + (d.rows ? ' style="--dlg-rows: ' + Number(d.rows) + '"' : '') + (d.noFieldFocus ? ' data-no-field-focus' : '') + (d.layout === 'lightbox' ? ' data-fixed data-backdrop' : '') + toneAttr(d.tone || (d.danger ? 'danger' : '')) + ' role="' + (d.alert ? 'alertdialog' : 'dialog') + '"' + (d.modal === false ? '' : ' aria-modal="true"') + ' aria-labelledby="' + tid + '"' + (form ? ' data-form="' + form + '"' : '') + '><div class="dlg-head"><h3 id="' + tid + '">' + h(d.title) + helpTip(d.help) + '</h3>' + (d.actions || '') + popX(k) + '</div>' +
79
+ (text || body || d.fields || d.doc || d.error ? '<div class="dialog-body scroll"' + (d.layout === 'lightbox' ? ' data-backdrop' : '') + '>' + (d.error ? '<p class="ws-danger">' + h(d.error) + '</p>' : '') + (text ? '<p>' + text + '</p>' : '') + (d.panes ? dlgPanes(d.panes) : '') + (d.fields ? d.fields.filter(function (f) { return !f.pane || !d.panes || f.pane === d.panes.cur; }).map(function (f) { return f.block ? pvBlocks([f.block], d, d) : dlgField(f); }).join('') : '') + (d.foot ? dlgFoot(d.foot) : '') + (d.doc ? docBody(d.doc) : '') + (body || '') + '</div>' : '') + (d.acts ? '<div class="acts">' + btnsHtml(d.acts) + '</div>' : d.ok ? '<div class="acts">' + (d.ack ? '' : popCancel(k, d.focus)) + btn(d.ok, { primary: true, danger: !!d.danger, submit: true, data: d.focus === 'confirm' || d.ack ? ' data-autofocus="1"' : '' }) + '</div>' : '') + '</' + tag + '>';
80
+ }
81
+ /* 对话框里的字段:数据描述 { id, label, value, text(只读文本), type: 'switch'(布尔值), placeholder, mono, max, req, area, rows, options, members: [id], none, check } */
82
+ function dlgField(f) {
83
+ if (f.kv) return kvGrid(f.kv.map(function (p) { return [p[0], h(p[1])]; })); /* 只读的几行键值 */
84
+ if (f.control || f.text != null) return field({ id: f.id, label: f.label, text: f.text, control: f.control ? pvControl(f.control, f, f) : undefined,
85
+ req: f.req, help: f.help, foot: dlgFootHtml(f) });
86
+ if (f.opts && !f.label) return dlgSpecial(f);
87
+ if (f.chips || f.swatch || f.color || f.avatar || f.opts || f.env) return field({ label: f.label, control: dlgSpecial(f), req: f.req, help: f.help, foot: dlgFootHtml(f) });
88
+ if (f.type === 'switch') {
89
+ const data = ' id="' + h(f.id) + '"' + argAttrs({ path: 'dlgf.{id}.value', id: f.id });
90
+ return field({ id: f.id, label: f.label, control: sw(f.value, 'toggle', data, f.label, f.disabled), req: f.req, help: f.help, foot: dlgFootHtml(f) });
91
+ }
92
+ if (f.check) return '<label class="pdl-check"><input type="checkbox" class="sr" id="' + f.id + '"' + (f.checked ? ' checked' : '') + '>' + checkInd() + h(f.check) + '</label>'; /* 表单里的勾选:同一个勾选组件的样子,原生输入只负责表单的值 */
93
+ if (f.radios) return '<div class="opts" role="radiogroup">' + f.radios.map(function (r, i) { return '<label class="opt"><input type="radio" class="sr" name="' + f.id + '" value="' + h(r.v) + '"' + ((f.value != null ? f.value === r.v : i === 0) ? ' checked' : '') + '><span class="radio"></span><div class="row-main"><div class="row-title">' + h(r.title) + '</div>' + (r.sub ? '<div class="row-sub">' + h(r.sub) + '</div>' : '') + '</div></label>'; }).join('') + '</div>'; /* 几个带说明的单选(第一个默认选中) */
94
+ if (f.pre) return '<pre class="' + (f.mono ? 'mono ' : '') + (f.cls === 'json' ? 'pdl-json scroll' : 'pre') + '">' + h(f.pre) + '</pre>'; /* 一段只读原文 */
95
+ if (f.members) return field({ id: f.id, label: f.label, control: memberPick({ id: f.id, label: f.label, pool: f.members,
96
+ value: f.value, none: f.none, change: f.change }), req: f.req, help: f.help, foot: dlgFootHtml(f) });
97
+ const attrs = ' id="' + f.id + '"' + (f.placeholder ? ' placeholder="' + h(f.placeholder) + '"' : '') + (f.max ? ' maxlength="' + f.max + '"' : '') + (f.label ? '' : ' aria-label="' + h(f.aria || f.placeholder || '') + '"');
98
+ const attrs2 = attrs + (f.disabled ? ' disabled' : '') + (f.type ? ' type="' + f.type + '"' : '') + (f.min != null ? ' min="' + f.min + '"' : '') + (f.maxv != null ? ' max="' + f.maxv + '"' : '');
99
+ /* The HTML parser consumes the line feed immediately after the textarea start tag. */
100
+ const ctl = f.file ? '<input class="input" id="' + f.id + '" type="file"' + (f.file.accept ? ' accept="' + h(f.file.accept) + '"' : '') + (f.file.change ? ' data-change="' + f.file.change + '"' : '') + '>' :
101
+ f.options ? sel(f.id, f.options, f.value, { change: f.change, label: f.label }) :
102
+ f.area ? '<textarea class="input' + (f.mono ? ' mono' : '') + '"' + attrs2 + (f.rows ? ' rows="' + f.rows + '"' : '') + '>\n' + h(f.value || '') + '</textarea>' :
103
+ f.type === 'date' ? dateCtl(f) :
104
+ '<input class="input' + (f.mono ? ' mono' : '') + '"' + attrs2 + (f.value != null ? ' value="' + h(f.value) + '"' : '') + '>';
105
+ return f.label ? field({ label: f.label, id: f.id, control: ctl, req: f.req, help: f.help, foot: dlgFootHtml(f), stack: !!f.area }) : ctl;
106
+ }
107
+ /* 对话框里的一份文档:说明行(可带等宽路径)、几组切换、原文(可编辑的多行框或只读原文)、下面一行操作
108
+ { meta, path, metaId, num, segs: [{ label, items, act }], text, id, edit, readonly, rows, json, acts: [{ label, act, args, sm }] } */
109
+ function docBody(d) {
110
+ const acts = (d.acts || []).map(function (a) { return btn(a.label, Object.assign({}, a, { data: argAttrs(a.args) })); }).join('');
111
+ return '<div class="dlg-body wide">' + (d.meta != null ? '<div class="lr-section-label' + (d.num ? ' num' : '') + '"' + (d.metaId ? ' id="' + d.metaId + '"' : '') + '>' + (d.path ? '<span class="mono">' + h(d.path) + '</span> · ' : '') + h(d.meta) + '</div>' : '') +
112
+ (d.segs ? '<div class="sw-line">' + d.segs.map(function (g) { return seg(g.items, g.act, 'seg', g.label, argAttrs(g.args)); }).join('') + '</div>' : '') +
113
+ (d.edit ? '<textarea class="input mono seg-text" id="' + d.id + '" rows="' + (d.rows || 16) + '"' + (d.readonly ? ' readonly' : '') + ' aria-label="' + h(d.label || '') + '">' + h(d.text) + '</textarea>' : '<pre class="' + (d.json ? 'pdl-json scroll mono' : 'mono pre') + '"' + (d.id ? ' id="' + d.id + '"' : '') + '>' + h(d.text) + '</pre>') +
114
+ (acts ? '<div class="sw-line">' + acts + '</div>' : '') + '</div>';
115
+ }
116
+ /* 浮动小窗:标题 + ×(弹窗框架的 popX,o.pop = 弹窗名)+ 内容(伴随对话这类) */
117
+ function floatPanel(o) { return floatHtml({ cls: o.cls, label: o.title, head: '<span class="u-strong grow">' + h(o.title) + '</span>' + popX(o.pop), body: '<div class="u-p-foot scroll">' + o.body + '</div>', bare: true }); } /* 小窗的内容在小窗里滚动:插件界面框量的是内容的高度,比窗高时不越出窗外 */
118
+
119
+ /* 模态窗(对话区的“整理、导入、开局……”):标题(说明进 ?)+ 关闭、可滚动的内容、底部按钮;整窗是一个表单,可拖动 */
120
+ function modalHtml(o) {
121
+ return dialogHtml({ key: o.key || 'chat.modal', form: o.form, title: o.title, help: o.help, wide: o.wide, error: o.error, body: o.body, acts: btnsHtml(o.foot) ? o.foot : null }); /* 同一个对话框组件,不另画一份头 */
122
+ }
123
+ /* 限行数的列表(组件库):最多露 k 整行,再加 1 整行渐隐到透明(和折叠同一条规则:k 个完整单位 + 1 个整单位渐隐),一眼看得出还有更多。
124
+ step 是这个列表行高的 token;列表放得下就不滚、不渐隐。 */
125
+ const MENU_ROWS = 10;
126
+
127
+ /* ───────── 表单弹窗(组件库):字段全是数据,开合 / 切换 / 增删都改数据再重画;输入随时写回字段,重画不丢 ─────────
128
+ 字段:chips { vals, kind, ph, label, empty }、swatch { cur }、avatar { text, tint }、opts { items: [{ v, title, sub }], cur, custom: { id, placeholder } }、
129
+ env { open, rows: [[k, v]], toggle: '高级配置(可选)' }、kv(只读键值)、type / min / maxv(数字框)、foot / footTone / links(字段下的一行) */
130
+ function dlgFootHtml(f) {
131
+ const t = f.foot ? (f.footTone ? '<span class="' + f.footTone + '-t">' + h(f.foot) + '</span>' : h(f.foot)) : '';
132
+ return t + (f.links || []).map(dlgLink).join('');
133
+ }
134
+ function dlgLink(l) { return l.href ? '<a class="btn btn-text" href="' + h(l.href) + '" target="_blank" rel="noopener">' + h(l.label) + icon('openExternal', 12) + '</a>' : btn(l.label, { link: true, act: l.act, data: argAttrs(l.args) + (l.msg ? ' data-msg="' + h(l.msg) + '"' : '') }); }
135
+ function dlgFoot(o) { return '<div class="field-foot">' + h(o.text || '') + (o.links || []).map(dlgLink).join('') + '</div>'; }
136
+ function dlgPanes(p) { return '<div class="seg' + (p.locked ? ' u-disabled' : '') + '" role="group"' + (p.locked ? ' aria-disabled="true"' : '') + '>' + p.items.map(function (x) { return '<button type="button"' + (p.locked ? '' : ' data-act="set" data-path="s.dialog.panes.cur"') + ' data-v="' + h(x.v) + '" aria-pressed="' + (x.v === p.cur) + '">' + h(x.label) + '</button>'; }).join('') + '</div>'; }
137
+ /* Model managers supply their catalogue and install operation. The picker owns selection and submission. */
138
+ function modelInstallDialog(show, { id, title, ok, environment, items, selected, custom, missing, install }) {
139
+ const field = { id, opts: { cur: selected, items, custom } };
140
+ return show({
141
+ title, ok, text: { parts: [{ text: '$.environment', variant: 'meta' }], data: { environment } },
142
+ fields: [field],
143
+ on: function () {
144
+ const choice = custom && field.opts.cur === 'custom' ? val(custom.id) : field.opts.cur;
145
+ if (!choice) throw new Error(missing);
146
+ return install(choice);
147
+ }
148
+ });
149
+ }
150
+ function dlgSpecial(f) {
151
+ if (f.chips) return chipBox(f.id, f.chips.vals, { kind: f.chips.kind, ph: f.chips.ph, label: f.chips.label, empty: f.chips.empty, lock: f.chips.lock });
152
+ if (f.swatch) return colorCtl({ kind: 'slot', value: f.swatch.cur, act: 'swatch', label: f.label, name: f.id });
153
+ if (f.color) return colorCtl({ id: f.id, value: f.color.value, slots: 'name', label: f.label }); /* 统一的取色(调色盘);值在同 id 的颜色输入里,dialogSync 照常读 */
154
+ if (f.avatar) return avatarUp(f.avatar.lead, 'xl', {
155
+ label: f.avatar.label || tc('control.upload'), accept: f.avatar.accept || 'image/png,image/jpeg,image/webp', msg: tc('control.avatarUploaded')
156
+ }, (f.id ? ' id="' + h(f.id) + '"' : '') + (f.avatar.change ? ' data-change="' + h(f.avatar.change) + '"' : ''));
157
+ if (f.opts) return '<div class="opts">' + f.opts.items.map(function (m) { return opt(f.id, m.v, f.opts.cur, m.title, m.sub, { act: 'set', data: ' data-path="dlgf.' + h(f.id) + '.opts.cur"' }); }).join('') +
158
+ (f.opts.custom && f.opts.cur === 'custom' ? '<div class="custom-model"><input class="input mono" id="' + f.opts.custom.id + '" placeholder="' + h(f.opts.custom.placeholder || '') + '" value="' + h(f.opts.custom.value || '') + '"></div>' : '') + '</div>';
159
+ if (f.env) return btn(f.env.toggle || tc('control.envToggle'), { link: true, act: 'toggle', data: ' data-path="dlgf.' + h(f.id) + '.env.open"' }) + (f.env.open ? '<div class="env-rows">' + f.env.rows.map(function (r, i) { return '<div class="env-row"><input class="input mono" id="' + f.id + '-k' + i + '" value="' + h(r[0]) + '" placeholder="KEY" aria-label="' + h(tc('control.envKey')) + '"><input class="input mono" id="' + f.id + '-v' + i + '" value="' + h(r[1]) + '" placeholder="value" aria-label="' + h(tc('kv.value')) + '"></div>'; }).join('') + '</div>' + btn(tc('control.envAdd'), { sm: true, icon: 'plus', act: 'listOp', data: ' data-path="dlgf.' + h(f.id) + '.env.rows" data-op="add" data-shape="pair"' }) : '');
160
+ return '';
161
+ }
162
+ /* 引擎经组件库画的部件(ENGINE_PARTS,见 engine/core.js) */
163
+ Object.assign(ENGINE_PARTS, { float: floatHtml, modal: modalHtml, menu: menuHtml, dialog: dialogHtml, dialogSync: dialogSync, toast: toastHtml, undo: undoBar, copied: copyFlash, back: engineBack, md: mdLite,
164
+ icons: function (map) { Object.assign(ICONS, map); },
165
+ framePopup: function (k, pk, d) { return d.view ? pdlView(d.view) : floatPanel({ cls: 'plugin-float', title: d.title, pop: k, body: pdlView(Object.keys(PDL_VIEWS).find(function (id) { return PDL_VIEWS[id].popup === k; })) }); } });
@@ -0,0 +1,142 @@
1
+ /* 边界:一个含义一个组件、不为接口定制、不按位置推导样式 */
2
+ /* 页面结构:页头、详情头、小节、分组、设置行、字段、说明、列表头尾、键值、统计、等宽块、长文本 */
3
+ 'use strict';
4
+ function cellsHtml(o) {
5
+ const r = cellsResolve(o.items, o.saved), gap = function (n) { return n > 0 ? '<span class="cell-gap" style="--u-n:' + n + '"></span>' : ''; };
6
+ const one = function (it) { return '<span class="citem" data-ckey="' + h(it.key) + '" data-anchor="' + it.anchor + '" data-cell="' + it.cell + '" style="--u-span:' + it.span + '"' + (it.locked ? ' data-locked="1"' : o.edit ? ' data-edit="cell"' : '') + '>' + it.html + '</span>'; };
7
+ let cur = 0, head = '';
8
+ r.start.forEach(function (it) { head += gap(it.cell - cur) + one(it); cur = it.cell + it.span; });
9
+ let tail = '';
10
+ r.end.forEach(function (it, i) { const nx = r.end[i + 1]; tail += one(it) + gap(nx ? it.cell - (nx.cell + nx.span) : it.cell); });
11
+ return '<div class="cells cells-' + (o.axis || 'row') + (o.cls ? ' ' + o.cls : '') + '" data-cells="' + h(o.key) + '"' + (o.attrs || '') + '>' + (o.before || '') + head + '<span class="cells-flex"></span>' + tail + '</div>';
12
+ }
13
+ /* 页头:返回、(可选)前导头像、标题 + 标注 + ?、下方一行数据(sub);右边操作。标题带 data-title:组件声明的标题位(返回的提示取它的字,引擎只认这个标记) */
14
+ function pageHead(o) {
15
+ const h1 = '<h1 class="page-title" data-title' + (o.titleNote ? ' data-note="' + o.titleNote + '"' : '') + '>' + o.title + annotLabel(o.label, 'after') + helpTip(o.help || o.desc) + '</h1>';
16
+ const id = (o.status ? '<div class="head-line">' + h1 + o.status + '</div>' : h1) + annotLabel(o.label, 'below') + (o.sub ? '<div class="vw-label below">' + o.sub + '</div>' : ''); /* 行内状态紧跟标题(头的统一排法) */
17
+ const drawer = !o.back && typeof NAV_OVERRIDE !== 'undefined' && NAV_OVERRIDE[space()] ? btn(tc('frame.openNav'), { sm: true, iconOnly: true, cls: 'nav-toggle', icon: 'menu', act: 'toggle', data: ' data-path="s.navOpen"' }) : '';
18
+ return '<header class="page-head">' + (o.back || drawer) + '<div class="grow">' +
19
+ (o.lead ? '<div class="page-id">' + o.lead + '<div class="grow">' + id + '</div></div>' : id) + '</div>' +
20
+ (o.actions ? '<div class="page-actions"' + (o.actNote ? ' data-note="' + o.actNote + '"' : '') + '>' + o.actions + '</div>' : '') + '</header>';
21
+ }
22
+ function section(o) {
23
+ /* 小节头(统一排法):标题 → 行内状态 → 空白 → 操作控件在最后 */
24
+ const h2 = '<h2 class="section-title">' + h(o.title) + annotLabel(o.label, 'after') + helpTip(o.help || o.desc) + '</h2>';
25
+ return '<section class="section"' + (o.note ? ' data-note="' + o.note + '"' : '') + (o.id ? ' id="' + o.id + '"' : '') + '>' + (o.title ? '<div class="section-head"><div class="grow">' + (o.status ? '<div class="head-line">' + h2 + o.status + '</div>' : h2) + annotLabel(o.label, 'below') + '</div>' + (o.actions || '') + '</div>' : '') + o.body + '</section>';
26
+ }
27
+ /* ───────── 注释:help(解释,渲染成 ?,悬停约 0.5 秒后显示,离开立刻消失——原生提示)/ label(直接显示的短文字,位置 after / corner / below) ─────────
28
+ 说明性文字只能来自这两个字段(lint:ui-note)。 */
29
+ function helpPlain(t) { return String(t == null ? '' : t).replace(/<[^>]*>/g, '').replace(/&nbsp;/g, ' ').replace(/\s+/g, ' ').trim(); }
30
+ function helpTip(t) { const x = helpPlain(t); return x ? ' <span class="help-q" tabindex="0" role="img" data-tip="' + h(x) + '" aria-label="' + h(tc('control.helpLabel', x)) + '">?</span>' : ''; }
31
+ function annotLabel(l, pos) {
32
+ if (!l) return '';
33
+ if (Array.isArray(l)) return l.map(function (x) { return annotLabel(x, pos); }).join('');
34
+ const o = typeof l === 'string' ? { text: l, pos: 'after' } : l;
35
+ if ((o.pos || 'after') !== pos || !o.text) return '';
36
+ return pos === 'below' ? '<div class="vw-label below' + (o.tone ? ' vw-t-' + o.tone : '') + '">' + h(o.text) + '</div>' : ' <span class="vw-label ' + pos + (o.tone ? ' vw-t-' + o.tone : '') + '">' + h(o.text) + '</span>';
37
+ }
38
+ function group(rows, cls) { return '<div class="group' + (cls ? ' ' + cls : '') + '">' + rows.join('') + '</div>'; }
39
+ /* 说明(help)一律收成标题后的 ?;状态、校验错误、跟着字段的操作放在字段下面一行(foot),不写成说明段 */
40
+ function srow(label, trail, o) {
41
+ o = o || {};
42
+ return '<div class="row setting"' + (o.note ? ' data-note="' + o.note + '"' : '') + '><div class="row-main"><div class="row-title' + (o.mono ? ' mono' : '') + '">' + h(label) + helpTip(o.help) + '</div></div>' + (trail ? '<div class="row-trail">' + trail + '</div>' : '') + '</div>';
43
+ }
44
+ function field(o) {
45
+ const control = o.control ?? '<div class="value">' + h(o.text) + '</div>';
46
+ return '<div class="field' + (o.stack ? ' field-stack' : '') + '"' + (o.note ? ' data-note="' + o.note + '"' : '') + '>' + (o.id ? '<label for="' + o.id + '">' : '<div class="label">') + h(o.label) + (o.req ? '<span class="req" aria-label="' + h(tc('common.required')) + '">*</span>' : '') + helpTip(o.help) + (o.id ? '</label>' : '</div>') + '<div>' + control + (o.foot ? '<div class="field-foot">' + o.foot + '</div>' : '') + '</div></div>';
47
+ }
48
+ function muted(t) { return '<span class="t-m muted">' + t + '</span>'; }
49
+ function backLink(o) {
50
+ const tip = o.label ? tc('frame.backNamed', o.label) : tc('common.back');
51
+ return btn(tip, { sm: true, iconOnly: true, cls: 'back', icon: 'back', act: o.act, data: o.data });
52
+ }
53
+ /* 容器声明每一级的名称和去处。箭头和文字入口使用同一个目的地,只有文字路径进滚动区。 */
54
+ function breadcrumbs(path, back = path[path.length - 2]) {
55
+ const current = path[path.length - 1], ancestors = path.slice(0, -1).filter(function (p) { return p.label; });
56
+ const arrow = back && back.act ? backLink(back) : '';
57
+ if (!current?.label || !ancestors.length) return arrow;
58
+ const crumbs = ancestors.concat(current).map(function (p, i) {
59
+ const here = p === current;
60
+ const title = h(p.label), tip = ' data-tip="' + title + '"';
61
+ const label = here || !p.act ? '<span class="breadcrumb-text"' + tip + '>' + title + '</span>' :
62
+ btn(p.label, { link: true, act: p.act, data: (p.data || '') + tip });
63
+ return '<li' + (here ? ' aria-current="page"' : '') + '>' + (i ? '<span class="breadcrumb-sep" aria-hidden="true">›</span>' : '') + label + '</li>';
64
+ }).join('');
65
+ return '<nav class="breadcrumbs" aria-label="' + h(tc('frame.breadcrumbs')) + '">' + arrow + '<ol class="breadcrumb-scroll scroll-x">' + crumbs + '</ol></nav>';
66
+ }
67
+ function engineBack(d, title) {
68
+ if (!d.path) return backLink(d);
69
+ const path = d.path[d.path.length - 1].label || !title ? d.path : d.path.slice(0, -1).concat({ label: title });
70
+ return breadcrumbs(path, d);
71
+ }
72
+ document.addEventListener('focusin', function (e) {
73
+ if (e.target.matches('.breadcrumb-scroll button:focus-visible')) {
74
+ e.target.scrollIntoView({ block: 'nearest', inline: 'nearest', behavior: 'instant', container: 'nearest' });
75
+ }
76
+ });
77
+ function scrollRows(k, step, more) { const v = ['--rows:' + k, '--row-step:var(' + step + ')'].concat(more ? [more] : []); return ' data-rows style="' + v.join(';') + '"'; }
78
+
79
+ /* ───────── 小件(组件库) ───────── */
80
+ /* 路径 + “在访达中显示”;只读的设置值 */
81
+ function plain(v) { return '<span class="sys-v">' + h(v) + '</span>'; }
82
+ /* 列表上方的一行工具:左边若干、右边若干(中间撑开) */
83
+ /* 列表上方的工具条:一个操作组(格子),编辑布局时组内的操作可以换位置;items = [{ key, html, span, anchor: start | end }] */
84
+ function listBar(o) { return '<div class="workspace-toolbar"' + (o.note ? ' data-note="' + o.note + '"' : '') + '>' + cellsHtml({ key: o.key, axis: 'row', items: o.items, saved: pdlCells(o.key), edit: S.editLayout }) + '</div>'; }
85
+ function listWrap(html) { return '<div class="pdl-list-wrap">' + html + '</div>'; }
86
+ /* 一段等宽原样输出(工具结果) */
87
+ function monoBlock(t) { return '<div class="mono vw-12">' + h(t) + '</div>'; }
88
+
89
+ /* 工作台详情的通用零件:详情头、顶栏、可折叠分节、键值表、统计行、进度条、勾选框、原文块、chip 行;列表行(交给 lrow) */
90
+ function detailHead(o) {
91
+ const h2 = o.title ? '<h2 class="ws-h"' + (o.note ? ' data-note="' + o.note + '"' : '') + '>' + o.title + '</h2>' : ''; /* 没有标题的子层头(面板顶上一行数据 + 操作):只有数据行 */
92
+ return '<div class="ws-dhead"' + (o.note && !o.title ? ' data-note="' + o.note + '"' : '') + '>' + (o.back || '') + '<div class="grow">' +
93
+ (o.eyebrow ? '<div class="ws-eyebrow">' + o.eyebrow + '</div>' : '') + (o.status ? '<div class="head-line">' + h2 + o.status + '</div>' : h2) + (o.sub ? '<div class="vw-label below">' + o.sub + '</div>' : '') + '</div>' +
94
+ (o.actions ? '<div class="ws-acts">' + o.actions + '</div>' : '') + '</div>';
95
+ }
96
+ /* 展开 / 收起一块(disclosure,组件库唯一的一个):标题行 + 始终显示的摘要(o.summary)+ 展开时的内容。
97
+ 开合默认记在开合状态里(S.folds[key],通用动作 toggle);o.state + o.act:开合由视图模型管。
98
+ v:角色变体——缺省 = 页面 / 面板里的一块(内容和标题之间留一档间距);list = 列表里的一段(浮层列表的「最近关闭」:内容就是接着的几行,行距跟着所在列表) */
99
+ function foldSection(key, title, body, o) {
100
+ o = o || {};
101
+ const open = o.state != null ? !!o.state : S.folds[key] != null ? S.folds[key] : !!o.open; /* o.state:调用方自己管开合(比如弹窗内容);o.act 换成它的动作 */
102
+ const head = '<button type="button" class="ws-fold-h" data-act="' + (o.act || 'toggle') + '"' + (o.act ? '' : ' data-path="folds.' + h(key) + '" data-values="' + (o.open ? 'false|true' : 'true|false') + '" data-cast="bool"') + (o.data || '') + ' data-k="' + h(key) + '" data-d="' + (o.open ? 1 : 0) + '" aria-expanded="' + open + '">' + twisty(open) + '<span>' + title + '</span>' + (o.sub ? '<span class="faint ws-fold-s">' + o.sub + '</span>' : '') + (o.count != null ? '<span class="faint num">' + o.count + '</span>' : '') + (o.trail ? '<span class="grow"></span>' + o.trail : '') + '</button>';
103
+ return '<div class="ws-fold"' + (o.v ? ' data-v="' + o.v + '"' : '') + (o.note ? ' data-note="' + o.note + '"' : '') + '>' +
104
+ (o.actions ? '<div class="ws-fold-bar">' + head + '<span class="ws-fold-acts">' + o.actions + '</span></div>' : head) +
105
+ (o.summary ? '<div class="ws-fold-summary">' + o.summary + '</div>' : '') + (open ? '<div class="ws-fold-b">' + body + '</div>' : '') + '</div>';
106
+ }
107
+ /* 键值(组件库,唯一的一个):一列标签 + 一列值。一个块里的所有行共用一列标签:宽度按这块里最宽的标签取档(s / m / l,token --kv-k-*),
108
+ 超过最宽一档的标签省略(悬停看全文);值从标签列右边开始左对齐,可以换行。surface: 'group' 时自带分组底(工作台里的一块)。
109
+ pairs:[[标签, 值的 HTML]] */
110
+ function kvGrid(pairs, o) {
111
+ o = o || {};
112
+ return '<dl class="kvg' + (o.surface ? ' kvg-' + o.surface : '') + '"' + (o.units ? ' data-units-container="' + h(o.units) + '"' : '') + '>' + pairs.map(function (p) { return '<dt data-tip="' + h(p[0]) + '">' + h(p[0]) + '</dt><dd>' + p[1] + '</dd>'; }).join('') + '</dl>';
113
+ }
114
+ function chipList(list) { return '<div class="chips">' + list.join('') + '</div>'; }
115
+ function chipItem(t, act, data) { return chipHtml({ label: t, act: act, data: data }); }
116
+ /* 一段等宽文字(路径、id) */
117
+ /* 列表上方的小标签(说明进 ?) */
118
+ /* 一行操作,后面可带一句弱色状态 */
119
+ /* 宽一点的弹窗内容(同步结果、异常列表这类表格感的内容) */
120
+ function wideBody(html) { return '<div class="dlg-wide">' + html + '</div>'; }
121
+ /* 长说明:只露一行,悬停给全文(内容是已经转义好的片段) */
122
+ function longText(t) { return '<span data-tip="' + h(String(t).replace(/<[^>]+>/g, '')) + '">' + t + '</span>'; }
123
+
124
+ /* 带小标题的要点列表(条目是已经转义好的片段);没有条目时不画 */
125
+ function bulletList(title, items) { return items && items.length ? '<div class="cap-dlg-h">' + h(title) + '</div><ul class="rules">' + items.map(function (x) { return '<li>' + x + '</li>'; }).join('') + '</ul>' : ''; }
126
+ /* 现有正文原件的 PDL 入口:只解析声明,仍由同一个原件画。 */
127
+ PDL_COMPONENTS.breadcrumbs = function (path) {
128
+ return breadcrumbs(path.map(function (step) { return { label: step.label, act: step.act, data: argAttrs(step.args) }; }));
129
+ };
130
+ PDL_COMPONENTS.wideBody = function (p, sc, root) { return wideBody(pvBlocks(p.blocks, sc, root)); };
131
+ PDL_COMPONENTS.longText = function (p, sc, root) { return longText(pvParts(p.parts, sc, root)); };
132
+ PDL_COMPONENTS.bulletList = function (p, sc, root) { return bulletList(pv(p.title, sc, root), pvList(p.from, sc, root).map(function (x) { return pvPart(p.item, x, root); })); };
133
+ PDL_COMPONENTS.wideBody.catalog = { g: 'structure', props: { blocks: [{ type: 'text', variant: 'para', text: '$.sub' }] } };
134
+ PDL_COMPONENTS.longText.catalog = { g: 'basics', props: { parts: [{ text: '$.sub' }] } };
135
+ PDL_COMPONENTS.bulletList.catalog = { g: 'structure', props: { title: '$.label', from: '$.chips', item: { text: '@' } } };
136
+ /* ───────── 目录登记:这个文件里的组件 ───────── */
137
+ Object.assign(LIB_CATALOG, {
138
+ cells: { g: 'structure', via: ['prop:ordered', 'shell'], ex: function (s) { return cellsHtml({ key: 'catalog', axis: 'row', items: s.chips.map(function (c, i) { return { key: c, html: btn(c, { sm: true, act: 'noop' }), span: i === 0 ? 'm' : 's', anchor: i < 2 ? 'start' : 'end' }; }) }); } },
139
+ scrollY: { g: 'structure', via: ['prop:scroll', 'type:pop', 'type:chatpage'], ex: function (s) { return '<div class="scroll cat-scroll">' + s.radios.concat(s.chips, s.steps).map(function (t) { return '<p>' + h(t) + '</p>'; }).join('') + '</div>'; } },
140
+ scrollX: { g: 'structure', via: ['type:tabs', 'type:lanes'], ex: function (s) { return '<div class="scroll-x cat-scroll-x"><span class="chips">' + s.chips.concat(s.radios, s.steps).map(function (t) { return chipHtml({ label: h(t) }); }).join('') + '</span></div>'; } },
141
+ srow: { g: 'rows', via: ['type:settings'], ex: function (s) { return group([srow(s.label, sw(true, 'noop', '', s.label)), srow(s.label2, h(s.value))]); } }
142
+ });
@@ -0,0 +1,154 @@
1
+ /* 边界:一个含义一个组件、不为接口定制、不按位置推导样式 */
2
+ /* 统一配置表单 */
3
+ 'use strict';
4
+
5
+ /* ───────── 统一配置表单:统一配置注册表的投影(PluginManagerConfigField[])画成一张表单 ─────────
6
+ props(config-form.js 的 pcfModel 整理好):{ p 表单实例, installed, steps: [{ text / code }], rows: [字段行], fieldCount, testable }
7
+ 字段行:{ key, id, kind, label, req, readonly, desc(清单的字段说明,原样画在字段下面), err, value / items / operation };组件按 kind 画对应的控件。
8
+ 操作 op.mode:seq(按钮 → 进行中 → 轮询〔二维码、剩余秒数〕→ 结果 / 已连接 + 断开)、live(限时授权:状态 + 一个按钮)、rows(列表按钮 + 行,每行自己的动作)。
9
+ 都是组件库的控件(field、sel、sw、kvEditor、btn、status、notice、lrow);点了什么由 data-act(pcf*)+ 实例 / 字段 / 动作给出 */
10
+ /* 动作的结果:标签是一行状态;文本结果(网址、要粘贴的消息)是可复制的值 */
11
+ function pcfFb(fb) { /* 文本结果是表单里的一个只读框(和输入框同一个样子,按内容长高)+ 框尾的复制 */
12
+ if (!fb) return '';
13
+ const copy = fb.copy ? '<span class="combo"><textarea class="input' + (/\s/.test(fb.copy) ? '' : ' mono') + '" readonly data-grow rows="1" aria-label="' + h(fb.label || tc('common.copy')) + '">' + h(fb.copy) + '</textarea>' +
14
+ btn(tc('common.copy'), { iconOnly: true, sm: true, icon: 'copy', act: 'copy', data: argAttrs({ v: fb.copy, msg: tc('control.copied', fb.label || tc('common.copy')) }) }) + '</span>' : '';
15
+ return (fb.label ? status('ok', fb.label) : '') + copy;
16
+ }
17
+ function pcfData(p, k) { return argAttrs({ p: p, k: k }); }
18
+ function pcfOpHtml(o) {
19
+ const A = function (a, extra) { return actAttrs('cfOp', Object.assign({ p: o.p, f: o.f, a: a }, extra || {})); };
20
+ const action = function (id) { return o.actions.find(function (a) { return a.id === id; }); };
21
+ const err = o.err ? status('danger', o.err) : '';
22
+ if (o.mode === 'rows') {
23
+ const list = action(o.listId), buttons = o.actions.filter(function (a) { return a.render === 'button' && a.id !== o.listId; });
24
+ /* 自动看的状态没有常驻的刷新:读失败或自动查看到点了才有“重新检查”(提示里说为什么停了) */
25
+ const refresh = o.refresh ? btn(o.refreshAuto ? tc('pcf.recheck') : list.label, { sm: true, data: A(list.id) + (o.paused ? ' data-tip="' + h(tc('pcf.observePaused')) + '"' : ''), icon: 'refresh' }) : '';
26
+ const bar = refresh || buttons.length ? '<div class="pcf-acts">' + refresh + buttons.map(function (b) { return btn(b.label, { sm: true, data: A(b.id) }); }).join('') + '</div>' : '';
27
+ const rs = o.rows.map(function (r) {
28
+ const actions = (r.actions || []).map(function (ra) { const d = o.rowActions.find(function (a) { return a.id === ra.action; }); return d ? { id: d.id, label: ra.label || d.label } : null; }).filter(Boolean);
29
+ return { sm: !r.detail && !r.fb, title: h(r.label), sub: (r.detail ? h(r.detail) : '') + pcfFb(r.fb), meta: r.err ? status('danger', r.err) : '',
30
+ cols: actions.length ? [{ w: 'ctl', v: actions.map(function (a) { return btn(a.label, { sm: true, data: A(a.id, { r: r.key }) }); }).join('') }] : [] };
31
+ });
32
+ const rows = rs.length ? '<div class="group lr-list lined"' + lrCols(rs) + '>' + rs.map(lrow).join('') + '</div>' : '';
33
+ return '<div class="pcf-op">' + bar + err + pcfFb(o.fb) + (o.awaiting ? '<span class="muted">' + h(tc('pcf.awaiting', list.label)) + '</span>' : '') + (o.loaded && !o.rows.length ? '<span class="muted">' + h(o.emptyText || tc('pcf.noRows')) + '</span>' : '') + rows + '</div>';
34
+ }
35
+ if (o.mode === 'live') { const current = action(o.status && o.status.armed ? o.revokeId : o.armId); return '<div class="pcf-op">' + status(o.status && o.status.armed ? 'ok' : 'info', !o.status ? tc('pcf.checking') : o.status.armed ? tc('pcf.armedLeft', o.status.label, o.status.seconds) : o.status.label) + err + '<div class="pcf-acts">' + btn(current.label, { sm: true, data: A(current.id), disabled: o.busy || !o.status }) + '</div></div>'; }
36
+ if (!o.available) return o.err ? '<div class="pcf-op">' + err + '</div>' : status('info', tc('pcf.operationUnavailable'));
37
+ const current = o.step;
38
+ const feedback = o.polling ? (o.label || current.label) + ' · ' + tc('pcf.left', o.seconds) :
39
+ o.busy ? tc('pcf.ui.pending', current.label) : o.label;
40
+ const run = current.render === 'button' ? btn(current.label, { sm: true, data: A(current.id), disabled: o.busy, icon: current.resultRender === 'img' ? 'grid' : '' }) : '';
41
+ const cancel = current.cancel ? btn(tc('common.cancel'), { sm: true, data: A(current.cancel), disabled: o.busy && !o.polling }) : '';
42
+ return '<div class="pcf-op">' + err +
43
+ (run || cancel ? '<div class="pcf-acts">' + run + cancel + '</div>' : '') +
44
+ (o.image ? '<img class="pcf-qr" src="' + h(o.image) + '" alt="' + h(o.label || current.label) + '">' : '') +
45
+ (feedback && !o.err ? status(o.polling || o.busy ? 'info' : 'ok', feedback) : '') +
46
+ (o.text ? pcfFb({ copy: o.text }) : '') + '</div>';
47
+ }
48
+ function pcfPresetLabel(unit, value) {
49
+ const n = Number(value);
50
+ if (unit === 'percent') return String(Number((n * 100).toFixed(2))) + '%';
51
+ const suffix = { seconds: 's', minutes: 'min', days: 'd', count: '', items: '', levels: '' }[unit] || '';
52
+ return String(value) + (suffix ? ' ' + suffix : '');
53
+ }
54
+ function pcfCombo(r) {
55
+ if (r.record || r.readonly) return false;
56
+ if (['operation', 'select', 'member', 'thread', 'boolean', 'list', 'map', 'records'].indexOf(r.kind) >= 0) return false;
57
+ return (Array.isArray(r.suggestions) && r.suggestions.length > 0) || !!(r.hasSuggestions && r.refreshAction);
58
+ }
59
+ function pcfCtl(r, p) {
60
+ const d = pcfData(p, r.key), label = r.label ? pv(r.label, r, r) : tc('pcf.fieldLabel', r.schemaKey || r.key);
61
+ if (r.kind === 'operation') return pcfOpHtml(r.operation);
62
+ if (r.instant && r.kind === 'number' && Array.isArray(r.presets) && r.presets.length) {
63
+ const customKey = 'cf-custom:' + p + ':' + r.key;
64
+ const editSt = typeof inlineEditState === 'function' ? inlineEditState(customKey) : null;
65
+ if (editSt) {
66
+ const unitSuffix = r.unit === 'percent' ? '%' : ({ seconds: 's', minutes: 'min', days: 'd' }[r.unit] || '');
67
+ return '<span class="inline-edit-wrap">' + inlineEditInput({ state: editSt, cls: 'inline-edit-num', label: label }) + (unitSuffix ? '<span class="vw-meta">' + h(unitSuffix) + '</span>' : '') + '</span>';
68
+ }
69
+ const options = r.presets.map(function (x) { return { v: String(x), label: pcfPresetLabel(r.unit, x) }; });
70
+ const match = r.value === '' ? null : r.presets.find(function (x) { return String(x) === String(r.value) || (Number.isFinite(Number(r.value)) && Number(x) === Number(r.value)); });
71
+ const selected = match !== undefined && match !== null ? String(match) : String(r.value);
72
+ if (match === undefined && r.value !== '') options.unshift({ v: selected, label: pcfPresetLabel(r.unit, r.value) });
73
+ options.push({ v: '__custom__', label: tc('pcf.custom') });
74
+ return sel(r.id, options, selected, { change: 'cfSel', data: d, invalid: !!r.err, label: label, disabled: !!r.readonly });
75
+ }
76
+ if (r.kind === 'select') {
77
+ const options = r.options.map(function (x) { return { v: x.value, label: pv(x.label, x, x) }; });
78
+ const needChoose = r.value === '' && !options.some(function (x) { return x.v === ''; });
79
+ return sel(r.id, needChoose ? [{ v: '', label: tc('pcf.choose') }].concat(options) : options, r.value, { change: r.record ? 'cfRecSel' : 'cfSel', data: d, invalid: !!r.err, label: label, disabled: !!r.readonly });
80
+ }
81
+ if (r.kind === 'member') return memberPick({ id: r.id, pool: r.options, value: r.value, multi: r.multiple, none: tc('pcf.choose'), change: 'cfSel', data: d, label: label, act: 'cfOp', args: { op: 'pick', p: p, k: r.key }, disabled: !!r.readonly });
82
+ if (r.kind === 'thread') return sel(r.id, (r.multiple ? [] : [{ v: '', label: tc('pcf.choose') }]).concat(r.options.map(function (x) { return { v: x.value, label: x.label }; })), r.value, { change: 'cfSel', data: d, label: label, multi: r.multiple, act: 'cfOp', args: { op: 'pick', p: p, k: r.key }, key: 'id', none: tc('pcf.choose'), disabled: !!r.readonly });
83
+ if (r.kind === 'boolean') return sw(r.value, 'cfOp', d + ' data-op="' + (r.record ? 'recBool' : 'bool') + '"', label, !!r.readonly);
84
+ if (r.kind === 'list') return kvEditor({ key: p + '|' + r.key, rows: r.items.map(function (v) { return { v: v }; }), single: true, ro: !!r.readonly, input: 'cfListIn', del: 'cfOp', add: tc('pcf.addItem') });
85
+ if (r.kind === 'map') return kvEditor({ key: p + '|' + r.key, rows: r.items || [], single: false, ro: !!r.readonly, input: 'cfListIn', del: 'cfOp', eye: 'cfOp', add: tc('pcf.addItem') });
86
+ if (r.kind === 'records') return pcfRecordsHtml(r, p);
87
+ const type = { secret: 'password', number: 'number', url: 'url' }[r.kind] || 'text';
88
+ const readonly = r.readonly || (r.defaultClient && (r.schemaKey === 'id' || r.schemaKey === 'name'));
89
+ const suggestions = !r.record && Array.isArray(r.suggestions) && r.suggestions.length ? r.suggestions : [];
90
+ const emptySuggestion = suggestions.find(function (one) { return one.value === ''; });
91
+ const ph = r.record ? r.placeholder
92
+ : r.kind === 'secret' ? (r.currentValue ? tc('pcf.secretSet') : tc('pcf.unset'))
93
+ : emptySuggestion ? pv(emptySuggestion.label, emptySuggestion, emptySuggestion)
94
+ : r.hasSuggestions ? (r.placeholder || r.defaultValue || tc('pcf.unset'))
95
+ : r.currentValue || r.defaultValue || r.placeholder || tc('pcf.unset');
96
+ const inp = '<input class="input" id="' + h(r.id) + '" type="' + type + '" value="' + h(r.value) + '" placeholder="' + h(ph) + '"' + (readonly ? ' readonly' : ' data-input="' + (r.record ? 'cfRecIn' : 'cfIn') + '"') + d + (r.err ? ' aria-invalid="true"' : '') + ' autocomplete="off">';
97
+ if (pcfCombo(r)) {
98
+ if (suggestions.length) {
99
+ COMBO[r.id] = suggestions.map(function (one) {
100
+ const text = pv(one.label, one, one);
101
+ return { v: one.value, label: text, sub: one.value && one.value !== text ? one.value : '' };
102
+ });
103
+ } else {
104
+ delete COMBO[r.id];
105
+ }
106
+ const picker = suggestions.length
107
+ ? btn(label, { iconOnly: true, sm: true, icon: 'updown', act: 'comboOpen', data: ' data-for="' + h(r.id) + '" aria-haspopup="menu"' })
108
+ : btn(label, { iconOnly: true, sm: true, icon: 'updown', why: r.refreshBusy ? (r.refreshTip || tc('common.loading')) : tc('common.none') });
109
+ const reload = r.refreshAction
110
+ ? btn(r.refreshLabel || tc('common.refresh'), { iconOnly: true, sm: true, icon: 'refresh', act: r.refreshAction, busy: !!r.refreshBusy, tip: r.refreshBusy ? (r.refreshTip || tc('common.loading')) : (r.refreshLabel || tc('common.refresh')) })
111
+ : '';
112
+ return '<span class="combo">' + inp + picker + reload + '</span>';
113
+ }
114
+ return inp;
115
+ }
116
+ function pcfRecordsHtml(r, p) {
117
+ const sub = function (x) { return field({ label: x.label ? pv(x.label, x, x) : tc('pcf.fieldLabel', x.schemaKey), id: x.kind === 'list' || x.kind === 'boolean' ? '' : x.id, req: x.req, help: x.desc, control: pcfCtl(x, p), foot: x.err ? status('danger', x.err) : '' }); };
118
+ if (r.readonly && !r.items.length) return '<span class="muted">' + h(tc('common.none')) + '</span>';
119
+ const canEditRows = !r.readonly && r.configurationMode !== 'single';
120
+ return '<div class="pcf-recs">' + r.items.map(function (it) {
121
+ const check = it.checked;
122
+ return '<div class="group pcf-rec"><div class="pcf-rec-h"><b>' + h(it.name || tc('pcf.recordN', it.i + 1)) + '</b>' + (check ? status(check.error ? 'danger' : check.ok ? 'ok' : 'warn', check.error || check.message) : '') + '<span class="grow"></span>' + (r.checkable ? btn(tc('pcf.checkRecord'), { sm: true, act: 'cfOp', data: argAttrs({ op: 'recCheck', p: p, k: r.key, i: it.i }) }) : '') + (canEditRows ? btn(tc('kv.deleteRow'), { iconOnly: true, icon: 'delete', sm: true, act: 'cfOp', data: argAttrs({ op: 'recDel', p: p, k: r.key, i: it.i }) }) : '') + '</div>' + it.rows.map(sub).join('') + '</div>';
123
+ }).join('') + (canEditRows ? '<div class="pcf-acts">' + btn(tc('common.add'), { sm: true, icon: 'plus', act: 'cfOp', data: argAttrs({ op: 'recAdd', p: p, k: r.key }) }) +
124
+ r.presets.map(function (pr) { return btn(pv(pr.label, pr, pr), { sm: true, act: 'cfOp', data: argAttrs({ op: 'recAdd', p: p, k: r.key, preset: pr.id }) }); }).join('') + '</div>' : '') + '</div>';
125
+ }
126
+ function configForm(p) {
127
+ if (!p) return '';
128
+ if (!p.installed) return group([emptyState(tc('common.status.notInstalled'))]);
129
+ if (p.compact) {
130
+ const compactRows = p.rows.map(function (r) {
131
+ const label = r.label ? pv(r.label, r, r) : tc('pcf.fieldLabel', r.key);
132
+ return srow(label, pcfCtl(r, p.p), { help: r.desc || '' });
133
+ }).join('');
134
+ return '<div class="group pcf compact" data-config-scope="' + h(p.scope || p.p) + '">' + compactRows + '</div>';
135
+ }
136
+ const rows = p.steps.map(function (s, i) { return field({ label: tc('pcf.step', i + 1), text: s.code ? tc('pcf.ui.step', s.code) : s.text }); })
137
+ .concat(p.rows.map(function (r) {
138
+ const current = (r.options || []).find(function (o) { return o.value === r.value; }), hint = current && current.hint;
139
+ const refresh = r.refreshAction && !pcfCombo(r) ? btn(r.refreshLabel || tc('common.refresh'), { link: true, act: r.refreshAction, busy: !!r.refreshBusy }) : '';
140
+ const foot = (r.err ? status('danger', r.err) : '') + (hint ? '<span>' + h(hint) + '</span>' : '') +
141
+ (r.canClear ? btn(tc('pcf.clear'), { link: true, act: 'cfOp', data: argAttrs({ op: 'clear', p: p.p, k: r.key }) }) : '') + refresh;
142
+ return field({ label: r.label ? pv(r.label, r, r) : tc('pcf.fieldLabel', r.key), id: ['operation', 'list', 'boolean', 'records'].indexOf(r.kind) >= 0 ? '' : r.id, req: r.req, help: r.desc, control: pcfCtl(r, p.p), foot: foot });
143
+ }));
144
+ if (!rows.length) return !p.fieldCount && !p.testable ? group([emptyState(tc('pcf.none'))]) : '';
145
+ if (p.external) {
146
+ return '<div class="group pcf" data-config-scope="' + h(p.scope || p.p) + '">' + rows.join('') + '</div>';
147
+ }
148
+ const body = '<div class="group pcf">' + rows.join('') + '</div>';
149
+ const bar = p.dirty ? '<div class="pcf-savebar">' + btn(tc('common.cancel'), { act: 'cfOp', data: argAttrs({ op: 'discard', p: p.p }) }) + btn(tc('common.save'), { submit: true, primary: true }) + '</div>' : '';
150
+ return '<form data-form="cf" data-scope="' + h(p.scope || p.p) + '" data-p="' + h(p.p) + '" data-config-scope="' + h(p.scope || p.p) + '">' + body + bar + '</form>';
151
+ }
152
+ /* 统一配置表单。PCF 样式类名保留,是因为它已经表达“配置字段卡片”这一种视觉角色。 */
153
+ PDL_COMPONENTS.configForm = configForm;
154
+ PDL_COMPONENTS.configForm.catalog = { g: 'structure', vm: 'pcfCatalog', props: ['$.kinds', '$.variants', '$.qr', '$.rows', '$.live'] }; /* 每种字段、分支切换、扫码流程、行结果、限时授权 */