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,238 @@
|
|
|
1
|
+
/* 边界:一个含义一个组件、不为接口定制、不按位置推导样式 */
|
|
2
|
+
/* 折叠:内容折叠、查看更多、开合的唯一动作 */
|
|
3
|
+
'use strict';
|
|
4
|
+
/* 开合的状态(组件库唯一的一份):所有开合——折叠块、展开一块(disclosure)、列表里一次展开一行、树的目录、分组段——都记在 S.folds,键按形状分范围:
|
|
5
|
+
键本身 = 折叠块 / 展开一块(真假);'row:列表' = 这张列表展开着的那一行;'tree:树' = 展开着的目录 { 路径: 真 };'sec:段' = 分组段 { c: 收起, m: 露出更多 }。
|
|
6
|
+
只有分组段存进本机(store 'secs',刷新还在),别的跟着这次打开。状态路径的根是 folds(通用动作 set / toggle 能直接改,比如 disclosure 的默认开合) */
|
|
7
|
+
const FOLD_ROW = 'row:', FOLD_TREE = 'tree:', FOLD_SEC = 'sec:';
|
|
8
|
+
const ROW_OPEN = pdlKeyed('rowOpen'), TREE_FOLD = pdlKeyed('treeFold');
|
|
9
|
+
const FOLD_BASE = Object.create(null), FOLD_ROW_MAP = Object.create(null), FOLD_TREE_MAP = Object.create(null), FOLD_TREE_PROXY = Object.create(null);
|
|
10
|
+
function foldRowKeysOf(v) {
|
|
11
|
+
if (v == null) return [];
|
|
12
|
+
if (typeof v === 'object') return Object.keys(v).filter(function (k) { return !!v[k]; });
|
|
13
|
+
return [String(v)];
|
|
14
|
+
}
|
|
15
|
+
function foldRowWrite(list, next) {
|
|
16
|
+
const prevKeys = new Set(foldRowKeysOf(FOLD_ROW_MAP[list]));
|
|
17
|
+
const nextKeys = new Set(foldRowKeysOf(next));
|
|
18
|
+
if (next === undefined) delete FOLD_ROW_MAP[list];
|
|
19
|
+
else FOLD_ROW_MAP[list] = next;
|
|
20
|
+
prevKeys.forEach(function (k) { if (!nextKeys.has(k)) ROW_OPEN.set(list + '|' + k, false); });
|
|
21
|
+
nextKeys.forEach(function (k) { if (!prevKeys.has(k)) ROW_OPEN.set(list + '|' + k, true); });
|
|
22
|
+
}
|
|
23
|
+
function foldTreeEnsure(name) {
|
|
24
|
+
if (!FOLD_TREE_MAP[name]) FOLD_TREE_MAP[name] = Object.create(null);
|
|
25
|
+
if (!FOLD_TREE_PROXY[name]) {
|
|
26
|
+
FOLD_TREE_PROXY[name] = new Proxy(FOLD_TREE_MAP[name], {
|
|
27
|
+
get: function (t, p) {
|
|
28
|
+
if (typeof p === 'string' && p !== 'toJSON') TREE_FOLD.get(name + '|' + p);
|
|
29
|
+
return FOLD_TREE_MAP[name][p];
|
|
30
|
+
},
|
|
31
|
+
set: function (t, p, v) {
|
|
32
|
+
const map = FOLD_TREE_MAP[name];
|
|
33
|
+
if (typeof p === 'string') {
|
|
34
|
+
map[p] = v;
|
|
35
|
+
TREE_FOLD.set(name + '|' + p, !!v);
|
|
36
|
+
}
|
|
37
|
+
return true;
|
|
38
|
+
},
|
|
39
|
+
deleteProperty: function (t, p) {
|
|
40
|
+
const map = FOLD_TREE_MAP[name];
|
|
41
|
+
if (typeof p === 'string') {
|
|
42
|
+
delete map[p];
|
|
43
|
+
TREE_FOLD.set(name + '|' + p, false);
|
|
44
|
+
}
|
|
45
|
+
return true;
|
|
46
|
+
},
|
|
47
|
+
ownKeys: function () { return Object.keys(FOLD_TREE_MAP[name]); },
|
|
48
|
+
getOwnPropertyDescriptor: function (t, p) {
|
|
49
|
+
const map = FOLD_TREE_MAP[name];
|
|
50
|
+
return Object.prototype.hasOwnProperty.call(map, p) ? { value: map[p], writable: true, enumerable: true, configurable: true } : undefined;
|
|
51
|
+
},
|
|
52
|
+
has: function (t, p) { return p in FOLD_TREE_MAP[name]; }
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
return FOLD_TREE_PROXY[name];
|
|
56
|
+
}
|
|
57
|
+
function foldTreeWrite(name, next) {
|
|
58
|
+
const prev = FOLD_TREE_MAP[name] || Object.create(null);
|
|
59
|
+
const fresh = Object.create(null);
|
|
60
|
+
if (next && typeof next === 'object') {
|
|
61
|
+
Object.keys(next).forEach(function (k) { if (next[k]) fresh[k] = true; });
|
|
62
|
+
}
|
|
63
|
+
FOLD_TREE_MAP[name] = fresh;
|
|
64
|
+
const all = new Set(Object.keys(prev).concat(Object.keys(fresh)));
|
|
65
|
+
all.forEach(function (k) {
|
|
66
|
+
if (!!prev[k] !== !!fresh[k]) TREE_FOLD.set(name + '|' + k, !!fresh[k]);
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
function treeFoldIsOpen(name, path) {
|
|
70
|
+
return !!TREE_FOLD.get(name + '|' + path);
|
|
71
|
+
}
|
|
72
|
+
function treeFoldSet(name, path, isOpen) {
|
|
73
|
+
const map = FOLD_TREE_MAP[name] || (FOLD_TREE_MAP[name] = Object.create(null));
|
|
74
|
+
if (isOpen) map[path] = true; else delete map[path];
|
|
75
|
+
TREE_FOLD.set(name + '|' + path, !!isOpen);
|
|
76
|
+
}
|
|
77
|
+
/* S.folds 保持统一读写接口,同时将 row:* / tree:* 路由至键级 pdlKeyed(toJSON 仅含普通折叠项,避免发射粗粒度 ~S.folds) */
|
|
78
|
+
S.folds = new Proxy(FOLD_BASE, {
|
|
79
|
+
get: function (t, p) {
|
|
80
|
+
if (p === 'toJSON') return function () { return FOLD_BASE; };
|
|
81
|
+
if (typeof p === 'string') {
|
|
82
|
+
if (p.indexOf(FOLD_ROW) === 0) return FOLD_ROW_MAP[p.slice(FOLD_ROW.length)];
|
|
83
|
+
if (p.indexOf(FOLD_TREE) === 0) {
|
|
84
|
+
const name = p.slice(FOLD_TREE.length);
|
|
85
|
+
return FOLD_TREE_MAP[name] ? foldTreeEnsure(name) : undefined;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
return t[p];
|
|
89
|
+
},
|
|
90
|
+
set: function (t, p, v) {
|
|
91
|
+
if (typeof p === 'string') {
|
|
92
|
+
if (p.indexOf(FOLD_ROW) === 0) { foldRowWrite(p.slice(FOLD_ROW.length), v); return true; }
|
|
93
|
+
if (p.indexOf(FOLD_TREE) === 0) { foldTreeWrite(p.slice(FOLD_TREE.length), v); return true; }
|
|
94
|
+
}
|
|
95
|
+
t[p] = v;
|
|
96
|
+
return true;
|
|
97
|
+
},
|
|
98
|
+
deleteProperty: function (t, p) {
|
|
99
|
+
if (typeof p === 'string') {
|
|
100
|
+
if (p.indexOf(FOLD_ROW) === 0) { foldRowWrite(p.slice(FOLD_ROW.length), undefined); return true; }
|
|
101
|
+
if (p.indexOf(FOLD_TREE) === 0) { foldTreeWrite(p.slice(FOLD_TREE.length), null); delete FOLD_TREE_MAP[p.slice(FOLD_TREE.length)]; return true; }
|
|
102
|
+
}
|
|
103
|
+
delete t[p];
|
|
104
|
+
return true;
|
|
105
|
+
},
|
|
106
|
+
has: function (t, p) {
|
|
107
|
+
if (typeof p === 'string') {
|
|
108
|
+
if (p.indexOf(FOLD_ROW) === 0) return p.slice(FOLD_ROW.length) in FOLD_ROW_MAP;
|
|
109
|
+
if (p.indexOf(FOLD_TREE) === 0) return p.slice(FOLD_TREE.length) in FOLD_TREE_MAP;
|
|
110
|
+
}
|
|
111
|
+
return p in t;
|
|
112
|
+
},
|
|
113
|
+
getOwnPropertyDescriptor: function (t, p) {
|
|
114
|
+
if (typeof p === 'string') {
|
|
115
|
+
if (p.indexOf(FOLD_ROW) === 0) {
|
|
116
|
+
const name = p.slice(FOLD_ROW.length);
|
|
117
|
+
return name in FOLD_ROW_MAP ? { value: FOLD_ROW_MAP[name], writable: true, enumerable: true, configurable: true } : undefined;
|
|
118
|
+
}
|
|
119
|
+
if (p.indexOf(FOLD_TREE) === 0) {
|
|
120
|
+
const name = p.slice(FOLD_TREE.length);
|
|
121
|
+
return name in FOLD_TREE_MAP ? { value: foldTreeEnsure(name), writable: true, enumerable: true, configurable: true } : undefined;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
return Reflect.getOwnPropertyDescriptor(t, p);
|
|
125
|
+
},
|
|
126
|
+
ownKeys: function (t) {
|
|
127
|
+
return Reflect.ownKeys(t)
|
|
128
|
+
.concat(Object.keys(FOLD_ROW_MAP).map(function (k) { return FOLD_ROW + k; }))
|
|
129
|
+
.concat(Object.keys(FOLD_TREE_MAP).map(function (k) { return FOLD_TREE + k; }));
|
|
130
|
+
}
|
|
131
|
+
});
|
|
132
|
+
STATE_ROOTS.folds = function () { return S.folds; };
|
|
133
|
+
|
|
134
|
+
/* 滚动边缘渐隐:组件库的滚动原件 .scroll 自带(CSS 滚动时间线,见 core.css),这里不再测量 */
|
|
135
|
+
|
|
136
|
+
/* ───────── 折叠组件:一个机制,shape 两种(middle | bottom),完全声明式 ─────────
|
|
137
|
+
结构和开关都在这里画出(HTML 里写着展开状态 data-open),测量步骤只写 data-foldable(middle 另写切口的 CSS 变量),从不插 DOM,跑几遍结果都一样。
|
|
138
|
+
展开状态在数据里(S.folds[key]):点开关改数据 → 重画 → HTML 变了,节点不会被当成“没变”复用。
|
|
139
|
+
两种 shape 共用:切口落在整行上、渐隐一行高、同一个开关组件(foldTg:无杆尖角 ⌄ 展开 / ⌃ 收起)。
|
|
140
|
+
bottom:留开头 N 整行(N 是档位 s 3 行 · m 5 行 · l 8 行),由浏览器的行数截断(line-clamp)切,不量行;最后一行从上到下渐隐,开关紧贴在下面居中。
|
|
141
|
+
middle:留开头 FOLD_HEAD 行、结尾 FOLD_TAIL 行;上面一行渐隐、下面一行渐显(互为镜像),开关在右侧、竖直居中在两行之间;展开后留在原切口处。 */
|
|
142
|
+
const FOLD_HEAD = 5, FOLD_TAIL = 3, FOLD_MIN_HIDDEN = 4;
|
|
143
|
+
const FOLD_LINES = { s: 3, m: 5, l: 8 }; /* 折叠档位 = 收起时完整显示的单位数 k;收起 = k 个完整单位 + 第 k+1 个整单位渐隐;多于 k+1 个单位才折 */
|
|
144
|
+
/* 折叠开关(组件库,唯一一个):折叠块、排队“还有 N 条”都用它;label 可带文字 */
|
|
145
|
+
/* 图标(同一族无杆尖角):bottom 收着 ⌄、展开 ⌃;middle 收着 ⌃⌄(上下都能展开)、展开 ⌄⌃(向里收) */
|
|
146
|
+
/* 折叠开关:字形按展开方向定义——往下展开的(bottom)收着是 ⌄、开着是 ⌃;往上展开的(up:输入框上沿的队列)收着是 ⌃、开着是 ⌄;中间折叠是一对 */
|
|
147
|
+
function foldTg(open, act, data, label, tip, shape) {
|
|
148
|
+
const ic = shape === 'middle' ? (open ? 'chevin' : 'chevboth') : shape === 'up' ? (open ? 'down' : 'chevup') : (open ? 'chevup' : 'down');
|
|
149
|
+
return '<button type="button" class="fold-tg" data-act="' + act + '"' + (data || '') + ' aria-expanded="' + open + '" aria-label="' + h(tip || label || tc(open ? 'common.collapse' : 'common.expand')) + '" data-tip="' + h(tip || tc(open ? 'common.collapse' : 'common.expand')) + '">' + icon(ic, 14) + (label ? '<span>' + label + '</span>' : '') + '</button>';
|
|
150
|
+
}
|
|
151
|
+
/* 查看更多(折叠的 more):数据说后面还有(全文还没读、还有下一批……)时,开关一直在,写“查看更多”;展开时执行声明的读取。读到了数据就不再说有更多,回到普通的折叠 */
|
|
152
|
+
const FOLD_MORE = {};
|
|
153
|
+
function foldBox(style, key, html, o) {
|
|
154
|
+
o = o || {};
|
|
155
|
+
const open = !!S.folds[key], k = h(key), more = o.more && !open ? o.more : null;
|
|
156
|
+
if (o.more) FOLD_MORE[key] = o.more; else delete FOLD_MORE[key];
|
|
157
|
+
const tg = more ? foldTg(false, 'fold', ' data-k="' + k + '"', tc('fold.viewMore'), tc('fold.viewMore'), style) : foldTg(open, 'fold', ' data-k="' + k + '"', '', style === 'middle' ? tc(open ? 'fold.collapseMiddle' : 'fold.expandMiddle') : '', style);
|
|
158
|
+
if (style === 'middle') return '<div class="fold" data-fold="middle" data-fold-key="' + k + '" data-open="' + open + '"><div class="msg-body fold-head">' + html + '</div>' +
|
|
159
|
+
'<div class="msg-body fold-tail" aria-hidden="true" inert><div class="fold-tail-in">' + html + '</div></div>' + tg + '</div>'; /* 尾巴一直画着,展开时样式藏起来:开关只改属性 */
|
|
160
|
+
/* 单位跟着里面的内容走:包着一个列表(o.items = 项数)时单位是项——一项换行了还是一项,折不折由项数直接决定(多于 k+1 项),不测量;正文的单位是行(line-clamp k+1,最后一行渐隐,截断后溢出才折) */
|
|
161
|
+
const n = FOLD_LINES[o.height] || FOLD_LINES.l, items = o.items != null;
|
|
162
|
+
return '<div class="fold" data-fold="bottom" data-fold-key="' + k + '" data-open="' + open + '" data-lines="' + n + '"' + (more ? ' data-more' : '') + (items ? ' data-unit="item" data-foldable="' + (o.items > n + 1 ? 1 : 0) + '"' : '') + '><div class="fold-in' + (o.cls ? ' ' + o.cls : '') + '">' + html + '</div>' + tg + '</div>';
|
|
163
|
+
}
|
|
164
|
+
/* 一段内容按真实排版分成行:每行的中线(文字矩形的中点),行框 = 中线 ± 行高 / 2 */
|
|
165
|
+
function foldLines(el) {
|
|
166
|
+
const r = document.createRange(); r.selectNodeContents(el);
|
|
167
|
+
const top = el.getBoundingClientRect().top, mids = [];
|
|
168
|
+
Array.prototype.slice.call(r.getClientRects()).forEach(function (x) { if (x.height < 4) return; const m = (x.top + x.bottom) / 2 - top; if (!mids.some(function (y) { return Math.abs(y - m) < 4; })) mids.push(m); });
|
|
169
|
+
return mids.sort(function (a, b) { return a - b; });
|
|
170
|
+
}
|
|
171
|
+
/* 量折叠(折叠组件自己的事):只在折叠块出现或尺寸变化时量(ResizeObserver),不插 DOM、不每次渲染全局扫。
|
|
172
|
+
新出现的折叠块由引擎的进树通知交过来(frame.js treeMatch),不扫页面。middle 量出切口位置写成 CSS 变量;bottom 只判断够不够长 */
|
|
173
|
+
function foldMeasure(el) {
|
|
174
|
+
if (el.dataset.fold === 'middle') {
|
|
175
|
+
const head = el.querySelector(':scope > .fold-head'); if (!head) return;
|
|
176
|
+
const lh = parseFloat(getComputedStyle(head).lineHeight) || 26, ls = foldLines(head), n = ls.length;
|
|
177
|
+
if (n < FOLD_HEAD + FOLD_TAIL + FOLD_MIN_HIDDEN) { el.dataset.foldable = '0'; return; }
|
|
178
|
+
const cut = ls[FOLD_HEAD - 1] + lh / 2, from = ls[n - FOLD_TAIL] - lh / 2, end = ls[n - 1] + lh / 2;
|
|
179
|
+
el.style.setProperty('--flh', lh + 'px'); el.style.setProperty('--fh', Math.round(cut) + 'px'); el.style.setProperty('--fs', Math.round(from) + 'px'); el.style.setProperty('--ft', Math.round(end - from) + 'px');
|
|
180
|
+
const tg = el.querySelector(':scope > .fold-tg'), hid = n - FOLD_HEAD - FOLD_TAIL, lab = el.dataset.open === 'true' ? tc('fold.collapseMiddle') : tc('fold.expandMiddleN', hid);
|
|
181
|
+
if (tg && tg.getAttribute('aria-label') !== lab) { tg.setAttribute('aria-label', lab); tg.dataset.tip = lab; }
|
|
182
|
+
el.dataset.foldable = '1'; return;
|
|
183
|
+
}
|
|
184
|
+
if (el.dataset.unit === 'item') return; /* 列表:折不折在画的时候按项数定好了,不量 */
|
|
185
|
+
const inner = el.querySelector(':scope > .fold-in'); if (!inner) return;
|
|
186
|
+
/* bottom 正文:截断本身就是尺子——套上 line-clamp(k+1 行)后还溢出,才有东西被藏起来;不按行高算。展开着的时候临时套上截断量一次(同一轮里,不绘制) */
|
|
187
|
+
const tmp = el.dataset.open === 'true'; if (tmp) el.setAttribute('data-measure', '');
|
|
188
|
+
const f = inner.scrollHeight > inner.clientHeight + 1 ? '1' : '0';
|
|
189
|
+
if (tmp) el.removeAttribute('data-measure');
|
|
190
|
+
if (el.dataset.foldable !== f) el.dataset.foldable = f;
|
|
191
|
+
}
|
|
192
|
+
treeMatch('[data-fold]', foldMeasure, true); /* 进树通知:折叠块进了文档、或尺寸变了,量一次 */
|
|
193
|
+
/* 本地更新记版本时:把折叠块上的测量结果去掉、开关换回刚画出来的样子 */
|
|
194
|
+
LOCAL_NORM.push(function (root) {
|
|
195
|
+
root.querySelectorAll('[data-fold]').forEach(function (f) {
|
|
196
|
+
if (f.dataset.unit !== 'item') f.removeAttribute('data-foldable'); f.removeAttribute('style'); /* 列表的 data-foldable 是画出来的,不是量的 */
|
|
197
|
+
const tg = f.querySelector(':scope > .fold-tg'), open = f.dataset.open === 'true', shape = f.dataset.fold;
|
|
198
|
+
if (tg && !f.hasAttribute('data-more')) tg.outerHTML = foldTg(open, 'fold', ' data-k="' + h(f.dataset.foldKey) + '"', '', shape === 'middle' ? tc(open ? 'fold.collapseMiddle' : 'fold.expandMiddle') : '', shape);
|
|
199
|
+
});
|
|
200
|
+
});
|
|
201
|
+
/* 折叠开关:本地更新——改 data-open、换开关、重新量;不重画消息、不重画对话流。改完把所在消息 / 孤岛记下的“版本”更新成现在的样子,
|
|
202
|
+
下次整页重画时这条消息照样复用(工具栏、作者行的节点身份都不变) */
|
|
203
|
+
/* 决定结果的详情开合(result 块):展开状态在数据里,改完重画 */
|
|
204
|
+
function foldBlock(d) {
|
|
205
|
+
const k = d.k, open = S.folds[k] = !S.folds[k];
|
|
206
|
+
if (open && FOLD_MORE[k]) { actFn(FOLD_MORE[k].act)(FOLD_MORE[k].args); render(true); return; } /* 查看更多:读剩下的,重画(读到之前照样展开着) */
|
|
207
|
+
document.querySelectorAll('[data-fold-key]').forEach(function (f) {
|
|
208
|
+
if (f.dataset.foldKey !== k) return;
|
|
209
|
+
f.setAttribute('data-open', String(open));
|
|
210
|
+
const shape = f.dataset.fold, tg = f.querySelector(':scope > .fold-tg');
|
|
211
|
+
if (tg) tg.outerHTML = foldTg(open, 'fold', ' data-k="' + h(k) + '"', '', shape === 'middle' ? tc(open ? 'fold.collapseMiddle' : 'fold.expandMiddle') : '', shape);
|
|
212
|
+
foldMeasure(f); localSync(f);
|
|
213
|
+
});
|
|
214
|
+
}
|
|
215
|
+
/* 开合只有一个动作(fold):f = row(列表里一次展开一行)| tree(目录)| sec(分组段)| more(段里露出更多)| result(重画的开合);
|
|
216
|
+
path = 状态里的手风琴(同一个值再点一下就收起,v 或 i 是这一项);什么都没写 = 折叠块(S.folds[k],本地更新) */
|
|
217
|
+
/* 定位到段里的一行之前把它露出来:段收着就展开,在“还有 N 条”里就展开那几条(引擎的 locateNode 经 ENGINE_PARTS.reveal 调) */
|
|
218
|
+
ENGINE_PARTS.reveal = function (el) {
|
|
219
|
+
const sec = el.closest('.gsec'); if (!sec) return;
|
|
220
|
+
const key = sec.dataset.sec;
|
|
221
|
+
if (sec.hasAttribute('data-collapsed')) { const st = secSt(key, true); st.c = false; secSave(); secFlip(el, false); }
|
|
222
|
+
if (el.closest('.gsec-x') && !sec.hasAttribute('data-more')) { const t = sec.querySelector('[data-f="more"]'); if (t) foldMore({ k: key }, t); }
|
|
223
|
+
};
|
|
224
|
+
A.fold = function (d, el) {
|
|
225
|
+
if (d.path) { const v = d.v != null ? d.v : d.i, cur = pathGet(d.path, d); pathSet(d.path, String(cur) === String(castTo(v, cur, d.cast)) && cur != null ? null : v, d); render(true); return; }
|
|
226
|
+
if (d.f === 'row') return foldRow(d, el);
|
|
227
|
+
if (d.f === 'tree') return foldTree(d, el);
|
|
228
|
+
if (d.f === 'sec') return foldSec(d, el);
|
|
229
|
+
if (d.f === 'more') return foldMore(d, el);
|
|
230
|
+
if (d.f === 'queue') return foldQueue(d, el);
|
|
231
|
+
if (d.f === 'result') { S.folds[d.k] = !S.folds[d.k]; render(true); return; }
|
|
232
|
+
foldBlock(d);
|
|
233
|
+
};
|
|
234
|
+
/* ───────── 目录登记:这个文件里的组件 ───────── */
|
|
235
|
+
Object.assign(LIB_CATALOG, {
|
|
236
|
+
foldBottom: { g: 'structure', via: ['type:fold', 'type:content'], ex: function (s) { return foldBox('bottom', 'catalog-fb', '<p>' + h(s.long) + '</p>', { height: 's' }); } },
|
|
237
|
+
foldMiddle: { g: 'structure', via: ['type:content'], ex: function (s) { return foldBox('middle', 'catalog-fm', '<p>' + h(s.long + s.long + s.long) + '</p>'); } }
|
|
238
|
+
});
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/* 边界:一个含义一个组件、不为接口定制、不按位置推导样式 */
|
|
2
|
+
/* 值的写法:时间、大小、时长(PDL 的 { of, fmt }) */
|
|
3
|
+
'use strict';
|
|
4
|
+
/* 时间和大小的写法(PDL 的 { of, fmt }):接口给时间戳 / 字节数,这里按“你”的时区写成字。ago 侧栏的相对时间 · day 今天 / N月N日 · at 今天 hh:mm / 昨天 hh:mm / N 天前 / N月N日 hh:mm · hm 时:分 · stamp MM/DD hh:mm(对话和消息的时间,不分今天) · bytes GB / MB / KB(一位小数) */
|
|
5
|
+
function fmtParts(ts) { const tz = WHO_DATA.me().timeZone, o = {}; new Intl.DateTimeFormat('en-US', { timeZone: tz || undefined, year: 'numeric', month: 'numeric', day: 'numeric', hour: '2-digit', minute: '2-digit', hourCycle: 'h23' }).formatToParts(ts).forEach(function (p) { o[p.type] = p.value; }); return o; }
|
|
6
|
+
/* 时间:毫秒数、数字串或 ISO 串都读成时间戳;读不出来是 NaN,各个时间写法一律写成空串 */
|
|
7
|
+
function fmtTs(ts) { return typeof ts === 'number' ? ts : typeof ts === 'string' ? (/^\d+$/.test(ts) ? Number(ts) : Date.parse(ts)) : NaN; }
|
|
8
|
+
function fmtDayNo(o) { return Date.UTC(+o.year, +o.month - 1, +o.day) / 864e5; }
|
|
9
|
+
const FORMATS = {
|
|
10
|
+
ago: function (ts) { ts = fmtTs(ts); if (!isFinite(ts)) return ''; const s = Math.max(0, (ioNow() - ts) / 1000); /* 时间可能是毫秒数、数字串或 ISO 串;读不出来就不写 */ return s < 60 ? tc('common.justNow') : s < 3600 ? tc('format.minutes', Math.round(s / 60)) : s < 86400 ? tc('format.hours', Math.round(s / 3600)) : tc('format.days', Math.round(s / 86400)); },
|
|
11
|
+
hm: function (ts) { ts = fmtTs(ts); if (!isFinite(ts)) return ''; const o = fmtParts(ts); return o.hour + ':' + o.minute; },
|
|
12
|
+
stamp: function (ts) { ts = fmtTs(ts); if (!isFinite(ts)) return ''; const o = fmtParts(ts); return ('0' + o.month).slice(-2) + '/' + ('0' + o.day).slice(-2) + ' ' + o.hour + ':' + o.minute; },
|
|
13
|
+
day: function (ts) { ts = fmtTs(ts); if (!isFinite(ts)) return ''; const o = fmtParts(ts); return fmtDayNo(o) === fmtDayNo(fmtParts(ioNow())) ? tc('format.today') : tc('format.date', +o.month, +o.day); },
|
|
14
|
+
at: function (ts) { ts = fmtTs(ts); if (!isFinite(ts)) return ''; const o = fmtParts(ts), d = fmtDayNo(fmtParts(ioNow())) - fmtDayNo(o), hm = o.hour + ':' + o.minute; return d <= 0 ? tc('format.todayAt', hm) : d === 1 ? tc('format.yesterdayAt', hm) : d < 7 ? tc('format.daysAgo', Math.round((ioNow() - ts) / 864e5)) : tc('format.date', +o.month, +o.day) + ' ' + hm; },
|
|
15
|
+
floorMinutes: function (seconds) { return Math.floor(seconds / 60); },
|
|
16
|
+
num: function (n) { return Number(n).toLocaleString(); },
|
|
17
|
+
datetime: function (ts) { ts = fmtTs(ts); if (!isFinite(ts)) return ''; return new Date(ts).toLocaleString(undefined, { timeZone: WHO_DATA.me().timeZone || undefined }); },
|
|
18
|
+
date: function (ts) { ts = fmtTs(ts); if (!isFinite(ts)) return ''; return new Date(ts).toLocaleDateString(undefined, { timeZone: WHO_DATA.me().timeZone || undefined }); },
|
|
19
|
+
duration: function (sec) { return ENGINE_PARTS.duration(sec); },
|
|
20
|
+
clock: function (sec) { return clockText(sec); },
|
|
21
|
+
clockH: function (sec) { return clockText(sec, true); },
|
|
22
|
+
latency: function (ms) { return ms >= 1000 ? (ms / 1000).toFixed(1) + 's' : ms + 'ms'; },
|
|
23
|
+
compact: function (n) { return n >= 1e6 ? (n / 1e6).toFixed(2) + 'M' : n >= 1e3 ? (n / 1e3).toFixed(1) + 'k' : String(n); },
|
|
24
|
+
dec2: function (n) { return Number(n).toFixed(2); },
|
|
25
|
+
basename: function (path) { return String(path).replace(/:\d+(-\d+)?$/, '').split('/').filter(Boolean).pop(); },
|
|
26
|
+
localized: function (value) { if (typeof value === 'string') return value; const lang = S.lang || 'zh', t = value.translations || {}; return t[lang] || (lang === 'zh' ? t['zh-CN'] : '') || value.default; },
|
|
27
|
+
jsonValue: function (value) { return typeof value === 'string' ? value : JSON.stringify(value); },
|
|
28
|
+
json: function (value) { return JSON.stringify(value); },
|
|
29
|
+
/* 读的 JSON:对象 / JSON 串都分行缩进;不是 JSON 的字串原样 */
|
|
30
|
+
jsonPretty: function (value) { if (typeof value === 'string') { try { value = JSON.parse(value); } catch (e) { return value; } } return JSON.stringify(value, null, 2); },
|
|
31
|
+
jsonLines: function (entries) { return entries.map(function (entry) { return JSON.stringify(entry); }).join('\n'); },
|
|
32
|
+
noFinalPeriod: function (text) { return String(text).replace(/。$/, ''); },
|
|
33
|
+
stem: function (name) { return String(name).replace(/\.[^.]+$/, ''); },
|
|
34
|
+
markdown: function (text) { return mdLite(text); },
|
|
35
|
+
escaped: function (text) { return h(text); },
|
|
36
|
+
urlLabel: function (url) { return String(url).replace('https://', ''); },
|
|
37
|
+
dirname: function (path) { return String(path).split('/').slice(0, -1).join('/'); },
|
|
38
|
+
console: function (args) { return Array.isArray(args) ? args.map(function (v) { return typeof v === 'string' ? v : JSON.stringify(v); }).join(' ') : args; },
|
|
39
|
+
server: function (target) { return target.host + ':' + target.port; },
|
|
40
|
+
endpoint: function (target) { return FORMATS.server(target) + target.path; },
|
|
41
|
+
withoutMention: function (value) { return value.text.replace(new RegExp('^' + value.handle.replace(/[.*+?^${}()|[\]\\]/g, '\\$&') + '\\s*'), ''); },
|
|
42
|
+
toolCall: function (value) { const name = value.call ? value.call.toolName || value.call.label.replace(/^.*? → /, '') : value.label; return name + (value.input ? ' ' + value.input : ''); },
|
|
43
|
+
firstLine: function (text) { return String(text).split('\n').find(function (line) { return line.trim(); }); },
|
|
44
|
+
/* Markdown 的第一行当一行字(去掉标记)和其余部分:一段说明收起时只露第一行,展开时接着画后面的,不把第一行再画一遍 */
|
|
45
|
+
plainLine: function (text) { return htmlText(mdLite(FORMATS.firstLine(text) || '')); },
|
|
46
|
+
markdownRest: function (text) { const lines = String(text).split('\n'), i = lines.findIndex(function (line) { return line.trim(); }); const rest = lines.slice(i + 1).join('\n'); return rest.trim() ? mdLite(rest) : ''; },
|
|
47
|
+
identity: function (identity) { return whoText(identity); },
|
|
48
|
+
identityHandle: function (identity) { return whoText(identity, { handle: true }); },
|
|
49
|
+
color: function (value) { const c = whoColors('primary' in value ? { color: value } : value); return c.fixed || getComputedStyle(document.documentElement).getPropertyValue('--name-' + (c.step || 1)).trim().toLowerCase(); },
|
|
50
|
+
bytes: function (n) { const r = function (d) { return Math.round(n / d * 10) / 10; }; return n >= 1073741824 ? tc('format.gb', r(1073741824)) : n >= 1048576 ? tc('format.mb', r(1048576)) : tc('format.kb', r(1024)); }
|
|
51
|
+
};
|
|
52
|
+
ENGINE_PARTS.format = function (kind, v) { return FORMATS[kind](v); };
|
|
53
|
+
ENGINE_PARTS.duration = function (sec) { sec = Math.round(sec); return sec >= 60 ? tc('format.duration.minutesSeconds', Math.floor(sec / 60), sec % 60) : tc('format.duration.seconds', sec); };
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
/* 边界:一个含义一个组件、不为接口定制、不按位置推导样式 */
|
|
2
|
+
/* 插件框:iframe 的消息、生命周期、尺寸 */
|
|
3
|
+
'use strict';
|
|
4
|
+
/* 插件框:谁提供的在框的提示里,不写成框里的一句话 */
|
|
5
|
+
function frame(plugin, what, tall) { const d = WHO_DATA.plugins()[plugin] || { name: plugin, icon: 'robot' }; /* 没装的插件不在身份里:名字回退到 id */ return '<div class="frame' + (tall ? ' tall' : '') + '" data-tip="' + h(tc('frame.embeddedBy', d.name)) + '">' + icon(d.icon, 28) + '<b>' + h(what) + ('</b><span class="mono faint">plugin://') + plugin + '/' + (tall ? 'app' : 'settings') + '</span></div>'; }
|
|
6
|
+
|
|
7
|
+
/* 一次性发送:应用经引擎的既有登记点找指定的框;不保存消息,不在进树、重画或加载后重放。 */
|
|
8
|
+
ENGINE_PARTS.framePost = function (key, data) {
|
|
9
|
+
const el = Array.from(document.querySelectorAll('iframe[data-frame-key]')).find(function (frame) { return frame.dataset.frameKey === key && !frame.closest('[inert]'); });
|
|
10
|
+
if (!el) return false;
|
|
11
|
+
el.contentWindow.postMessage(data, '*'); return true;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
/* 独立 HTML 内容的通用数据绑定:属性变化只发消息,不重载 iframe。
|
|
15
|
+
消息含义由内容与应用约定,组件不认识页面或业务阶段。 */
|
|
16
|
+
function frameMessage(el) {
|
|
17
|
+
const value = el.getAttribute('data-frame-message');
|
|
18
|
+
if (el._frameMessage === value) return;
|
|
19
|
+
el.contentWindow.postMessage(JSON.parse(value), '*'); el._frameMessage = value;
|
|
20
|
+
}
|
|
21
|
+
function frameMessages() { document.querySelectorAll('iframe[data-frame-message]').forEach(frameMessage); }
|
|
22
|
+
onRender(frameMessages);
|
|
23
|
+
/* 框看不看得见(pdl-frame-lifecycle):画完、页面显隐变化、框说 ready 时告诉有名字的框;没变不重发 */
|
|
24
|
+
function frameLifecycles(force) {
|
|
25
|
+
document.querySelectorAll('iframe[data-frame-key]').forEach(function (f) {
|
|
26
|
+
const v = !document.hidden && f.isConnected && !f.closest('[inert]'); /* 被盖住的层是 inert */
|
|
27
|
+
if (!force && f._frameVisible === v) return;
|
|
28
|
+
f._frameVisible = v; if (f.contentWindow) f.contentWindow.postMessage({ type: 'pdl-frame-lifecycle', visible: v }, '*');
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
function frameVisibility() { frameLifecycles(false); }
|
|
32
|
+
onRender(frameVisibility);
|
|
33
|
+
document.addEventListener('visibilitychange', frameVisibility);
|
|
34
|
+
window.addEventListener('message', function (e) { if (e.data && e.data.type === 'pdl-frame-ready') frameLifecycles(true); });
|
|
35
|
+
/* 只认消息来自哪个框;消息协议与可信 origin 均交给应用动作。 */
|
|
36
|
+
window.addEventListener('message', function (e) {
|
|
37
|
+
const el = Array.from(document.querySelectorAll('iframe[data-frame-on-message]')).find(function (frame) { return frame.contentWindow === e.source; });
|
|
38
|
+
if (!el) return;
|
|
39
|
+
const fn = actFn(el.dataset.frameOnMessage); if (fn) fn(e.data, el, e);
|
|
40
|
+
});
|
|
41
|
+
document.addEventListener('load', function (e) {
|
|
42
|
+
if (e.target.matches && e.target.matches('iframe[data-frame-message]')) { e.target._frameMessage = null; frameMessage(e.target); }
|
|
43
|
+
}, true);
|
|
44
|
+
|
|
45
|
+
/* 沙箱只回报内容尺寸;父页按 source 找到自己的 iframe,不接受其他窗口的尺寸。 */
|
|
46
|
+
function frameSizeScript() {
|
|
47
|
+
const report = function () {
|
|
48
|
+
const body = document.body; let bottom = 0, seen = false;
|
|
49
|
+
const include = function (rect) { if (rect.width > 0 || rect.height > 0) { seen = true; bottom = Math.max(bottom, rect.bottom + window.scrollY); } };
|
|
50
|
+
body.querySelectorAll('*').forEach(function (el) { Array.from(el.getClientRects()).forEach(include); });
|
|
51
|
+
const walker = document.createTreeWalker(body, NodeFilter.SHOW_TEXT); let node;
|
|
52
|
+
while ((node = walker.nextNode())) { if (!node.textContent.trim()) continue; const range = document.createRange(); range.selectNodeContents(node); Array.from(range.getClientRects()).forEach(include); range.detach(); }
|
|
53
|
+
if (!seen) return; /* 内容还没排版(层刚露出来):不报,免得先报一个只有边距的高度再长回去 */
|
|
54
|
+
/* 内容的后缘 + body / html 自己的下内边距、边框、外边距;只量内容不量盒子,所以 height:100% 的视口底不算进来,量出的高度也不随框当前的高度变 */
|
|
55
|
+
[body, document.documentElement].forEach(function (el) { const style = getComputedStyle(el); ['paddingBottom', 'borderBottomWidth', 'marginBottom'].forEach(function (key) { bottom += Math.max(0, parseFloat(style[key]) || 0); }); });
|
|
56
|
+
parent.postMessage({ type: 'pdl-frame-size', height: Math.max(1, Math.ceil(bottom)) }, '*');
|
|
57
|
+
};
|
|
58
|
+
const start = function () { const observer = new ResizeObserver(report); observer.observe(document.body); document.body.querySelectorAll('*').forEach(function (el) { observer.observe(el); }); window.addEventListener('load', report); report(); };
|
|
59
|
+
if (document.readyState === 'loading') document.addEventListener('DOMContentLoaded', start, { once: true }); else start();
|
|
60
|
+
}
|
|
61
|
+
const FRAME_SIZE_PENDING = new Set(), FRAME_SIZE_HEIGHTS = new Map();
|
|
62
|
+
function frameSizeHold(el) {
|
|
63
|
+
const src = el.getAttribute('srcdoc');
|
|
64
|
+
if (el._frameSrc !== src) {
|
|
65
|
+
if (el._frameSizeDone) el._frameSizeDone();
|
|
66
|
+
el._frameSrc = src; el._frameSized = false; el._frameHeight = FRAME_SIZE_HEIGHTS.has(src) ? FRAME_SIZE_HEIGHTS.get(src) + 'px' : el._frameHeight; el._frameSizeDone = null;
|
|
67
|
+
}
|
|
68
|
+
if (el._frameHeight && el.style.height !== el._frameHeight) el.style.height = el._frameHeight; /* 量过的高度进树时直接设上,不写进画出来的标记:重画时标记不变,节点和高度都留着 */
|
|
69
|
+
if (el._frameSized || el._frameSizeDone || !el.offsetWidth) return; /* 藏着的框(被切走的层里)不等:它报来的高度不算数,露出来时再量 */
|
|
70
|
+
FRAME_SIZE_PENDING.add(el);
|
|
71
|
+
/* 静止前等它报一次高度;框在报之前被切走(报来时不占位)、被移除(onRender 里释放),或者等满两个慢动效的时长,也算等完,不会一直卡着 */
|
|
72
|
+
settleHold(new Promise(function (resolve) {
|
|
73
|
+
const done = function () { if (el._frameSizeDone !== done) return; el._frameSizeDone = null; FRAME_SIZE_PENDING.delete(el); resolve(); };
|
|
74
|
+
el._frameSizeDone = done; setTimeout(done, 2 * ms('--dur-slow'));
|
|
75
|
+
}));
|
|
76
|
+
}
|
|
77
|
+
treeMatch('iframe[data-frame-size]', frameSizeHold);
|
|
78
|
+
window.addEventListener('message', function (e) {
|
|
79
|
+
if (!e.data || e.data.type !== 'pdl-frame-size' || !Number.isFinite(e.data.height) || e.data.height < 1) return; /* 量到 0 = 框里还没排版(框被收起时发出的),不是内容的高度 */
|
|
80
|
+
const el = Array.from(document.querySelectorAll('iframe[data-frame-size]')).find(function (frame) { return frame.contentWindow === e.source; });
|
|
81
|
+
if (!el) return;
|
|
82
|
+
if (!el.offsetWidth) { if (el._frameSizeDone) el._frameSizeDone(); return; } /* 框此刻不在页面上占位:高度不算数,但这次等待算结束 */
|
|
83
|
+
const measured = Math.max(1, e.data.height), height = measured + 'px';
|
|
84
|
+
FRAME_SIZE_HEIGHTS.set(el.getAttribute('srcdoc'), measured);
|
|
85
|
+
if (el.style.height !== height) { el.style.height = height; settleHold(Promise.resolve()); }
|
|
86
|
+
el._frameHeight = height; el._frameSized = true;
|
|
87
|
+
if (el._frameSizeDone) { el._frameSizeDone(); el._frameSizeDone = null; FRAME_SIZE_PENDING.delete(el); }
|
|
88
|
+
});
|
|
89
|
+
/* HTML 作品请求跳转(pdl:html-widget-navigation,v 1):只认三种去处——本站某条对话里的某条消息、
|
|
90
|
+
OpenStreetMap 上的一个地点、本机 127.0.0.1 上的页面(避开宿主自己的端口);认得的交给动作 widgetNav 去开(去哪开是应用的事),其余不理 */
|
|
91
|
+
const WIDGET_NAV_RESERVED = [3001, 3002, 3003, 3004, 6397, 6398, 6399, 18888, 19999, 9876, 9877, 9878, 9879, 9880, 9881];
|
|
92
|
+
function widgetNavTarget(value) {
|
|
93
|
+
if (typeof value !== 'string' || value.length > 2048 || /[\s\\]/.test(value)) return null;
|
|
94
|
+
let url; try { url = new URL(value, location.origin); } catch (e) { return null; }
|
|
95
|
+
if (url.username || url.password || url.hash) return null;
|
|
96
|
+
const q = Array.from(url.searchParams), port = Number(url.port), thread = /^\/thread\/(thread_[A-Za-z0-9_-]{1,193})$/.exec(url.pathname);
|
|
97
|
+
if (value.indexOf('/thread/') === 0 && url.origin === location.origin && thread && q.length === 1 && (q[0][0] === 'message' || q[0][0] === 'messageId') && /^[A-Za-z0-9_-]{1,200}$/.test(q[0][1]))
|
|
98
|
+
return { kind: 'message', t: thread[1], mid: q[0][1] };
|
|
99
|
+
if (url.origin === 'https://www.openstreetmap.org' && /^\/(way|node|relation)\/\d+$/.test(url.pathname) && !q.length) return { kind: 'map', url: url.href };
|
|
100
|
+
if (url.protocol === 'http:' && url.hostname === '127.0.0.1' && url.pathname === '/' && port >= 1024 && port <= 65535 && WIDGET_NAV_RESERVED.indexOf(port) < 0 &&
|
|
101
|
+
(!q.length || (q.length === 1 && q[0][0] === 'asset' && /^[a-f0-9]{64}$/.test(q[0][1])))) return { kind: 'local', url: url.href };
|
|
102
|
+
return null;
|
|
103
|
+
}
|
|
104
|
+
window.addEventListener('message', function (e) {
|
|
105
|
+
if (!e.data || e.data.type !== 'pdl:html-widget-navigation' || e.data.v !== 1 || e.origin !== 'null') return;
|
|
106
|
+
const el = Array.from(document.querySelectorAll('iframe.vw-widget[srcdoc]')).find(function (frame) { return frame.contentWindow === e.source; });
|
|
107
|
+
const to = el && widgetNavTarget(e.data.href), open = to && actFn('widgetNav'); if (!open) return;
|
|
108
|
+
open(to);
|
|
109
|
+
e.source.postMessage({ type: 'pdl:html-widget-navigation-ready', v: 1 }, '*');
|
|
110
|
+
});
|
|
111
|
+
function frameSizePrune() {
|
|
112
|
+
document.querySelectorAll('iframe[data-frame-size]').forEach(function (el) { frameSizeHold(el); if (el._frameHeight) el.style.height = el._frameHeight; });
|
|
113
|
+
FRAME_SIZE_PENDING.forEach(function (el) { if (!el.isConnected) { el._frameSizeDone(); el._frameSizeDone = null; FRAME_SIZE_PENDING.delete(el); } });
|
|
114
|
+
}
|
|
115
|
+
onRender(frameSizePrune);
|
|
116
|
+
LOCAL_NORM.push(function (root) {
|
|
117
|
+
(root.matches('iframe[data-frame-size]') ? [root] : Array.from(root.querySelectorAll('iframe[data-frame-size]'))).forEach(function (el) { el.style.removeProperty('height'); if (!el.getAttribute('style')) el.removeAttribute('style'); });
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
PDL_COMPONENTS.documentTools = function (target) {
|
|
121
|
+
const frame = target?.frame, key = h(frame ?? target);
|
|
122
|
+
return '<div data-island="document-tools:' + key + '" ' + (frame ? 'data-document-frame' : 'data-document-tools') + '="' + key + '"></div>';
|
|
123
|
+
};
|