hostlet 0.0.0-stage → 0.1.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +233 -2
- package/bin/hostlet.js +61 -0
- package/console/app/api.js +1223 -0
- package/console/app/boot.js +165 -0
- package/console/app/cards.js +222 -0
- package/console/app/compose-quote.js +127 -0
- package/console/app/config-form.js +727 -0
- package/console/app/document-drafts.js +62 -0
- package/console/app/document-tools.mjs +67 -0
- package/console/app/documents.js +106 -0
- package/console/app/pages.js +6483 -0
- package/console/app/plugins.js +509 -0
- package/console/app/preview-tools.js +172 -0
- package/console/app/reference-labels.js +118 -0
- package/console/app/selection.js +372 -0
- package/console/app/store.js +57 -0
- package/console/app/text-anchor.js +26 -0
- package/console/app/topic-local.js +322 -0
- package/console/app/topic-nav.js +414 -0
- package/console/app/topic-status.js +109 -0
- package/console/app/views.js +43 -0
- package/console/apple-touch-icon.png +0 -0
- package/console/avatars/agy.svg +34 -0
- package/console/avatars/alhena.svg +36 -0
- package/console/avatars/castor.svg +38 -0
- package/console/avatars/claude.svg +34 -0
- package/console/avatars/codex.svg +34 -0
- package/console/avatars/devin.svg +34 -0
- package/console/avatars/echo.svg +34 -0
- package/console/avatars/kimi.svg +33 -0
- package/console/avatars/opencode.svg +33 -0
- package/console/avatars/pinion.svg +34 -0
- package/console/avatars/sprocket.svg +34 -0
- package/console/avatars/vela.svg +44 -0
- package/console/avatars/wasat.svg +38 -0
- package/console/clients/agy.svg +1 -0
- package/console/clients/claude.svg +1 -0
- package/console/clients/codex.svg +1 -0
- package/console/clients/devin.svg +1 -0
- package/console/clients/kimi.svg +1 -0
- package/console/clients/opencode.svg +1 -0
- package/console/favicon.ico +0 -0
- package/console/favicon.svg +16 -0
- package/console/index.html +99 -0
- package/console/pdl/engine/README.md +13 -0
- package/console/pdl/engine/anchor.js +195 -0
- package/console/pdl/engine/core.js +1340 -0
- package/console/pdl/engine/frame.js +1252 -0
- package/console/pdl/engine/i18n.js +67 -0
- package/console/pdl/engine/pdl-check.js +102 -0
- package/console/pdl/engine/pdl-doc.js +353 -0
- package/console/pdl/engine/pdl-view.js +280 -0
- package/console/pdl/engine/pdl.js +1064 -0
- package/console/pdl/engine/platform.js +18 -0
- package/console/pdl/engine/proj.js +279 -0
- package/console/pdl/engine/theme.js +176 -0
- package/console/pdl/engine/tree.js +171 -0
- package/console/pdl/engine/units.js +546 -0
- package/console/pdl/library/README.md +28 -0
- package/console/pdl/library/blocks.js +1512 -0
- package/console/pdl/library/buttons.js +86 -0
- package/console/pdl/library/capsules.js +130 -0
- package/console/pdl/library/charts.js +287 -0
- package/console/pdl/library/code.js +98 -0
- package/console/pdl/library/css/base.css +12 -0
- package/console/pdl/library/css/blocks.css +98 -0
- package/console/pdl/library/css/capsules.css +42 -0
- package/console/pdl/library/css/catalog-page.css +24 -0
- package/console/pdl/library/css/chat.css +100 -0
- package/console/pdl/library/css/composer-top.css +145 -0
- package/console/pdl/library/css/controls.css +195 -0
- package/console/pdl/library/css/drag.css +29 -0
- package/console/pdl/library/css/edit-layout.css +93 -0
- package/console/pdl/library/css/floating-window.css +30 -0
- package/console/pdl/library/css/hover.css +50 -0
- package/console/pdl/library/css/label-search.css +37 -0
- package/console/pdl/library/css/layers.css +43 -0
- package/console/pdl/library/css/library-parts.css +33 -0
- package/console/pdl/library/css/library.css +117 -0
- package/console/pdl/library/css/member-select.css +34 -0
- package/console/pdl/library/css/message.css +72 -0
- package/console/pdl/library/css/page.css +104 -0
- package/console/pdl/library/css/parts.css +338 -0
- package/console/pdl/library/css/responsive.css +40 -0
- package/console/pdl/library/css/roles.css +28 -0
- package/console/pdl/library/css/rows.css +231 -0
- package/console/pdl/library/css/settings-rows.css +37 -0
- package/console/pdl/library/css/shell.css +59 -0
- package/console/pdl/library/css/stream.css +296 -0
- package/console/pdl/library/css/theme-calculator.css +18 -0
- package/console/pdl/library/css/thumb-choice.css +69 -0
- package/console/pdl/library/css/tweaks.css +16 -0
- package/console/pdl/library/css/widgets.css +211 -0
- package/console/pdl/library/css/workbench.css +59 -0
- package/console/pdl/library/feedback.js +83 -0
- package/console/pdl/library/floating-window.mjs +100 -0
- package/console/pdl/library/fold.js +238 -0
- package/console/pdl/library/format.js +53 -0
- package/console/pdl/library/frames.js +123 -0
- package/console/pdl/library/icons.js +165 -0
- package/console/pdl/library/identity.js +149 -0
- package/console/pdl/library/inputs.js +801 -0
- package/console/pdl/library/label-search.js +214 -0
- package/console/pdl/library/markdown-text.js +115 -0
- package/console/pdl/library/markdown.js +150 -0
- package/console/pdl/library/media-viewer.js +293 -0
- package/console/pdl/library/member-select.mjs +32 -0
- package/console/pdl/library/message.js +105 -0
- package/console/pdl/library/motion.js +56 -0
- package/console/pdl/library/overlays.js +165 -0
- package/console/pdl/library/page.js +142 -0
- package/console/pdl/library/plugin-form.js +154 -0
- package/console/pdl/library/registry.js +198 -0
- package/console/pdl/library/rows.js +523 -0
- package/console/pdl/library/shell.js +151 -0
- package/console/pdl/library/stream.js +58 -0
- package/console/pdl/library/tabs.js +259 -0
- package/console/pdl/library/theme-calculator.js +300 -0
- package/console/pdl/library/widgets.js +114 -0
- package/console/pdl/load-order.json +74 -0
- package/console/pdl/platform/README.md +3 -0
- package/console/pdl/platform/rich-markdown.mjs +17 -0
- package/console/pdl/platform/web-links.js +26 -0
- package/console/pdl/platform/web.js +80 -0
- package/console/sdk-browser/mentions.d.mts +16 -0
- package/console/sdk-browser/mentions.mjs +84 -0
- package/console/theme/assets.js +21 -0
- package/console/theme/theme.json +9417 -0
- package/console/theme/tokens.json +444 -0
- package/dist/core/a2a.d.ts +288 -0
- package/dist/core/a2a.js +2197 -0
- package/dist/core/address.d.ts +34 -0
- package/dist/core/address.js +33 -0
- package/dist/core/approval-inputs.d.ts +17 -0
- package/dist/core/approval-inputs.js +70 -0
- package/dist/core/archive.d.ts +19 -0
- package/dist/core/archive.js +135 -0
- package/dist/core/attachments.d.ts +17 -0
- package/dist/core/attachments.js +143 -0
- package/dist/core/blocked-handoffs.d.ts +132 -0
- package/dist/core/blocked-handoffs.js +349 -0
- package/dist/core/config-schema.d.ts +124 -0
- package/dist/core/config-schema.js +192 -0
- package/dist/core/config.d.ts +117 -0
- package/dist/core/config.js +638 -0
- package/dist/core/disk-usage.d.ts +26 -0
- package/dist/core/disk-usage.js +83 -0
- package/dist/core/documents.d.ts +9 -0
- package/dist/core/documents.js +48 -0
- package/dist/core/entry.d.ts +316 -0
- package/dist/core/entry.js +711 -0
- package/dist/core/home.d.ts +76 -0
- package/dist/core/home.js +449 -0
- package/dist/core/i18n.d.ts +36 -0
- package/dist/core/i18n.js +458 -0
- package/dist/core/instances.d.ts +224 -0
- package/dist/core/instances.js +1272 -0
- package/dist/core/members.d.ts +190 -0
- package/dist/core/members.js +358 -0
- package/dist/core/mentions.d.ts +12 -0
- package/dist/core/mentions.js +49 -0
- package/dist/core/messages.d.ts +876 -0
- package/dist/core/messages.js +916 -0
- package/dist/core/notices.d.ts +88 -0
- package/dist/core/notices.js +54 -0
- package/dist/core/ops.d.ts +117 -0
- package/dist/core/ops.js +146 -0
- package/dist/core/package.d.ts +2 -0
- package/dist/core/package.js +14 -0
- package/dist/core/parts.d.ts +25 -0
- package/dist/core/parts.js +119 -0
- package/dist/core/plugins/catalog.d.ts +14 -0
- package/dist/core/plugins/catalog.js +54 -0
- package/dist/core/plugins/external.d.ts +7 -0
- package/dist/core/plugins/external.js +921 -0
- package/dist/core/plugins/index.d.ts +5 -0
- package/dist/core/plugins/index.js +51 -0
- package/dist/core/plugins/npm.d.ts +12 -0
- package/dist/core/plugins/npm.js +99 -0
- package/dist/core/plugins/plugin-manifest.d.ts +12 -0
- package/dist/core/plugins/plugin-manifest.js +231 -0
- package/dist/core/push.d.ts +22 -0
- package/dist/core/push.js +63 -0
- package/dist/core/resource.d.ts +77 -0
- package/dist/core/resource.js +48 -0
- package/dist/core/spawn.d.ts +12 -0
- package/dist/core/spawn.js +30 -0
- package/dist/core/storage-inventory.d.ts +118 -0
- package/dist/core/storage-inventory.js +279 -0
- package/dist/core/storage.d.ts +45 -0
- package/dist/core/storage.js +602 -0
- package/dist/core/store.d.ts +15 -0
- package/dist/core/store.js +33 -0
- package/dist/core/topic-index.d.ts +19 -0
- package/dist/core/topic-index.js +70 -0
- package/dist/core/topic-ops.d.ts +139 -0
- package/dist/core/topic-ops.js +507 -0
- package/dist/core/topic-status.d.ts +32 -0
- package/dist/core/topic-status.js +105 -0
- package/dist/core/topics.d.ts +327 -0
- package/dist/core/topics.js +786 -0
- package/dist/core/turn-clients.d.ts +1 -0
- package/dist/core/turn-clients.js +5 -0
- package/dist/core/types.d.ts +2866 -0
- package/dist/core/types.js +166 -0
- package/dist/core/util.d.ts +10 -0
- package/dist/core/util.js +47 -0
- package/dist/main.d.ts +12 -0
- package/dist/main.js +82 -0
- package/dist/plugins/adapter-acp/index.d.ts +3 -0
- package/dist/plugins/adapter-acp/index.js +57 -0
- package/dist/plugins/adapter-acp/plugin.yaml +100 -0
- package/dist/plugins/adapter-agy/command.d.ts +9 -0
- package/dist/plugins/adapter-agy/command.js +34 -0
- package/dist/plugins/adapter-agy/index.d.ts +5 -0
- package/dist/plugins/adapter-agy/index.js +65 -0
- package/dist/plugins/adapter-agy/quota.d.ts +2 -0
- package/dist/plugins/adapter-agy/quota.js +155 -0
- package/dist/plugins/adapter-agy/terminal.d.ts +6 -0
- package/dist/plugins/adapter-agy/terminal.js +132 -0
- package/dist/plugins/adapter-agy/version.d.ts +9 -0
- package/dist/plugins/adapter-agy/version.js +17 -0
- package/dist/plugins/adapter-claude/index.d.ts +43 -0
- package/dist/plugins/adapter-claude/index.js +412 -0
- package/dist/plugins/adapter-claude/quota.d.ts +14 -0
- package/dist/plugins/adapter-claude/quota.js +103 -0
- package/dist/plugins/adapter-codex/index.d.ts +4 -0
- package/dist/plugins/adapter-codex/index.js +688 -0
- package/dist/plugins/adapter-codex/responses-model.d.ts +9 -0
- package/dist/plugins/adapter-codex/responses-model.js +82 -0
- package/dist/plugins/adapter-kimi/index.d.ts +4 -0
- package/dist/plugins/adapter-kimi/index.js +51 -0
- package/dist/plugins/adapter-kimi/quota.d.ts +3 -0
- package/dist/plugins/adapter-kimi/quota.js +171 -0
- package/dist/plugins/adapter-opencode/index.d.ts +12 -0
- package/dist/plugins/adapter-opencode/index.js +64 -0
- package/dist/plugins/annotations/console/cards.css +189 -0
- package/dist/plugins/annotations/console/cards.mjs +439 -0
- package/dist/plugins/annotations/console/pdl.json +52 -0
- package/dist/plugins/annotations/console/view.mjs +241 -0
- package/dist/plugins/annotations/console/window.mjs +219 -0
- package/dist/plugins/annotations/followups.d.ts +51 -0
- package/dist/plugins/annotations/followups.js +112 -0
- package/dist/plugins/annotations/index.d.ts +3 -0
- package/dist/plugins/annotations/index.js +298 -0
- package/dist/plugins/annotations/plugin.yaml +3 -0
- package/dist/plugins/ask-choice/index.d.ts +9 -0
- package/dist/plugins/ask-choice/index.js +24 -0
- package/dist/plugins/ask-choice/plugin.yaml +2 -0
- package/dist/plugins/background/index.d.ts +2 -0
- package/dist/plugins/background/index.js +398 -0
- package/dist/plugins/background/plugin.yaml +7 -0
- package/dist/plugins/builtin.json +37 -0
- package/dist/plugins/cards/console/pdl.json +516 -0
- package/dist/plugins/cards/console/view.mjs +67 -0
- package/dist/plugins/cards/index.d.ts +8 -0
- package/dist/plugins/cards/index.js +627 -0
- package/dist/plugins/cards/plugin.yaml +3 -0
- package/dist/plugins/console/browser.d.ts +2 -0
- package/dist/plugins/console/browser.js +115 -0
- package/dist/plugins/console/console/pdl.json +38 -0
- package/dist/plugins/console/console/view.mjs +26 -0
- package/dist/plugins/console/index.d.ts +4 -0
- package/dist/plugins/console/index.js +94 -0
- package/dist/plugins/console/picker.d.ts +2 -0
- package/dist/plugins/console/picker.js +48 -0
- package/dist/plugins/console/plugin.yaml +3 -0
- package/dist/plugins/console/topic-view.d.ts +3 -0
- package/dist/plugins/console/topic-view.js +388 -0
- package/dist/plugins/handoff/index.d.ts +2 -0
- package/dist/plugins/handoff/index.js +147 -0
- package/dist/plugins/handoff/plugin.yaml +8 -0
- package/dist/plugins/host-api/index.d.ts +7 -0
- package/dist/plugins/host-api/index.js +310 -0
- package/dist/plugins/host-api/plugin.yaml +2 -0
- package/dist/plugins/host-api/signing.d.ts +63 -0
- package/dist/plugins/host-api/signing.js +427 -0
- package/dist/plugins/host-api/skills/host-ops/SKILL.md +28 -0
- package/dist/plugins/host-api/skills/hostlet-plugin-dev/SKILL.md +38 -0
- package/dist/plugins/inbox/index.d.ts +15 -0
- package/dist/plugins/inbox/index.js +161 -0
- package/dist/plugins/inbox/plugin.yaml +2 -0
- package/dist/plugins/keys/account-directories.d.ts +18 -0
- package/dist/plugins/keys/account-directories.js +86 -0
- package/dist/plugins/keys/account-storage.d.ts +18 -0
- package/dist/plugins/keys/account-storage.js +112 -0
- package/dist/plugins/keys/console/pdl.json +710 -0
- package/dist/plugins/keys/console/view.mjs +619 -0
- package/dist/plugins/keys/index.d.ts +7 -0
- package/dist/plugins/keys/index.js +842 -0
- package/dist/plugins/keys/login-link.d.ts +2 -0
- package/dist/plugins/keys/login-link.js +15 -0
- package/dist/plugins/keys/plugin.yaml +3 -0
- package/dist/plugins/keys/quota-history.d.ts +91 -0
- package/dist/plugins/keys/quota-history.js +420 -0
- package/dist/plugins/mcp/console/pdl.json +412 -0
- package/dist/plugins/mcp/console/view.mjs +207 -0
- package/dist/plugins/mcp/index.d.ts +7 -0
- package/dist/plugins/mcp/index.js +494 -0
- package/dist/plugins/mcp/plugin.yaml +3 -0
- package/dist/plugins/member-health/index.d.ts +2 -0
- package/dist/plugins/member-health/index.js +478 -0
- package/dist/plugins/member-health/plugin.yaml +2 -0
- package/dist/plugins/memory/capabilities.d.ts +10 -0
- package/dist/plugins/memory/capabilities.js +70 -0
- package/dist/plugins/memory/console/pdl.json +459 -0
- package/dist/plugins/memory/console/view.mjs +254 -0
- package/dist/plugins/memory/corpus.d.ts +60 -0
- package/dist/plugins/memory/corpus.js +521 -0
- package/dist/plugins/memory/engines/fts-tree-diversity.d.ts +8 -0
- package/dist/plugins/memory/engines/fts-tree-diversity.js +49 -0
- package/dist/plugins/memory/engines/fts-tree-text.d.ts +12 -0
- package/dist/plugins/memory/engines/fts-tree-text.js +93 -0
- package/dist/plugins/memory/engines/fts-tree.d.ts +4 -0
- package/dist/plugins/memory/engines/fts-tree.js +387 -0
- package/dist/plugins/memory/engines/search.d.ts +9 -0
- package/dist/plugins/memory/engines/search.js +35 -0
- package/dist/plugins/memory/index.d.ts +3 -0
- package/dist/plugins/memory/index.js +465 -0
- package/dist/plugins/memory/notes.d.ts +22 -0
- package/dist/plugins/memory/notes.js +140 -0
- package/dist/plugins/memory/plugin.yaml +23 -0
- package/dist/plugins/model-profiles/index.d.ts +2 -0
- package/dist/plugins/model-profiles/index.js +916 -0
- package/dist/plugins/model-profiles/plugin.yaml +13 -0
- package/dist/plugins/model-profiles/review-source.d.ts +11 -0
- package/dist/plugins/model-profiles/review-source.js +640 -0
- package/dist/plugins/model-profiles/rules.d.ts +130 -0
- package/dist/plugins/model-profiles/rules.js +729 -0
- package/dist/plugins/model-profiles/skills/model-profile/SKILL.md +59 -0
- package/dist/plugins/model-profiles/sources.d.ts +61 -0
- package/dist/plugins/model-profiles/sources.js +375 -0
- package/dist/plugins/model-profiles/storage.d.ts +84 -0
- package/dist/plugins/model-profiles/storage.js +315 -0
- package/dist/plugins/model-profiles/types.d.ts +179 -0
- package/dist/plugins/model-profiles/types.js +12 -0
- package/dist/plugins/model-profiles/wakeup.d.ts +29 -0
- package/dist/plugins/model-profiles/wakeup.js +390 -0
- package/dist/plugins/models/index.d.ts +2 -0
- package/dist/plugins/models/index.js +63 -0
- package/dist/plugins/models/plugin.yaml +8 -0
- package/dist/plugins/ops/collector.d.ts +22 -0
- package/dist/plugins/ops/collector.js +48 -0
- package/dist/plugins/ops/config.d.ts +11 -0
- package/dist/plugins/ops/config.js +13 -0
- package/dist/plugins/ops/console/pdl.json +676 -0
- package/dist/plugins/ops/console/view.mjs +700 -0
- package/dist/plugins/ops/index.d.ts +3 -0
- package/dist/plugins/ops/index.js +20 -0
- package/dist/plugins/ops/journal.d.ts +7 -0
- package/dist/plugins/ops/journal.js +109 -0
- package/dist/plugins/ops/metrics.d.ts +3 -0
- package/dist/plugins/ops/metrics.js +81 -0
- package/dist/plugins/ops/plugin.yaml +63 -0
- package/dist/plugins/ops/samples.d.ts +54 -0
- package/dist/plugins/ops/samples.js +100 -0
- package/dist/plugins/ops/trace.d.ts +3 -0
- package/dist/plugins/ops/trace.js +104 -0
- package/dist/plugins/ops/usage.d.ts +2 -0
- package/dist/plugins/ops/usage.js +152 -0
- package/dist/plugins/plans/acceptance.d.ts +284 -0
- package/dist/plugins/plans/acceptance.js +247 -0
- package/dist/plugins/plans/blocked.d.ts +25 -0
- package/dist/plugins/plans/blocked.js +66 -0
- package/dist/plugins/plans/console/pdl.json +639 -0
- package/dist/plugins/plans/console/view.d.mts +2 -0
- package/dist/plugins/plans/console/view.mjs +855 -0
- package/dist/plugins/plans/dependencies.d.ts +5 -0
- package/dist/plugins/plans/dependencies.js +21 -0
- package/dist/plugins/plans/index.d.ts +72 -0
- package/dist/plugins/plans/index.js +2057 -0
- package/dist/plugins/plans/plugin.yaml +44 -0
- package/dist/plugins/plans/progress.d.ts +82 -0
- package/dist/plugins/plans/progress.js +516 -0
- package/dist/plugins/prompt/index.d.ts +8 -0
- package/dist/plugins/prompt/index.js +361 -0
- package/dist/plugins/prompt/plugin.yaml +2 -0
- package/dist/plugins/recovery/console/pdl.json +50 -0
- package/dist/plugins/recovery/console/view.mjs +46 -0
- package/dist/plugins/recovery/index.d.ts +9 -0
- package/dist/plugins/recovery/index.js +454 -0
- package/dist/plugins/recovery/plugin.yaml +9 -0
- package/dist/plugins/recovery/probe.d.ts +11 -0
- package/dist/plugins/recovery/probe.js +128 -0
- package/dist/plugins/restart/console/pdl.json +112 -0
- package/dist/plugins/restart/console/view.mjs +85 -0
- package/dist/plugins/restart/index.d.ts +10 -0
- package/dist/plugins/restart/index.js +669 -0
- package/dist/plugins/restart/plugin.yaml +9 -0
- package/dist/plugins/restart/scope.d.ts +6 -0
- package/dist/plugins/restart/scope.js +44 -0
- package/dist/plugins/schedule/console/pdl.json +696 -0
- package/dist/plugins/schedule/console/view.mjs +398 -0
- package/dist/plugins/schedule/events.d.ts +76 -0
- package/dist/plugins/schedule/events.js +158 -0
- package/dist/plugins/schedule/index.d.ts +32 -0
- package/dist/plugins/schedule/index.js +1199 -0
- package/dist/plugins/schedule/plugin.yaml +26 -0
- package/dist/plugins/schedule/when.d.ts +14 -0
- package/dist/plugins/schedule/when.js +83 -0
- package/dist/plugins/sessions/console/pdl.json +259 -0
- package/dist/plugins/sessions/console/view.mjs +355 -0
- package/dist/plugins/sessions/index.d.ts +3 -0
- package/dist/plugins/sessions/index.js +126 -0
- package/dist/plugins/sessions/participants.d.ts +28 -0
- package/dist/plugins/sessions/participants.js +83 -0
- package/dist/plugins/sessions/plugin.yaml +3 -0
- package/dist/plugins/signals/console/pdl.json +802 -0
- package/dist/plugins/signals/console/view.mjs +284 -0
- package/dist/plugins/signals/content.d.ts +31 -0
- package/dist/plugins/signals/content.js +151 -0
- package/dist/plugins/signals/index.d.ts +2 -0
- package/dist/plugins/signals/index.js +601 -0
- package/dist/plugins/signals/plugin.yaml +32 -0
- package/dist/plugins/signals/skills/signal-sources/SKILL.md +27 -0
- package/dist/plugins/skills/console/pdl.json +254 -0
- package/dist/plugins/skills/console/view.mjs +204 -0
- package/dist/plugins/skills/index.d.ts +11 -0
- package/dist/plugins/skills/index.js +567 -0
- package/dist/plugins/skills/install.d.ts +69 -0
- package/dist/plugins/skills/install.js +265 -0
- package/dist/plugins/skills/plugin.yaml +24 -0
- package/dist/plugins/skills/safety-scan.d.ts +17 -0
- package/dist/plugins/skills/safety-scan.js +78 -0
- package/dist/plugins/skills/skills/skill-ops/SKILL.md +29 -0
- package/dist/plugins/terminal/console/pdl.json +115 -0
- package/dist/plugins/terminal/console/view.mjs +178 -0
- package/dist/plugins/terminal/index.d.ts +3 -0
- package/dist/plugins/terminal/index.js +204 -0
- package/dist/plugins/terminal/plugin.yaml +2 -0
- package/dist/plugins/tools/index.d.ts +3 -0
- package/dist/plugins/tools/index.js +455 -0
- package/dist/plugins/tools/plugin.yaml +2 -0
- package/dist/plugins/tools/token.d.ts +61 -0
- package/dist/plugins/tools/token.js +179 -0
- package/dist/plugins/topic-tools/index.d.ts +9 -0
- package/dist/plugins/topic-tools/index.js +29 -0
- package/dist/plugins/topic-tools/plugin.yaml +2 -0
- package/dist/plugins/topic-tools/skills/topic-tidy/SKILL.md +108 -0
- package/dist/plugins/works/console/pdl.json +120 -0
- package/dist/plugins/works/console/view.mjs +91 -0
- package/dist/plugins/works/document-words.d.ts +50 -0
- package/dist/plugins/works/document-words.js +27 -0
- package/dist/plugins/works/editors.d.ts +3 -0
- package/dist/plugins/works/editors.js +162 -0
- package/dist/plugins/works/events.d.ts +58 -0
- package/dist/plugins/works/events.js +82 -0
- package/dist/plugins/works/files.d.ts +23 -0
- package/dist/plugins/works/files.js +53 -0
- package/dist/plugins/works/index.d.ts +9 -0
- package/dist/plugins/works/index.js +1088 -0
- package/dist/plugins/works/plugin.yaml +9 -0
- package/dist/plugins/works/preview.d.ts +10 -0
- package/dist/plugins/works/preview.js +30 -0
- package/dist/plugins/works/project.d.ts +3 -0
- package/dist/plugins/works/project.js +245 -0
- package/dist/plugins/works/resource.d.ts +28 -0
- package/dist/plugins/works/resource.js +71 -0
- package/dist/plugins/works/retention.d.ts +36 -0
- package/dist/plugins/works/retention.js +295 -0
- package/dist/plugins/works/skills/works-ops/SKILL.md +14 -0
- package/dist/plugins/works/viewers.d.ts +13 -0
- package/dist/plugins/works/viewers.js +87 -0
- package/dist/plugins/works/web/anchors.js +94 -0
- package/dist/plugins/works/web/document-edit.js +245 -0
- package/dist/plugins/works/web/preview-bridge.js +142 -0
- package/dist/plugins/works/web/reading-position.js +74 -0
- package/dist/plugins/works/web/view.html +1118 -0
- package/dist/runtime/runtime.d.ts +210 -0
- package/dist/runtime/runtime.js +338 -0
- package/dist/sdk/adapter-kit.d.ts +1 -0
- package/dist/sdk/adapter-kit.js +1 -0
- package/dist/sdk/client.d.ts +163 -0
- package/dist/sdk/client.js +43 -0
- package/dist/sdk/contracts.d.ts +1263 -0
- package/dist/sdk/contracts.js +1 -0
- package/dist/sdk/index.d.ts +57 -0
- package/dist/sdk/index.js +27 -0
- package/dist/sdk/source-choice.d.ts +40 -0
- package/dist/sdk/source-choice.js +217 -0
- package/dist/sdk/topic-text.d.ts +5 -0
- package/dist/sdk/topic-text.js +26 -0
- package/dist/sdk/transport.d.ts +12 -0
- package/dist/sdk/transport.js +34 -0
- package/node_modules/@hostlet/adapter-kit/dist/acp.d.ts +88 -0
- package/node_modules/@hostlet/adapter-kit/dist/acp.js +674 -0
- package/node_modules/@hostlet/adapter-kit/dist/command.d.ts +18 -0
- package/node_modules/@hostlet/adapter-kit/dist/command.js +39 -0
- package/node_modules/@hostlet/adapter-kit/dist/index.d.ts +8 -0
- package/node_modules/@hostlet/adapter-kit/dist/index.js +6 -0
- package/node_modules/@hostlet/adapter-kit/dist/models.d.ts +29 -0
- package/node_modules/@hostlet/adapter-kit/dist/models.js +108 -0
- package/node_modules/@hostlet/adapter-kit/dist/quota.d.ts +3 -0
- package/node_modules/@hostlet/adapter-kit/dist/quota.js +4 -0
- package/node_modules/@hostlet/adapter-kit/dist/rpc.d.ts +29 -0
- package/node_modules/@hostlet/adapter-kit/dist/rpc.js +84 -0
- package/node_modules/@hostlet/adapter-kit/dist/upstream-failure.d.ts +5 -0
- package/node_modules/@hostlet/adapter-kit/dist/upstream-failure.js +37 -0
- package/node_modules/@hostlet/adapter-kit/package.json +16 -0
- package/node_modules/@hostlet/platform/dist/desktop.d.ts +16 -0
- package/node_modules/@hostlet/platform/dist/desktop.js +270 -0
- package/node_modules/@hostlet/platform/dist/files.d.ts +24 -0
- package/node_modules/@hostlet/platform/dist/files.js +113 -0
- package/node_modules/@hostlet/platform/dist/index.d.ts +6 -0
- package/node_modules/@hostlet/platform/dist/index.js +4 -0
- package/node_modules/@hostlet/platform/dist/paths.d.ts +4 -0
- package/node_modules/@hostlet/platform/dist/paths.js +9 -0
- package/node_modules/@hostlet/platform/dist/process.d.ts +45 -0
- package/node_modules/@hostlet/platform/dist/process.js +297 -0
- package/node_modules/@hostlet/platform/package.json +14 -0
- package/package.json +60 -4
|
@@ -0,0 +1,523 @@
|
|
|
1
|
+
/* 边界:一个含义一个组件、不为接口定制、不按位置推导样式 */
|
|
2
|
+
/* 列表行:行、列表、列轨、树、分段、对话行、行的更多、续读、触屏露出 */
|
|
3
|
+
/* 列表行:所有“一行一项”的列表都用它,面板不再自己写行样式。
|
|
4
|
+
规则只在这里定一次:
|
|
5
|
+
- 行高 --row-h;小行 --row-h-sm(展开区里的子行)
|
|
6
|
+
- 结构固定:前导(头像/图标)→ 标题 + 行内标记(状态点、计时)→ 尾部数据列(状态、元信息)→ 操作(永远是最后一列)
|
|
7
|
+
- 尾部数据列右对齐,在列表容器的 subgrid 列轨上上下对齐(lrCols);操作占最后一条列轨(acts),同一列表里上下对齐
|
|
8
|
+
- 没有数据列的单行:悬停操作浮在行尾,不占宽度;不可用时置灰,悬停/点击说明原因
|
|
9
|
+
- 展开只有一层:同一个列表一次只展开一行;子行(sm)不能再展开
|
|
10
|
+
- 展开区左边缘对齐标题,不对齐前导 */
|
|
11
|
+
'use strict';
|
|
12
|
+
/* list / cards 共用续读尾标(唯一一个):服务端的下一页(声明的 next)和本地的下一页(渐进显示)都是它。
|
|
13
|
+
还有下一批时末尾是一个 ⋯(悬停“查看更多”),点它就读下一批;滚到附近也会自动读(服务端的下一页、本地的下一页一样;节点重画不续读,离开附近再进入或向下滚轮才触发下一批) */
|
|
14
|
+
const LIST_NEXT = {};
|
|
15
|
+
function listNextHtml(decl, sc, root) {
|
|
16
|
+
const d = pv(decl, sc, root); if (!d) return '';
|
|
17
|
+
return listNextTail(pv(d.key, sc, root), { act: pv(d.act, sc, root), args: pvArgsObj(d.args, sc, root), enabled: pvOk(d.when, sc, root), busy: !!pv(d.busy, sc, root) });
|
|
18
|
+
}
|
|
19
|
+
function listNextTail(k, x) {
|
|
20
|
+
LIST_NEXT[k] = x;
|
|
21
|
+
return '<div class="list-next" data-list-next="' + h(k) + '" data-island="list-next:' + h(k) + '">' + (x.enabled && !x.busy ? btn(tc('list.loadMore'), { iconOnly: true, sm: true, icon: 'more', act: 'listNextGo', data: ' data-k="' + h(k) + '"' }) : '') + '</div>';
|
|
22
|
+
}
|
|
23
|
+
A.listNextGo = function (d) { const x = LIST_NEXT[d.k]; if (x && x.enabled && !x.busy) actFn(x.act)(x.args); };
|
|
24
|
+
function listNextRead(el, near) {
|
|
25
|
+
const d = LIST_NEXT[el.dataset.listNext];
|
|
26
|
+
if (!near) { el._nextRead = false; return; }
|
|
27
|
+
if (!d.enabled || d.busy || el._nextRead || !el.checkVisibility()) return;
|
|
28
|
+
el._nextRead = true; actFn(d.act)(d.args, el);
|
|
29
|
+
}
|
|
30
|
+
nearView('[data-list-next]', listNextRead);
|
|
31
|
+
/* 消息流的顶端(和列表的下一页同一个做法):最早那条消息滚到附近就加载更早的(登记的 STREAM_OLDER;正在加载、已经没有更早的它会拒绝),
|
|
32
|
+
加载完还在附近就接着加载。看的是流里的第一条,不另加节点(流是带间距的 flex,多一个节点就多一段间距) */
|
|
33
|
+
function streamOlderRead(el, near) {
|
|
34
|
+
if (!near || !STREAM_OLDER.load || el._olderBusy) return;
|
|
35
|
+
el._olderBusy = true;
|
|
36
|
+
if (STREAM_OLDER.load(function () { el._olderBusy = false; if (el.isConnected && el.__near) streamOlderRead(el, true); }) === false) el._olderBusy = false;
|
|
37
|
+
}
|
|
38
|
+
nearView('[data-own="stream"] > :first-child', streamOlderRead);
|
|
39
|
+
document.addEventListener('wheel', function (e) {
|
|
40
|
+
if (e.deltaY <= 0) return;
|
|
41
|
+
const sc = e.target.closest('.scroll'); if (!sc) return;
|
|
42
|
+
sc.querySelectorAll('[data-list-next]').forEach(function (el) { if (el.closest('.scroll') === sc && el.__near && !LIST_NEXT[el.dataset.listNext].busy) { el._nextRead = false; listNextRead(el, true); } });
|
|
43
|
+
}, { passive: true });
|
|
44
|
+
/* 数据列(subgrid):列由行模板声明(cols 的第 i 项就是第 i 列,w 是宽度档);列表容器按这些声明铺列轨(lrCols),行、行头、行尾一层层 subgrid 到容器的列上,
|
|
45
|
+
所以同一列表里每一列上下对齐(按内容宽的 ctl / auto 列也对齐)。宽度档 icon num id money time label state date 的宽度是 token(--col-*),只当列轨的尺寸用;
|
|
46
|
+
ctl / auto / 没写档:按整列最宽的内容;整列都空:0。行自己不定宽 */
|
|
47
|
+
const COL_TIER = { icon: 1, num: 1, id: 1, money: 1, time: 1, label: 1, state: 1, date: 1 };
|
|
48
|
+
function lrCols(rows) { const t = lrColTracks(rows); return t ? ' data-cols style="' + t + '"' : ''; }
|
|
49
|
+
/* 紧凑列轨签名:每行仅记 [{ w, full }],供 Tier 1 行补丁按需更新容器列轨而不重画兄弟行 */
|
|
50
|
+
function lrColSig(cols) {
|
|
51
|
+
if (!cols || !cols.length) return [];
|
|
52
|
+
return cols.map(function (c) { return c && { w: c.w, full: c.v != null && c.v !== '' }; });
|
|
53
|
+
}
|
|
54
|
+
function lrColTracksFromSigs(sigs) {
|
|
55
|
+
const n = sigs.reduce(function (m, s) { return Math.max(m, s ? s.length : 0); }, 0); if (!n) return '';
|
|
56
|
+
const data = [], ctl = [];
|
|
57
|
+
for (let i = 0; i < n; i++) {
|
|
58
|
+
let w = '', full = false;
|
|
59
|
+
for (let j = 0; j < sigs.length; j++) {
|
|
60
|
+
const c = sigs[j] && sigs[j][i];
|
|
61
|
+
if (!c) continue;
|
|
62
|
+
if (!w && c.w) w = c.w;
|
|
63
|
+
if (c.full) full = true;
|
|
64
|
+
}
|
|
65
|
+
w = w || 'num';
|
|
66
|
+
(w === 'ctl' ? ctl : data).push(!full ? '0px' : COL_TIER[w] ? 'minmax(0, calc(var(--col-' + w + ') + var(--sp-s)))' : w === 'ctl' ? 'auto' : 'minmax(0, auto)');
|
|
67
|
+
}
|
|
68
|
+
return '--lr-cols:' + (data.join(' ') || '0px') + ';--lr-ctls:' + (ctl.join(' ') || '0px');
|
|
69
|
+
}
|
|
70
|
+
function lrColsFromSigs(sigs) { const t = lrColTracksFromSigs(sigs); return t ? ' data-cols style="' + t + '"' : ''; }
|
|
71
|
+
function lrColSigSame(a, b) {
|
|
72
|
+
const sa = a || [], sb = b || [];
|
|
73
|
+
if (sa.length !== sb.length) return false;
|
|
74
|
+
for (let i = 0; i < sa.length; i++) if (sa[i]?.w !== sb[i]?.w || sa[i]?.full !== sb[i]?.full) return false;
|
|
75
|
+
return true;
|
|
76
|
+
}
|
|
77
|
+
function lrUpdateCols(containerEl, container, unit, prevMeta) {
|
|
78
|
+
if (!containerEl) return;
|
|
79
|
+
if (lrColSigSame(prevMeta && prevMeta.colSig, unit.meta && unit.meta.colSig)) return;
|
|
80
|
+
const sigs = [];
|
|
81
|
+
container.units.forEach(function (u) { if (u.meta && u.meta.colSig) sigs.push(u.meta.colSig); });
|
|
82
|
+
const tracks = lrColTracksFromSigs(sigs);
|
|
83
|
+
if (!tracks) {
|
|
84
|
+
containerEl.removeAttribute('data-cols');
|
|
85
|
+
containerEl.style.removeProperty('--lr-cols');
|
|
86
|
+
containerEl.style.removeProperty('--lr-ctls');
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
containerEl.setAttribute('data-cols', '');
|
|
90
|
+
tracks.split(';').forEach(function (pair) {
|
|
91
|
+
const idx = pair.indexOf(':');
|
|
92
|
+
if (idx > 0) containerEl.style.setProperty(pair.slice(0, idx), pair.slice(idx + 1));
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
OWN.units = pdlUnitsOwn(function (n) { return n.nodeType === 1 ? (n.dataset.uk || n.dataset.nodeKey || n.dataset.rowKey || null) : null; });
|
|
96
|
+
/* 列轨分两段(行的通用排法:内容 · 空白 · 操作):数据列(--lr-cols)在悬停操作前面,常显的控件列(ctl:开关、主操作、投给谁)在悬停操作后面、最右。
|
|
97
|
+
返回写在列表容器上的两个变量(没有列 = 空) */
|
|
98
|
+
function lrColTracks(rows) {
|
|
99
|
+
return lrColTracksFromSigs(rows.map(function (row) { return lrColSig(row?.cols); }));
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
function lrAct(a) {
|
|
103
|
+
if (!a) return '';
|
|
104
|
+
return btn(a.label, { iconOnly: true, sm: true, icon: a.icon, act: a.act, data: (a.data || '') + (a.act === 'menu' ? MENU_DECL : ''), why: a.why, busy: !!a.busy, cls: a.why ? 'lr-dis' : '' });
|
|
105
|
+
}
|
|
106
|
+
/* o: { lead, title, inline, sub, cols:[{v, w, tip, tone, act, data}], acts:[{label, icon, act, data, why}], tone:'run'|'here'|'selected'|'past'|'done', color, bar:{pct, tone, tip},
|
|
107
|
+
expand: html(空串只展开标题全文), open, list, key, sm, act, data,
|
|
108
|
+
more: html 调用方自己管的展开(可以同时开几行):给了就画在行下面 } */
|
|
109
|
+
/* 行布局:组件库只有五种行布局,行模板只把数据绑到其中一种上(layout 必填;直接调用 lrow 的组件代码也写明)。
|
|
110
|
+
line 单行 · two 双行(标题 + 一行副行,可再带一行 meta)· item 条目(图标 · 标题 + 最多两行简介 · 竖排尾部:上操作、下状态)· tree 树行(缩进 + 展开指示)· record 记录行(紧凑的一行明细,子行高) */
|
|
111
|
+
const ROW_LAYOUTS = ['line', 'two', 'item', 'tree', 'record'];
|
|
112
|
+
function treeArrow(tip) { return icon(tip ? 'doubleRight' : 'right', 14); }
|
|
113
|
+
function treeTwisty(state, act, collapsedTip) {
|
|
114
|
+
if (!state) return '';
|
|
115
|
+
if (state === 'leaf') return '<span class="tw" aria-hidden="true"></span>';
|
|
116
|
+
const open = state === 'open', tip = open ? '' : collapsedTip;
|
|
117
|
+
const hint = (collapsedTip ? ' data-collapsed-tip="' + h(collapsedTip) + '"' : '') + (tip ? ' data-tip="' + h(tip) + '"' : '');
|
|
118
|
+
if (!act) return '<span class="tw" aria-hidden="true"' + hint + '>' + treeArrow(tip) + '</span>';
|
|
119
|
+
return '<button type="button" class="tw" data-act="fold" data-f="tree"' + act + ' aria-expanded="' + open +
|
|
120
|
+
'" aria-label="' + h(tc(open ? 'common.collapse' : 'common.expand')) + '"' + hint + '>' + treeArrow(tip) + '</button>';
|
|
121
|
+
}
|
|
122
|
+
function lrow(o) {
|
|
123
|
+
const editSt = o.edit && typeof inlineEditState === 'function' ? inlineEditState(o.edit.key) : null, editing = !!editSt;
|
|
124
|
+
const cols = o.cols || [], L = ROW_LAYOUTS.indexOf(o.layout) >= 0 ? o.layout : 'line', compact = L === 'record' || L === 'tree';
|
|
125
|
+
const canOpen = !editing && L !== 'tree' && (o.hasExpand || o.expand != null) && o.list; /* 记录行声明了展开也能点开(执行轨迹的一步);树行由树块自己开合 */
|
|
126
|
+
const click = editing || o.disabled ? '' : canOpen ? ' data-act="fold" data-f="row" data-l="' + h(o.list) + '" data-k="' + h(o.key) + '"' + (o.many ? ' data-many="1"' : '') + ' role="button" tabindex="0" aria-expanded="' + !!o.open + '"' : o.act ? ' data-act="' + o.act + '"' + (o.data || '') + ' role="button" tabindex="' + (o.disabled ? '-1' : '0') + '"' : '';
|
|
127
|
+
const dataCols = cols.filter(function (c) { return c.w !== 'ctl'; }), ctlCols = cols.filter(function (c) { return c.w === 'ctl'; });
|
|
128
|
+
const ctlHtml = ctlCols.map(function (c) { return '<span class="lr-col lr-ctl">' + (c.v || '') + '</span>'; }).join('');
|
|
129
|
+
const colHtml = dataCols.map(function (c) {
|
|
130
|
+
const tag = c.act ? 'button type="button"' : 'span';
|
|
131
|
+
return '<' + tag + ' class="lr-col' + (c.tone ? ' ' + c.tone : '') + (c.act ? ' lr-colbtn' : '') + '" data-w="' + (c.w || 'num') + '"' + (c.act ? ' data-act="' + c.act + '"' + (c.data || '') : '') + (c.tip ? ' data-tip="' + h(c.tip) + '"' : '') + '>' + (c.v == null ? '' : c.v) + '</' + tag.split(' ')[0] + '>';
|
|
132
|
+
}).join('');
|
|
133
|
+
const bar = o.bar && o.bar.pct != null ? '<span class="lr-bar' + (o.bar.tone ? ' ' + o.bar.tone : '') + '" style="--p:' + Math.min(100, o.bar.pct) + '%"' + (o.bar.tip ? ' data-tip="' + h(o.bar.tip) + '"' : '') + ' aria-hidden="true"></span>' : '';
|
|
134
|
+
const acts = (o.acts || []).filter(Boolean), nActs = acts.length || (o.actsHtml ? (o.actsHtml.match(/<button/g) || []).length : 0); /* actsHtml:调用方已经画好的一组操作按钮(插槽里的操作) */
|
|
135
|
+
const focus = !editing && !click && !o.disabled && nActs ? ' tabindex="0"' : ''; /* 只有悬停操作的行也能用 Tab 露出按钮 */
|
|
136
|
+
/* 展开指示:行本身点了做别的事(树的选中)时,指示是它自己的开合按钮(twAct:开合的参数) */
|
|
137
|
+
const tw = treeTwisty(o.twisty, o.twAct, o.collapsedTip);
|
|
138
|
+
const swap = !!(o.aside && nActs && o.swap !== false);
|
|
139
|
+
const actsHtml = nActs ? '<span class="lr-acts' + (swap ? ' swap' : '') + '">' + (o.actsHtml || acts.map(lrAct).join('')) + '</span>' : '';
|
|
140
|
+
/* 状态、时间和悬停操作共用固定区,宽度足以容纳其中较宽的一项。 */
|
|
141
|
+
const aside = o.aside ? '<span class="lr-aside"><span class="lr-aside-d' + (swap ? ' swap-d' : '') + '">' + (o.aside[1] ? '<span class="lr-aside-b">' + o.aside[1] + '</span>' : '') + '<span class="lr-aside-t">' + (o.aside[0] || '') + '</span></span>' + (swap ? actsHtml : '') + '</span>' : '';
|
|
142
|
+
const tone = (o.tone ? ' ' + o.tone : '') + (o.cur ? ' selected' : '');
|
|
143
|
+
const rowKey = o.key == null ? '' : ' data-row-key="' + h(o.key) + '"';
|
|
144
|
+
const titleHtml = editing ? inlineEditInput({ state: editSt, cls: 'inline-edit-row', label: o.edit.label }) : o.title;
|
|
145
|
+
return '<div class="lr' + tone + (canOpen || (!editing && o.act) ? ' click' : '') + (o.disabled ? ' off' : '') + (o.hook ? ' ' + o.hook : '') + '"' + ' data-layout="' + L + '"' + rowKey + (editing ? ' data-editing="true"' : '') + (swap ? ' data-swap' : '') + (o.rootAttrs || '') + (o.orderable && o.key != null ? ' data-okey="' + h(o.key) + '" data-edit="order"' : '') + (canOpen ? ' data-open="' + !!o.open + '"' + (o.titleWrap && o.titleWrap !== 'auto' ? ' data-title-wrap="' + h(o.titleWrap) + '"' : '') : '') + (o.note ? ' data-note="' + o.note + '"' : '') + ' style="--acts:' + (nActs && !swap && !cols.length ? 'calc(' + nActs + ' * var(--ctl-s) + var(--sp-s))' : '0px') + ';--c:' + (o.color || 'initial') + (o.depth != null ? ';--d:' + o.depth : '') + '">' +
|
|
146
|
+
(o.pre ? '<span class="lr-pre' + (o.preLive ? ' live' : '') + '">' + o.pre + '</span>' : '') +
|
|
147
|
+
'<div class="lr-head"' + click + focus + (o.cur ? ' aria-current="' + (o.cur === true ? 'true' : o.cur) + '"' : '') + (o.sel ? ' aria-selected="true"' : '') + (o.disabled ? ' aria-disabled="true"' : '') + (o.headAttrs || '') + (o.twisty && o.twisty !== 'leaf' && !o.twAct ? ' aria-expanded="' + (o.twisty === 'open') + '"' : '') + '>' + (o.orderable ? '<span class="lr-grip" aria-hidden="true">' + icon('grip', 14) + '</span>' : '') + tw + (o.lead || o.leadSlot ? '<span class="lr-lead">' + o.lead + '</span>' : '') +
|
|
148
|
+
'<span class="lr-main"><span class="lr-line"><span class="lr-title">' + titleHtml + '</span>' + (o.inline || '') + '</span>' + (o.sub ? '<span class="lr-sub' + (o.subLines ? ' clamp" style="--sub-lines:' + o.subLines : '') + '">' + o.sub + '</span>' : '') + (o.meta ? '<span class="lr-sub lr-meta">' + o.meta + '</span>' : '') + '</span>' +
|
|
149
|
+
/* 尾部(行的通用排法:内容 · 空白 · 操作):数据列(状态、元信息)→ 悬停才出现的操作(改名、删除、⋯:也支持,但少用)→ 常显的控件(开关、主操作:一定支持)在最右。
|
|
150
|
+
有数据列的行(和列表里对齐的行)悬停操作占自己的列轨(看不见也占着,状态不跳);没有数据列的行,悬停操作浮在常显控件的前面、不占宽度。
|
|
151
|
+
条目布局的竖排尾部(上:开关或主操作)也是常显的,所以悬停操作画在它前面 */
|
|
152
|
+
((nActs && !swap) || cols.length ? '<span class="lr-end">' + (dataCols.length ? '<span class="lr-cols">' + colHtml + '</span>' : '') + (nActs && !swap ? actsHtml : '') + (ctlCols.length ? '<span class="lr-ctls">' + ctlHtml + '</span>' : '') + '</span>' : '') + aside + bar + '</div>' +
|
|
153
|
+
(canOpen && o.open && o.expand ? '<div class="lr-more lr-exp' + (o.lead ? '' : ' nolead') + '">' + o.expand + '</div>' : '') + /* 额外内容只在打开时画:收起的行不画、也就不读它要的数据;只有标题全文时不另画展开块。 */
|
|
154
|
+
(o.more ? '<div class="lr-more' + (o.lead ? '' : ' nolead') + '">' + o.more + '</div>' : '') + '</div>';
|
|
155
|
+
}
|
|
156
|
+
/* 列表:放进统一的 group 底,管理行的展开(默认一次一行;o.many 每行各自开合) */
|
|
157
|
+
function lrList(key, items, o) {
|
|
158
|
+
o = o || {};
|
|
159
|
+
/* rows:限行数的列表(组件库唯一的限行机制 scrollRows):k 整行 + 1 整行渐隐,超出的在列表里滚动 */
|
|
160
|
+
const compact = items.length && items.every(function (it) { return it.layout === 'record' || it.layout === 'tree'; });
|
|
161
|
+
const tr = o.rows ? lrColTracks(items) : '', attrs = o.rows ? (tr ? ' data-cols' : '') + scrollRows(o.rows, compact ? '--row-h-sm' : '--row-h', tr || null) : lrCols(items);
|
|
162
|
+
/* order:可以拖动排序的列表——容器交给引擎的同级换位(data-ocontainer + data-order-act,放下时把新的 key 顺序交给这个动作),行带把手 */
|
|
163
|
+
const ord = o.order ? ' data-ocontainer="list:' + h(key) + '" data-order-act="' + h(o.order) + '"' : '';
|
|
164
|
+
return '<div class="group lr-list' + (o.rows ? ' scroll' : '') + (o.cls ? ' ' + o.cls : '') + '"' + attrs + ord + '>' + (items.length ? items.map(function (it) { return lrow(Object.assign({ list: key, open: rowOpen(key, it.key), many: !!o.many, orderable: !!o.order }, it)); }).join('') : emptyState({ text: o.empty || tc('list.empty'), acts: o.emptyActs || '' })) + '</div>';
|
|
165
|
+
}
|
|
166
|
+
/* 列表的本地筛选(列表声明 searchable):一个筛选框,只筛已经读到的项(项里任一文字含查询词),不发请求;查询词是列表自己的状态,按列表 id 记在 LIST_Q */
|
|
167
|
+
const LIST_Q = pdlKeyed('listQ');
|
|
168
|
+
function listQField(id) { return search('lq-' + id, tc('list.filter'), LIST_Q.get(id) || '', 'listQ', 'lr-q'); }
|
|
169
|
+
function listFind(items, q) {
|
|
170
|
+
q = (q || '').trim().toLowerCase(); if (!q) return items;
|
|
171
|
+
const hit = function (v) { return typeof v === 'string' ? v.toLowerCase().indexOf(q) >= 0 : v && typeof v === 'object' ? Object.keys(v).some(function (k) { return hit(v[k]); }) : false; };
|
|
172
|
+
return items.filter(hit);
|
|
173
|
+
}
|
|
174
|
+
INPUTS.listQ = function (e) { LIST_Q.set(e.target.id.slice(3), e.target.value); render(true); };
|
|
175
|
+
/* 列表的渐进显示:每个列表已经画了几行(按列表记,和筛选一样是列表自己的状态),一页 LIST_PAGE_N 行 */
|
|
176
|
+
const LIST_PAGE = pdlKeyed('listPage'), LIST_PAGE_N = 20;
|
|
177
|
+
A.listMore = function (d) { LIST_PAGE.set(d.list, (LIST_PAGE.peek(d.list) || LIST_PAGE_N) + LIST_PAGE_N); render(true); };
|
|
178
|
+
/* 显式分页每次替换当前页;同一列表换筛选条件回首页,删掉末页时退到最后一页。 */
|
|
179
|
+
const LIST_PAGE_SELECTION = pdlKeyed('listPageSelection');
|
|
180
|
+
function listPageWindow(list, count, query) {
|
|
181
|
+
const saved = LIST_PAGE_SELECTION.get(list);
|
|
182
|
+
const pages = Math.max(1, Math.ceil(count / LIST_PAGE_N));
|
|
183
|
+
const page = saved?.query === query ? Math.min(saved.page, pages) : 1;
|
|
184
|
+
if (saved && (saved.page !== page || saved.query !== query)) LIST_PAGE_SELECTION.set(list, { page, query });
|
|
185
|
+
const start = (page - 1) * LIST_PAGE_N;
|
|
186
|
+
if (pages === 1) return { start, controls: '' };
|
|
187
|
+
function turn(target, label, icon) {
|
|
188
|
+
return btn(tc(label), { iconOnly: true, sm: true, icon, act: 'listTurnPage',
|
|
189
|
+
data: argAttrs({ list, page: target, query }), disabled: target < 1 || target > pages });
|
|
190
|
+
}
|
|
191
|
+
const controls = '<nav class="list-pagination" aria-label="' + h(tc('list.pagination')) + '">' +
|
|
192
|
+
turn(page - 1, 'list.previousPage', 'left') + '<span class="num" aria-live="polite">' + page + ' / ' + pages + '</span>' +
|
|
193
|
+
turn(page + 1, 'common.next', 'right') + '</nav>';
|
|
194
|
+
return { start, controls };
|
|
195
|
+
}
|
|
196
|
+
A.listTurnPage = function (d) {
|
|
197
|
+
LIST_PAGE_SELECTION.set(d.list, { page: Number(d.page), query: d.query });
|
|
198
|
+
render(true);
|
|
199
|
+
};
|
|
200
|
+
function lrText(html, tone) { return '<div class="lr-text' + (tone ? ' ' + tone : '') + '">' + html + '</div>'; }
|
|
201
|
+
/* 树:逐级加载的层级列表(文件树)。规则同样只在这里:每层缩进 16px,箭头在前导前面,行高用小行,悬停操作和数据列沿用列表行。
|
|
202
|
+
.lr 行单元与 .lr-kids 子树容器分离:父节点更新仅补丁其 .lr,绝不重走其 .lr-kids 子树。 */
|
|
203
|
+
S.treeLoaded = {}; /* 读过的目录(数据,不是开合状态) */
|
|
204
|
+
function ltree(key, kids, o) {
|
|
205
|
+
o = o || {};
|
|
206
|
+
const loaded = S.treeLoaded[key] = S.treeLoaded[key] || {};
|
|
207
|
+
const branchSig = o.branch ? vmJson(o.root) : null;
|
|
208
|
+
function busyRow(depth) {
|
|
209
|
+
return lrow({ layout: 'tree', depth: depth, twisty: 'leaf', title: PDL_COMPONENTS.loadingStatus(tc('common.loading')) });
|
|
210
|
+
}
|
|
211
|
+
function branchHtml(path, depth) {
|
|
212
|
+
/* The branch reads its own state. Tree rows do not subscribe to sibling keys or loading. */
|
|
213
|
+
return ctLeaf(pdlUnitScope('branch', [key, path]), branchSig + '|' + depth, function () {
|
|
214
|
+
const branch = treeFoldIsOpen(key, path) ? o.branch(path) : null;
|
|
215
|
+
const html = branch ? (branch.pending ? busyRow(depth) : walk(path, depth, branch.items)) : '';
|
|
216
|
+
return '<div class="lr-kids" data-own="units">' + html + '</div>';
|
|
217
|
+
}, true);
|
|
218
|
+
}
|
|
219
|
+
const drawRow = function (raw, r, depth) {
|
|
220
|
+
const n = o.mapNode ? o.mapNode(raw, r) : raw;
|
|
221
|
+
const tg = ' data-l="' + h(key) + '" data-p="' + h(n.path) + '"';
|
|
222
|
+
const isOpen = n.dir ? treeFoldIsOpen(key, n.path) : false, twisty = n.dir ? (isOpen ? 'open' : 'closed') : 'leaf';
|
|
223
|
+
const rowHtml = lrow(Object.assign({ layout: 'tree', depth: depth, twisty: o.flat ? '' : twisty, twAct: n.pick && n.dir ? tg : '', collapsedTip: n.collapsedTip, title: h(n.name),
|
|
224
|
+
act: n.pick ? n.pick.act : n.dir ? 'fold' : o.fileAct, data: n.pick ? n.pick.data : n.dir ? ' data-f="tree"' + tg : (o.fileData ? o.fileData(n) : '') }, n.row || {}));
|
|
225
|
+
return { html: rowHtml, meta: { shape: n.dir ? 'branch' : 'leaf', dir: !!n.dir, path: n.path, open: isOpen } };
|
|
226
|
+
};
|
|
227
|
+
function walk(path, depth, items = kids(path) || []) {
|
|
228
|
+
const uRes = pdlUnits({
|
|
229
|
+
id: pdlUnitScope('tree', [key, path]),
|
|
230
|
+
items: items,
|
|
231
|
+
keyOf: function (it) { return it && it.path != null ? String(it.path) : null; },
|
|
232
|
+
root: o.root,
|
|
233
|
+
draw: function (raw, r) { return drawRow(raw, r, depth); },
|
|
234
|
+
onRowPatch: o.branch ? function (parent, _container, row) {
|
|
235
|
+
if (row.meta.dir) parent.dataset.open = String(row.meta.open);
|
|
236
|
+
} : null
|
|
237
|
+
});
|
|
238
|
+
const out = [];
|
|
239
|
+
for (let i = 0; i < uRes.parts.length; i++) {
|
|
240
|
+
const rowHtml = uRes.parts[i];
|
|
241
|
+
const meta = uRes.metas[i];
|
|
242
|
+
if (!meta.dir) { out.push(rowHtml); continue; }
|
|
243
|
+
const p = meta.path;
|
|
244
|
+
const isOpen = o.branch ? meta.open : treeFoldIsOpen(key, p);
|
|
245
|
+
if (o.ready) loaded[p] = true;
|
|
246
|
+
let branch;
|
|
247
|
+
if (o.branch) branch = branchHtml(p, depth + 1);
|
|
248
|
+
else {
|
|
249
|
+
const busy = isOpen && (o.pending?.(p) || !loaded[p]);
|
|
250
|
+
const sub = busy ? busyRow(depth + 1) : loaded[p] ? walk(p, depth + 1) : '';
|
|
251
|
+
branch = sub ? '<div class="lr-kids" data-own="units">' + sub + '</div>' : '';
|
|
252
|
+
}
|
|
253
|
+
out.push('<div class="lr-node" data-node-key="node:' + h(p) + '" data-open="' + isOpen + '">' + rowHtml + branch + '</div>');
|
|
254
|
+
}
|
|
255
|
+
return out.join('');
|
|
256
|
+
}
|
|
257
|
+
const path = o.rootPath ?? (typeof o.root === 'string' ? o.root : '');
|
|
258
|
+
const body = walk(path, 0, o.branch ? o.branch(path).items : undefined);
|
|
259
|
+
return '<div class="group lr-list lr-tree' + (o.divider ? ' lined' : '') + '" data-own="units">' + (body || emptyState(o.empty || tc('list.emptyFolder'))) + '</div>';
|
|
260
|
+
}
|
|
261
|
+
/* 展开目录:已加载过的直接本地开合;第一次展开先画“加载中…”,接口返回后再画出下一级(数据变了才重画) */
|
|
262
|
+
const TREE_FOLD_HOOKS = [];
|
|
263
|
+
function onTreeFold(key, fn) { TREE_FOLD_HOOKS.push([key, fn]); }
|
|
264
|
+
function foldTree(d, el) {
|
|
265
|
+
const loaded = S.treeLoaded[d.l] = S.treeLoaded[d.l] || {};
|
|
266
|
+
const isOpen = !treeFoldIsOpen(d.l, d.p);
|
|
267
|
+
treeFoldSet(d.l, d.p, isOpen);
|
|
268
|
+
const open = foldTreeEnsure(d.l);
|
|
269
|
+
TREE_FOLD_HOOKS.forEach(function (x) { if (x[0] === d.l) x[1](open, d.p, isOpen); });
|
|
270
|
+
const node = el && el.closest('.lr-node');
|
|
271
|
+
if (node && (loaded[d.p] || !isOpen)) {
|
|
272
|
+
const arrow = el.matches('.tw') ? el : el.querySelector(':scope > .tw');
|
|
273
|
+
if (arrow?.dataset.collapsedTip) {
|
|
274
|
+
const tip = isOpen ? '' : arrow.dataset.collapsedTip;
|
|
275
|
+
if (tip) arrow.dataset.tip = tip; else delete arrow.dataset.tip;
|
|
276
|
+
arrow.innerHTML = treeArrow(tip);
|
|
277
|
+
}
|
|
278
|
+
if (arrow === el) arrow.setAttribute('aria-label', tc(isOpen ? 'common.collapse' : 'common.expand'));
|
|
279
|
+
localOpen(node, isOpen, el);
|
|
280
|
+
return;
|
|
281
|
+
}
|
|
282
|
+
render(true);
|
|
283
|
+
if (isOpen && !loaded[d.p]) ioSend('tree:open', { l: d.l, p: d.p }); /* 第一次展开:读下一级(接口返回 tree:loaded 后画出来) */
|
|
284
|
+
}
|
|
285
|
+
ioOn('tree:loaded', function (e) { (S.treeLoaded[e.l] = S.treeLoaded[e.l] || {})[e.p] = true; render(true); });
|
|
286
|
+
|
|
287
|
+
/* 列表之间的小标题;可以带一个操作图标,高度固定,带不带图标都一样高 */
|
|
288
|
+
/* 组标签(组件库唯一的小标题,principles:一件事一个地方):一组行上方的小字,或分组列表里一组的标题;可带计数、说明(问号)和组的操作。
|
|
289
|
+
页面里的大小节标题是另一种(section 块的标题),只有这两种 */
|
|
290
|
+
/* tip:标题文字的提示(范围这类一句话的补充,不写成标题下的一行说明)
|
|
291
|
+
v:放在哪种列表上(角色变体,样子只差留白):缺省 = 页面里两组行之间;float = 浮层列表里(菜单、弹出层、启动面板、全部标签);nav = 侧栏的分组。
|
|
292
|
+
attrs:额外属性(侧栏分组编辑布局时的拖动 / 改名标记),不挑样子 */
|
|
293
|
+
function lrSection(t, actions, o) {
|
|
294
|
+
o = o || {};
|
|
295
|
+
const editSt = o.edit && typeof inlineEditState === 'function' ? inlineEditState(o.edit.key) : null;
|
|
296
|
+
if (editSt) return '<div class="lr-section-label" data-editing="true"' + (o.v ? ' data-v="' + o.v + '"' : '') + (o.attrs || '') + '><span class="grow">' + inlineEditInput({ state: editSt, cls: 'inline-edit-row', label: o.edit.label }) + '</span></div>';
|
|
297
|
+
const tt = o.html != null ? o.html : h(t);
|
|
298
|
+
return '<div class="lr-section-label"' + (o.v ? ' data-v="' + o.v + '"' : '') + (o.attrs || '') + '><span class="grow">' + (o.tip ? '<span data-tip="' + h(o.tip) + '">' + tt + '</span>' : tt) + (o.count != null && o.count !== '' ? ' <span class="num">' + h(String(o.count)) + '</span>' : '') + (o.help ? helpTip(o.help) : '') + '</span>' + (actions || '') + '</div>';
|
|
299
|
+
}
|
|
300
|
+
/* 行内标记:状态点 */
|
|
301
|
+
function lrDot(tone, tip, c) { return '<span class="dot"' + (tone ? ' data-tone="' + tone + '"' : '') + (c ? ' style="--c:' + c + '"' : '') + (tip ? ' data-tip="' + h(tip) + '"' : '') + '></span>'; }
|
|
302
|
+
|
|
303
|
+
/* 一次只展开一行:展开区只在打开时画,开合是一次重画(局部更新只换变了的行,别的行节点不动) */
|
|
304
|
+
/* 列表的行展开:默认一次一行(再点收起、点别的换过去);列表声明 expand: many 时每行各自开合。读取走键级 ROW_OPEN,绝不污染 ~S.folds */
|
|
305
|
+
function rowOpen(list, key) { return key != null && list != null && !!ROW_OPEN.get(list + '|' + key); }
|
|
306
|
+
function foldRow(d) {
|
|
307
|
+
const v = FOLD_ROW_MAP[d.l];
|
|
308
|
+
if (d.many) {
|
|
309
|
+
const o = Object.assign({}, v && typeof v === 'object' ? v : {});
|
|
310
|
+
if (o[d.k]) delete o[d.k]; else o[d.k] = true;
|
|
311
|
+
foldRowWrite(d.l, o);
|
|
312
|
+
} else {
|
|
313
|
+
foldRowWrite(d.l, v === d.k ? null : d.k);
|
|
314
|
+
}
|
|
315
|
+
render(true);
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
/* 触屏(hover: none):悬停能露出的东西,点一下也能露出——行的操作、胶囊 / 头像堆展开、? 的说明;再点一下或点别处收起。
|
|
319
|
+
胶囊、头像堆、? 第一下只展开(不执行它的动作);展开后再点:收起,有动作的照常执行 */
|
|
320
|
+
const TAP_HOST = '.rstack, .cap, .help-q, .stream-message, .workspace-thread-row, .lr, [data-swap]', TAP_PEEK = '.rstack, .cap, .help-q';
|
|
321
|
+
window.addEventListener('click', function (e) {
|
|
322
|
+
if (!matchMedia('(hover: none)').matches) return;
|
|
323
|
+
let host = e.target.closest ? e.target.closest(TAP_HOST) : null;
|
|
324
|
+
let sameCap = true;
|
|
325
|
+
if (host && host.matches('.cap') && host.closest('.rstack')) {
|
|
326
|
+
const st = host.closest('.rstack');
|
|
327
|
+
sameCap = host.classList.contains('tap-cap');
|
|
328
|
+
st.querySelectorAll('.tap-cap').forEach(function (c) { c.classList.remove('tap-cap'); });
|
|
329
|
+
host.classList.add('tap-cap'); host = st;
|
|
330
|
+
}
|
|
331
|
+
document.querySelectorAll('.tap-on').forEach(function (x) { if (!host || (x !== host && !x.contains(host))) x.classList.remove('tap-on'); });
|
|
332
|
+
if (!host) return;
|
|
333
|
+
const peek = host.matches(TAP_PEEK);
|
|
334
|
+
if (host.classList.contains('tap-on')) {
|
|
335
|
+
if (peek && !sameCap) { e.preventDefault(); e.stopPropagation(); return; }
|
|
336
|
+
if (peek) {
|
|
337
|
+
host.classList.remove('tap-on'); tipHide();
|
|
338
|
+
if (!host.contains(e.target.closest('[data-act]'))) e.stopPropagation();
|
|
339
|
+
}
|
|
340
|
+
return;
|
|
341
|
+
}
|
|
342
|
+
host.classList.add('tap-on');
|
|
343
|
+
if (peek) { e.preventDefault(); e.stopPropagation(); if (host.dataset.tip && !host.querySelector('.cap-x')) tipShow(host); }
|
|
344
|
+
}, true);
|
|
345
|
+
|
|
346
|
+
/* ───────── 弹出层里的一项(组件库):视图模型只给数据,这里画 ─────────
|
|
347
|
+
选项 { lead: { who } | { icon, big } | { glyph }, title: 文字 | [文字 | { hl: 命中的字 }], handle, tag, mono, sub, subTone: run | warn, subMono,
|
|
348
|
+
value(右边的当前值), chev(右箭头:进子页), go(右边“跳过去 ›”), cur(已选,打勾), sel(键盘选中), act, args, disabled }
|
|
349
|
+
另外三种:{ sep: 1 } 分隔线;{ sec: '小节名', mono };{ note: '一行说明', tone: warn } */
|
|
350
|
+
function popEntry(x) {
|
|
351
|
+
if (x.sep) return '<div class="divider" role="separator"></div>';
|
|
352
|
+
if (x.sec != null) return lrSection(x.sec, '', { v: 'float', html: x.mono ? '<span class="mono">' + h(x.sec) + '</span>' : null }); /* 小节名:组标签(浮层列表里的那种) */
|
|
353
|
+
if (x.note != null) return '<p class="pop-foot' + (x.tone === 'warn' ? ' vw-warn-t' : '') + '">' + h(x.note) + '</p>';
|
|
354
|
+
const tx = function (t) { return Array.isArray(t) ? t.map(function (s) { return typeof s === 'string' ? h(s) : '<mark>' + h(s.hl) + '</mark>'; }).join('') : h(t); };
|
|
355
|
+
const lead = !x.lead ? '' : x.lead.who ? whoAva(x.lead.who, { size: 's', tip: false, health: x.lead.health }) : x.lead.glyph ? glyph(x.lead.glyph, 'pop-glyph') : icon(x.lead.icon, x.lead.big ? 16 : 14);
|
|
356
|
+
const title = (x.mono ? '<span class="mono">' + tx(x.title) + '</span>' : tx(x.title)) + (x.handle ? ' <span class="muted">' + h(x.handle) + '</span>' : '') + (x.tag ? ' <span class="pdl-meta-tag">' + h(x.tag) + '</span>' : '');
|
|
357
|
+
const sub = x.sub ? (x.subTone ? '<span class="' + (x.subTone === 'run' ? 'pop-run' : 'vw-warn-t') + '">' : '') + (x.subMono ? '<span class="mono">' + h(x.sub) + '</span>' : h(x.sub)) + (x.subTone ? '</span>' : '') : '';
|
|
358
|
+
/* 一项就是一行 lrow(小行):前导 · 标题 + 说明 · 行尾(当前值、进子页、已选打勾)。
|
|
359
|
+
整行能点(act)时就没有“跳过去”这一列:点行就是去那里,不再在行尾另写一遍 */
|
|
360
|
+
const tail = (x.value != null ? '<span class="lr-meta">' + h(x.value) + '</span>' : '') + (x.go && !x.act ? '<span class="lr-meta">' + h(x.go) + '</span>' : '') + (x.chev ? icon('right', 14) : '') + (x.cur ? icon('check', 14) : '');
|
|
361
|
+
return lrow({ layout: 'record', hook: 'pop-opt', rootAttrs: (x.stay ? ' data-stay' : '') + (x.why ? ' data-tip="' + h(x.why) + '"' : ''), act: x.act, data: argAttrs(x.args), lead: lead, title: title, sub: sub, cur: !!x.cur, sel: !!x.sel, disabled: !!x.disabled, cols: tail ? [{ w: 'ctl', v: tail }] : [] });
|
|
362
|
+
}
|
|
363
|
+
/* 分组列表的一段(组件库):侧栏的置顶、对话组、项目、最近……都是它。
|
|
364
|
+
- 只有一个滚动:外面的列表(导航栏)。段里不再套滚动容器。
|
|
365
|
+
- 表头就是调用方给的那一行(比如“置顶 · 12 个对话”),和行一起滚动(组标签从不吸顶);点表头(fold,data-f="sec")收起 / 展开整段。
|
|
366
|
+
- 段就是通用的父子关系:表头是父,行是子;缩进、对齐、收起都由这一个分组渲染决定,段不能单独定制。
|
|
367
|
+
- 默认展开还是收起、几条以上折叠(limit 档位)由 PDL 按段的种类声明(groups: { pinned: { collapsed, limit } … });用户点过的状态盖在上面。
|
|
368
|
+
- 行默认只显示前 SEC_COUNT[limit] 条,下面是同一个折叠开关(foldTg)“还有 N 条”,原地展开、⌃ 收起。
|
|
369
|
+
- 收起整段、展开更多,按段记住(store 'secs',刷新还在)。调用方自己管收起状态的段(对话组、项目)传 collapsed。 */
|
|
370
|
+
const SEC_COUNT = { s: 5, m: 10, l: 15 }; /* 折叠阈值档位;默认 l = 15 */
|
|
371
|
+
(function () { const s = store.get('secs', {}); Object.keys(s).forEach(function (k) { S.folds[FOLD_SEC + k] = s[k]; }); })(); /* 本机记着的分组段(存的格式不变:{ 段: { c, m } }) */
|
|
372
|
+
function secSave() { const o = {}; Object.keys(S.folds).forEach(function (k) { if (k.indexOf(FOLD_SEC) === 0) o[k.slice(FOLD_SEC.length)] = S.folds[k]; }); store.set('secs', o); }
|
|
373
|
+
function secSt(key, make) { return S.folds[FOLD_SEC + key] || (make ? (S.folds[FOLD_SEC + key] = {}) : null); }
|
|
374
|
+
function secCollapsed(key, dflt) { const st = secSt(key); return st && st.c != null ? !!st.c : !!dflt; }
|
|
375
|
+
/* ───────── 对话列表(组件库):一个对话一行 + 分组段。视图模型只给数据,这里画 ─────────
|
|
376
|
+
行 { id, title, time, cur, pinned, renaming, fav, meta: [{ text, tone: run | err }], badge: { kind: draft | at | unread, n }, more: { menu, label } }
|
|
377
|
+
段 { key, head, rows, peek, collapsed, empty, gid }(所有段的行缩进相同:行内容左边和段表头左边对齐,一条规则,段不能单独缩进);head:{ kind: 'sec', label, n, note } 段名 + “N 个对话”(点了收起整段)、
|
|
378
|
+
{ kind: 'group', id, name, n, open } 对话组、{ kind: 'proj', id, name, tip, open, warn, fixed, n, add } 项目;{ other: { open, n } } 是“其他项目”开关 */
|
|
379
|
+
function rowMore(menu, k, label, cls) { return btn(label || tc('common.moreActions'), { sm: true, iconOnly: true, icon: 'more', cls: cls, act: 'menu', data: ' data-menu="' + menu + '"' + MENU_DECL + (k != null ? ' data-k="' + h(k) + '"' : '') }); }
|
|
380
|
+
const TROW_TONE = { run: { cls: 'run', dot: true }, err: { cls: 'workspace-row-error' } }; /* 行的状态:执行中(圆点按状态表挑节拍预设)、出错 */
|
|
381
|
+
/* rn:原地改名的绑定(threads 块声明 rename = { form, path, blur }:回车提交给哪个表单、Esc 关掉哪个状态、失焦执行什么),组件不认识 */
|
|
382
|
+
function threadRow(v, rn, root, movable) {
|
|
383
|
+
if (v.renaming && rn) return ('<form class="workspace-thread-row renaming" data-form="' + rn.form + '"><label class="sr" for="row-rename">' + h(tc('threadRow.name')) + '</label><input class="input" id="row-rename" value="') + h(v.title) + ('" maxlength="200" data-path="' + h(rn.path) + '" data-on-esc="close" data-on-blur="' + rn.blur + '"></form>');
|
|
384
|
+
/* 一项状态:可以带身份(who,颜色是这一项自己的能力,取不到就是组件的中性默认)和执行状态(status,和头像的圈读同一张表);
|
|
385
|
+
runs:一条对话里有几只猫同时在执行时,按节拍轮流显示(通用轮换 data-rot,悬停不换) */
|
|
386
|
+
const one = function (m) { const tn = TROW_TONE[m.tone]; const c = m.who ? whoInfo(m.who).color : '', st = c ? '--c:' + c : '';
|
|
387
|
+
/* 执行中:圆点是唯一的 .dot(run 色调:身份色 + 状态表的颜色和节奏),不再用伪元素画 */
|
|
388
|
+
const dt = tn && tn.dot ? '<span class="dot" data-tone="run"' + (m.who ? ' data-live="' + h(m.who) + '" data-status="' + h(m.status || '') + '"' : m.status ? ' data-status="' + h(m.status) + '"' : '') + (st ? ' style="' + st + '"' : '') + '></span>' : '';
|
|
389
|
+
return tn ? '<span class="' + tn.cls + '"' + (m.who ? ' data-k="' + h(m.who) + '"' : '') + '>' + dt + h(m.text) + '</span>' : '<span>' + h(m.text) + '</span>'; }; /* data-k:这一项是谁(树键的一段)——轮换里换了顺序,节拍也按成员认,不按位置 */
|
|
390
|
+
const state = [];
|
|
391
|
+
if (v.hub) state.push({ text: tc('threadRow.meta.hub') });
|
|
392
|
+
if (v.bedroom) state.push({ text: tc('threadRow.meta.bedroom') });
|
|
393
|
+
if (v.runs && v.runs.length) state.push({ runs: v.runs.map(function (r) { return { who: r.who, status: r.status, tone: 'run', text: tc('threadRow.meta.run', whoInfo(r.who).name, Math.max(1, Math.round((r.secs || 0) / 60))) }; }) });
|
|
394
|
+
else if (v.failed) state.push({ text: tc('common.status.error'), tone: 'err' });
|
|
395
|
+
else if (v.running && v.who) state.push({ text: tc('threadRow.meta.running', whoInfo(v.who).name) });
|
|
396
|
+
else if (v.note || v.restored) state.push({ text: rn && rn.note ? pv(rn.note, v, root) : v.note });
|
|
397
|
+
else if (v.lastWho) state.push({ text: tc('threadRow.meta.replied', whoInfo(v.lastWho).name) });
|
|
398
|
+
const meta = (v.fav ? ['<span class="workspace-row-star" data-tip="' + h(tc('threadRow.starred')) + '">' + icon('star', 12) + '</span>'] : []).concat(state.map(function (m) {
|
|
399
|
+
if (!m.runs || m.runs.length < 2) return one(m.runs ? m.runs[0] : m);
|
|
400
|
+
return rotHtml('span', 'trow-rot', m.runs.map(function (r) { return one(r); })); }));
|
|
401
|
+
const n = (v.unread || 0) + (v.pending || 0), tip = [v.unread ? tc('threadRow.unread', v.unread) : '', v.pending ? tc('threadRow.pending', v.pending) : '', v.at ? tc('threadRow.mention', v.mention) : ''].filter(Boolean).join(' · ');
|
|
402
|
+
const bdg = n || v.at ? badge(n || true, { at: v.at, tip: tip }) : '';
|
|
403
|
+
/* 时间和草稿是同一格的状态(有草稿时显示“草稿”,主题色):悬停时一起让位给操作 */
|
|
404
|
+
const stamp = v.draft && !bdg ? '<span class="trow-draft">' + h(tc('common.status.draft')) + '</span>' : h(rn && rn.time ? pv(rn.time, v, root) : v.time || '');
|
|
405
|
+
/* 一行对话就是一行 lrow:标题 · 第二行状态;行尾按行对齐(时间 / 计数),悬停的“更多”出现在时间的位置上(同一位置互斥);置顶是左上角的标记 */
|
|
406
|
+
return lrow({ layout: 'item', hook: 'workspace-thread-row' + (v.pinned ? ' pinned' : ''), rootAttrs: ' data-tid="' + h(v.id) + '"' + (movable ? ' data-edit="move" data-move-key="' + h(v.id) + '"' : ''), act: 'thread', data: ' data-id="' + h(v.id) + '"', headAttrs: ' data-tip="' + h(v.title) + '"',
|
|
407
|
+
cur: v.cur ? 'page' : false, title: h(v.title), sub: meta.length ? meta.join(' · ') : '​', aside: [stamp, bdg], swap: true, /* 状态行总在:没有状态时留空一行,所有对话行一样高 */
|
|
408
|
+
actsHtml: rn && rn.more ? (rn.acts || []).map(function (c) { return pvControl(c, v, root); }).join('') + rowMore(menuLive(rowMenuItems(rn.more.items, v, root)), v.id, pv(rn.more.label, v, root)) : '', /* 悬停时换上来的:声明的操作按钮(acts)+ 更多 */
|
|
409
|
+
acts: rn && rn.more ? [] : [{ icon: 'more', label: tc('threadRow.more', v.title), act: 'menu', data: ' data-menu="' + (rn && rn.menu || '') + '" data-k="' + h(v.id) + '"' }],
|
|
410
|
+
/* 置顶是左上角的标记;主题声明了 pin 就是开关:置顶了一直在,没置顶时悬停这一行才出现,点一下切换(不占行尾的操作位,不挡标题) */
|
|
411
|
+
pre: rn && rn.pin ? '<button type="button" class="lr-pin"' + actAttrs(rn.pin.act, pvArgsObj(rn.pin.args, v, root)) + ' aria-pressed="' + !!v.pinned + '" data-tip="' + h(pv(rn.pin.label, v, root)) + '" aria-label="' + h(pv(rn.pin.label, v, root)) + '">' + icon('pin', 12) + '</button>'
|
|
412
|
+
: v.pinned ? '<span data-tip="' + h(tc('threadRow.pinned')) + '" aria-label="' + h(tc('threadRow.pinned')) + '">' + icon('pin', 12) + '</span>' : '',
|
|
413
|
+
preLive: !!(rn && rn.pin) });
|
|
414
|
+
}
|
|
415
|
+
/* 行 / 行内的更多按钮仍是同一个 rowMore;只把菜单项与插槽按声明展开。 */
|
|
416
|
+
function rowMenuItems(items, data, root) { return items.flatMap(function (it) { return it.slot ? pdlMenuItems(it.slot, pvArgsObj(it.args, data, root)) : pvMenu([it], data, root); }); }
|
|
417
|
+
PDL_COMPONENTS.rowMore = function (p, sc, root) { return rowMore(menuLive(rowMenuItems(p.items, sc, root)), pv(p.k, sc, root), pv(p.label, sc, root)); };
|
|
418
|
+
PDL_COMPONENTS.rowMore.catalog = { g: 'rows', view: 'chat.header', get props() { return pdlLoc(pdlQuery({ type: 'component' }).find(function (n) { return n.node.use === 'rowMore'; }).node.props); } };
|
|
419
|
+
/* 段头(组件库,一个形式;置顶、最近、项目、对话组都是它):三格——标题 ·(空白)· [数量 ⇄ 段的操作(项目的 + ⋯)] · 状态箭头(› 收起 / ⌄ 展开)。数量和操作同一格互斥,悬停时操作换上来;箭头是自己的一格,不参与互斥;点了收起 / 展开整段;右边悬停出现段的操作。
|
|
420
|
+
置顶、最近、对话组、项目都是它——不同的只是图标和点了交给谁 */
|
|
421
|
+
function secHead(o) {
|
|
422
|
+
/* 整个头是开合的那一下(role=button,和可点的行一样);段的操作(⋯、+)是它旁边的兄弟格子,不叠在开合按钮上面 */
|
|
423
|
+
return '<div class="workspace-group-heading" role="button" tabindex="0"' + (o.act ? ' data-act="' + o.act + '"' : '') + (o.data || '') + ' aria-expanded="' + !!o.open + '"' + (o.tip ? ' data-tip="' + h(o.tip) + '"' : '') + (o.note ? ' data-note="' + o.note + '"' : '') + '><span class="workspace-group-button"><span class="workspace-group-lead">' + icon(o.icon, 14) + '<span class="n">' + h(o.name) + '</span>' + (o.extra || '') + '</span>' + (o.n != null ? qty(o.n) : '') + twisty(o.open) + '</span>' + (o.acts ? '<span class="workspace-group-actions">' + o.acts + '</span>' : '') + '</div>';
|
|
424
|
+
}
|
|
425
|
+
/* 段头的绑定在主题的 threads 块里声明(heads[种类] = { icon, act, args, more: { menu, label }, add: { act, args } },参数里的 @字段 取段头的数据):
|
|
426
|
+
点表头改哪个状态、⋯ 打开哪个菜单、+ 去哪,组件不认识。kind = sec 的段自己开合(折叠组件的 fold sec),图标按段的 key 声明 */
|
|
427
|
+
function threadSecHead(hd, dc, root) {
|
|
428
|
+
const d = (dc.heads || {})[hd.kind] || {}, ic = d.icon && typeof d.icon === 'object' ? d.icon[hd.key] || d.icon['*'] : d.icon;
|
|
429
|
+
if (hd.kind === 'sec') return secHead({ act: 'fold', data: ' data-f="sec" data-k="' + h(hd.key) + '"' + (hd.dflt ? ' data-dflt="1"' : ''), open: !hd.collapsed, icon: ic, name: tc('threadRow.section', hd.key), n: hd.n, note: hd.note });
|
|
430
|
+
const more = d.more ? rowMore(d.more.items ? menuLive(pvMenu(d.more.items, hd, root)) : d.more.menu, hd.id, pv(d.more.label, hd, root), 'workspace-group-hover') : '', add = hd.add && d.add ? btn(pv(d.add.label, hd, root), { iconOnly: true, icon: 'plus', sm: true, act: d.add.act, data: pvArgs(d.add.args, hd, root), cls: 'workspace-group-hover' }) : '';
|
|
431
|
+
return secHead({ act: d.act, data: pvArgs(d.args, hd, root), open: hd.open, icon: ic, name: hd.unassigned ? tc('threadRow.unassigned') : hd.name, tip: hd.tip, n: hd.n,
|
|
432
|
+
extra: (hd.warn ? lrDot('warn', hd.warn) : '') + (hd.fixed ? '<span class="t-s faint">' + h(tc('threadRow.fixed')) + '</span>' : ''), acts: hd.add ? add + more : more });
|
|
433
|
+
}
|
|
434
|
+
/* dc:threads 块的声明(groups 每种段的默认、heads 段头的绑定、other「其他项目」那一段的开合、rename 行的原地改名)。
|
|
435
|
+
「其他项目」是同一种段头(名字 · 数量 · 箭头),点了展开的是它下面的几段(other.sections) */
|
|
436
|
+
function threadSections(list, dc, root, renderRows, parent = []) {
|
|
437
|
+
dc = dc || {}; const groups = dc.groups || {};
|
|
438
|
+
const keys = renderRows && typeof pdlUnitKeys === 'function' && pdlUnitKeys(list, pvItemKey);
|
|
439
|
+
return (list || []).map(function (s, index) {
|
|
440
|
+
const path = keys && parent.concat(keys[index]);
|
|
441
|
+
const dflt = (groups || {})[String(s.key || '').split(':')[0]] || {};
|
|
442
|
+
if (s.other) { const d = dc.other || {}; return secHead({ act: d.act, data: pvArgs(d.args, s.other, root), open: s.other.open, name: tc('threadRow.otherProjects'), n: s.other.n }) + (s.other.open ? threadSections(s.other.sections, dc, root, keys && renderRows, path) : ''); }
|
|
443
|
+
/* move(主题声明的动作):对话能拖进别的分组、拖出到不分组的段;段是放下的容器(data-move-act + 它是哪一段);rowDrop(段的数据):放在这一段的行上是插进先后(insert)还是放到那一行上(onto) */
|
|
444
|
+
const mvAct = dc.move ? pv(dc.move, root, root) : '', mv = !!mvAct;
|
|
445
|
+
const rows = function (items, slot) { return path ? renderRows(items, path.concat(slot), mv) : items.map(function (v) { return threadRow(v, dc.rename, root, mv); }); };
|
|
446
|
+
return gsection({ key: s.key, collapsed: s.collapsed, dflt: !!dflt.collapsed, step: dflt.limit, rows: rows(s.rows, 'rows'), peek: rows(s.peek || [], 'peek'), empty: s.empty ? emptyState(tc('threadRow.empty', s.empty)) : '',
|
|
447
|
+
attrs: (s.gid ? ' data-gid="' + h(s.gid) + '"' : '') + (mv ? ' data-move="threads" data-move-act="' + h(mvAct) + '" data-to="' + h(s.gid || '') + '"' + (s.rowDrop ? ' data-move-rows="' + h(s.rowDrop) + '"' : '') : ''), head: threadSecHead(Object.assign({ key: s.key, collapsed: s.collapsed != null ? s.collapsed : secCollapsed(s.key, !!dflt.collapsed), dflt: !!dflt.collapsed }, s.head), dc, root) });
|
|
448
|
+
}).join('');
|
|
449
|
+
}
|
|
450
|
+
function gsection(o) {
|
|
451
|
+
const key = o.key, rows = o.rows || [], n = SEC_COUNT[o.step || 'l'];
|
|
452
|
+
const collapsed = o.collapsed != null ? !!o.collapsed : secCollapsed(key, !!o.dflt), more = !!(secSt(key) && secSt(key).m);
|
|
453
|
+
/* 所有行都画出来,收起 / “还有 N 条”只改段上的属性(data-collapsed / data-more),点开关是本地更新、不重画:
|
|
454
|
+
展开时露 .gsec-rows(多出的几条在 .gsec-x 里,data-more 时才露);收起时只露 .gsec-peek(需要注意的那几行) */
|
|
455
|
+
const fold = rows.length > n ? secMoreTg(key, more, rows.length - n) : '';
|
|
456
|
+
return '<section class="gsec" data-sec="' + h(key) + '"' + (collapsed ? ' data-collapsed' : '') + (more ? ' data-more' : '') + (o.attrs || '') + '><div class="gsec-h">' + o.head + '</div><div class="gsec-b">' +
|
|
457
|
+
'<div class="gsec-rows">' + (rows.slice(0, n).join('') || (o.empty || '')) + (rows.length > n ? '<div class="gsec-x">' + rows.slice(n).join('') + '</div>' : '') + fold + '</div>' +
|
|
458
|
+
'<div class="gsec-peek">' + (o.peek || []).join('') + '</div></div></section>';
|
|
459
|
+
}
|
|
460
|
+
function secMoreTg(key, more, extra) { return foldTg(more, 'fold', ' data-f="more" data-k="' + h(key) + '"', more ? '' : tc('fold.moreHtml', '<span class="num">' + extra + '</span>'), more ? tc('common.collapse') : '', 'bottom'); }
|
|
461
|
+
/* 段的收起 / 展开:本地更新(段的属性 + 表头箭头),不重画整页。对话组、项目的表头也走它(状态各自存,DOM 一样改) */
|
|
462
|
+
function secFlip(el, collapsed) {
|
|
463
|
+
const sec = el && el.closest('.gsec'); if (!sec) { render(true); return; }
|
|
464
|
+
sec.toggleAttribute('data-collapsed', collapsed);
|
|
465
|
+
const b = sec.querySelector(':scope > .gsec-h .workspace-group-heading'); if (b) { b.setAttribute('aria-expanded', String(!collapsed)); }
|
|
466
|
+
}
|
|
467
|
+
function foldSec(d, el) { const st = secSt(d.k, true); st.c = !secCollapsed(d.k, d.dflt === '1'); secSave(); secFlip(el, st.c); };
|
|
468
|
+
function foldMore(d, el) {
|
|
469
|
+
const st = secSt(d.k, true); st.m = !st.m; secSave();
|
|
470
|
+
const sec = el && el.closest('.gsec'); if (!sec) { render(true); return; }
|
|
471
|
+
sec.toggleAttribute('data-more', st.m); el.outerHTML = secMoreTg(d.k, st.m, sec.querySelectorAll(':scope .gsec-x > *').length);
|
|
472
|
+
};
|
|
473
|
+
/* A data table with an optional action on each row heading. Values are plain text. */
|
|
474
|
+
PDL_COMPONENTS.dataTable = function (p) {
|
|
475
|
+
const cell = function (tag, value, numeric, attrs) {
|
|
476
|
+
return '<' + tag + (numeric ? ' class="num" data-numeric' : '') + (attrs || '') + '>' + value + '</' + tag + '>';
|
|
477
|
+
};
|
|
478
|
+
const head = p.columns.map(function (column) { return cell('th', h(column.label), column.numeric, ' scope="col"'); }).join('');
|
|
479
|
+
const body = p.rows.map(function (row) {
|
|
480
|
+
const title = row.open
|
|
481
|
+
? btn(row.label, { link: true, sm: true, act: row.open.act, data: argAttrs(row.open.args) })
|
|
482
|
+
: '<span class="pdl-ellipsis">' + h(row.label) + '</span>';
|
|
483
|
+
const values = row.cells.map(function (value, i) {
|
|
484
|
+
return cell('td', h(value.text), p.columns[i + 1].numeric, value.tip ? ' data-tip="' + h(value.tip) + '"' : '');
|
|
485
|
+
}).join('');
|
|
486
|
+
return '<tr>' + cell('th', title, false, ' scope="row"') + values + '</tr>';
|
|
487
|
+
}).join('');
|
|
488
|
+
return '<div class="group data-table' + (p.compact ? ' compact' : '') + '"><table aria-label="' + h(p.label) + '"><thead><tr>' + head + '</tr></thead><tbody>' + body + '</tbody></table></div>';
|
|
489
|
+
};
|
|
490
|
+
|
|
491
|
+
/* A titled list of source choices: optional warning, one state column when any row has one,
|
|
492
|
+
and the same number of action slots on every row so subgrid tracks stay aligned. */
|
|
493
|
+
PDL_COMPONENTS.sourceChoices = function (p) {
|
|
494
|
+
if (!p) return '';
|
|
495
|
+
const rows = Array.isArray(p.rows) ? p.rows : [];
|
|
496
|
+
const warning = p.warning ? '<div class="prose vw-md">' + mdLite(String(p.warning)) + '</div>' : '';
|
|
497
|
+
if (!warning && !rows.length) return '';
|
|
498
|
+
const hasState = rows.some(function (r) { return !!(r && r.state); });
|
|
499
|
+
const maxActions = rows.reduce(function (m, r) { return Math.max(m, r && Array.isArray(r.actions) ? r.actions.length : 0); }, 0);
|
|
500
|
+
const items = rows.map(function (row) {
|
|
501
|
+
row = row || {};
|
|
502
|
+
const cols = [];
|
|
503
|
+
if (hasState) cols.push({ w: 'state', v: row.state ? h(row.state) : '' });
|
|
504
|
+
for (let i = 0; i < maxActions; i++) {
|
|
505
|
+
const action = row.actions && row.actions[i];
|
|
506
|
+
cols.push({ w: 'ctl', v: action ? btn(action.label, { sm: true, act: action.act, data: argAttrs(action.args) }) : '' });
|
|
507
|
+
}
|
|
508
|
+
return {
|
|
509
|
+
layout: 'two', key: row.id, title: h(row.title), sub: row.sub ? h(row.sub) : '',
|
|
510
|
+
act: row.open ? row.open.act : '', data: row.open ? argAttrs(row.open.args) : '', cols: cols,
|
|
511
|
+
};
|
|
512
|
+
});
|
|
513
|
+
return section({ title: p.title, body: warning + (items.length ? lrList(p.id || 'source-choices', items) : '') });
|
|
514
|
+
};
|
|
515
|
+
|
|
516
|
+
/* ───────── 目录登记:这个文件里的组件 ───────── */
|
|
517
|
+
Object.assign(LIB_CATALOG, {
|
|
518
|
+
lrow: { g: 'rows', via: ['type:list', 'type:settings'], ex: function (s) { return '<div class="group lr-list">' + s.rows.map(function (r) { return lrow({ layout: 'two', title: h(r.title), sub: h(r.sub), act: 'noop' }); }).join('') + '</div>'; } },
|
|
519
|
+
ltree: { g: 'rows', via: ['type:tree'], ex: function (s) { return ltree('catalog-ltree', function (p) { return (s.tree[p] || []).map(function (n) { return { name: n.name, path: n.path, dir: n.dir, row: { title: '<span class="mono">' + h(n.name) + '</span>' } }; }); }, {}); } },
|
|
520
|
+
threadRow: { g: 'rows', via: ['type:threads'], ex: function (s) { return '<div class="workspace-threads">' + s.threads[0].rows.map(threadRow).join('') + '</div>'; } },
|
|
521
|
+
gsection: { g: 'rows', via: ['type:threads'], ex: function (s) { return threadSections(s.threads, {}); } },
|
|
522
|
+
popEntry: { g: 'popups', via: ['type:opts'], ex: function (s) { return '<div class="pop-list cat-pop">' + s.pop.map(popEntry).join('') + '</div>'; } }
|
|
523
|
+
});
|