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,300 @@
|
|
|
1
|
+
/* 边界:一个含义一个组件、不为接口定制、不按位置推导样式 */
|
|
2
|
+
/* 主题计算器:组件库自带的主题编辑器 */
|
|
3
|
+
/* 主题计算器(组件库自带的主题编辑器:只用引擎的主题文档和组件库,不认识应用):用少量 OKLCH 参数算出整套语义变量,并实时显示关键文字的对比度。
|
|
4
|
+
它只改“当前主题”,不管理主题(列表、复制、切换都在主题页):当前是系统主题时,第一次改动先自动复制出自定义主题(带撤销提示),之后的改动直接写进它;每次改动都已保存,没有单独的保存按钮。
|
|
5
|
+
改动写进当前主题 × 当前浅/深色的值(themeVals),和主题页的逐项编辑共用保存与恢复。 */
|
|
6
|
+
'use strict';
|
|
7
|
+
/* 主题能设的语义变量(引擎的 TOKENS / LAYER_DERIVED):组件库的样式(css/core.css 顶部)读的就是这些;成员色 tint-* / name-* 各六档,层级推导的那几个主题只给叠多深 d-* */
|
|
8
|
+
TOKENS.push('bg-rail', 'bg-nav', 'bg-page', 'bg-group', 'bg-field', 'bg-hover', 'bg-selected', 'bg-bubble', 'bg-raised', 'bg-code',
|
|
9
|
+
'fg-strong', 'fg', 'fg-muted', 'fg-faint', 'fg-on-accent', 'accent', 'accent-hover', 'accent-soft', 'accent-fg', 'focus', 'switch-on',
|
|
10
|
+
'ok', 'warn', 'warn-soft', 'danger', 'danger-soft', 'info', 'line', 'line-strong', 'font-display',
|
|
11
|
+
'd-hover', 'd-btn', 'd-selected', 'd-inset', 'd-code', 'd-line', 'd-line-strong');
|
|
12
|
+
[1, 2, 3, 4, 5, 6].forEach(function (n) { TOKENS.push('tint-' + n, 'name-' + n); });
|
|
13
|
+
LAYER_DERIVED.push('bg-hover', 'bg-selected', 'bg-field', 'bg-code', 'line', 'line-strong');
|
|
14
|
+
|
|
15
|
+
/* ── 参数 ⇄ token(文案在画的时候取:文案包在组件库之后加载,切换语言也会即时生效) ── */
|
|
16
|
+
function calcGroups() { return [
|
|
17
|
+
['accent', tc('themeCalc.group.text'), tc('themeCalc.group.accentHelp'), [['aH', tc('themeCalc.group.hue'), 0, 360, 1], ['aC', tc('themeCalc.group.chroma'), 0, 0.3, 0.005], ['aL', tc('control.colorLight'), 0.3, 0.9, 0.005]]],
|
|
18
|
+
['layers', tc('themeCalc.group.surfaces'), tc('themeCalc.group.surfacesHelp'), [['nH', tc('themeCalc.group.hue'), 0, 360, 1], ['nC', tc('themeCalc.group.chroma'), 0, 0.05, 0.001], ['rail', tc('theme.tokens.rail'), 0, 1, 0.005], ['nav', tc('theme.tokens.sidebar'), 0, 1, 0.005], ['page', tc('theme.tokens.page'), 0, 1, 0.005], ['group', tc('themeCalc.group.groupSurface'), 0, 1, 0.005], ['dHover', tc('themeCalc.group.hoverOverlay'), 0, 0.3, 0.005], ['dSelected', tc('themeCalc.group.selectedOverlay'), 0, 0.3, 0.005], ['dInset', tc('themeCalc.group.inputOverlay'), 0, 0.3, 0.005]]],
|
|
19
|
+
['bubble', tc('themeCalc.group.messageAndCode'), tc('themeCalc.group.messageAndCodeHelp'), [['uH', tc('themeCalc.group.bubbleHue'), 0, 360, 1], ['uC', tc('themeCalc.group.bubbleChroma'), 0, 0.1, 0.002], ['uL', tc('themeCalc.group.bubbleLightness'), 0, 1, 0.005], ['dCode', tc('themeCalc.group.inlineCodeOverlay'), 0, 0.3, 0.005]]],
|
|
20
|
+
['text', tc('themeCalc.group.typographyAndLines'), tc('themeCalc.group.typographyAndLinesHelp'), [['tC', tc('themeCalc.group.textChroma'), 0, 0.03, 0.001], ['strong', tc('themeCalc.group.primaryText'), 0, 1, 0.005], ['fg', tc('themeCalc.group.secondaryText'), 0, 1, 0.005], ['muted', tc('common.note'), 0, 1, 0.005], ['faint', tc('themeCalc.group.placeholderAndDisabled'), 0, 1, 0.005], ['dLine', tc('themeCalc.group.dividerOverlay'), 0, 0.4, 0.005], ['dLineS', tc('themeCalc.group.emphasisLineOverlay'), 0, 0.4, 0.005]]],
|
|
21
|
+
['names', tc('themeCalc.group.memberColors'), tc('themeCalc.group.memberColorsHelp'), [['mL', tc('themeCalc.group.identityLightness'), 0.3, 0.9, 0.005], ['mC', tc('themeCalc.group.identityChroma'), 0, 0.2, 0.005], ['tL', tc('themeCalc.group.avatarLightness'), 0, 1, 0.005], ['tTC', tc('themeCalc.group.avatarChroma'), 0, 0.1, 0.002]]],
|
|
22
|
+
['status', tc('theme.tokens.status'), tc('themeCalc.group.statusHelp'), [['sL', tc('control.colorLight'), 0.3, 0.9, 0.005], ['sC', tc('themeCalc.group.chroma'), 0, 0.25, 0.005], ['okH', tc('themeCalc.group.normalHue'), 0, 360, 1], ['warnH', tc('themeCalc.group.warningHue'), 0, 360, 1], ['dangerH', tc('themeCalc.group.dangerHue'), 0, 360, 1], ['dangerL', tc('themeCalc.group.dangerL'), 0.3, 0.9, 0.005], ['infoH', tc('themeCalc.group.informationHue'), 0, 360, 1], ['softL', tc('themeCalc.group.hintBackgroundLightness'), 0, 1, 0.005]]]
|
|
23
|
+
]; }
|
|
24
|
+
function calcRead() {
|
|
25
|
+
const cs = getComputedStyle(document.documentElement), t = function (k) { return hexOk(cs.getPropertyValue('--' + k).trim()); };
|
|
26
|
+
const page = t('bg-page'), acc = t('accent'), ub = t('bg-bubble'), w = t('warn'), n1 = t('name-1'), t1 = t('tint-1'), fs = t('fg-strong');
|
|
27
|
+
return { aH: acc.H, aC: acc.C, aL: acc.L, nH: page.H, nC: page.C, rail: t('bg-rail').L, nav: t('bg-nav').L, page: page.L, group: t('bg-group').L,
|
|
28
|
+
uH: ub.H, uC: ub.C, uL: ub.L,
|
|
29
|
+
tC: fs.C, strong: fs.L, fg: t('fg').L, muted: t('fg-muted').L, faint: t('fg-faint').L,
|
|
30
|
+
mL: n1.L, mC: n1.C, m1: n1.H, m2: t('name-2').H, m3: t('name-3').H, m4: t('name-4').H, m5: t('name-5').H, m6: t('name-6').H, tL: t1.L, tTC: t1.C,
|
|
31
|
+
sL: w.L, sC: w.C, okH: t('ok').H, warnH: w.H, dangerH: t('danger').H, dangerL: t('danger').L, infoH: t('info').H, softL: t('warn-soft').L,
|
|
32
|
+
dHover: layerPct('d-hover'), dBtn: layerPct('d-btn'), dSelected: layerPct('d-selected'), dInset: layerPct('d-inset'), dCode: layerPct('d-code'), dLine: layerPct('d-line'), dLineS: layerPct('d-line-strong') };
|
|
33
|
+
}
|
|
34
|
+
function layerPct(name) { const v = getComputedStyle(document.documentElement).getPropertyValue('--' + name).trim(); return (parseFloat(v) || 0) / 100; }
|
|
35
|
+
function calcTokens(P, dark) {
|
|
36
|
+
const n = function (L, C) { return okHex(L, C == null ? P.nC : C, P.nH); }, tx = function (L) { return okHex(L, P.tC, P.nH); };
|
|
37
|
+
const soft = function (H) { return okHex(P.softL, Math.min(0.06, P.sC * 0.35), H); };
|
|
38
|
+
const T = {
|
|
39
|
+
'accent': okHex(P.aL, P.aC, P.aH), 'accent-hover': okHex(P.aL + (dark ? 0.06 : -0.07), P.aC, P.aH), 'accent-fg': okHex(P.aL + (dark ? 0.08 : -0.08), P.aC, P.aH),
|
|
40
|
+
'accent-soft': okHex(dark ? 0.3 : 0.93, P.aC * 0.25, P.aH), 'focus': okHex(P.aL, P.aC, P.aH),
|
|
41
|
+
'bg-rail': n(P.rail), 'bg-nav': n(P.nav), 'bg-page': n(P.page), 'bg-group': n(P.group), 'bg-raised': n(P.group),
|
|
42
|
+
'bg-bubble': okHex(P.uL, P.uC, P.uH),
|
|
43
|
+
'fg-strong': tx(P.strong), 'fg': tx(P.fg), 'fg-muted': tx(P.muted), 'fg-faint': tx(P.faint), 'switch-on': okHex(P.aL, P.aC, P.aH), /* 开关开着 = 强调色 */
|
|
44
|
+
'ok': okHex(P.sL, P.sC, P.okH), 'warn': okHex(P.sL, P.sC, P.warnH), 'danger': okHex(P.dangerL != null ? P.dangerL : P.sL, P.sC, P.dangerH), 'info': okHex(P.sL, P.sC, P.infoH), 'warn-soft': soft(P.warnH), 'danger-soft': soft(P.dangerH)
|
|
45
|
+
};
|
|
46
|
+
for (let i = 1; i <= 6; i++) { T['name-' + i] = okHex(P.mL, P.mC, P['m' + i]); T['tint-' + i] = okHex(P.tL, P.tTC, P['m' + i]); }
|
|
47
|
+
/* 悬停、选中、内嵌、行内代码、分隔线是叠在所在层上的墨色:只输出叠多深(见 core.css 的推导块) */
|
|
48
|
+
const pc = function (x) { return Math.round(x * 1000) / 10 + '%'; };
|
|
49
|
+
T['d-hover'] = pc(P.dHover); T['d-btn'] = pc(P.dBtn); T['d-selected'] = pc(P.dSelected); T['d-inset'] = pc(P.dInset); T['d-code'] = pc(P.dCode); T['d-line'] = pc(P.dLine); T['d-line-strong'] = pc(P.dLineS);
|
|
50
|
+
return T;
|
|
51
|
+
}
|
|
52
|
+
/* 对比度要检查的几对:文案在画的时候取(文案包在组件库之后加载) */
|
|
53
|
+
function calcPairs() { return [
|
|
54
|
+
[tc('themeCalc.contrastPairs.text'), 'fg-strong', 'bg-page', 4.5], [tc('themeCalc.contrastPairs.secondaryOnGroup'), 'fg', 'bg-group', 4.5], [tc('themeCalc.contrastPairs.descriptionOnGroup'), 'fg-muted', 'bg-group', 4.5], [tc('themeCalc.contrastPairs.placeholderOnInput'), 'fg-faint', 'bg-field', 3],
|
|
55
|
+
[tc('themeCalc.contrastPairs.buttonOnAccent'), 'fg-on-accent', 'accent', 4.5], [tc('themeCalc.contrastPairs.linkOnPage'), 'accent-fg', 'bg-page', 4.5], [tc('themeCalc.contrastPairs.textOnBubble'), 'fg-strong', 'bg-bubble', 4.5],
|
|
56
|
+
[tc('themeCalc.contrastPairs.memberOnPage'), 'NAMEMIN', 'bg-page', 3], [tc('themeCalc.contrastPairs.warningOnGroup'), 'warn', 'bg-group', 3], [tc('themeCalc.contrastPairs.dangerOnGroup'), 'danger', 'bg-group', 3],
|
|
57
|
+
[tc('themeCalc.contrastPairs.groupOnPage'), 'bg-group', 'bg-page', 1.04]
|
|
58
|
+
]; }
|
|
59
|
+
|
|
60
|
+
/* ── 面板 ── */
|
|
61
|
+
S.calc = { open: false, P: null, mode: null, fold: {}, tab: 'colors', ct: null }; /* tab:配色 / 背景 / 结构;ct:结构页里选中的容器。拖动、×、Esc 都来自弹窗框架(PDL_POPUPS.calc) */
|
|
62
|
+
function calcMode() { return stMode(); }
|
|
63
|
+
function calcEnsure() {
|
|
64
|
+
const mode = calcMode(), themeId = pdlThemes().active;
|
|
65
|
+
if (S.calc.P && S.calc.mode === mode && S.calc.themeId === themeId) return;
|
|
66
|
+
S.calc.P = calcRead();
|
|
67
|
+
S.calc.mode = mode;
|
|
68
|
+
S.calc.themeId = themeId;
|
|
69
|
+
}
|
|
70
|
+
function calcApply() {
|
|
71
|
+
const T = calcTokens(S.calc.P, S.calc.mode === 'dark'), mode = S.calc.mode;
|
|
72
|
+
themeValsEdit(S.pdlPalette, function (v) { v[mode] = Object.assign(v[mode] || {}, T); }); /* 内置配色:改动进当前主题文档(系统主题上先自动复制出自定义主题) */
|
|
73
|
+
const de = document.documentElement; Object.keys(T).forEach(function (k) { de.style.setProperty('--' + k, T[k]); });
|
|
74
|
+
calcReadouts();
|
|
75
|
+
}
|
|
76
|
+
/* 对比度:叠加色先合成到它所在的层上再算 */
|
|
77
|
+
function layerOver(tok, base) {
|
|
78
|
+
const probe = document.createElement('div'); probe.style.cssText = 'position:absolute;visibility:hidden;background:var(--' + tok + ')'; document.body.appendChild(probe);
|
|
79
|
+
const c = getComputedStyle(probe).backgroundColor; probe.remove();
|
|
80
|
+
const b = getComputedStyle(document.documentElement).getPropertyValue('--' + base).trim();
|
|
81
|
+
const m = /rgba?\(([\d.]+),\s*([\d.]+),\s*([\d.]+)(?:,\s*([\d.]+))?/.exec(c) || /color\(srgb ([\d.]+) ([\d.]+) ([\d.]+)(?: \/ ([\d.]+))?/.exec(c);
|
|
82
|
+
if (!m) return b;
|
|
83
|
+
const scale = c.indexOf('color(') === 0 ? 255 : 1, a = m[4] == null ? 1 : +m[4];
|
|
84
|
+
const bh = toHex(b), br = parseInt(bh.slice(1, 3), 16), bg = parseInt(bh.slice(3, 5), 16), bb = parseInt(bh.slice(5, 7), 16);
|
|
85
|
+
const mix = function (x, y) { return Math.round(x * scale * a + y * (1 - a)); };
|
|
86
|
+
return '#' + [mix(+m[1], br), mix(+m[2], bg), mix(+m[3], bb)].map(function (x) { return Math.max(0, Math.min(255, x)).toString(16).padStart(2, '0'); }).join('');
|
|
87
|
+
}
|
|
88
|
+
function calcReadouts() {
|
|
89
|
+
/* 对比度表读的是变量的值;叠加类的变量先换成“合成到所在层后”的颜色,读完再还原 */
|
|
90
|
+
const de = document.documentElement, solid = [['bg-field', 'bg-group'], ['bg-selected', 'bg-nav'], ['bg-hover', 'bg-page'], ['bg-code', 'bg-group']].map(function (x) { return [x[0], layerOver(x[0], x[1])]; });
|
|
91
|
+
solid.forEach(function (x) { de.style.setProperty('--' + x[0], x[1]); });
|
|
92
|
+
try { calcReadoutsRaw(); } finally { solid.forEach(function (x) { de.style.removeProperty('--' + x[0]); }); }
|
|
93
|
+
}
|
|
94
|
+
function calcReadoutsRaw() {
|
|
95
|
+
const cs = getComputedStyle(document.documentElement), g = function (k) { return cs.getPropertyValue('--' + k).trim(); };
|
|
96
|
+
const box = document.getElementById('calc-contrast'); if (!box) return;
|
|
97
|
+
box.innerHTML = calcPairs().map(function (p) {
|
|
98
|
+
let fgc = g(p[1]);
|
|
99
|
+
if (p[1] === 'NAMEMIN') { fgc = [1, 2, 3, 4, 5, 6].map(function (i) { return g('name-' + i); }).sort(function (a, b) { return contrast(a, g(p[2])) - contrast(b, g(p[2])); })[0]; }
|
|
100
|
+
const r = contrast(fgc, g(p[2])), layer = p[3] < 2, ok = r >= p[3];
|
|
101
|
+
return '<div class="calc-pair"><span class="calc-sw" style="background:' + g(p[2]) + ';color:' + fgc + (tc('themeCalc.readouts.previewMarkup')) + h(p[0]) + '</span><span class="num ' + (ok ? '' : 'calc-bad') + '">' + r.toFixed(2) + '</span><span class="calc-mark">' + (layer ? (ok ? tc('themeCalc.readouts.noticeable') : tc('themeCalc.readouts.tooClose')) : (r >= 4.5 ? 'AA' : r >= 3 ? tc('themeCalc.readouts.largeText') : tc('themeCalc.readouts.insufficient'))) + '</span></div>';
|
|
102
|
+
}).join('');
|
|
103
|
+
calcGroups().forEach(function (gr) { const sw = document.getElementById('calc-sw-' + gr[0]); if (sw) sw.innerHTML = calcSwatches(gr[0]); });
|
|
104
|
+
}
|
|
105
|
+
function calcSwatches(k) {
|
|
106
|
+
const cs = getComputedStyle(document.documentElement), list = { accent: ['accent', 'accent-hover', 'accent-soft', 'accent-fg'], layers: ['bg-rail', 'bg-nav', 'bg-page', 'bg-group', 'bg-field', 'bg-selected'], bubble: ['bg-bubble', 'bg-code'], text: ['fg-strong', 'fg', 'fg-muted', 'fg-faint', 'line', 'line-strong'], names: ['name-1', 'name-2', 'name-3', 'name-4', 'name-5', 'name-6'], status: ['ok', 'warn', 'danger', 'info', 'warn-soft', 'danger-soft'] }[k];
|
|
107
|
+
return list.map(function (t) { return '<i data-tip="--' + t + '" style="background:' + cs.getPropertyValue('--' + t).trim() + '"></i>'; }).join('');
|
|
108
|
+
}
|
|
109
|
+
/* 计算器是一个普通的弹窗(PDL_POPUPS.calc:在角上,× + Esc 关,能拖,不是模态),用通用的对话框组件(dialogHtml)画:同一个面、同一个标题行、同一个正文滚动。
|
|
110
|
+
标题行:切浅 / 深、编辑布局、⋯(恢复默认布局、查看页面描述)、×;两个标签页(配色 / 结构)同一个标题行。页面样式的入口都收在这里 */
|
|
111
|
+
function calcHtml() {
|
|
112
|
+
calcEnsure();
|
|
113
|
+
const tab = S.calc.tab || 'colors';
|
|
114
|
+
const tabs = seg([['colors', 'structure.tabColors'], ['tree', 'structure.tab']].map(function (t) { return { v: t[0], label: tc(t[1]), active: tab === t[0] }; }), 'set', undefined, '', ' data-path="s.calc.tab"');
|
|
115
|
+
const html = dialogHtml({ key: 'calc', modal: false, title: tc('theme.calculator'),
|
|
116
|
+
actions: btn(S.calc.mode === 'dark' ? tc('themeCalc.controls.switchLight') : tc('themeCalc.controls.switchDark'), { sm: true, act: 'calcFlip' }) +
|
|
117
|
+
btn(tc('pdlDoc.editing'), { sm: true, act: S.editLayout ? 'close' : 'set', data: ' data-path="s.editLayout"' + (S.editLayout ? '' : ' data-v="true" data-cast="bool"'), pressed: !!S.editLayout }) + moreBtn('calcMore'),
|
|
118
|
+
body: tabs + (tab === 'tree' ? calcTreeHtml() : calcColorsHtml()),
|
|
119
|
+
acts: tab === 'colors' ? [[tc('themeCalc.controls.copyParameters'), { icon: 'copy', act: 'copy', data: argAttrs({ v: calcCopyText() }) }], [tc('themeCalc.controls.reset'), { act: 'reset', data: ' data-scope="calc"' }]] : null }); /* 标题行不带主题名 / 浅深;背景归结构的根容器 */
|
|
120
|
+
return html + '<div class="overlay-host" data-calc-rings></div>';
|
|
121
|
+
}
|
|
122
|
+
/* 配色页:背景(和主题页的“背景”一节是同一份数据、同一个视图,两个入口)、对比度、各组参数 */
|
|
123
|
+
function calcColorsHtml() {
|
|
124
|
+
const P = S.calc.P;
|
|
125
|
+
return '<div class="calc-sec"><div class="calc-sec-h">' + h(tc('themeCalc.contrast')) + '</div><div id="calc-contrast"></div></div>' +
|
|
126
|
+
calcGroups().map(function (g) {
|
|
127
|
+
const fold = S.calc.fold[g[0]];
|
|
128
|
+
return '<div class="calc-sec"><button type="button" class="calc-sec-h" data-act="toggle" data-path="s.calc.fold.' + g[0] + '" aria-expanded="' + !fold + '">' + twisty(!(fold)) + h(g[1]) + '<span class="calc-sws" id="calc-sw-' + g[0] + '"></span></button>' +
|
|
129
|
+
(fold ? '' : '<p class="calc-help">' + h(g[2]) + '</p>' + g[3].map(function (s) {
|
|
130
|
+
const v = P[s[0]], dec = s[4] < 1 ? (s[4] < 0.01 ? 3 : 2) : 0;
|
|
131
|
+
return '<label class="calc-row"><span>' + h(s[1]) + '</span><input type="range" min="' + s[2] + '" max="' + s[3] + '" step="' + s[4] + '" value="' + v + '" data-calc="' + s[0] + '" aria-label="' + h(g[1] + ' ' + s[1]) + '"><output class="num" id="calc-o-' + s[0] + '">' + Number(v).toFixed(dec) + '</output></label>';
|
|
132
|
+
}).join('')) + '</div>';
|
|
133
|
+
}).join('');
|
|
134
|
+
}
|
|
135
|
+
/* ⋯:布局的两个动作 */
|
|
136
|
+
MENU_FNS.calcMore = function () { return [{ label: tc('themeEntries.resetLayout'), act: 'reset', data: { scope: 'layout' }, why: S.pdlDoc ? '' : tc('themeEntries.resetOff') }, { label: tc('themeEntries.viewPdl'), act: 'dialog', data: { kind: 'pdl' } }]; };
|
|
137
|
+
/* 结构页:容器树(只有容器,没有元素)。每一行是一个容器:名字、方向;加子容器、删除(只有空的能删)用行上的图标,移动 / 换父容器是拖动这一行
|
|
138
|
+
(放在另一行的上半 / 下半 = 前面 / 后面,中间 = 里面)。下面是选中的容器的属性:名字、方向、在父容器里的份额 */
|
|
139
|
+
function calcTreeHtml() {
|
|
140
|
+
const t = pdlTree(), sel = pdlCtInfo(S.calc.ct) ? S.calc.ct : t.key;
|
|
141
|
+
const dirLabel = function (d) { return tc(d === 'row' ? 'structure.dirRow' : 'structure.dirCol'); };
|
|
142
|
+
const label = function (n) { return n.label || (pdlLayout().regions[n.key] || {}).label || n.key; };
|
|
143
|
+
if (!S.folds[FOLD_TREE + 'calc-tree']) S.folds[FOLD_TREE + 'calc-tree'] = { [t.key]: true };
|
|
144
|
+
const tree = ltree('calc-tree', function (path) {
|
|
145
|
+
const kids = path ? pdlTreeFind(t, path).n.kids || [] : [t];
|
|
146
|
+
return kids.map(function (n) {
|
|
147
|
+
const info = pdlCtInfo(n.key);
|
|
148
|
+
return { name: label(n), path: n.key, dir: !!(n.kids && n.kids.length),
|
|
149
|
+
pick: { act: 'set', data: ' data-path="s.calc.ct" data-v="' + h(n.key) + '"' },
|
|
150
|
+
row: { hook: 'calc-ct', rootAttrs: ' data-ct-row="' + h(n.key) + '"' + (info.whyMove || !info.parent ? ' data-locked="1"' : ' data-edit="ct"'), cur: sel === n.key,
|
|
151
|
+
lead: icon(n.kids && n.kids.length ? 'layers' : 'panel', 14), inline: info.locked ? '<span class="faint" data-tip="' + h(tc('structure.whyLocked')) + '">' + icon('lock', 12) + '</span>' : '',
|
|
152
|
+
sub: h(n.key) + ' · ' + h(dirLabel(n.dir)) + (info.empty ? ' · ' + h(tc('structure.empty')) : ''), /* 容器 id(不可改)+ 方向 */
|
|
153
|
+
acts: [{ label: tc('structure.add'), icon: 'plus', act: 'calcCtAdd', data: ' data-k="' + h(n.key) + '"', why: info.accepts ? '' : tc('structure.whyNoKids') }, { label: tc('common.delete'), icon: 'delete', act: 'calcCtDel', data: ' data-k="' + h(n.key) + '"', why: info.whyDel }] } };
|
|
154
|
+
});
|
|
155
|
+
}, { ready: true });
|
|
156
|
+
const si = pdlCtInfo(sel), n = si.node, fixed = si.builtin ? tc('structure.whyBuiltinProps') : '';
|
|
157
|
+
const props = '<div class="calc-sec"><div class="calc-sec-h">' + h(tc('structure.props')) + '</div>' +
|
|
158
|
+
'<label class="calc-row"><span>' + h(tc('structure.name')) + helpTip(tc('structure.helpName')) + '</span><input class="input" id="calc-ct-name" data-change="calcCtName" value="' + h(label(n)) + '" data-calc-ct="' + h(sel) + '" aria-label="' + h(tc('structure.name')) + '"><span></span></label>' + /* 名字只是显示:每个容器都能改(内置的、锁定的也一样) */
|
|
159
|
+
'<div class="calc-row"><span>' + h(tc('structure.dir')) + helpTip(tc('structure.helpDir')) + '</span>' + seg(['column', 'row'].map(function (d) { return { v: d, g: sel, label: dirLabel(d), active: (n.dir || 'column') === d, why: fixed }; }), 'setStatus', undefined, '', ' data-entity="ct" data-id="' + h(sel) + '" data-field="dir"') + '<span></span></div>' +
|
|
160
|
+
'<div class="calc-row"><span>' + h(tc('structure.span')) + helpTip(tc('structure.helpSpan')) + '</span>' + seg(['fit', '1', '2', '3'].map(function (x) { return { v: x, g: sel, label: tcOf('structure.spanOptions', x), active: String(n.span || 'fit') === x, why: fixed || (si.parent ? '' : tc('structure.whyLocked')) }; }), 'setStatus', undefined, '', ' data-entity="ct" data-id="' + h(sel) + '" data-field="span"') + '<span></span></div>' +
|
|
161
|
+
'<div class="calc-row"><span>' + h(tc('structure.hideEmpty')) + helpTip(tc('structure.helpHideEmpty')) + '</span>' + sw(!!n.hideEmpty, 'calcCtHideEmpty', ' data-k="' + h(sel) + '"', tc('structure.hideEmpty'), !!(n.pages || n.space || n.tabs)) + '<span></span></div>' +
|
|
162
|
+
(n.surface || !n.flat && !(n.kids || []).length ? calcSurfaceHtml(sel) : '') + '</div>';
|
|
163
|
+
return '<div class="calc-sec calc-tree">' + tree + '</div>' + props + calcPolicyHtml(si, t, label) + calcHostsHtml(si, t, label);
|
|
164
|
+
}
|
|
165
|
+
/* 选中的容器的打开策略:这里的按钮默认开到哪(opens,声明在容器里的内容容器上;没有内容容器的容器声明在自己身上),选了强制就一律按它;
|
|
166
|
+
下面是这个容器里的按钮,各自跟随容器或单独指定 */
|
|
167
|
+
function calcPolicyHtml(si, t, label) {
|
|
168
|
+
const k = si.node.key, opts = [], slots = (si.node.slots || []).filter(pdlSlotDef);
|
|
169
|
+
pdlTreeWalk(t, function (n) { opts.push({ v: n.key, label: label(n) }); });
|
|
170
|
+
const holders = slots.length ? slots.map(function (sl) { return { kind: 'slot', id: sl, name: pdlText(pdlSlotDef(sl).label) || sl, rule: pdlSlotDef(sl).opens || null }; })
|
|
171
|
+
: [{ kind: 'ct', id: k, name: '', rule: si.node.opens || null }];
|
|
172
|
+
const data = function (x) { return ' data-kind="' + x.kind + '" data-id="' + h(x.id) + '"'; };
|
|
173
|
+
const policy = '<div class="calc-sec"><div class="calc-sec-h">' + h(tc('structure.openPolicy')) + helpTip(tc('structure.helpOpenPolicy')) + '</div>' + holders.map(function (x) {
|
|
174
|
+
return srow(holders.length > 1 ? x.name : tc('structure.openTo'), pick('calc-opens-' + x.id, [{ v: '', label: tc('structure.openUnset') }].concat(opts), x.rule ? x.rule.anchor : '', tc('structure.openTo'), 'calcCtOpens', data(x))) +
|
|
175
|
+
srow(tc('structure.force'), sw(!!(x.rule && x.rule.force), 'calcCtForce', data(x), tc('structure.force'), !x.rule));
|
|
176
|
+
}).join('') + '</div>';
|
|
177
|
+
const trig = pdlEntryIds().filter(function (id) { const e = pdlEntry(id), sl = pdlSlotOf(id); return sl && pdlSlotBox(sl) === k && e && e.open && !e.open.ref && !e.open.action && !e.open.space; });
|
|
178
|
+
if (!trig.length) return policy;
|
|
179
|
+
return policy + '<div class="calc-sec"><div class="calc-sec-h">' + h(tc('structure.triggersHere')) + helpTip(tc('structure.helpTriggersHere')) + '</div>' + trig.map(function (id) {
|
|
180
|
+
const e = pdlEntry(id), o = pdlOpenOf(id), own = e.open.anchor || e.open.as ? o.target || '' : '';
|
|
181
|
+
return srow(e.title || id, o.forced ? muted(h(tc('structure.whyForced'))) : pick('calc-trig-' + id, [{ v: '', label: tc('structure.followContainer') }].concat(opts), own, tc('structure.openTo'), 'calcTrigTo', ' data-id="' + h(id) + '"'));
|
|
182
|
+
}).join('') + '</div>';
|
|
183
|
+
}
|
|
184
|
+
/* 改一处打开策略:内容容器的在主题文档的 slots 里,容器自己的在容器树上 */
|
|
185
|
+
function calcOpensSet(kind, id, fn) {
|
|
186
|
+
if (kind === 'slot') pdlDocNodes(function (own) { const box = own('slots', id), next = fn(box.opens || null); if (next) box.opens = next; else delete box.opens; });
|
|
187
|
+
else pdlCtSet(id, { opens: fn(pdlCtInfo(id).node.opens || null) || undefined });
|
|
188
|
+
render(true); calcDraw();
|
|
189
|
+
}
|
|
190
|
+
CHANGES.calcCtOpens = function (e) { const v = e.target.value; calcOpensSet(e.target.dataset.kind, e.target.dataset.id, function (rule) { return v ? Object.assign({}, rule, { anchor: v, as: (rule && rule.as) || 'cover' }) : null; }); };
|
|
191
|
+
A.calcCtForce = function (d) { calcOpensSet(d.kind, d.id, function (rule) { return rule && Object.assign({}, rule, { force: !rule.force }); }); };
|
|
192
|
+
/* 按钮跟随容器 = 去掉它自己的 anchor / depth / as;单独指定 = 和“开在这里的按钮”同一个改法 */
|
|
193
|
+
CHANGES.calcTrigTo = function (e) {
|
|
194
|
+
const id = e.target.dataset.id, v = e.target.value;
|
|
195
|
+
if (v) pdlOpenRebind(id, v);
|
|
196
|
+
else { const open = Object.assign({}, pdlEntry(id).open); delete open.anchor; delete open.depth; delete open.as; pdlNodeSet(id, { open: open }); }
|
|
197
|
+
render(true); calcDraw();
|
|
198
|
+
};
|
|
199
|
+
/* 选中的容器里会打开东西的按钮:每个按钮单独改开到哪(用户容器要删时先在这里迁移承载);所在容器强制去处的按钮改不了 */
|
|
200
|
+
function calcHostsHtml(si, t, label) {
|
|
201
|
+
if (!si.hosts.length) return '';
|
|
202
|
+
const opts = []; pdlTreeWalk(t, function (n) { opts.push({ v: n.key, label: label(n) }); });
|
|
203
|
+
return '<div class="calc-sec"><div class="calc-sec-h">' + h(tc('structure.opensHere')) + helpTip(tc('structure.helpOpensHere')) + '</div>' + si.hosts.map(function (id) {
|
|
204
|
+
const e = pdlEntry(id), o = pdlOpenOf(id);
|
|
205
|
+
return srow(e.title || id, o.forced ? muted(h(tc('structure.whyForced'))) : pick('calc-open-' + id, opts, si.node.key, tc('structure.openTo'), 'calcOpenTo', ' data-id="' + h(id) + '"'));
|
|
206
|
+
}).join('') + '</div>';
|
|
207
|
+
}
|
|
208
|
+
/* 同一个容器属性编辑器;根容器使用全局背景视图,子容器只编辑声明。 */
|
|
209
|
+
function calcSurfaceHtml(key) {
|
|
210
|
+
const surface = bgState().planes[key];
|
|
211
|
+
const modes = [['relative', tc('structure.surface.relative')], ['absolute', tc('structure.surface.absolute')]].map(function (mode) { return { v: mode[0], label: mode[1], active: surface.mode === mode[0] }; });
|
|
212
|
+
return '<div class="calc-row"><span>' + h(tc('structure.surface.label')) + helpTip(tc('structure.surface.help')) + '</span>' + seg(modes, 'calcCtSurface', undefined, '', ' data-k="' + h(key) + '"') + '<span></span></div>' +
|
|
213
|
+
'<label class="calc-row"><span>' + h(tc('themeBackground.opacity')) + '</span><input type="range" id="calc-ct-opacity" min="0" max="100" step="1" value="' + (100 - surface.opacity) + '" data-input="ctBg" data-k="' + h(key) + '" aria-label="' + h(tc('themeBackground.opacity')) + '"><output id="calc-ct-opacity-o">' + (100 - surface.opacity) + '%</output></label>' +
|
|
214
|
+
'<label class="calc-row"><span>' + h(tc('themeBackground.blur')) + '</span><input type="range" id="calc-ct-blur" min="0" max="30" step="1" value="' + surface.blur + '" data-input="ctBg" data-field="blur" data-k="' + h(key) + '" aria-label="' + h(tc('themeBackground.blur')) + '"><output id="calc-ct-blur-o">' + surface.blur + 'px</output></label>';
|
|
215
|
+
}
|
|
216
|
+
A.calcCtSurface = function (d) {
|
|
217
|
+
const surface = bgState().planes[d.k];
|
|
218
|
+
pdlCtSet(d.k, { surface: { mode: d.v, opacity: d.v === 'absolute' ? surface.value : surface.opacity, blur: surface.blur } });
|
|
219
|
+
render(true); calcDraw();
|
|
220
|
+
};
|
|
221
|
+
INPUTS.ctBg = function (e) {
|
|
222
|
+
const key = e.target.dataset.k, field = e.target.dataset.field || 'opacity', current = bgState().planes[key];
|
|
223
|
+
const surface = { mode: current.mode, opacity: current.opacity, blur: current.blur };
|
|
224
|
+
surface[field] = field === 'opacity' ? 100 - +e.target.value : +e.target.value;
|
|
225
|
+
BG_LIVE = { container: { key: key, surface: surface } };
|
|
226
|
+
document.getElementById(e.target.id + '-o').textContent = e.target.value + (field === 'opacity' ? '%' : 'px');
|
|
227
|
+
ctGridSync();
|
|
228
|
+
};
|
|
229
|
+
document.addEventListener('change', function (e) {
|
|
230
|
+
if (e.target.dataset.input !== 'ctBg') return;
|
|
231
|
+
const live = BG_LIVE.container; BG_LIVE = null;
|
|
232
|
+
pdlCtSet(live.key, { surface: live.surface });
|
|
233
|
+
});
|
|
234
|
+
/* 只重画计算器这个弹窗(不整页重画),之后补上读数和描边 */
|
|
235
|
+
POPUPS.calc = function () { return S.calc.open ? calcHtml() : ''; };
|
|
236
|
+
function calcDraw() { popRefresh('calc'); calcAfter(); }
|
|
237
|
+
function calcAfter() { if (S.calc.open) calcReadouts(); ctRingSync(); }
|
|
238
|
+
onRender(calcAfter);
|
|
239
|
+
/* 结构页选中的容器在页面上描边(通用:只按容器键找,不认哪个容器)。容器的根元素带 data-c="键"(frame.js 投影写的);
|
|
240
|
+
没有自己盒子的容器(flat,例如外壳)描它有盒子的子容器。描边是一个锚定在容器上的环(锚点名来自 engine/anchor.js 的锚定,环自己不量坐标):
|
|
241
|
+
画在容器外面一层,不受容器的滚动渐隐遮罩影响 */
|
|
242
|
+
function ctRingEls(key) {
|
|
243
|
+
const root = document.getElementById('app'), out = [];
|
|
244
|
+
const walk = function (n) { const el = root && root.querySelector('[data-c="' + CSS.escape(n.key) + '"]:not([data-act])'); if (el && el.getClientRects().length) out.push(el); else (n.kids || []).forEach(walk); };
|
|
245
|
+
const f = pdlTreeFind(pdlTree(), key); if (f) walk(f.n);
|
|
246
|
+
return out;
|
|
247
|
+
}
|
|
248
|
+
function ctRingSync() {
|
|
249
|
+
document.querySelectorAll('.ct-ring').forEach(function (x) { x.remove(); });
|
|
250
|
+
const host = document.querySelector('[data-calc-rings]'); if (!host || !S.calc.open || S.calc.tab !== 'tree') return;
|
|
251
|
+
const key = pdlCtInfo(S.calc.ct) ? S.calc.ct : pdlTree().key;
|
|
252
|
+
ctRingEls(key).forEach(function (el) { const r = document.createElement('div'); r.className = 'ct-ring'; r.dataset.ring = key; r.setAttribute('aria-hidden', 'true'); r.style.setProperty('--u-anchor', anchorOf(el)); host.appendChild(r); });
|
|
253
|
+
}
|
|
254
|
+
/* 重画时如果深浅模式变了,按新模式重读参数 */
|
|
255
|
+
function calcFollowMode() { if (S.calc.open && S.calc.mode !== calcMode()) { S.calc.P = null; calcDraw(); } }
|
|
256
|
+
onRender(calcFollowMode);
|
|
257
|
+
|
|
258
|
+
document.addEventListener('input', function (e) {
|
|
259
|
+
const k = e.target.dataset && e.target.dataset.calc; if (!k) return;
|
|
260
|
+
S.calc.P[k] = +e.target.value; const o = document.getElementById('calc-o-' + k); if (o) o.textContent = e.target.value;
|
|
261
|
+
calcApply();
|
|
262
|
+
});
|
|
263
|
+
/* 结构页的名字:失焦或回车时写进主题文档 */
|
|
264
|
+
CHANGES.calcOpenTo = function (e) { if (pdlOpenRebind(e.target.dataset.id, e.target.value)) { render(true); calcDraw(); } };
|
|
265
|
+
CHANGES.calcCtName = function (e) { const k = e.target.dataset.calcCt, v = e.target.value.trim(); if (v) { pdlCtSet(k, { label: v }); render(true); calcDraw(); } };
|
|
266
|
+
/* 结构页里拖一行:移动 / 换父容器(组件库唯一的拖动机制 EDGE_DRAG,整行都是抓手)。放在另一行的上半 / 下半 = 前面 / 后面,中间 = 里面;不允许的落点不画标记 */
|
|
267
|
+
EDGE_DRAG.push({
|
|
268
|
+
find: function (t) { const r = t && t.closest && t.closest('[data-pop="calc"] [data-ct-row][data-edit="ct"]'); return r ? { el: r, whole: true } : null; },
|
|
269
|
+
start: function (el, e0) {
|
|
270
|
+
const k = el.dataset.ctRow, sx = e0.clientX, sy = e0.clientY; let at = null;
|
|
271
|
+
const mark = function (e) {
|
|
272
|
+
document.querySelectorAll('[data-pop="calc"] :is(.drop-before, .drop-end, .pdl-over)').forEach(function (x) { x.classList.remove('drop-before', 'drop-end', 'pdl-over'); });
|
|
273
|
+
el.style.pointerEvents = 'none'; const u = document.elementFromPoint(e.clientX, e.clientY); el.style.pointerEvents = '';
|
|
274
|
+
const row = u && u.closest && u.closest('[data-pop="calc"] [data-ct-row]'); at = null; if (!row || row === el) return;
|
|
275
|
+
const r = row.getBoundingClientRect(), y = (e.clientY - r.top) / r.height, zone = y < 0.3 ? 'before' : y > 0.7 ? 'after' : 'inside';
|
|
276
|
+
if (pdlCtMoveWhy(k, row.dataset.ctRow, zone)) return;
|
|
277
|
+
at = { target: row.dataset.ctRow, zone: zone }; row.classList.add(zone === 'before' ? 'drop-before' : zone === 'after' ? 'drop-end' : 'pdl-over');
|
|
278
|
+
};
|
|
279
|
+
return { move: function (e) { el.style.translate = (e.clientX - sx) + 'px ' + (e.clientY - sy) + 'px'; mark(e); }, /* 相对增量(跟着指针) */
|
|
280
|
+
end: function (e, moved) { el.style.translate = ''; if (!moved) return; if (at && pdlCtMove(k, at.target, at.zone)) { render(true); } calcDraw(); } }; /* 没拖动 = 点击:不重画(重画会换掉按下的元素,点击就丢了,这一行选不中) */
|
|
281
|
+
}
|
|
282
|
+
});
|
|
283
|
+
Object.assign(A, {
|
|
284
|
+
calcCtHideEmpty: function (d) { pdlCtSet(d.k, { hideEmpty: !pdlCtInfo(d.k).node.hideEmpty }); render(true); calcDraw(); },
|
|
285
|
+
calcCtAdd: function (d) { const k = pdlCtAdd(d.k); if (k) S.calc.ct = k; render(true); calcDraw(); },
|
|
286
|
+
calcCtDel: function (d) { const p = (pdlCtInfo(d.k) || {}).parent; if (pdlCtDel(d.k)) { S.calc.ct = p ? p.key : null; render(true); calcDraw(); } },
|
|
287
|
+
calcFlip: function () { A.themeFlip(); S.calc.P = null; calcDraw(); }
|
|
288
|
+
});
|
|
289
|
+
/* 通用动作用的数据:打开计算器时从当前主题重新读参数;容器的方向 / 份额写进主题文档的结构;复制的是当前参数和推出来的 token */
|
|
290
|
+
SET_AFTER['s.calc.open'] = function (v) { if (v) { S.protoOpen = false; S.calc.P = null; } };
|
|
291
|
+
ENT.ct = { get: function (k) { return { id: k }; }, set: function (x, f, v) { const o = {}; o[f] = v; pdlCtSet(x.id, o); } };
|
|
292
|
+
function calcCopyText() { return JSON.stringify({ theme: S.pdlPalette, mode: S.calc.mode, params: S.calc.P, tokens: calcTokens(S.calc.P, S.calc.mode === 'dark') }, null, 2); }
|
|
293
|
+
/* 恢复默认值能撤回(改过的值记着):系统主题本来就是默认值,恢复不需要复制,也没有要撤回的 */
|
|
294
|
+
RESETS.calc = {
|
|
295
|
+
editable: function () { return !!(S.pdlDoc || THEME_SRC.own().some(function (t) { return t.id === S.pdlPalette; })); },
|
|
296
|
+
get: function () { return themeVals(S.pdlPalette)[S.calc.mode] || {}; },
|
|
297
|
+
set: function (v) { if (!RESETS.calc.editable()) return; const mode = S.calc.mode; themeValsEdit(S.pdlPalette, function (x) { x[mode] = v; }); applyThemeVals(); S.calc.P = null; },
|
|
298
|
+
def: function () { return {}; },
|
|
299
|
+
text: function () { return tc('themeCalc.notifications.toast'); }
|
|
300
|
+
};
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
/* 边界:一个含义一个组件、不为接口定制、不按位置推导样式 */
|
|
2
|
+
/* 其他复合组件:日历、卡片网格、排队消息 */
|
|
3
|
+
/* 复合组件(这里和 code.js、media-viewer.js、charts.js、plugin-form.js)都登记在 PDL_COMPONENTS,只在组件库里登记(lint:pdl-comp)。
|
|
4
|
+
契约:组件只吃数据(props),不读页面状态、不认识页面名和功能 ID;点了执行什么由 props 里的 { act, args } 给出,
|
|
5
|
+
文字由组件的 i18n 或 PDL 绑定;状态和计数由数据给出。props 的字段见各组件的 catalog(组件目录)。 */
|
|
6
|
+
'use strict';
|
|
7
|
+
/* 用本地中午表示自然日,年份 1–99 也按原值处理。 */
|
|
8
|
+
function calendarDate(year, month, day) {
|
|
9
|
+
const d = new Date(0);
|
|
10
|
+
d.setHours(12, 0, 0, 0);
|
|
11
|
+
d.setFullYear(year, month, day);
|
|
12
|
+
return d;
|
|
13
|
+
}
|
|
14
|
+
/* 日期网格:只认识日期、计数、高亮区间和选择动作;事件的含义、筛选和详情由 VM / PDL 负责。
|
|
15
|
+
{ anchor, value, today, mode: 'month'|'week', marks: [{ at }], highlights?: [{ at, count?, span? }], min?, max?, tabIndex?, act, args } */
|
|
16
|
+
PDL_COMPONENTS.calendar = function (o, sc) {
|
|
17
|
+
o = pvDeep(o, sc);
|
|
18
|
+
const anchor = new Date(o.anchor), first = calendarDate(anchor.getFullYear(), anchor.getMonth(), o.mode === 'week' ? anchor.getDate() : 1);
|
|
19
|
+
first.setDate(first.getDate() - (first.getDay() + 6) % 7);
|
|
20
|
+
const min = o.min ?? -Infinity, max = o.max ?? Infinity;
|
|
21
|
+
const selected = new Date(o.value).toDateString(), today = new Date(o.today).toDateString(), counts = {}, marked = {};
|
|
22
|
+
(o.marks || []).forEach(function (m) { const key = new Date(m.at).toDateString(); counts[key] = (counts[key] || 0) + 1; });
|
|
23
|
+
(o.highlights || []).forEach(function (m) {
|
|
24
|
+
const key = new Date(m.at).toDateString(), prev = marked[key];
|
|
25
|
+
marked[key] = { count: (prev ? prev.count : 0) + (m.count || 1), span: m.span || prev?.span || 'single' };
|
|
26
|
+
});
|
|
27
|
+
const days = Array.from({ length: o.mode === 'week' ? 7 : 42 }, function (_, i) {
|
|
28
|
+
const d = calendarDate(first.getFullYear(), first.getMonth(), first.getDate() + i), key = d.toDateString(), count = counts[key] || 0, hl = marked[key];
|
|
29
|
+
const parts = [d.getFullYear() + '/' + (d.getMonth() + 1) + '/' + d.getDate()];
|
|
30
|
+
if (hl) parts.push(tc('calendar.marked', hl.count));
|
|
31
|
+
if (count) parts.push(tc('calendar.count', count));
|
|
32
|
+
return '<button type="button" class="calendar-day"' + wgAct({ act: o.act, args: Object.assign({}, o.args, { v: d.getTime() }) }) +
|
|
33
|
+
' aria-label="' + h(parts.join(' · ')) + '" aria-pressed="' + (key === selected) + '" data-outside="' + (d.getMonth() !== anchor.getMonth()) + '" data-today="' + (key === today) + '"' +
|
|
34
|
+
(key === today ? ' aria-current="date"' : '') + (d < min || d > max ? ' disabled' : '') +
|
|
35
|
+
(o.tabIndex != null ? ' tabindex="' + h(o.tabIndex) + '"' : '') +
|
|
36
|
+
(hl ? ' data-marked="true" data-span="' + h(hl.span) + '"' : '') + '>' +
|
|
37
|
+
'<span>' + d.getDate() + '</span><span class="calendar-count">' + (count || '') + '</span></button>';
|
|
38
|
+
});
|
|
39
|
+
return '<div class="calendar" data-period="' + h(o.mode) + '"><div class="calendar-weekdays">' + tc('calendar.weekdays').split(' ').map(function (d) { return '<span>' + h(d) + '</span>'; }).join('') + '</div><div class="calendar-days">' + days.join('') + '</div></div>';
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
/* ───────── 卡片网格:一排预览卡(图标预览 + 标题 + 一行说明) ─────────
|
|
43
|
+
{ items: [{ icon, title, sub, act, args, label, preview?:{kind,src}, actions?:[{label,icon,act,args}] }], empty, skel };from / item 声明每项字段、预览和操作,when 按该项数据判断。 */
|
|
44
|
+
PDL_COMPONENTS.cards = function (p, sc, root) {
|
|
45
|
+
if (p.skel) return skel(p.skel, 'card');
|
|
46
|
+
const xs = pvList(p.from || p.items, sc, root), next = listNextHtml(p.next, sc, root);
|
|
47
|
+
if (!xs.length) return emptyState({ text: (p.item ? pv(p.empty, sc, root) : p.empty) || tc('list.empty') }) + next;
|
|
48
|
+
return '<div class="cgrid">' + xs.map(function (data) {
|
|
49
|
+
const t = p.item, w = t ? Object.assign({}, data, pvArgsObj(t, data, root)) : data;
|
|
50
|
+
if (t && t.preview) w.preview = pvOk(t.preview.when, data, root) ? pvArgsObj(t.preview, data, root) : null;
|
|
51
|
+
const preview = w.preview ? w.preview.kind === 'video' ? '<video src="' + h(w.preview.src) + '" preload="metadata" muted playsinline></video>' : '<img src="' + h(w.preview.src) + '" alt="" draggable="false">' : icon(w.icon, 22);
|
|
52
|
+
const actions = (w.actions || []).filter(function (a) { return !t || pvOk(a.when, data, root); }).map(function (a) { return btn(t ? pv(a.label, data, root) : a.label, { iconOnly: true, icon: t ? pv(a.icon, data, root) : a.icon, act: a.act, data: t ? pvArgs(a.args, data, root) : argAttrs(a.args) }); }).join('');
|
|
53
|
+
const act = t ? actAttrs(w.act, pvArgsObj(t.args, data, root)) : wgAct(w);
|
|
54
|
+
return '<div class="cgrid-card"><button type="button" class="cgrid-prev"' + act + ' aria-label="' + h(w.label || w.title) + '">' + preview + '</button>' +
|
|
55
|
+
'<div class="cgrid-meta"><div class="cgrid-t" data-tip="' + h(w.title) + '">' + h(w.title) + '</div><div class="cgrid-foot"><div class="cgrid-s">' + h(w.sub) + '</div>' + actions + '</div></div></div>';
|
|
56
|
+
}).join('') + '</div>' + next;
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
/* ───────── 队列:收起时只露右下角“排队中 · n”,展开时以右下角为基点向上、向左长成面板 ─────────
|
|
60
|
+
{ key, items: [{ key, orderable, text, to: [成员 id] }], actions: [{ label, icon, act, args, when, items }], label, visible, order };字段可由 PDL 绑定。 */
|
|
61
|
+
PDL_COMPONENTS.queue = function (p, sc, root) {
|
|
62
|
+
const q = pv(p.items, sc, root); if (!q.length) return '';
|
|
63
|
+
const more = q.length - 1, key = 'queue:' + pv(p.key, sc, root), label = pv(p.label, sc, root), order = pv(p.order, sc, root), open = !!S.folds[key];
|
|
64
|
+
const fold = more ? foldTg(open, 'fold', ' data-f="queue"', open ? '' : tc('fold.moreHtml', '<span class="num">' + more + '</span>'), null, 'up') : ''; /* 和折叠块共用开关,队列向上展开。 */
|
|
65
|
+
/* 一条排队消息就是一行 lrow(小行):正文 · 投给谁(头像叠放)· 悬停操作;行与行之间是分组的发丝线 */
|
|
66
|
+
const rows = q.map(function (x) {
|
|
67
|
+
return { key: x.key, orderable: !!order && !!x.orderable, layout: 'record', hook: 'qitem', title: '<span data-tip="' + h(x.text) + '">' + h(x.text) + '</span>', cols: [{ w: 'ctl', v: p.targets && x.delivery ? '<span class="qto">' + x.delivery.map(function (target) { return pvParts(p.targets, target, root); }).join('') + '</span>' : x.to.length ? '<span class="qto">' + x.to.map(function (id) { return whoAva(id, { size: 'sm', tip: tc('queue.to', who(id, 'text', { handle: true })) }); }).join('') + '</span>' : '' }],
|
|
68
|
+
actsHtml: (p.actions || []).filter(function (a) { return pvOk(a.when, x, root); }).map(function (a) {
|
|
69
|
+
if (a.type === 'more') return lrAct({ icon: 'more', label: pv(a.label, x, root), act: 'menu', data: argAttrs({ menu: menuLive(pvMenu(a.items, x, root)), k: x.key }) });
|
|
70
|
+
return lrAct({ icon: a.icon, label: pv(a.label, x, root), act: a.act, data: pvArgs(a.args, x, root) });
|
|
71
|
+
}).join('') };
|
|
72
|
+
});
|
|
73
|
+
return '<div class="qwrap" data-island="' + h(key) + '" data-fold-key="' + h(key) + '" data-open="' + open + '" data-count="' + q.length + '"><div class="qbox" role="dialog" aria-label="' + h(label) + '">' + fold +
|
|
74
|
+
lrList(key, rows, { rows: pv(p.visible, sc, root) || 5, order: order, cls: 'qlist' }) +
|
|
75
|
+
'<div class="qbox-foot"><span class="qchip">' + h(label) + ' · <span class="num">' + q.length + '</span></span></div></div></div>';
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
function foldQueue(d, el) {
|
|
79
|
+
const box = el.closest('.qwrap');
|
|
80
|
+
localOpen(box, box.dataset.open !== 'true', box.querySelector('.fold-tg'));
|
|
81
|
+
}
|
|
82
|
+
onOpenToggle('.qwrap', function (box, open) {
|
|
83
|
+
S.folds[box.dataset.foldKey] = open;
|
|
84
|
+
const tg = box.querySelector('.fold-tg'); if (!tg) return;
|
|
85
|
+
const tmp = document.createElement('template');
|
|
86
|
+
tmp.innerHTML = foldTg(open, 'fold', ' data-f="queue"', open ? '' : tc('fold.moreHtml', '<span class="num">' + (+box.dataset.count - 1) + '</span>'), null, 'up');
|
|
87
|
+
const next = tmp.content.firstElementChild;
|
|
88
|
+
tg.innerHTML = next.innerHTML;
|
|
89
|
+
['aria-label', 'data-tip'].forEach(function (name) { tg.setAttribute(name, next.getAttribute(name)); });
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
/* 队列自己的行为:
|
|
93
|
+
- 展开着时点队列外面(对话框里除外:排队消息的“现在发出”会开对话框)就本地收起;
|
|
94
|
+
- 收起时的裁剪大小 = 底下“排队中 · n”这一行的实际大小:胶囊进了文档 / 变宽时量一次(引擎的进树通知),--qmax 是输入框的宽 */
|
|
95
|
+
document.addEventListener('click', function (e) {
|
|
96
|
+
const w = document.querySelector('.qwrap[data-open="true"]'), t = e.target; if (!w || !t.closest || t.closest('.qwrap, .dialog')) return;
|
|
97
|
+
localOpen(w, false, w.querySelector('.fold-tg'));
|
|
98
|
+
}, true);
|
|
99
|
+
function measureQueueClip(chip) {
|
|
100
|
+
const box = chip && chip.closest('.qbox'); if (!box) return;
|
|
101
|
+
const first = !box.style.getPropertyValue('--qch'); /* 新生成的框:量的时候样式已经按默认值算过一次,第一次放值不能走过渡 */
|
|
102
|
+
if (first) box.style.transition = 'none';
|
|
103
|
+
box.style.setProperty('--qcw', chip.offsetWidth + 'px'); box.style.setProperty('--qch', chip.offsetHeight + 'px');
|
|
104
|
+
if (first) { void box.offsetWidth; box.style.transition = ''; }
|
|
105
|
+
const comp = box.closest('.composer'); if (comp) box.style.setProperty('--qmax', comp.offsetWidth + 'px');
|
|
106
|
+
}
|
|
107
|
+
treeMatch('.qbox .qchip', measureQueueClip, true);
|
|
108
|
+
/* 裁剪尺寸是组件量出来的值,不是内容版本。 */
|
|
109
|
+
LOCAL_NORM.push(function (root) {
|
|
110
|
+
root.querySelectorAll('.qbox').forEach(function (box) { box.removeAttribute('style'); });
|
|
111
|
+
});
|
|
112
|
+
PDL_COMPONENTS.calendar.catalog = { g: 'workbench', view: 'ws.schedule', props: '$.calendar' };
|
|
113
|
+
PDL_COMPONENTS.cards.catalog = { g: 'workbench', props: '$.cgrid' };
|
|
114
|
+
PDL_COMPONENTS.queue.catalog = { g: 'composer', props: '$.queue' };
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
{
|
|
2
|
+
"scripts": [
|
|
3
|
+
"engine/i18n.js",
|
|
4
|
+
"engine/core.js",
|
|
5
|
+
"engine/theme.js",
|
|
6
|
+
"engine/proj.js",
|
|
7
|
+
"engine/frame.js",
|
|
8
|
+
"engine/units.js",
|
|
9
|
+
"engine/anchor.js",
|
|
10
|
+
"engine/pdl-view.js",
|
|
11
|
+
"engine/pdl.js",
|
|
12
|
+
"engine/tree.js",
|
|
13
|
+
"engine/pdl-doc.js",
|
|
14
|
+
"engine/platform.js",
|
|
15
|
+
"platform/web.js",
|
|
16
|
+
"library/icons.js",
|
|
17
|
+
"library/registry.js",
|
|
18
|
+
"library/format.js",
|
|
19
|
+
"library/identity.js",
|
|
20
|
+
"library/buttons.js",
|
|
21
|
+
"library/inputs.js",
|
|
22
|
+
"library/feedback.js",
|
|
23
|
+
"library/page.js",
|
|
24
|
+
"library/markdown-text.js",
|
|
25
|
+
"library/markdown.js",
|
|
26
|
+
"library/overlays.js",
|
|
27
|
+
"library/shell.js",
|
|
28
|
+
"library/tabs.js",
|
|
29
|
+
"library/blocks.js",
|
|
30
|
+
"library/motion.js",
|
|
31
|
+
"library/fold.js",
|
|
32
|
+
"library/rows.js",
|
|
33
|
+
"library/label-search.js",
|
|
34
|
+
"library/capsules.js",
|
|
35
|
+
"library/message.js",
|
|
36
|
+
"library/stream.js",
|
|
37
|
+
"library/frames.js",
|
|
38
|
+
"library/media-viewer.js",
|
|
39
|
+
"library/code.js",
|
|
40
|
+
"library/charts.js",
|
|
41
|
+
"library/widgets.js",
|
|
42
|
+
"library/plugin-form.js",
|
|
43
|
+
"library/theme-calculator.js"
|
|
44
|
+
],
|
|
45
|
+
"styles": [
|
|
46
|
+
"library/css/base.css",
|
|
47
|
+
"library/css/shell.css",
|
|
48
|
+
"library/css/page.css",
|
|
49
|
+
"library/css/controls.css",
|
|
50
|
+
"library/css/chat.css",
|
|
51
|
+
"library/css/library-parts.css",
|
|
52
|
+
"library/css/settings-rows.css",
|
|
53
|
+
"library/css/composer-top.css",
|
|
54
|
+
"library/css/workbench.css",
|
|
55
|
+
"library/css/theme-calculator.css",
|
|
56
|
+
"library/css/catalog-page.css",
|
|
57
|
+
"library/css/tweaks.css",
|
|
58
|
+
"library/css/responsive.css",
|
|
59
|
+
"library/css/drag.css",
|
|
60
|
+
"library/css/message.css",
|
|
61
|
+
"library/css/rows.css",
|
|
62
|
+
"library/css/hover.css",
|
|
63
|
+
"library/css/capsules.css",
|
|
64
|
+
"library/css/blocks.css",
|
|
65
|
+
"library/css/stream.css",
|
|
66
|
+
"library/css/edit-layout.css",
|
|
67
|
+
"library/css/thumb-choice.css",
|
|
68
|
+
"library/css/layers.css",
|
|
69
|
+
"library/css/roles.css",
|
|
70
|
+
"library/css/parts.css",
|
|
71
|
+
"library/css/widgets.css",
|
|
72
|
+
"library/css/library.css"
|
|
73
|
+
]
|
|
74
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
let katex, mermaid, diagramId = 0;
|
|
2
|
+
|
|
3
|
+
export async function renderRichMarkdown(kind, source, inline) {
|
|
4
|
+
if (kind === 'math') {
|
|
5
|
+
katex ??= import('https://cdn.jsdelivr.net/npm/katex@0.16.11/dist/katex.mjs').then(({ default: library }) => library);
|
|
6
|
+
// Native MathML uses the page's fonts and needs no KaTeX stylesheet.
|
|
7
|
+
return (await katex).renderToString(source, { displayMode: !inline, throwOnError: true, output: 'mathml' });
|
|
8
|
+
}
|
|
9
|
+
mermaid ??= import('https://cdn.jsdelivr.net/npm/mermaid@11.4.1/dist/mermaid.esm.min.mjs').then(({ default: library }) => {
|
|
10
|
+
const dark = getComputedStyle(document.documentElement).colorScheme === 'dark';
|
|
11
|
+
library.initialize({ startOnLoad: false, suppressErrorRendering: true, theme: dark ? 'dark' : 'neutral' });
|
|
12
|
+
return library;
|
|
13
|
+
});
|
|
14
|
+
const library = await mermaid;
|
|
15
|
+
const { svg } = await library.render('md-mermaid-' + ++diagramId, source);
|
|
16
|
+
return svg;
|
|
17
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
const WEB_LOOPBACK = new Set(['localhost', '127.0.0.1', '[::1]']);
|
|
3
|
+
|
|
4
|
+
function webLocalConsole() {
|
|
5
|
+
return window.top === window && WEB_LOOPBACK.has(location.hostname);
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
function webLinkTarget(url) {
|
|
9
|
+
if (url.origin === location.origin) return url.pathname.startsWith('/p/') ? 'preview' : 'host';
|
|
10
|
+
return WEB_LOOPBACK.has(url.hostname) ? 'preview' : 'browser';
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
async function webOpenExternal(url) {
|
|
14
|
+
if (!webLocalConsole()) {
|
|
15
|
+
window.open(url.href, '_blank', 'noopener,noreferrer');
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
if (!navigator.userActivation.isActive) return;
|
|
19
|
+
const response = await fetch('/api/console/browser/open', {
|
|
20
|
+
method: 'POST', headers: { 'content-type': 'application/json' }, body: JSON.stringify({ url: url.href }),
|
|
21
|
+
});
|
|
22
|
+
if (!response.ok) {
|
|
23
|
+
const data = await response.json();
|
|
24
|
+
throw Object.assign(new Error(data.error), { i18n: data.i18n });
|
|
25
|
+
}
|
|
26
|
+
}
|