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,118 @@
|
|
|
1
|
+
/* The console and the document viewer share the same lookup for generated link labels. */
|
|
2
|
+
'use strict';
|
|
3
|
+
const REFERENCE_LABEL_SELECTOR = '[data-reference-label]';
|
|
4
|
+
const REFERENCE_LABEL_CACHE = new Map(), REFERENCE_LABEL_NODES = new WeakMap();
|
|
5
|
+
let referenceLabelQueue = [];
|
|
6
|
+
let referenceLabelFallback = () => '…';
|
|
7
|
+
|
|
8
|
+
function referenceLabelTarget(href, text) {
|
|
9
|
+
let fragment = href;
|
|
10
|
+
if (!href.startsWith('#')) {
|
|
11
|
+
const url = URL.parse(href);
|
|
12
|
+
if (!url || url.origin !== location.origin || url.pathname !== '/' || url.search) return '';
|
|
13
|
+
fragment = url.hash;
|
|
14
|
+
}
|
|
15
|
+
const match = /^#([\w-]+\/([^/?#\s]+))(?:\?source=[\w.%~-]+)?$/.exec(fragment);
|
|
16
|
+
const label = text.trim().replace(/^`([^`]+)`$/, '$1');
|
|
17
|
+
return match && (label === match[2] || label === fragment || label === href) ? match[1] : '';
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function referenceLabelFlush() {
|
|
21
|
+
const queued = referenceLabelQueue;
|
|
22
|
+
referenceLabelQueue = [];
|
|
23
|
+
for (let from = 0; from < queued.length; from += 100) {
|
|
24
|
+
const batch = queued.slice(from, from + 100);
|
|
25
|
+
fetch('/api/console/reference-labels', {
|
|
26
|
+
method: 'POST', headers: { 'content-type': 'application/json' },
|
|
27
|
+
body: JSON.stringify({ addresses: batch.map((job) => job.address) }),
|
|
28
|
+
}).then((response) => {
|
|
29
|
+
if (!response.ok) throw new Error('HTTP ' + response.status);
|
|
30
|
+
return response.json();
|
|
31
|
+
}).catch((error) => {
|
|
32
|
+
console.debug('Could not read reference labels:', error.message);
|
|
33
|
+
return {};
|
|
34
|
+
}).then((labels) => {
|
|
35
|
+
for (const job of batch) {
|
|
36
|
+
job.label = Object.hasOwn(labels, job.address) ? labels[job.address] : undefined;
|
|
37
|
+
job.resolve();
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function referenceLabelLookup(address) {
|
|
44
|
+
let job = REFERENCE_LABEL_CACHE.get(address);
|
|
45
|
+
if (!job) {
|
|
46
|
+
const { promise, resolve } = Promise.withResolvers();
|
|
47
|
+
job = { address, promise, resolve };
|
|
48
|
+
REFERENCE_LABEL_CACHE.set(address, job);
|
|
49
|
+
referenceLabelQueue.push(job);
|
|
50
|
+
if (referenceLabelQueue.length === 1) queueMicrotask(referenceLabelFlush);
|
|
51
|
+
}
|
|
52
|
+
return job;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function referenceLabelPaint(node, text) {
|
|
56
|
+
if (node.textContent !== text) node.textContent = text;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
function referenceLabelMount(node) {
|
|
60
|
+
const address = node.dataset.referenceLabel;
|
|
61
|
+
const job = referenceLabelLookup(address);
|
|
62
|
+
const previous = REFERENCE_LABEL_NODES.get(node);
|
|
63
|
+
// Keep an existing label visible while its address is refreshed.
|
|
64
|
+
if (previous?.address !== address || Object.hasOwn(job, 'label')) {
|
|
65
|
+
referenceLabelPaint(node, job.label || referenceLabelFallback());
|
|
66
|
+
}
|
|
67
|
+
if (previous === job) return job.promise;
|
|
68
|
+
REFERENCE_LABEL_NODES.set(node, job);
|
|
69
|
+
return job.promise.then(() => {
|
|
70
|
+
if (REFERENCE_LABEL_CACHE.get(address) === job && node.dataset.referenceLabel === address) {
|
|
71
|
+
referenceLabelPaint(node, job.label || referenceLabelFallback());
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
function referenceLabelsIn(root) {
|
|
77
|
+
return Promise.all(Array.from(root.querySelectorAll(REFERENCE_LABEL_SELECTOR), referenceLabelMount));
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
function referenceLabelsRefresh(matches, clear = false) {
|
|
81
|
+
const changed = new Set();
|
|
82
|
+
for (const address of REFERENCE_LABEL_CACHE.keys()) {
|
|
83
|
+
if (!matches(address)) continue;
|
|
84
|
+
REFERENCE_LABEL_CACHE.delete(address);
|
|
85
|
+
changed.add(address);
|
|
86
|
+
}
|
|
87
|
+
if (!changed.size) return;
|
|
88
|
+
for (const node of document.querySelectorAll(REFERENCE_LABEL_SELECTOR)) {
|
|
89
|
+
if (!changed.has(node.dataset.referenceLabel)) continue;
|
|
90
|
+
if (clear) referenceLabelPaint(node, referenceLabelFallback());
|
|
91
|
+
referenceLabelMount(node);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
function referenceLabelsListen(stream) {
|
|
96
|
+
const on = (name, fn) => stream.addEventListener(name, (event) => fn(JSON.parse(event.data)));
|
|
97
|
+
const message = (record, clear) => {
|
|
98
|
+
const address = 'chat-' + record.topicId + '/' + record.id;
|
|
99
|
+
referenceLabelsRefresh((href) => href === address, clear);
|
|
100
|
+
};
|
|
101
|
+
on('message.appended', (data) => message(data.message));
|
|
102
|
+
on('message.changed', (data) => message(data.message));
|
|
103
|
+
on('message.deleted', (data) => message(data, true));
|
|
104
|
+
on('address.changed', ({ addresses }) => {
|
|
105
|
+
const changed = new Set(addresses || []);
|
|
106
|
+
if (changed.size) referenceLabelsRefresh((href) => changed.has(href));
|
|
107
|
+
});
|
|
108
|
+
on('topic.updated', ({ topic, trashChanged }) => {
|
|
109
|
+
if (!trashChanged) return;
|
|
110
|
+
const chats = new Set(trashChanged.map((id) => 'chat-' + id));
|
|
111
|
+
referenceLabelsRefresh((href) => chats.has(href.split('/', 1)[0]), topic.deletedAt !== null);
|
|
112
|
+
});
|
|
113
|
+
let connected = false;
|
|
114
|
+
stream.addEventListener('open', () => {
|
|
115
|
+
if (connected) referenceLabelsRefresh(() => true);
|
|
116
|
+
connected = true;
|
|
117
|
+
});
|
|
118
|
+
}
|
|
@@ -0,0 +1,372 @@
|
|
|
1
|
+
/* A visible selection belongs to one message or workbench object. Its range is local to that object. */
|
|
2
|
+
'use strict';
|
|
3
|
+
const HL_SELECTION_POP = 'hl.selectionQuote';
|
|
4
|
+
const HL_SELECTION_MAIN = '[data-key="hl-stage-view"]';
|
|
5
|
+
const HL_SELECTION_PANEL = '.panel-body[data-lc^="panel/"]';
|
|
6
|
+
const HL_SELECTION_ITEM = '[data-quote-target], [data-row-key]';
|
|
7
|
+
const HL_SELECTION_DOCUMENT = '.vw-md, .vw-code';
|
|
8
|
+
const HL_SELECTION_TEXT = '[data-quotable], .vw-md, .vw-code, .msg-body';
|
|
9
|
+
const HL_SELECTION_MESSAGE = '.stream-message[data-mid]';
|
|
10
|
+
const HL_SELECTION_BODY = '.msg-body:not(.typing), .vw-md';
|
|
11
|
+
|
|
12
|
+
function hlSelectionVisible(element) {
|
|
13
|
+
return element && !element.closest('[inert], [hidden]') && element.getClientRects().length;
|
|
14
|
+
}
|
|
15
|
+
function hlSelectionSelector(root, block) {
|
|
16
|
+
const path = [];
|
|
17
|
+
for (let node = block; node !== root; node = node.parentElement) {
|
|
18
|
+
const siblings = Array.from(node.parentElement.children).filter(function (child) { return child.localName === node.localName; });
|
|
19
|
+
path.unshift(CSS.escape(node.localName) + ':nth-of-type(' + (siblings.indexOf(node) + 1) + ')');
|
|
20
|
+
}
|
|
21
|
+
return path.length ? ':scope > ' + path.join(' > ') : undefined;
|
|
22
|
+
}
|
|
23
|
+
/* A fingerprint keeps an old offset from silently landing on a different occurrence after an edit. */
|
|
24
|
+
function hlSelectionFingerprint(text) {
|
|
25
|
+
let hash = 2166136261;
|
|
26
|
+
for (let i = 0; i < text.length; i++) hash = Math.imul(hash ^ text.charCodeAt(i), 16777619);
|
|
27
|
+
return (hash >>> 0).toString(36);
|
|
28
|
+
}
|
|
29
|
+
function hlSelectionContent(root) {
|
|
30
|
+
if (!root.matches(HL_SELECTION_MESSAGE)) return root.textContent;
|
|
31
|
+
return Array.from(root.querySelectorAll(HL_SELECTION_BODY)).map(function (block) { return block.textContent; }).join('\n');
|
|
32
|
+
}
|
|
33
|
+
function hlSelectionOffsets(text, locator, fingerprint) {
|
|
34
|
+
const range = locator.range;
|
|
35
|
+
if (fingerprint !== undefined) {
|
|
36
|
+
const usable = Number.isInteger(range?.start) && Number.isInteger(range?.end)
|
|
37
|
+
&& range.start >= 0 && range.end > range.start && range.end <= text.length;
|
|
38
|
+
if (usable && (range.fingerprint === fingerprint || range.signature === text.length + '-' + fingerprint)) return [range.start, range.end];
|
|
39
|
+
/* A diagram or formula may finish drawing elsewhere after the quote was made, changing the block's whole text
|
|
40
|
+
while the words before it stay put. Keep the offsets only when the same words are still there. */
|
|
41
|
+
if (usable && !range.repeated && typeof locator.text === 'string' && text.slice(range.start, range.end) === locator.text) return [range.start, range.end];
|
|
42
|
+
return null;
|
|
43
|
+
}
|
|
44
|
+
const context = textAnchorContext(locator);
|
|
45
|
+
return range?.repeated && !context ? null : textAnchorOffsets(text, locator.text, context);
|
|
46
|
+
}
|
|
47
|
+
function hlSelectionTextRange(root, offsets) {
|
|
48
|
+
const walk = document.createTreeWalker(root, NodeFilter.SHOW_TEXT), range = document.createRange();
|
|
49
|
+
let offset = 0, from = null;
|
|
50
|
+
for (let node = walk.nextNode(); node; node = walk.nextNode()) {
|
|
51
|
+
const end = offset + node.length;
|
|
52
|
+
if (!from && offsets[0] < end) from = [node, offsets[0] - offset];
|
|
53
|
+
if (from && offsets[1] <= end) {
|
|
54
|
+
range.setStart(...from);
|
|
55
|
+
range.setEnd(node, offsets[1] - offset);
|
|
56
|
+
return range;
|
|
57
|
+
}
|
|
58
|
+
offset = end;
|
|
59
|
+
}
|
|
60
|
+
return null;
|
|
61
|
+
}
|
|
62
|
+
function hlSelectionBlock(root, selector) {
|
|
63
|
+
if (!selector) return root;
|
|
64
|
+
// Selectors can arrive in a link or a plugin's source. Resolve them only inside the named object.
|
|
65
|
+
let options;
|
|
66
|
+
try { options = Array.from(root.querySelectorAll(selector)).filter(hlSelectionVisible); }
|
|
67
|
+
catch (error) { if (error.name !== 'SyntaxError') throw error; return null; }
|
|
68
|
+
return options.length === 1 ? options[0] : null;
|
|
69
|
+
}
|
|
70
|
+
function hlSelectionRange(root, locator) {
|
|
71
|
+
if (!hlSelectionVisible(root) || !locator?.text) return null;
|
|
72
|
+
if (!locator.range && !locator.selector && !root.matches(HL_SELECTION_DOCUMENT)) return null;
|
|
73
|
+
const block = hlSelectionBlock(root, locator.selector);
|
|
74
|
+
const exact = block && hlSelectionOffsets(block.textContent, locator, hlSelectionFingerprint(hlSelectionContent(root)));
|
|
75
|
+
const offsets = exact || hlSelectionOffsets(root.textContent, locator);
|
|
76
|
+
const range = offsets && hlSelectionTextRange(exact ? block : root, offsets);
|
|
77
|
+
if (!range || (root.matches(HL_SELECTION_MESSAGE) && !range.startContainer.parentElement.closest(HL_SELECTION_BODY))) return null;
|
|
78
|
+
return range;
|
|
79
|
+
}
|
|
80
|
+
function hlLandSelection(root, locator) {
|
|
81
|
+
if (!hlSelectionVisible(root)) return false;
|
|
82
|
+
if (!locator?.text) {
|
|
83
|
+
const block = hlSelectionBlock(root, locator?.selector);
|
|
84
|
+
if (!block) return false;
|
|
85
|
+
block.scrollIntoView({ block: 'center' });
|
|
86
|
+
return true;
|
|
87
|
+
}
|
|
88
|
+
const range = hlSelectionRange(root, locator), rect = range?.getClientRects()[0];
|
|
89
|
+
if (!rect) return false;
|
|
90
|
+
CSS.highlights?.set('hl-source', new Highlight(range));
|
|
91
|
+
const spot = spotAt('source', range.startContainer.parentElement, rect);
|
|
92
|
+
spot?.scrollIntoView({ block: 'center', inline: 'nearest', behavior: 'instant' });
|
|
93
|
+
return true;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
function hlDocumentMode(root) { return root?.matches('.vw-md') ? 'rendered' : root ? 'source' : undefined; }
|
|
97
|
+
function hlRestoreFileMode(path, locator) {
|
|
98
|
+
if (locator?.view !== 'rendered' && locator?.view !== 'source') return;
|
|
99
|
+
hlFilesFor();
|
|
100
|
+
const mode = locator.view === 'source' ? 'source' : 'render';
|
|
101
|
+
if ((HLF.mode[path] || 'render') !== mode) A.hlFileMode({ p: path, v: mode });
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
function hlSelectionObject(element, topic) {
|
|
105
|
+
const message = element.closest(HL_SELECTION_MESSAGE);
|
|
106
|
+
if (message) {
|
|
107
|
+
const block = element.closest(HL_SELECTION_BODY);
|
|
108
|
+
if (!block || block.closest('.lr, .typing') || !message.contains(block) || !topic.messages.some(function (m) { return m.id === message.dataset.mid; })) return null;
|
|
109
|
+
return { root: message, block: block, label: tc('hl.selection.msgLabel'), surface: 'message', target: message.dataset.mid };
|
|
110
|
+
}
|
|
111
|
+
const documentBody = element.closest(HL_SELECTION_DOCUMENT);
|
|
112
|
+
const mounted = documentBody && hlDocumentAt(documentBody);
|
|
113
|
+
if (mounted) return {
|
|
114
|
+
root: documentBody, block: documentBody, label: mounted.title, resource: mounted.resource,
|
|
115
|
+
mode: mounted.markdown ? hlDocumentMode(documentBody) : undefined
|
|
116
|
+
};
|
|
117
|
+
const stage = element.closest(HL_SELECTION_MAIN + ', ' + HL_SELECTION_PANEL);
|
|
118
|
+
if (!stage) return null;
|
|
119
|
+
const panel = stage.dataset.lc, view = panel ? panel.slice('panel/'.length) : hlEffectiveMain(topic.id);
|
|
120
|
+
if (view === HL_CONVERSATION.id) return null;
|
|
121
|
+
const nearest = element.closest(HL_SELECTION_ITEM);
|
|
122
|
+
const item = stage.contains(nearest) ? nearest : null;
|
|
123
|
+
const text = element.closest(HL_SELECTION_TEXT);
|
|
124
|
+
const root = item || stage;
|
|
125
|
+
const block = text && root.contains(text) ? text : root;
|
|
126
|
+
const label = element.closest('[data-quotable]')?.dataset.quotable
|
|
127
|
+
|| item?.querySelector('.lr-title, h1, h2, h3')?.textContent || hlMainViewLabel(view, topic.id);
|
|
128
|
+
return { root: root, block: block, label: label, surface: view,
|
|
129
|
+
target: item?.dataset.quoteTarget || item?.dataset.rowKey || view,
|
|
130
|
+
detail: item?.hasAttribute('data-quote-target') || undefined };
|
|
131
|
+
}
|
|
132
|
+
function hlReadSelection() {
|
|
133
|
+
const topic = HL.topic, record = topic && hlTopic(topic.id), selection = document.getSelection();
|
|
134
|
+
if (S.route !== 'chat' || !record || record.archivedAt != null || !selection?.rangeCount || selection.isCollapsed) return null;
|
|
135
|
+
const range = selection.getRangeAt(0);
|
|
136
|
+
const elementOf = function (node) { return node.nodeType === 1 ? node : node.parentElement; };
|
|
137
|
+
const element = elementOf(range.startContainer);
|
|
138
|
+
if (!hlSelectionVisible(element) || element.closest('input, textarea, [contenteditable="true"]')) return null;
|
|
139
|
+
const object = hlSelectionObject(element, topic);
|
|
140
|
+
const excerpt = selection.toString().trim().slice(0, 600);
|
|
141
|
+
if (!object || !excerpt) return null;
|
|
142
|
+
let block = object.block;
|
|
143
|
+
if (!block.contains(range.endContainer)) {
|
|
144
|
+
if (hlSelectionObject(elementOf(range.endContainer), topic)?.root !== object.root) return null;
|
|
145
|
+
block = elementOf(range.commonAncestorContainer);
|
|
146
|
+
}
|
|
147
|
+
const before = document.createRange(), raw = range.toString();
|
|
148
|
+
before.selectNodeContents(block);
|
|
149
|
+
before.setEnd(range.startContainer, range.startOffset);
|
|
150
|
+
const start = before.toString().length + raw.length - raw.trimStart().length;
|
|
151
|
+
const content = hlSelectionContent(object.root);
|
|
152
|
+
const compact = content.replace(/\s/g, ''), needle = excerpt.replace(/\s/g, '');
|
|
153
|
+
const repeated = compact.indexOf(needle) !== compact.lastIndexOf(needle);
|
|
154
|
+
const locator = { text: excerpt, selector: hlSelectionSelector(object.root, block), view: object.mode, range: {
|
|
155
|
+
start: start, end: start + raw.trim().length, fingerprint: hlSelectionFingerprint(content),
|
|
156
|
+
repeated: repeated || undefined, detail: object.detail
|
|
157
|
+
} };
|
|
158
|
+
return { block: block, rect: range.getBoundingClientRect(), canAnnotate: !!object.resource, ref: {
|
|
159
|
+
topicId: topic.id, kind: 'selection', label: object.label, excerpt: excerpt,
|
|
160
|
+
source: object.resource ? { resource: object.resource, locator: locator } : { surface: object.surface, target: object.target, locator: locator }
|
|
161
|
+
} };
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
function hlSelectionSource(value) {
|
|
165
|
+
let source;
|
|
166
|
+
if (typeof value?.resource === 'string' && /^res:(topic|ref|work)\//.test(value.resource)) source = { resource: value.resource };
|
|
167
|
+
else if (typeof value?.surface === 'string' && value.surface && typeof value.target === 'string' && value.target) {
|
|
168
|
+
source = { surface: value.surface, target: value.target };
|
|
169
|
+
} else return null;
|
|
170
|
+
if (value.locator && typeof value.locator === 'object' && !Array.isArray(value.locator)) source.locator = value.locator;
|
|
171
|
+
return source;
|
|
172
|
+
}
|
|
173
|
+
function hlSelectionAddress(topicId, source) {
|
|
174
|
+
const message = source.surface === 'message' && /^msg_[\w-]+$/.test(source.target) ? '/' + source.target : '';
|
|
175
|
+
const encoded = encodeURIComponent(JSON.stringify(source)).replace(/[!'()*]/g, function (c) { return '%' + c.charCodeAt(0).toString(16); });
|
|
176
|
+
return '#chat-' + topicId + message + '?source=' + encoded;
|
|
177
|
+
}
|
|
178
|
+
function hlSelectionFromAddress(value) {
|
|
179
|
+
try { return hlSelectionSource(JSON.parse(decodeURIComponent(value))); }
|
|
180
|
+
catch (error) { if (error.name !== 'SyntaxError' && error.name !== 'URIError') throw error; return null; }
|
|
181
|
+
}
|
|
182
|
+
function hlLocalWorkViewer(href) {
|
|
183
|
+
const url = href && URL.parse(href, location.origin);
|
|
184
|
+
return url?.origin === location.origin && url.pathname === '/works/view.html' ? url : null;
|
|
185
|
+
}
|
|
186
|
+
function hlSelectionLocation(locator) {
|
|
187
|
+
const location = [];
|
|
188
|
+
if (Number.isInteger(locator?.page) && locator.page > 0) location.push(tc('hl.selection.page', locator.page));
|
|
189
|
+
if (Number.isFinite(locator?.time) && locator.time >= 0) location.push(tc('hl.selection.sec', locator.time));
|
|
190
|
+
return location.join(' · ');
|
|
191
|
+
}
|
|
192
|
+
function hlSelectionUnavailable(source, reason) {
|
|
193
|
+
dialog({ kind: 'hlSelectionSource', args: { excerpt: source.locator?.text, warning: reason } });
|
|
194
|
+
}
|
|
195
|
+
function hlWorkbenchSourceRegion(view) {
|
|
196
|
+
const selector = hlEffectiveMain() === view ? HL_SELECTION_MAIN
|
|
197
|
+
: '.panel-body[data-lc="' + CSS.escape(navTabKey('panel', view)) + '"]';
|
|
198
|
+
return Array.from(document.querySelectorAll(selector)).find(hlSelectionVisible);
|
|
199
|
+
}
|
|
200
|
+
function hlWorkbenchSourceItem(stage, key, target) {
|
|
201
|
+
const items = stage.querySelectorAll('[' + key + '="' + CSS.escape(target) + '"]');
|
|
202
|
+
return items.length === 1 ? items[0] : null;
|
|
203
|
+
}
|
|
204
|
+
function hlWorkbenchSourceRoot(stage, source) {
|
|
205
|
+
if (!stage) return null;
|
|
206
|
+
if (source.locator?.range?.detail) return hlWorkbenchSourceItem(stage, 'data-quote-target', source.target);
|
|
207
|
+
return hlWorkbenchSourceItem(stage, 'data-row-key', source.target) || (source.surface === source.target ? stage : null);
|
|
208
|
+
}
|
|
209
|
+
function hlShowWorkbenchDetail(stage, target) {
|
|
210
|
+
const row = stage && hlWorkbenchSourceItem(stage, 'data-row-key', target);
|
|
211
|
+
const control = row?.querySelector(':scope > .lr-head[data-act="topicSet"], :scope > .lr-head[data-act="plugSet"]');
|
|
212
|
+
if (!control) return false;
|
|
213
|
+
const args = actionArgs(control);
|
|
214
|
+
if (args.v !== target) return false;
|
|
215
|
+
A[control.dataset.act](args);
|
|
216
|
+
return true;
|
|
217
|
+
}
|
|
218
|
+
function hlOpenWorkbenchSource(topicId, source, unavailable, after) {
|
|
219
|
+
const view = source.surface;
|
|
220
|
+
let showDetail = !!source.locator?.range?.detail;
|
|
221
|
+
const land = function () {
|
|
222
|
+
const stage = hlWorkbenchSourceRegion(view);
|
|
223
|
+
let root = hlWorkbenchSourceRoot(stage, source);
|
|
224
|
+
if (!root && showDetail && hlShowWorkbenchDetail(stage, source.target)) {
|
|
225
|
+
showDetail = false;
|
|
226
|
+
root = hlWorkbenchSourceRoot(hlWorkbenchSourceRegion(view), source);
|
|
227
|
+
}
|
|
228
|
+
if (!root || !hlLandSelection(root, source.locator)) return false;
|
|
229
|
+
after?.();
|
|
230
|
+
return true;
|
|
231
|
+
};
|
|
232
|
+
if (land()) return;
|
|
233
|
+
if (hlEffectiveMain() === view) {
|
|
234
|
+
if (S.panelWide) { S.panelWide = false; render(true); }
|
|
235
|
+
} else if (hlPanelViewAllowed(view)) ENGINE_PARTS.openTab('panel', view);
|
|
236
|
+
else if (hlMainViewAllowed(view)) A.hlMainPick({ v: view });
|
|
237
|
+
else return unavailable(tc('hl.selection.noWorkbench'));
|
|
238
|
+
if (land()) return;
|
|
239
|
+
// A reopened file or plugin view may still be fetching the content for this tab.
|
|
240
|
+
const current = function () { return HL.topic?.id === topicId && S.route === 'chat' && hlViewShown(view); };
|
|
241
|
+
const observer = new MutationObserver(function () {
|
|
242
|
+
if (!current() || land()) finish();
|
|
243
|
+
});
|
|
244
|
+
const timer = setTimeout(function () {
|
|
245
|
+
finish();
|
|
246
|
+
if (current()) unavailable(tc('hl.selection.noSelection'));
|
|
247
|
+
}, 1800);
|
|
248
|
+
const finish = function () { clearTimeout(timer); observer.disconnect(); };
|
|
249
|
+
observer.observe(document.getElementById('app'), {
|
|
250
|
+
childList: true, characterData: true, subtree: true,
|
|
251
|
+
attributeFilter: ['data-quote-target', 'data-row-key', 'data-lc', 'hidden', 'inert']
|
|
252
|
+
});
|
|
253
|
+
if (showDetail) hlPluginSelect(view, { topicId, source })?.then(function () {
|
|
254
|
+
if (current() && land()) finish();
|
|
255
|
+
}, hlFail);
|
|
256
|
+
return finish;
|
|
257
|
+
}
|
|
258
|
+
let hlCancelWorkbenchSource;
|
|
259
|
+
function hlOpenSelectionSource(topicId, source, opts = {}) {
|
|
260
|
+
hlCancelWorkbenchSource?.();
|
|
261
|
+
hlCancelPreviewLocation();
|
|
262
|
+
const unavailable = opts.unavailable || function (reason) { hlSelectionUnavailable(source, reason); };
|
|
263
|
+
if (source.surface === 'message') {
|
|
264
|
+
if (!/^msg_[\w-]+$/.test(source.target)) return unavailable(tc('hl.selection.noMessage'));
|
|
265
|
+
return A.hlTopic({ id: topicId, mid: source.target, messageUnavailable: function () { unavailable(tc('hl.selection.noMessage')); },
|
|
266
|
+
afterMessage: function (root) {
|
|
267
|
+
if (hlLandSelection(root, source.locator)) opts.after?.();
|
|
268
|
+
else unavailable(tc('hl.selection.noSelection'));
|
|
269
|
+
} });
|
|
270
|
+
}
|
|
271
|
+
return A.hlTopic({ id: topicId, after: function () {
|
|
272
|
+
if (source.resource) {
|
|
273
|
+
const preview = source.locator?.view === 'preview';
|
|
274
|
+
if (!preview && hlDocumentFor({ topicId, source })?.go(source.locator)) { opts.after?.(); return; }
|
|
275
|
+
const frame = !preview && hlDocumentFrameFor(topicId, source.resource);
|
|
276
|
+
if (frame) {
|
|
277
|
+
if (source.locator) frame.contentWindow.postMessage({
|
|
278
|
+
channel: 'hostlet-frame/v1', type: 'document.goto', resource: source.resource, locator: source.locator,
|
|
279
|
+
}, location.origin);
|
|
280
|
+
opts.after?.();
|
|
281
|
+
return;
|
|
282
|
+
}
|
|
283
|
+
const params = new URLSearchParams({ resource: source.resource });
|
|
284
|
+
if (source.locator) params.set('locator', JSON.stringify(source.locator));
|
|
285
|
+
return hlFetch('GET', '/api/topics/' + encodeURIComponent(topicId) + '/works/resource?' + params).then(function ({ title, open }) {
|
|
286
|
+
if (HL.topic?.id !== topicId || S.route !== 'chat') return;
|
|
287
|
+
if (preview && open.inline === 'web') return hlOpenPreviewLocation(topicId, source, open.url, opts.after, unavailable);
|
|
288
|
+
hlWorkbenchShow(open.url, title, open.frame, open.initialUrl, true);
|
|
289
|
+
opts.after?.();
|
|
290
|
+
}, function (error) {
|
|
291
|
+
if (HL.topic?.id === topicId) unavailable(error.message);
|
|
292
|
+
});
|
|
293
|
+
}
|
|
294
|
+
hlCancelWorkbenchSource = hlOpenWorkbenchSource(topicId, source, unavailable, opts.after);
|
|
295
|
+
} });
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
function hlObserveSelection(ref) {
|
|
299
|
+
return hlFetch('POST', '/api/topics/' + ref.topicId + '/works/events', { event: 'select', ...ref.source });
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
let hlSelectionTimer, hlSelectionLast, hlSelecting = false;
|
|
303
|
+
function hlSelectionClose() {
|
|
304
|
+
if (!HU.selectionQuote) return;
|
|
305
|
+
HU.selectionQuote = null;
|
|
306
|
+
popRefresh(HL_SELECTION_POP);
|
|
307
|
+
}
|
|
308
|
+
function hlSelectionTake() {
|
|
309
|
+
const ref = HU.selectionQuote;
|
|
310
|
+
hlSelectionClose();
|
|
311
|
+
hlSelectionLast = null;
|
|
312
|
+
hlPreviewClearSelection();
|
|
313
|
+
document.getSelection()?.removeAllRanges();
|
|
314
|
+
return ref;
|
|
315
|
+
}
|
|
316
|
+
function hlSelectionSync() {
|
|
317
|
+
if (hlSelecting) return;
|
|
318
|
+
const selected = hlReadSelection() || hlPreviewReadSelection();
|
|
319
|
+
if (!selected) { hlSelectionLast = null; return hlSelectionClose(); }
|
|
320
|
+
const ref = selected.ref, key = JSON.stringify([ref.topicId, ref.source, selected.external && selected.rect]);
|
|
321
|
+
const canAnnotate = selected.canAnnotate && !!hlDocumentFor(ref)?.has('annotate');
|
|
322
|
+
if (key === hlSelectionLast) {
|
|
323
|
+
if (HU.selectionQuote && HU.selectionQuote.canAnnotate !== canAnnotate) {
|
|
324
|
+
HU.selectionQuote.canAnnotate = canAnnotate;
|
|
325
|
+
popRefresh(HL_SELECTION_POP);
|
|
326
|
+
}
|
|
327
|
+
return;
|
|
328
|
+
}
|
|
329
|
+
hlSelectionLast = key;
|
|
330
|
+
spotOpen('selection', selected.block, selected.rect, function (spot) {
|
|
331
|
+
popAnchor(HL_SELECTION_POP, spot);
|
|
332
|
+
HU.selectionQuote = { ...ref, canAnnotate: canAnnotate };
|
|
333
|
+
popRefresh(HL_SELECTION_POP);
|
|
334
|
+
});
|
|
335
|
+
if (!selected.external) hlObserveSelection(ref).catch(hlFail);
|
|
336
|
+
}
|
|
337
|
+
function hlSelectionSchedule() {
|
|
338
|
+
clearTimeout(hlSelectionTimer);
|
|
339
|
+
hlSelectionTimer = setTimeout(hlSelectionSync, 100);
|
|
340
|
+
}
|
|
341
|
+
function hlSelectionStart() {
|
|
342
|
+
VM.hlSelectionQuote = function () { return HU.selectionQuote; };
|
|
343
|
+
A.hlSelectionQuoteClose = hlSelectionClose;
|
|
344
|
+
A.hlSelectionAsk = function () {
|
|
345
|
+
const ref = hlSelectionTake();
|
|
346
|
+
if (ref) A.composeQuote(ref);
|
|
347
|
+
};
|
|
348
|
+
A.hlSelectionAnnotate = function () {
|
|
349
|
+
const selection = HU.selectionQuote;
|
|
350
|
+
if (!selection?.canAnnotate) return;
|
|
351
|
+
const tools = hlDocumentFor(selection);
|
|
352
|
+
if (!tools?.has('annotate')) return;
|
|
353
|
+
const ref = hlSelectionTake();
|
|
354
|
+
tools.run('annotate', { locator: ref.source.locator, excerpt: ref.excerpt });
|
|
355
|
+
};
|
|
356
|
+
document.addEventListener('selectionchange', hlSelectionSchedule);
|
|
357
|
+
document.addEventListener('pointerdown', function (event) {
|
|
358
|
+
if (event.target.closest('[data-pop="' + HL_SELECTION_POP + '"] button')) event.preventDefault();
|
|
359
|
+
else if (event.button === 0) { hlSelecting = true; hlPreviewClearSelection(); }
|
|
360
|
+
});
|
|
361
|
+
const end = function () { hlSelecting = false; hlSelectionSchedule(); };
|
|
362
|
+
document.addEventListener('pointerup', end);
|
|
363
|
+
document.addEventListener('pointercancel', end);
|
|
364
|
+
NAV_RESET.push(function (options) {
|
|
365
|
+
HU.selectionQuote = null;
|
|
366
|
+
if (options.popupsOnly) return;
|
|
367
|
+
clearTimeout(hlSelectionTimer);
|
|
368
|
+
hlCancelWorkbenchSource?.();
|
|
369
|
+
globalThis.CSS?.highlights?.delete('hl-source');
|
|
370
|
+
});
|
|
371
|
+
}
|
|
372
|
+
hlSelectionStart();
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/* What the library's identity components read: members, the owner. */
|
|
2
|
+
'use strict';
|
|
3
|
+
/* A member's chosen colour overrides its slot in the theme's palette. */
|
|
4
|
+
function hlIdentities() { return HL.members.concat(HL.owner); }
|
|
5
|
+
function hlIdentity(id) { return id === HL.owner.id ? HL.owner : hlMember(id); }
|
|
6
|
+
function hlHasMemberSettings(member) { return member === HL.owner || !!member?.adapter; }
|
|
7
|
+
function hlWho(m) {
|
|
8
|
+
let color;
|
|
9
|
+
if (typeof m.color === 'string' && !m.color.includes('"') && CSS.supports('color', m.color)) color = m.color;
|
|
10
|
+
else if (m.color?.primary) color = 'oklch(from var(--name-1) l c ' + senderHue(m.color.primary) + ')';
|
|
11
|
+
return { id: m.id, kind: m.kind, persona: m.persona, icon: m.icon, name: m.name || (m.id === 'owner' ? tc('hl.common.you') : ''), handle: '@' + m.handle, avatarPath: m.avatarPath, color: color, tint: m === HL.owner ? 6 : HL.members.indexOf(m) % 6 + 1 };
|
|
12
|
+
}
|
|
13
|
+
pdlReads('who', {
|
|
14
|
+
member: function (id) {
|
|
15
|
+
const m = hlIdentity(id);
|
|
16
|
+
return m ? { ...hlWho(m), profile: hlHasMemberSettings(m) } : { id: id, name: tc('hl.common.removedMember'), handle: '' };
|
|
17
|
+
},
|
|
18
|
+
members: function () { return hlIdentities().map(hlWho); },
|
|
19
|
+
me: function () { return hlWho(HL.owner); },
|
|
20
|
+
/* Is this member at work in the topic that is open (`turn`: on this reply of it)? Every avatar of it drawn there pulses, on one beat. */
|
|
21
|
+
live: function (id, turn) { const t = HL.topic; if (!t) return ''; return (turn != null ? !!t.live[turn] && t.live[turn].memberId === id : Object.keys(t.live).some(function (k) { return t.live[k].memberId === id; })) ? 'streaming' : ''; },
|
|
22
|
+
handleWho: function (handle) { const q = handle.replace(/^@/, '').toLowerCase(), m = hlIdentities().find(function (x) { return x.handle.toLowerCase() === q; }); return m ? { kind: 'member', id: m.id } : null; }
|
|
23
|
+
});
|
|
24
|
+
ENGINE_PARTS.addressParam = function (route, args) {
|
|
25
|
+
const t = HL.topic;
|
|
26
|
+
if (route !== 'chat' || !t) return args.p;
|
|
27
|
+
return t.id + (t.addressMid ? '/' + t.addressMid : '');
|
|
28
|
+
};
|
|
29
|
+
ENGINE_PARTS.navState = function () { return {}; };
|
|
30
|
+
ENGINE_PARTS.navRestore = function () {};
|
|
31
|
+
/* Width of the side column: kept on this device, dragged at its edge. */
|
|
32
|
+
S.navW = store.get('navW', null);
|
|
33
|
+
(function () {
|
|
34
|
+
const tokPx = function (n) {
|
|
35
|
+
const el = document.createElement('div');
|
|
36
|
+
el.style.cssText = 'position:fixed;visibility:hidden;pointer-events:none;width:var(' + n + ')';
|
|
37
|
+
document.body.appendChild(el);
|
|
38
|
+
const w = el.getBoundingClientRect().width;
|
|
39
|
+
el.remove();
|
|
40
|
+
return w;
|
|
41
|
+
};
|
|
42
|
+
const setW = function (w) {
|
|
43
|
+
S.navW = w;
|
|
44
|
+
const app = document.querySelector('.app');
|
|
45
|
+
if (app) app.style.setProperty('--nav-w', w ? w + 'px' : '');
|
|
46
|
+
const handle = document.querySelector('[data-resize="nav"]');
|
|
47
|
+
if (handle) handle.setAttribute('aria-valuenow', String(Math.round(w || tokPx('--nav-w0'))));
|
|
48
|
+
};
|
|
49
|
+
RESIZERS.nav = {
|
|
50
|
+
get min() { return tokPx('--nav-min'); },
|
|
51
|
+
max: function () { const lo = tokPx('--nav-min'); return Math.max(lo, Math.min(tokPx('--nav-max'), Math.round(window.innerWidth * 0.45))); },
|
|
52
|
+
width: function () { return S.navW || document.querySelector('.nav')?.getBoundingClientRect().width || tokPx('--nav-w0'); },
|
|
53
|
+
preview: setW,
|
|
54
|
+
commit: function (w) { setW(w); store.set('navW', w); },
|
|
55
|
+
reset: function () { setW(null); store.set('navW', null); }
|
|
56
|
+
};
|
|
57
|
+
})();
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/* The reader omits some whitespace at DOM text-node boundaries. Match on compact text and map back to the original offsets. */
|
|
2
|
+
'use strict';
|
|
3
|
+
function textAnchorContext({ prefix, suffix }) {
|
|
4
|
+
const compact = (value) => typeof value === 'string' ? value.replace(/\s/g, '') : '';
|
|
5
|
+
const before = compact(prefix), after = compact(suffix);
|
|
6
|
+
return before || after ? { before, after } : null;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
function textAnchorOffsets(text, quote, context) {
|
|
10
|
+
if (typeof quote !== 'string' || !quote.trim()) return null;
|
|
11
|
+
const needle = quote.replace(/\s/g, ''), offsets = [];
|
|
12
|
+
const compact = text.replace(/\s|\S/g, (char, at) => {
|
|
13
|
+
if (/\s/.test(char)) return '';
|
|
14
|
+
offsets.push(at);
|
|
15
|
+
return char;
|
|
16
|
+
});
|
|
17
|
+
const { before = '', after = '' } = context ?? {};
|
|
18
|
+
let match = -1;
|
|
19
|
+
for (let at = compact.indexOf(needle); at >= 0; at = compact.indexOf(needle, at + 1)) {
|
|
20
|
+
if (at < before.length || !compact.startsWith(before, at - before.length) ||
|
|
21
|
+
!compact.startsWith(after, at + needle.length)) continue;
|
|
22
|
+
if (match >= 0) return null;
|
|
23
|
+
match = at;
|
|
24
|
+
}
|
|
25
|
+
return match < 0 ? null : [offsets[match], offsets[match + needle.length - 1] + 1];
|
|
26
|
+
}
|