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.
- 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 +919 -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 +132 -0
- package/dist/plugins/model-profiles/rules.js +767 -0
- package/dist/plugins/model-profiles/skills/model-profile/SKILL.md +60 -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 +104 -0
- package/dist/plugins/model-profiles/storage.js +352 -0
- package/dist/plugins/model-profiles/types.d.ts +187 -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 +458 -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 +276 -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,214 @@
|
|
|
1
|
+
/* 通用标签搜索:输入框 + 可叠加、可删除的条件标签。使用方给 key、placeholder 和 types;
|
|
2
|
+
范围(当前主题 / 当前主题与父主题 / 全部主题)是自带的,默认带「当前主题」,删掉就是全部。
|
|
3
|
+
条件类型可以 multiple(同类型可多选)或 date(今天 / 昨天 / 近 7 天 / 近 30 天,再加自选日期)。
|
|
4
|
+
状态按 key 记在 S.labelSearch 里,使用方用 labelSearchValue(key) 读 q 和条件,不各写一套搜索框。 */
|
|
5
|
+
'use strict';
|
|
6
|
+
S.labelSearch = S.labelSearch || {};
|
|
7
|
+
const LABEL_SEARCH_POP = 'labelSearch';
|
|
8
|
+
let labelSearchPicker = null;
|
|
9
|
+
const LABEL_SEARCH_SCOPE = [
|
|
10
|
+
{ id: 'topic', label: 'labelSearch.current' },
|
|
11
|
+
{ id: 'lineage', label: 'labelSearch.parents' },
|
|
12
|
+
{ id: 'all', label: 'labelSearch.all' }
|
|
13
|
+
];
|
|
14
|
+
function labelSearchState(key, defaultScope) {
|
|
15
|
+
return S.labelSearch[key] || (S.labelSearch[key] = { q: '', type: '',
|
|
16
|
+
conds: defaultScope === false ? [] : [{ type: 'scope', id: defaultScope || 'topic' }] });
|
|
17
|
+
}
|
|
18
|
+
function labelSearchValue(key, opts) { return labelSearchState(key, opts && opts.defaultScope); }
|
|
19
|
+
function labelSearchClear(key) {
|
|
20
|
+
if (labelSearchPicker === S.labelSearch[key]) labelSearchDismiss();
|
|
21
|
+
delete S.labelSearch[key];
|
|
22
|
+
}
|
|
23
|
+
function labelSearchScopeLabel(id) {
|
|
24
|
+
const hit = LABEL_SEARCH_SCOPE.find(function (x) { return x.id === id; });
|
|
25
|
+
return tc(hit ? hit.label : 'labelSearch.all');
|
|
26
|
+
}
|
|
27
|
+
function labelSearchTypes(p) {
|
|
28
|
+
const types = (p.types || []).slice();
|
|
29
|
+
if (p.scope !== false) types.unshift({ id: 'scope', label: tc('labelSearch.scope'), icon: 'layers',
|
|
30
|
+
values: LABEL_SEARCH_SCOPE.map(function (x) { return { id: x.id, label: tc(x.label) }; }) });
|
|
31
|
+
return types;
|
|
32
|
+
}
|
|
33
|
+
function labelSearchYmd(date) {
|
|
34
|
+
const m = date.getMonth() + 1, d = date.getDate();
|
|
35
|
+
return date.getFullYear() + '-' + (m < 10 ? '0' : '') + m + '-' + (d < 10 ? '0' : '') + d;
|
|
36
|
+
}
|
|
37
|
+
function labelSearchDaysAgo(days) {
|
|
38
|
+
const date = new Date();
|
|
39
|
+
date.setDate(date.getDate() - days);
|
|
40
|
+
return labelSearchYmd(date);
|
|
41
|
+
}
|
|
42
|
+
function labelSearchCond(d) {
|
|
43
|
+
const cond = { type: d.type, id: d.id };
|
|
44
|
+
if (d.since) cond.since = d.since;
|
|
45
|
+
if (d.until) cond.until = d.until;
|
|
46
|
+
return cond;
|
|
47
|
+
}
|
|
48
|
+
function labelSearchChipLabel(cond, types) {
|
|
49
|
+
if (cond.type === 'scope') return labelSearchScopeLabel(cond.id);
|
|
50
|
+
const type = types.find(function (x) { return x.id === cond.type; });
|
|
51
|
+
const value = type && type.values.find(function (x) { return x.id === cond.id; });
|
|
52
|
+
return value ? value.label : cond.id;
|
|
53
|
+
}
|
|
54
|
+
function labelSearchChipLead(cond, types) {
|
|
55
|
+
if (cond.type === 'scope') return icon('layers', 12);
|
|
56
|
+
if (cond.type === 'member' && cond.id) return cond.id === '@me' ? icon('at', 12) : whoAva(cond.id, { size: 'xs', tip: false });
|
|
57
|
+
const type = types.find(function (x) { return x.id === cond.type; });
|
|
58
|
+
return icon(type && type.icon || 'filter', 12);
|
|
59
|
+
}
|
|
60
|
+
function labelSearchConds(st, types) {
|
|
61
|
+
return st.conds.map(function (cond) {
|
|
62
|
+
const label = labelSearchChipLabel(cond, types);
|
|
63
|
+
return '<span class="chip label-search-chip">' + labelSearchChipLead(cond, types) + '<span>' + h(label) + '</span>' +
|
|
64
|
+
chipX('labelSearchRemove', argAttrs({ key: st.key, type: cond.type, id: cond.id }), tc('labelSearch.remove', label)) + '</span>';
|
|
65
|
+
}).join('');
|
|
66
|
+
}
|
|
67
|
+
function labelSearchMenu(st, types) {
|
|
68
|
+
const key = st.key, cls = 'pop label-search-menu', label = tc('labelSearch.add');
|
|
69
|
+
const type = types.find(function (x) { return x.id === st.type; });
|
|
70
|
+
if (!type) {
|
|
71
|
+
const body = types.map(function (t) {
|
|
72
|
+
return lrow({ layout: 'record', act: 'labelSearchType', data: argAttrs({ key: key, type: t.id }), lead: icon(t.icon || 'filter', 14), title: h(t.label) });
|
|
73
|
+
}).join('');
|
|
74
|
+
return floatHtml({ cls: cls, label: label, body: body });
|
|
75
|
+
}
|
|
76
|
+
const back = btn(tc('labelSearch.back'), { iconOnly: true, sm: true, icon: 'left', act: 'labelSearchType', data: argAttrs({ key: key, type: '' }) });
|
|
77
|
+
const rows = type.values.length ? type.values.map(function (v) {
|
|
78
|
+
const since = type.date && v.days !== undefined ? labelSearchDaysAgo(v.days) : v.since;
|
|
79
|
+
const until = type.date && v.untilDays !== undefined ? labelSearchDaysAgo(v.untilDays) : v.until;
|
|
80
|
+
return lrow({ layout: 'record', act: 'labelSearchPick',
|
|
81
|
+
data: argAttrs({ key: key, type: type.id, id: v.id, since: since, until: until, multi: type.multiple ? '1' : undefined }),
|
|
82
|
+
lead: v.who ? whoAva(v.who, { size: 'sm', tip: false }) : v.icon ? icon(v.icon, 14) : '',
|
|
83
|
+
title: h(v.label), sub: v.sub ? h(v.sub) : '', cur: st.conds.some(function (c) { return c.type === type.id && c.id === v.id; }) });
|
|
84
|
+
}).join('') : '<div class="label-search-empty">' + h(tc('labelSearch.none')) + '</div>';
|
|
85
|
+
const date = type.date
|
|
86
|
+
? dateCtl({ id: 'label-search-date-' + key, input: 'hlLabelSearchDate', data: argAttrs({ key: key, type: type.id }), label: tc('labelSearch.pickDate') })
|
|
87
|
+
: '';
|
|
88
|
+
return floatHtml({ cls: cls, label: label, head: back + '<span class="u-strong">' + h(type.label) + '</span>', body: rows, foot: date });
|
|
89
|
+
}
|
|
90
|
+
POPUPS[LABEL_SEARCH_POP] = function () { return labelSearchPicker?.menu() || ''; };
|
|
91
|
+
function labelSearchPopup() { return document.querySelector(POP_SEL + '[data-pop="' + LABEL_SEARCH_POP + '"]'); }
|
|
92
|
+
function labelSearchField() { return anchorEl(POP_TRIG[LABEL_SEARCH_POP]); }
|
|
93
|
+
function labelSearchFocus() { labelSearchField()?.focus({ preventScroll: true }); }
|
|
94
|
+
function labelSearchOpen(field) {
|
|
95
|
+
const st = labelSearchState(field.dataset.key);
|
|
96
|
+
if (!st.menu) return;
|
|
97
|
+
if (labelSearchPicker === st) { popRaise(LABEL_SEARCH_POP); return; }
|
|
98
|
+
labelSearchPicker = st;
|
|
99
|
+
st.type = '';
|
|
100
|
+
popAnchor(LABEL_SEARCH_POP, field.parentElement);
|
|
101
|
+
const from = ACT_FROM;
|
|
102
|
+
ACT_FROM = field;
|
|
103
|
+
try { popRefresh(LABEL_SEARCH_POP); } finally { ACT_FROM = from; }
|
|
104
|
+
}
|
|
105
|
+
function labelSearchDismiss(returnFocus) {
|
|
106
|
+
if (!labelSearchPicker) return;
|
|
107
|
+
if (returnFocus && labelSearchPopup()?.contains(document.activeElement)) labelSearchFocus();
|
|
108
|
+
labelSearchPicker = null;
|
|
109
|
+
popRefresh(LABEL_SEARCH_POP);
|
|
110
|
+
}
|
|
111
|
+
/* Focus can move to an owned popup before returning to the search field. */
|
|
112
|
+
let labelSearchRestoringFocus = false;
|
|
113
|
+
beforeRender(function () { labelSearchRestoringFocus = document.activeElement?.matches('.label-search-in'); });
|
|
114
|
+
onRender(function () { labelSearchRestoringFocus = false; });
|
|
115
|
+
document.addEventListener('focusin', function (e) {
|
|
116
|
+
if (!RENDERING && !labelSearchRestoringFocus && e.target.matches('.label-search-in')) labelSearchOpen(e.target);
|
|
117
|
+
});
|
|
118
|
+
document.addEventListener('click', function (e) {
|
|
119
|
+
if (e.target.matches('.label-search-in')) labelSearchOpen(e.target);
|
|
120
|
+
});
|
|
121
|
+
document.addEventListener('focusout', function (e) {
|
|
122
|
+
if (RENDERING || !labelSearchPicker) return;
|
|
123
|
+
const field = labelSearchField();
|
|
124
|
+
if (e.target !== field && !popWithin(LABEL_SEARCH_POP, e.target)) return;
|
|
125
|
+
if (e.relatedTarget !== field && !(e.relatedTarget && popWithin(LABEL_SEARCH_POP, e.relatedTarget))) labelSearchDismiss();
|
|
126
|
+
});
|
|
127
|
+
KEY_FNS.push(function (e) {
|
|
128
|
+
if (e.isComposing || (e.key !== 'ArrowDown' && e.key !== 'ArrowUp') || e.target.matches('.date-trigger')) return false;
|
|
129
|
+
const field = e.target.matches('.label-search-in');
|
|
130
|
+
if (field) labelSearchOpen(e.target);
|
|
131
|
+
const pop = labelSearchPopup();
|
|
132
|
+
if (!pop || (!field && !pop.contains(e.target))) return false;
|
|
133
|
+
const items = Array.from(pop.querySelectorAll('.lr-head[data-act]'));
|
|
134
|
+
const i = keyStep(e, items.indexOf(e.target), items.length, { wrap: true });
|
|
135
|
+
if (i === null) return false;
|
|
136
|
+
e.preventDefault();
|
|
137
|
+
items[i].focus({ preventScroll: true });
|
|
138
|
+
keySelShow(items[i]);
|
|
139
|
+
return true;
|
|
140
|
+
});
|
|
141
|
+
function labelSearchFire(st) {
|
|
142
|
+
if (st.change && st.change !== '' && actFn(st.change)) actFn(st.change)();
|
|
143
|
+
}
|
|
144
|
+
PDL_COMPONENTS.labelSearch = function (p, sc, root) {
|
|
145
|
+
const P = function (x) { return sc || root ? pv(x, sc, root) : x; };
|
|
146
|
+
const key = P(p.key) || 'search', inputId = P(p.inputId) || 'label-search-' + key;
|
|
147
|
+
const scope = P(p.scope);
|
|
148
|
+
const st = labelSearchState(key, scope === false ? false : P(p.defaultScope)); st.key = key; st.change = P(p.change) || '';
|
|
149
|
+
const types = labelSearchTypes({ types: P(p.types), scope: scope });
|
|
150
|
+
st.menu = types.length ? function () { return labelSearchMenu(st, types); } : null;
|
|
151
|
+
const placeholder = P(p.placeholder) || tc('labelSearch.placeholder');
|
|
152
|
+
const enter = P(p.enter) ? ' data-on-enter="' + h(P(p.enter)) + '"' : '';
|
|
153
|
+
return '<div class="label-search"><div class="label-search-box" data-k="' + h(key) + '">' + icon('search', 14) + labelSearchConds(st, types) +
|
|
154
|
+
'<input id="' + h(inputId) + '" class="label-search-in" type="search" value="' + h(st.q) + '" placeholder="' + h(placeholder) + '" aria-label="' + h(placeholder) + '" data-input="hlLabelSearch" data-key="' + h(key) + '"' +
|
|
155
|
+
(types.length ? ' aria-haspopup="dialog"' : '') + enter + ' autocomplete="off"></div></div>';
|
|
156
|
+
};
|
|
157
|
+
Object.assign(A, {
|
|
158
|
+
labelSearchClose: function () { labelSearchDismiss(true); },
|
|
159
|
+
labelSearchType: function (d) {
|
|
160
|
+
const st = labelSearchState(d.key);
|
|
161
|
+
st.type = d.type;
|
|
162
|
+
if (labelSearchPicker === st) { labelSearchFocus(); popRefresh(LABEL_SEARCH_POP); }
|
|
163
|
+
},
|
|
164
|
+
labelSearchPick: function (d) {
|
|
165
|
+
if (!d || !d.type) return;
|
|
166
|
+
const st = labelSearchState(d.key), multi = d.multi === '1';
|
|
167
|
+
if (multi) {
|
|
168
|
+
const had = st.conds.some(function (c) { return c.type === d.type && c.id === d.id; });
|
|
169
|
+
st.conds = st.conds.filter(function (c) { return !(c.type === d.type && c.id === d.id); });
|
|
170
|
+
if (!had) st.conds.push(labelSearchCond(d));
|
|
171
|
+
st.type = d.type;
|
|
172
|
+
} else {
|
|
173
|
+
st.conds = st.conds.filter(function (c) { return c.type !== d.type; });
|
|
174
|
+
if (!(d.type === 'scope' && d.id === 'all')) st.conds.push(labelSearchCond(d));
|
|
175
|
+
if (labelSearchPicker === st) labelSearchDismiss(true);
|
|
176
|
+
}
|
|
177
|
+
render(true);
|
|
178
|
+
labelSearchFire(st);
|
|
179
|
+
},
|
|
180
|
+
labelSearchRemove: function (d) {
|
|
181
|
+
if (!d || !d.type) return;
|
|
182
|
+
const st = labelSearchState(d.key);
|
|
183
|
+
st.conds = st.conds.filter(function (c) { return d.id === undefined ? c.type !== d.type : !(c.type === d.type && c.id === d.id); });
|
|
184
|
+
render(true);
|
|
185
|
+
labelSearchFire(st);
|
|
186
|
+
}
|
|
187
|
+
});
|
|
188
|
+
INPUTS.hlLabelSearch = function (e) {
|
|
189
|
+
const st = labelSearchState(e.target.dataset.key);
|
|
190
|
+
st.q = e.target.value;
|
|
191
|
+
render(true);
|
|
192
|
+
};
|
|
193
|
+
INPUTS.hlLabelSearchDate = function (e) {
|
|
194
|
+
const date = e.target.value, st = labelSearchState(e.target.dataset.key);
|
|
195
|
+
if (!date) return;
|
|
196
|
+
st.conds = st.conds.filter(function (c) { return c.type !== e.target.dataset.type; });
|
|
197
|
+
st.conds.push({ type: e.target.dataset.type, id: date, since: date });
|
|
198
|
+
if (labelSearchPicker === st) labelSearchDismiss(true);
|
|
199
|
+
render(true);
|
|
200
|
+
labelSearchFire(st);
|
|
201
|
+
};
|
|
202
|
+
|
|
203
|
+
PDL_COMPONENTS.hlChatSearchResults = function (model) {
|
|
204
|
+
const { results, labels, hitAction, moreAction } = model;
|
|
205
|
+
let rows = results.hits.map(function (hit) {
|
|
206
|
+
const title = h(hit.before) + (hit.match ? '<mark>' + h(hit.match) + '</mark>' : '') + h(hit.after);
|
|
207
|
+
return lrow({ layout: 'two', key: hit.id, title: title, sub: h(hit.sub), act: hitAction, data: argAttrs({ tid: hit.topicId, mid: hit.id }) });
|
|
208
|
+
}).join('');
|
|
209
|
+
if (results.loading) rows += PDL_COMPONENTS.loadingStatus(labels.loading);
|
|
210
|
+
else if (results.failed) rows += '<div class="hl-find-status" role="status">' + h(labels.failed) + ' ' + btn(labels.retry, { sm: true, act: moreAction }) + '</div>';
|
|
211
|
+
else if (!rows) rows = '<div class="hl-find-status" role="status">' + h(labels.empty) + '</div>';
|
|
212
|
+
if (results.more && !results.loading && !results.failed) rows += '<div class="hl-find-status">' + btn(labels.more, { sm: true, act: moreAction }) + '</div>';
|
|
213
|
+
return '<div id="hl-find-results" role="region" aria-label="' + h(labels.results) + '" aria-busy="' + results.loading + '">' + rows + '</div>';
|
|
214
|
+
};
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
/* The console and document tools share the Markdown grammar. Console link and identity decorations are supplied by the caller. */
|
|
2
|
+
'use strict';
|
|
3
|
+
function mdEscape(text) {
|
|
4
|
+
return text.replace(/[&<>"]/g, (c) => ({ '&': '&', '<': '<', '>': '>', '"': '"' })[c]);
|
|
5
|
+
}
|
|
6
|
+
function mdUnesc(x) { return String(x).replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"').replace(/'/g, "'").replace(/&/g, '&'); }
|
|
7
|
+
function mdTextInline(t, options, tokens) {
|
|
8
|
+
const keep = [], ph = function (x) { keep.push(x); return '\u0000' + (keep.length - 1) + '\u0000'; };
|
|
9
|
+
let s = mdEscape(t.replace(tokens?.pattern || /`([^`]+)`/g, function (mark, code) {
|
|
10
|
+
if (code !== undefined) {
|
|
11
|
+
const literal = mdEscape(code);
|
|
12
|
+
return ph(options.code?.(literal) || '<code>' + literal + '</code>');
|
|
13
|
+
}
|
|
14
|
+
return ph(tokens.render(mark));
|
|
15
|
+
}));
|
|
16
|
+
if (options.rich) s = s.replace(/(^|[^\w$])\$([^\s$](?:[^$]*?[^\s$])?)\$(?![\w$])/g, function (m, p, c) { return p + ph(options.rich('math', mdUnesc(c), true)); }); /* 行内公式 $…$(不跨行;$5 这类价格不是公式:结尾不能紧跟空格或字母) */
|
|
17
|
+
s = mdTextLinks(s, ph, keep, options.link || mdWebLink);
|
|
18
|
+
s = s.replace(/\*\*([^*]+?)\*\*/g, '<b>$1</b>').replace(/(^|[^\w])__([^_]+?)__(?!\w)/g, '$1<b>$2</b>')
|
|
19
|
+
.replace(/(^|[^\w*])\*(?![\s*])([^*]+?)\*(?![\w*])/g, '$1<i>$2</i>').replace(/(^|[^\w])_(?![\s_])([^_]+?)_(?!\w)/g, '$1<i>$2</i>');
|
|
20
|
+
if (options.decorate) s = options.decorate(s);
|
|
21
|
+
return s.replace(/\u0000(\d+)\u0000/g, function (m, i) { return keep[+i]; });
|
|
22
|
+
}
|
|
23
|
+
function mdTextLinks(s, ph, keep, render) {
|
|
24
|
+
let out = '', i = 0;
|
|
25
|
+
while (i < s.length) {
|
|
26
|
+
const a = s.indexOf('[', i); if (a < 0) break;
|
|
27
|
+
const b = s.indexOf('](', a); if (b < 0) break;
|
|
28
|
+
const tx = s.slice(a + 1, b);
|
|
29
|
+
if (tx.indexOf('[') >= 0 || tx.indexOf('\n') >= 0 || !tx) { out += s.slice(i, a + 1); i = a + 1; continue; }
|
|
30
|
+
let d = 1, j = b + 2, url = null;
|
|
31
|
+
if (s.startsWith('<', b + 2)) {
|
|
32
|
+
/* CommonMark 的尖括号目标:路径里可以有空格和括号,还可以带 :行号(正文已经过 h(),尖括号是 <…>) */
|
|
33
|
+
const end = s.indexOf('>', b + 2);
|
|
34
|
+
if (end > b + 2 && s[end + 4] === ')') { url = s.slice(b + 6, end); j = end + 5; }
|
|
35
|
+
} else {
|
|
36
|
+
for (; j < s.length && d; j++) { const c = s[j]; if (c === '(') d++; else if (c === ')') d--; else if (c === ' ' || c === '\n') break; }
|
|
37
|
+
url = d ? null : s.slice(b + 2, j - 1);
|
|
38
|
+
}
|
|
39
|
+
const link = url && render(url, tx, ph, keep);
|
|
40
|
+
if (!link) { out += s.slice(i, a + 1); i = a + 1; continue; }
|
|
41
|
+
out += s.slice(i, a) + link;
|
|
42
|
+
i = j;
|
|
43
|
+
}
|
|
44
|
+
return out + s.slice(i);
|
|
45
|
+
}
|
|
46
|
+
function mdWebLink(url, label, protect) {
|
|
47
|
+
if (!/^https?:\/\//i.test(url) || !URL.parse(mdUnesc(url))) return '';
|
|
48
|
+
return protect('<a href="' + url + '" target="_blank" rel="noopener noreferrer">') + label + protect('</a>');
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function renderMarkdownText(src, options = {}) {
|
|
52
|
+
let fm = '', body = String(src ?? '').replace(/\r\n?/g, '\n').replace(/\u0000/g, '\ufffd');
|
|
53
|
+
if (!body.trim()) return ''; /* 没有正文就什么都不画(调用方据此不画空的正文块) */
|
|
54
|
+
/* Literal links share the inline code pass so the earlier token wins. Link labels can contain Markdown punctuation. */
|
|
55
|
+
const links = options.tokens;
|
|
56
|
+
const tokens = links && { pattern: new RegExp('`([^`]+)`|' + links.pattern, 'g'), render: links.render };
|
|
57
|
+
const inline = (text) => mdTextInline(text, options, tokens);
|
|
58
|
+
const m = /^---\n([\s\S]*?)\n---\n?/.exec(body);
|
|
59
|
+
if (m) { fm = '<pre class="cap-fm mono">' + mdEscape(m[1]) + '</pre>'; body = body.slice(m[0].length); }
|
|
60
|
+
const out = []; let list = null, ord = false, code = null, table = null, math = null;
|
|
61
|
+
const flush = function () {
|
|
62
|
+
if (list) { out.push((ord ? '<ol>' : '<ul>') + list.join('') + (ord ? '</ol>' : '</ul>')); list = null; }
|
|
63
|
+
if (!table) return;
|
|
64
|
+
const rows = table.filter((row) => !/^\s*\|?\s*:?-{2,}/.test(row));
|
|
65
|
+
const cells = (row, tag) => row.replace(/^\s*\|/, '').replace(/\|\s*$/, '').split('|')
|
|
66
|
+
.map((cell) => '<' + tag + '>' + inline(cell.trim()) + '</' + tag + '>').join('');
|
|
67
|
+
if (rows.length) out.push('<div class="md-table"><table><thead><tr>' + cells(rows[0], 'th') + '</tr></thead><tbody>' +
|
|
68
|
+
rows.slice(1).map((row) => '<tr>' + cells(row, 'td') + '</tr>').join('') + '</tbody></table></div>');
|
|
69
|
+
else out.push(...table.map((line) => '<p>' + inline(line) + '</p>'));
|
|
70
|
+
table = null;
|
|
71
|
+
};
|
|
72
|
+
body.split('\n').forEach(function (line) {
|
|
73
|
+
if (math) { if (/^\s*\$\$\s*$/.test(line)) { out.push(options.rich('math', math.join('\n'))); math = null; } else math.push(line); return; }
|
|
74
|
+
if (code) {
|
|
75
|
+
const close = /^\s*(`{3,})\s*$/.exec(line);
|
|
76
|
+
if (close && close[1].length >= code.fence) {
|
|
77
|
+
const source = code.join('\n');
|
|
78
|
+
out.push(code.lang === 'mermaid' && options.rich ? options.rich('mermaid', source) : '<pre><code>' + mdCode(source, code.lang) + '</code></pre>');
|
|
79
|
+
code = null;
|
|
80
|
+
} else code.push(line);
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
const open = /^\s*(`{3,})([^`]*)$/.exec(line);
|
|
84
|
+
if (open) { flush(); code = []; code.fence = open[1].length; code.lang = open[2].trim(); return; }
|
|
85
|
+
const formula = options.rich && /^\s*\$\$(?:(.+?)\$\$)?\s*$/.exec(line);
|
|
86
|
+
if (formula) {
|
|
87
|
+
flush();
|
|
88
|
+
if (formula[1] === undefined) math = [];
|
|
89
|
+
else out.push(options.rich('math', formula[1].trim()));
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
if (/^\s*\|.*\|\s*$/.test(line)) { if (list) { const t = table; table = null; flush(); table = t; } table = table || []; table.push(line); return; }
|
|
93
|
+
const li = /^\s*(-|\*|\d+\.) (.*)$/.exec(line);
|
|
94
|
+
if (li) { if (table) flush(); const o = /\d/.test(li[1]); if (list && o !== ord) flush(); ord = o; list = list || []; list.push('<li>' + inline(li[2]) + '</li>'); return; }
|
|
95
|
+
flush();
|
|
96
|
+
if (/^#{1,6} /.test(line)) out.push('<h4>' + inline(line.replace(/^#+ /, '')) + '</h4>');
|
|
97
|
+
else if (/^\s*> ?/.test(line)) out.push('<blockquote>' + inline(line.replace(/^\s*> ?/, '')) + '</blockquote>');
|
|
98
|
+
else if (/^\s*(-{3,}|\*{3,})\s*$/.test(line)) out.push('<div class="divider" role="separator"></div>');
|
|
99
|
+
else if (line.trim()) out.push('<p>' + inline(line) + '</p>');
|
|
100
|
+
});
|
|
101
|
+
if (code) out.push('<pre><code>' + mdEscape(code.join('\n')) + '</code></pre>');
|
|
102
|
+
if (math) out.push(options.rich('math', math.join('\n')));
|
|
103
|
+
flush();
|
|
104
|
+
return fm + '<div class="md">' + out.join('') + '</div>';
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/* 代码块的轻量高亮(只认注释、字符串、关键字;CSS 认属性名),只在写了语言的代码块里用 */
|
|
108
|
+
const MD_KW = /\b(export|function|const|let|var|return|import|from|if|else|for|while|class|new|async|await|type|interface)\b/g;
|
|
109
|
+
function mdCode(src, lang) {
|
|
110
|
+
if (!lang) return mdEscape(src);
|
|
111
|
+
const keep = [], ph = function (cls, x) { keep.push('<span class="' + cls + '">' + x + '</span>'); return '\u0000' + (keep.length - 1) + '\u0000'; };
|
|
112
|
+
let s = mdEscape(src).replace(/\/\*[\s\S]*?\*\/|\/\/[^\n]*/g, function (m) { return ph('c', m); }).replace(/'[^\n]*?'|"[^\n]*?"|'[^'\n]*'/g, function (m) { return ph('s', m); });
|
|
113
|
+
s = lang === 'css' ? s.replace(/(^|\n)(\s+)([\w-]+)(?=:)/g, function (m, a, b, c) { return a + b + ph('k', c); }) : s.replace(MD_KW, function (m) { return ph('k', m); });
|
|
114
|
+
return s.replace(/\u0000(\d+)\u0000/g, function (m, i) { return keep[+i]; });
|
|
115
|
+
}
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
/* 边界:一个含义一个组件、不为接口定制、不按位置推导样式 */
|
|
2
|
+
/* Markdown 正文:行内与块的渲染、链接、引用标记、批注 */
|
|
3
|
+
'use strict';
|
|
4
|
+
const MD_MENTION_SPAN = /(<span class="mention"(?: style="[^"]*")?>[^<]*<\/span>)/g;
|
|
5
|
+
/* Keep leading mentions at full emphasis and deemphasize mentions inside generated prose. */
|
|
6
|
+
function mdPassiveMentions(html, leadingEnd) {
|
|
7
|
+
if (!html.includes('class="mention"')) return html;
|
|
8
|
+
return html.replace(/<(p|li|blockquote|h4|th|td)>([\s\S]*?)<\/\1>/g, function (block, tag, body) {
|
|
9
|
+
const parts = body.split(MD_MENTION_SPAN);
|
|
10
|
+
if (parts.length === 1) return block;
|
|
11
|
+
// A Markdown link opens with "[". Other inline markup starts prose.
|
|
12
|
+
const line = parts.map(function (part, i) {
|
|
13
|
+
const raw = i % 2 ? part.slice(part.indexOf('>') + 1, part.lastIndexOf('</span>')) : part.replace(/<(?:a|button)\b[^>]*>/g, '[');
|
|
14
|
+
return mdUnesc(raw).toLowerCase();
|
|
15
|
+
});
|
|
16
|
+
const end = tag === 'p' || tag === 'li' || tag === 'blockquote' ? leadingEnd(line.join('')) : 0;
|
|
17
|
+
let at = 0;
|
|
18
|
+
const styled = parts.map(function (part, i) {
|
|
19
|
+
const passive = i % 2 && at >= end;
|
|
20
|
+
at += line[i].length;
|
|
21
|
+
return passive ? part.replace('class="mention"', 'class="mention hl-mention-pass"') : part;
|
|
22
|
+
}).join('');
|
|
23
|
+
return '<' + tag + '>' + styled + '</' + tag + '>';
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
function mdRef(ref, fileOk) {
|
|
27
|
+
const u = mdUnesc(ref), target = mdLinkTarget(u), r = MD_REF.resolve ? MD_REF.resolve(u, target) : null;
|
|
28
|
+
if (!r) return '';
|
|
29
|
+
if (r.file) return fileOk ? '<button type="button" class="pdl-inline-link mono" data-act="fileOpen" data-v="' + h(r.file.v) + '" data-tip="' + h(r.file.v) + '"><code>' + ref + '</code></button>' : '';
|
|
30
|
+
return refChip(r);
|
|
31
|
+
} /* 链接的种类由 Markdown 组件认(mdLinkTarget);文件只认 resolve 返回的 file,行内代码才画 */
|
|
32
|
+
function refChip(r) {
|
|
33
|
+
const t = PDL_FRAGS.refChip, act = pv(t.act, r, r);
|
|
34
|
+
return '<button type="button" class="ref-chip"' + toneAttr(pv(t.tone, r, r)) + (act ? ' data-act="' + act + '"' + argAttrs(pvDeep(t.args, r, r)) : ' disabled') + ' data-tip="' + pvText(t.tip, r, r) + '">' + icon(pv(t.icon, r, r), 13) + '<span class="ref-n">' + pvParts(t.name, r, r) + '</span></button>';
|
|
35
|
+
}
|
|
36
|
+
function mdMentions(s) {
|
|
37
|
+
if (s.includes('@')) {
|
|
38
|
+
const names = WHO_DATA.members().map(function (m) { return m.handle; }).filter(Boolean).sort(function (a, b) { return b.length - a.length; });
|
|
39
|
+
if (names.length) {
|
|
40
|
+
const aliases = names.map(function (name) { return h(name).replace(/[.*+?^$(){}|[\]\\]/g, '\\$&'); });
|
|
41
|
+
const at = new RegExp('(?<![\\w@])(?:' + aliases.join('|') + ')(?![\\w-])', 'gi');
|
|
42
|
+
s = s.replace(at, function (handle) {
|
|
43
|
+
const w = WHO_DATA.handleWho(mdUnesc(handle)), c = w && whoInfo(w).color;
|
|
44
|
+
return w ? '<span class="mention"' + (c ? ' style="--mention-c:' + c + '"' : '') + '>' + handle + '</span>' : handle;
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
return s;
|
|
49
|
+
}
|
|
50
|
+
/* 链接 [文字](地址):地址按括号配对扫描(路径里可以有括号,可以带 :行号)。
|
|
51
|
+
http(s) 在外部打开;thread:id 和控制台自己的对话地址 /thread/id(?message= 带上消息就跳到那条,&block= 再落到消息里的那张卡片)跳到对话;
|
|
52
|
+
file:路径、绝对 / 相对路径(/ ./ ../ ~/ 或带扩展名)打开文件预览;其它保持原文 */
|
|
53
|
+
function mdLinkTarget(u) {
|
|
54
|
+
if (u.startsWith('#') && u.length > 1) return { k: 'anchor', v: u };
|
|
55
|
+
const m = /^(file|thread):(.+)$/.exec(u);
|
|
56
|
+
if (m) return { k: m[1], v: m[2] };
|
|
57
|
+
if (/^\/thread\/[^/?#]+\/?([?#]|$)/.test(u)) { const a = new URL(u, 'https://pdl.invalid'); return { k: 'thread', v: decodeURIComponent(a.pathname.split('/')[2]), mid: a.searchParams.get('message') || a.searchParams.get('messageId') || '', block: a.searchParams.get('block') || '' }; }
|
|
58
|
+
if (/^https?:\/\//i.test(u)) return { k: 'url', v: u };
|
|
59
|
+
if (/^(\/|\.{1,2}\/|~\/)/.test(u) || /^[\p{L}\p{N}_.@%-]+(\/[\p{L}\p{N}_.@%()-]+)*\.\w+(:\d+(-\d+)?)?$/u.test(u)) return { k: 'file', v: u };
|
|
60
|
+
return null;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function mdConsoleLink(url, tx, ph, keep) {
|
|
64
|
+
const t = mdLinkTarget(url.replace(/&/g, '&'));
|
|
65
|
+
if (!t) {
|
|
66
|
+
const custom = MD_REF.link ? MD_REF.link(mdUnesc(url)) : null;
|
|
67
|
+
if (!custom) return '';
|
|
68
|
+
const attrs = (custom.act ? actAttrs(custom.act, custom.args) : '') + (custom.tip ? ' data-tip="' + h(custom.tip) + '"' : '');
|
|
69
|
+
return custom.href
|
|
70
|
+
? ph('<a class="pdl-inline-link" href="' + h(custom.href) + '"' + attrs + '>') + tx + ph('</a>')
|
|
71
|
+
: ph('<button type="button" class="pdl-inline-link"' + attrs + '>') + tx + ph('</button>');
|
|
72
|
+
}
|
|
73
|
+
const chip = mdRef(url);
|
|
74
|
+
if (chip) return ph(chip);
|
|
75
|
+
let label = tx;
|
|
76
|
+
if (MD_REF.label && (t.k === 'anchor' || t.k === 'url')) {
|
|
77
|
+
const text = tx.replace(/^\u0000(\d+)\u0000$/, (token, index) => /^<code>([\s\S]*)<\/code>$/.exec(keep[+index])?.[1] ?? token);
|
|
78
|
+
const reference = MD_REF.label(mdUnesc(url), mdUnesc(text));
|
|
79
|
+
if (reference) label = ph('<span data-own="reference-label" data-reference-label="' + h(reference.address) + '">' + h(reference.text) + '</span>');
|
|
80
|
+
}
|
|
81
|
+
if (t.k === 'anchor') {
|
|
82
|
+
const action = MD_REF.anchor && MD_REF.anchor(mdUnesc(t.v));
|
|
83
|
+
const attrs = action ? actAttrs(action.act, action.args) + (action.tip ? ' data-tip="' + h(action.tip) + '"' : '') : '';
|
|
84
|
+
return ph('<a class="pdl-inline-link" href="' + url + '"' + attrs + '>') + label + ph('</a>');
|
|
85
|
+
}
|
|
86
|
+
return t.k === 'url' ? ph('<a class="md-ext" href="' + url + '" target="_blank" rel="noopener noreferrer">') + label + ph('</a>')
|
|
87
|
+
: ph(t.k === 'file' ? '<button type="button" class="pdl-inline-link" data-act="fileOpen" data-v="' + t.v + '" data-tip="' + t.v + '">' : t.mid ? '<button type="button" class="pdl-inline-link mono" data-act="msgJump"' + argAttrs(Object.assign({ t: t.v, mid: t.mid }, t.block ? { block: t.block } : {})) + '>' : '<button type="button" class="pdl-inline-link mono" data-act="thread" data-id="' + t.v + '">') + tx + ph('</button>');
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/* 正文里的批注:文字范围和气泡共用一份声明,不改变原来的段落结构。 */
|
|
91
|
+
function annotationHtml(html, annotations, markdown) {
|
|
92
|
+
if (!annotations.length) return html;
|
|
93
|
+
const root = document.createElement('div'); root.innerHTML = html;
|
|
94
|
+
annotations.forEach(function (a) {
|
|
95
|
+
const walk = document.createTreeWalker(root, NodeFilter.SHOW_TEXT, { acceptNode: function (n) { return n.parentElement.closest('button') ? NodeFilter.FILTER_REJECT : NodeFilter.FILTER_ACCEPT; } }), nodes = [];
|
|
96
|
+
let n, text = '';
|
|
97
|
+
while ((n = walk.nextNode())) { nodes.push({ node: n, from: text.length, to: text.length + n.length }); text += n.data; }
|
|
98
|
+
const positions = []; let compact = '';
|
|
99
|
+
for (let i = 0; i < text.length; i++) if (!/\s/.test(text[i])) { positions.push(i); compact += text[i]; }
|
|
100
|
+
const quote = document.createElement('div'); quote.innerHTML = markdown ? mdLite(a.quote) : h(a.quote);
|
|
101
|
+
const needle = quote.textContent.replace(/\s/g, ''), at = compact.indexOf(needle);
|
|
102
|
+
if (at < 0) return;
|
|
103
|
+
const from = positions[at], to = positions[at + needle.length - 1] + 1; let last;
|
|
104
|
+
nodes.forEach(function (s) {
|
|
105
|
+
if (s.to <= from || s.from >= to) return;
|
|
106
|
+
const r = document.createRange(), mark = document.createElement('mark'); mark.className = 'annotation-quote';
|
|
107
|
+
r.setStart(s.node, Math.max(0, from - s.from)); r.setEnd(s.node, Math.min(s.node.length, to - s.from)); r.surroundContents(mark); last = mark;
|
|
108
|
+
});
|
|
109
|
+
last.insertAdjacentHTML('afterend', btn(a.speaking ? tc('frame.speak') : a.label, { iconOnly: true, icon: 'chat', sm: true, cls: 'annotation-mark', data: a.open ? actAttrs(a.open.act, a.open.args) : '' }));
|
|
110
|
+
});
|
|
111
|
+
return root.innerHTML;
|
|
112
|
+
}
|
|
113
|
+
function mdLite(src, links) {
|
|
114
|
+
return renderMarkdownText(src, {
|
|
115
|
+
code: (literal) => mdRef(literal, true),
|
|
116
|
+
tokens: links && { pattern: links.pattern, render(mark) {
|
|
117
|
+
const link = links.resolve(mark);
|
|
118
|
+
return '<button type="button" class="pdl-inline-link"' + actAttrs(link.act, link.args) + '>' + h(link.text) + '</button>';
|
|
119
|
+
} },
|
|
120
|
+
rich: mdRich,
|
|
121
|
+
link: mdConsoleLink,
|
|
122
|
+
decorate: mdMentions,
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/* 正文里的公式和 Mermaid 图(同一个正文组件):组件只认语法;真正的绘制交给平台层 PLATFORM.richRender(kind, src, inline) → Promise<html>
|
|
127
|
+
(网页版按需加载渲染库)。画好的结果按源文本缓存:重画时直接放进去,不闪;还没画好或画不了时显示源文本 */
|
|
128
|
+
const MD_RICH = {};
|
|
129
|
+
function mdRichSource(src, inline) { return inline ? '<code>' + h(src) + '</code>' : '<pre><code>' + h(src) + '</code></pre>'; }
|
|
130
|
+
function mdRich(kind, src, inline) {
|
|
131
|
+
const k = kind + (inline ? ':i:' : ':b:') + src, done = MD_RICH[k], tag = inline ? 'span' : 'div';
|
|
132
|
+
return '<' + tag + ' class="md-rich" data-rich="' + kind + '"' + (inline ? ' data-inline' : '') + ' data-src="' + h(src) + '"' + (done ? ' data-done' : '') + '>' + (done || mdRichSource(src, inline)) + '</' + tag + '>';
|
|
133
|
+
}
|
|
134
|
+
treeIn(function (ns) { /* 进树就画(整页重画、只重画一条消息、弹窗局部更新都一样) */
|
|
135
|
+
ns.forEach(function (n) { (n.matches('.md-rich') ? [n] : Array.prototype.slice.call(n.querySelectorAll('.md-rich'))).filter(function (el) { return !el.hasAttribute('data-done') && !el.hasAttribute('data-busy'); }).forEach(function (el) {
|
|
136
|
+
const kind = el.dataset.rich, src = el.dataset.src, inline = el.hasAttribute('data-inline'), k = kind + (inline ? ':i:' : ':b:') + src;
|
|
137
|
+
el.setAttribute('data-busy', '');
|
|
138
|
+
settleHold(PLATFORM.richRender(kind, src, inline)).then(function (html) {
|
|
139
|
+
MD_RICH[k] = html;
|
|
140
|
+
/* 重画会重置临时的 data-busy,结果仍按当前节点对应的公式或图更新。 */
|
|
141
|
+
document.querySelectorAll('.md-rich:not([data-done])').forEach(function (x) {
|
|
142
|
+
if (x.dataset.src !== src || x.dataset.rich !== kind || x.hasAttribute('data-inline') !== inline) return;
|
|
143
|
+
x.innerHTML = html;
|
|
144
|
+
x.removeAttribute('data-busy');
|
|
145
|
+
x.setAttribute('data-done', '');
|
|
146
|
+
});
|
|
147
|
+
},
|
|
148
|
+
function () { el.removeAttribute('data-busy'); el.setAttribute('data-done', ''); }); /* 画不了:留源文本 */
|
|
149
|
+
}); });
|
|
150
|
+
});
|