@waq666/pneuma 0.7.1 → 0.8.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/README.md +242 -206
- package/bin/dsc.js +9 -3
- package/bin/headless.cjs +1 -1
- package/lib/adapter/transcript.d.ts +19 -2
- package/lib/adapter/transcript.js +71 -14
- package/lib/app/AgentsOverlay.js +7 -6
- package/lib/app/App.js +1 -1
- package/lib/app/ApprovalCard.js +15 -9
- package/lib/app/ChatView.d.ts +3 -1
- package/lib/app/ChatView.js +21 -17
- package/lib/app/Composer.js +22 -4
- package/lib/app/MarkdownView.js +2 -1
- package/lib/app/ModelPicker.js +7 -6
- package/lib/app/PickerFrame.d.ts +4 -0
- package/lib/app/PickerFrame.js +18 -0
- package/lib/app/PlanReviewCard.js +2 -1
- package/lib/app/PresetPicker.js +8 -7
- package/lib/app/SessionPicker.js +21 -20
- package/lib/app/SettingsOverlay.js +1 -1
- package/lib/app/SkillsPicker.js +7 -6
- package/lib/app/StatusBar.js +3 -15
- package/lib/app/TaskStrips.js +1 -4
- package/lib/app/TimelineRail.js +2 -1
- package/lib/app/ToolCard.js +2 -6
- package/lib/app/Welcome.d.ts +1 -0
- package/lib/app/Welcome.js +1 -4
- package/lib/app/click.d.ts +0 -2
- package/lib/app/click.js +2 -21
- package/lib/app/display-width.d.ts +16 -0
- package/lib/app/display-width.js +33 -0
- package/lib/app/markdown.d.ts +1 -3
- package/lib/app/markdown.js +2 -19
- package/lib/app/scroll-model.js +1 -1
- package/lib/contract/approval.d.ts +91 -0
- package/lib/contract/approval.js +1 -0
- package/lib/contract/mode.d.ts +69 -0
- package/lib/contract/mode.js +1 -0
- package/lib/contract/plugin.d.ts +240 -0
- package/lib/contract/plugin.js +1 -0
- package/lib/contract/runtime.d.ts +282 -0
- package/lib/contract/runtime.js +1 -0
- package/lib/contract/session.d.ts +208 -0
- package/lib/contract/session.js +36 -0
- package/lib/contract/settings.d.ts +242 -0
- package/lib/contract/settings.js +1 -0
- package/lib/contract/snapshot.d.ts +453 -0
- package/lib/contract/snapshot.js +1 -0
- package/lib/contract/task.d.ts +189 -0
- package/lib/contract/task.js +10 -0
- package/lib/contract/transcript.d.ts +358 -0
- package/lib/contract/transcript.js +1 -0
- package/lib/contract/usage.d.ts +132 -0
- package/lib/contract/usage.js +10 -0
- package/lib/contract.d.ts +20 -1968
- package/lib/contract.js +19 -30
- package/lib/core/agent-roles.d.ts +1 -1
- package/lib/core/agent-roles.js +6 -5
- package/lib/core/approval-floor.d.ts +9 -0
- package/lib/core/approval-floor.js +152 -25
- package/lib/core/attachments.d.ts +185 -0
- package/lib/core/attachments.js +425 -0
- package/lib/core/bytes.d.ts +14 -0
- package/lib/core/bytes.js +28 -0
- package/lib/core/call-meaning.d.ts +20 -0
- package/lib/core/call-meaning.js +347 -0
- package/lib/core/cdp/actions.js +6 -0
- package/lib/core/cdp/launch.js +2 -2
- package/lib/core/cdp/report.d.ts +27 -0
- package/lib/core/cdp/report.js +50 -0
- package/lib/core/cdp/ring-buffer.d.ts +25 -0
- package/lib/core/cdp/ring-buffer.js +44 -0
- package/lib/core/cdp/snapshot.js +5 -9
- package/lib/core/cdp/transport.js +1 -1
- package/lib/core/clamp.d.ts +20 -0
- package/lib/core/clamp.js +24 -0
- package/lib/core/clock.d.ts +16 -0
- package/lib/core/clock.js +20 -0
- package/lib/core/command-policy.js +33 -1
- package/lib/core/commands-completion.d.ts +28 -0
- package/lib/core/commands-completion.js +108 -30
- package/lib/core/compact.d.ts +36 -6
- package/lib/core/compact.js +89 -17
- package/lib/core/desktop-control.js +1 -3
- package/lib/core/dsh-compat/llm-usage-event.d.ts +78 -0
- package/lib/core/dsh-compat/llm-usage-event.js +91 -0
- package/lib/core/dsh-compat/presentation.d.ts +84 -0
- package/lib/core/dsh-compat/presentation.js +105 -0
- package/lib/core/dsh-compat/resolve-hook.d.ts +3 -3
- package/lib/core/dsh-compat/resolve-hook.js +41 -13
- package/lib/core/dsh-compat/service-map.d.ts +52 -0
- package/lib/core/dsh-compat/service-map.js +87 -0
- package/lib/core/dsh-compat/session-bridge.d.ts +107 -0
- package/lib/core/dsh-compat/session-bridge.js +376 -0
- package/lib/core/dsh-compat/session-events.d.ts +54 -0
- package/lib/core/dsh-compat/session-events.js +297 -0
- package/lib/core/dsh-compat/shims/credentials.d.ts +62 -0
- package/lib/core/dsh-compat/shims/credentials.js +86 -0
- package/lib/core/dsh-compat/shims/home-paths.d.ts +77 -0
- package/lib/core/dsh-compat/shims/home-paths.js +143 -0
- package/lib/core/dsh-compat/tools-facade.d.ts +31 -1
- package/lib/core/dsh-compat/tools-facade.js +207 -3
- package/lib/core/err-text.d.ts +5 -0
- package/lib/core/err-text.js +5 -0
- package/lib/core/events.d.ts +31 -2
- package/lib/core/git-info.d.ts +127 -15
- package/lib/core/git-info.js +315 -34
- package/lib/core/git-surface.d.ts +17 -0
- package/lib/core/git-surface.js +7 -0
- package/lib/core/hooks.d.ts +19 -2
- package/lib/core/hooks.js +57 -13
- package/lib/core/host-methods.d.ts +1 -1
- package/lib/core/host-methods.js +4 -0
- package/lib/core/image-diet.js +1 -4
- package/lib/core/json-text.d.ts +11 -0
- package/lib/core/json-text.js +18 -0
- package/lib/core/learnings/skill-write.d.ts +1 -7
- package/lib/core/learnings/skill-write.js +3 -37
- package/lib/core/lifecycle-hooks.d.ts +11 -3
- package/lib/core/lifecycle-hooks.js +33 -42
- package/lib/core/llm.d.ts +42 -0
- package/lib/core/llm.js +40 -25
- package/lib/core/loop.d.ts +11 -1
- package/lib/core/loop.js +95 -28
- package/lib/core/lsp/client.js +30 -17
- package/lib/core/lsp/normalize.d.ts +0 -2
- package/lib/core/lsp/normalize.js +1 -6
- package/lib/core/lsp/servers.js +1 -4
- package/lib/core/mcp.d.ts +18 -0
- package/lib/core/mcp.js +60 -16
- package/lib/core/microcompact.d.ts +45 -0
- package/lib/core/microcompact.js +128 -0
- package/lib/core/native-bridge.js +2 -10
- package/lib/core/path-policy.d.ts +13 -1
- package/lib/core/path-policy.js +87 -18
- package/lib/core/permission-presets.d.ts +9 -5
- package/lib/core/permission-presets.js +14 -7
- package/lib/core/permission-scope.d.ts +65 -0
- package/lib/core/permission-scope.js +109 -0
- package/lib/core/plugin-bundle.d.ts +95 -0
- package/lib/core/plugin-bundle.js +137 -0
- package/lib/core/plugin-loader.d.ts +36 -1
- package/lib/core/plugin-loader.js +336 -12
- package/lib/core/plugin-patch.d.ts +64 -0
- package/lib/core/plugin-patch.js +146 -0
- package/lib/core/plugin-registry.d.ts +14 -0
- package/lib/core/plugin-registry.js +2 -0
- package/lib/core/prefs.js +40 -2
- package/lib/core/presets.d.ts +11 -0
- package/lib/core/presets.js +61 -22
- package/lib/core/profile-dir.d.ts +5 -0
- package/lib/core/profile-dir.js +40 -0
- package/lib/core/prompt.js +55 -19
- package/lib/core/ptc.d.ts +8 -2
- package/lib/core/ptc.js +18 -4
- package/lib/core/records.d.ts +16 -0
- package/lib/core/records.js +22 -0
- package/lib/core/remote/notify.js +1 -3
- package/lib/core/remote/push.js +2 -6
- package/lib/core/sandbox/execpolicy.js +27 -3
- package/lib/core/sandbox/net-proxy.js +2 -2
- package/lib/core/sandbox/policy.d.ts +1 -1
- package/lib/core/sandbox/policy.js +21 -15
- package/lib/core/sandbox/win/account.js +1 -4
- package/lib/core/sandbox/win/acl.js +1 -6
- package/lib/core/sandbox/win/backend.d.ts +24 -3
- package/lib/core/sandbox/win/backend.js +73 -23
- package/lib/core/sandbox/win/doctor.js +1 -4
- package/lib/core/sandbox/win/runner-entry.js +1 -6
- package/lib/core/sandbox/win/setup.js +1 -4
- package/lib/core/sandbox/win/utf16.d.ts +11 -0
- package/lib/core/sandbox/win/utf16.js +15 -0
- package/lib/core/sandbox/win/wfp.js +1 -4
- package/lib/core/schedule/rule.d.ts +0 -17
- package/lib/core/schedule/rule.js +1 -3
- package/lib/core/schedule/runner.d.ts +5 -2
- package/lib/core/schedule/runner.js +32 -9
- package/lib/core/schedule/store.d.ts +0 -2
- package/lib/core/schedule/store.js +2 -9
- package/lib/core/session-index.d.ts +50 -0
- package/lib/core/session-index.js +169 -3
- package/lib/core/session.d.ts +89 -13
- package/lib/core/session.js +385 -32
- package/lib/core/shell-quote.d.ts +21 -0
- package/lib/core/shell-quote.js +24 -0
- package/lib/core/side-ask.d.ts +52 -0
- package/lib/core/side-ask.js +89 -0
- package/lib/core/skills.d.ts +16 -0
- package/lib/core/skills.js +45 -8
- package/lib/core/snapshot-throttle.d.ts +8 -0
- package/lib/core/snapshot-throttle.js +24 -0
- package/lib/core/spill.d.ts +11 -5
- package/lib/core/spill.js +35 -36
- package/lib/core/strings.d.ts +21 -0
- package/lib/core/strings.js +33 -0
- package/lib/core/terminal-env.d.ts +61 -0
- package/lib/core/terminal-env.js +327 -0
- package/lib/core/text-format.d.ts +17 -0
- package/lib/core/text-format.js +26 -0
- package/lib/core/todo-reminder.d.ts +19 -14
- package/lib/core/todo-reminder.js +14 -23
- package/lib/core/token-estimate.d.ts +18 -2
- package/lib/core/token-estimate.js +10 -2
- package/lib/core/tool-result-prune.d.ts +42 -0
- package/lib/core/tool-result-prune.js +47 -0
- package/lib/core/tool-search.d.ts +3 -2
- package/lib/core/tool-search.js +3 -2
- package/lib/core/tools/bash.d.ts +35 -3
- package/lib/core/tools/bash.js +168 -41
- package/lib/core/tools/fs-tools.js +18 -17
- package/lib/core/tools/image-tool.d.ts +2 -0
- package/lib/core/tools/image-tool.js +59 -0
- package/lib/core/tools/path-args.d.ts +4 -0
- package/lib/core/tools/path-args.js +22 -0
- package/lib/core/tools/search-tools.d.ts +30 -0
- package/lib/core/tools/search-tools.js +321 -34
- package/lib/core/tools.d.ts +82 -0
- package/lib/core/tools.js +21 -0
- package/lib/core/transcript-text.d.ts +19 -0
- package/lib/core/transcript-text.js +44 -0
- package/lib/core/ui-boot-source.d.ts +5 -0
- package/lib/core/ui-boot-source.js +10 -3
- package/lib/core/ui-bundles.d.ts +80 -6
- package/lib/core/ui-bundles.js +700 -76
- package/lib/core/ui-events.d.ts +10 -0
- package/lib/core/ui-events.js +25 -0
- package/lib/core/ui-methods.d.ts +1 -1
- package/lib/core/ui-methods.js +42 -13
- package/lib/core/ui-route.js +11 -7
- package/lib/core/ui-server.d.ts +6 -0
- package/lib/core/ui-server.js +106 -1
- package/lib/core/unified-diff.d.ts +35 -0
- package/lib/core/unified-diff.js +86 -0
- package/lib/core/usage-log.js +39 -0
- package/lib/core/web-http.d.ts +1 -1
- package/lib/core/web-http.js +1 -3
- package/lib/host/kernel.js +57 -41
- package/lib/plugins/agent.js +101 -20
- package/lib/plugins/approval-floor.js +12 -8
- package/lib/plugins/approval.js +252 -80
- package/lib/plugins/ask.js +60 -8
- package/lib/plugins/browser.js +32 -84
- package/lib/plugins/commands.js +167 -57
- package/lib/plugins/compact.d.ts +2 -2
- package/lib/plugins/compact.js +200 -30
- package/lib/plugins/computer-use.js +34 -18
- package/lib/plugins/dock-browser.js +24 -65
- package/lib/plugins/dsh-compat.js +7 -0
- package/lib/plugins/file-review.js +59 -15
- package/lib/plugins/git.js +16 -8
- package/lib/plugins/goal.js +9 -8
- package/lib/plugins/hooks.js +4 -2
- package/lib/plugins/host-stdio.js +14 -16
- package/lib/plugins/lifecycle-hooks.d.ts +5 -4
- package/lib/plugins/lifecycle-hooks.js +12 -10
- package/lib/plugins/llm.js +74 -33
- package/lib/plugins/lsp.js +22 -27
- package/lib/plugins/mcp.js +16 -17
- package/lib/plugins/memory.js +3 -24
- package/lib/plugins/microcompact.d.ts +4 -1
- package/lib/plugins/microcompact.js +117 -19
- package/lib/plugins/mode.js +30 -11
- package/lib/plugins/permission-presets.d.ts +2 -1
- package/lib/plugins/permission-presets.js +55 -35
- package/lib/plugins/plugin-manager.js +4 -6
- package/lib/plugins/presets.js +56 -27
- package/lib/plugins/prompt.js +54 -11
- package/lib/plugins/ptc.d.ts +13 -0
- package/lib/plugins/ptc.js +121 -24
- package/lib/plugins/remote/types.d.ts +1 -1
- package/lib/plugins/remote/types.js +11 -0
- package/lib/plugins/remote.js +14 -15
- package/lib/plugins/runtime.js +91 -14
- package/lib/plugins/sandbox.js +181 -60
- package/lib/plugins/schedule.js +12 -11
- package/lib/plugins/self-improve.js +28 -18
- package/lib/plugins/session-search.js +18 -13
- package/lib/plugins/session-title.js +1 -1
- package/lib/plugins/session.js +103 -25
- package/lib/plugins/settings.js +16 -40
- package/lib/plugins/skills.js +18 -1
- package/lib/plugins/spill.js +18 -11
- package/lib/plugins/subagent.js +208 -42
- package/lib/plugins/team.js +11 -5
- package/lib/plugins/todo.d.ts +1 -1
- package/lib/plugins/todo.js +25 -19
- package/lib/plugins/tool-search.js +47 -28
- package/lib/plugins/tools-default.js +89 -5
- package/lib/plugins/tools.js +3 -3
- package/lib/plugins/transcript.js +116 -9
- package/lib/plugins/web-search.d.ts +1 -1
- package/lib/plugins/web-search.js +25 -16
- package/lib/plugins/webserver.js +40 -7
- package/lib/remote/assets/app-B3Id1EBq.js +14 -0
- package/lib/remote/assets/index.html +2 -2
- package/lib/remote/assets/{style-DIB6729x.css → style-NtlpbKOI.css} +1 -1
- package/lib/services/types.d.ts +247 -29
- package/lib/tools/plugin-cli.d.ts +1 -0
- package/lib/tools/plugin-cli.js +209 -0
- package/lib/ui/assets/app-B-Jx5dnh.js +90 -0
- package/lib/ui/assets/{chunk-BajyYBss.js → chunk-Bfdlo8Me.js} +1 -1
- package/lib/ui/assets/chunk-DGX-i4eb.js +12 -0
- package/lib/ui/assets/index.html +62 -14
- package/lib/ui/assets/style-WzxwEPaE.css +1 -0
- package/lib/ui/frames.js +1 -3
- package/lib/ui/index.d.ts +30 -1
- package/lib/ui/index.js +29 -0
- package/lib/ui/manifest.d.ts +24 -6
- package/lib/ui/manifest.js +3 -2
- package/lib/ui/plugins/actions/bundle.json +8 -0
- package/lib/ui/plugins/actions/client.js +43 -0
- package/lib/ui/plugins/ask/bundle.json +8 -0
- package/lib/ui/plugins/ask/client.js +415 -0
- package/lib/ui/plugins/browser/bundle.json +8 -0
- package/lib/ui/plugins/composer/bundle.json +9 -0
- package/lib/ui/plugins/composer/client.js +1806 -1087
- package/lib/ui/plugins/files/bundle.json +8 -0
- package/lib/ui/plugins/files/client.js +13 -98
- package/lib/ui/plugins/manifest.json +1 -104
- package/lib/ui/plugins/palette/bundle.json +8 -0
- package/lib/ui/plugins/palette/client.js +360 -0
- package/lib/ui/plugins/plugins/bundle.json +8 -0
- package/lib/ui/plugins/plugins/client.js +116 -38
- package/lib/ui/plugins/preview/bundle.json +8 -0
- package/lib/ui/plugins/preview/client.js +6 -16
- package/lib/ui/plugins/prompt/bundle.json +8 -0
- package/lib/ui/plugins/prompt/client.js +81 -47
- package/lib/ui/plugins/sessions/bundle.json +8 -0
- package/lib/ui/plugins/sessions/client.js +157 -111
- package/lib/ui/plugins/settings/bundle.json +8 -0
- package/lib/ui/plugins/settings/client.js +184 -170
- package/lib/ui/plugins/skills/bundle.json +8 -0
- package/lib/ui/plugins/skills/client.js +161 -79
- package/lib/ui/plugins/status/bundle.json +8 -0
- package/lib/ui/plugins/status/client.js +165 -26
- package/lib/ui/plugins/statusbar/bundle.json +9 -0
- package/lib/ui/plugins/statusbar/client.js +100 -144
- package/lib/ui/plugins/tasks/bundle.json +8 -0
- package/lib/ui/plugins/team/bundle.json +8 -0
- package/lib/ui/plugins/team/client.js +60 -58
- package/lib/ui/plugins/terminal/bundle.json +8 -0
- package/lib/ui/plugins/terminal/client.js +1 -7
- package/lib/ui/plugins/trace/bundle.json +11 -0
- package/lib/ui/plugins/trace/client.js +86 -179
- package/lib/ui/plugins/transcript/bundle.json +8 -0
- package/lib/ui/plugins/transcript/client.js +1608 -1243
- package/lib/ui/sdk/@dsc/ui/index.d.ts +54 -16
- package/lib/ui/sdk/@dsc/ui/package.json +1 -1
- package/lib/ui/sdk/@dsc/ui-core/contract.d.ts +20 -1968
- package/lib/ui/sdk/@dsc/ui-core/core/attachments.d.ts +185 -0
- package/lib/ui/sdk/@dsc/ui-core/core/bytes.d.ts +14 -0
- package/lib/ui/sdk/@dsc/ui-core/core/err-text.d.ts +18 -0
- package/lib/ui/sdk/@dsc/ui-core/core/git-surface.d.ts +17 -0
- package/lib/ui/sdk/@dsc/ui-core/core/json-text.d.ts +11 -0
- package/lib/ui/sdk/@dsc/ui-core/core/path-policy.d.ts +44 -0
- package/lib/ui/sdk/@dsc/ui-core/core/records.d.ts +16 -0
- package/lib/ui/sdk/@dsc/ui-core/core/throughput.d.ts +46 -0
- package/lib/ui/sdk/@dsc/ui-core/core/token-estimate.d.ts +18 -2
- package/lib/ui/sdk/@dsc/ui-core/core/unified-diff.d.ts +35 -0
- package/lib/ui/sdk/@dsc/ui-core/package.json +1 -1
- package/lib/ui/sdk/@dsc/ui-core/ui/index.d.ts +30 -1
- package/lib/ui/sdk/@dsc/ui-core/ui/manifest.d.ts +24 -6
- package/lib/ui/sdk/@dsc/ui-core/ui/services.d.ts +19 -8
- package/lib/ui/sdk/@dsc/ui-core/ui/signal.d.ts +49 -0
- package/lib/ui/sdk/@dsc/ui-dockkit/dock-model.d.ts +17 -3
- package/lib/ui/sdk/@dsc/ui-dockkit/dock-state.d.ts +1 -1
- package/lib/ui/sdk/@dsc/ui-dockkit/package.json +1 -1
- package/lib/ui/sdk/@dsc/ui-layout/app.d.ts +4 -0
- package/lib/ui/sdk/@dsc/ui-layout/appearance.d.ts +6 -1
- package/lib/ui/sdk/@dsc/ui-layout/host-channel.d.ts +21 -0
- package/lib/ui/sdk/@dsc/ui-layout/index.d.ts +1 -0
- package/lib/ui/sdk/@dsc/ui-layout/package.json +1 -1
- package/lib/ui/sdk/@dsc/ui-layout/page-state.d.ts +1 -1
- package/lib/ui/sdk/@dsc/ui-layout/runtime-context.d.ts +10 -1
- package/lib/ui/sdk/@dsc/ui-layout/thread-view.d.ts +1 -1
- package/lib/ui/sdk/@dsc/ui-layout/usage-today.d.ts +11 -0
- package/lib/ui/sdk/@dsc/ui-primitives/dialog-focus.d.ts +30 -0
- package/lib/ui/sdk/@dsc/ui-primitives/error-text.d.ts +12 -0
- package/lib/ui/sdk/@dsc/ui-primitives/git-surface.d.ts +9 -0
- package/lib/ui/sdk/@dsc/ui-primitives/highlight.d.ts +23 -0
- package/lib/ui/sdk/@dsc/ui-primitives/humanize-error.d.ts +35 -0
- package/lib/ui/sdk/@dsc/ui-primitives/icons-workspace.d.ts +33 -0
- package/lib/ui/sdk/@dsc/ui-primitives/icons.d.ts +21 -3
- package/lib/ui/sdk/@dsc/ui-primitives/image-lightbox.d.ts +21 -0
- package/lib/ui/sdk/@dsc/ui-primitives/index.d.ts +16 -0
- package/lib/ui/sdk/@dsc/ui-primitives/markdown.d.ts +10 -14
- package/lib/ui/sdk/@dsc/ui-primitives/package.json +1 -1
- package/lib/ui/sdk/@dsc/ui-primitives/panels.d.ts +31 -8
- package/lib/ui/sdk/@dsc/ui-primitives/paths.d.ts +2 -0
- package/lib/ui/sdk/@dsc/ui-primitives/review-findings-card.d.ts +25 -0
- package/lib/ui/sdk/@dsc/ui-primitives/review-findings.d.ts +64 -0
- package/lib/ui/sdk/@dsc/ui-primitives/review-notice-card.d.ts +27 -0
- package/lib/ui/sdk/@dsc/ui-primitives/review-notice.d.ts +80 -0
- package/lib/ui/sdk/@dsc/ui-primitives/signal.d.ts +9 -0
- package/lib/ui/sdk/@dsc/ui-primitives/sizes.d.ts +15 -0
- package/lib/ui/sdk/@dsc/ui-primitives/skeleton.d.ts +39 -0
- package/lib/ui/sdk/@dsc/ui-primitives/snapshot.d.ts +46 -0
- package/lib/ui/sdk/@dsc/ui-primitives/thread-resizer.d.ts +3 -3
- package/lib/ui/sdk/@dsc/ui-primitives/throughput.d.ts +13 -0
- package/lib/ui/sdk/@dsc/ui-primitives/tokens.d.ts +9 -0
- package/lib/ui/sdk/@dsc/ui-primitives/tool-args.d.ts +1 -1
- package/lib/ui/sdk/@dsc/ui-primitives/tool-summary.d.ts +30 -6
- package/lib/ui/sdk/@dsc/ui-primitives/unified-diff.d.ts +10 -0
- package/lib/ui/sdk/@dsc/ui-renderer/boot.d.ts +10 -1
- package/lib/ui/sdk/@dsc/ui-renderer/cordis-host.d.ts +113 -0
- package/lib/ui/sdk/@dsc/ui-renderer/package.json +1 -1
- package/lib/ui/sdk/@dsc/ui-slots/package.json +1 -1
- package/lib/ui/services.d.ts +19 -8
- package/lib/ui/services.js +20 -12
- package/lib/ui/signal.d.ts +49 -0
- package/lib/ui/signal.js +57 -0
- package/lib/ui/tui-plugins.js +36 -16
- package/package.json +71 -58
- package/lib/remote/assets/app-DAcUCOEn.js +0 -14
- package/lib/ui/assets/app-B70nVIKd.js +0 -69
- package/lib/ui/assets/chunk-BGcgwlCI.js +0 -12
- package/lib/ui/assets/style-Bq01xH_b.css +0 -1
package/lib/core/ui-bundles.js
CHANGED
|
@@ -29,12 +29,21 @@
|
|
|
29
29
|
*/
|
|
30
30
|
import { readFileSync, statSync } from 'node:fs';
|
|
31
31
|
import { createHash } from 'node:crypto';
|
|
32
|
-
import { dirname, resolve } from 'node:path';
|
|
32
|
+
import { basename, dirname, resolve } from 'node:path';
|
|
33
33
|
import { fileURLToPath } from 'node:url';
|
|
34
34
|
import { satisfies, validRange } from 'semver';
|
|
35
35
|
import { inside } from './web-static.js';
|
|
36
|
-
|
|
36
|
+
import { activeProfileDir } from './profile-dir.js';
|
|
37
|
+
/** 根清单文件名(界面壳构建时写在插件目录根部;2.0 起只写壳契约版本)。 */
|
|
37
38
|
export const UI_PLUGIN_MANIFEST = 'manifest.json';
|
|
39
|
+
/**
|
|
40
|
+
* 每个插件产物目录里的自述文件名(2.0 起一个插件一处声明)。
|
|
41
|
+
*
|
|
42
|
+
* 为什么不是 package.json:产物目录里没有包(是构建出来的四件东西),拿 package.json 的
|
|
43
|
+
* 名字会让人以为那是 npm 包;也不是 plugin.json——1.x 的 plugin.json 是「源码目录里的声明」,
|
|
44
|
+
* 2.0 已经并进各插件自己的 package.json 的 dsh.client 了,同名会混淆两件事。
|
|
45
|
+
*/
|
|
46
|
+
export const UI_PLUGIN_BUNDLE = 'bundle.json';
|
|
38
47
|
/**
|
|
39
48
|
* 认得的载体取值:`UiPlatform` 的那两个,一字不差。
|
|
40
49
|
* 不在这张表里的值(写错、或将来别的壳)一律丢弃并记问题——失败关闭。
|
|
@@ -93,6 +102,8 @@ export function readThirdPartyUiPluginBundle(id, dir = thirdPartyUiRoot()) {
|
|
|
93
102
|
*
|
|
94
103
|
* 规则(对齐 ui-plugin-parity-plan §5.1 拍板的六条):
|
|
95
104
|
* - 内置清单(顶层带 `apiVersion`,即构建产物)的条目没写 `api` 视为与壳同源,放行;
|
|
105
|
+
* - 清单没有 `apiVersion`(不是当前构建写的)时**连没有 `api` 的条目也拒**——两边都没有
|
|
106
|
+
* 依据就是无从判断,放行等于给手写清单开一条绕过门禁的路(失败关闭);
|
|
96
107
|
* - 第三方清单(没有 `apiVersion`)的条目**必须**声明区间,缺失即拒(失败关闭);
|
|
97
108
|
* - `workspace:` 前缀与解析不了的区间直接拒——请写具体版本区间,不做「等于当前」的猜法;
|
|
98
109
|
* - `satisfies(壳版本, 区间)` 不满足(含预发布版)即拒。
|
|
@@ -100,7 +111,11 @@ export function readThirdPartyUiPluginBundle(id, dir = thirdPartyUiRoot()) {
|
|
|
100
111
|
export function evaluateUiApiGate(api, apiVersion) {
|
|
101
112
|
if (apiVersion === undefined) {
|
|
102
113
|
if (api === undefined) {
|
|
103
|
-
|
|
114
|
+
// 失败关闭(2026-10-26 改):清单没写 apiVersion,条目也没声明 api——两边都没有依据,
|
|
115
|
+
// 以前是「不拦」。那种放行等于给一份手写清单开了后门:往里加一条 id 就能绕过门禁。
|
|
116
|
+
// 现在的构建一定写 apiVersion(`build-plugins.mjs`),落到这一档只有两种可能:
|
|
117
|
+
// 产物是旧版构建写的,或清单是人手写的。两种都该让人看见并重建,不该静默装载。
|
|
118
|
+
return '清单没写 apiVersion(不是当前构建写的),条目也没声明 api 区间——无从判断兼容性,已跳过(重新构建界面壳,或给条目补 api)';
|
|
104
119
|
}
|
|
105
120
|
return matchGate(api, '(清单未声明 apiVersion)');
|
|
106
121
|
}
|
|
@@ -123,93 +138,224 @@ function matchGate(api, shellVersion) {
|
|
|
123
138
|
return null;
|
|
124
139
|
}
|
|
125
140
|
/**
|
|
126
|
-
*
|
|
141
|
+
* 读插件产物清单,并把所有被丢掉的行/字段记成问题。
|
|
142
|
+
*
|
|
143
|
+
* **2.0 起「谁是插件」由每个产物目录自己说**:`<dir>/<id>/bundle.json` 是这一份产物的
|
|
144
|
+
* 自述(契约版本、载体、依赖、调度档位)。宿主扫目录,不再按中央清单列插件——加一个插件
|
|
145
|
+
* 不用改任何汇总文件,删一个插件也只是目录没了。
|
|
146
|
+
*
|
|
147
|
+
* 中央 `manifest.json` 仍会读,但只剩两件事:
|
|
148
|
+
* 1. 顶层 `apiVersion`(壳契约版本;产物目录里那份也带着,根文件缺了就从目录里取);
|
|
149
|
+
* 2. 旧构建的 `plugins` 数组——**只在一个 `bundle.json` 都找不到时**当兜底,
|
|
150
|
+
* 免得拿着一份旧产物升级宿主后界面全空。构建脚本不再写这个数组。
|
|
127
151
|
*
|
|
128
152
|
* 文件缺失/整个 JSON 坏掉一律按空处理(界面壳还没构建就是这样,与 remote 的
|
|
129
|
-
* "资产未构建"
|
|
153
|
+
* "资产未构建"占位页同一套待遇:能起来,但没有插件);但**坏掉的自述要说话**,
|
|
130
154
|
* 不然"插件怎么不见了"只能靠猜。
|
|
131
155
|
*/
|
|
132
156
|
export function readUiPluginManifestReport(dir = uiPluginsDir()) {
|
|
133
|
-
const entries = [];
|
|
134
157
|
const problems = [];
|
|
158
|
+
const root = readRootManifest(dir, problems);
|
|
159
|
+
const bundled = readBundleDeclarations(dir, problems);
|
|
160
|
+
if (bundled.found) {
|
|
161
|
+
// 壳契约版本:根文件优先,其次取产物自述里那个(同一轮构建写的,值应当一样)。
|
|
162
|
+
const apiVersion = root.apiVersion ?? singleApiVersion(bundled.apiVersions, problems);
|
|
163
|
+
return { entries: bundled.entries, problems, ...(apiVersion === undefined ? {} : { apiVersion }) };
|
|
164
|
+
}
|
|
165
|
+
const entries = [];
|
|
166
|
+
if (root.plugins !== undefined) {
|
|
167
|
+
for (let index = 0; index < root.plugins.length; index += 1) {
|
|
168
|
+
const raw = root.plugins[index];
|
|
169
|
+
const where = `${UI_PLUGIN_MANIFEST} 第 ${String(index + 1)} 条`;
|
|
170
|
+
if (raw === null || typeof raw !== 'object' || Array.isArray(raw)) {
|
|
171
|
+
problems.push(`${where}: 不是对象,丢弃`);
|
|
172
|
+
continue;
|
|
173
|
+
}
|
|
174
|
+
const record = raw;
|
|
175
|
+
const id = typeof record['id'] === 'string' ? record['id'] : '';
|
|
176
|
+
const parsed = parseUiPluginEntry(record, id, where, problems);
|
|
177
|
+
if (parsed !== null)
|
|
178
|
+
entries.push(parsed);
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
return { entries, problems, ...(root.apiVersion === undefined ? {} : { apiVersion: root.apiVersion }) };
|
|
182
|
+
}
|
|
183
|
+
/** 读根 manifest.json;坏掉记问题并当没写。文件不在不记问题(等于还没构建)。 */
|
|
184
|
+
function readRootManifest(dir, problems) {
|
|
135
185
|
let text;
|
|
136
186
|
try {
|
|
137
187
|
text = readFileSync(resolve(dir, UI_PLUGIN_MANIFEST), 'utf8');
|
|
138
188
|
}
|
|
139
189
|
catch {
|
|
140
|
-
return {
|
|
190
|
+
return {};
|
|
141
191
|
}
|
|
142
192
|
let doc;
|
|
143
193
|
try {
|
|
144
194
|
doc = JSON.parse(text);
|
|
145
195
|
}
|
|
146
196
|
catch (error) {
|
|
147
|
-
problems.push(`${UI_PLUGIN_MANIFEST}: 不是合法 JSON(${error instanceof Error ? error.message : String(error)}
|
|
148
|
-
return {
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
if (rawApiVersion !== undefined
|
|
197
|
+
problems.push(`${UI_PLUGIN_MANIFEST}: 不是合法 JSON(${error instanceof Error ? error.message : String(error)}),当没写处理`);
|
|
198
|
+
return {};
|
|
199
|
+
}
|
|
200
|
+
if (doc === null || typeof doc !== 'object' || Array.isArray(doc)) {
|
|
201
|
+
problems.push(`${UI_PLUGIN_MANIFEST}: 顶层不是对象,当没写处理`);
|
|
202
|
+
return {};
|
|
203
|
+
}
|
|
204
|
+
const record = doc;
|
|
205
|
+
const out = {};
|
|
206
|
+
const rawApiVersion = record['apiVersion'];
|
|
207
|
+
if (typeof rawApiVersion === 'string' && rawApiVersion.trim() !== '')
|
|
208
|
+
out.apiVersion = rawApiVersion.trim();
|
|
209
|
+
else if (rawApiVersion !== undefined) {
|
|
160
210
|
problems.push(`${UI_PLUGIN_MANIFEST}: 顶层 apiVersion 不是非空字符串(${JSON.stringify(rawApiVersion)}),当没写处理`);
|
|
161
211
|
}
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
212
|
+
if (Array.isArray(record['plugins']))
|
|
213
|
+
out.plugins = record['plugins'];
|
|
214
|
+
return out;
|
|
215
|
+
}
|
|
216
|
+
/**
|
|
217
|
+
* 扫产物目录,读每个插件自己的 `bundle.json`。
|
|
218
|
+
*
|
|
219
|
+
* 目录名就是 id(与第三方、组合包同一口径);目录里有 `client.js` 却没有自述要**点名报出来**
|
|
220
|
+
* ——那是旧构建的产物(2.0 起每份产物必须自述),静默跳过会变成「插件怎么不见了」。
|
|
221
|
+
*/
|
|
222
|
+
function readBundleDeclarations(dir, problems) {
|
|
223
|
+
const entries = [];
|
|
224
|
+
const apiVersions = new Set();
|
|
225
|
+
let names;
|
|
226
|
+
try {
|
|
227
|
+
names = readdirSync(dir, { withFileTypes: true })
|
|
228
|
+
.filter((entry) => entry.isDirectory() && !entry.name.startsWith('.'))
|
|
229
|
+
.map((entry) => entry.name)
|
|
230
|
+
.sort();
|
|
231
|
+
}
|
|
232
|
+
catch {
|
|
233
|
+
return { entries, apiVersions, found: false };
|
|
234
|
+
}
|
|
235
|
+
let found = false;
|
|
236
|
+
for (const name of names) {
|
|
237
|
+
let text;
|
|
238
|
+
try {
|
|
239
|
+
text = readFileSync(resolve(dir, name, UI_PLUGIN_BUNDLE), 'utf8');
|
|
168
240
|
}
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
241
|
+
catch {
|
|
242
|
+
// 没有自述:有 client.js 就是旧产物(要说话),没有就当这不是插件目录。
|
|
243
|
+
try {
|
|
244
|
+
statSync(resolve(dir, name, 'client.js'));
|
|
245
|
+
problems.push(`${name}: 没有 ${UI_PLUGIN_BUNDLE}——这份产物不是 2.0 的构建写的,重新构建界面壳`);
|
|
246
|
+
}
|
|
247
|
+
catch {
|
|
248
|
+
// 无关目录,静默跳过
|
|
249
|
+
}
|
|
174
250
|
continue;
|
|
175
251
|
}
|
|
176
|
-
|
|
177
|
-
|
|
252
|
+
found = true;
|
|
253
|
+
let doc;
|
|
254
|
+
try {
|
|
255
|
+
doc = JSON.parse(text);
|
|
256
|
+
}
|
|
257
|
+
catch (error) {
|
|
258
|
+
problems.push(`${name}/${UI_PLUGIN_BUNDLE}: 不是合法 JSON(${error instanceof Error ? error.message : String(error)}),这份插件跳过`);
|
|
178
259
|
continue;
|
|
179
260
|
}
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
if (platform !== undefined && (typeof platform !== 'string' || !KNOWN_PLATFORMS.has(platform))) {
|
|
183
|
-
problems.push(`${id}: 载体(platform)不认识(${JSON.stringify(platform)}),丢弃`);
|
|
261
|
+
if (doc === null || typeof doc !== 'object' || Array.isArray(doc)) {
|
|
262
|
+
problems.push(`${name}/${UI_PLUGIN_BUNDLE}: 不是对象,这份插件跳过`);
|
|
184
263
|
continue;
|
|
185
264
|
}
|
|
186
|
-
const
|
|
187
|
-
const
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
const
|
|
191
|
-
|
|
192
|
-
|
|
265
|
+
const record = doc;
|
|
266
|
+
const declared = record['apiVersion'];
|
|
267
|
+
if (typeof declared === 'string' && declared.trim() !== '')
|
|
268
|
+
apiVersions.add(declared.trim());
|
|
269
|
+
const where = `${name}/${UI_PLUGIN_BUNDLE}`;
|
|
270
|
+
// 载体:自述里写 platforms 数组(一份产物出几行),缺省 ['web']——与组合包的
|
|
271
|
+
// dsh.client.platforms 同一套词表与默认值,只是这里是构建产物、那边是包。
|
|
272
|
+
const rawPlatforms = record['platforms'];
|
|
273
|
+
let platforms = ['web'];
|
|
274
|
+
if (rawPlatforms !== undefined) {
|
|
275
|
+
if (!Array.isArray(rawPlatforms) || rawPlatforms.length === 0
|
|
276
|
+
|| rawPlatforms.some((value) => value !== 'web' && value !== 'tui')) {
|
|
277
|
+
problems.push(`${where}: platforms 只能是 'web' / 'tui' 的非空数组(收到 ${JSON.stringify(rawPlatforms)}),这份插件跳过`);
|
|
278
|
+
continue;
|
|
279
|
+
}
|
|
280
|
+
platforms = rawPlatforms;
|
|
193
281
|
}
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
282
|
+
for (const platform of platforms) {
|
|
283
|
+
const parsed = parseUiPluginEntry({ ...record, platform }, name, where, problems);
|
|
284
|
+
if (parsed !== null)
|
|
285
|
+
entries.push(parsed);
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
return { entries, apiVersions, found };
|
|
289
|
+
}
|
|
290
|
+
/** 各份自述的契约版本必须一致;不一致就没法判门禁,记一条问题并当没写。 */
|
|
291
|
+
function singleApiVersion(versions, problems) {
|
|
292
|
+
if (versions.size === 0)
|
|
293
|
+
return undefined;
|
|
294
|
+
if (versions.size === 1)
|
|
295
|
+
return [...versions][0];
|
|
296
|
+
problems.push(`产物自述里的 apiVersion 不一致(${[...versions].join('、')})——这份产物是混着几个壳版本构建的,重新构建界面壳`);
|
|
297
|
+
return undefined;
|
|
298
|
+
}
|
|
299
|
+
/**
|
|
300
|
+
* 解析一条插件声明(中央清单的一行,或某个目录的 bundle.json)。
|
|
301
|
+
*
|
|
302
|
+
* id 由调用方给(目录名 / 数组那一行的 id):目录路径上的身份不许由文件内容改写,
|
|
303
|
+
* 否则一个包里写别的 id 就能顶掉别人的位置。
|
|
304
|
+
* @param record - 声明对象
|
|
305
|
+
* @param id - 这条的 id(已由调用方定下来源)
|
|
306
|
+
* @param where - 报错里写的位置
|
|
307
|
+
* @param problems - 问题收集
|
|
308
|
+
* @returns 条目;不合法给 null(原因已进 problems)
|
|
309
|
+
*/
|
|
310
|
+
function parseUiPluginEntry(record, id, where, problems) {
|
|
311
|
+
const declaredId = record['id'];
|
|
312
|
+
if (typeof declaredId === 'string' && declaredId !== id) {
|
|
313
|
+
problems.push(`${where}: 写着自己的 id 是 ${JSON.stringify(declaredId)},与目录名/位置上那个不一致——id 由位置决定,丢弃`);
|
|
314
|
+
return null;
|
|
315
|
+
}
|
|
316
|
+
if (!PLUGIN_ID.test(id)) {
|
|
317
|
+
problems.push(`${where}: id 不成形(${JSON.stringify(id)}),丢弃`);
|
|
318
|
+
return null;
|
|
211
319
|
}
|
|
212
|
-
|
|
320
|
+
const file = typeof record['file'] === 'string' ? record['file'] : '';
|
|
321
|
+
if (file === '' || file.includes('/') || file.includes('\\')) {
|
|
322
|
+
problems.push(`${id}: 文件名不成形(${JSON.stringify(record['file'])}),丢弃`);
|
|
323
|
+
return null;
|
|
324
|
+
}
|
|
325
|
+
// 载体:认识的只有 web / tui 两个取值;别的(写错、或别的壳的取值)不当客户端行。
|
|
326
|
+
const platform = record['platform'];
|
|
327
|
+
if (platform !== undefined && (typeof platform !== 'string' || !KNOWN_PLATFORMS.has(platform))) {
|
|
328
|
+
problems.push(`${id}: 载体(platform)不认识(${JSON.stringify(platform)}),丢弃`);
|
|
329
|
+
return null;
|
|
330
|
+
}
|
|
331
|
+
// inject = 依赖的插件 id;services = 依赖的服务名(2.0 起分开,见 UiPluginRow)。
|
|
332
|
+
const inject = readNameList(record['inject'], id, 'inject', problems);
|
|
333
|
+
const services = readNameList(record['services'], id, 'services', problems);
|
|
334
|
+
const external = readNameList(record['external'], id, 'external', problems);
|
|
335
|
+
// api:插件声明的 @dsc/ui 区间(第三方必需;形状校验放门禁判定,这里只管类型)。
|
|
336
|
+
const rawApi = record['api'];
|
|
337
|
+
const api = typeof rawApi === 'string' && rawApi.trim() !== '' ? rawApi.trim() : undefined;
|
|
338
|
+
if (rawApi !== undefined && api === undefined) {
|
|
339
|
+
problems.push(`${id}: api 不是非空字符串(${JSON.stringify(rawApi)}),当没声明处理`);
|
|
340
|
+
}
|
|
341
|
+
// phase:调度档位。坏值记问题并**当没声明**(按 application),方向与 api 一致——
|
|
342
|
+
// 一个拼错的 phase 不该让整个插件消失,但也不能静默当 early 发出去。
|
|
343
|
+
const rawPhase = record['phase'];
|
|
344
|
+
const phase = rawPhase === 'early' || rawPhase === 'application' ? rawPhase : undefined;
|
|
345
|
+
if (rawPhase !== undefined && phase === undefined) {
|
|
346
|
+
problems.push(`${id}: phase 只能是 'early' / 'application'(${JSON.stringify(rawPhase)}),当没声明处理`);
|
|
347
|
+
}
|
|
348
|
+
return {
|
|
349
|
+
id,
|
|
350
|
+
file,
|
|
351
|
+
...(inject === undefined ? {} : { inject }),
|
|
352
|
+
...(services === undefined ? {} : { services }),
|
|
353
|
+
...(external === undefined ? {} : { external }),
|
|
354
|
+
...(record['immediately'] === true ? { immediately: true } : {}),
|
|
355
|
+
...(phase === undefined ? {} : { phase }),
|
|
356
|
+
...(api === undefined ? {} : { api }),
|
|
357
|
+
...(platform === undefined ? {} : { platform: platform }),
|
|
358
|
+
};
|
|
213
359
|
}
|
|
214
360
|
/**
|
|
215
361
|
* 读一个字符串数组字段(`inject` / `external`)。
|
|
@@ -238,6 +384,16 @@ function readNameList(value, id, field, problems) {
|
|
|
238
384
|
export function readUiPluginManifest(dir = uiPluginsDir()) {
|
|
239
385
|
return readUiPluginManifestReport(dir).entries;
|
|
240
386
|
}
|
|
387
|
+
/** 一个文件的「mtime:size」戳;读不到给 null(指纹里当没有)。 */
|
|
388
|
+
function stampOf(path) {
|
|
389
|
+
try {
|
|
390
|
+
const stat = statSync(path);
|
|
391
|
+
return `${String(Math.trunc(stat.mtimeMs))}:${String(stat.size)}`;
|
|
392
|
+
}
|
|
393
|
+
catch {
|
|
394
|
+
return null;
|
|
395
|
+
}
|
|
396
|
+
}
|
|
241
397
|
/** 定位一条缓存用的键(id 与文件名都可能含 `.` `-`,用不会出现的 NUL 分隔)。 */
|
|
242
398
|
function cacheKey(id, file) {
|
|
243
399
|
return `${id}\u0000${file}`;
|
|
@@ -278,16 +434,30 @@ class UiArtifactCache {
|
|
|
278
434
|
this.dir = dir;
|
|
279
435
|
this.platform = platform;
|
|
280
436
|
}
|
|
281
|
-
/**
|
|
437
|
+
/**
|
|
438
|
+
* 现在的产物指纹:根清单 + 目录列表 + 每份自述的 mtime/size。
|
|
439
|
+
*
|
|
440
|
+
* 为什么要连目录一起 stat:2.0 起「谁是插件」由目录自己说,新增/删掉一个插件只体现在
|
|
441
|
+
* 目录列表上(根清单只写壳契约版本)。目录的 mtime 在 NTFS/ext4 上增删条目都会变。
|
|
442
|
+
* 没构建(目录不在、根清单也不在)给一个固定值,仍然算一种指纹。
|
|
443
|
+
*/
|
|
282
444
|
fingerprint() {
|
|
283
|
-
|
|
445
|
+
const parts = [stampOf(resolve(this.dir, UI_PLUGIN_MANIFEST)) ?? 'no-manifest'];
|
|
446
|
+
let names;
|
|
284
447
|
try {
|
|
285
|
-
|
|
286
|
-
|
|
448
|
+
names = readdirSync(this.dir, { withFileTypes: true })
|
|
449
|
+
.filter((entry) => entry.isDirectory() && !entry.name.startsWith('.'))
|
|
450
|
+
.map((entry) => entry.name)
|
|
451
|
+
.sort();
|
|
287
452
|
}
|
|
288
453
|
catch {
|
|
289
|
-
return '
|
|
454
|
+
return parts.join('|');
|
|
290
455
|
}
|
|
456
|
+
parts.push(`dirs:${String(names.length)}`);
|
|
457
|
+
for (const name of names)
|
|
458
|
+
parts.push(`${name}=${stampOf(resolve(this.dir, name, UI_PLUGIN_BUNDLE)) ?? 'none'}`);
|
|
459
|
+
CACHE_COUNTERS.manifestStats += 1 + names.length;
|
|
460
|
+
return parts.join('|');
|
|
291
461
|
}
|
|
292
462
|
/** 建表(读清单 + 逐文件算版本)。清单没换且没要求强制,就直接返回。 */
|
|
293
463
|
rebuild(force) {
|
|
@@ -370,12 +540,19 @@ class UiArtifactCache {
|
|
|
370
540
|
/** 现在的产物表(清单没换就不重算)。 */
|
|
371
541
|
table() {
|
|
372
542
|
this.rebuild(false);
|
|
373
|
-
|
|
543
|
+
// 内置清单没有逐条启停(它们随壳一起发布),被停用的只有第三方与组合包——
|
|
544
|
+
// 那两个来源在 collect 那层合并进来,这里给空。
|
|
545
|
+
return {
|
|
546
|
+
entries: [...this.entries],
|
|
547
|
+
problems: [...this.problems],
|
|
548
|
+
disabled: [],
|
|
549
|
+
...(this.apiVersion === undefined ? {} : { apiVersion: this.apiVersion }),
|
|
550
|
+
};
|
|
374
551
|
}
|
|
375
552
|
/** 强制重算(页面每次加载、`refresh()` 用:文件被手工换掉也立刻反映)。 */
|
|
376
553
|
refresh() {
|
|
377
554
|
this.rebuild(true);
|
|
378
|
-
return
|
|
555
|
+
return this.table();
|
|
379
556
|
}
|
|
380
557
|
/**
|
|
381
558
|
* 按 id + 文件名 + 版本取字节。
|
|
@@ -504,12 +681,13 @@ function thirdPartyCache(dir) {
|
|
|
504
681
|
export function discoverThirdPartyUiArtifacts(shellApiVersion, builtinIds, dir = thirdPartyUiRoot()) {
|
|
505
682
|
const entries = [];
|
|
506
683
|
const problems = [];
|
|
684
|
+
const disabled = [];
|
|
507
685
|
let names;
|
|
508
686
|
try {
|
|
509
687
|
names = readdirSync(dir, { withFileTypes: true }).filter((e) => e.isDirectory() && !e.name.startsWith('.')).map((e) => e.name);
|
|
510
688
|
}
|
|
511
689
|
catch {
|
|
512
|
-
return { entries, problems }; // 目录还没有 = 还没装过第三方,正常态
|
|
690
|
+
return { entries, problems, disabled }; // 目录还没有 = 还没装过第三方,正常态
|
|
513
691
|
}
|
|
514
692
|
const cache = thirdPartyCache(dir);
|
|
515
693
|
const trusted = readUiPluginTrust();
|
|
@@ -559,7 +737,8 @@ export function discoverThirdPartyUiArtifacts(shellApiVersion, builtinIds, dir =
|
|
|
559
737
|
continue;
|
|
560
738
|
}
|
|
561
739
|
if (!isPluginEnabled(fileKey)) {
|
|
562
|
-
|
|
740
|
+
disabled.push(name); // 停用不是问题(启停是用户的开关),但要能报「它被停用了」
|
|
741
|
+
continue;
|
|
563
742
|
}
|
|
564
743
|
if (trusted[fileKey] === undefined) {
|
|
565
744
|
problems.push(`${where}: 还没有信任记录——首次安装需要在插件中心确认一次(它将能调用宿主的界面方法)`);
|
|
@@ -573,6 +752,16 @@ export function discoverThirdPartyUiArtifacts(shellApiVersion, builtinIds, dir =
|
|
|
573
752
|
const rev = contentRev(bytes);
|
|
574
753
|
const cached = cache.get(fileKey);
|
|
575
754
|
const fingerprint = `${rev}`;
|
|
755
|
+
// services:与内置清单同一口径——坏值记一条问题,不静默丢(丢一个依赖等于让插件少等一件事)。
|
|
756
|
+
let services;
|
|
757
|
+
if (doc['services'] !== undefined) {
|
|
758
|
+
if (Array.isArray(doc['services']) && doc['services'].every((value) => typeof value === 'string' && value !== '')) {
|
|
759
|
+
services = doc['services'];
|
|
760
|
+
}
|
|
761
|
+
else {
|
|
762
|
+
problems.push(`${where}: services 必须是非空字符串数组(依赖的服务名),当没声明处理`);
|
|
763
|
+
}
|
|
764
|
+
}
|
|
576
765
|
const row = {
|
|
577
766
|
id: name,
|
|
578
767
|
file: 'client.js',
|
|
@@ -580,6 +769,7 @@ export function discoverThirdPartyUiArtifacts(shellApiVersion, builtinIds, dir =
|
|
|
580
769
|
api,
|
|
581
770
|
origin: 'third-party',
|
|
582
771
|
source: name,
|
|
772
|
+
...(services === undefined ? {} : { services }),
|
|
583
773
|
...(phase === undefined ? {} : { phase }),
|
|
584
774
|
};
|
|
585
775
|
// 双平台插件进两个平台视图:web 行缺省(无 platform 字段),tui 行显式写。
|
|
@@ -596,7 +786,7 @@ export function discoverThirdPartyUiArtifacts(shellApiVersion, builtinIds, dir =
|
|
|
596
786
|
});
|
|
597
787
|
}
|
|
598
788
|
}
|
|
599
|
-
return { entries, problems };
|
|
789
|
+
return { entries, problems, disabled };
|
|
600
790
|
}
|
|
601
791
|
function existsClient(dir, name) {
|
|
602
792
|
try {
|
|
@@ -649,6 +839,8 @@ export function scanThirdPartyUiTrusts(shellApiVersion, builtinIds, dir = thirdP
|
|
|
649
839
|
const trust = trusted[fileKey];
|
|
650
840
|
const row = {
|
|
651
841
|
name,
|
|
842
|
+
key: fileKey,
|
|
843
|
+
origin: 'third-party',
|
|
652
844
|
platforms: ['web'],
|
|
653
845
|
trusted: trust !== undefined,
|
|
654
846
|
enabled: isPluginEnabled(fileKey),
|
|
@@ -776,20 +968,446 @@ export function lookupThirdPartyUiBundle(id, file, rev, dir = thirdPartyUiRoot()
|
|
|
776
968
|
}
|
|
777
969
|
return { known: true, current: false, previous: false, size: null, body: null };
|
|
778
970
|
}
|
|
971
|
+
/** profile 目录 → (包名 → 缓存)。进程内只有宿主这一个写者。 */
|
|
972
|
+
const packageCaches = new Map();
|
|
973
|
+
/**
|
|
974
|
+
* 在一个已装包的 `package.json` 里读 `dsh.client`。
|
|
975
|
+
* @param dir - 包的目录
|
|
976
|
+
* @returns 声明;没写或形状不对给 null(形状问题由调用方记 problems)
|
|
977
|
+
*/
|
|
978
|
+
function readClientDeclaration(dir) {
|
|
979
|
+
let manifest;
|
|
980
|
+
try {
|
|
981
|
+
manifest = JSON.parse(readFileSync(resolve(dir, 'package.json'), 'utf8'));
|
|
982
|
+
}
|
|
983
|
+
catch {
|
|
984
|
+
return null;
|
|
985
|
+
}
|
|
986
|
+
const dsh = manifest['dsh'];
|
|
987
|
+
const client = dsh !== null && typeof dsh === 'object' ? dsh.client : undefined;
|
|
988
|
+
if (client === null || typeof client !== 'object')
|
|
989
|
+
return null;
|
|
990
|
+
const decl = client;
|
|
991
|
+
return {
|
|
992
|
+
platform: decl['platform'],
|
|
993
|
+
platforms: decl['platforms'],
|
|
994
|
+
api: decl['api'],
|
|
995
|
+
inject: decl['inject'],
|
|
996
|
+
services: decl['services'],
|
|
997
|
+
phase: decl['phase'],
|
|
998
|
+
immediately: decl['immediately'],
|
|
999
|
+
version: typeof manifest['version'] === 'string' ? manifest['version'] : undefined,
|
|
1000
|
+
clientPath: clientEntryOf(manifest['exports']),
|
|
1001
|
+
};
|
|
1002
|
+
}
|
|
1003
|
+
/** `exports["./client"]` 的入口(字符串或条件对象)。 */
|
|
1004
|
+
function clientEntryOf(exports) {
|
|
1005
|
+
if (exports === null || typeof exports !== 'object')
|
|
1006
|
+
return null;
|
|
1007
|
+
const entry = exports['./client'];
|
|
1008
|
+
if (typeof entry === 'string')
|
|
1009
|
+
return entry;
|
|
1010
|
+
if (entry === null || typeof entry !== 'object')
|
|
1011
|
+
return null;
|
|
1012
|
+
const conditions = entry;
|
|
1013
|
+
for (const key of ['default', 'import', 'node', 'require']) {
|
|
1014
|
+
const value = conditions[key];
|
|
1015
|
+
if (typeof value === 'string')
|
|
1016
|
+
return value;
|
|
1017
|
+
}
|
|
1018
|
+
return null;
|
|
1019
|
+
}
|
|
1020
|
+
/** 目录列表缓存:`node_modules` 的 mtime + 条目数是钥匙(装/删包会变,读盘不会)。 */
|
|
1021
|
+
const packageListCache = new Map();
|
|
1022
|
+
/** 单包声明的解析缓存:`package.json` 的 mtime+size 是钥匙。 */
|
|
1023
|
+
const packageDeclCache = new Map();
|
|
1024
|
+
function statStamp(path) {
|
|
1025
|
+
try {
|
|
1026
|
+
const stat = statSync(path);
|
|
1027
|
+
return `${String(stat.mtimeMs)}:${String(stat.size)}`;
|
|
1028
|
+
}
|
|
1029
|
+
catch {
|
|
1030
|
+
return null;
|
|
1031
|
+
}
|
|
1032
|
+
}
|
|
1033
|
+
/**
|
|
1034
|
+
* 读一个包声明的缓存版(`package.json` 没换就不重解析)。
|
|
1035
|
+
*
|
|
1036
|
+
* 为什么要缓存:`collectUiArtifactsForPlatform` 每次组图都会被调(`/boot.js`、HMR 轮询),
|
|
1037
|
+
* profile 里几十个包时,每个包一次 stat + readFile 是白花的。
|
|
1038
|
+
*/
|
|
1039
|
+
function readClientDeclarationCached(dir) {
|
|
1040
|
+
const stamp = statStamp(resolve(dir, 'package.json'));
|
|
1041
|
+
if (stamp === null)
|
|
1042
|
+
return null;
|
|
1043
|
+
const cached = packageDeclCache.get(dir);
|
|
1044
|
+
if (cached !== undefined && cached.stamp === stamp)
|
|
1045
|
+
return cached.decl;
|
|
1046
|
+
const decl = readClientDeclaration(dir);
|
|
1047
|
+
packageDeclCache.set(dir, { stamp, decl });
|
|
1048
|
+
return decl;
|
|
1049
|
+
}
|
|
1050
|
+
/** `node_modules` 下的包目录(含 `@scope/*` 一层)。 */
|
|
1051
|
+
function packageDirs(nodeModules) {
|
|
1052
|
+
let names;
|
|
1053
|
+
try {
|
|
1054
|
+
names = readdirSync(nodeModules);
|
|
1055
|
+
}
|
|
1056
|
+
catch {
|
|
1057
|
+
return [];
|
|
1058
|
+
}
|
|
1059
|
+
const stamp = `${String(existsStamp(nodeModules))}:${String(names.length)}`;
|
|
1060
|
+
const cachedList = packageListCache.get(nodeModules);
|
|
1061
|
+
if (cachedList !== undefined && cachedList.stamp === stamp)
|
|
1062
|
+
return cachedList.dirs;
|
|
1063
|
+
const found = [];
|
|
1064
|
+
for (const name of names) {
|
|
1065
|
+
if (name.startsWith('.'))
|
|
1066
|
+
continue;
|
|
1067
|
+
const dir = resolve(nodeModules, name);
|
|
1068
|
+
if (name.startsWith('@')) {
|
|
1069
|
+
let scoped;
|
|
1070
|
+
try {
|
|
1071
|
+
scoped = readdirSync(dir);
|
|
1072
|
+
}
|
|
1073
|
+
catch {
|
|
1074
|
+
continue;
|
|
1075
|
+
}
|
|
1076
|
+
for (const child of scoped)
|
|
1077
|
+
found.push({ name: `${name}/${child}`, dir: resolve(dir, child) });
|
|
1078
|
+
continue;
|
|
1079
|
+
}
|
|
1080
|
+
found.push({ name, dir });
|
|
1081
|
+
}
|
|
1082
|
+
packageListCache.set(nodeModules, { stamp, dirs: found });
|
|
1083
|
+
return found;
|
|
1084
|
+
}
|
|
1085
|
+
function existsStamp(path) {
|
|
1086
|
+
try {
|
|
1087
|
+
return statSync(path).mtimeMs;
|
|
1088
|
+
}
|
|
1089
|
+
catch {
|
|
1090
|
+
return 0;
|
|
1091
|
+
}
|
|
1092
|
+
}
|
|
1093
|
+
/**
|
|
1094
|
+
* 读 `dsh.client.platforms`(载体声明):不写就是 `['web']`——组合包的界面半默认只服务
|
|
1095
|
+
* 浏览器壳。终端壳的插件是 ink 组件,与浏览器那份 `@dsc/ui` 不是同一套值面,所以**要服务
|
|
1096
|
+
* 终端得显式声明**,不能靠猜。
|
|
1097
|
+
* @param raw - `dsh.client.platforms` 的原始值
|
|
1098
|
+
* @returns 载体清单;声明坏了给 null(调用方记一条 problem,当装不上处理)
|
|
1099
|
+
*/
|
|
1100
|
+
function packagePlatformsOf(raw) {
|
|
1101
|
+
if (raw === undefined)
|
|
1102
|
+
return ['web'];
|
|
1103
|
+
if (!Array.isArray(raw))
|
|
1104
|
+
return null;
|
|
1105
|
+
const platforms = raw.filter((value) => value === 'web' || value === 'tui');
|
|
1106
|
+
// 有一个不认识的值就整条拒掉:`['web', 'term']` 里的 term 是多打的字,静默按 web
|
|
1107
|
+
// 处理会让人以为终端也装上了。
|
|
1108
|
+
if (platforms.length !== raw.length || platforms.length === 0)
|
|
1109
|
+
return null;
|
|
1110
|
+
return platforms;
|
|
1111
|
+
}
|
|
1112
|
+
/**
|
|
1113
|
+
* 判一个组合包的界面半边装不装得上:`api` 声明 → 门禁 → 撞名 → 入口存在且在包内。
|
|
1114
|
+
*
|
|
1115
|
+
* 顺序为什么是这一条:先判「这份代码能不能进启动图」,再去看它在不在——撞名与版本
|
|
1116
|
+
* 不满足是**声明**的问题,入口缺失是**文件**的问题,两档的下一步动作不一样。
|
|
1117
|
+
*/
|
|
1118
|
+
function judgePackageClient(name, dir, decl, shellApiVersion, takenIds) {
|
|
1119
|
+
const where = `${name}/client`;
|
|
1120
|
+
const platforms = packagePlatformsOf(decl.platforms);
|
|
1121
|
+
if (platforms === null) {
|
|
1122
|
+
return {
|
|
1123
|
+
platforms: [],
|
|
1124
|
+
clientPath: decl.clientPath,
|
|
1125
|
+
path: null,
|
|
1126
|
+
problem: `${where}: dsh.client.platforms 只能是 'web' / 'tui' 的非空数组(收到 ${JSON.stringify(decl.platforms)})`,
|
|
1127
|
+
problemKind: 'manifest',
|
|
1128
|
+
};
|
|
1129
|
+
}
|
|
1130
|
+
const api = typeof decl.api === 'string' && decl.api.trim() !== '' ? decl.api.trim() : undefined;
|
|
1131
|
+
if (api === undefined) {
|
|
1132
|
+
return {
|
|
1133
|
+
platforms,
|
|
1134
|
+
clientPath: decl.clientPath,
|
|
1135
|
+
path: null,
|
|
1136
|
+
problem: `${where}: dsh.client.api 没写(@dsc/ui 的版本区间,如 "^2.0.0")——组合包的界面半必须声明`,
|
|
1137
|
+
problemKind: 'manifest',
|
|
1138
|
+
};
|
|
1139
|
+
}
|
|
1140
|
+
const gate = evaluateUiApiGate(api, shellApiVersion);
|
|
1141
|
+
if (gate !== null) {
|
|
1142
|
+
return { api, platforms, clientPath: decl.clientPath, path: null, problem: `${name}: ${gate}`, problemKind: 'version' };
|
|
1143
|
+
}
|
|
1144
|
+
if (takenIds.has(name)) {
|
|
1145
|
+
return {
|
|
1146
|
+
api,
|
|
1147
|
+
platforms,
|
|
1148
|
+
clientPath: decl.clientPath,
|
|
1149
|
+
path: null,
|
|
1150
|
+
problem: `${name}: 界面半的 id 与已有插件撞名,这一份跳过`,
|
|
1151
|
+
problemKind: 'clash',
|
|
1152
|
+
};
|
|
1153
|
+
}
|
|
1154
|
+
if (decl.clientPath === null) {
|
|
1155
|
+
return {
|
|
1156
|
+
api,
|
|
1157
|
+
platforms,
|
|
1158
|
+
clientPath: null,
|
|
1159
|
+
path: null,
|
|
1160
|
+
problem: `${where}: package.json 没有 exports["./client"],找不到界面半的入口`,
|
|
1161
|
+
problemKind: 'artifact',
|
|
1162
|
+
};
|
|
1163
|
+
}
|
|
1164
|
+
const path = resolve(dir, decl.clientPath);
|
|
1165
|
+
if (!inside(dir, path)) {
|
|
1166
|
+
return {
|
|
1167
|
+
api,
|
|
1168
|
+
platforms,
|
|
1169
|
+
clientPath: decl.clientPath,
|
|
1170
|
+
path: null,
|
|
1171
|
+
problem: `${where}: exports["./client"] 指到了包外(${decl.clientPath}),拒绝`,
|
|
1172
|
+
problemKind: 'artifact',
|
|
1173
|
+
};
|
|
1174
|
+
}
|
|
1175
|
+
return { api, platforms, clientPath: decl.clientPath, path };
|
|
1176
|
+
}
|
|
1177
|
+
/**
|
|
1178
|
+
* 扫 profile 里装好的组合包,收它们的界面半边。
|
|
1179
|
+
* @param profileDir - profile 目录(没有就返回空)
|
|
1180
|
+
* @param shellApiVersion - 当前壳的 `@dsc/ui` 契约版本
|
|
1181
|
+
* @param takenIds - 已经占用的 id(内置与第三方目录),撞名时让路
|
|
1182
|
+
*/
|
|
1183
|
+
export function discoverPackageUiArtifacts(profileDir, shellApiVersion, takenIds) {
|
|
1184
|
+
const entries = [];
|
|
1185
|
+
const problems = [];
|
|
1186
|
+
const disabled = [];
|
|
1187
|
+
if (profileDir === null)
|
|
1188
|
+
return { entries, problems, disabled };
|
|
1189
|
+
const nodeModules = resolve(profileDir, 'node_modules');
|
|
1190
|
+
let cache = packageCaches.get(profileDir);
|
|
1191
|
+
if (cache === undefined) {
|
|
1192
|
+
cache = new Map();
|
|
1193
|
+
packageCaches.set(profileDir, cache);
|
|
1194
|
+
}
|
|
1195
|
+
const seen = new Set();
|
|
1196
|
+
for (const { name, dir } of packageDirs(nodeModules)) {
|
|
1197
|
+
const decl = readClientDeclarationCached(dir);
|
|
1198
|
+
if (decl === null)
|
|
1199
|
+
continue;
|
|
1200
|
+
if (decl.platform !== 'pneuma') {
|
|
1201
|
+
if (decl.platform === 'web') {
|
|
1202
|
+
// dsh 自己的界面半:只列不加载(插件中心会显示它的能力),这里静默跳过。
|
|
1203
|
+
continue;
|
|
1204
|
+
}
|
|
1205
|
+
problems.push(`${name}: dsh.client.platform 只能是 'pneuma'(收到 ${JSON.stringify(decl.platform)}),界面半跳过`);
|
|
1206
|
+
continue;
|
|
1207
|
+
}
|
|
1208
|
+
const where = `${name}/client`;
|
|
1209
|
+
const judged = judgePackageClient(name, dir, decl, shellApiVersion, new Set([...takenIds, ...seen]));
|
|
1210
|
+
if (judged.problem !== undefined) {
|
|
1211
|
+
problems.push(judged.problem);
|
|
1212
|
+
continue;
|
|
1213
|
+
}
|
|
1214
|
+
const bytes = judged.path === null ? null : readFileSyncSafe(judged.path);
|
|
1215
|
+
if (bytes === null) {
|
|
1216
|
+
problems.push(`${where}: exports["./client"] 指向的 ${judged.clientPath ?? '(没写)'} 读不到`);
|
|
1217
|
+
continue;
|
|
1218
|
+
}
|
|
1219
|
+
// services / phase / inject 与内置产物、第三方同一套词表与校验口径:坏值记一条问题、
|
|
1220
|
+
// 当没声明处理(丢一个依赖等于让插件少等一件事;拼错的 phase 会静默落进 application)。
|
|
1221
|
+
const services = readNameList(decl.services, name, 'dsh.client.services', problems);
|
|
1222
|
+
const rawPhase = decl.phase;
|
|
1223
|
+
const phase = rawPhase === 'early' || rawPhase === 'application' ? rawPhase : undefined;
|
|
1224
|
+
if (rawPhase !== undefined && phase === undefined) {
|
|
1225
|
+
problems.push(`${name}: dsh.client.phase 只能是 'early' / 'application'(${JSON.stringify(rawPhase)}),当没声明处理`);
|
|
1226
|
+
}
|
|
1227
|
+
if (!isPluginEnabled(where)) {
|
|
1228
|
+
disabled.push(name); // 停用不是问题,是用户的开关;但要能报「它被停用了」
|
|
1229
|
+
continue;
|
|
1230
|
+
}
|
|
1231
|
+
// 判定通过时这两项必有值(judgePackageClient 的契约);这里只是把类型收窄。
|
|
1232
|
+
if (judged.api === undefined || judged.path === null)
|
|
1233
|
+
continue;
|
|
1234
|
+
const api = judged.api;
|
|
1235
|
+
const path = judged.path;
|
|
1236
|
+
const rev = contentRev(bytes);
|
|
1237
|
+
const row = {
|
|
1238
|
+
id: name,
|
|
1239
|
+
file: 'client.js',
|
|
1240
|
+
rev,
|
|
1241
|
+
api,
|
|
1242
|
+
origin: 'package',
|
|
1243
|
+
source: name,
|
|
1244
|
+
path,
|
|
1245
|
+
...(Array.isArray(decl.inject)
|
|
1246
|
+
? { inject: decl.inject.filter((value) => typeof value === 'string') }
|
|
1247
|
+
: {}),
|
|
1248
|
+
...(services === undefined ? {} : { services }),
|
|
1249
|
+
...(phase === undefined ? {} : { phase }),
|
|
1250
|
+
...(decl.immediately === true ? { immediately: true } : {}),
|
|
1251
|
+
};
|
|
1252
|
+
// 载体:缺省只服务浏览器壳;声明了 platforms 的每个载体各出一行(同一个 client.js,
|
|
1253
|
+
// 与内置清单「一份产物两条清单行」同一口径,两种壳的 collect 各取各的)。
|
|
1254
|
+
for (const platform of judged.platforms) {
|
|
1255
|
+
entries.push(platform === 'web' ? row : { ...row, platform });
|
|
1256
|
+
}
|
|
1257
|
+
seen.add(name);
|
|
1258
|
+
const cached = cache.get(name);
|
|
1259
|
+
const fingerprint = `${rev}`;
|
|
1260
|
+
if (cached === undefined || cached.fingerprint !== fingerprint) {
|
|
1261
|
+
cache.set(name, {
|
|
1262
|
+
row,
|
|
1263
|
+
bytes,
|
|
1264
|
+
fingerprint,
|
|
1265
|
+
previous: cached === undefined ? null : { rev: cached.row.rev, bytes: cached.bytes },
|
|
1266
|
+
});
|
|
1267
|
+
}
|
|
1268
|
+
}
|
|
1269
|
+
return { entries, problems, disabled };
|
|
1270
|
+
}
|
|
1271
|
+
/**
|
|
1272
|
+
* 组合包界面半边的卡片视图(插件中心「组合包界面」那一组)。
|
|
1273
|
+
*
|
|
1274
|
+
* 与 {@link discoverPackageUiArtifacts} 共用 {@link judgePackageClient} 同一套判定,
|
|
1275
|
+
* 差别只在输出形状:那边只给「能进启动图的条目」,这边给**每一条的状态**——被停用的、
|
|
1276
|
+
* 装不上的也要看得见,不然用户只知道「界面里没有」,不知道该去哪儿拧。
|
|
1277
|
+
*
|
|
1278
|
+
* 信任恒为 true:`numa plugin add` 把包装进 profile 那一步就是同意(见上面的注释)。
|
|
1279
|
+
*/
|
|
1280
|
+
/**
|
|
1281
|
+
* profile 目录 → 给界面看的名字。
|
|
1282
|
+
*
|
|
1283
|
+
* 直接取目录名:`~/.dsc/profiles/work` → `work`。为什么不读 profile 的 package.json 里的
|
|
1284
|
+
* `name`:那个字段用户可以不写,而且写了的也不保证唯一;目录名是 `numa plugin add --profile`
|
|
1285
|
+
* 真正用的那一把钥匙,用户在同一条命令里见过的就是它。
|
|
1286
|
+
*/
|
|
1287
|
+
function profileNameOf(profileDir) {
|
|
1288
|
+
const name = basename(profileDir);
|
|
1289
|
+
return name === '' ? undefined : name;
|
|
1290
|
+
}
|
|
1291
|
+
export function scanPackageUiTrusts(shellApiVersion, takenIds, profileDir = activeProfileDir()) {
|
|
1292
|
+
const out = [];
|
|
1293
|
+
if (profileDir === null)
|
|
1294
|
+
return out;
|
|
1295
|
+
// profile 的名字给界面看「这个包装在哪一层」:装了多个 profile 时,光有包名分不清来源。
|
|
1296
|
+
const profile = profileNameOf(profileDir);
|
|
1297
|
+
const nodeModules = resolve(profileDir, 'node_modules');
|
|
1298
|
+
for (const { name, dir } of packageDirs(nodeModules)) {
|
|
1299
|
+
const decl = readClientDeclarationCached(dir);
|
|
1300
|
+
const key = `${name}/client`;
|
|
1301
|
+
const provenance = {
|
|
1302
|
+
...(decl?.version === undefined ? {} : { version: decl.version }),
|
|
1303
|
+
...(profile === undefined ? {} : { profile }),
|
|
1304
|
+
};
|
|
1305
|
+
if (decl === null)
|
|
1306
|
+
continue;
|
|
1307
|
+
if (decl.platform !== 'pneuma') {
|
|
1308
|
+
if (decl.platform === 'web')
|
|
1309
|
+
continue; // dsh 自己的界面半:另一条体系,不在这张卡上
|
|
1310
|
+
out.push({
|
|
1311
|
+
name,
|
|
1312
|
+
key,
|
|
1313
|
+
origin: 'package',
|
|
1314
|
+
platforms: [],
|
|
1315
|
+
trusted: true,
|
|
1316
|
+
enabled: isPluginEnabled(key),
|
|
1317
|
+
...provenance,
|
|
1318
|
+
problem: `dsh.client.platform 只能是 'pneuma'(收到 ${JSON.stringify(decl.platform)}),界面半不会装载`,
|
|
1319
|
+
problemKind: 'manifest',
|
|
1320
|
+
});
|
|
1321
|
+
continue;
|
|
1322
|
+
}
|
|
1323
|
+
const judged = judgePackageClient(name, dir, decl, shellApiVersion, takenIds);
|
|
1324
|
+
out.push({
|
|
1325
|
+
name,
|
|
1326
|
+
key,
|
|
1327
|
+
origin: 'package',
|
|
1328
|
+
platforms: judged.platforms,
|
|
1329
|
+
trusted: true,
|
|
1330
|
+
enabled: isPluginEnabled(key),
|
|
1331
|
+
...provenance,
|
|
1332
|
+
...(judged.api === undefined ? {} : { api: judged.api }),
|
|
1333
|
+
...(judged.problem === undefined
|
|
1334
|
+
? {}
|
|
1335
|
+
: {
|
|
1336
|
+
problem: judged.problem,
|
|
1337
|
+
...(judged.problemKind === undefined ? {} : { problemKind: judged.problemKind }),
|
|
1338
|
+
}),
|
|
1339
|
+
});
|
|
1340
|
+
}
|
|
1341
|
+
return out;
|
|
1342
|
+
}
|
|
1343
|
+
/**
|
|
1344
|
+
* 这个启停键是不是组合包的界面半边(`<包名>/client`)。
|
|
1345
|
+
*
|
|
1346
|
+
* 与 {@link isThirdPartyUiEntry} 同一个用途:这类键没有宿主半边可热挂,启停写盘即完事,
|
|
1347
|
+
* 生效在页面下一次加载(启动图按 plugins.json 的启停现场合成)。
|
|
1348
|
+
*/
|
|
1349
|
+
export function isPackageUiEntry(file, profileDir = activeProfileDir()) {
|
|
1350
|
+
const suffix = '/client';
|
|
1351
|
+
if (!file.endsWith(suffix))
|
|
1352
|
+
return false;
|
|
1353
|
+
const name = file.slice(0, -suffix.length);
|
|
1354
|
+
if (!PLUGIN_ID.test(name) || profileDir === null)
|
|
1355
|
+
return false;
|
|
1356
|
+
const decl = readClientDeclarationCached(resolve(profileDir, 'node_modules', name));
|
|
1357
|
+
return decl !== null && decl.platform === 'pneuma';
|
|
1358
|
+
}
|
|
1359
|
+
/**
|
|
1360
|
+
* 组合包界面半边的内容寻址查询(与内置/第三方同形,路由按 rev 对字节)。
|
|
1361
|
+
*/
|
|
1362
|
+
export function lookupPackageUiBundle(id, file, rev, profileDir, wantBody = true) {
|
|
1363
|
+
void file;
|
|
1364
|
+
const empty = { known: false, current: false, previous: false, size: null, body: null };
|
|
1365
|
+
if (profileDir === null || !PLUGIN_ID.test(id))
|
|
1366
|
+
return empty;
|
|
1367
|
+
const cached = packageCaches.get(profileDir)?.get(id);
|
|
1368
|
+
if (cached === undefined)
|
|
1369
|
+
return empty;
|
|
1370
|
+
if (cached.row.rev === rev) {
|
|
1371
|
+
return { known: true, current: true, previous: false, size: cached.bytes.length, body: wantBody ? cached.bytes : null };
|
|
1372
|
+
}
|
|
1373
|
+
if (cached.previous !== null && cached.previous.rev === rev) {
|
|
1374
|
+
return {
|
|
1375
|
+
known: true,
|
|
1376
|
+
current: false,
|
|
1377
|
+
previous: true,
|
|
1378
|
+
size: cached.previous.bytes.length,
|
|
1379
|
+
body: wantBody ? cached.previous.bytes : null,
|
|
1380
|
+
};
|
|
1381
|
+
}
|
|
1382
|
+
return { known: true, current: false, previous: false, size: null, body: null };
|
|
1383
|
+
}
|
|
779
1384
|
/**
|
|
780
1385
|
* 一个平台视图下的**全部**界面插件:内置(构建产物清单)+ 第三方(`~/.dsc/plugins/`
|
|
781
|
-
*
|
|
782
|
-
*
|
|
1386
|
+
* 里带界面半边的目录)+ 组合包(profile 里装的、`dsh.client.platform = 'pneuma'` 的包)。
|
|
1387
|
+
* 启动图(web)与终端装载器(tui)都从这一个口子取,谁也不许自己再拼一份——口径分叉
|
|
1388
|
+
* 就是从这里开始的。
|
|
783
1389
|
*/
|
|
784
1390
|
export function collectUiArtifactsForPlatform(platform, options = {}) {
|
|
785
1391
|
const builtin = collectUiPluginArtifacts(options.builtinDir, platform, { force: options.force });
|
|
786
1392
|
const third = discoverThirdPartyUiArtifacts(builtin.apiVersion, new Set(builtin.entries.map((entry) => entry.id)), options.thirdPartyDir);
|
|
1393
|
+
// 组合包的界面半边:只在指定了 profile(或环境里配了)时收。
|
|
1394
|
+
const packageDir = options.packageDir === undefined ? activeProfileDir() : options.packageDir;
|
|
1395
|
+
const taken = new Set([...builtin.entries.map((entry) => entry.id), ...third.entries.map((entry) => entry.id)]);
|
|
1396
|
+
const fromPackages = discoverPackageUiArtifacts(packageDir, builtin.apiVersion, taken);
|
|
787
1397
|
const entries = [
|
|
788
1398
|
...builtin.entries,
|
|
789
1399
|
...third.entries.filter((entry) => (entry.platform ?? 'web') === platform),
|
|
1400
|
+
...fromPackages.entries.filter((entry) => (entry.platform ?? 'web') === platform),
|
|
790
1401
|
];
|
|
791
|
-
const problems = [...builtin.problems, ...third.problems];
|
|
792
|
-
|
|
1402
|
+
const problems = [...builtin.problems, ...third.problems, ...fromPackages.problems];
|
|
1403
|
+
// 被停用的 id 并成一份(同一份清单给装载器报「被停用」用;重复的去一次)。
|
|
1404
|
+
const disabled = [...new Set([...third.disabled, ...fromPackages.disabled])];
|
|
1405
|
+
return {
|
|
1406
|
+
entries,
|
|
1407
|
+
problems,
|
|
1408
|
+
disabled,
|
|
1409
|
+
...(builtin.apiVersion === undefined ? {} : { apiVersion: builtin.apiVersion }),
|
|
1410
|
+
};
|
|
793
1411
|
}
|
|
794
1412
|
/**
|
|
795
1413
|
* 一条产物条目对应的磁盘路径(内置 `<dir>/<id>/<file>`;第三方 `<root>/<id>/ui/client.js`)。
|
|
@@ -798,6 +1416,11 @@ export function collectUiArtifactsForPlatform(platform, options = {}) {
|
|
|
798
1416
|
* 放在这里与发现层同一口径;拼出来的路径同样过 `inside()` 围栏。
|
|
799
1417
|
*/
|
|
800
1418
|
export function uiArtifactFilePath(entry, dirs = {}) {
|
|
1419
|
+
if (entry.origin === 'package') {
|
|
1420
|
+
// 组合包的界面半边:发现时已经把绝对路径算好(入口由包的 exports 决定,不在固定位置)。
|
|
1421
|
+
const path = entry.path;
|
|
1422
|
+
return typeof path === 'string' && path !== '' ? path : null;
|
|
1423
|
+
}
|
|
801
1424
|
if (entry.origin === 'third-party') {
|
|
802
1425
|
const root = dirs.thirdPartyDir ?? thirdPartyUiRoot();
|
|
803
1426
|
if (!PLUGIN_ID.test(entry.id))
|
|
@@ -823,6 +1446,7 @@ export function toUiPluginRows(entries) {
|
|
|
823
1446
|
id: entry.id,
|
|
824
1447
|
rev: entry.rev,
|
|
825
1448
|
...(entry.inject === undefined ? {} : { inject: entry.inject }),
|
|
1449
|
+
...(entry.services === undefined ? {} : { services: entry.services }),
|
|
826
1450
|
...(entry.external === undefined ? {} : { external: entry.external }),
|
|
827
1451
|
...(entry.immediately === true ? { immediately: true } : {}),
|
|
828
1452
|
...(entry.phase === undefined ? {} : { phase: entry.phase }),
|