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,1512 @@
1
+ /* 边界:一个含义一个组件、不为接口定制、不按位置推导样式 */
2
+ /* 视图块:PDL 块的画法(PDL_BLOCKS)、片段、控件、行、设置行、头、读取状态、节点模板、小节目录 */
3
+ /* 视图块的画法(组件库):片段、控件、行、设置行、头、列表、全部块(PDL_BLOCKS 的内容)、节点模板、读取状态、提示、小节目录。
4
+ 视图引擎(取值、本地化、按块派发、视图的读取状态、下钻的返回)在 engine/pdl-view.js;这里画,块、块的属性契约(PDL_SCHEMA)和角色变体(PDL_ROLES)只在这里登记(lint:pdl-block)。 */
5
+ 'use strict';
6
+ /* 组件的角色变体:一个组件只有一个默认样子;变体只表示真正不同的角色,每个变体的含义写在这里(契约的一部分,组件目录也从这里读)。
7
+ 不在这张表里的变体不存在:墨色、字重、留白、对齐、所在位置都不是变体——组件的默认就是它们的样子。新增变体先在这里写清楚它是什么角色 */
8
+ const PDL_ROLES = { /* 每个角色的含义(组件目录显示的那句话)在文案包 catalog.role.<组件>.<角色>,这里的注释是同一句 */
9
+ box: [
10
+ 'card', /* 自成一体的一张卡片(消息里的决策卡、富内容块、评审表单) */
11
+ 'group', /* 一组并列项的分组底(项之间是分隔线) */
12
+ 'composer', /* 输入区:打字的范围,正文和它的工具条在里面 */
13
+ 'log', /* 跟随最新的滚动区(消息流、执行记录):贴底,新内容出现在底部 */
14
+ 'scroll', /* 占满所在容器剩下高度的滚动区(收件箱、回放) */
15
+ 'expand', /* 一行或一项展开出来的详情区(缩进在它的主人下面) */
16
+ 'inline', /* 子块排成一行,放不下时换行 */
17
+ 'columns', /* 子容器并排:按声明的顺序从左到右,自带宽度的(目录)不伸缩,其余平分剩下的宽度 */
18
+ 'viewport', /* 内嵌的视口(页面预览):占满可用高度,裁掉溢出 */
19
+ 'hero', /* 落地区:空页面的问候和开始方式 */
20
+ 'dock' /* 停靠在内容盒底部的一块(落地页预览作品时的输入框) */
21
+ ],
22
+ toolbar: [
23
+ 'head', /* 容器的标题行:一排格子,返回在最前面 */
24
+ 'savebar', /* 有未保存的改动时贴在底部的保存条 */
25
+ 'selection', /* 对选中项的批量操作条 */
26
+ 'embed', /* 嵌在正文里的一件东西(附件、小组件、音频、批注) */
27
+ 'marker', /* 流里居中的一条标记(更早的消息、已删除、导入来源) */
28
+ 'float' /* 浮在内容上面的一条(查找结果、语音建议) */
29
+ ],
30
+ head: [
31
+ 'detail', /* 下钻出来的详情或子层的头:眉题、副标题,取下钻的返回 */
32
+ 'hero' /* 落地区的问候 */
33
+ ],
34
+ pop: [
35
+ 'card' /* 非滚动的悬停摘要卡;与滚动弹出层共用浮层外壳 */
36
+ ],
37
+ text: [
38
+ 'value', /* 一项设置 / 字段的值(只读):正文字号的次要墨色;mono / num 是值的种类 */
39
+ 'para', /* 一段正文 */
40
+ 'meta', /* 次要信息(时间、数量、来源、状态说明) */
41
+ 'title', /* 卡片的标题 */
42
+ 'list' /* 一列要点 */
43
+ ],
44
+ part: [
45
+ 'meta', /* 片段里的次要信息 */
46
+ 'badge', /* 短代码徽标(优先级、文件状态),颜色来自 tone */
47
+ 'twisty' /* 跟着所在按钮的展开状态转动的箭头 */
48
+ ],
49
+ button: [
50
+ 'meta', /* 次要信息那一行里的文字按钮(过程记录、召回、轨迹) */
51
+ 'nav', /* 页面目录里的一项(和侧栏导航同一种行) */
52
+ 'cycle', /* 点一下换到下一个状态的圆形标记(任务状态) */
53
+ 'title', /* 可点的标题(点了改名) */
54
+ 'drawer', /* 打开侧栏抽屉(只在侧栏收成抽屉时出现) */
55
+ 'reveal', /* 把收起的侧栏放回来(侧栏是抽屉时没有它) */
56
+ 'terminalOpen', /* 打开终端:电源图标,悬停变绿 */
57
+ 'terminalClose' /* 关闭终端:电源图标,悬停变红 */
58
+ ],
59
+ check: [
60
+ 'row' /* 列表行前面的选择框(名字只给读屏) */
61
+ ],
62
+ more: [
63
+ 'row' /* 列表行尾的“更多”(带行的键) */
64
+ ],
65
+ choices: [
66
+ 'multi' /* 多选:一项一个勾选 */
67
+ ],
68
+ input: [
69
+ 'title', /* 就地改名的标题输入 */
70
+ 'date' /* 原生日期选择 */
71
+ ],
72
+ inlineEdit: [
73
+ 'title' /* 点击原地编辑的容器标题(如对话栏左上角主题标题) */
74
+ ],
75
+ select: [
76
+ 'member' /* 选成员:带头像,可多选 */
77
+ ],
78
+ seg: [
79
+ 'tabs' /* 兼容既有声明:与默认分段统一画成 .seg */
80
+ ],
81
+ split: [
82
+ 'aside', /* 主栏 + 侧栏(不是列表 → 详情) */
83
+ 'compare' /* 两个等价内容对照;窄容器自然换行 */
84
+ ],
85
+ stats: [
86
+ 'counters' /* 一行计数 + 操作(不是一格一格的数字) */
87
+ ],
88
+ steps: [
89
+ 'checks', /* 清单:做完的打勾 */
90
+ 'flow', /* 流程图:区域里的节点和箭头 */
91
+ 'progress' /* 阶段进度:做完 / 当前 / 未到;有动作时每一步可点 */
92
+ ]
93
+ };
94
+ function R(k) { return PDL_ROLES[k].slice(); }
95
+ /* 每个块 / 控件声明自己接受的属性(组件契约):1 = 任意值或数据绑定;数组 = 只能取这些枚举 / 档位('$' 表示也可以是数据绑定)。
96
+ PDL 里出现没声明的属性、或者枚举外的字面值,结构检查(pdl-schema)就报错。新增属性先在这里声明 */
97
+ Object.assign(PDL_SCHEMA, {
98
+ /* 行模板(列表的 row:PDL_ROWS 里的实体模板,或列表声明里就地写的字段映射):layout 必填,取组件库的一种行布局(组件库 rows.js ROW_LAYOUTS;tree 只由树块用);
99
+ 其余是数据绑定。_rowNo:每种布局不接受的字段(单行没有副行;记录行声明了 expand 也能在原位展开,lang 2026-11-18) */
100
+ _row: { layout: ['line', 'two', 'item', 'record'], key: 1, lead: 1, title: 1, inline: 1, inlineEdit: 1, sub: 1, meta: 1, cols: 1, acts: 1, tone: 1, color: 1, bar: 1, act: 1, args: 1, note: 1, expand: 1, titleWrap: ['$', 'auto', 'open'], more: 1, moreWhen: 1, moreAfter: 1, cur: 1, aside: 1, swap: 1, subLines: 1, label: 1, help: 1, when: 1 },
101
+ _rowNo: { line: ['sub', 'meta', 'subLines'], two: ['subLines'], item: [], record: ['sub', 'meta', 'aside', 'swap', 'subLines'] },
102
+ app: { demo: 1, name: ['entry', 'stripe', 'handle'], region: 1, when: 1 },
103
+ back: { act: 1, args: 1, label: 1, when: 1 }, /* 返回放在这里(引擎的返回);act / args 是没有返回可回时的去处 */
104
+ box: { blocks: 1, faint: 1, fill: 1, follow: 1, note: 1, open: 1, tone: ['$', 'info', 'ok', 'warn', 'danger'], variant: R('box'), when: 1 },
105
+ jump: { act: 1, args: 1, icon: 1, label: 1, tip: 1, when: 1, hideWhileTyping: 1 },
106
+ notices: { items: 1, key: 1, when: 1, hideWhileTyping: 1 },
107
+ stack: { items: 1, when: 1 },
108
+ button: { act: 1, args: 1, aria: 1, busy: 1, danger: 1, disabled: 1, expanded: 1, items: 1, icon: 1, iconOnly: 1, label: 1, link: 1, menu: 1, note: 1, open: 1, parts: 1, pressed: 1, state: 1, submit: 1, tip: 1, current: 1, primary: 1, size: ['xs'], variant: R('button'), when: 1, who: 1 },
109
+ capsules: { act: 1, from: 1, label: 1 },
110
+ check: { act: 1, args: 1, label: 1, tint: 1, value: 1, variant: R('check'), when: 1 },
111
+ chip: { act: 1, args: 1, check: 1, ellip: 1, faint: 1, icon: 1, kind: 1, label: 1, pressed: 1, thumb: 1, tint: 1, tip: 1, tone: 1, when: 1, x: 1 },
112
+ choices: { act: 1, args: 1, from: 1, group: 1, ro: 1, value: 1, variant: R('choices'), when: 1 },
113
+ component: { props: 1, use: 1, when: 1 },
114
+ content: { annotations: 1, fold: 1, html: 1, note: 1, raw: 1, when: 1 },
115
+ result: { actions: 1, blocks: 1, key: 1, label: 1, status: ['$', 'approved', 'rejected', 'expired', 'withdrawn', 'closed', 'unconfirmed'], when: 1 },
116
+ tints: { act: 1, args: 1, value: 1, label: 1 },
117
+ toc: { note: 1, when: 1 }, /* 小节目录:条目来自同一视图里带 id 的小节标题(锚点),不另给数据 */
118
+ disclosure: { act: 1, actions: 1, args: 1, blocks: 1, count: 1, key: 1, note: 1, open: 1, sub: 1, summary: 1, title: 1, trail: 1, when: 1 }, /* summary:标题下始终显示的内容;actions:标题行后的行内操作;act:开合由视图模型管(open 来自数据) */
119
+ each: { blocks: 1, control: 1, from: 1, itemKey: 1, when: 1 },
120
+ empty: { action: 1, help: 1, icon: 1, text: 1, when: 1 },
121
+ fold: { blocks: 1, height: ['m', 's'], key: 1, more: { act: 1, args: 1, when: 1 }, shape: ['$', 'bottom'], when: 1 },
122
+ dialog: { pop: 1, title: 1, help: 1, wide: 1, layout: ['viewport', 'fill', 'lightbox'], span: ['full'], rows: 1, form: 1, error: 1, actions: 1, footer: 1, blocks: 1, when: 1 }, /* footer:底部区域的块声明,与标题栏 actions 分开。 */
123
+ form: { args: 1, blocks: 1, from: 1, htmlId: 1, id: 1, note: 1, when: 1 },
124
+ frame: { html: 1, src: 1, message: 1, on: 1, icon: 1, note: 1, plugin: 1, tall: 1, title: 1, what: 1, when: 1 }, /* html 自动量内容;src 填满视口。on.message 把框内消息交给动作,origin 的判断属于应用。 */
125
+ grow: { when: 1 },
126
+ head: { actNote: 1, tools: 1, descAction: 1, actions: 1, close: 1, count: 1, desc: 1, eyebrow: 1, help: 1, label: 1, lead: 1, meta: 1, note: 1, sub: 1, title: 1, variant: R('head'), when: 1 },
127
+ input: { change: 1, complete: 1, grow: 1, disabled: 1, id: 1, input: 1, on: 1, label: 1, rows: 1, code: 1, lead: 1, listFrom: 1, reload: 1, max: 1, mono: 1, num: 1, placeholder: 1, post: 1, ro: 1, invalid: 1, secret: 1, value: 1, variant: R('input'), when: 1,
128
+ go: 1, args: 1, icon: 1, goLabel: 1, cancel: 1, more: 1, tint: 1, add: 1 }, /* go:回车 / 框里的图标提交到这个动作(组件库 goField);cancel:Esc / 失焦;more:同一个框里的另几个输入;tint:框里的选色 { id, value, input, label }(组件库的取色器) */
129
+ inlineEdit: { act: 1, args: 1, disabled: 1, id: 1, label: 1, max: 1, note: 1, selectStem: 1, tip: 1, value: 1, variant: R('inlineEdit'), when: 1 },
130
+ kv: { actions: 1, from: 1, itemKey: 1, when: 1 },
131
+ label: { action: 1, count: 1, help: 1, text: 1, tip: 1, when: 1 },
132
+ lanes: { lanes: 1, when: 1 }, /* 每条道:{ share(不写 = 按内容定宽), name, scroll, align: 'start' | 'center' | 'end', attach: 'above' | 'straddle', items } */
133
+ list: { actions: 1, count: 1, empty: 1, emptyAction: 1, expand: ['many'], from: 1, group: 1, groups: 1, id: 1, inline: 1, label: 1, next: 1, optional: ['true'], order: 1, pagination: 1, partial: 1, reverse: ['true'], row: 1, rows: 1, scroll: 1, searchable: ['true'], when: 1 }, /* pagination:本地列表逐页替换,可用 resetOn 在查询变化时回首页 */
134
+ /* 列表总是画出来(没有数据时是组件库的空状态,文字是 empty);label / count = 列表自己的组标签;optional = 只在有项时才有的子组:没有项时连组标签一起不画 */
135
+ markdown: { annotations: 1, clamp: 1, empty: 1, from: 1, more: 1, text: 1, when: 1 },
136
+ more: { args: 1, items: 1, k: 1, label: 1, menu: 1, size: ['s', 'm'], variant: R('more'), when: 1 }, /* items:菜单项在这里声明(pvMenu);menu:老的按名字登记的菜单 */
137
+ notice: { action: 1, each: 1, from: 1, items: 1, note: 1, num: 1, parts: 1, strong: 1, text: 1, tone: ['$', 'info', 'ok', 'warn', 'danger'], when: 1 },
138
+ ordered: { blocks: 1, order: 1, when: 1 },
139
+ picker: { act: 1, args: 1, items: 1, auto: 1, autoTip: 1, check: 1, disabled: 1, icon: 1, label: 1, parts: 1, prefix: 1, tip: 1, when: 1, who: 1 },
140
+ pre: { annotations: 1, rows: 1, text: 1, when: 1 },
141
+ pop: { blocks: 1, page: 1, pos: 1, view: 1, label: 1, variant: R('pop'), when: 1 },
142
+ opts: { empty: 1, from: 1, when: 1 },
143
+ chatpage: { bar: 1, body: 1, dock: 1, head: 1, side: 1, top: 1 }, /* 子容器 stream / composer 的顺序由用户层的 order['main.chat'] 决定 */
144
+ ticks: { from: 1, older: 1, when: 1 },
145
+ threads: { from: 1, groups: 1, heads: 1, move: 1, note: 1, other: 1, rename: 1, when: 1 },
146
+ range: { args: 1, change: 1, id: 1, input: 1, label: 1, max: 1, min: 1, step: 1, unit: 1, value: 1, when: 1 },
147
+ reply: { ref: 1 },
148
+ via: { via: 1, when: 1 },
149
+ search: { form: 1, id: 1, input: 1, on: 1, label: 1, note: 1, placeholder: 1, value: 1, when: 1, wide: 1 },
150
+ section: { actions: 1, blocks: 1, from: 1, help: 1, id: 1, keep: 1, key: 1, label: 1, note: 1, open: 1, row: 1, rows: 1, title: 1, when: 1 },
151
+ seg: { act: 1, args: 1, from: 1, label: 1, options: 1, slot: 1, value: 1, variant: R('seg'), when: 1 },
152
+ select: { span: 1, act: 1, args: 1, change: 1, disabled: 1, from: 1, id: 1, invalid: 1, label: 1, multi: 1, none: 1, options: 1, prefix: 1, tip: 1, value: 1, variant: R('select'), when: 1 },
153
+ send: { act: 1, args: 1, disabled: 1, stop: 1, stopping: 1, tip: 1 },
154
+ settings: { from: 1, itemKey: 1, plain: 1, row: 1, rows: 1, when: 1 },
155
+ slot: { ctx: 1, slot: 1 },
156
+ split: { back: 1, left: 1, picked: 1, right: 1, scroll: ['panes'], follow: ['left', 'right', 'both'], variant: R('split'), when: 1 }, /* follow:独立滚动的一侧跟随最新内容;picked:窄屏下钻的选中状态;back:选中是状态(不导航)时,收起后详情的返回。 */
157
+ panes: { panes: 1, when: 1 }, /* panes: [{ key, title, min, max | fill, when, back, blocks }]:按容器宽度并排或栈顶覆盖 */
158
+ stats: { actions: 1, from: 1, itemKey: 1, items: 1, variant: R('stats'), when: 1 }, /* 数字块只有两种:一格一格的数字(默认)、一行计数 + 操作(counters) */
159
+ status: { text: 1, tone: ['$', 'info', 'ok', 'warn', 'danger'], when: 1 },
160
+ steps: { act: 1, args: 1, from: 1, variant: R('steps'), when: 1 },
161
+ stream: { from: 1, id: 1 }, /* id:这条消息流的名字(同名的流里,新出现的消息走统一的“到达”动效;对话主流就是 chat.stream 视图) */
162
+ switch: { act: 1, args: 1, disabled: 1, label: 1, tip: 1, value: 1, when: 1 }, /* label 是名字(提示和读屏),开关旁边不写字 */
163
+ tabs: { act: 1, after: 1, args: 1, close: 1, from: 1, label: 1, parts: 1, selected: 1, tip: 1 },
164
+ text: { actions: 1, count: 1, faint: 1, for: 1, from: 1, help: 1, label: 1, mono: 1, num: 1, parts: 1, sep: 1, text: 1, tip: 1, tone: ['$', 'info', 'ok', 'warn', 'danger'], variant: R('text'), when: 1 },
165
+ tiles: { act: 1, from: 1 },
166
+ tags: { add: 1, empty: 1, from: 1, pick: 1, remove: 1, when: 1, id: 1, k: 1, kind: 1, label: 1, lock: 1, placeholder: 1, values: 1 }, /* values:一列字(别名、参数)的编辑器(id / k / kind / lock,增删走 chipAdd / chipDel) */ /* 标签编辑器(唯一一个):一排标签(色调点 · 名字 · 对话数;pick 时可勾选,remove 时带 ×)+ 新建标签的输入 */
167
+ toolbar: { args: 1, dropAct: 1, form: 1, hidden: 1, id: 1, items: 1, left: 1, note: 1, parts: 1, right: 1, tone: ['$', 'warn'], variant: R('toolbar'), when: 1 },
168
+ tree: { collapsedTip: 1, divider: 1, fileAct: 1, fileArgs: 1, flat: 1, id: 1, nodes: 1, pending: 1, ready: 1, row: 1, select: 1, when: 1 }, /* collapsedTip:目录折叠时用双箭头显示的子级提示 */
169
+ upload: { accept: 1, hidden: 1, multiple: 1, icon: 1, iconOnly: 1, id: 1, label: 1, msg: 1, args: 1 },
170
+ copy: { field: 1, fieldLabel: 1, label: 1, mono: 1, tail: 1, tip: 1, v: 1, value: 1, when: 1 }, /* 可复制的值:值 + 复制图标(label 说复制的是什么,tip 是值的提示,v 是复制的内容,默认就是值) */
171
+ view: { id: 1, data: 1, when: 1 },
172
+ typed: { slot: 1, of: 1, data: 1, blocks: 1, when: 1 }, /* 按渲染类型画:of 是类型(容器.子类型),data 是这一项交给模板的数据,blocks 是没有模板时宿主的默认画法 */ /* data 显式给子视图的正文 VM;未声明时由子视图自己的 vm 取数。 */
173
+ /* 视图模型里直接给的控件(表单字段的 control) */
174
+ kvlist: { add: 1, del: 1, empty: 1, eye: 1, input: 1, key: 1, keyPh: 1, path: 1, ro: 1, rows: 1, single: 1 },
175
+ avatar: { args: 1, lead: 1, size: ['$', 'xs', 's', 'm', 'l', 'xl'], upload: 1 },
176
+ color: { id: 1, input: 1, label: 1, preview: 1, slots: ['name'], value: 1, when: 1 }
177
+ });
178
+ const RESULT_TONE = { approved: 'ok', rejected: 'danger' };
179
+ /* 按钮的两个外壳角色(PDL_ROLES.button):drawer = 打开侧栏抽屉(只在侧栏收成抽屉时出现);reveal = 把收起的侧栏放回来(侧栏是抽屉时没有它)。出不出现由组件库的样式按容器决定 */
180
+ const BTN_ROLE_CLS = { drawer: 'nav-toggle', reveal: 'pdl-reveal', terminalOpen: 'term-open', terminalClose: 'term-close' }; /* 决定结果的状态 → 色调(组件自己的表) */
181
+ /* 组件目录的登记(和契约放在一起,只有这一份):每个块 / 控件属于哪一组(g),示例是 PDL(ex,和页面写法一样,数据来自目录的样例视图模型 /api/catalog/sample)。
182
+ tones:带严重度的组件按四档(info / ok / warn / danger)各画一次,示例里的 %tone 换成那一档。目录(catalog.js)从这里和 PDL_SCHEMA 枚举,不另写一份清单 */
183
+ const PDL_CATALOG = {
184
+ app: { g: 'structure', ex: [{ type: 'chatpage', key: 'catalog.handle', body: [{ type: 'text', text: '$.title' }], side: [{ type: 'app', name: 'handle', region: 'panel', demo: true }] }] }, /* 固定件放在所属容器里展示;demo 不看区域当前开关。 */
185
+ back: { g: 'basics', ex: [{ type: 'back', label: 't:common.cancel', act: 'noop' }] },
186
+ dialog: { g: 'popups', ex: [{ type: 'button', label: 't:common.open', act: 'catalogDialog' }] },
187
+ box: { g: 'structure', ex: [{ type: 'box', variant: 'card', blocks: [{ type: 'text', variant: 'title', text: '$.title' }, { type: 'text', variant: 'para', text: '$.sub' }] }],
188
+ tones: [{ type: 'box', variant: 'card', tone: '%tone', blocks: [{ type: 'text', variant: 'title', text: '$.toneText.%tone' }] }] },
189
+ jump: { g: 'composer', ex: [{ type: 'jump', icon: 'latest', label: 't:composer.jump', tip: 't:composer.jump', act: 'noop' }] },
190
+ notices: { g: 'alerts', ex: [{ type: 'notices', items: '$.notices' }], tones: [{ type: 'notices', items: '$.noticeTones.%tone' }] },
191
+ stack: { g: 'composer', ex: [{ type: 'stack', items: [{ type: 'chip', label: '$.chips.0' }, { type: 'chip', label: '$.chips.1' }] }] },
192
+ button: { g: 'basics', ex: [{ type: 'button', variant: 'meta', act: 'noop', parts: [{ icon: 'trace', size: 's' }, { text: '$.label' }] }, { type: 'button', primary: true, label: '$.save', act: 'noop' }, { type: 'button', label: '$.cancel', act: 'noop' }, { type: 'button', danger: true, label: 't:common.delete', act: 'noop' }, { type: 'button', primary: true, danger: true, label: 't:common.delete', act: 'noop' }, { type: 'button', link: true, label: '$.more', act: 'noop' }, { type: 'button', iconOnly: true, icon: 'copy', label: 't:common.copy', act: 'noop' }] },
193
+ capsules: { g: 'identity', ex: [{ type: 'capsules', from: '$.runners', label: '$.title' }] },
194
+ check: { g: 'basics', ex: [{ type: 'check', value: '$.on', label: '$.label', act: 'noop' }, { type: 'check', value: '$.off', label: '$.label2', act: 'noop' }] },
195
+ each: { g: 'structure', ex: [{ type: 'each', from: '$.eachRows', blocks: [{ type: 'notice', text: '@title' }] }, { type: 'toolbar', items: [{ type: 'each', from: '$.kv', control: { type: 'chip', kind: '@k', label: '@v', act: 'noop' } }] }] },
196
+ chip: { g: 'basics', ex: [{ type: 'chip', label: '$.chips.0' }, { type: 'chip', label: '$.chips.1', act: 'noop', pressed: true, check: true }, { type: 'chip', icon: 'file', label: '$.chips.2', x: { act: 'noop', label: 't:common.remove' } }, { type: 'chip', thumb: '$.lightbox.src', label: '$.chips.0', act: 'noop', x: { act: 'noop', label: 't:common.remove' } }] },
197
+ choices: { g: 'basics', ex: [
198
+ { type: 'choices', variant: 'multi', from: '$.checks', act: 'noop' },
199
+ { type: 'choices', group: 'cat-ch', from: '$.opts', value: 'a' },
200
+ { type: 'choices', group: 'cat-ch-readonly', from: '$.opts', value: 'a', ro: true }
201
+ ] },
202
+ component: { g: 'structure', ex: [{ type: 'component', use: 'diff', props: '$.diff' }] },
203
+ content: { g: 'message', ex: [{ type: 'content', html: '$.long' }] },
204
+ tints: { g: 'basics', ex: [{ type: 'tints', value: '$.tint', act: 'noop', label: '$.label' }] },
205
+ toc: { g: 'structure', ex: [{ type: 'box', variant: 'columns', blocks: [{ type: 'toc' }, { type: 'box', blocks: [{ type: 'section', id: 'cat-toc-a', title: '$.title', keep: true, blocks: [{ type: 'text', variant: 'para', text: '$.sub' }] }, { type: 'section', id: 'cat-toc-b', title: '$.label2', keep: true, blocks: [{ type: 'text', variant: 'para', text: '$.sub' }] }] }] }] },
206
+ disclosure: { g: 'structure', ex: [{ type: 'disclosure', key: 'a', act: 'noop', open: '$.on', title: '$.title', sub: '$.sub', blocks: [{ type: 'text', variant: 'para', text: '$.long' }] }, { type: 'disclosure', key: 'catalog-disc', title: '$.title', blocks: [{ type: 'settings', from: '$.setRows' }] }, { type: 'disclosure', title: '$.label2', blocks: [{ type: 'text', variant: 'para', text: '$.sub' }] }] },
207
+ empty: { g: 'structure', ex: [{ type: 'empty', text: '$.empty', help: '$.emptyHelp' }, { type: 'empty', icon: 'puzzle', text: '$.empty' }] },
208
+ fold: { g: 'structure', ex: [{ type: 'fold', key: 'catalog-fold', height: 's', blocks: [{ type: 'text', variant: 'para', text: '$.long' }] }] },
209
+ form: { g: 'structure', ex: [{ type: 'form', id: 'catalog', blocks: [{ type: 'settings', from: '$.setRows' }] }] },
210
+ frame: { g: 'structure', ex: [{ type: 'frame', plugin: 'companion', what: '$.title' }, { type: 'frame', icon: '$.preview.icon', title: '$.preview.title', note: '$.preview.note' }, { type: 'frame', html: '<p>HTML</p>', title: '$.title' } ] },
211
+ grow: { g: 'structure', ex: [{ type: 'toolbar', items: [{ type: 'button', label: '$.cancel', act: 'noop' }, { type: 'grow' }, { type: 'button', primary: true, label: '$.save', act: 'noop' }] }] },
212
+ head: { g: 'structure', ex: [{ type: 'head', lead: [{ glyph: '$.packageIcon' }], title: '$.title', actions: [{ type: 'button', label: '$.more', act: 'noop' }] }] },
213
+ input: { g: 'basics', ex: [{ type: 'input', id: 'cat-in', placeholder: '$.placeholder' }, { type: 'input', id: 'cat-ta', rows: 3, placeholder: '$.placeholder', value: '' }, { type: 'input', id: 'cat-in2', value: '$.value', label: '$.label', mono: true }, { type: 'input', id: 'cat-ta-grow', rows: true, grow: true, complete: '$.history', placeholder: '$.placeholder', value: '' }] },
214
+ kv: { g: 'rows', ex: [{ type: 'kv', from: '$.kvPeople' }, { type: 'kv', from: '$.kvLong' }] },
215
+ label: { g: 'rows', ex: [{ type: 'label', text: '$.title', count: '$.n' }, { type: 'label', text: '$.label', help: '$.sub' }] },
216
+ lanes: { g: 'composer', ex: [{ type: 'lanes', lanes: [{ share: 1, name: 'run', scroll: true, items: [{ type: 'capsules', from: '$.runners', label: '$.title' }] }, { share: 3, name: 'notice', align: 'center', items: [{ type: 'notices', items: '$.notices' }] }, { share: 1, name: 'queue', align: 'end', items: [{ type: 'chip', label: '$.chips.0' }] }] }] },
217
+ list: { g: 'rows', ex: [{ type: 'list', from: '$.rows', row: { layout: 'two', title: '@title', sub: '@sub' } }] },
218
+ markdown: { g: 'message', ex: [{ type: 'markdown', text: '$.md' }] },
219
+ more: { g: 'basics', ex: [{ type: 'more', menu: 'work', label: '$.more' }] },
220
+ notice: { g: 'alerts', ex: [{ type: 'notice', text: '$.sub' }, { type: 'notice', tone: 'warn', text: '$.toneText.warn' }],
221
+ tones: [{ type: 'notice', tone: '%tone', text: '$.toneText.%tone' }],
222
+ banner: [{ type: 'notice', tone: '%tone', strong: '$.bannerStrong.%tone', text: '$.toneText.%tone', action: [{ type: 'button', sm: true, label: '$.more', act: 'noop' }, { type: 'button', sm: true, label: '$.save', act: 'noop' }] }] },
223
+ ordered: { g: 'structure', ex: [{ type: 'ordered', order: '$.order', blocks: { a: { type: 'notice', text: '$.label' }, b: { type: 'notice', text: '$.label2' } } }] },
224
+ picker: { g: 'composer', ex: [{ type: 'picker', label: '$.chips.0', prefix: 't:composer.afterCreate', act: 'noop', icon: 'box' }, { type: 'picker', label: '$.label2', check: '$.on', act: 'noop' }] },
225
+ pre: { g: 'basics', ex: [{ type: 'pre', text: '$.code' }] },
226
+ color: { g: 'basics', ex: [{ type: 'color', id: 'cat-col-b', value: '$.color.value', label: '$.color.label', preview: '$.color.label', slots: 'name' }] },
227
+ pop: { g: 'popups', ex: [{ type: 'pop', pos: '$.popPos', blocks: [{ type: 'opts', from: '$.pop' }] }] },
228
+ opts: { g: 'popups', ex: [{ type: 'opts', from: '$.pop' }] },
229
+ chatpage: { g: 'message', ex: [{ type: 'chatpage', key: 'catalog.chat', head: [{ type: 'head', title: '$.title' }], body: [{ type: 'stream', id: 'catalog', from: '$.stream' }], dock: [{ type: 'notice', text: '$.placeholder' }] }] },
230
+ ticks: { g: 'message', ex: [{ type: 'ticks', from: '$.ticks' }] },
231
+ typed: { g: 'structure', ex: [{ type: 'typed', slot: 'chat.rich', of: 'card', data: '$', blocks: [{ type: 'notice', text: '$.label' }] }] },
232
+ threads: { g: 'rows', ex: [{ type: 'threads', from: '$.threads' }] },
233
+ range: { g: 'basics', ex: [{ type: 'range', id: 'cat-range', min: 0, max: 100, step: 5, value: '$.range', unit: '%', input: 'noop', label: '$.label' }] },
234
+ reply: { g: 'message', ex: [{ type: 'reply', ref: '$.reply' }] },
235
+ via: { g: 'message', ex: [{ type: 'via', via: { icon: 'relayOut', dir: 'out', title: '$.title', summary: '$.sub', act: 'noop' } }] },
236
+ search: { g: 'basics', ex: [{ type: 'search', id: 'cat-q', placeholder: '$.search', value: '' }] },
237
+ section: { g: 'structure', ex: [{ type: 'section', title: '$.title', help: '$.sub', actions: [{ type: 'button', label: '$.more', act: 'noop' }], blocks: [{ type: 'settings', from: '$.setRows' }] }] },
238
+ seg: { g: 'basics', ex: [{ type: 'seg', from: '$.seg', act: 'noop' }, { type: 'seg', variant: 'tabs', from: '$.seg', act: 'noop' }] },
239
+ select: { g: 'basics', ex: [{ type: 'select', id: 'cat-sel', options: '$.opts', value: 'a', label: '$.label' }, { type: 'select', id: 'cat-sel2', options: '$.opts', value: 'b' }, { type: 'select', variant: 'member', id: 'cat-mp', options: '$.memberOpts', value: '$.memberOne', label: '$.label' }, { type: 'select', variant: 'member', multi: true, id: 'cat-mp2', options: '$.memberOpts', value: '$.memberSome', act: 'noop', label: '$.label' }] },
240
+ send: { g: 'composer', ex: [{ type: 'send', tip: '$.save' }, { type: 'send', stop: '$.on', tip: '$.cancel' }] },
241
+ settings: { g: 'structure', ex: [{ type: 'settings', from: '$.setRows' }, { type: 'settings', rows: [{ label: '$.label', ctls: [{ type: 'switch', value: '$.on', act: 'noop', label: '$.label' }] }] }] },
242
+ slot: { g: 'message', ex: [{ type: 'slot', slot: 'chat.message.actions', ctx: '$.slotCtx' }] },
243
+ split: { g: 'structure', ex: [{ type: 'split', variant: 'aside', left: [{ type: 'settings', from: '$.setRows' }], right: [{ type: 'kv', from: '$.kv' }] }, { type: 'split', variant: 'aside', scroll: 'panes', left: [{ type: 'markdown', text: '$.md' }], right: [{ type: 'settings', from: '$.setRows' }] }] },
244
+ stats: { g: 'rows', ex: [{ type: 'stats', from: '$.stats' }] },
245
+ result: { g: 'message', ex: [{ type: 'result', status: 'approved', label: '$.statusText.ok', key: 'cat-result', blocks: [{ type: 'text', variant: 'para', text: '$.sub' }] }, { type: 'result', status: 'expired', label: '$.statusText.info', key: 'cat-result2' }] },
246
+ status: { g: 'alerts', ex: [{ type: 'status', text: '$.statusText.info' }, { type: 'status', tone: 'ok', text: '$.statusText.ok' }], tones: [{ type: 'status', tone: '%tone', text: '$.statusText.%tone' }] },
247
+ steps: { g: 'rows', ex: [{ type: 'steps', from: '$.steps' }, { type: 'steps', variant: 'checks', from: '$.stepChecks' }, { type: 'steps', variant: 'progress', from: '$.stepChecks' }] },
248
+ stream: { g: 'message', ex: [{ type: 'stream', id: 'catalog', from: '$.stream' }] },
249
+ switch: { g: 'basics', ex: [{ type: 'switch', value: '$.on', act: 'noop', label: '$.label' }, { type: 'switch', value: '$.off', act: 'noop', label: '$.label2' }] },
250
+ tabs: { g: 'structure', ex: [{ type: 'tabs', label: '$.title', from: '$.tabs', act: 'noop', args: { k: '@k' }, selected: '@on', tip: '@label', parts: [{ text: '@label' }] }] },
251
+ text: { g: 'basics', ex: [{ type: 'text', variant: 'para', text: '$.sub' }, { type: 'text', variant: 'meta', text: '$.value' }], tones: [{ type: 'text', variant: 'meta', tone: '%tone', text: '$.statusText.%tone' }] },
252
+ tiles: { g: 'basics', ex: [{ type: 'tiles', from: '$.tiles', act: 'noop' }] },
253
+ tags: { g: 'rows', ex: [{ type: 'tags', id: 'cat-chipbox', values: '$.chipVals', k: 'tags', placeholder: '$.placeholder', label: '$.label' }, { type: 'tags', from: '$.tagItems', pick: { act: 'noop' }, remove: { act: 'noop', label: 't:classify.deleteTag' }, add: { id: 'cat-tag', act: 'noop', tint: { id: 'cat-tag-tint', value: '#94b2cc', label: 't:control.color' } } }] },
254
+ toolbar: { g: 'structure', ex: [{ type: 'toolbar', left: [{ type: 'text', variant: 'meta', text: '$.title' }], right: [{ type: 'button', label: '$.more', act: 'noop' }, { type: 'button', primary: true, label: '$.save', act: 'noop' }] }] },
255
+ tree: { g: 'rows', ex: [{ type: 'tree', id: 'catalog-tree', nodes: '$.tree', row: { lead: [{ icon: 'folder', size: 's', when: '@dir' }, { icon: 'file', size: 's', when: '!@dir' }], title: { text: '@name', mono: true } } }] },
256
+ upload: { g: 'basics', ex: [{ type: 'upload', icon: 'upload', label: '$.upload', accept: 'image/*', msg: '$.value' }] },
257
+ copy: { g: 'basics', ex: [{ type: 'copy', value: '$.path', label: 't:composerPop.copyPath', tip: 't:composerPop.pathReadonly', mono: true }] }, /* 可复制的值:值 + 复制图标 */
258
+ view: { g: 'structure', ex: [{ type: 'view', id: 'chat.welcome' }] },
259
+ kvlist: { g: 'basics', ex: [{ type: 'kvlist', key: 'catalog', rows: '$.kvRows', input: 'noop', add: 'noop', del: 'noop' }] },
260
+ avatar: { g: 'identity', ex: [{ type: 'avatar', lead: '$.lead', size: 'l' }] }
261
+ };
262
+
263
+ /* ───────── 片段 ───────── */
264
+ /* 图标档位(PDL 只写档位):xs 12 · s 14 · m 16 · l 20 */
265
+ const ICON_STEP = { xs: 12, s: 14, m: 16, l: 20 };
266
+ /* 片段的角色(PDL_ROLES.part):meta 次要信息、badge 短代码徽标(颜色来自 tone)、twisty 跟着展开状态转的箭头 */
267
+ const PART_ROLE = { meta: 'vw-meta', badge: 'vw-badge', twisty: 'vw-ic vw-turn' };
268
+ function pvPart(p, sc, root) {
269
+ if (p == null) return '';
270
+ if (typeof p === 'string') return pvText(p, sc, root);
271
+ if (typeof p !== 'object') return h(String(p)); /* 数字、布尔(插件和接口的数据里常有)按文字画 */
272
+ if (!pvOk(p.when, sc, root)) return '';
273
+ if (p.lit != null) return h(String(p.lit));
274
+ if ('of' in p) { const x = pv(p, sc, root); return x == null ? '' : typeof x === 'object' ? pvPart(x, sc, root) : h(String(x)); } /* 值的写法 / 值映射当片段:取到字就转义,取到片段就照片段画 */
275
+ if (p.use) { const f = pdlComponent(p.use); if (!f) console.error(tc('engine.part.error', p.use)); return f ? f(pv(p.props, sc, root), sc, root) : ''; }
276
+ if (p.control) return typeof p.control === 'string' ? pvControls(p.control, sc, root) : pvControl(p.control, sc, root); /* 写成路径:控件来自数据(行自己的勾选这类) */
277
+ if (p.roll) { /* 轮换的一行:先显示 a(当前动作),停 --roll-hold 后向上滚成 b(累计数);a 变了节点就重画,动画从头开始。at = 这个动作开始的时刻(生成 HTML 时才算过去了多久,视图模型被缓存也照样接着走;旧的 t = 秒数仍认) */
278
+ const r = pv(p.roll, sc, root); if (!r) return '';
279
+ /* after:跟在每一行文字后面的尾巴(比如展开的箭头)——两行宽度不同,尾巴放进行里才能永远紧跟当前那行的文字 */
280
+ const tail = p.after ? pvPart(p.after, sc, root) : '';
281
+ return '<span class="roll"' + (r.at ? ' data-at="' + r.at + '"' : '') + '><span class="roll-in"><span class="roll-a">' + pvLit(p.a == null ? r.a : pv(p.a, sc, root), sc, root) + tail + '</span><span class="roll-b">' + pvLit(p.b == null ? r.b : pv(p.b, sc, root), sc, root) + tail + '</span></span></span>';
282
+ }
283
+ if (typeof p.t === 'string') { /* 一句带片段参数的话:{ t: 键, args: [值或片段] }——值照常填进字里,片段参数({ parts, mono } 这类)画好再放进去,其余的字都转义 */
284
+ const rich = [], args = (p.args || []).map(function (a) { if (a && typeof a === 'object' && !a.t && !('of' in a)) { rich.push(pvPart(a, sc, root)); return '\u0001' + (rich.length - 1) + '\u0001'; } return pv(a, sc, root); });
285
+ return h(tc.apply(null, [p.t].concat(args))).replace(/\u0001(\d+)\u0001/g, function (m, i) { return rich[+i]; });
286
+ }
287
+ if (p.hint !== undefined) return helpTip(pv(p.hint, sc, root)); /* hint:就是 help */
288
+ if (p.br) return '<br>';
289
+ if (p.swatch) return '<span class="u-v-background theme-dot" style="--u-background:' + h(pv(p.swatch, sc, root)) + '"></span>'; /* 色块:颜色来自数据(主题强调色) */
290
+ if (p.tile) return letterTile(pvText(p.tile, sc, root));
291
+ if (p.bar != null) return progBar(pv(p.bar, sc, root), pv(p.tone, sc, root));
292
+ if (p.parts) { /* 一组片段包在一层里(variant 给样式;form 时是一张小表单) */
293
+ const tone = pv(p.tone, sc, root), cls = ((p.variant ? PART_ROLE[p.variant] || '' : '') + (tone ? ' vw-t-' + tone : '')).trim(), tip = pv(p.tip, sc, root), tag = p.form ? 'form' : 'span'; /* tone:整组一个色调(一层) */
294
+ const inner = typeof p.parts === 'string' ? (p.each ? pvGlue(pvList(p.parts, sc, root).map(function (x) { return pvPart(p.each, x, root); }), p.sep != null ? p.sep : '') : p.sep != null ? pvGlue((pv(p.parts, sc, root) || []).map(function (x) { return typeof x === 'string' ? h(x) : pvPart(x, sc, root); }), p.sep) : pvLit(pv(p.parts, sc, root), sc, root)) : pvJoin(p.parts, sc, root, p.sep != null ? p.sep : ''); /* sep:片段之间的分隔(数据里的字原样当文字,'@…' 也不当绑定);each:一组数据每项怎么画(@ 是那一项) */
295
+ if (pv(p.mono, sc, root)) return '<span class="mono">' + inner + '</span>'; /* mono:这一组片段整个用等宽字(工具名、路径这类) */
296
+ if (!p.variant && !tone && !tip && !p.form && !p.note) return inner;
297
+ return '<' + tag + (cls ? ' class="' + cls + '"' : '') + pvNote(p.note) + (p.form ? ' data-form="' + p.form + '"' : '') + (tip ? ' data-tip="' + h(tip) + '"' : '') + '>' + inner + '</' + tag + '>';
298
+ }
299
+ if (p.who) { const w = pv(p.who, sc, root); if (Array.isArray(w)) return '<span class="hb-av">' + w.map(function (x) { return avatar(WHO_DATA.member(x), 'sm'); }).join('') + '</span>'; const x = who(w, p.form || 'avatar', { size: p.size || PV.leadSize || 's', health: !!pv(p.health, sc, root), handle: p.handle }); return x; }
300
+ if (p.tint != null) return tintDot(pv(p.tint, sc, root)); /* 色调点(标签颜色) */
301
+ if (p.icon) { /* 图标;可带文字(variant 给样式,如计数 n、类型 kind) */
302
+ const ic = icon(pv(p.icon, sc, root), ICON_STEP[pv(p.size, sc, root)] || 15), tone = pv(p.tone, sc, root), tip = pv(p.tip, sc, root), t = p.text != null ? pvText(p.text, sc, root) : '';
303
+ const cls = ((p.variant ? PART_ROLE[p.variant] : 'vw-ic') + (tone ? ' vw-t-' + tone : '')).trim();
304
+ return p.variant || tone || tip || t ? '<span class="' + cls + '"' + (tip ? ' data-tip="' + h(tip) + '"' : '') + '>' + ic + t + '</span>' : ic;
305
+ }
306
+ if (p.glyph) return glyph(pv(p.glyph, sc, root), p.size === 'xl' ? 'glyph-xl' : ''); /* xl:页头里的大图标,和成员头像 xl 一样大 */
307
+ if (p.dot != null) return lrDot(pv(p.dot, sc, root), pv(p.tip, sc, root), p.member != null ? whoInfo(pv(p.member, sc, root)).color : ''); /* member:点用这位成员的主题色(执行中的点) */
308
+ if (p.badge != null) return badge(Number(pv(p.badge, sc, root)), { tone: pv(p.tone, sc, root), tip: pv(p.tip, sc, root) });
309
+ if (p.status) { const st = pv(p.status, sc, root); return st ? status(st.tone, st.text, st.strong) : ''; }
310
+ if (p.chip != null) { const t = pv(p.mono, sc, root) ? '<span class="mono">' + pvText(p.chip, sc, root) + '</span>' : pvText(p.chip, sc, root), act = pv(p.act, sc, root); return chipItem(t, act, act ? pvArgs(p.args, sc, root) : ''); } /* act 可以是绑定(每项模板里 '@act') */
311
+ if (p.chips) { const xs = pvList(p.chips, sc, root); return chipList(xs.length ? xs.map(function (x) { return pvPart(p.each || x, x, root); }) : p.empty ? ['<span class="faint">' + pvText(p.empty, sc, root) + '</span>'] : []); } /* each:每一项怎么画(片段,@ 是这一项的数据);没写时每一项本身就是片段 */
312
+ /* 文字 */
313
+ const t0 = pvText(p.text, sc, root);
314
+ if (p.mark) return t0 ? '<mark>' + t0 + '</mark>' : '';
315
+ if (p.strong) return '<b class="vw-strong">' + t0 + '</b>';
316
+ const tone = pv(p.tone, sc, root), tip = pv(p.tip, sc, root), cls = (p.variant ? PART_ROLE[p.variant] || '' : '') + (tone ? ' vw-t-' + tone : '');
317
+ const t = cls.trim() || tip ? '<span' + (cls.trim() ? ' class="' + cls.trim() + '"' : '') + (tip ? ' data-tip="' + h(tip) + '"' : '') + '>' + t0 + '</span>' : t0;
318
+ return pv(p.mono, sc, root) ? '<span class="mono">' + t + '</span>' : p.num ? '<span class="num">' + t + '</span>' : t;
319
+ }
320
+ /* 片段列表:数组或 { parts, sep };默认用空格连接 */
321
+ function pvParts(ps, sc, root) {
322
+ if (ps == null) return '';
323
+ ps = pdlLoc(ps);
324
+ if (!Array.isArray(ps) && typeof ps === 'object' && ps.parts) return pvJoin(ps.parts, sc, root, ps.sep == null ? ' ' : ps.sep);
325
+ return pvJoin(ps, sc, root, ' ');
326
+ }
327
+ /* 片段之间用 sep 连接;排版规则:全角标点(:,。、;)前面不加分隔,紧贴前一段 */
328
+ const PV_GLUE = /^[:,。、;)」』]/;
329
+ function pvJoin(ps, sc, root, sep) { return pvGlue((Array.isArray(ps) ? ps : [ps]).map(function (p) { return pvPart(p, sc, root); }), sep); }
330
+ function pvGlue(xs, sep) { return xs.filter(Boolean).reduce(function (acc, x, k) { return k && !PV_GLUE.test(x) ? acc + sep + x : acc + x; }, ''); }
331
+ /* 一处内容:写成路径时取视图模型的值(字符串原样当文字、数组 / 对象按片段画);写成片段时按片段画 */
332
+ function pvAny(x, sc, root) { return x == null ? '' : typeof x === 'string' ? pvLit(pv(x, sc, root), sc, root) : pvParts(x, sc, root); }
333
+ /* 来自视图模型的内容:字符串、数字、布尔原样当文字;数组 / 对象按片段画 */
334
+ function pvLit(x, sc, root) { if (x == null) return ''; if (typeof x !== 'object') return h(String(x)); return (Array.isArray(x) ? x : [x]).map(function (p) { return p == null || typeof p !== 'object' ? h(p == null ? '' : String(p)) : pvPart(p, sc, root); }).filter(Boolean).reduce(function (acc, x, k) { const el = /^</.test(x) !== />$/.test(acc); return k && el && !/\s$/.test(acc) && !/^\s/.test(x) && !PV_GLUE.test(x) ? acc + ' ' + x : acc + x; }, ''); } /* 文字和组件(状态、标签……)相邻时隔一个空格;视图模型自己带了空白或分隔的照旧 */
335
+
336
+ /* ───────── 控件 ───────── */
337
+ /* Controls can share a block path (e.g. settings fields). The declaration and enclosing
338
+ item distinguish their row sets. A repeated scope without an identity stays unkeyed. */
339
+ const REPEAT_DECLARATIONS = new WeakMap();
340
+ let repeatDeclarationCount = 0;
341
+ function pvRepeatRows(b, sc, root, items, draw, options = {}) {
342
+ const keyOf = options.keyOf || pvListKeyOf(b.item, root);
343
+ const outer = sc === root ? null : pvItemKey(sc);
344
+ const paint = function (item, r, key, index) {
345
+ return draw(options.raw ? item : unitsItem(b, item, r), r, sc === root ? r : sc, index);
346
+ };
347
+ if (typeof pdlUnits !== 'function' || (sc !== root && outer == null)) {
348
+ const parts = items.map(function (it, i) {
349
+ const result = paint(it, root, null, i);
350
+ return typeof result === 'string' ? result : result.html;
351
+ });
352
+ return { html: parts.join(''), parts: parts };
353
+ }
354
+ if (!REPEAT_DECLARATIONS.has(b)) REPEAT_DECLARATIONS.set(b, ++repeatDeclarationCount);
355
+ const id = pdlUnitScope(b.type, [REPEAT_DECLARATIONS.get(b), outer, options.part]);
356
+ const version = vmJson([options.layout, PV.ro, PV.inert, sc === root ? null : sc]);
357
+ return pdlUnits({ id: id, items: items, keyOf: keyOf, root: root, draw: paint,
358
+ indexed: options.indexed, version: function () { return version; } });
359
+ }
360
+
361
+ Object.assign(PV.units, { seg: 1, tabs: 1, tags: 1, tiles: 1, choices: 1, steps: 1, opts: 1 });
362
+ /* 只读上下文:视图声明 readonly(比如回放剧场)时,里面的消息和卡片不带操作——消息的工具条不画,卡片里能触发动作的控件不画。
363
+ 这是消息 / 卡片组件自己的能力:PV_RO 由视图开关,PV_INERT 在画消息节点时打开 */
364
+ const PV_TOC = '\u0000toc\u0000'; /* 目录的占位(见 toc 块) */
365
+ /* 画一段 PDL,里面的小节目录(toc)换成这段里带 id 的小节标题(锚点):视图和组件目录的示例都走这里 */
366
+ function pvWithToc(fn) {
367
+ const prev = PV.anchors; PV.anchors = [];
368
+ try { const s = fn(); return s.indexOf(PV_TOC) < 0 ? s : s.split(PV_TOC).join(PV.anchors.map(function (a) { return navRow({ label: a.label, attrs: ' data-act="anchorScroll"' + argAttrs({ id: a.id }) }); }).join('')); }
369
+ finally { PV.anchors = prev; }
370
+ }
371
+ function pvControl(c, sc, root) {
372
+ c = pdlLoc(c);
373
+ if (c && !PV.units[c.type]) c = pvItemize(c, sc, root);
374
+ if (!c || !pvOk(c.when, sc, root)) return '';
375
+ if (PV.block) PV.block(c);
376
+ if (c.stay) return pvStay(pvControl(Object.assign({}, c, { stay: false }), sc, root));
377
+ if (c.key && pdlNodeHidden(c.key)) return ''; /* 用户在 界面元素 里关掉的节点:连同里面的东西一起不画 */
378
+ if (c.plugin) pdlPluginNeed(c.plugin); /* 插件插进来的控件画出来了:取回它的子树(延迟加载) */
379
+ /* hideWhileTyping:所在的输入区域(typing-scope)里正在打字时淡出,停下约 1.5 秒后淡回(组件库的通用行为,不重画);支持它的组件自己在外层元素上写 data-htype */
380
+ const htype = c.hideWhileTyping ? ' data-htype' : '';
381
+ if (PV.inert && (c.act || c.change || c.input || c.menu || c.type === 'more' || c.type === 'switch')) return '';
382
+ const P = function (x) { return pv(x, sc, root); };
383
+ let data = pvArgs(c.args, sc, root);
384
+ /* items:按钮 / 选择器点开的菜单在这里声明(和 more 的 items 同一种写法);样子不变,动作是打开这个菜单 */
385
+ if (c.items && (c.type === 'button' || c.type === 'picker')) { data += ' data-menu="' + menuLive(pvMenu(c.items, sc, root)) + '"' + MENU_DECL; c = Object.assign({}, c, { act: 'menu', items: null }); }
386
+ switch (c.type) {
387
+ case 'button':
388
+ if (c.variant === 'nav') return navRow({ label: pvText(c.label, sc, root), attrs: ' data-act="' + c.act + '"' + data, current: P(c.current) ? 'true' : '' }); /* 页面目录:和侧栏导航同一种行 */
389
+ if (c.variant === 'meta') { /* 次要信息那一行里的文字按钮(消息的过程记录行):墨色小字,悬停变强调色 */
390
+ const ex = c.expanded != null ? ' aria-expanded="' + !!P(c.expanded) + '"' : '';
391
+ return '<button type="button" class="meta-btn" data-act="' + c.act + '"' + data + ex + '>' + (c.parts ? pvJoin(c.parts, sc, root, '') : pvText(c.label, sc, root)) + '</button>';
392
+ }
393
+ if (c.variant === 'cycle') /* 点一下换到下一个状态:圆形状态标记(任务) */
394
+ return '<button type="button" class="tk-st" data-act="' + c.act + '"' + data + ' data-tip="' + pvText(c.tip, sc, root) + '" aria-label="' + pvText(c.label, sc, root) + '"><span class="tk-g ' + pvText(c.state, sc, root) + '" aria-hidden="true"></span></button>';
395
+ if (c.variant === 'title') { /* 可编辑时点标题改名 */
396
+ const title = pvText(c.label, sc, root);
397
+ if (P(c.disabled)) return '<span class="chat-title" data-title>' + title + '</span>';
398
+ return '<button type="button" class="chat-title pdl-title-button" data-title data-act="' + c.act + '"' + data + ' data-tip="' + pvText(c.tip, sc, root) + '"' + pvNote(c.note) + '>' + title + '</button>';
399
+ }
400
+ if (c.who) { /* 带成员的按钮:头像叠放(最多 3 个)+ 可选文字 + 下箭头(打开成员列表) */
401
+ const ids = pvList(c.who, sc, root), lab = pvText(c.label, sc, root);
402
+ return '<button type="button" class="pdl-people-picker" data-act="' + c.act + '"' + data + ' aria-label="' + pvText(c.aria, sc, root) + '" data-tip="' + pvText(c.tip, sc, root) + '"' + pvNote(c.note) + '><span class="stack">' + ids.slice(0, 3).map(function (id) { return whoAva(id, { size: 'sm', tip: false }); }).join('') + '</span>' + (lab ? '<span class="pdl-ellipsis vw-w80">' + lab + '</span>' : '') + icon('down', 12) + '</button>';
403
+ }
404
+ if (c.menu) return '<button type="button" class="target" data-act="menu" data-menu="' + c.menu + '"' + MENU_DECL + ' data-tip="' + pvText(c.tip, sc, root) + '">' + (c.icon ? icon(c.icon, 14) : '') + '<span class="pdl-ellipsis">' + pvText(c.label, sc, root) + '</span>' + icon('down', 12) + '</button>'; /* 打开菜单选一项:图标 + 当前值 + 下箭头(和输入框里的“项目 / 发给”同一种触发) */
405
+ if (c.open != null) return btn(pv(c.label, sc, root), { sm: true, act: c.act, icon: c.icon, data: data + ' aria-expanded="' + !!P(c.open) + '"' + (c.tip ? ' data-tip="' + pvText(c.tip, sc, root) + '"' : ''), html: pvText(c.label, sc, root) + twisty(P(c.open)) });
406
+ if (c.parts) return btn('', { sm: c.sm !== false, primary: P(c.primary), act: c.act, data: data, html: pvJoin(c.parts, sc, root, '') });
407
+ return btn(P(c.label), { cls: BTN_ROLE_CLS[c.variant] || '', primary: !!P(c.primary), link: !!c.link, danger: !!P(c.danger), sm: true, size: c.size, icon: P(c.icon), act: P(c.act), data: data + (c.tip && !P(c.disabled) ? ' data-tip="' + pvText(c.tip, sc, root) + '"' : ''), iconOnly: !!c.iconOnly, disabled: !!P(c.disabled), why: P(c.disabled) && c.tip ? pvText(c.tip, sc, root) : '', /* 停用 + 提示 = 停用的原因(悬停看、点了也说) */ pressed: c.pressed != null ? !!P(c.pressed) : null, busy: !!P(c.busy), note: c.note, submit: !!c.submit }); /* 四种样子只由按钮自己的声明决定:默认浅底,primary 实底,danger 危险(见 btn);不看所在的位置 */
408
+ case 'picker': { /* 输入框里的“项目 / 发给”:图标或头像 + 当前值 + 下箭头,可带“自动”标记 */
409
+ const lead = c.who ? whoAva(P(c.who), { size: 'sm', tip: false }) : icon(c.icon, 14), dis = c.disabled != null && !!P(c.disabled);
410
+ if (c.check != null) { const on = !!P(c.check); return '<button type="button" class="target" role="checkbox" aria-checked="' + on + '" data-act="' + c.act + '"' + data + (dis ? ' disabled' : '') + '>' + checkInd(on) + (c.prefix ? '<span class="hide-sm">' + h(c.prefix) + '</span>' : '') + pvText(c.label, sc, root) + '</button>'; }
411
+ return '<button type="button" class="target" data-act="' + c.act + '"' + data + ' data-tip="' + pvText(c.tip, sc, root) + '"' + (dis ? ' disabled' : '') + '>' + (c.prefix ? '<span class="hide-sm">' + h(c.prefix) + '</span> ' : '') + lead + '<span class="' + (c.who ? 'hide-sm' : 'pdl-ellipsis') + '">' + pvJoin(c.parts || [{ text: c.label }], sc, root, ' ') + '</span>' + icon('down', c.who ? 14 : 12) + (P(c.auto) ? '<span class="c auto-tag" data-tip="' + h(c.autoTip || '') + '">' + h(tc('modeThumb.label.system')) + '</span>' : '') + '</button>';
412
+ }
413
+ case 'send': { /* 发送 / 停止 */
414
+ if (P(c.stop)) return P(c.stopping) ? ('<button type="button" class="send stop" disabled aria-label="' + h(tc('composer.stopping')) + '" data-tip="' + h(tc('composer.stopping')) + '">') + icon('stop', 14) + '</button>' : ('<button type="button" class="send stop" data-act="stop" aria-label="' + h(tc('composer.stop')) + '" data-tip="' + h(tc('composer.stop')) + '">') + icon('stop', 14) + '</button>';
415
+ return '<button type="button" class="send" data-act="' + h(P(c.act) || 'send') + '"' + data + ' aria-label="' + h(tc('common.send')) + '" data-tip="' + pvText(c.tip, sc, root) + '"' + (P(c.disabled) ? ' disabled' : '') + '>' + icon('reply', 16) + '</button>'; /* 在对话里发出去就是回复:reply 字形;纸飞机 send 只给排队的“现在发出” */
416
+ }
417
+ case 'capsules': { /* 身份胶囊:数据与 from/item 模板;状态片段、打开动作、悬停操作由声明绑定。 */
418
+ const xs = [], draw = function (x, t) {
419
+ const state = t ? pvParts(t.state, x, root) : x.state, showClock = t ? pv(t.clockWhen, x, root) : !!x.clock;
420
+ const ticking = t ? pv(t.ticking, x, root) : !!x.tick, time = t ? clockText(pv(t.seconds, x, root)) : x.clock;
421
+ const st = state + (showClock ? ' · <span class="num"' + (ticking ? ' data-tick="run"' : '') + '>' + h(time) + '</span>' : ''), id = t ? pv(t.who, x, root) : x.who;
422
+ const cap = capWho({ who: id }, st, (t ? pv(t.cur, x, root) : x.cur) ? 'cur' : '', true, 'm');
423
+ const opens = t ? t.open || [] : x.open ? [x.open] : [], open = opens.find(function (o) { return pvOk(o.when, x, root); }) || {};
424
+ /* 一位成员有几条在跑(回复 + 后台命令):展开时胶囊往上长高——底下一行是头像 + 名字,上面一条一行(同一个状态模板、各自的去向、各自的 @ / 停止);只有一条照旧横着展开 */
425
+ const rows = t && t.entries ? pvList(t.entries, x, root) : [], acts = function (e) {
426
+ const html = ((t ? t.actions : x.actions) || []).filter(function (a) { return pvOk(a.when, e, root); }).map(function (a) { return btn(pv(a.label, e, root), { iconOnly: true, icon: a.icon, sm: true, act: a.act, data: pvArgs(a.args, e, root) }); }).join('');
427
+ return html ? '<span class="cap-acts">' + html + '</span>' : '';
428
+ };
429
+ const multi = rows.length > 1;
430
+ if (multi) {
431
+ const line = function (e) { const o = opens.find(function (q) { return pvOk(q.when, e, root); }) || {}, sp = pvParts(t.state, e, root), clk = pv(t.clockWhen, e, root), act = o.act || c.act;
432
+ const text = capText(sp + (clk ? ' · <span class="num"' + (pv(t.ticking, e, root) ? ' data-tick="run"' : '') + '>' + h(clockText(pv(t.seconds, e, root))) + '</span>' : ''));
433
+ const link = act ? '<button type="button" class="cap-row" data-act="' + h(act) + '"' + argAttrs(Object.assign({ id: id }, pvArgsObj(o.args, e, root))) + '>' + text + '</button>' : text;
434
+ return '<span class="cap-line">' + link + acts(e) + '</span>'; };
435
+ const w = whoInfo(id), identity = capText('<b>' + h(w.name) + '</b>' + (w.handle ? ' <span class="faint">' + h(w.handle) + '</span>' : ''));
436
+ cap.body = '<span class="cap-rows">' + rows.map(line).join('') + '<span class="cap-row-who">' + identity + '</span></span>'; cap.cls += ' cap-multi';
437
+ }
438
+ return Object.assign(cap, { act: multi ? '' : open.act || c.act, data: argAttrs(Object.assign({ id: id }, pvArgsObj(open.args, x, root))),
439
+ tip: (t ? pv(t.tip, x, root) : x.tip) || cap.tip, actions: multi ? '' : acts(x) });
440
+ };
441
+ if (Array.isArray(c.from)) c.from.forEach(function (entry) { if (entry.from) pvList(entry.from, sc, root).forEach(function (x) { xs.push(draw(x, entry.item)); }); else xs.push(draw(entry)); });
442
+ else pvList(c.from, sc, root).forEach(function (x) { xs.push(draw(x)); });
443
+ return xs.length ? capStack(xs, { label: c.label, size: 'm' }) : '';
444
+ }
445
+ case 'stack': return '<div class="vstack">' + pvControls(c.items || [], sc, root) + '</div>'; /* 竖着叠的一列(底对齐);子项位置变了时组件自己做过渡 */
446
+ case 'jump': return '<button type="button" class="stream-latest" data-island="jump" data-flip' + htype + ' data-act="' + c.act + '"' + data + ' data-jump="1" data-tip="' + pvText(c.tip, sc, root) + '">' + icon(c.icon || 'latest', 14) + pvText(c.label, sc, root) + '</button>'; /* 跳到底部:离底部远时才显示——纯 CSS,按消息流的滚动时间线 */
447
+ case 'notices': return noticeList(c.items.slot ? pdlSlotItems(c.items.slot).concat(pvList(c.items.from, sc, root)) : pvList(c.items, sc, root), c.key || 'notices', htype); /* 提示:slot 与 owner 使用同一轮换队列;多条时轮换,悬停暂停 */
448
+ case 'slot': { /* 页面插槽:list 按摆放画工具按钮;single 只画胜出的那一项 */
449
+ const d = PDL_SLOTS[c.slot] || {};
450
+ if (d.cardinality === 'single') { const x = pdlSingle(c.slot); return x ? pvSingleItem(x) : ''; }
451
+ return pdlTools(c.slot, P(c.ctx) || {});
452
+ }
453
+ case 'switch': return sw(!!P(c.value), c.act, data + (c.tip ? ' data-tip="' + pvText(c.tip, sc, root) + '"' : ''), pvText(c.label, sc, root), !!P(c.disabled));
454
+ case 'seg': {
455
+ if (c.slot) {
456
+ const items = pdlKids(c.slot).map(function (id) {
457
+ const e = pdlEntry(id), page = e && e.open && e.open.page;
458
+ if (!e || !pdlWhen(e.when) || pdlNodeHidden(id) || !page) return null;
459
+ return { v: page, label: pdlText(e.title), active: S.route === page, data: ' data-page="' + h(page) + '" data-replace="true"' };
460
+ }).filter(Boolean);
461
+ return segBar(items.map(function (it) { return segButton(it, it.active, 'open', (it.data || '')); }).join(''), null, P(c.label));
462
+ }
463
+ const options = c.options || c.from;
464
+ const items = c.item ? pvList(options, sc, root) : pvItems(options, sc, root);
465
+ return segBar(pvRepeatRows(c, sc, root, items, function (it, r, context) {
466
+ const active = it.active != null ? it.active : it.v === pv(c.value, context, r);
467
+ return segButton(it, active, c.act, data);
468
+ }, { layout: data }).html, null, P(c.label));
469
+ }
470
+ case 'select': {
471
+ const id = P(c.id), o = c.options ? pvItems(c.options, sc, root) : pvList(c.from, sc, root), v = P(c.value);
472
+ if (c.variant === 'member') return memberPick({ id: id, pool: o, value: v, none: c.none ? pvText(c.none, sc, root) : null, multi: !!c.multi, act: c.act, args: c.args ? pvArgsObj(c.args, sc, root) : null, change: c.change, data: data, label: c.label ? pvText(c.label, sc, root) : '' }); /* 选成员:组件库唯一的成员选择器 */
473
+ return sel(id, o, v, { span: P(c.span), change: c.change, data: data, invalid: !!P(c.invalid), disabled: !!P(c.disabled), tip: c.tip ? pvText(c.tip, sc, root) : '', label: c.label ? pvText(c.label, sc, root) : '', prefix: c.prefix ? pvText(c.prefix, sc, root) : '',
474
+ multi: !!c.multi, none: c.none ? pvText(c.none, sc, root) : '', act: c.act, args: c.args ? pvArgsObj(c.args, sc, root) : null }); /* 单选、多选与成员选择共用同一个下拉。 */
475
+ }
476
+ case 'search': {
477
+ if (!c.form && !c.wide && !c.note && !c.label && !c.on) return search(c.id, c.placeholder, P(c.value), c.input);
478
+ const inp = searchGo() + '<input class="input" id="' + c.id + '" placeholder="' + h(c.placeholder) + '"' + (c.label ? ' aria-label="' + h(c.label) + '"' : '') + ' value="' + h(P(c.value) || '') + '" data-input="' + c.input + '"' + onAttrs(c.on) + '>';
479
+ return c.form ? '<form class="search" data-form="' + c.form + '"' + pvNote(c.note) + '>' + inp + '</form>' : '<div class="search' + (c.wide ? ' vw-search' : '') + '">' + inp + '</div>';
480
+ }
481
+ case 'input': {
482
+ if (c.go) { /* 表单里的一个输入(组件库的 goField):回车提交、Esc / 失焦取消,提交是框里唯一的图标 */
483
+ const one = function (x) { return { id: P(x.id), value: P(x.value), placeholder: pvText(x.placeholder, sc, root), label: pvText(x.label || x.placeholder, sc, root), mono: !!P(x.mono) }; };
484
+ return goField(Object.assign(one(c), { go: c.go, add: !!P(c.add), data: data, icon: c.icon, goLabel: pvText(c.goLabel, sc, root), cancel: c.cancel, list: c.list ? P(c.list) : '', listFrom: pvList(c.listFrom, sc, root), input: c.input,
485
+ more: (c.more || []).map(one), extra: c.tint ? colorCtl({ id: P(c.tint.id), value: P(c.tint.value), default: P(c.tint.default), input: c.tint.input, label: pvText(c.tint.label, sc, root) }) : '' })); /* 框里的选色:组件库统一的取色器,值是固定的颜色 */
486
+ }
487
+ /* rows:多行输入(rows: true = 行数由所在的容器定,比如输入区的正文);多行和单行是同一个输入框组件 */
488
+ /* grow:按内容长高到上限再滚动;complete:同行补全的候选(组件自己按已输入的内容挑,见 widgets.js 的 taGhost) */
489
+ if (c.rows && c.complete) { TA_COMPLETE[P(c.id)] = pvList(c.complete, sc, root); return '<div class="ta-wrap"><div class="ta-ghost" aria-hidden="true"><span class="ta-typed"></span><span class="ta-rest"></span></div>' + pvControl(Object.assign({}, c, { complete: null }), sc, root) + '</div>'; }
490
+ if (c.rows) {
491
+ const ro = !!P(c.ro), inpAct = !ro && c.input ? P(c.input) : '';
492
+ const edits = ro ? ' readonly' : data + (inpAct ? ' data-input="' + h(inpAct) + '"' : '') +
493
+ (c.change ? ' data-change="' + c.change + '"' : '') + onAttrs(P(c.on));
494
+ return '<textarea class="input' + (P(c.mono) ? ' mono' : '') + '" id="' + h(P(c.id)) + '"' + edits +
495
+ (c.grow ? ' data-grow rows="1"' : c.rows !== true ? ' rows="' + P(c.rows) + '"' : '') +
496
+ (P(c.invalid) ? ' aria-invalid="true"' : '') + (c.label ? ' aria-label="' + pvText(c.label, sc, root) + '"' : '') +
497
+ (c.code ? ' spellcheck="false"' : '') + (P(c.disabled) ? ' disabled' : '') +
498
+ ' placeholder="' + pvText(c.placeholder, sc, root) + '">' + pvText(c.value, sc, root) + '</textarea>';
499
+ }
500
+ /* 输入框只有一个样子:值、占位、等宽、候选、只读、校验失败、密文都是声明;title 是就地改名的标题 */
501
+ const id = P(c.id), combo = c.listFrom ? pvItems(c.listFrom, sc, root).map(function (x) { return typeof x === 'object' ? { v: x.v, label: x.label, sub: x.sub } : { v: x, label: x }; }) : null, val = c.value != null ? P(c.value) : null;
502
+ if (c.variant === 'title') return '<label class="sr" for="' + h(id) + '">' + pvText(c.label, sc, root) + '</label><input class="input input-title" id="' + h(id) + '" maxlength="200" value="' + h(val == null ? '' : val) + '"' + (c.placeholder ? ' placeholder="' + pvText(c.placeholder, sc, root) + '"' : '') + (c.input ? ' data-input="' + c.input + '"' : '') + data + onAttrs(c.on) + (P(c.disabled) ? ' disabled' : '') + '>';
503
+ const draft = val == null && !c.input && !c.lead, date = c.variant === 'date', inputType = P(c.secret) ? 'password' : '';
504
+ if (draft && !date) return pdlDraftField(id, null, pvText(c.placeholder, sc, root), { mono: !!P(c.mono), max: c.max, type: inputType }); /* 没有绑定值:草稿留在本地(提问卡、新建表单) */
505
+ const ctl = date ? dateCtl({
506
+ id: id, value: draft ? pdlDraftValue(id) : val, placeholder: P(c.placeholder), label: P(c.label),
507
+ input: draft ? 'pdlField' : P(c.input), change: c.change, data: data, on: P(c.on),
508
+ mono: P(c.mono), disabled: P(c.disabled), ro: P(c.ro), invalid: P(c.invalid)
509
+ }) : '<input class="input' + (P(c.mono) ? ' mono' : '') + '" id="' + h(id) + '" value="' + h(val == null ? '' : val) + '" placeholder="' + pvText(c.placeholder, sc, root) + '"' + (c.input ? ' data-input="' + c.input + '"' : '') + (c.change ? ' data-change="' + c.change + '"' : '') + data + (P(c.num) ? ' inputmode="numeric"' : '') + (P(c.ro) ? ' readonly' : '') + (P(c.invalid) ? ' aria-invalid="true"' : '') + (inputType ? ' type="' + inputType + '"' : '') + (c.max ? ' maxlength="' + c.max + '"' : '') + (c.label || c.placeholder ? ' aria-label="' + pvText(c.label || c.placeholder, sc, root) + '"' : '') + (P(c.disabled) ? ' disabled' : '') + onAttrs(c.on) + '>';
510
+ const inp = ctl + (c.post ? ' <span class="vw-meta">' + pvText(c.post, sc, root) + '</span>' : ''); /* post:框后的单位 */
511
+ /* listFrom:候选(字符串,或 { v, label, sub })——框尾一个下拉按钮,点开组件库的菜单,选中的写回框里(inputs.js 的 comboOpen) */
512
+ /* reload:候选是读来的,可以重读——框尾一直有一个刷新({ act, args, busy, tip, why },读的时候它自己转;why 有值 = 这次不能读,置灰、悬停说原因) */
513
+ if (combo) { COMBO[id] = combo; return '<span class="combo">' + inp + btn(pvText(c.label || c.placeholder, sc, root), { iconOnly: true, sm: true, icon: 'updown', act: 'comboOpen', data: ' data-for="' + h(id) + '" aria-haspopup="menu"' }) + (c.reload ? btn(tc('common.refresh'), { iconOnly: true, sm: true, icon: 'refresh', act: c.reload.act, busy: !!P(c.reload.busy), tip: P(c.reload.tip), why: P(c.reload.why), data: argAttrs(pvArgsObj(c.reload.args || {}, sc, root)) }) : '') + '</span>'; }
514
+ return c.lead ? '<label class="input-lead">' + pvParts(c.lead, sc, root) + inp + '</label>' : inp; /* lead:框里最前面的状态(地址栏的连接点) */
515
+ }
516
+ case 'inlineEdit': {
517
+ const key = String(P(c.id) || ''), val = P(c.value), title = h(val == null ? '' : String(val));
518
+ const disabled = !!P(c.disabled), isTitle = c.variant === 'title';
519
+ const cls = isTitle ? 'chat-title' : 'inline-edit-text', titleAttr = isTitle ? ' data-title' : '';
520
+ if (disabled || !key || typeof inlineEditReg !== 'function') return '<span class="' + cls + '"' + titleAttr + '>' + title + '</span>';
521
+ const editLabel = pvText(c.label, sc, root) || tc('common.rename');
522
+ inlineEditReg({ key: key, value: val == null ? '' : String(val), act: P(c.act), args: pvArgsObj(c.args || {}, sc, root), label: editLabel, max: c.max || 200, selectStem: !!P(c.selectStem) });
523
+ const st = inlineEditState(key);
524
+ if (st) return '<span class="' + cls + ' inline-edit"' + titleAttr + pvNote(c.note) + '>' + inlineEditInput({ state: st, cls: isTitle ? 'input-title' : 'inline-edit-row', label: editLabel }) + '</span>';
525
+ return '<button type="button" class="' + cls + ' pdl-title-button"' + titleAttr + ' data-act="inlineEditStart" data-key="' + h(key) + '" data-tip="' + pvText(c.tip, sc, root) + '"' + pvNote(c.note) + '>' + title + '</button>';
526
+ }
527
+ case 'check': return c.variant === 'row' ? checkMark(!!P(c.value), c.act, data, pvText(c.label, sc, root)) : checkBox(!!P(c.value), (c.tint ? tintDot(P(c.tint)) : '') + pvText(c.label, sc, root), c.act, data);
528
+ case 'tints': return colorCtl({ kind: 'slot', value: +P(c.value), act: c.act, label: pvText(c.label, sc, root), data: data }); /* 取色的槽位变体:6 个成员色调里单选 */
529
+ case 'text': { /* 一段文字:默认是正文墨色;meta 是次要信息;value 是一项设置的值;for 时是某个控件的名字(label 元素)。什么都不加时就是片段本身(不包一层) */
530
+ const t = c.parts ? (typeof c.parts === 'string' ? pvLit(P(c.parts), sc, root) : pvJoin(c.parts, sc, root, '')) : pvText(c.text, sc, root), tone = P(c.tone), tip = P(c.tip);
531
+ if (!t && !c.id) return '';
532
+ const cls = (c.variant === 'meta' ? 'vw-meta' : c.variant === 'value' ? 'sys-v' + (P(c.mono) ? ' mono' : '') + (P(c.faint) ? ' faint' : '') + (P(c.num) ? ' num' : '') : '') + (tone ? ' vw-t-' + tone : ''), tag = c.for ? 'label' : 'span';
533
+ if (!cls.trim() && !c.for && !c.id && !tip) return t;
534
+ return '<' + tag + (cls.trim() ? ' class="' + cls.trim() + '"' : '') + (c.for ? ' for="' + h(P(c.for)) + '"' : '') + (c.id ? ' id="' + c.id + '"' : '') + (tip ? ' data-tip="' + h(tip) + '"' : '') + '>' + t + '</' + tag + '>';
535
+ }
536
+ case 'copy': return copyValue({ value: P(c.value), v: P(c.v), label: pvText(c.label, sc, root), fieldLabel: P(c.fieldLabel), tip: c.tip ? pvText(c.tip, sc, root) : '', mono: !!c.mono, tail: !!c.tail, field: !!P(c.field) });
537
+ case 'status': return status(P(c.tone), P(c.text));
538
+ case 'more': { const key = c.items ? menuLive(pvMenu(c.items, sc, root)) : P(c.menu); return c.variant === 'row' ? rowMore(key, P(c.k), c.label) : moreBtn(key, data + (c.k != null ? ' data-k="' + h(String(P(c.k))) + '"' : ''), c.label, c.size); } /* k:菜单作用的对象(菜单项的动作从 S.menuTarget 读),两种样子都带 */
539
+ case 'back': { /* 返回放在这里(引擎的返回):比如表单自己的取消就是返回——容器的标题行不再画返回。没有返回可回时用声明的动作 */
540
+ const k = BACK.page ? 'page' : BACK.detail ? 'detail' : null, d = k ? BACK[k] : null; if (k) BACK[k] = null;
541
+ return btn(pvText(c.label, sc, root), { sm: true, act: d ? d.act : c.act, data: (d ? d.data || '' : data) + (d ? ' data-tip="' + h(tc('frame.backTo', d.label || '')) + '"' : '') });
542
+ }
543
+ case 'app': { const f = RT_CHROME[c.name]; return f ? f(c.region, { demo: !!c.demo }) : ''; } /* 标签式容器(区域)的固定件:菜单条 stripe、把手 handle——放在哪个容器里、属于哪个区域(region)由页面 PDL 声明,长什么样、什么时候出现由区域的 chrome 声明 */
544
+ case 'range': { /* 滑块 + 数值;input 时边拖边更新(数值节点 id = 滑块 id + '-o'),change 时松手才提交 */
545
+ const v = P(c.value), id = P(c.id);
546
+ return '<span class="pdl-inline"><input type="range" class="ws-range"' + (id ? ' id="' + h(id) + '"' : '') + ' min="' + c.min + '" max="' + c.max + '" step="' + (c.step || 1) + '" value="' + h(v) + '"' + (c.change ? ' data-change="' + c.change + '"' : '') + (c.input ? ' data-input="' + c.input + '"' : '') + data + ' data-unit="' + h(pvText(c.unit, sc, root)) + '" aria-label="' + pvText(c.label, sc, root) + '"><span class="num"' + (id ? ' id="' + h(id) + '-o"' : '') + '>' + h(v) + pvText(c.unit, sc, root) + '</span></span>';
547
+ }
548
+ case 'tiles': { /* 选一项:card = 一格一张小卡(头像 / 图标 + 名字 + 一行说明);swatch = 一排色块头像。选中 aria-pressed,点了执行 act(带每项 args) */
549
+ const xs = pvList(c.from, sc, root);
550
+ const swatches = xs.length > 0 && xs.every(function (x) { return !(c.item && 'title' in c.item ? pvDeep(c.item.title, root, x) : x.title); });
551
+ const rows = pvRepeatRows(c, sc, root, xs, function (x) {
552
+ const action = actAttrs(x.act || c.act, x.args) + (x.pressed != null ? ' aria-pressed="' + !!x.pressed + '"' : '');
553
+ if (swatches) return '<button type="button" class="tile-av"' + action + ' aria-label="' + h(x.label || x.tip || '') + '"' + (x.tip ? ' data-tip="' + h(x.tip) + '"' : '') + '>' + avatar({ name: x.text, tint: x.tint }, 'l') + '</button>';
554
+ return '<button type="button" class="tpl"' + action + '>' + (x.lead ? avatar(x.lead) : '<span class="avatar" aria-hidden="true">' + icon(x.icon || 'plus', 14) + '</span>') + '<span class="tpl-t"><b>' + h(x.title) + '</b>' + (x.tail ? ' <span class="muted">' + h(x.tail) + '</span>' : '') + '<span class="faint">' + h(x.sub || '') + '</span></span></button>';
555
+ }, { layout: swatches });
556
+ return '<div class="' + (swatches ? 'chips tiles-av' : 'tpl-grid') + '">' + rows.html + '</div>';
557
+ }
558
+ case 'upload': if (c.hidden) return '<input type="file" id="' + h(P(c.id)) + '" accept="' + h(c.accept || '') + '"' + (c.multiple ? ' multiple' : '') + ' hidden' + data + '>'; /* hidden:只有选文件的输入,由别处的按钮触发 */
559
+ return '<label class="btn btn-sm' + (c.iconOnly ? ' btn-icon" aria-label="' + pvText(c.label, sc, root) + '" data-tip="' + pvText(c.label, sc, root) : '') + '">' + (c.icon ? icon(c.icon, 14) : '') + (c.iconOnly ? '' : pvText(c.label, sc, root)) + '<input type="file" accept="' + h(c.accept || '') + '"' + (c.multiple ? ' multiple' : '') + ' class="sr" data-filemsg="' + pvText(c.msg, sc, root) + '"' + data + '></label>'; /* 上传:按钮样子的文件选择 */
560
+ case 'chip': { /* 一个小标签(组件库 chipHtml):图标、类型(等宽小字)、名字、淡色补充;x 是移除按钮;有 act 时整个标签可点 */
561
+ const xo = typeof c.x === 'string' ? P(c.x) : c.x, ca = P(c.act); /* 动作可以来自数据(每一项自己的去处;没有就是不可点的标签) */
562
+ return chipHtml({ tint: c.tint ? P(c.tint) : undefined, check: c.check, pressed: c.pressed != null ? P(c.pressed) : null, thumb: P(c.thumb), icon: c.icon ? P(c.icon) : '', kind: c.kind ? pvText(c.kind, sc, root) : '', label: pvText(c.label, sc, root), ellip: c.ellip, faint: c.faint ? pvText(c.faint, sc, root) : '',
563
+ tip: c.tip ? pvText(c.tip, sc, root) : '', tone: P(c.tone), act: ca, data: data, x: xo && pvOk(xo.when, sc, root) ? chipX(xo.act, pvArgs(xo.args, sc, root), pv(xo.label, sc, root), pv(xo.icon, sc, root)) : '' }); /* 色调只写 data-tone(颜色通道),和提示一起放在标签的根上 */
564
+ }
565
+ case 'each': return pvRepeat(c, pvList(c.from, sc, root), root, function (x, r) { return pvControl(c.control, x, r); }, { part: 'control' }).html;
566
+ case 'kvlist': return kvEditor({ key: P(c.key), path: c.path, rows: pvItems(c.rows, sc, root), single: !!c.single, ro: !!P(c.ro), input: c.input, add: P(c.add), eye: c.eye, del: c.del, keyPh: pvText(c.keyPh, sc, root), empty: pvText(c.empty, sc, root) }); /* 键值对 / 一列值的编辑器 */
567
+ case 'avatar': { /* 一个头像(还不是成员时,用名字 + 代表色);upload:点头像本身就是上传(悬停出现上传提示) */
568
+ const up = P(c.upload); return up ? avatarUp(P(c.lead), c.size || '', up, data) : avatar(P(c.lead), c.size || '');
569
+ }
570
+ case 'color': return colorCtl({ id: P(c.id), value: P(c.value), label: pvText(c.label, sc, root), input: c.input, slots: c.slots, preview: P(c.preview) }); /* 取色(组件库 colorCtl):色块 + 调色盘;preview:名字用这个颜色的预览 */
571
+ case 'reply': return replyRef(P(c.ref)); /* 回复引用(组件库的 replyRef) */
572
+ case 'grow': return '<span class="grow"></span>';
573
+ case 'tags': return PDL_BLOCKS.tags(c, sc, root); /* 标签编辑器也可以是表单字段的控件 */
574
+ case 'notice': return PDL_BLOCKS.notice(c, sc, root); /* 提示在组合控件里仍由同一个提示组件画。 */
575
+ case 'tabs': return PDL_BLOCKS.tabs(c, sc, root); /* 标签页条也可以直接放进标题工具条里,占同一行 */
576
+ case 'component': { const f = pdlComponent(c.use); if (!f) console.error(tc('engine.part.error', c.use)); return f ? f(P(c.props), sc, root) : ''; }
577
+ }
578
+ console.error(tc('engine.control.missingControl', c.type));
579
+ return '';
580
+ }
581
+ function pvControls(cs, sc, root) {
582
+ if (typeof cs === 'string') cs = pv(cs, sc, root);
583
+ cs = pdlLoc(cs);
584
+ const path = PV.path;
585
+ return (Array.isArray(cs) ? cs : cs ? [cs] : []).map(function (c, i) {
586
+ PV.path = (path || '') + '/control:' + i;
587
+ try { return pvControl(c, sc, root); } finally { PV.path = path; }
588
+ }).join('');
589
+ }
590
+
591
+ /* ───────── 行 ─────────
592
+ key lead title inline sub meta cols acts tone color bar sm act args note expand(一层,列表管理)more/moreWhen/moreAfter(调用方管理) */
593
+ function pvRow(t, sc, root, listId) {
594
+ if (typeof t === 'string') { if (!PDL_ROWS[t]) console.error(tc('engine.row.error', t)); t = PDL_ROWS[t]; }
595
+ t = pdlLoc(t);
596
+ const cols = (t.cols || []).map(function (c) {
597
+ const w = pv(c.w, sc, root);
598
+ if (!pvOk(c.when, sc, root)) return { v: '', w: w || (c.control ? 'ctl' : 'num') }; /* 这一行没有这一列:留一个空格子(列表的列上下对齐) */
599
+ if (c.control) { const v = pvControls(c.control, sc, root); return { v: v, w: w || 'ctl' }; }
600
+ return { v: c.v != null ? pvParts(c.v, sc, root) : '', w: w || 'num', tip: pv(c.tip, sc, root), tone: pv(c.tone, sc, root), act: c.act, data: pvArgs(c.args, sc, root) };
601
+ });
602
+ let acts = null;
603
+ if (t.acts && t.acts.slot) { const sl = pv(t.acts.slot, sc, root); acts = sl ? pdlActs(sl, pv(t.acts.ctx, sc, root) || {}) : null; } /* 插槽可以来自数据(同一种行用在几段里,每段一个行插槽) */
604
+ if (!acts && t.acts && t.acts.items) acts = pvList(t.acts.items, sc, root).filter(function (a) { return !t.acts.item || pvOk(t.acts.item.when, a, root); }).map(function (a) { return t.acts.item ? pvDeep(t.acts.item, root, a) : a; }).map(function (a) { return { label: a.label, icon: a.icon, act: a.act, data: argAttrs(a.args), busy: !!a.busy }; }); /* 数据项也可以带声明在主题里的逐项模板 */
605
+ else if (Array.isArray(t.acts)) acts = t.acts.filter(function (a) { return pvOk(a.when, sc, root); }).map(function (a) { const menu = a.items ? menuLive(pvMenu(a.items, sc, root)) : ''; return { label: pvText(a.label, sc, root), icon: pv(a.icon, sc, root), act: menu ? 'menu' : pv(a.act, sc, root), data: pvArgs(a.args, sc, root) + (menu ? ' data-menu="' + menu + '"' + MENU_DECL : ''), why: pv(a.why, sc, root), busy: !!pv(a.busy, sc, root) }; });
606
+ const bar = t.bar && pv(t.bar.pct, sc, root) != null ? { pct: pv(t.bar.pct, sc, root), tone: pv(t.bar.tone, sc, root) } : null;
607
+ const color = t.color ? (t.color.who ? whoInfo(pv(t.color.who, sc, root)).color : pv(t.color, sc, root)) : null; /* 颜色是数据:身份自带的颜色,或视图模型给的 token */
608
+ const sub = t.sub && !(t.sub.when && !pvOk(t.sub.when, sc, root)) ? pvParts(t.sub.parts && !Array.isArray(t.sub) && t.sub.sep == null ? t.sub.parts : t.sub, sc, root) : '';
609
+ const prevL = PV.leadSize; PV.leadSize = t.layout === 'record' ? 's' : 'm'; /* 前导头像的档位跟着行布局(记录行是小档),不跟着所在的列表 */
610
+ const lead = t.lead ? pvJoin(t.lead, sc, root, '') : ''; PV.leadSize = prevL;
611
+ const act = pv(t.act && t.act.map ? pv(t.act, sc, root) : t.act, sc, root), args = t.args && t.args.map && 'of' in t.args ? pv(t.args, sc, root) : t.args;
612
+ const key = pv(t.key, sc, root);
613
+ const open = listId != null ? rowOpen(listId, key) : false;
614
+ const expandDecl = pvOk(t.expandWhen, sc, root) ? (typeof t.expand === 'string' ? pv(t.expand, sc, root) : t.expand) : null;
615
+ const hasExpand = expandDecl != null;
616
+ const o = {
617
+ key: key, layout: t.layout, list: listId, open: open, hasExpand: hasExpand,
618
+ lead: lead, leadSlot: !!t.lead, title: pvParts(t.title, sc, root) + annotLabel(pvAnnot(t.label, sc, root), 'after') + helpTip(pv(t.help, sc, root)),
619
+ inline: (t.inline ? pvJoin(t.inline, sc, root, '') : '') + annotLabel(pvAnnot(t.label, sc, root), 'corner'),
620
+ sub: sub || (pvAnnot(t.label, sc, root) && pvAnnot(t.label, sc, root).pos === 'below' ? h(pvAnnot(t.label, sc, root).text) : ''), meta: t.meta ? pvParts(t.meta, sc, root) : '',
621
+ cols: cols, acts: acts, tone: Array.isArray(t.tone) ? pv((t.tone.find(function (c) { return pvOk(c.when, sc, root); }) || {}).value, sc, root) : pv(t.tone, sc, root), color: color, bar: bar,
622
+ act: act, data: act ? pvArgs(args, sc, root) : '',
623
+ expand: hasExpand && open ? pvBlocks(expandDecl, sc, root) : null, cur: !!pv(t.cur, sc, root) /* 折叠态不求值 expand;展开时由 ROW_OPEN 键触发该行重算并读取最新数据 */
624
+ };
625
+ if (t.inlineEdit && typeof inlineEditReg === 'function' && pvOk(t.inlineEdit.when, sc, root)) {
626
+ const ie = t.inlineEdit, ieKey = String(pv(ie.key, sc, root) || '');
627
+ if (ieKey) {
628
+ const ieVal = pv(ie.value, sc, root), ieLabel = ie.label ? pvText(ie.label, sc, root) : tc('common.rename');
629
+ o.edit = inlineEditReg({
630
+ key: ieKey,
631
+ value: ieVal == null ? '' : String(ieVal),
632
+ act: pv(ie.act, sc, root),
633
+ args: pvArgsObj(ie.args || {}, sc, root),
634
+ label: ieLabel,
635
+ max: ie.max || 200,
636
+ selectStem: !!pv(ie.selectStem, sc, root)
637
+ });
638
+ }
639
+ }
640
+ if (t.note) o.note = pv(t.note, sc, root);
641
+ if (t.aside) {
642
+ const tail = t.aside.map(function (x) { return x ? pvJoin(x, sc, root, '') : ''; });
643
+ if (tail[0] || tail[1]) { o.aside = tail; if (t.swap !== undefined) o.swap = !!pv(t.swap, sc, root); }
644
+ }
645
+ if (t.subLines) o.subLines = t.subLines; /* 副行最多几行(超出省略) */
646
+ if (t.titleWrap) o.titleWrap = pv(t.titleWrap, sc, root); /* 打开时标题怎么排:auto(默认:展开区有内容时保持一行)、open(打开就换行看全) */
647
+ if (t.more && pvOk(t.moreWhen, sc, root) && !t.moreAfter) o.more = pvRowMore(t, sc, root); /* 模板在行的作用域里画,内部 each 保留自己的作用域 */
648
+ return o;
649
+ }
650
+ function pvRowMore(t, sc, root) { const blocks = pv(t.more, sc, root); return pvBlocks(typeof blocks === 'string' ? pvList(blocks, sc, root) : blocks, sc, root); }
651
+ function pvRowHtml(t, it, root, listId) {
652
+ const tpl = pdlLoc(typeof t === 'string' ? PDL_ROWS[t] : t);
653
+ return lrow(pvRow(tpl, it, root, listId)) + (tpl.more && tpl.moreAfter && pvOk(tpl.moreWhen, it, root) ? pvRowMore(tpl, it, root) : '');
654
+ }
655
+
656
+ /* ───────── 设置行 ─────────
657
+ 一行:{ label, help, value | control | ctls, mono, faint, tip, acts, use/props(整行是组件), link(可点的行), kind(field / empty / row,来自数据的行) } */
658
+ function pvSetting(r, sc, root, lit, plain) {
659
+ const T = function (x) { return lit ? (x == null ? '' : h(String(x))) : pvText(x, sc, root); };
660
+ if (r.blocks) return pvBlocks(r.blocks, lit ? r : sc, root); /* 组里的一行换成几个块(行内表单、说明) */
661
+ if (r.link) return lrow({ layout: 'line', title: T(r.label), act: r.act, data: pvArgs(r.args, sc, root) });
662
+ if (r.kind === 'field') { const fs = lit ? r : sc; return field({ label: lit ? r.label : pvText(r.label, sc, root), id: pv(r.id, fs, root), req: !!pv(r.req, fs, root), note: r.note, control: pvControls(r.control, fs, root), help: r.help ? (lit ? h(r.help) : pvParts(r.help, sc, root)) : '', foot: r.foot ? pvParts(r.foot, fs, root) : '' }); } /* 表单字段:标签(必填 *、?)、控件(一个或几个)、字段下方一行 foot(状态、校验错误、字段操作) */
663
+ let right;
664
+ if (r.ctls) right = pvControls(r.ctls, lit ? r : sc, root);
665
+ else if (r.control) right = pvControl(r.control, lit ? r : r.scope ? pv(r.scope, sc, root) : sc, root);
666
+ else if (lit && r.parts != null) right = pvLit(r.parts, r, root);
667
+ else if (plain) right = T(r.value);
668
+ else if (lit && (r.value == null || r.value === '')) right = '';
669
+ else right = '<span class="sys-v' + (r.mono ? ' mono' : '') + (r.faint ? ' faint' : '') + '"' + (r.tip ? ' data-tip="' + h(lit ? r.tip : pv(r.tip, sc, root) || '') + '"' : '') + '>' + T(r.value) + '</span>';
670
+ if (r.acts) right += r.acts.map(function (a) { return lrAct({ label: a.label, icon: a.icon, act: a.act, data: pvArgs(a.args, sc, root) }); }).join('');
671
+ const help = r.help ? (lit ? pvLit(r.help, r, root) : pvParts(r.help, sc, root)) : '';
672
+ return srow(lit ? r.label : (r.label && typeof r.label === 'object' && r.label.lit != null ? h(r.label.lit) : pvText(r.label, sc, root)), right, { help: help });
673
+ }
674
+ function pvSettings(b, sc, root) {
675
+ let out = [];
676
+ if (b.from) {
677
+ const tpl = b.row;
678
+ const rows = pvRepeat(b, pvList(b.from, sc, root), root, function (it, r) {
679
+ if (tpl && !pvOk(tpl.when, it, r)) return '';
680
+ const html = tpl ? (tpl.swap && pvOk(tpl.swap.when, it, r) ? pvBlocks(tpl.swap.blocks, it, r) : pvSetting(tpl, it, r, false))
681
+ : pvSetting(it, it, r, true, b.plain) + (it.after ? pvBlocks(it.after, it, r) : '');
682
+ return { html: html, meta: true };
683
+ }, { key: b.itemKey ?? tpl?.key });
684
+ out = b.empty && !rows.metas.some(Boolean) ? [emptyState(pvText(b.empty, sc, root))] : rows.parts;
685
+ }
686
+ if (b.rows) out = out.concat(b.rows.filter(function (r) { return pvOk(r.when, sc, root); }).map(function (r) { return pvSetting(r, sc, root, false); }));
687
+ return out;
688
+ }
689
+
690
+ /* ───────── 块 ───────── */
691
+ /* 容器(box)和一排控件(toolbar)的角色 → 组件库的类(角色的含义见 PDL_ROLES)。没写角色 = 组件的默认 */
692
+ const BOX = { '': 'vw-box', card: 'vw-card', group: 'group', composer: 'composer typing-scope', log: 'vw-log scroll', scroll: 'vw-scrollbox vw-scroll scroll', expand: 'vw-expand', inline: 'pdl-inline', columns: 'vw-cols', viewport: 'wpv', hero: 'vw-hero', dock: 'vw-dock' };
693
+ const BAR = { '': 'toolbar', head: 'chat-head', savebar: 'savebar', selection: 'toolbar vw-selection', embed: 'vw-embed', marker: 'vw-marker', float: 'vw-float' };
694
+ /* 标题行在容器里的角色:默认是容器本身的头(取容器的返回),detail 是下钻出来的详情的头(先取下钻的返回) */
695
+ const HEAD_ROLE = { page: 'page', hero: 'page', detail: 'detail' };
696
+ /* 头的统一排法:标题 → 行内状态(带色调点的小字,紧跟标题、垂直居中)→ 空白 → 所有操作控件(文字按钮、图标按钮、更多、开关)在最后。
697
+ 声明里写在 actions 里的状态(type: 'status')由这里分出来放到标题后面;视图不用各自安排 */
698
+ function pvHeadSplit(cs, sc, root) {
699
+ if (typeof cs === 'string') cs = pv(cs, sc, root); cs = pdlLoc(cs); cs = Array.isArray(cs) ? cs : cs ? [cs] : [];
700
+ const st = cs.filter(function (c) { return c && c.type === 'status'; }), rest = cs.filter(function (c) { return !(c && c.type === 'status'); });
701
+ const sh = pvControls(st, sc, root);
702
+ return { status: sh ? '<span class="head-status">' + sh + '</span>' : '', acts: pvControls(rest, sc, root) };
703
+ }
704
+ function pvHead(b, sc, root) {
705
+ /* close:这个标题所在弹窗的名字,× 由弹窗框架给(popX:声明了 x 的弹窗才有) */
706
+ const v = b.variant || 'page', xk = b.close ? pv(b.close, sc, root) : '', x = xk ? popX(xk) : '', hs = pvHeadSplit(b.actions, sc, root), actions = hs.acts + x;
707
+ const label = typeof b.title === 'string' ? pv(b.title, sc, root) : null;
708
+ const bk = backTake(HEAD_ROLE[v], typeof label === 'string' ? label : ''); /* 页名可由容器声明,否则取页头文字 */
709
+ if (v === 'hero') return '<div class="pdl-greeting">' + bk + '<h1 class="greet"' + pvNote(b.note) + '>' + pvText(b.title, sc, root) + '</h1>' + (b.sub ? '<p class="pdl-greeting-subtitle">' + pvText(b.sub, sc, root) + '</p>' : '') + '</div>';
710
+ /* 详情 / 子层的头:眉题、标题(可带 ?)、副标题或一行数据(desc,里面可以有控件),都可以是视图模型给的片段 */
711
+ if (v === 'detail') {
712
+ const eyebrow = pvAny(b.eyebrow, sc, root), title = b.title ? pvAny(b.title, sc, root) + helpTip(pv(b.help, sc, root)) : '', sub = (b.sub ? pvAny(b.sub, sc, root) : b.desc ? (b.desc.t ? pvText(b.desc, sc, root) : pvAny(b.desc, sc, root)) : '') + annotLabel(pvAnnot(b.label, sc, root), 'after');
713
+ return bk || eyebrow || title || hs.status || sub || actions ? detailHead({ back: bk, eyebrow: eyebrow, title: title, status: hs.status, sub: sub, note: b.note, actions: actions }) : '';
714
+ }
715
+ /* 说明进 help;状态(meta)和状态里的操作(descAction)是 label,标题下方直接显示 */
716
+ const sub = (b.meta ? pvParts(b.meta, sc, root) : '') + (b.descAction ? pvControl(b.descAction, sc, root) : '');
717
+ return pageHead({ back: bk, lead: b.lead ? pvJoin(b.lead, sc, root, '') : '', title: pvText(b.title, sc, root), status: hs.status, titleNote: b.note, help: pv(b.help, sc, root) || (b.desc ? pvText(b.desc, sc, root) : ''), sub: sub, label: pvAnnot(b.label, sc, root), actions: (b.tools ? pvControls(b.tools, sc, root) : '') + actions, actNote: b.actNote });
718
+ }
719
+ function pvListContainerId(id) {
720
+ return pdlUnitScope('list', id);
721
+ }
722
+ function pvItemKey(item) { return item?.id ?? item?.key ?? item?.path ?? item?.mid; }
723
+ function pvListKeyOf(tpl, root) {
724
+ if (!tpl || tpl.key == null) return pvItemKey;
725
+ return function (it) { return pv(tpl.key, it, root); };
726
+ }
727
+ /* 映射在单元的读取作用域内进行。 */
728
+ function unitsItem(b, it, root) { return b.item ? Object.assign({}, it, pvDeep(b.item, root, it)) : it; }
729
+ function pvRepeat(b, items, root, draw, { key = b.itemKey, part = '', cacheOnly = false, version } = {}) {
730
+ return pdlUnits({
731
+ id: pdlUnitScope(b.type, part), items: items, root: root, keyOf: pvListKeyOf({ key: key }, root),
732
+ cacheOnly: cacheOnly, version: version,
733
+ draw: function (it, r) { return draw(unitsItem(b, it, r), r); }
734
+ });
735
+ }
736
+ Object.assign(PV.units, { each: 1, settings: 1, kv: 1, stats: 1 });
737
+ function pvListBody(b, sc, root) {
738
+ const tpl = pdlLoc(typeof b.row === 'string' ? PDL_ROWS[b.row] : b.row);
739
+ const useUnits = typeof pdlUnits === 'function';
740
+ if (b.groups) { /* 分组:组标题和行在同一个列表底里,均接入行级单元 */
741
+ const gs = pvList(b.groups, sc, root).filter(function (g) { return g.items.length || g.keep; }); /* keep:没有行的组也画组标题(比如一段还没有运行的会话) */
742
+ const cls = 'group lr-list' + (b.scroll ? ' vw-scroll scroll' : ''), gid = pv(b.id, sc, root);
743
+ if (!gs.length) return '<div class="' + cls + '">' + emptyState({ html: pvText(b.empty, sc, root) }) + '</div>';
744
+ const gh = function (g, r) { const t = b.group; if (!t) return g; const m = t.more && pvOk(t.more.when, g, r) ? { label: pv(t.more.label, g, r), act: t.more.act, args: pvArgsObj(t.more.args, g, r) } : null; return { title: pv(t.title, g, r), count: t.count != null ? pv(t.count, g, r) : null, act: pv(t.act, g, r), args: pvArgsObj(t.args, g, r), more: m, who: g.who, meta: g.meta, items: g.items }; };
745
+ const drawHead = function (g0, r) {
746
+ const g = gh(g0, r);
747
+ if (g.who) {
748
+ const w = whoInfo(g.who), col = w.color || 'var(--identity-fallback)';
749
+ const labelHtml = '<span class="lr-who-g">' + whoAva(g.who, { size: 'xs', tip: false }) + '<b class="lr-who-n">' + h(w.name) + '</b>' + (g.meta ? '<span class="lr-who-m">· ' + h(g.meta) + '</span>' : '') + '</span>';
750
+ return lrSection(g.title || w.name, g.more ? btn(g.more.label, { sm: true, act: g.more.act, data: argAttrs(g.more.args) }) : '', { html: labelHtml, attrs: ' style="--c:' + h(col) + '"', count: g.count != null ? g.count : g.items.length });
751
+ }
752
+ if (g.title) {
753
+ return lrSection(g.title, g.more ? btn(g.more.label, { sm: true, act: g.more.act, data: argAttrs(g.more.args) }) : '', { html: g.act ? btn(g.title, { link: true, act: g.act, data: argAttrs(g.args) }) : null, count: g.count != null ? g.count : g.items.length });
754
+ }
755
+ return '';
756
+ };
757
+ const drawRow = function (it, r, col) {
758
+ const row = pvRow(b.row, it, r, gid);
759
+ row.many = b.expand === 'many';
760
+ if (col) { row.color = col; row.rootAttrs = (row.rootAttrs || '') + ' data-who-row="1"'; }
761
+ return { html: lrow(row), meta: { colSig: lrColSig(row.cols) } };
762
+ };
763
+ if (useUnits) {
764
+ const explicitKey = pvListKeyOf(tpl, root);
765
+ const flatKeys = [], entryByKey = new Map();
766
+ let allKeyed = true;
767
+ for (let gi = 0; gi < gs.length; gi++) {
768
+ const g = gs[gi], gk = g.key ?? g.id ?? g.title;
769
+ const col = g.who ? (whoInfo(g.who).color || 'var(--identity-fallback)') : null;
770
+ if (g.who || g.title || (b.group && (b.group.title != null))) {
771
+ const hk = 'g:' + gk;
772
+ if (gk == null || entryByKey.has(hk)) { allKeyed = false; break; }
773
+ flatKeys.push(hk);
774
+ entryByKey.set(hk, { isHead: true, g: g, version: vmJson(g) });
775
+ }
776
+ const source = pdlKeyedListInfo(g.items);
777
+ if (source) {
778
+ const ks = source.keys;
779
+ for (let ii = 0; ii < ks.length; ii++) {
780
+ const rk = 'r:' + ks[ii];
781
+ if (entryByKey.has(rk)) { allKeyed = false; break; }
782
+ flatKeys.push(rk);
783
+ entryByKey.set(rk, { isHead: false, key: ks[ii], read: source.read, col: col });
784
+ }
785
+ } else {
786
+ const rKeys = pdlUnitKeys(g.items, explicitKey);
787
+ if (!rKeys) { allKeyed = false; break; }
788
+ for (let ii = 0; ii < rKeys.length; ii++) {
789
+ const rk = 'r:' + rKeys[ii];
790
+ if (entryByKey.has(rk)) { allKeyed = false; break; }
791
+ flatKeys.push(rk);
792
+ entryByKey.set(rk, { isHead: false, item: g.items[ii], col: col });
793
+ }
794
+ }
795
+ if (!allKeyed) break;
796
+ }
797
+ if (allKeyed) {
798
+ const hasLazy = gs.every(function (g) { return !!pdlKeyedListInfo(g.items); });
799
+ const source = hasLazy
800
+ ? pdlKeyedList(flatKeys, function (k) {
801
+ const e = entryByKey.get(k);
802
+ if (e.isHead) return { __head: true, title: e.g.title, who: e.g.who, meta: e.g.meta, count: e.g.count, act: e.g.act, args: e.g.args, more: e.g.more, n: e.g.items.length };
803
+ return e.read ? e.read(e.key) : e.item;
804
+ })
805
+ : flatKeys.map(function (k) {
806
+ const e = entryByKey.get(k);
807
+ return e.isHead ? { __uk: k, __head: true } : { __uk: k, __item: e.read ? e.read(e.key) : e.item };
808
+ });
809
+ const uRes = pdlUnits({
810
+ id: pvListContainerId(gid),
811
+ items: source,
812
+ keyOf: hasLazy ? null : function (x) { return x.__uk; },
813
+ root: root,
814
+ onRowPatch: lrUpdateCols,
815
+ version: function (k) { const e = entryByKey.get(k); return e.isHead ? e.version : e.col; },
816
+ draw: function (it, r, k) {
817
+ const e = entryByKey.get(k);
818
+ if (e.isHead) return { html: drawHead(e.g, r), meta: { colSig: [] } };
819
+ return drawRow(hasLazy ? it : it.__item, r, e.col);
820
+ }
821
+ });
822
+ const sigs = uRes.metas.map(function (m) { return m && m.colSig; }).filter(Boolean);
823
+ return '<div class="' + cls + '"' + lrColsFromSigs(sigs) + ' data-own="units">' + uRes.html + '</div>';
824
+ }
825
+ }
826
+ const rows = gs.map(function (g) {
827
+ const col = g.who ? (whoInfo(g.who).color || 'var(--identity-fallback)') : null;
828
+ return g.items.map(function (it) {
829
+ const r = pvRow(b.row, it, root, gid);
830
+ r.many = b.expand === 'many';
831
+ if (col) { r.color = col; r.rootAttrs = (r.rootAttrs || '') + ' data-who-row="1"'; }
832
+ return r;
833
+ });
834
+ });
835
+ return '<div class="' + cls + '"' + lrCols([].concat.apply([], rows)) + '>' + gs.map(function (g, gi) {
836
+ return drawHead(g, root) + rows[gi].map(lrow).join('');
837
+ }).join('') + '</div>';
838
+ }
839
+ const id = pv(b.id, sc, root), all = pvList(b.from, sc, root), q = b.searchable ? (LIST_Q.get(id) || '') : '';
840
+ const pageKey = id || PV.viewId + ':' + (typeof b.from === 'string' ? b.from : '');
841
+ const source = pdlKeyedListInfo(all);
842
+ const keyed = source && !q.trim(), sequence = keyed ? source.keys : all;
843
+ const ordered = b.reverse ? sequence.slice().reverse() : sequence;
844
+ const found = keyed ? ordered : listFind(ordered, q);
845
+ const page = b.pagination && listPageWindow(pageKey, found.length, pv(b.pagination.resetOn, sc, root) ?? q);
846
+ const start = page ? page.start : 0;
847
+ const limit = page ? start + LIST_PAGE_N : b.order || b.inline || b.next || b.rows ? Infinity : (LIST_PAGE.get(pageKey) || LIST_PAGE_N);
848
+ const slice = start || found.length > limit ? found.slice(start, limit) : found;
849
+ const items = keyed ? (slice === source.keys ? all : pdlKeyedList(slice, source.read, { sig: source.sig })) : slice;
850
+ const more = page ? page.controls : items.length < found.length ? listNextTail('page:' + pageKey, { act: 'listMore', args: { list: pageKey }, enabled: true, busy: false }) : '';
851
+ const esc = b.searchable ? Object.assign({}, sc, { q: q }) : sc;
852
+ const orderAct = b.order ? pv(b.order, sc, root) : null;
853
+ if (!items.length) {
854
+ if (b.inline) return emptyState({ text: pvText(b.empty, sc, root) || tc('list.empty') });
855
+ return lrList(id, [], { empty: pvText(b.empty, esc, root), emptyActs: b.emptyAction ? pvControl(b.emptyAction, esc, root) : '', rows: b.rows || 0, many: b.expand === 'many', order: orderAct, cls: (b.scroll ? 'vw-scroll scroll' : '') }) + more;
856
+ }
857
+ if (useUnits) {
858
+ const rowListId = b.inline || (tpl && tpl.moreAfter) ? null : id;
859
+ const uRes = pdlUnits({
860
+ id: pvListContainerId(id),
861
+ items: items,
862
+ keyOf: pvListKeyOf(tpl, root),
863
+ root: root,
864
+ onRowPatch: lrUpdateCols,
865
+ draw: function (it, r) {
866
+ const row = pvRow(b.row, it, r, rowListId);
867
+ row.many = b.expand === 'many';
868
+ row.orderable = !!orderAct;
869
+ const html = tpl && tpl.moreAfter
870
+ ? lrow(row) + (tpl.more && pvOk(tpl.moreWhen, it, r) ? pvRowMore(tpl, it, r) : '')
871
+ : lrow(row);
872
+ return { html: html, meta: { colSig: lrColSig(row.cols), compact: row.layout === 'record' || row.layout === 'tree' } };
873
+ }
874
+ });
875
+ const sigs = uRes.metas.map(function (m) { return m && m.colSig; }).filter(Boolean);
876
+ const ownAttr = uRes.keyed ? ' data-own="units"' : '';
877
+ if (b.inline) return '<div class="lr-inline"' + lrColsFromSigs(sigs) + ownAttr + '>' + uRes.html + '</div>';
878
+ if (tpl && tpl.moreAfter) return '<div class="group lr-list"' + lrColsFromSigs(sigs) + ownAttr + '>' + uRes.html + '</div>' + more;
879
+ const compact = uRes.metas.length && uRes.metas.every(function (m) { return m && m.compact; });
880
+ const tr = b.rows ? lrColTracksFromSigs(sigs) : '';
881
+ const attrs = b.rows ? (tr ? ' data-cols' : '') + scrollRows(b.rows, compact ? '--row-h-sm' : '--row-h', tr || null) : lrColsFromSigs(sigs);
882
+ const ord = orderAct ? ' data-ocontainer="list:' + h(id) + '" data-order-act="' + h(orderAct) + '"' : '';
883
+ return '<div class="group lr-list' + (b.rows ? ' scroll' : '') + (b.scroll ? ' vw-scroll scroll' : '') + '"' + attrs + ord + ownAttr + '>' + uRes.html + '</div>' + more;
884
+ }
885
+ if (tpl && tpl.moreAfter) {
886
+ const rows = items.map(function (it) { return pvRowHtml(b.row, it, root, null); }).join('');
887
+ return b.inline ? '<div class="lr-inline"' + lrCols(items.map(function (it) { return pvRow(b.row, it, root, null); })) + '>' + rows + '</div>' : '<div class="group lr-list"' + lrCols(items.map(function (it) { return pvRow(b.row, it, root, null); })) + '>' + rows + '</div>' + more;
888
+ }
889
+ if (b.inline) { const rs = items.map(function (it) { return pvRow(b.row, it, root, null); }); return '<div class="lr-inline"' + lrCols(rs) + '>' + rs.map(lrow).join('') + '</div>'; }
890
+ return lrList(id, items.map(function (it) { return pvRow(b.row, it, root, id); }), { empty: pvText(b.empty, esc, root), emptyActs: b.emptyAction ? pvControl(b.emptyAction, esc, root) : '', rows: b.rows || 0, many: b.expand === 'many', order: orderAct, cls: (b.scroll ? 'vw-scroll scroll' : '') }) + more;
891
+ }
892
+ /* 按 pane 的 min / max / fill 分配宽度:先满足 min;只有一栏时铺满;有 fill 时剩余给 fill,
893
+ 否则按各栏 min 的比例分,每个不超过 max,封顶后的余量再分给还能变宽的那几栏。
894
+ width 是 grid 的内容宽度(不含 gap):各栏宽度之和 = width - gap * (栏数 - 1)。 */
895
+ function paneWidths(panes, width) {
896
+ const out = panes.map(function (p) { return p.min; });
897
+ if (!width) return out;
898
+ if (panes.length === 1) return [width];
899
+ let free = width - out.reduce(function (a, b) { return a + b; }, 0);
900
+ if (free <= 0) return out;
901
+ let open = panes.map(function (p, i) { return i; });
902
+ while (free > 0.5 && open.length) {
903
+ const fills = open.filter(function (i) { return panes[i].fill; });
904
+ const pool = fills.length ? fills : open;
905
+ const weights = pool.map(function (i) { return fills.length ? 1 : panes[i].min || 1; });
906
+ const sum = weights.reduce(function (a, b) { return a + b; }, 0) || 1;
907
+ let used = 0;
908
+ pool.forEach(function (i, j) {
909
+ const limit = panes[i].max == null ? Infinity : Math.max(0, panes[i].max - out[i]);
910
+ const add = Math.min(limit, free * weights[j] / sum);
911
+ out[i] += add; used += add;
912
+ });
913
+ free -= used;
914
+ open = open.filter(function (i) { return panes[i].max == null || out[i] < panes[i].max - 0.5; });
915
+ if (used < 0.5) break;
916
+ }
917
+ return out;
918
+ }
919
+
920
+ /* 宽度是节点的测量值,布局模式才影响画哪些 pane。 */
921
+ function paneLayout(panes, room) {
922
+ const width = Number(room?.width) || 0, gap = Number(room?.gap) || 0;
923
+ if (!width) return { stack: false, columns: 'repeat(' + panes.length + ', minmax(0, 1fr))' };
924
+ const available = width - gap * (panes.length - 1);
925
+ if (panes.length > 1 && panes.reduce(function (sum, pane) { return sum + pane.min; }, 0) > available) return { stack: true };
926
+ return { stack: false, columns: paneWidths(panes, available).map(function (w) { return w + 'px'; }).join(' ') };
927
+ }
928
+ const PANE_ROOMS = new WeakMap(), PANE_MODE_CHANGES = new Set();
929
+ let PANE_LAYOUT_REVISION = 0, PANE_LAYOUT_FRAME = 0;
930
+ function paneRoom(key) {
931
+ const el = document.querySelector('[data-panes="' + CSS.escape(key) + '"]:not(.layer-covered [data-panes])');
932
+ return el ? PANE_ROOMS.get(el) : null;
933
+ }
934
+ function paneApplyRoom(el, room) {
935
+ const layout = paneLayout(JSON.parse(el.dataset.paneTracks), room);
936
+ if (layout.stack !== el.classList.contains('vw-panes-stack')) return true;
937
+ if (!layout.stack && el.style.gridTemplateColumns !== layout.columns) el.style.gridTemplateColumns = layout.columns;
938
+ return false;
939
+ }
940
+ function paneResize(entries) {
941
+ for (const entry of entries) {
942
+ const el = entry.target;
943
+ if (!el.isConnected) { PANE_OBSERVER.unobserve(el); continue; }
944
+ if (!entry.contentRect.width || el.closest('[hidden], [inert]')) continue;
945
+ const room = { width: entry.contentRect.width, gap: parseFloat(getComputedStyle(el).columnGap) || 0 };
946
+ PANE_ROOMS.set(el, room);
947
+ if (paneApplyRoom(el, room)) PANE_MODE_CHANGES.add(el);
948
+ else PANE_MODE_CHANGES.delete(el);
949
+ }
950
+ if (!PANE_MODE_CHANGES.size || PANE_LAYOUT_FRAME) return;
951
+ PANE_LAYOUT_FRAME = requestAnimationFrame(function () {
952
+ PANE_LAYOUT_FRAME = 0;
953
+ const changed = Array.from(PANE_MODE_CHANGES).some(function (el) {
954
+ return el.isConnected && !el.closest('[hidden], [inert]') && paneApplyRoom(el, PANE_ROOMS.get(el));
955
+ });
956
+ PANE_MODE_CHANGES.clear();
957
+ if (!changed) return;
958
+ PANE_LAYOUT_REVISION++;
959
+ renderForget();
960
+ render(true);
961
+ });
962
+ }
963
+ const PANE_OBSERVER = new ResizeObserver(function (entries) { paneResize(entries); });
964
+ treeMatch('[data-panes]', function (el) { PANE_OBSERVER.observe(el); });
965
+ OWN.panes = function (live, next) {
966
+ const room = PANE_ROOMS.get(live);
967
+ if (room) paneApplyRoom(live, room); /* 缓存的视图 HTML 也沿用节点最新的列宽 */
968
+ patchKids(live, next);
969
+ };
970
+
971
+ Object.assign(PDL_BLOCKS, {
972
+ head: pvHead,
973
+ /* 一排控件:items;或 left / right;foot 还可以带片段 parts */
974
+ /* 分道的一行(组件库):几条道按 share 分宽度(比如 1:3:1),每条道是横向滚动原件(scroll-x,溢出那边渐隐 = 还有内容);
975
+ 空的道不占位,把份额让给别的道。道里悬停展开的层会升到浮层层(escape),不被道的滚动裁掉 */
976
+ lanes: function (b, sc, root) {
977
+ /* scroll: true 的道才是横向滚动容器(可能溢出,溢出那边渐隐);不滚动的道按内容定宽,永远不渐隐 */
978
+ const ls = b.lanes.map(function (l) { return { share: l.share || 0, scroll: !!l.scroll, html: pvControls(l.items, sc, root), name: l.name || '', align: ['center', 'end'].indexOf(l.align) >= 0 ? l.align : 'start', attach: l.attach === 'straddle' ? 'straddle' : 'above' }; });
979
+ if (!ls.some(function (l) { return l.html; })) return ''; /* 没内容的道也占着它的列:别的道有没有内容,居中的那条都不挪 */
980
+ if (b.key) { const want = pdlOrderOf(b.key, ls.map(function (l) { return l.name; })); ls.sort(function (x, y) { return want.indexOf(x.name) - want.indexOf(y.name); }); } /* 有 key 的道组是容器:道在组内按用户的顺序排 */
981
+ return '<div class="lanes" data-island="lanes:' + (b.key || '') + '"' + (b.key ? ' data-ocontainer="' + h(b.key) + '"' : '') + ' style="--lanes:' + ls.map(function (l) { return l.share ? 'minmax(' + (l.scroll ? '0' : 'max-content') + ', ' + l.share + 'fr)' : 'fit-content(60%)'; }).join(' ') /* 不滚动的道从不比内容窄;按内容定宽的中间道受限于容器比例,避免压扁两侧滚动道 */ + '">' +
982
+ ls.map(function (l) { return '<div class="lane' + (l.scroll ? ' scroll-x' : '') + '" data-attach="' + l.attach + '" data-align="' + l.align + '"' + (l.name ? ' data-lane="' + l.name + '"' + (b.key ? ' data-okey="' + l.name + '"' + (S.editLayout ? ' data-edit="order"' : '') : '') : '') + '><div class="lane-in">' + l.html + '</div></div>'; }).join('') + '</div>';
983
+ },
984
+ /* 一排控件:items;或 left / right(右边的推到末尾),可以带片段 parts。角色见 PDL_ROLES.toolbar;什么都没有就不画 */
985
+ toolbar: function (b, sc, root) {
986
+ const v = b.variant || '';
987
+ const drop = b.dropAct ? ' data-drop-act="' + h(b.dropAct) + '"' : '';
988
+ let inner;
989
+ if ((b.ordered || b.kind === 'actions') && b.key) { /* 操作组(kind: 'actions')默认就是一排格子,用户可以在组内编排(不用逐个开启)。grow 之前的项默认从起始端排,之后的从结束端排;每项按种类占 span 个格子;固定的(locked,比如发送)不动 */
990
+ let anchor = 'start';
991
+ const bk = v === 'head' ? backTake('page') : ''; /* 返回路径在格子组前面,长度由容器决定 */
992
+ const items = (b.items || []).map(function (c) {
993
+ if (c.type === 'grow') { anchor = 'end'; return null; }
994
+ const html = pvControl(c, sc, root); if (!html) return null;
995
+ return { key: c.key || c.variant || c.act || c.type, html: html, span: c.span || 's', anchor: anchor, locked: !!c.locked }; /* 没写 key 的项按它的动作认 */
996
+ }).filter(Boolean);
997
+ return cellsHtml({ key: b.key, axis: 'row', items: items, before: bk, saved: pdlCells(b.key), edit: S.editLayout, cls: BAR[v], attrs: drop });
998
+ }
999
+ const bk = v === 'head' && !b.key ? backTake('page') : '';
1000
+ if (b.left || b.right) { const right = pvControls(b.right, sc, root); inner = bk + pvControls(b.left, sc, root) + pvParts(b.parts, sc, root) + (right ? '<span class="grow"></span>' + right : ''); }
1001
+ else inner = bk + pvControls(b.items, sc, root) + pvParts(b.parts, sc, root);
1002
+ if (!inner.replace(/<span class="grow"><\/span>/g, '') && b.id == null) return ''; /* 里面只剩撑开的空白(按钮都按条件藏了):整条不画 */
1003
+ const tone = pv(b.tone, sc, root), tag = b.form ? 'form' : 'div', cls = BAR[v] + (tone ? ' vw-t-' + tone : '');
1004
+ /* id / hidden:保存栏这类由别处按 id 显示、隐藏的条 */
1005
+ return '<' + tag + ' class="' + cls + '"' + drop + (b.id ? ' id="' + b.id + '"' : '') + (b.hidden != null && pvOk(b.hidden, sc, root) ? ' hidden' : '') + (b.form ? ' data-form="' + b.form + '"' + pvArgs(b.args, sc, root) : '') + pvNote(pv(b.note, sc, root)) + '>' + inner + '</' + tag + '>';
1006
+ },
1007
+ section: function (b, sc, root) {
1008
+ /* 小节里直接是设置行(rows / from / row):设置行组就是它的正文(系统配置这类按数据结构走的小节) */
1009
+ if (b.rows || b.from) b = Object.assign({}, b, { blocks: [{ type: 'settings', rows: b.rows, from: b.from, row: b.row }].concat(b.blocks || []), rows: null, from: null, row: null });
1010
+ let body = pvBlocks(b.blocks, sc, root);
1011
+ if (!body && !b.keep) return '';
1012
+ const hs = pvHeadSplit(b.actions, sc, root);
1013
+ if (b.id && PV.anchors) PV.anchors.push({ id: pv(b.id, sc, root), label: pvText(b.title, sc, root) }); /* 小节标题是锚点:同一视图里的目录(toc)从这里取条目 */
1014
+ return section({ id: b.id ? pv(b.id, sc, root) : null, title: pvText(b.title, sc, root), note: b.note, help: pv(b.help, sc, root) || (b.desc ? pvText(b.desc, sc, root) : ''), label: pvAnnot(b.label, sc, root), status: hs.status, actions: hs.acts, body: body });
1015
+ },
1016
+ /* 列表:空 / 加载 / 出错之外还有“部分可用”(partial:有的来源读不到)——列表顶上一行 warn 色调,文字是视图声明的 */
1017
+ /* 列表:没有数据时也画列表,里面是组件库的空状态(声明的 empty 文字,没声明就是通用的“无”)——有没有数据,这一块看起来一样。
1018
+ 唯一的例外是声明了 optional 的子组(只在有成员时才存在,如已封存的会话、过去参与的猫):没有项时整个不画,连它的组标签(label)一起 */
1019
+ list: function (b, sc, root) {
1020
+ const n = b.groups ? pvList(b.groups, sc, root).filter(function (g) { return g.items.length || g.keep; }).length : pvList(b.from, sc, root).length;
1021
+ if (b.optional && !n) return '';
1022
+ const pt = pv(b.partial, sc, root), q = b.searchable && n ? listQField(pv(b.id, sc, root)) : '';
1023
+ const acts = b.actions ? pvControls(b.actions, sc, root) : '';
1024
+ const lab = b.label ? lrSection(pvText(b.label, sc, root), q + acts, { count: b.count != null ? pv(b.count, sc, root) : null }) : q || acts ? '<div class="lr-section-label">' + q + acts + '</div>' : ''; /* 筛选框和列表的操作在列表自己的头里:有组标签时在它的行尾,没有时单独一行头 */
1025
+ return lab + (pt ? '<div class="lr-partial" data-tone="warn" role="status">' + icon('alert', 14) + h(pt) + '</div>' : '') + pvListBody(b, sc, root) + listNextHtml(b.next, sc, root);
1026
+ },
1027
+ tree: function (b, sc, root) {
1028
+ const nodes = pv(b.nodes, sc, root) || {}, pending = pv(b.pending, sc, root) || {};
1029
+ const branch = typeof nodes === 'function' ? nodes : null;
1030
+ const sel = b.select;
1031
+ return ltree(pv(b.id, sc, root), function (path) { return nodes[path] || []; }, {
1032
+ branch: branch,
1033
+ root: root,
1034
+ rootPath: '',
1035
+ mapNode: function (data, r) {
1036
+ const n = b.item ? Object.assign({}, data, pvDeep(b.item, r, data)) : data;
1037
+ const row = pvRow(b.row, n, r, null);
1038
+ return { name: n.name, path: n.path, dir: n.dir, collapsedTip: pv(b.collapsedTip, n, r),
1039
+ row: { lead: row.lead, title: row.title, edit: row.edit, sub: row.sub, inline: row.inline, cols: row.cols, acts: row.acts, cur: row.cur, aside: row.aside, swap: row.swap },
1040
+ pick: sel && pvOk(sel.when, n, r) ? { act: pv(sel.act, n, r), data: pvArgs(sel.args, n, r) } : null };
1041
+ },
1042
+ fileAct: b.fileAct, fileData: function (n) { return pvArgs(b.fileArgs, n, root); }, flat: !!b.flat, divider: !!b.divider,
1043
+ ready: !!pv(b.ready, sc, root), pending: function (path) { return pending[path]; }
1044
+ });
1045
+ },
1046
+ /* 设置行组:rows(模板)、from(数据)、from + row(每项按行模板);行都在同一个分组底里 */
1047
+ settings: function (b, sc, root) {
1048
+ const rows = pvSettings(b, sc, root).filter(Boolean);
1049
+ return rows.length ? group(rows) : '';
1050
+ },
1051
+ /* 表单:提交时交给 FORMS[id];里面是任意块(字段行用 settings 的 field 行) */
1052
+ form: function (b, sc, root) {
1053
+ return '<form data-form="' + b.id + '"' + (b.htmlId ? ' id="' + b.htmlId + '"' : '') + pvArgs(b.args, sc, root) + ' class="form-sections"' + pvNote(b.note) + '>' + pvBlocks(b.blocks, sc, root) + '</form>';
1054
+ },
1055
+ /* 键值:都是组件库的 kvGrid(一列标签对齐、按最宽标签取档)。一行是 { k, v } 或 { label, value }。copy → 只读复制框、人 → 身份、act → 文字按钮、warn → 留意色。 */
1056
+ kv: function (b, sc, root) {
1057
+ const xs = b.item ? pvList(b.from, sc, root) : pvItems(b.from, sc, root);
1058
+ const units = pvRepeat(b, xs, root, function (r, view) {
1059
+ const k = r.k ?? r.label, v = r.v ?? r.value;
1060
+ if (r.copy) return { meta: [k, copyValue({ value: v, v: r.copyValue ?? v, label: typeof r.copy === 'string' ? r.copy : k, fieldLabel: k, mono: r.mono !== false, field: true, tip: r.tip })] };
1061
+ const act = pv(r.act, r, view);
1062
+ const template = b.item && (b.item.v || b.item.value), rich = template && (Array.isArray(template) || template.parts), value = pvLit(rich ? template : v, r, view);
1063
+ const val = r.who ? who(r.who, 'line') + (v ? ' <span class="faint">' + value + '</span>' : '') : act ? btn(v, { link: true, sm: true, act: act, data: argAttrs(!b.item && Array.isArray(b.from) ? pvArgsObj(r.args, sc === root ? view : sc, view) : r.args), html: rich ? value : undefined }) : r.warn ? '<span class="vw-t-warn">' + value + '</span>' : value;
1064
+ const plain = String(val ?? '');
1065
+ return { meta: /<(img|svg|button|input)/.test(plain) || plain.replace(/<[^>]*>/g, '').trim() ? [k, val] : null };
1066
+ }, { cacheOnly: true, version: sc === root || !Array.isArray(b.from) ? undefined : function () { return vmJson(sc); } });
1067
+ const rows = units.metas.filter(Boolean);
1068
+ return rows.length ? kvGrid(rows, { units: units.units?.id }) : '';
1069
+ },
1070
+ stats: function (b, sc, root) {
1071
+ const v = b.variant || 'grid';
1072
+ if (v === 'counters') {
1073
+ const units = pvRepeat(b, pvList(b.items, sc, root), root, function (i, r) {
1074
+ const scope = sc === root ? r : sc, tone = pv(i.tone, scope, r);
1075
+ return '<span class="vw-counter' + (tone ? ' vw-t-' + tone : '') + '"><b class="num">' + pvText(i.value, scope, r) + '</b>' + h(i.label) + '</span>';
1076
+ }, { version: sc === root ? undefined : function () { return vmJson(sc); } });
1077
+ return '<div class="vw-counters">' + units.html + '<span class="grow"></span>' + pvControls(b.actions, sc, root) + '</div>';
1078
+ }
1079
+ const units = pvRepeat(b, b.item ? pvList(b.from, sc, root) : pvItems(b.from, sc, root), root, function (x, r) {
1080
+ const value = x.format === 'number' ? Number(x.v).toLocaleString() : x.format === 'uptime' ? tc('stats.uptime', Math.floor(x.v / 3600), Math.floor(x.v % 3600 / 60)) : String(x.v);
1081
+ return '<div' + (x.tip ? ' data-tip="' + h(x.tip) + '"' : '') + '>' + (x.warn ? '<span class="vw-warn-t vw-13">' + h(x.warn) + '</span>' + (x.action ? pvControl(x.action, x, r) : '') : '<b' + (x.tone ? ' class="ws-' + x.tone + '"' : '') + '>' + h(value) + '</b><span>' + h(x.l) + '</span>') + '</div>';
1082
+ });
1083
+ return '<div class="kv">' + units.html + '</div>';
1084
+ },
1085
+ /* 文字:一行(片段 + ? + 控件,默认)、一段正文(para)、次要信息(meta)、卡片标题(title)、一列要点(list)。
1086
+ from + parts:按数据重复片段(一行里,sep 连接);from 单独:视图模型给的文字或片段 */
1087
+ text: function (b, sc, root) {
1088
+ const v = b.variant || '', tone = pv(b.tone, sc, root), help = helpTip(pv(b.help || b.hint, sc, root));
1089
+ if (v === 'list') { const xs = pvList(b.from, sc, root); return xs.length ? '<ul class="card-ul">' + xs.map(function (x) { return '<li>' + h(x) + '</li>'; }).join('') + '</ul>' : ''; }
1090
+ if (b.from && b.parts) {
1091
+ const xs = pvList(b.from, sc, root); if (!xs.length) return '';
1092
+ return lrText(xs.map(function (x) { return '<span' + (b.tip ? ' data-tip="' + pvText(b.tip, x, root) + '"' : '') + '>' + pvParts(b.parts, x, root) + '</span>'; }).join(b.sep == null ? ' · ' : b.sep), tone);
1093
+ }
1094
+ const t = b.from ? pvLit(pv(b.from, sc, root), sc, root) : b.parts ? (v ? (!Array.isArray(b.parts) && b.parts.parts ? pvParts(b.parts, sc, root) : pvJoin(b.parts, sc, root, '')) : pvParts(b.parts, sc, root)) : pvText(b.text, sc, root); /* parts 可以是 { sep, parts }:片段之间用 sep 连 */
1095
+ if (v === 'para') return t ? '<p class="vw-para' + (tone ? ' vw-t-' + tone : '') + '">' + t + help + '</p>' : '';
1096
+ if (v === 'meta') return t ? '<div class="vw-label below' + (tone ? ' vw-t-' + tone : '') + '">' + t + help + '</div>' : '';
1097
+ if (v === 'title') return t ? '<div class="vw-card-t">' + t + annotLabel(pvAnnot(b.label, sc, root), 'after') + help + annotLabel(pvAnnot(b.label, sc, root), 'corner') + '</div>' : '';
1098
+ const acts = pvControls(b.actions, sc, root);
1099
+ return t || acts ? lrText(t + help + (t && acts ? ' ' : '') + acts, tone) : '';
1100
+ },
1101
+ label: function (b, sc, root) { /* 组标签:只有一种(lrSection) */
1102
+ return lrSection(pv(b.text, sc, root) || '', b.action ? pvControl(b.action, sc, root) : '', { count: b.count != null ? pv(b.count, sc, root) : null, help: pv(b.help, sc, root), tip: pv(b.tip, sc, root) });
1103
+ },
1104
+
1105
+ /* 提示:粗体开头 + 正文 + 操作;from 时一项一条(撤销不在这里:可撤回的动作给撤销提示,core.js undoShow) */
1106
+ notice: function (b, sc, root) {
1107
+ const one = function (x) { const st = pv(b.strong, x, root); if (pvSaidInHead(st, pv(b.text, x, root))) return ''; return notice({ tone: pv(b.tone, x, root), note: b.note, text: (st ? '<b>' + h(st) + '</b>' : '') + (b.parts ? pvParts(b.parts, x, root) : pvText(b.text, x, root)) + (b.num ? ' <span class="num">' + pvText(b.num, x, root) + '</span>' : '') + (function () { const it = pvList(b.items, x, root); return it.length ? '<ul class="pdl-bullets">' + it.map(function (t) { return '<li>' + (b.each ? pvParts(b.each, t, root) : h(t)) + '</li>'; }).join('') + '</ul>' : ''; /* each:每一项怎么画(@ 是这一项) */ })(), action: pvControls(b.action, x, root) }); };
1108
+ return b.from ? pvList(b.from, sc, root).map(one).join('') : one(sc);
1109
+ },
1110
+
1111
+ tabs: function (b, sc, root) {
1112
+ const xs = pvList(b.from, sc, root); /* 一排标签页只有一个样子;声明了 close 的每个标签带 ×;滚动只裹标签,后置按钮留在外侧不被滚走 */
1113
+ const strip = pvRepeatRows(b, sc, root, xs, function (x, r) {
1114
+ const on = !!pv(b.selected, x, r);
1115
+ const tab = '<button type="button" role="tab" aria-selected="' + on + '" data-act="' + b.act + '"' + pvArgs(b.args, x, r) + ' data-tip="' + pvText(b.tip, x, r) + '">' + pvParts(b.parts, x, r) + '</button>';
1116
+ return '<span class="wpv-tab' + (on ? ' on' : '') + '">' + tab + (b.close ? pvControl(b.close, x, r) : '') + '</span>';
1117
+ }).html;
1118
+ return '<div class="wpv-tabs"><div class="scroll-x wpv-tabs-strip" role="tablist"' + (b.label ? ' aria-label="' + pvText(b.label, sc, root) + '"' : '') + '>' + strip + '</div>' + pvControls(b.after, sc, root) + '</div>';
1119
+ },
1120
+
1121
+ /* 多层分栏:放得下时并排,放不下只画栈顶。观察器在同一模式内直接调整列宽。 */
1122
+ panes: function (b, sc, root) {
1123
+ const pp = function (x) { return pv(x, sc, root); };
1124
+ const panes = (b.panes || []).map(function (p) {
1125
+ return { key: pp(p.key) || '', title: pp(p.title) || '', min: Number(pp(p.min)) || 0,
1126
+ max: p.max != null ? Number(pp(p.max)) : null, fill: !!pp(p.fill), when: p.when, back: p.back, blocks: p.blocks };
1127
+ }).filter(function (p) { return p.when == null || pvOk(p.when, sc, root); });
1128
+ if (!panes.length) return '';
1129
+ const key = pdlUnitScope('panes', b.key || '');
1130
+ const fixed = root?.viewport;
1131
+ const tracks = panes.map(function (p) { return { min: p.min, max: p.max, fill: p.fill }; });
1132
+ const layout = paneLayout(tracks, fixed ? (typeof fixed === 'object' ? fixed : { width: fixed }) : paneRoom(key));
1133
+ const attrs = fixed ? '' : ' data-own="panes" data-panes="' + h(key) + '" data-pane-tracks="' + h(JSON.stringify(tracks)) + '"';
1134
+ const paneBody = function (p) { return '<div class="vw-pane"><div class="vw-pane-scroll scroll" data-pane="' + h((PV.region || 'main') + '|' + p.key + '|' + p.title) + '">' + pvBlocks(p.blocks, sc, root) + '</div></div>'; };
1135
+ if (layout.stack) {
1136
+ const path = panes.map(function (p, i) {
1137
+ const back = panes[i + 1]?.back;
1138
+ return { label: p.title, act: back?.act, data: back ? pvArgs(back.args, sc, root) : '' };
1139
+ });
1140
+ return '<div class="vw-panes vw-panes-stack"' + attrs + '>' + breadcrumbs(path) + paneBody(panes[panes.length - 1]) + '</div>';
1141
+ }
1142
+ return '<div class="vw-panes"' + attrs + ' style="grid-template-columns:' + layout.columns + '">' + panes.map(paneBody).join('') + '</div>';
1143
+ },
1144
+ /* 左右两栏:默认 = 列表 + 详情(窄屏收成下钻);aside = 主栏 + 侧栏 */
1145
+ split: function (b, sc, root) {
1146
+ if (b.variant === 'compare') return '<div class="vw-split-compare"><section>' + pvBlocks(b.left, sc, root) + '</section><section>' + pvBlocks(b.right, sc, root) + '</section></div>';
1147
+ if (b.variant === 'aside') {
1148
+ const pane = function (side, cls) { const follow = b.scroll && (b.follow === side || b.follow === 'both'), body = pvBlocks(b[side], sc, root); return '<div class="' + cls + (b.scroll ? ' scroll' : '') + (follow ? ' stick-end' : '') + '">' + (follow ? '<div>' + body + '</div>' : body) + '</div>'; };
1149
+ const target = b.picked && pv(b.picked, sc, root);
1150
+ return '<div class="pdl-two-pane"' + (b.scroll ? ' data-scroll="panes"' : '') +
1151
+ (typeof target === 'string' && target ? ' data-quote-target="' + h(target) + '"' : '') + '>' +
1152
+ pane('left', 'pdl-two-pane-main') + pane('right', 'pdl-two-pane-side') + '</div>';
1153
+ }
1154
+ /* 容器树:分栏(split)下面两栏(pane-l 列表 / pane-r 详情)。并排时选中的详情打开在 pane-r(列表的兄弟);收起时(窗口窄(VIEWPORT.narrow),或者画在窄的区域里(regionNarrow:没放大的工作台))
1155
+ 分栏变成“列表 → 详情”,详情打开在两栏共同的父容器 split 里。打开到哪个容器写在 data-into 上,返回的判断只看容器树,在画之前从触发点定(见 core.js 的 go、proj.js 的 navOpen) */
1156
+ const col = VIEWPORT.narrow || regionNarrow(PV.region), picked = b.picked != null && pvOk(b.picked, sc, root); /* picked 是条件(可以写 !、一组) */
1157
+ const value = picked && typeof b.picked === 'string' && /^[@$]/.test(b.picked) ? pv(b.picked, sc, root) : null;
1158
+ const detail = Array.isArray(value) ? (value.length === 1 ? value[0] : null) : value;
1159
+ const target = typeof detail === 'string' ? detail : detail?.id;
1160
+ /* 收起时选了一项:详情盖住了列表,详情的头先画(引擎的返回落在看得见的那一栏的头里) */
1161
+ /* 选中是状态(不是导航压栈)的分栏自己声明返回(back: { act, args }):只在收起并且选了一项时放进详情的返回槽,并排时没有 */
1162
+ const back = col && picked && b.back ? { act: b.back.act, data: pvArgs(b.back.args, sc, root), label: b.back.label ? pvText(b.back.label, sc, root) : PV.ctTitle } : null;
1163
+ let L, Rr; if (col && picked) { Rr = backIn('detail', back, function () { return pvBlocks(b.right, sc, root); }); L = pvBlocks(b.left, sc, root); } else { L = pvBlocks(b.left, sc, root); Rr = pvBlocks(b.right, sc, root); }
1164
+ /* 并排时两栏各自滚动(详情栏是自己的滚动容器,列表栏里的列表自己滚),滚详情不带着整页;收起时只有一栏,照常随页面滚 */
1165
+ return '<div class="vw-split" data-ct="split" data-into="' + (col ? 'split' : 'pane-r') + '" data-mode="' + (col ? 'collapsed' : 'side') + '"' + (picked ? ' data-picked' : '') + '><aside class="vw-split-l" data-ct="pane-l">' + L + '</aside><section class="vw-split-r' + (col ? '' : ' scroll') + '" data-ct="pane-r"' + (typeof target === 'string' && target ? ' data-quote-target="' + h(target) + '"' : '') + '>' + Rr + '</section></div>';
1166
+ },
1167
+ /* 决定后的一行结果:所有卡片模板共用。状态到色调的对应在这里(同意 ok、拒绝 danger,其余不着色);
1168
+ 详情收在下面,展开状态在数据里(S.folds[key]);行尾是调用方给的操作 */
1169
+ result: function (b, sc, root) {
1170
+ const st = pv(b.status, sc, root); if (!st) return '';
1171
+ const k = pv(b.key, sc, root), det = pvBlocks(b.blocks, sc, root), open = !!(det && S.folds[k]);
1172
+ return '<div class="vw-result" data-status="' + h(st) + '"><div class="vw-result-row">' + status(RESULT_TONE[st] || '', pv(b.label, sc, root)) +
1173
+ (det ? btn(tc(open ? 'common.collapse' : 'common.details'), { link: true, sm: true, act: 'fold', data: ' data-f="result" data-k="' + h(k) + '" aria-expanded="' + open + '"', html: h(tc(open ? 'common.collapse' : 'common.details')) + twisty(open) }) : '') +
1174
+ '<span class="grow"></span>' + pvControls(b.actions, sc, root) + '</div>' + (open ? '<div class="vw-result-d">' + det + '</div>' : '') + '</div>';
1175
+ },
1176
+ each: function (b, sc, root) {
1177
+ return pvRepeat(b, pvList(b.from, sc, root), root, function (it, r) { return pvBlocks(b.blocks, it, r); }).html;
1178
+ },
1179
+ /* 按视图模型给的顺序画一组有名字的块(可拖动排序的小节) */
1180
+ ordered: function (b, sc, root) {
1181
+ const order = pvList(b.order, sc, root);
1182
+ const collectsAnchors = !!PV.anchors;
1183
+ return pvRepeatRows(b, sc, root, order, function (id, r, context) {
1184
+ const block = b.blocks[id];
1185
+ if (!block) return '';
1186
+ const previous = PV.anchors;
1187
+ if (collectsAnchors && !previous) PV.anchors = []; /* A speculative row patch must also see newly visible headings. */
1188
+ const anchors = PV.anchors?.length, page = BACK.page, detail = BACK.detail, placed = BACK.placed, focus = PROJ_FOCUS;
1189
+ try {
1190
+ const html = pvBlocks([block], context, r);
1191
+ /* Register headings and consume the back button in their actual render order. */
1192
+ const reusable = anchors === PV.anchors?.length && page === BACK.page && detail === BACK.detail && placed === BACK.placed && focus === PROJ_FOCUS;
1193
+ return { html: html, reusable: reusable };
1194
+ } finally { PV.anchors = previous; }
1195
+ }, { raw: true, keyOf: function (id) { return typeof id === 'string' ? id : null; }, layout: [BACK.page, BACK.detail, BACK.placed] }).html;
1196
+ },
1197
+ steps: function (b, sc, root) {
1198
+ const xs = pvList(b.from, sc, root);
1199
+ if (b.variant === 'progress') {
1200
+ const rows = pvRepeatRows(b, sc, root, xs, function (s, r, context, position) {
1201
+ const i = s.i != null ? s.i : position;
1202
+ return chipHtml({ cls: 'ws-step' + (s.done ? ' done' : ''), pressed: !!s.on, lead: s.done ? icon('check', 12) : '<span class="num">' + (i + 1) + '</span>', label: h(s.label), act: b.act, data: b.act ? pvArgs(b.args, context, r) + ' data-i="' + i + '"' : '', attrs: b.act ? '' : ' role="listitem"' });
1203
+ }, { indexed: true });
1204
+ return '<div class="ws-steps" role="list">' + rows.html + '</div>';
1205
+ }
1206
+ if (b.variant === 'flow') { /* 流程图:区域(循环)里一排排节点,区域可以套区域;节点点了执行 act(带 i),on 选中、aff 受影响 */
1207
+ const data = pvArgs(b.args, sc, root);
1208
+ const node = function (n) { return chipHtml({ cls: 'lnode' + (n.state === 'aff' ? ' aff' : ''), pressed: n.state === 'on', act: b.act, data: data + ' data-i="' + n.i + '"', tip: h(n.tip || ''), icon: n.icon, label: h(n.label), tail: n.count ? '<span class="lnum num">' + n.count + '</span>' : '' }); };
1209
+ const arr = '<span class="larr" aria-hidden="true">' + icon('right', 12) + '</span>';
1210
+ const loop = function (l) { return '<div class="lloop' + (l.tone ? ' ' + l.tone : '') + '"><div class="lloop-h">' + icon(l.icon, 12) + h(l.title) + '</div>' + l.items.map(function (it) { return it.loop ? loop(it.loop) : '<div class="lrow">' + it.nodes.map(node).join(arr) + (it.back ? '<span class="lback" data-tip="' + h(it.back) + '">' + icon('refresh', 12) + '</span>' : '') + '</div>'; }).join('') + '</div>'; };
1211
+ return '<div class="lflow">' + pvRepeatRows(b, sc, root, xs, loop, { layout: data }).html + '</div>';
1212
+ }
1213
+ if (b.variant === 'checks') return '<ul class="pdl-checklist">' + pvRepeatRows(b, sc, root, xs, function (x) { return '<li' + (x.done ? ' class="done"' : '') + '>' + checkInd(x.done) + h(x.label) + '</li>'; }).html + '</ul>';
1214
+ return xs.length ? '<ol class="vw-steps">' + pvRepeatRows(b, sc, root, xs, function (x) { return '<li>' + h(x) + '</li>'; }).html + '</ol>' : '';
1215
+ },
1216
+ /* 小节目录:先占位,整个视图画完后由 pdlView 换成锚点列表(目录在前、小节在后,条目要等小节画出来才知道) */
1217
+ toc: function (b, sc, root) { return '<nav class="mtoc scroll"' + pvNote(b.note) + '>' + PV_TOC + '</nav>'; },
1218
+ disclosure: function (b, sc, root) {
1219
+ const body = pvBlocks(b.blocks, sc, root);
1220
+ /* 展开 / 收起一块:一个样子(组件库的 foldSection);里面什么都没有(optional 的列表没有项)就整个不画 */
1221
+ return body ? foldSection(pv(b.key, sc, root) || pvText(b.title, sc, root), pvAny(b.title, sc, root), body, { open: !!pv(b.open, sc, root), state: b.act ? !!pv(b.open, sc, root) : null, act: b.act, data: b.args ? pvArgs(b.args, sc, root) : '', sub: b.sub ? pvText(b.sub, sc, root) : '', note: b.note, count: pv(b.count, sc, root), trail: pvAny(b.trail, sc, root), actions: b.actions ? pvControls(b.actions, sc, root) : '', summary: pvBlocks(b.summary, sc, root) }) : '';
1222
+ },
1223
+ frame: function (b, sc, root) {
1224
+ const html = pv(b.html, sc, root), src = pv(b.src, sc, root);
1225
+ if (html != null || src != null) {
1226
+ const message = pv(b.message, sc, root), receive = b.on && pv(b.on.message, sc, root), key = pv(b.key, sc, root);
1227
+ const content = src != null ? ' data-island="frame:' + h(key != null ? key : src) + '" src="' + h(src) + '" sandbox="allow-scripts allow-forms allow-same-origin"' : (b.tall ? '' : ' data-frame-size') + ' sandbox="allow-scripts" srcdoc="' + h(html + '<script>(' + frameSizeScript.toString() + ')();<\/script>') + '"';
1228
+ return '<iframe class="vw-widget' + (b.tall ? ' tall' : '') + '"' + content + (b.name ? ' name="' + h(b.name) + '"' : '') + ' aria-label="' + pvText(b.title, sc, root) + '"' + (key != null ? ' data-frame-key="' + h(key) + '"' : '') + (receive ? ' data-frame-on-message="' + h(receive) + '"' : '') + (message != null ? ' data-frame-message="' + h(JSON.stringify(message)) + '"' : '') + '></iframe>';
1229
+ }
1230
+ if (b.plugin) return frame(pv(b.plugin, sc, root), pvText(b.what, sc, root), !!b.tall);
1231
+ const n = pvText(b.note, sc, root); return '<div class="frame">' + icon(pv(b.icon, sc, root), 28) + '<b>' + pvText(b.title, sc, root) + '</b>' + (n ? '<span>' + n + '</span>' : '') + '</div>';
1232
+ },
1233
+ empty: function (b, sc, root) { /* 空状态(组件库的 emptyState,只有一种):一句话 + ? + 一个操作;icon 是“选一项”的占位。加载中不是空状态(节点的 load,见 pvLoad) */
1234
+ const t = pvText(b.text, sc, root); if (!t) return '';
1235
+ return emptyState({ html: t, help: helpTip(pv(b.help || b.hint, sc, root)), acts: b.action ? pvControl(b.action, sc, root) : '', icon: b.icon });
1236
+ },
1237
+ /* 弹出层(组件库):贴着触发元素(锚定 --pop,见 engine/anchor.js);pos 只有方向 up、宽度 span(窗口网格占几列,按内容需要声明:候选这类少几列)、按内容定宽 fit,
1238
+ at = 相对锚点的偏移(选中文字:锚在消息上,偏到选区处)。不写坐标,放不下由浏览器翻到另一边 */
1239
+ pop: function (b, sc, root) {
1240
+ const v = Array.isArray(b.pos) ? b.pos.find(function (x) { return pvOk(x.when, sc, root); }) || {} : pv(b.pos, sc, root) || {}, p = { up: pv(v.up, sc, root), span: pv(v.span, sc, root), fit: pv(v.fit, sc, root) }, up = !!p.up, card = b.variant === 'card'; /* pos:位置的几种情况(第一个 when 成立的),每种写 up / span / fit */
1241
+ const vars = p.fit || !p.span ? '' : '--u-w:var(--span-' + (+p.span) + ')', page = pv(b.page, sc, root); /* page:弹窗现在是哪一页(换了一页 = 留在弹窗里,pick 不关) */
1242
+ return floatHtml({ cls: card ? 'member-card' : 'pop' + (up ? ' up' : '') + (p.fit ? ' fit' : ''), label: b.label != null ? pv(b.label, sc, root) : undefined,
1243
+ attrs: (card ? ' aria-modal="true"' : '') + (page ? ' data-page="' + h(page) + '"' : '') + (vars ? ' style="' + vars + '"' : ''), body: b.view ? pdlView(pv(b.view, sc, root)) : pvBlocks(b.blocks, sc, root), bare: card }); /* 两种角色都用同一个面;摘要卡不套滚动层,保留原有内容结构。 */
1244
+ },
1245
+ /* 对话页的外壳(组件库):顶部 → 浮在上面的条 → 消息流(唯一的滚动容器 #stream:流顶部的几行 + 消息)→ 右侧消息导航 → 底部(“到最新”、提示条、输入框)→ 浮层。
1246
+ #stream 的结构固定在这里:停在底部是组件库的 stick-end(反向排列,浏览器负责);“到最新”是一个普通控件(jump),放在哪由 PDL 决定,离底部远时才显示 */
1247
+ chatpage: function (b, sc, root) {
1248
+ /* 对话页的两个子容器:消息流(内容,不动)和输入框(容器,可以在对话页里上下换位置;它附属的上沿三栏、工具栏是它的子节点,跟着走) */
1249
+ const key = b.key || 'main.chat';
1250
+ const parts = { stream: '<div class="stream scroll stick-end" id="stream" data-okey="stream"><div class="stream-inner">' + pvBlocks(b.top, sc, root) + pvBlocks(b.body, sc, root) + '</div></div>' + pvBlocks(b.side, sc, root),
1251
+ composer: '<div class="composer-wrap" data-okey="composer"' + (S.editLayout ? ' data-edit="order"' : '') + '>' + pvBlocks(b.dock, sc, root) + '</div>' };
1252
+ return '<div class="chat" data-ocontainer="' + key + '" data-order="' + pdlOrderOf(key, ['stream', 'composer']).join(' ') + '">' + pvBlocks(b.head, sc, root) + pvBlocks(b.bar, sc, root) + pdlOrderOf(key, ['stream', 'composer']).map(function (k) { return parts[k]; }).join('') + '</div>';
1253
+ },
1254
+ /* 消息导航(右侧细刻度):一条消息一格;tone u 你 / c 成员 / s 其它,err 有出错、wait 等你回应;older:更早的还没加载 */
1255
+ ticks: function (b, sc, root) {
1256
+ const uRes = pdlUnits({
1257
+ id: pdlUnitScope('ticks', b.id || 'ticks'),
1258
+ items: pvList(b.from, sc, root),
1259
+ keyOf: function (x) { return x && x.mid != null ? String(x.mid) : null; },
1260
+ root: root,
1261
+ draw: function (raw, r) {
1262
+ const x = unitsItem(b, raw, r), w = whoInfo(x.from, x.source), tip = x.tip && typeof x.tip === 'object' ? x.tip.prefix + htmlText(mdHtml(x.tip.markdown.filter(Boolean).join('\n'))).slice(0, x.tip.max) : x.tip;
1263
+ return '<button type="button" class="stream-tick ' + x.tone + (x.err ? ' err' : '') + (x.wait ? ' wait' : '') + '" style="--c:' + h(w.color || 'var(--identity-fallback)') + '" data-act="msgJump" data-mid="' + h(x.mid) + '" data-tip="' + h(tip) + '" aria-label="' + h(x.label) + '"></button>';
1264
+ }
1265
+ });
1266
+ return ('<nav class="stream-ruler hide-sm" data-note="14" data-tip-group="inline" data-own="ticks" aria-label="' + h(tc('chatNav.label')) + '">') + (pv(b.older, sc, root) ? '<span class="stream-tick older" data-tip="' + h(tc('chatNav.older')) + '"></span>' : '') + uRes.html + '</nav>';
1267
+ },
1268
+ /* 开始的几种方式(空对话):图标 · 标题 · 一句话,点了做对应的事 */
1269
+ /* 标签编辑器:管理标签、整理未分类、对话设置、信号的标签都是它。项 { id, name, tint, n, on };
1270
+ pick { act, args }:标签可勾选(on 是选中);remove { act, label }:每个标签带 ×;add { id, act, args, tint, label, placeholder }:新建标签的输入(回车 / 框里的 + 提交) */
1271
+ tags: function (b, sc, root) {
1272
+ if (b.values) {
1273
+ return chipBox(pv(b.id, sc, root), pvList(b.values, sc, root), { kind: pv(b.kind, sc, root), k: pv(b.k, sc, root), ph: pvText(b.placeholder, sc, root), label: pvText(b.label, sc, root), empty: pvText(b.empty, sc, root), lock: pv(b.lock, sc, root) },
1274
+ function (values, draw, layout) { return pvRepeatRows(b, sc, root, values, draw, { raw: true, keyOf: function (v) { return typeof v === 'string' ? v : null; }, layout: layout }).parts; });
1275
+ }
1276
+ const xs = pvList(b.from, sc, root), pk = b.pick, rm = b.remove, ad = b.add;
1277
+ const chips = pvRepeatRows(b, sc, root, xs, function (x, r) {
1278
+ return pvControl({ type: 'chip', tint: x.tint != null ? '@tint' : null, label: '@name', faint: x.n != null ? '@n' : null, check: !!pk, pressed: pk ? '@on' : null,
1279
+ act: pk ? pk.act : null, args: pk ? Object.assign({ id: '@id' }, pk.args) : null, x: rm ? { act: rm.act, args: Object.assign({ id: '@id' }, rm.args), label: rm.label, icon: 'delete' } : null }, x, r);
1280
+ }).parts;
1281
+ const field = ad ? pvControl({ type: 'input', add: true, id: ad.id, placeholder: ad.placeholder || 't:tagManager.tagName', label: ad.label || 't:tagManager.newTag', go: ad.act, args: ad.args, goLabel: 't:common.create', tint: ad.tint }, sc, root) : '';
1282
+ return tagEditor({ chips: chips, empty: b.empty ? pvText(b.empty, sc, root) : '', field: field });
1283
+ },
1284
+ /* 对话列表:分组段 + 一个对话一行(数据形状见 rows.js threadRow / threadSections) */
1285
+ threads: function (b, sc, root) {
1286
+ const html = threadSections(pvList(b.from, sc, root), b, root, function (rows, part, movable) {
1287
+ return pvRepeatRows(b, sc, root, rows, function (row, r) { return threadRow(row, b.rename, r, movable); },
1288
+ { part: part, layout: movable, raw: true, keyOf: pvItemKey }).parts;
1289
+ });
1290
+ const note = pv(b.note, sc, root);
1291
+ return note ? '<div data-note="' + h(note) + '">' + html + '</div>' : html;
1292
+ },
1293
+ /* A menu group can declare one or several entries per source item. Keep that source in its own row scope. */
1294
+ opts: function (b, sc, root) {
1295
+ const list = pvList(b.from, sc, root);
1296
+ const one = function (it, data, r) {
1297
+ if (Array.isArray(it)) return it.map(function (part) { return one(part, data, r); }).join('');
1298
+ if (!pvOk(it.when, data, r)) return '';
1299
+ const x = pvArgsObj(it, data, r);
1300
+ if (x.lead) x.lead = pvArgsObj(Array.isArray(x.lead) ? x.lead.find(function (part) { return pvOk(part.when, data, r); }) : x.lead, data, r);
1301
+ if (x.args) x.args = pvArgsObj(x.args, data, r);
1302
+ if (x.disabled) x.act = '';
1303
+ return popEntry(x);
1304
+ };
1305
+ const group = function (it, r, context, index) {
1306
+ if (!it.from || !it.item) return one(it, context, r);
1307
+ return pvRepeatRows(it, context, r, pvList(it.from, context, r), function (row, rowRoot) {
1308
+ return one(it.item, row, rowRoot);
1309
+ }, { part: index, raw: true }).html;
1310
+ };
1311
+ /* 静态声明列出菜单分组,每个 from 才是要逐行更新的数据源。 */
1312
+ const declaredGroups = Array.isArray(b.from) && list.some(function (it) { return it.from && it.item; });
1313
+ const out = declaredGroups ? list.map(function (it, i) { return group(it, root, sc, i); }).join('') : pvRepeatRows(b, sc, root, list, group).html;
1314
+ const e = pv(b.empty, sc, root);
1315
+ return '<div class="pop-list">' + (out || (e ? popEntry({ note: e }) : '')) + '</div>';
1316
+ },
1317
+ view: function (b, sc, root) { const id = pv(b.id, sc, root); return 'data' in b ? pdlViewOf(id, pv(b.data, sc, root)) : pdlView(id); }, /* 显式数据只在子视图里成为根;未声明时沿用子视图自己的 VM,由 pdlView 统一收口 ctLeaf */
1318
+ /* 按渲染类型画(类型 = 容器.子类型,见 pdlTyped):插槽里取最长的已登记、可用的前缀的模板;模板可以带自己的视图模型(收到这一项的数据,返回它要画的);
1319
+ 一个都没有就画块自己的 blocks(宿主的默认画法)——插件不在时,内容照样按宿主的容器画出来 */
1320
+ typed: function (b, sc, root) {
1321
+ const it = pv(b.data, sc, root), node = pdlTyped(b.slot, pv(b.of, sc, root));
1322
+ if (!node) return pvBlocks(b.blocks, sc, root);
1323
+ const r = node.sources ? pdlSourceOf(node, it) : node.vm ? vmRead(node.vm, it) : it;
1324
+ return r ? pvBlocks(node.blocks, r, r) : node.vm && vmFailed(node.vm) ? viewState('error', { text: tc('common.viewError') }) : '';
1325
+ },
1326
+ component: function (b, sc, root) { const f = pdlComponent(b.use); return f ? f(pv(b.props, sc, root), sc, root) : ''; },
1327
+ /* 容器:给一组块套组件库里的一种角色(见 PDL_ROLES.box);里面什么都没有就不画。tone:带状态色调的容器(告警卡片);faint:被新的取代了(旧提议) */
1328
+ dialog: function (b, sc, root) { return dialogHtml({ key: pv(b.pop, sc, root), title: pv(b.title, sc, root), help: pv(b.help, sc, root), wide: pv(b.wide, sc, root), rows: pv(b.rows, sc, root), layout: pv(b.layout, sc, root), span: pv(b.span, sc, root), form: pv(b.form, sc, root), error: pv(b.error, sc, root), actions: pvControls(b.actions, sc, root), body: pvBlocks(b.blocks, sc, root), acts: pvBlocks(b.footer, sc, root) }); },
1329
+ box: function (b, sc, root) { const body = pvBlocks(b.blocks, sc, root), cls = BOX[b.variant || ''] + (pv(b.follow, sc, root) ? ' scroll stick-end' : ''); if (!body) return ''; const tone = pv(b.tone, sc, root), key = b.key ? pv(b.key, sc, root) : ''; return '<div class="' + cls + '"' + (key ? ' data-key="' + h(key) + '"' : '') + (tone ? ' data-tone="' + h(tone) + '"' : '') + (pv(b.faint, sc, root) ? ' data-faint' : '') + (b.open != null ? ' data-open="' + !!pv(b.open, sc, root) + '"' : '') + (pv(b.fill, sc, root) ? ' data-fill' : '') + pvNote(pv(b.note, sc, root)) + '>' + (/\bstick-end\b/.test(cls) ? '<div>' + body + '</div>' : body) + '</div>'; }, /* 停在底部的容器(stick-end)里只放一个子元素 */
1330
+ pre: function (b, sc, root) { /* 原样的文字(代码、日志、原始记录):一个样子;默认不在里面限高滚动——它在的页面 / 详情铺满容器,由页面滚动。
1331
+ rows:持续追加的文字(日志)在页面里只占几行,框里自己滚动,停在最新的一行(stick-end) */
1332
+ const t = pv(b.text, sc, root); if (!t) return '';
1333
+ const pre = '<pre class="vw-code mono">' + annotationHtml(h(t), pvList(b.annotations, sc, root)) + '</pre>';
1334
+ return b.rows ? '<div class="scroll stick-end vw-code-rows" style="--rows:' + (+b.rows) + '">' + pre + '</div>' : pre;
1335
+ },
1336
+ /* 正文(Markdown):一个样子。text 是 Markdown 文字;from 是一组段落;more 是接在后面的段落;clamp 收成几行 */
1337
+ markdown: function (b, sc, root) {
1338
+ const t = pv(b.text, sc, root), paras = pvList(b.from, sc, root).concat(pvList(b.more, sc, root));
1339
+ if (!t && !paras.length) return '';
1340
+ return '<div class="prose vw-md' + (pv(b.clamp, sc, root) ? ' clamp' : '') + '">' + annotationHtml((t ? mdLite(String(t)) : '') + paras.map(function (x) { return '<p>' + h(x) + '</p>'; }).join(''), pvList(b.annotations, sc, root), true) + '</div>';
1341
+ },
1342
+
1343
+ /* 消息流:from 是消息列表,每一项按 kind 分派到 keyed 插槽(默认 chat.node)的节点模板 */
1344
+ /* 折叠(同一个组件,两种样式):bottom 只留开头、底部渐隐、开关是居中的单个 V / ^;middle 留开头和结尾、中间收起、两侧渐隐、开关是右侧的双箭头。
1345
+ 开关由测量步骤按真实高度决定要不要出现;展开状态写进 HTML(data-open),所以消息节点缓存会跟着重画 */
1346
+ fold: function (b, sc, root) {
1347
+ const one = (b.blocks || []).length === 1 ? b.blocks[0] : null, list = one && (one.type === 'list' || one.type === 'each') ? one : null; /* 包着一个列表(list / each):单位是项,项数来自数据 */
1348
+ const body = one && one.type === 'each' ? pvRepeat(one, pvList(one.from, sc, root), root, function (it, r) {
1349
+ return '<div class="fold-item">' + pvBlocks(one.blocks, it, r) + '</div>';
1350
+ }, { part: 'fold' }).html : pvBlocks(b.blocks, sc, root); /* 折叠沿用已有的逐项测量外框 */
1351
+ if (!body) return '';
1352
+ const more = b.more && pvOk(b.more.when, sc, root) ? { act: pv(b.more.act, sc, root), args: pvArgsObj(b.more.args, sc, root) } : null; /* 数据说还有更多:开关写“查看更多”,展开时读 */
1353
+ return foldBox(pv(b.shape, sc, root) || 'bottom', pv(b.key, sc, root), body, { height: b.height, items: list ? pvList(list.from, sc, root).length : null, more: more });
1354
+ },
1355
+ stream: function (b, sc, root) {
1356
+ const id = b.id || 'chat', slot = b.slot || 'chat.node';
1357
+ const uRes = pdlUnits({
1358
+ id: pdlUnitScope('stream', id),
1359
+ items: pvList(b.from, sc, root),
1360
+ keyOf: streamUnitKey,
1361
+ root: root,
1362
+ progressive: true,
1363
+ draw: function (raw, r) {
1364
+ const it = unitsItem(b, raw, r), t = pdlTyped(slot, it.kind);
1365
+ return t ? pvNode(t, it, r) : '';
1366
+ }
1367
+ });
1368
+ return '<div class="stream-list" data-stream="' + h(id) + '" data-own="stream">' + uRes.html + '</div>';
1369
+ },
1370
+ /* 消息正文:内容本身(来自消息的富文本),不是界面标记;clamp 时收成几行 */
1371
+ content: function (b, sc, root) {
1372
+ const value = pv(b.html, sc, root); if (value == null) return ''; const html = annotationHtml(value, pvList(b.annotations, sc, root)); if (b.raw) return html;
1373
+ const f = pvDeep(b.fold, root, sc); /* 折叠是组件库的 foldBox:长回复用 middle,转来的消息用 bottom */
1374
+ if (f && f.shape === 'middle') return '<div' + pvNote(pv(b.note, sc, root)) + '>' + foldBox('middle', f.key, html) + '</div>';
1375
+ if (f) return foldBox('bottom', f.key, html, { cls: 'msg-body' });
1376
+ return '<div class="msg-body' + (pv(b.clamp, sc, root) ? ' clamp' : '') + '"' + pvNote(pv(b.note, sc, root)) + '>' + html + '</div>';
1377
+ },
1378
+ /* 投递 / 来源提示行(正文里的独立一行):直接复用 msgVia,收窄宽度并留出与段落一致的上下间距 */
1379
+ via: function (b, sc, root) {
1380
+ const v = pvDeep(b.via, root, sc);
1381
+ return v ? '<div class="msg-via-block">' + msgVia(v) + '</div>' : '';
1382
+ },
1383
+ search: function (b, sc, root) { return search(b.id, pv(b.placeholder, sc, root), pv(b.value, sc, root), b.input, 'vw-search'); },
1384
+ /* 一组选项:radio = 单选(对话区);opt = 单选(选一个再提交);check = 勾选 */
1385
+ /* 一组选项:默认单选(声明了 value 时选中项来自数据,否则记在本地草稿);multi = 多选(一项一个勾选);选项带缩略图(thumb)时画成缩略图单选(外观) */
1386
+ choices: function (b, sc, root) {
1387
+ const xs = pvList(b.from, sc, root);
1388
+ const thumbs = xs.length > 0 && xs.every(function (x) { return b.item && 'thumb' in b.item ? pvDeep(b.item.thumb, root, x) : x && x.thumb; });
1389
+ const rows = pvRepeatRows(b, sc, root, xs, function (x, r, context) {
1390
+ const ro = pvOk(b.ro ?? false, context, r);
1391
+ if (thumbs) return modeThumb(x, b.act, b.args ? pvArgsObj(b.args, context, r) : null, ro);
1392
+ if (b.variant === 'multi') return checkBox(!!x.on, h(x.label) + (x.sub ? ' <span class="faint">' + h(x.sub) + '</span>' : ''), b.act, ' data-v="' + h(x.v) + '"' + pvArgs(b.args, context, r), false, ro);
1393
+ const object = x && typeof x === 'object';
1394
+ const g = pv(b.group, context, r), v = object ? x.v : x, label = object ? x.label : x, sub = object ? x.sub : '';
1395
+ return b.value != null ? opt(g, v, pv(b.value, context, r), label, sub, { plain: true, act: b.act, data: b.act ? pvArgs(b.args, context, r) : '', ro: ro }) : pdlRadioField(g, v, label, sub, ro);
1396
+ }, { layout: thumbs });
1397
+ const container = thumbs ? '<div class="thumbs" role="radiogroup">' : b.variant === 'multi' ? '<div class="group vw-pad8">' : '<div class="ws-opts" role="radiogroup">';
1398
+ return container + rows.html + '</div>';
1399
+
1400
+ }
1401
+ });
1402
+ /* 一个节点(视图或块)在某个读取状态下的样子:文字是节点声明的;只有节点自己声明了 retry 才有重试(没有默认的原位重试:出错的说明里写着重新打开或刷新) */
1403
+ const LOAD_SHAPE = { cards: 'card', component: 'card' };
1404
+ function pvLoad(b, st, sc, root) {
1405
+ const r = b.retry ? { act: pv(b.retry.act, sc, root), data: pvArgs(b.retry.args, sc, root) } : null;
1406
+ return viewState(st, { text: pvText(b[st] || (st === 'empty' ? b.empty : ''), sc, root), retry: r, shape: LOAD_SHAPE[b.type] });
1407
+ }
1408
+ /* 节点:按模板把字段绑到消息卡片组件(msgFrame)上;正文和卡片下方是块 */
1409
+ function pvNode(t, sc, root) {
1410
+ if (PV.ro) { PV.inert++; try { return pvNodeIn(Object.assign({}, t, { acts: null }), sc, root); } finally { PV.inert--; } }
1411
+ return pvNodeIn(t, sc, root);
1412
+ }
1413
+ function pvNodeIn(t, sc, root) {
1414
+ const P = function (x) { return pv(x, sc, root); };
1415
+ const meta = t.meta && pvOk(t.meta.when, sc, root) ? '<div class="msg-meta"' + pvNote(P(t.meta.note)) + '>' + '<span class="msg-meta-start">' + pvJoin(t.meta.parts, sc, root, '<span class="sep">·</span>') + '</span>' + (t.meta.end ? '<span class="grow"></span><span class="msg-meta-end">' + pvJoin(t.meta.end, sc, root, '') + '</span>' : '') + '</div>' : '';
1416
+ const side = t.frame === 'msg' && whoInfo(P(t.from) || P(t.who) || 'system').side || 'left'; /* 左右只由发送者推出:你在右,其余在左;表面跟着左右(卡片例外,由模板的 card 决定) */
1417
+ const markdown = t.markdown && pvOk(t.markdownWhen, sc, root) ? pvDeep(t.markdown, root, sc).join('\n') : null;
1418
+ const actsCtx = t.acts ? Object.assign({}, P(t.acts.ctx)) : {}; if (t.acts && t.acts.items) actsCtx.menu = menuLive(pvMenu(t.acts.items, actsCtx, root));
1419
+ const actsTools = t.acts ? pdlTools(t.acts.slot, actsCtx, true) : '';
1420
+ return msgFrame({ frame: t.frame, side: side, surface: t.card ? 'none' : side === 'right' ? 'bubble' : 'bar', running: !!t.running, nested: P(t.nested), mid: sc.mid, text: P(t.text), who: P(t.who), time: P(t.time), receivedAt: P(t.receivedAt), badges: P(t.badges), via: P(t.via), quote: t.quote && pvOk(t.quote.when, sc, root) ? pvDeep(t.quote, root, sc) : null,
1421
+ icon: P(t.icon), title: P(t.title), tags: Array.isArray(t.tags) ? t.tags.filter(function (tag) { return pvOk(tag.when, sc, root); }).map(function (tag) { return { icon: P(tag.icon), text: P(tag.text), parts: tag.parts ? pvPart(tag.parts, sc, root) : null }; }) : P(t.tags), chips: (P(t.chips) || []).map(function (xs) { return t.chip ? xs.map(function (x) { return pvArgsObj(t.chip, x, root); }) : xs; }), delivery: pvDeep(t.delivery, root, sc), recv: P(t.recv), from: P(t.from), source: P(t.source), jump: P(t.jump), label: pvAnnot(t.label, sc, root), emph: sc.emph, picking: sc.picking, picked: sc.picked, notes: sc.notes,
1422
+ body: (markdown != null ? mdHtml(markdown) : '') + pvBlocks(t.body, sc, root), below: pvBlocks(t.pre, sc, root) + meta + pvBlocks(t.below, sc, root),
1423
+ acts: t.acts && (actsTools || S.editLayout) ? '<div class="stream-message-actions ' + (side === 'right' ? 'mine' : 'theirs') + '" role="toolbar" aria-label="' + h(tc('message.actions')) + '" data-slot-page="' + t.acts.slot + '" data-context-actions' + pvNote(sc.notes && sc.notes.acts) + '>' + actsTools + '</div>' : '' });
1424
+ }
1425
+ /* 提示胶囊(tone / text / tip / 可关掉);n > 1 时带一个“第几条 / 共几条”的小标记 */
1426
+ function pvSingleItem(x, i, n) {
1427
+ const body = status(x.tone || '', x.text || ''); /* 带 act 的提示:文字就是去处(点了打开),× 仍只关这一条 */
1428
+ return '<div class="cnote" data-i="' + (i || 0) + '" data-tip="' + h((x.text || '') + (x.tip ? ' · ' + x.tip : '')) + '">' + (x.act ? '<button type="button" class="cnote-go"' + actAttrs(x.act, x.args) + '>' + body + '</button>' : body) + (n > 1 ? qty((i + 1) + '/' + n) : '') + (x.dismiss ? btn(tc('notice.dismiss'), { iconOnly: true, icon: 'close', size: 'xs', act: x.dismiss, data: argAttrs(x.dismissArgs) }) : '') + '</div>'; /* × 只关这一条。 */
1429
+ }
1430
+ /* 一组提示:同一时刻只露一条;多条时按节拍轮换(通用轮换 rotHtml),悬停暂停;关掉一条后下一条接上 */
1431
+ function noticeList(items, key, attrs) {
1432
+ if (!items.length) return '';
1433
+ return rotHtml('div', 'cnotes', items.map(function (x, i) { return pvSingleItem(x, i, items.length); }), ' data-island="cnotes" data-flip' + (attrs || ''));
1434
+ }
1435
+ /* chain 插槽认领后的卡片:数据描述 { icon, title, chips, line },字段用 {name} 引用 extract 出来的值 */
1436
+ function pvClaim(x, ctx) {
1437
+ const v = {}; Object.keys(x.extract || {}).forEach(function (k) {
1438
+ const e = x.extract[k]; let val = null;
1439
+ if (e.from === 'tool') { const m = new RegExp(e.re).exec(ctx.tool || ''); val = m ? m[1] : null; }
1440
+ else { try { const j = JSON.parse(ctx.result); val = j[e.key]; } catch (err) { val = null; } }
1441
+ if (e.map && Object.prototype.hasOwnProperty.call(e.map, String(val))) val = e.map[String(val)];
1442
+ if ((val == null || val === '') && e.empty != null) val = e.empty;
1443
+ v[k] = val == null ? '' : String(val);
1444
+ });
1445
+ const f = function (t) { return h(String(t || '').replace(/\{(\w+)\}/g, function (_, k) { return v[k] || ''; })); };
1446
+ return '<div class="vw-claim">' + (x.icon ? icon(x.icon, 14) : '') + '<b>' + f(x.title) + '</b>' + (x.chips || []).map(f).filter(Boolean).map(function (c) { return chipHtml({ label: c }); }).join('') + (x.line ? '<span class="faint">' + f(x.line) + '</span>' : '') + '<span class="grow"></span><span class="faint vw-12">' + h(x.by || '') + '</span></div>';
1447
+ }
1448
+ /* 插槽认领卡片原件的 PDL 入口:未被认领时保留原样输出。 */
1449
+ PDL_COMPONENTS.claim = function (p, sc, root) { const data = pvDeep(p.data, root, sc), claimed = pdlChain(p.slot, data); return claimed ? pvClaim(claimed, data) : monoBlock(data[p.fallback]); };
1450
+ PDL_COMPONENTS.claim.catalog = { g: 'message', props: { slot: 'chat.tool.result', data: { lit: { tool: 'bash', result: 'ok' } }, fallback: 'result' } };
1451
+ /* 视图在读取状态下:只画视图里的标题行(页头、详情头、面板顶栏,它们的操作照常可用),下面是组件库的状态;过期时状态在上、内容照常 */
1452
+ function pvViewLoad(v, st, root) {
1453
+ const state = pvLoad(v, st, root, root);
1454
+ if (st === 'stale') return state + pvBlocks(v.blocks, root, root);
1455
+ /* 读取中照常画的:页头,和切换子视图的分段(换子视图时只有下面的内容换成骨架,分段本身不重画) */
1456
+ const bs = (v.blocks || []).filter(function (b) { return pvOk(b.when, root, root) && (b.type === 'head' || b.type === 'page' || (b.type === 'toolbar' && (b.items || []).some(function (c) { return c.type === 'seg'; }))); });
1457
+ if (bs[0] && bs[0].type === 'page') return '<div class="page">' + pvHead(bs[0], root, root) + state + '</div>'; /* 整页容器:状态放在页里 */
1458
+ return bs.map(function (b) { return b.type === 'toolbar' ? pvBlocks([b], root, root) : pvHead(b, root, root); }).join('') + state;
1459
+ }
1460
+
1461
+ /* 小节目录跟着滚动标出当前小节(toc 块自己的行为):目录的每一项指向同一视图里一个带 id 的小节(data-id);
1462
+ 装着目录的滚动容器滚动时,最后一个越过容器上沿(留 20 个单位的余量)的小节是当前项(aria-current),一个都没越过时是第一项。只改属性,不重画 */
1463
+ document.addEventListener('scroll', function (e) {
1464
+ const sc = e.target, toc = sc.querySelector && sc.querySelector('.mtoc'); if (!toc) return;
1465
+ const items = Array.prototype.slice.call(toc.querySelectorAll('[data-id]')), top = sc.getBoundingClientRect().top, gap = 20 * (parseFloat(getComputedStyle(document.documentElement).getPropertyValue('--unit')) || 4);
1466
+ let cur = null; items.forEach(function (b, i) { const s = document.getElementById(b.dataset.id); if (s && (i === 0 || s.getBoundingClientRect().top - top < gap)) cur = b; });
1467
+ items.forEach(function (b) { if (b === cur) b.setAttribute('aria-current', 'true'); else b.removeAttribute('aria-current'); });
1468
+ }, true);
1469
+ /* 开进一个容器的东西:frame 节点(有视图画视图,只有地址画框)、页面;盖住容器时最前面是通用返回 */
1470
+ function pvOpened(l, key, cover) {
1471
+ const f = String(l.f), fr = navNodeOf(l), fk = fr ? f.slice(5) : null;
1472
+ const body = fr ? pdlView(fk) : PAGES[f] ? PAGES[f]() : '';
1473
+ return '<div class="opened" data-opened="' + h(key) + '">' + (cover ? engineBack({ act: 'back', data: ' data-c="' + h(key) + '"' }) : '') + body + '</div>';
1474
+ }
1475
+ Object.assign(PV_DRAW, { node: pvNode, control: pvControl, load: pvLoad, toc: pvWithToc, viewLoad: pvViewLoad, state: viewState, opened: pvOpened });
1476
+ /* 铺满页的浮动胶囊(纯画布的 .back-head,以及声明为 variant: head 的工具条 .chat-head):
1477
+ 复用组件库唯一的拖动机制(EDGE_DRAG,整块可拖,轻点照常触发按钮);偏移按视图记在本地存储里,容器缩放时夹在可视区内 */
1478
+ const FULL_FLOAT_SEL = '.vw-page-full.page > .chat-head, :is(.cover-in, .main-col, .main, .layer:not(.layer-covered)):not(.layer-covered):has(> .vw-page-full.page, > .page > .vw-page-full.page) > .back-head';
1479
+ const FULL_FLOAT_POS = store.get('fullFloatPos', {}) || {};
1480
+ function fullFloatKey(el) {
1481
+ const vw = el.closest('.vw-page-full') || (el.parentElement && el.parentElement.querySelector(':scope > .vw-page-full, :scope > .page > .vw-page-full'));
1482
+ return vw && vw.dataset.view ? vw.dataset.view : '';
1483
+ }
1484
+ function clampFullFloat(el, p) {
1485
+ const host = el.offsetParent; if (!host) return p;
1486
+ const hr = host.getBoundingClientRect(), r = el.getBoundingClientRect();
1487
+ if (!hr.width || !hr.height) return p;
1488
+ const cx = parseFloat(el.style.getPropertyValue('--drag-x')) || 0, cy = parseFloat(el.style.getPropertyValue('--drag-y')) || 0;
1489
+ const baseL = r.left - cx - hr.left, baseT = r.top - cy - hr.top, pad = parseFloat(getComputedStyle(document.documentElement).getPropertyValue('--sp-xs')) || 4;
1490
+ const minX = pad - baseL, maxX = Math.max(minX, hr.width - r.width - pad - baseL);
1491
+ const minY = pad - baseT, maxY = Math.max(minY, hr.height - r.height - pad - baseT);
1492
+ return { x: Math.round(Math.min(maxX, Math.max(minX, p.x))), y: Math.round(Math.min(maxY, Math.max(minY, p.y))) };
1493
+ }
1494
+ EDGE_DRAG.push({
1495
+ find: function (t) { const el = t && t.closest && t.closest(FULL_FLOAT_SEL); return el ? { el: el, whole: true } : null; },
1496
+ start: function (el, e0) {
1497
+ const k = fullFloatKey(el), cur = clampFullFloat(el, FULL_FLOAT_POS[k] || { x: 0, y: 0 }), sx = e0.clientX, sy = e0.clientY;
1498
+ let last = cur;
1499
+ return {
1500
+ move: function (e) { last = clampFullFloat(el, { x: cur.x + e.clientX - sx, y: cur.y + e.clientY - sy }); dragOffset(el, last); },
1501
+ end: function () { if (k) { FULL_FLOAT_POS[k] = last; store.set('fullFloatPos', FULL_FLOAT_POS); } }
1502
+ };
1503
+ }
1504
+ });
1505
+ function restoreFullFloatPos() {
1506
+ document.querySelectorAll(FULL_FLOAT_SEL).forEach(function (el) {
1507
+ const k = fullFloatKey(el), p = k && FULL_FLOAT_POS[k];
1508
+ if (p) dragOffset(el, clampFullFloat(el, p));
1509
+ });
1510
+ }
1511
+ onRender(restoreFullFloatPos);
1512
+ window.addEventListener('resize', restoreFullFloatPos);