@deepseek-harness-tui/dsh-tui 0.8.0 → 0.8.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +32 -15
- package/cordis.patch.yml +21 -2
- package/cordis.yml +12 -1
- package/dsh-ecosystem-spec/protocols/profile-definitions.d.ts +13 -0
- package/dsh-ecosystem-spec/protocols/profile-definitions.js +59 -0
- package/dsh-ecosystem-spec/protocols/tui-channel-http.d.ts +15 -0
- package/dsh-ecosystem-spec/protocols/tui-channel-http.js +32 -0
- package/dsh-ecosystem-spec/protocols/tui-channel.d.ts +59 -0
- package/dsh-ecosystem-spec/protocols/tui-channel.js +166 -0
- package/dsh-ecosystem-spec/protocols/tui-contributions.d.ts +42 -0
- package/dsh-ecosystem-spec/protocols/tui-contributions.js +143 -0
- package/dsh-ecosystem-spec/registry/README.md +14 -0
- package/dsh-ecosystem-spec/registry/contracts/decision-events-v1alpha1.json +13 -0
- package/dsh-ecosystem-spec/registry/contracts/scene-v1alpha1.json +13 -0
- package/dsh-ecosystem-spec/registry/contracts/settings-section-v1alpha1.json +13 -0
- package/dsh-ecosystem-spec/registry/contracts/tui-channel-v1alpha1.json +30 -0
- package/dsh-ecosystem-spec/registry/contracts/workspace-provider-v1alpha1.json +6 -0
- package/dsh-ecosystem-spec/registry/host-descriptor.tui.example.json +56 -0
- package/dsh-ecosystem-spec/registry/permissions-0.1.json +13 -0
- package/dsh-ecosystem-spec/registry/registry-0.15.json +149 -0
- package/dsh-ecosystem-spec/schemas/conformance-claim.schema.json +15 -0
- package/dsh-ecosystem-spec/schemas/effect-ledger-record.schema.json +16 -0
- package/dsh-ecosystem-spec/schemas/host-descriptor.schema.json +26 -0
- package/lib/types/cc/figures.d.ts +4 -0
- package/lib/types/cc/figures.d.ts.map +1 -1
- package/lib/types/cc/figures.js +4 -0
- package/lib/types/command-trees.d.ts +2 -1
- package/lib/types/command-trees.d.ts.map +1 -1
- package/lib/types/command-trees.js +1 -1
- package/lib/types/commands.d.ts.map +1 -1
- package/lib/types/commands.js +2 -0
- package/lib/types/components/ExtensionDialog.d.ts +40 -0
- package/lib/types/components/ExtensionDialog.d.ts.map +1 -0
- package/lib/types/components/ExtensionDialog.js +210 -0
- package/lib/types/components/HelpMenu.js +1 -1
- package/lib/types/components/LoadedContextPanel.d.ts +5 -5
- package/lib/types/components/LoadedContextPanel.js +6 -6
- package/lib/types/components/LogoV2.d.ts.map +1 -1
- package/lib/types/components/LogoV2.js +16 -8
- package/lib/types/components/Markdown.d.ts +13 -1
- package/lib/types/components/Markdown.d.ts.map +1 -1
- package/lib/types/components/Markdown.js +15 -1
- package/lib/types/components/MessageList.d.ts +3 -1
- package/lib/types/components/MessageList.d.ts.map +1 -1
- package/lib/types/components/MessageList.js +111 -6
- package/lib/types/components/PromptInput.d.ts.map +1 -1
- package/lib/types/components/PromptInput.js +26 -12
- package/lib/types/components/RewindPicker.d.ts +13 -1
- package/lib/types/components/RewindPicker.d.ts.map +1 -1
- package/lib/types/components/RewindPicker.js +26 -2
- package/lib/types/components/StreamingMarkdown.d.ts +2 -8
- package/lib/types/components/StreamingMarkdown.d.ts.map +1 -1
- package/lib/types/components/StreamingMarkdown.js +51 -9
- package/lib/types/components/ToolUseLoader.d.ts +8 -3
- package/lib/types/components/ToolUseLoader.d.ts.map +1 -1
- package/lib/types/components/ToolUseLoader.js +43 -9
- package/lib/types/components/activityFrames.d.ts +1 -1
- package/lib/types/components/activityFrames.d.ts.map +1 -1
- package/lib/types/components/activityFrames.js +4 -1
- package/lib/types/components/messages/AssistantThinkingMessage.d.ts +5 -1
- package/lib/types/components/messages/AssistantThinkingMessage.d.ts.map +1 -1
- package/lib/types/components/messages/AssistantThinkingMessage.js +26 -3
- package/lib/types/components/messages/AssistantToolUseMessage.d.ts.map +1 -1
- package/lib/types/components/messages/AssistantToolUseMessage.js +13 -2
- package/lib/types/dsh-adapter/channel.d.ts +61 -11
- package/lib/types/dsh-adapter/channel.d.ts.map +1 -1
- package/lib/types/dsh-adapter/channel.js +767 -120
- package/lib/types/dsh-adapter/childStderr.d.ts.map +1 -1
- package/lib/types/dsh-adapter/childStderr.js +10 -0
- package/lib/types/dsh-adapter/command-attribution.d.ts +51 -0
- package/lib/types/dsh-adapter/command-attribution.d.ts.map +1 -0
- package/lib/types/dsh-adapter/command-attribution.js +93 -0
- package/lib/types/dsh-adapter/command-errors.d.ts +42 -0
- package/lib/types/dsh-adapter/command-errors.d.ts.map +1 -0
- package/lib/types/dsh-adapter/command-errors.js +63 -0
- package/lib/types/dsh-adapter/command-trees.d.ts +7 -1
- package/lib/types/dsh-adapter/command-trees.d.ts.map +1 -1
- package/lib/types/dsh-adapter/command-trees.js +70 -20
- package/lib/types/dsh-adapter/component-identity.d.ts +33 -0
- package/lib/types/dsh-adapter/component-identity.d.ts.map +1 -0
- package/lib/types/dsh-adapter/component-identity.js +108 -0
- package/lib/types/dsh-adapter/contract.d.ts +1 -1
- package/lib/types/dsh-adapter/contract.js +2 -2
- package/lib/types/dsh-adapter/decision-guard.d.ts +84 -0
- package/lib/types/dsh-adapter/decision-guard.d.ts.map +1 -0
- package/lib/types/dsh-adapter/decision-guard.js +348 -0
- package/lib/types/dsh-adapter/dialogs.d.ts +145 -0
- package/lib/types/dsh-adapter/dialogs.d.ts.map +1 -0
- package/lib/types/dsh-adapter/dialogs.js +316 -0
- package/lib/types/dsh-adapter/effect-ledger.d.ts +91 -0
- package/lib/types/dsh-adapter/effect-ledger.d.ts.map +1 -0
- package/lib/types/dsh-adapter/effect-ledger.js +251 -0
- package/lib/types/dsh-adapter/extension-events.d.ts +193 -0
- package/lib/types/dsh-adapter/extension-events.d.ts.map +1 -0
- package/lib/types/dsh-adapter/extension-events.js +207 -0
- package/lib/types/dsh-adapter/extensions.d.ts +32 -0
- package/lib/types/dsh-adapter/extensions.d.ts.map +1 -0
- package/lib/types/dsh-adapter/extensions.js +42 -0
- package/lib/types/dsh-adapter/grants.d.ts +25 -0
- package/lib/types/dsh-adapter/grants.d.ts.map +1 -0
- package/lib/types/dsh-adapter/grants.js +213 -0
- package/lib/types/dsh-adapter/host-access.d.ts +37 -0
- package/lib/types/dsh-adapter/host-access.d.ts.map +1 -0
- package/lib/types/dsh-adapter/host-access.js +652 -0
- package/lib/types/dsh-adapter/host-descriptor.d.ts +24 -0
- package/lib/types/dsh-adapter/host-descriptor.d.ts.map +1 -0
- package/lib/types/dsh-adapter/host-descriptor.js +169 -0
- package/lib/types/dsh-adapter/index.d.ts +4 -0
- package/lib/types/dsh-adapter/index.d.ts.map +1 -1
- package/lib/types/dsh-adapter/index.js +1 -0
- package/lib/types/dsh-adapter/message-observer.d.ts +173 -0
- package/lib/types/dsh-adapter/message-observer.d.ts.map +1 -0
- package/lib/types/dsh-adapter/message-observer.js +553 -0
- package/lib/types/dsh-adapter/plugin-host.d.ts +136 -0
- package/lib/types/dsh-adapter/plugin-host.d.ts.map +1 -0
- package/lib/types/dsh-adapter/plugin-host.js +365 -0
- package/lib/types/dsh-adapter/plugin-storage.d.ts +108 -0
- package/lib/types/dsh-adapter/plugin-storage.d.ts.map +1 -0
- package/lib/types/dsh-adapter/plugin-storage.js +397 -0
- package/lib/types/dsh-adapter/plugin.d.ts.map +1 -1
- package/lib/types/dsh-adapter/plugin.js +124 -14
- package/lib/types/dsh-adapter/plugins-info.d.ts +43 -0
- package/lib/types/dsh-adapter/plugins-info.d.ts.map +1 -0
- package/lib/types/dsh-adapter/plugins-info.js +276 -0
- package/lib/types/dsh-adapter/promptDebug.d.ts +0 -6
- package/lib/types/dsh-adapter/promptDebug.d.ts.map +1 -1
- package/lib/types/dsh-adapter/promptDebug.js +13 -4
- package/lib/types/dsh-adapter/renderers.d.ts +57 -0
- package/lib/types/dsh-adapter/renderers.d.ts.map +1 -0
- package/lib/types/dsh-adapter/renderers.js +173 -0
- package/lib/types/dsh-adapter/sanitize.d.ts +36 -0
- package/lib/types/dsh-adapter/sanitize.d.ts.map +1 -0
- package/lib/types/dsh-adapter/sanitize.js +65 -0
- package/lib/types/dsh-adapter/scenes.d.ts +15 -5
- package/lib/types/dsh-adapter/scenes.d.ts.map +1 -1
- package/lib/types/dsh-adapter/scenes.js +149 -35
- package/lib/types/dsh-adapter/settings-sections.d.ts +7 -3
- package/lib/types/dsh-adapter/settings-sections.d.ts.map +1 -1
- package/lib/types/dsh-adapter/settings-sections.js +106 -26
- package/lib/types/dsh-adapter/shortcuts.d.ts +107 -0
- package/lib/types/dsh-adapter/shortcuts.d.ts.map +1 -0
- package/lib/types/dsh-adapter/shortcuts.js +340 -0
- package/lib/types/dsh-adapter/status.d.ts +74 -0
- package/lib/types/dsh-adapter/status.d.ts.map +1 -0
- package/lib/types/dsh-adapter/status.js +234 -0
- package/lib/types/dsh-adapter/workspaces.d.ts +16 -5
- package/lib/types/dsh-adapter/workspaces.d.ts.map +1 -1
- package/lib/types/dsh-adapter/workspaces.js +287 -170
- package/lib/types/extensions.d.ts +13 -0
- package/lib/types/extensions.d.ts.map +1 -0
- package/lib/types/extensions.js +21 -0
- package/lib/types/force-production-react.d.ts +1 -0
- package/lib/types/force-production-react.d.ts.map +1 -0
- package/lib/types/force-production-react.js +12 -0
- package/lib/types/i18n.d.ts +174 -20
- package/lib/types/i18n.d.ts.map +1 -1
- package/lib/types/i18n.js +56 -6
- package/lib/types/index.d.ts +1 -0
- package/lib/types/index.d.ts.map +1 -1
- package/lib/types/index.js +1 -0
- package/lib/types/ink/components/App.d.ts +2 -0
- package/lib/types/ink/components/App.d.ts.map +1 -1
- package/lib/types/ink/components/App.js +4 -0
- package/lib/types/ink/ink.d.ts +31 -3
- package/lib/types/ink/ink.d.ts.map +1 -1
- package/lib/types/ink/ink.js +90 -5
- package/lib/types/ink/log-update.d.ts.map +1 -1
- package/lib/types/ink/log-update.js +225 -56
- package/lib/types/ink/output.d.ts +35 -2
- package/lib/types/ink/output.d.ts.map +1 -1
- package/lib/types/ink/output.js +281 -14
- package/lib/types/ink/render-node-to-output.d.ts.map +1 -1
- package/lib/types/ink/render-node-to-output.js +14 -6
- package/lib/types/ink/screen.d.ts +39 -0
- package/lib/types/ink/screen.d.ts.map +1 -1
- package/lib/types/ink/screen.js +117 -0
- package/lib/types/ink/terminal.d.ts.map +1 -1
- package/lib/types/ink/terminal.js +26 -6
- package/lib/types/ink/wrapAnsi.d.ts +1 -1
- package/lib/types/ink/wrapAnsi.d.ts.map +1 -1
- package/lib/types/ink/wrapAnsi.js +29 -2
- package/lib/types/plugin-host.d.ts +15 -0
- package/lib/types/plugin-host.d.ts.map +1 -0
- package/lib/types/plugin-host.js +17 -0
- package/lib/types/plugin-spec/negotiate.d.ts +11 -0
- package/lib/types/plugin-spec/negotiate.d.ts.map +1 -0
- package/lib/types/plugin-spec/negotiate.js +97 -0
- package/lib/types/plugin-spec/permission-scope.d.ts +32 -0
- package/lib/types/plugin-spec/permission-scope.d.ts.map +1 -0
- package/lib/types/plugin-spec/permission-scope.js +90 -0
- package/lib/types/plugin-spec/registry.d.ts +23 -0
- package/lib/types/plugin-spec/registry.d.ts.map +1 -0
- package/lib/types/plugin-spec/registry.js +252 -0
- package/lib/types/plugin-spec/schema-check.d.ts +17 -0
- package/lib/types/plugin-spec/schema-check.d.ts.map +1 -0
- package/lib/types/plugin-spec/schema-check.js +165 -0
- package/lib/types/plugin-spec/tui-extension.d.ts +16 -0
- package/lib/types/plugin-spec/tui-extension.d.ts.map +1 -0
- package/lib/types/plugin-spec/tui-extension.js +79 -0
- package/lib/types/plugin-spec/types.d.ts +114 -0
- package/lib/types/plugin-spec/types.d.ts.map +1 -0
- package/lib/types/plugin-spec/types.js +10 -0
- package/lib/types/plugin-spec/validate.d.ts +21 -0
- package/lib/types/plugin-spec/validate.d.ts.map +1 -0
- package/lib/types/plugin-spec/validate.js +138 -0
- package/lib/types/scenes.d.ts +2 -1
- package/lib/types/scenes.d.ts.map +1 -1
- package/lib/types/scenes.js +1 -1
- package/lib/types/screens/Chat.d.ts +14 -1
- package/lib/types/screens/Chat.d.ts.map +1 -1
- package/lib/types/screens/Chat.js +173 -49
- package/lib/types/screens/SessionBrowser.d.ts.map +1 -1
- package/lib/types/screens/SessionBrowser.js +10 -3
- package/lib/types/sessions/view.d.ts +3 -2
- package/lib/types/sessions/view.d.ts.map +1 -1
- package/lib/types/sessions/view.js +18 -0
- package/lib/types/settings-sections.d.ts +2 -1
- package/lib/types/settings-sections.d.ts.map +1 -1
- package/lib/types/settings-sections.js +1 -1
- package/lib/types/theme.d.ts +5 -0
- package/lib/types/theme.d.ts.map +1 -1
- package/lib/types/theme.js +15 -0
- package/lib/types/update.d.ts +20 -0
- package/lib/types/update.d.ts.map +1 -1
- package/lib/types/update.js +54 -7
- package/lib/types/utils/execFileNoThrow.d.ts.map +1 -1
- package/lib/types/utils/execFileNoThrow.js +3 -0
- package/lib/types/utils/loaded-context.d.ts +8 -3
- package/lib/types/utils/loaded-context.d.ts.map +1 -1
- package/lib/types/utils/loaded-context.js +39 -3
- package/lib/types/utils/modifiers.d.ts.map +1 -1
- package/lib/types/utils/modifiers.js +3 -2
- package/lib/types/working-activity.d.ts +12 -0
- package/lib/types/working-activity.d.ts.map +1 -1
- package/lib/types/working-activity.js +13 -0
- package/lib/types/workspaces.d.ts +2 -1
- package/lib/types/workspaces.d.ts.map +1 -1
- package/lib/types/workspaces.js +1 -1
- package/node_modules/@dsh-std/command/CHANGELOG.md +8 -0
- package/node_modules/@dsh-std/command/LICENSE +21 -0
- package/node_modules/@dsh-std/command/README.md +26 -0
- package/node_modules/@dsh-std/command/README.zh.md +28 -0
- package/node_modules/@dsh-std/command/lib/index.d.ts +144 -0
- package/node_modules/@dsh-std/command/lib/index.d.ts.map +1 -0
- package/node_modules/@dsh-std/command/lib/index.js +252 -0
- package/node_modules/@dsh-std/command/lib/index.js.map +1 -0
- package/node_modules/@dsh-std/command/package.json +22 -0
- package/node_modules/@dsh-std/connection/CHANGELOG.md +8 -0
- package/node_modules/@dsh-std/connection/LICENSE +21 -0
- package/node_modules/@dsh-std/connection/README.md +42 -0
- package/node_modules/@dsh-std/connection/README.zh.md +42 -0
- package/node_modules/@dsh-std/connection/lib/connection-CdGcSQnu.d.ts +125 -0
- package/node_modules/@dsh-std/connection/lib/connection-CdGcSQnu.d.ts.map +1 -0
- package/node_modules/@dsh-std/connection/lib/index.d.ts +89 -0
- package/node_modules/@dsh-std/connection/lib/index.d.ts.map +1 -0
- package/node_modules/@dsh-std/connection/lib/index.js +158 -0
- package/node_modules/@dsh-std/connection/lib/index.js.map +1 -0
- package/node_modules/@dsh-std/connection/lib/memory.d.ts +24 -0
- package/node_modules/@dsh-std/connection/lib/memory.d.ts.map +1 -0
- package/node_modules/@dsh-std/connection/lib/memory.js +258 -0
- package/node_modules/@dsh-std/connection/lib/memory.js.map +1 -0
- package/node_modules/@dsh-std/connection/lib/resolve-3X6ausgz.js +226 -0
- package/node_modules/@dsh-std/connection/lib/resolve-3X6ausgz.js.map +1 -0
- package/node_modules/@dsh-std/connection/package.json +20 -0
- package/node_modules/@dsh-std/core/CHANGELOG.md +8 -0
- package/node_modules/@dsh-std/core/LICENSE +21 -0
- package/node_modules/@dsh-std/core/README.md +13 -0
- package/node_modules/@dsh-std/core/README.zh.md +13 -0
- package/node_modules/@dsh-std/core/lib/index.d.ts +112 -0
- package/node_modules/@dsh-std/core/lib/index.d.ts.map +1 -0
- package/node_modules/@dsh-std/core/lib/index.js +424 -0
- package/node_modules/@dsh-std/core/lib/index.js.map +1 -0
- package/node_modules/@dsh-std/core/package.json +21 -0
- package/node_modules/@dsh-std/manifest/CHANGELOG.md +9 -0
- package/node_modules/@dsh-std/manifest/LICENSE +21 -0
- package/node_modules/@dsh-std/manifest/README.md +5 -0
- package/node_modules/@dsh-std/manifest/README.zh.md +5 -0
- package/node_modules/@dsh-std/manifest/lib/index.d.ts +182 -0
- package/node_modules/@dsh-std/manifest/lib/index.d.ts.map +1 -0
- package/node_modules/@dsh-std/manifest/lib/index.js +625 -0
- package/node_modules/@dsh-std/manifest/lib/index.js.map +1 -0
- package/node_modules/@dsh-std/manifest/package.json +20 -0
- package/node_modules/@dsh-std/manifest/schema/dsh-plugin-0.15.schema.json +144 -0
- package/node_modules/@dsh-std/messages/CHANGELOG.md +8 -0
- package/node_modules/@dsh-std/messages/LICENSE +21 -0
- package/node_modules/@dsh-std/messages/README.md +5 -0
- package/node_modules/@dsh-std/messages/README.zh.md +7 -0
- package/node_modules/@dsh-std/messages/lib/index.d.ts +50 -0
- package/node_modules/@dsh-std/messages/lib/index.d.ts.map +1 -0
- package/node_modules/@dsh-std/messages/lib/index.js +151 -0
- package/node_modules/@dsh-std/messages/lib/index.js.map +1 -0
- package/node_modules/@dsh-std/messages/package.json +20 -0
- package/node_modules/@dsh-std/messages/schema/message-observer-envelope-0.15.schema.json +54 -0
- package/node_modules/@dsh-std/presentation/CHANGELOG.md +9 -0
- package/node_modules/@dsh-std/presentation/LICENSE +21 -0
- package/node_modules/@dsh-std/presentation/README.md +27 -0
- package/node_modules/@dsh-std/presentation/README.zh.md +29 -0
- package/node_modules/@dsh-std/presentation/lib/callback.d.ts +2 -0
- package/node_modules/@dsh-std/presentation/lib/callback.js +179 -0
- package/node_modules/@dsh-std/presentation/lib/callback.js.map +1 -0
- package/node_modules/@dsh-std/presentation/lib/index.d.ts +262 -0
- package/node_modules/@dsh-std/presentation/lib/index.d.ts.map +1 -0
- package/node_modules/@dsh-std/presentation/lib/index.js +550 -0
- package/node_modules/@dsh-std/presentation/lib/index.js.map +1 -0
- package/node_modules/@dsh-std/presentation/lib/interaction.d.ts +2 -0
- package/node_modules/@dsh-std/presentation/lib/interaction.js +2 -0
- package/node_modules/@dsh-std/presentation/lib/operations.d.ts +2 -0
- package/node_modules/@dsh-std/presentation/lib/operations.js +2 -0
- package/node_modules/@dsh-std/presentation/package.json +25 -0
- package/node_modules/@dsh-std/storage/CHANGELOG.md +8 -0
- package/node_modules/@dsh-std/storage/LICENSE +21 -0
- package/node_modules/@dsh-std/storage/README.md +5 -0
- package/node_modules/@dsh-std/storage/README.zh.md +7 -0
- package/node_modules/@dsh-std/storage/lib/index.d.ts +48 -0
- package/node_modules/@dsh-std/storage/lib/index.d.ts.map +1 -0
- package/node_modules/@dsh-std/storage/lib/index.js +104 -0
- package/node_modules/@dsh-std/storage/lib/index.js.map +1 -0
- package/node_modules/@dsh-std/storage/package.json +20 -0
- package/node_modules/@dsh-std/storage/schema/local-storage-0.15.schema.json +56 -0
- package/package.json +110 -70
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/connection/CHANGELOG.md +8 -0
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/connection/LICENSE +21 -0
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/connection/README.md +42 -0
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/connection/README.zh.md +42 -0
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/connection/lib/connection-CdGcSQnu.d.ts +125 -0
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/connection/lib/connection-CdGcSQnu.d.ts.map +1 -0
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/connection/lib/index.d.ts +89 -0
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/connection/lib/index.d.ts.map +1 -0
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/connection/lib/index.js +158 -0
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/connection/lib/index.js.map +1 -0
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/connection/lib/memory.d.ts +24 -0
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/connection/lib/memory.d.ts.map +1 -0
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/connection/lib/memory.js +258 -0
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/connection/lib/memory.js.map +1 -0
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/connection/lib/resolve-3X6ausgz.js +226 -0
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/connection/lib/resolve-3X6ausgz.js.map +1 -0
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/connection/package.json +20 -0
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/core/CHANGELOG.md +8 -0
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/core/LICENSE +21 -0
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/core/README.md +13 -0
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/core/README.zh.md +13 -0
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/core/lib/index.d.ts +112 -0
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/core/lib/index.d.ts.map +1 -0
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/core/lib/index.js +424 -0
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/core/lib/index.js.map +1 -0
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/core/package.json +21 -0
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/manifest/CHANGELOG.md +9 -0
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/manifest/LICENSE +21 -0
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/manifest/README.md +5 -0
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/manifest/README.zh.md +5 -0
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/manifest/lib/index.d.ts +182 -0
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/manifest/lib/index.d.ts.map +1 -0
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/manifest/lib/index.js +625 -0
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/manifest/lib/index.js.map +1 -0
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/manifest/package.json +20 -0
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/manifest/schema/dsh-plugin-0.15.schema.json +144 -0
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/presentation/CHANGELOG.md +9 -0
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/presentation/LICENSE +21 -0
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/presentation/README.md +27 -0
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/presentation/README.zh.md +29 -0
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/presentation/lib/callback.d.ts +2 -0
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/presentation/lib/callback.js +179 -0
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/presentation/lib/callback.js.map +1 -0
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/presentation/lib/index.d.ts +262 -0
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/presentation/lib/index.d.ts.map +1 -0
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/presentation/lib/index.js +550 -0
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/presentation/lib/index.js.map +1 -0
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/presentation/lib/interaction.d.ts +2 -0
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/presentation/lib/interaction.js +2 -0
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/presentation/lib/operations.d.ts +2 -0
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/presentation/lib/operations.js +2 -0
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/presentation/package.json +25 -0
- package/vendor/dsh-std/packages/connection/node_modules/@dsh-std/core/CHANGELOG.md +8 -0
- package/vendor/dsh-std/packages/connection/node_modules/@dsh-std/core/LICENSE +21 -0
- package/vendor/dsh-std/packages/connection/node_modules/@dsh-std/core/README.md +13 -0
- package/vendor/dsh-std/packages/connection/node_modules/@dsh-std/core/README.zh.md +13 -0
- package/vendor/dsh-std/packages/connection/node_modules/@dsh-std/core/lib/index.d.ts +112 -0
- package/vendor/dsh-std/packages/connection/node_modules/@dsh-std/core/lib/index.d.ts.map +1 -0
- package/vendor/dsh-std/packages/connection/node_modules/@dsh-std/core/lib/index.js +424 -0
- package/vendor/dsh-std/packages/connection/node_modules/@dsh-std/core/lib/index.js.map +1 -0
- package/vendor/dsh-std/packages/connection/node_modules/@dsh-std/core/package.json +21 -0
- package/vendor/dsh-std/packages/manifest/node_modules/@dsh-std/core/CHANGELOG.md +8 -0
- package/vendor/dsh-std/packages/manifest/node_modules/@dsh-std/core/LICENSE +21 -0
- package/vendor/dsh-std/packages/manifest/node_modules/@dsh-std/core/README.md +13 -0
- package/vendor/dsh-std/packages/manifest/node_modules/@dsh-std/core/README.zh.md +13 -0
- package/vendor/dsh-std/packages/manifest/node_modules/@dsh-std/core/lib/index.d.ts +112 -0
- package/vendor/dsh-std/packages/manifest/node_modules/@dsh-std/core/lib/index.d.ts.map +1 -0
- package/vendor/dsh-std/packages/manifest/node_modules/@dsh-std/core/lib/index.js +424 -0
- package/vendor/dsh-std/packages/manifest/node_modules/@dsh-std/core/lib/index.js.map +1 -0
- package/vendor/dsh-std/packages/manifest/node_modules/@dsh-std/core/package.json +21 -0
- package/vendor/dsh-std/packages/messages/node_modules/@dsh-std/core/CHANGELOG.md +8 -0
- package/vendor/dsh-std/packages/messages/node_modules/@dsh-std/core/LICENSE +21 -0
- package/vendor/dsh-std/packages/messages/node_modules/@dsh-std/core/README.md +13 -0
- package/vendor/dsh-std/packages/messages/node_modules/@dsh-std/core/README.zh.md +13 -0
- package/vendor/dsh-std/packages/messages/node_modules/@dsh-std/core/lib/index.d.ts +112 -0
- package/vendor/dsh-std/packages/messages/node_modules/@dsh-std/core/lib/index.d.ts.map +1 -0
- package/vendor/dsh-std/packages/messages/node_modules/@dsh-std/core/lib/index.js +424 -0
- package/vendor/dsh-std/packages/messages/node_modules/@dsh-std/core/lib/index.js.map +1 -0
- package/vendor/dsh-std/packages/messages/node_modules/@dsh-std/core/package.json +21 -0
- package/vendor/dsh-std/packages/presentation/node_modules/@dsh-std/connection/CHANGELOG.md +8 -0
- package/vendor/dsh-std/packages/presentation/node_modules/@dsh-std/connection/LICENSE +21 -0
- package/vendor/dsh-std/packages/presentation/node_modules/@dsh-std/connection/README.md +42 -0
- package/vendor/dsh-std/packages/presentation/node_modules/@dsh-std/connection/README.zh.md +42 -0
- package/vendor/dsh-std/packages/presentation/node_modules/@dsh-std/connection/lib/connection-CdGcSQnu.d.ts +125 -0
- package/vendor/dsh-std/packages/presentation/node_modules/@dsh-std/connection/lib/connection-CdGcSQnu.d.ts.map +1 -0
- package/vendor/dsh-std/packages/presentation/node_modules/@dsh-std/connection/lib/index.d.ts +89 -0
- package/vendor/dsh-std/packages/presentation/node_modules/@dsh-std/connection/lib/index.d.ts.map +1 -0
- package/vendor/dsh-std/packages/presentation/node_modules/@dsh-std/connection/lib/index.js +158 -0
- package/vendor/dsh-std/packages/presentation/node_modules/@dsh-std/connection/lib/index.js.map +1 -0
- package/vendor/dsh-std/packages/presentation/node_modules/@dsh-std/connection/lib/memory.d.ts +24 -0
- package/vendor/dsh-std/packages/presentation/node_modules/@dsh-std/connection/lib/memory.d.ts.map +1 -0
- package/vendor/dsh-std/packages/presentation/node_modules/@dsh-std/connection/lib/memory.js +258 -0
- package/vendor/dsh-std/packages/presentation/node_modules/@dsh-std/connection/lib/memory.js.map +1 -0
- package/vendor/dsh-std/packages/presentation/node_modules/@dsh-std/connection/lib/resolve-3X6ausgz.js +226 -0
- package/vendor/dsh-std/packages/presentation/node_modules/@dsh-std/connection/lib/resolve-3X6ausgz.js.map +1 -0
- package/vendor/dsh-std/packages/presentation/node_modules/@dsh-std/connection/package.json +20 -0
- package/vendor/dsh-std/packages/presentation/node_modules/@dsh-std/core/CHANGELOG.md +8 -0
- package/vendor/dsh-std/packages/presentation/node_modules/@dsh-std/core/LICENSE +21 -0
- package/vendor/dsh-std/packages/presentation/node_modules/@dsh-std/core/README.md +13 -0
- package/vendor/dsh-std/packages/presentation/node_modules/@dsh-std/core/README.zh.md +13 -0
- package/vendor/dsh-std/packages/presentation/node_modules/@dsh-std/core/lib/index.d.ts +112 -0
- package/vendor/dsh-std/packages/presentation/node_modules/@dsh-std/core/lib/index.d.ts.map +1 -0
- package/vendor/dsh-std/packages/presentation/node_modules/@dsh-std/core/lib/index.js +424 -0
- package/vendor/dsh-std/packages/presentation/node_modules/@dsh-std/core/lib/index.js.map +1 -0
- package/vendor/dsh-std/packages/presentation/node_modules/@dsh-std/core/package.json +21 -0
- package/vendor/dsh-std/packages/storage/node_modules/@dsh-std/core/CHANGELOG.md +8 -0
- package/vendor/dsh-std/packages/storage/node_modules/@dsh-std/core/LICENSE +21 -0
- package/vendor/dsh-std/packages/storage/node_modules/@dsh-std/core/README.md +13 -0
- package/vendor/dsh-std/packages/storage/node_modules/@dsh-std/core/README.zh.md +13 -0
- package/vendor/dsh-std/packages/storage/node_modules/@dsh-std/core/lib/index.d.ts +112 -0
- package/vendor/dsh-std/packages/storage/node_modules/@dsh-std/core/lib/index.d.ts.map +1 -0
- package/vendor/dsh-std/packages/storage/node_modules/@dsh-std/core/lib/index.js +424 -0
- package/vendor/dsh-std/packages/storage/node_modules/@dsh-std/core/lib/index.js.map +1 -0
- package/vendor/dsh-std/packages/storage/node_modules/@dsh-std/core/package.json +21 -0
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@dsh-std/connection",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"license": "MIT",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "lib/index.js",
|
|
7
|
+
"types": "lib/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": { "types": "./lib/index.d.ts", "default": "./lib/index.js" },
|
|
10
|
+
"./memory": { "types": "./lib/memory.d.ts", "default": "./lib/memory.js" }
|
|
11
|
+
},
|
|
12
|
+
"files": ["lib", "CHANGELOG.md"],
|
|
13
|
+
"scripts": {
|
|
14
|
+
"build": "pnpm run typecheck && tsdown",
|
|
15
|
+
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
16
|
+
"test": "vitest run"
|
|
17
|
+
},
|
|
18
|
+
"dependencies": { "@dsh-std/core": "workspace:*" },
|
|
19
|
+
"engines": { "node": "^22.19 || >=24" }
|
|
20
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
Changes to `@dsh-std/core` are recorded here.
|
|
4
|
+
|
|
5
|
+
## 0.1.0 (draft)
|
|
6
|
+
|
|
7
|
+
- Defined protocol coordinates, participant declarations, definition catalogs, and negotiation reports.
|
|
8
|
+
- Separated evaluator knowledge, requirements, potential support, and live support.
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 DSH Standard contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# @dsh-std/core
|
|
2
|
+
|
|
3
|
+
English | [中文](README.zh.md)
|
|
4
|
+
|
|
5
|
+
The minimal meta-protocol for protocol declarations, definition registration, and negotiation. See the [Core Meta-protocol proposal](../../docs/proposals/core.zh.md).
|
|
6
|
+
|
|
7
|
+
Core understands only `apiVersion`, `kind`, participants, requirements, supports, protocol definitions, and their agreements. It does not prescribe resources, capabilities, providers, execution planes, locality, endpoints, or plugin lifecycle.
|
|
8
|
+
|
|
9
|
+
A `ProtocolCatalog` belongs to an evaluator. Each protocol definition explicitly lists accepted API versions, validates requirement/support `spec` values, and owns its negotiation logic. Core neither infers compatibility from a shared major version nor treats an installed definition as a live implementation.
|
|
10
|
+
|
|
11
|
+
`defineProtocolDeclaration()` validates and freezes the requirements and supports currently published by one participant. Static component bounds belong to `@dsh-std/manifest`, selection to `@dsh-std/composition`, activation and the publication barrier to `@dsh-std/lifecycle`, and cross-endpoint offers to `@dsh-std/connection`.
|
|
12
|
+
|
|
13
|
+
Provider selection, multi-party merging, catalogs, invocation bindings, and UI semantics remain owned by their protocol definitions or domain packages.
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# @dsh-std/core
|
|
2
|
+
|
|
3
|
+
[English](README.md) | 中文
|
|
4
|
+
|
|
5
|
+
协议声明、definition 注册与协商的最小元协议。设计见 [Core Meta-protocol](../../docs/proposals/core.zh.md)。
|
|
6
|
+
|
|
7
|
+
Core 只认识 `apiVersion`、`kind`、participant、requirement、support、协议 definition 及其 agreement。它不预设 resource、capability、provider、execution plane、locality、endpoint 或插件生命周期。
|
|
8
|
+
|
|
9
|
+
`ProtocolCatalog` 由评估器持有。每个协议 definition 明确列出接受的 API 版本,分别校验 requirement/support 的 `spec`,并拥有自己的协商逻辑。Core 不会从相同主版本推断兼容性,也不会把安装了一份 definition 当作已有 live implementation。
|
|
10
|
+
|
|
11
|
+
`defineProtocolDeclaration()` 校验并冻结一个 participant 当前实际发布的 requirements 与 supports。静态组件上限属于 `@dsh-std/manifest`,选择属于 `@dsh-std/composition`,激活与 publication barrier 属于 `@dsh-std/lifecycle`,跨端点 offer 属于 `@dsh-std/connection`。
|
|
12
|
+
|
|
13
|
+
协议专属的 provider 选择、多项合并、目录、调用绑定和 UI 语义均由相应 definition 或独立协议包定义。
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
//#region src/protocol.d.ts
|
|
2
|
+
/** Domain-neutral protocol identities and live participant declarations. */
|
|
3
|
+
interface ApiReference {
|
|
4
|
+
readonly apiVersion: string;
|
|
5
|
+
readonly kind: string;
|
|
6
|
+
}
|
|
7
|
+
interface ParticipantIdentity {
|
|
8
|
+
/** Unique within the negotiation scope that carries this declaration. */
|
|
9
|
+
readonly id: string;
|
|
10
|
+
}
|
|
11
|
+
interface ProtocolRequirement<Spec = unknown> extends ApiReference {
|
|
12
|
+
readonly optional?: boolean;
|
|
13
|
+
readonly spec?: Spec;
|
|
14
|
+
}
|
|
15
|
+
interface ProtocolSupport<Spec = unknown> extends ApiReference {
|
|
16
|
+
readonly spec?: Spec;
|
|
17
|
+
}
|
|
18
|
+
interface ProtocolDeclaration {
|
|
19
|
+
readonly participant: ParticipantIdentity;
|
|
20
|
+
readonly requires?: readonly ProtocolRequirement[];
|
|
21
|
+
readonly supports?: readonly ProtocolSupport[];
|
|
22
|
+
}
|
|
23
|
+
interface ParsedApiVersion {
|
|
24
|
+
readonly group: string;
|
|
25
|
+
readonly major: number;
|
|
26
|
+
readonly stability: 'alpha' | 'beta' | 'stable';
|
|
27
|
+
readonly revision: number;
|
|
28
|
+
}
|
|
29
|
+
declare function protocolKey(reference: ApiReference): string;
|
|
30
|
+
/** A grouping key only. It does not claim that versions in the family interoperate. */
|
|
31
|
+
declare function protocolFamilyKey(reference: ApiReference): string;
|
|
32
|
+
declare function sameProtocol(left: ApiReference, right: ApiReference): boolean;
|
|
33
|
+
declare function parseApiVersion(value: string): ParsedApiVersion;
|
|
34
|
+
declare function validateApiReference(value: unknown, label?: string): asserts value is ApiReference;
|
|
35
|
+
declare function validateProtocolDeclaration(value: unknown): asserts value is ProtocolDeclaration;
|
|
36
|
+
declare function defineProtocolDeclaration<const T extends ProtocolDeclaration>(declaration: T): T;
|
|
37
|
+
//#endregion
|
|
38
|
+
//#region src/negotiation.d.ts
|
|
39
|
+
interface EvaluatorIdentity {
|
|
40
|
+
readonly name: string;
|
|
41
|
+
readonly version: string;
|
|
42
|
+
}
|
|
43
|
+
interface ProtocolRequirementEntry<Spec = unknown> {
|
|
44
|
+
readonly participant: string;
|
|
45
|
+
readonly requirement: ProtocolRequirement<Spec>;
|
|
46
|
+
}
|
|
47
|
+
interface ProtocolSupportEntry<Spec = unknown> {
|
|
48
|
+
readonly participant: string;
|
|
49
|
+
readonly support: ProtocolSupport<Spec>;
|
|
50
|
+
}
|
|
51
|
+
interface ProtocolIssue {
|
|
52
|
+
readonly code: string;
|
|
53
|
+
readonly severity: 'error' | 'warning';
|
|
54
|
+
readonly participant?: string;
|
|
55
|
+
readonly path?: string;
|
|
56
|
+
readonly message: string;
|
|
57
|
+
}
|
|
58
|
+
interface ProtocolNegotiationInput<RequirementSpec = unknown, SupportSpec = unknown, Policy = unknown> {
|
|
59
|
+
readonly requirements: readonly ProtocolRequirementEntry<RequirementSpec>[];
|
|
60
|
+
readonly supports: readonly ProtocolSupportEntry<SupportSpec>[];
|
|
61
|
+
readonly policy?: Policy;
|
|
62
|
+
}
|
|
63
|
+
interface ProtocolNegotiationOutcome<Agreement = unknown> {
|
|
64
|
+
readonly agreement?: Agreement;
|
|
65
|
+
readonly issues?: readonly ProtocolIssue[];
|
|
66
|
+
}
|
|
67
|
+
interface ProtocolDefinition<RequirementSpec = unknown, SupportSpec = unknown, Agreement = unknown, Policy = unknown> extends ApiReference {
|
|
68
|
+
/** Every accepted wire/static API version. No compatibility is inferred by core. */
|
|
69
|
+
readonly accepts?: readonly string[];
|
|
70
|
+
validateRequirement(spec: unknown): RequirementSpec;
|
|
71
|
+
validateSupport(spec: unknown): SupportSpec;
|
|
72
|
+
negotiate(input: ProtocolNegotiationInput<RequirementSpec, SupportSpec, Policy>): ProtocolNegotiationOutcome<Agreement>;
|
|
73
|
+
}
|
|
74
|
+
interface NegotiatedProtocol<Agreement = unknown> extends ApiReference {
|
|
75
|
+
readonly participants: readonly string[];
|
|
76
|
+
readonly agreement?: Agreement;
|
|
77
|
+
readonly issues: readonly ProtocolIssue[];
|
|
78
|
+
}
|
|
79
|
+
interface NegotiationReport {
|
|
80
|
+
readonly apiVersion: 'core.dsh/report/v1alpha1';
|
|
81
|
+
readonly evaluator: EvaluatorIdentity;
|
|
82
|
+
readonly compatible: boolean;
|
|
83
|
+
readonly protocols: readonly NegotiatedProtocol[];
|
|
84
|
+
readonly issues: readonly ProtocolIssue[];
|
|
85
|
+
}
|
|
86
|
+
declare class ProtocolCatalog {
|
|
87
|
+
readonly evaluator: EvaluatorIdentity;
|
|
88
|
+
private readonly definitions;
|
|
89
|
+
constructor(evaluator: EvaluatorIdentity);
|
|
90
|
+
register(definition: ProtocolDefinition): () => void;
|
|
91
|
+
list(): readonly ProtocolDefinition[];
|
|
92
|
+
resolve(reference: ApiReference): ProtocolDefinition | undefined;
|
|
93
|
+
understands(reference: ApiReference): boolean;
|
|
94
|
+
negotiate(declarations: readonly ProtocolDeclaration[], policy?: unknown): NegotiationReport;
|
|
95
|
+
}
|
|
96
|
+
//#endregion
|
|
97
|
+
//#region src/version.d.ts
|
|
98
|
+
interface SemanticVersion {
|
|
99
|
+
readonly major: number;
|
|
100
|
+
readonly minor: number;
|
|
101
|
+
readonly patch: number;
|
|
102
|
+
readonly prerelease: readonly (string | number)[];
|
|
103
|
+
readonly build: readonly string[];
|
|
104
|
+
}
|
|
105
|
+
type VersionRange = string | readonly string[];
|
|
106
|
+
declare function parseSemanticVersion(value: string): SemanticVersion;
|
|
107
|
+
declare function compareSemanticVersions(leftValue: string | SemanticVersion, rightValue: string | SemanticVersion): number;
|
|
108
|
+
declare function assertVersionRange(range: VersionRange): void;
|
|
109
|
+
declare function satisfiesVersionRange(versionValue: string, range: VersionRange): boolean;
|
|
110
|
+
//#endregion
|
|
111
|
+
export { ApiReference, EvaluatorIdentity, NegotiatedProtocol, NegotiationReport, ParsedApiVersion, ParticipantIdentity, ProtocolCatalog, ProtocolDeclaration, ProtocolDefinition, ProtocolIssue, ProtocolNegotiationInput, ProtocolNegotiationOutcome, ProtocolRequirement, ProtocolRequirementEntry, ProtocolSupport, ProtocolSupportEntry, SemanticVersion, VersionRange, assertVersionRange, compareSemanticVersions, defineProtocolDeclaration, parseApiVersion, parseSemanticVersion, protocolFamilyKey, protocolKey, sameProtocol, satisfiesVersionRange, validateApiReference, validateProtocolDeclaration };
|
|
112
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/protocol.ts","../src/negotiation.ts","../src/version.ts"],"mappings":";;UAEiB;WACN;WACA;;UAGM;;WAEN;;UAGM,oBAAoB,wBAAwB;WAClD;WACA,OAAO;;UAGD,gBAAgB,wBAAwB;WAC9C,OAAO;;UAGD;WACN,aAAa;WACb,oBAAoB;WACpB,oBAAoB;;UAGd;WACN;WACA;WACA;WACA;;iBAGK,YAAY,WAAW;;iBAKvB,kBAAkB,WAAW;iBAK7B,aAAa,MAAM,cAAc,OAAO;iBAIxC,gBAAgB,gBAAgB;iBAWhC,qBAAqB,gBAAgB,yBAAuC,SAAS;iBASrF,4BAA4B,yBAAyB,SAAS;iBAU9D,gCAAgC,UAAU,qBAAqB,aAAa,IAAI;;;UCpE/E;WACN;WACA;;UAGM,yBAAyB;WAC/B;WACA,aAAa,oBAAoB;;UAG3B,qBAAqB;WAC3B;WACA,SAAS,gBAAgB;;UAGnB;WACN;WACA;WACA;WACA;WACA;;UAGM,yBAAyB,2BAA2B,uBAAuB;WACjF,uBAAuB,yBAAyB;WAChD,mBAAmB,qBAAqB;WACxC,SAAS;;UAGH,2BAA2B;WACjC,YAAY;WACZ,kBAAkB;;UAGZ,mBAAmB,2BAA2B,uBAAuB,qBAAqB,0BACjG;;WAEC;EACT,oBAAoB,gBAAgB;EACpC,gBAAgB,gBAAgB;EAChC,UACE,OAAO,yBAAyB,iBAAiB,aAAa,UAC7D,2BAA2B;;UAGf,mBAAmB,6BAA6B;WACtD;WACA,YAAY;WACZ,iBAAiB;;UAGX;WACN;WACA,WAAW;WACX;WACA,oBAAoB;WACpB,iBAAiB;;cAQf;WAGU,WAAW;mBAFf;EAEI,YAAA,WAAW;EAKhC,SAAS,YAAY;EAmBrB,iBAAiB;EAIjB,QAAQ,WAAW,eAAe;EAKlC,YAAY,WAAW;EAIvB,UAAU,uBAAuB,uBAAuB,mBAAmB;;;;UClH5D;WACN;WACA;WACA;WACA;WACA;;KAGC;iBAEI,qBAAqB,gBAAgB;iBAerC,wBAAwB,oBAAoB,iBAAiB,qBAAqB;iBASlF,mBAAmB,OAAO;iBAI1B,sBAAsB,sBAAsB,OAAO"}
|
|
@@ -0,0 +1,424 @@
|
|
|
1
|
+
//#region src/protocol.ts
|
|
2
|
+
function protocolKey(reference) {
|
|
3
|
+
return `${reference.apiVersion}\0${reference.kind}`;
|
|
4
|
+
}
|
|
5
|
+
/** A grouping key only. It does not claim that versions in the family interoperate. */
|
|
6
|
+
function protocolFamilyKey(reference) {
|
|
7
|
+
const version = parseApiVersion(reference.apiVersion);
|
|
8
|
+
return `${version.group}/v${version.major}\0${reference.kind}`;
|
|
9
|
+
}
|
|
10
|
+
function sameProtocol(left, right) {
|
|
11
|
+
return left.apiVersion === right.apiVersion && left.kind === right.kind;
|
|
12
|
+
}
|
|
13
|
+
function parseApiVersion(value) {
|
|
14
|
+
const match = /^([a-z][a-z0-9.-]*)\/v([1-9][0-9]*)(?:(alpha|beta)([1-9][0-9]*))?$/u.exec(value);
|
|
15
|
+
if (match === null) throw new TypeError(`invalid apiVersion ${JSON.stringify(value)}`);
|
|
16
|
+
return Object.freeze({
|
|
17
|
+
group: match[1],
|
|
18
|
+
major: Number(match[2]),
|
|
19
|
+
stability: match[3] ?? "stable",
|
|
20
|
+
revision: match[4] === void 0 ? 0 : Number(match[4])
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
function validateApiReference(value, label = "protocol reference") {
|
|
24
|
+
if (!record(value)) throw new TypeError(`${label} must be an object`);
|
|
25
|
+
if (typeof value.apiVersion !== "string") throw new TypeError(`${label}.apiVersion must be a string`);
|
|
26
|
+
parseApiVersion(value.apiVersion);
|
|
27
|
+
if (typeof value.kind !== "string" || !/^[A-Z][A-Za-z0-9]*$/u.test(value.kind)) throw new TypeError(`${label}.kind is invalid`);
|
|
28
|
+
}
|
|
29
|
+
function validateProtocolDeclaration(value) {
|
|
30
|
+
if (!record(value)) throw new TypeError("protocol declaration must be an object");
|
|
31
|
+
exact(value, [
|
|
32
|
+
"participant",
|
|
33
|
+
"requires",
|
|
34
|
+
"supports"
|
|
35
|
+
], "protocol declaration");
|
|
36
|
+
if (!record(value.participant)) throw new TypeError("protocol declaration participant must be an object");
|
|
37
|
+
exact(value.participant, ["id"], "participant identity");
|
|
38
|
+
nonEmpty$1(value.participant.id, "participant identity.id");
|
|
39
|
+
validateRows(value.requires, true);
|
|
40
|
+
validateRows(value.supports, false);
|
|
41
|
+
}
|
|
42
|
+
function defineProtocolDeclaration(declaration) {
|
|
43
|
+
validateProtocolDeclaration(declaration);
|
|
44
|
+
return deepFreeze(structuredClone(declaration));
|
|
45
|
+
}
|
|
46
|
+
function validateRows(value, requirement) {
|
|
47
|
+
if (value === void 0) return;
|
|
48
|
+
const label = requirement ? "protocol requirements" : "protocol supports";
|
|
49
|
+
if (!Array.isArray(value)) throw new TypeError(`${label} must be an array`);
|
|
50
|
+
const seen = /* @__PURE__ */ new Set();
|
|
51
|
+
for (const [index, rowValue] of value.entries()) {
|
|
52
|
+
const rowLabel = `${label}[${index}]`;
|
|
53
|
+
validateApiReference(rowValue, rowLabel);
|
|
54
|
+
const row = rowValue;
|
|
55
|
+
exact(row, requirement ? [
|
|
56
|
+
"apiVersion",
|
|
57
|
+
"kind",
|
|
58
|
+
"optional",
|
|
59
|
+
"spec"
|
|
60
|
+
] : [
|
|
61
|
+
"apiVersion",
|
|
62
|
+
"kind",
|
|
63
|
+
"spec"
|
|
64
|
+
], rowLabel);
|
|
65
|
+
if (requirement && row.optional !== void 0 && typeof row.optional !== "boolean") throw new TypeError(`${rowLabel}.optional must be boolean`);
|
|
66
|
+
const key = protocolKey(row);
|
|
67
|
+
if (seen.has(key)) throw new TypeError(`${label} contains duplicate ${JSON.stringify(key)}`);
|
|
68
|
+
seen.add(key);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
function nonEmpty$1(value, label) {
|
|
72
|
+
if (typeof value !== "string" || value.trim() === "") throw new TypeError(`${label} must be a non-empty string`);
|
|
73
|
+
}
|
|
74
|
+
function record(value) {
|
|
75
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
76
|
+
}
|
|
77
|
+
function exact(value, allowed, label) {
|
|
78
|
+
const unknown = Object.keys(value).filter((key) => !allowed.includes(key) && !key.startsWith("x-"));
|
|
79
|
+
if (unknown.length > 0) throw new TypeError(`${label} contains unknown field ${JSON.stringify(unknown[0])}`);
|
|
80
|
+
}
|
|
81
|
+
function deepFreeze(value) {
|
|
82
|
+
if (typeof value !== "object" || value === null || Object.isFrozen(value)) return value;
|
|
83
|
+
Object.freeze(value);
|
|
84
|
+
for (const child of Object.values(value)) deepFreeze(child);
|
|
85
|
+
return value;
|
|
86
|
+
}
|
|
87
|
+
//#endregion
|
|
88
|
+
//#region src/negotiation.ts
|
|
89
|
+
var ProtocolCatalog = class {
|
|
90
|
+
evaluator;
|
|
91
|
+
definitions = /* @__PURE__ */ new Map();
|
|
92
|
+
constructor(evaluator) {
|
|
93
|
+
this.evaluator = evaluator;
|
|
94
|
+
nonEmpty(evaluator.name, "evaluator.name");
|
|
95
|
+
nonEmpty(evaluator.version, "evaluator.version");
|
|
96
|
+
}
|
|
97
|
+
register(definition) {
|
|
98
|
+
validateDefinition(definition);
|
|
99
|
+
const accepted = /* @__PURE__ */ new Set([definition.apiVersion, ...definition.accepts ?? []]);
|
|
100
|
+
for (const version of accepted) {
|
|
101
|
+
const key = protocolKey({
|
|
102
|
+
apiVersion: version,
|
|
103
|
+
kind: definition.kind
|
|
104
|
+
});
|
|
105
|
+
if (this.definitions.has(key)) throw new Error(`protocol definition for ${version} ${definition.kind} is already registered`);
|
|
106
|
+
}
|
|
107
|
+
const stored = Object.freeze({
|
|
108
|
+
definition: freezeDefinition(definition),
|
|
109
|
+
accepted: new Set(accepted)
|
|
110
|
+
});
|
|
111
|
+
for (const version of accepted) this.definitions.set(protocolKey({
|
|
112
|
+
apiVersion: version,
|
|
113
|
+
kind: definition.kind
|
|
114
|
+
}), stored);
|
|
115
|
+
return () => {
|
|
116
|
+
for (const version of accepted) {
|
|
117
|
+
const key = protocolKey({
|
|
118
|
+
apiVersion: version,
|
|
119
|
+
kind: definition.kind
|
|
120
|
+
});
|
|
121
|
+
if (this.definitions.get(key) === stored) this.definitions.delete(key);
|
|
122
|
+
}
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
list() {
|
|
126
|
+
return Object.freeze([...new Set([...this.definitions.values()].map((row) => row.definition))]);
|
|
127
|
+
}
|
|
128
|
+
resolve(reference) {
|
|
129
|
+
validateApiReference(reference);
|
|
130
|
+
return this.definitions.get(protocolKey(reference))?.definition;
|
|
131
|
+
}
|
|
132
|
+
understands(reference) {
|
|
133
|
+
return this.resolve(reference) !== void 0;
|
|
134
|
+
}
|
|
135
|
+
negotiate(declarations, policy) {
|
|
136
|
+
const participantIds = /* @__PURE__ */ new Set();
|
|
137
|
+
for (const declaration of declarations) {
|
|
138
|
+
validateProtocolDeclaration(declaration);
|
|
139
|
+
if (participantIds.has(declaration.participant.id)) throw new TypeError(`duplicate participant identity ${JSON.stringify(declaration.participant.id)}`);
|
|
140
|
+
participantIds.add(declaration.participant.id);
|
|
141
|
+
}
|
|
142
|
+
const groups = /* @__PURE__ */ new Map();
|
|
143
|
+
const issues = [];
|
|
144
|
+
for (const [declarationIndex, declaration] of declarations.entries()) {
|
|
145
|
+
for (const [index, requirement] of (declaration.requires ?? []).entries()) {
|
|
146
|
+
const stored = this.definitions.get(protocolKey(requirement));
|
|
147
|
+
if (stored === void 0) {
|
|
148
|
+
issues.push(freezeIssue({
|
|
149
|
+
code: "definition-unavailable",
|
|
150
|
+
severity: requirement.optional === true ? "warning" : "error",
|
|
151
|
+
participant: declaration.participant.id,
|
|
152
|
+
path: `/declarations/${declarationIndex}/requires/${index}`,
|
|
153
|
+
message: `no definition recognizes ${requirement.apiVersion} ${requirement.kind}`
|
|
154
|
+
}));
|
|
155
|
+
continue;
|
|
156
|
+
}
|
|
157
|
+
const group = groups.get(stored) ?? {
|
|
158
|
+
requirements: [],
|
|
159
|
+
supports: []
|
|
160
|
+
};
|
|
161
|
+
try {
|
|
162
|
+
group.requirements.push(Object.freeze({
|
|
163
|
+
participant: declaration.participant.id,
|
|
164
|
+
requirement: Object.freeze({
|
|
165
|
+
...requirement,
|
|
166
|
+
...Object.hasOwn(requirement, "spec") ? { spec: stored.definition.validateRequirement(requirement.spec) } : { spec: stored.definition.validateRequirement(void 0) }
|
|
167
|
+
})
|
|
168
|
+
}));
|
|
169
|
+
} catch (error) {
|
|
170
|
+
issues.push(freezeIssue({
|
|
171
|
+
code: "invalid-requirement",
|
|
172
|
+
severity: "error",
|
|
173
|
+
participant: declaration.participant.id,
|
|
174
|
+
path: `/declarations/${declarationIndex}/requires/${index}/spec`,
|
|
175
|
+
message: errorMessage(error)
|
|
176
|
+
}));
|
|
177
|
+
}
|
|
178
|
+
groups.set(stored, group);
|
|
179
|
+
}
|
|
180
|
+
for (const [index, support] of (declaration.supports ?? []).entries()) {
|
|
181
|
+
const stored = this.definitions.get(protocolKey(support));
|
|
182
|
+
if (stored === void 0) {
|
|
183
|
+
issues.push(freezeIssue({
|
|
184
|
+
code: "definition-unavailable",
|
|
185
|
+
severity: "warning",
|
|
186
|
+
participant: declaration.participant.id,
|
|
187
|
+
path: `/declarations/${declarationIndex}/supports/${index}`,
|
|
188
|
+
message: `no definition recognizes ${support.apiVersion} ${support.kind}`
|
|
189
|
+
}));
|
|
190
|
+
continue;
|
|
191
|
+
}
|
|
192
|
+
const group = groups.get(stored) ?? {
|
|
193
|
+
requirements: [],
|
|
194
|
+
supports: []
|
|
195
|
+
};
|
|
196
|
+
try {
|
|
197
|
+
group.supports.push(Object.freeze({
|
|
198
|
+
participant: declaration.participant.id,
|
|
199
|
+
support: Object.freeze({
|
|
200
|
+
...support,
|
|
201
|
+
...Object.hasOwn(support, "spec") ? { spec: stored.definition.validateSupport(support.spec) } : { spec: stored.definition.validateSupport(void 0) }
|
|
202
|
+
})
|
|
203
|
+
}));
|
|
204
|
+
} catch (error) {
|
|
205
|
+
issues.push(freezeIssue({
|
|
206
|
+
code: "invalid-support",
|
|
207
|
+
severity: "error",
|
|
208
|
+
participant: declaration.participant.id,
|
|
209
|
+
path: `/declarations/${declarationIndex}/supports/${index}/spec`,
|
|
210
|
+
message: errorMessage(error)
|
|
211
|
+
}));
|
|
212
|
+
}
|
|
213
|
+
groups.set(stored, group);
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
const protocols = [];
|
|
217
|
+
for (const stored of [...groups.keys()].sort((left, right) => protocolKey(left.definition).localeCompare(protocolKey(right.definition)))) {
|
|
218
|
+
const group = groups.get(stored);
|
|
219
|
+
let outcome;
|
|
220
|
+
try {
|
|
221
|
+
outcome = stored.definition.negotiate(Object.freeze({
|
|
222
|
+
requirements: Object.freeze([...group.requirements]),
|
|
223
|
+
supports: Object.freeze([...group.supports]),
|
|
224
|
+
...policy === void 0 ? {} : { policy }
|
|
225
|
+
}));
|
|
226
|
+
} catch (error) {
|
|
227
|
+
outcome = { issues: [{
|
|
228
|
+
code: "definition-failed",
|
|
229
|
+
severity: "error",
|
|
230
|
+
message: errorMessage(error)
|
|
231
|
+
}] };
|
|
232
|
+
}
|
|
233
|
+
const protocolIssues = Object.freeze((outcome.issues ?? []).map(freezeIssue));
|
|
234
|
+
issues.push(...protocolIssues);
|
|
235
|
+
protocols.push(Object.freeze({
|
|
236
|
+
apiVersion: stored.definition.apiVersion,
|
|
237
|
+
kind: stored.definition.kind,
|
|
238
|
+
participants: Object.freeze([.../* @__PURE__ */ new Set([...group.requirements.map((row) => row.participant), ...group.supports.map((row) => row.participant)])].sort()),
|
|
239
|
+
...Object.hasOwn(outcome, "agreement") ? { agreement: outcome.agreement } : {},
|
|
240
|
+
issues: protocolIssues
|
|
241
|
+
}));
|
|
242
|
+
}
|
|
243
|
+
return Object.freeze({
|
|
244
|
+
apiVersion: "core.dsh/report/v1alpha1",
|
|
245
|
+
evaluator: Object.freeze({ ...this.evaluator }),
|
|
246
|
+
compatible: !issues.some((issue) => issue.severity === "error"),
|
|
247
|
+
protocols: Object.freeze(protocols),
|
|
248
|
+
issues: Object.freeze(issues)
|
|
249
|
+
});
|
|
250
|
+
}
|
|
251
|
+
};
|
|
252
|
+
function validateDefinition(definition) {
|
|
253
|
+
validateApiReference(definition, "protocol definition");
|
|
254
|
+
if (typeof definition.validateRequirement !== "function" || typeof definition.validateSupport !== "function" || typeof definition.negotiate !== "function") throw new TypeError("protocol definition must provide validators and negotiate");
|
|
255
|
+
const versions = [definition.apiVersion, ...definition.accepts ?? []];
|
|
256
|
+
if (new Set(versions).size !== versions.length) throw new TypeError("protocol definition accepts duplicate versions");
|
|
257
|
+
for (const version of versions) validateApiReference({
|
|
258
|
+
apiVersion: version,
|
|
259
|
+
kind: definition.kind
|
|
260
|
+
});
|
|
261
|
+
}
|
|
262
|
+
function freezeDefinition(definition) {
|
|
263
|
+
return Object.freeze({
|
|
264
|
+
...definition,
|
|
265
|
+
...definition.accepts === void 0 ? {} : { accepts: Object.freeze([...definition.accepts]) }
|
|
266
|
+
});
|
|
267
|
+
}
|
|
268
|
+
function freezeIssue(issue) {
|
|
269
|
+
if (issue.severity !== "error" && issue.severity !== "warning") throw new TypeError("protocol issue severity is invalid");
|
|
270
|
+
nonEmpty(issue.code, "protocol issue.code");
|
|
271
|
+
nonEmpty(issue.message, "protocol issue.message");
|
|
272
|
+
return Object.freeze({ ...issue });
|
|
273
|
+
}
|
|
274
|
+
function nonEmpty(value, label) {
|
|
275
|
+
if (typeof value !== "string" || value.trim() === "") throw new TypeError(`${label} must be a non-empty string`);
|
|
276
|
+
}
|
|
277
|
+
function errorMessage(error) {
|
|
278
|
+
return error instanceof Error ? error.message : String(error);
|
|
279
|
+
}
|
|
280
|
+
//#endregion
|
|
281
|
+
//#region src/version.ts
|
|
282
|
+
function parseSemanticVersion(value) {
|
|
283
|
+
const match = /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-([0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*))?(?:\+([0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*))?$/u.exec(value);
|
|
284
|
+
if (match === null) throw new TypeError(`invalid semantic version ${JSON.stringify(value)}`);
|
|
285
|
+
const prerelease = match[4] === void 0 ? [] : match[4].split(".").map((identifier) => {
|
|
286
|
+
if (!/^\d+$/u.test(identifier)) return identifier;
|
|
287
|
+
if (identifier.length > 1 && identifier.startsWith("0")) throw new TypeError(`invalid semantic version ${JSON.stringify(value)}`);
|
|
288
|
+
return Number(identifier);
|
|
289
|
+
});
|
|
290
|
+
return Object.freeze({
|
|
291
|
+
major: Number(match[1]),
|
|
292
|
+
minor: Number(match[2]),
|
|
293
|
+
patch: Number(match[3]),
|
|
294
|
+
prerelease: Object.freeze(prerelease),
|
|
295
|
+
build: Object.freeze(match[5] === void 0 ? [] : match[5].split("."))
|
|
296
|
+
});
|
|
297
|
+
}
|
|
298
|
+
function compareSemanticVersions(leftValue, rightValue) {
|
|
299
|
+
const left = typeof leftValue === "string" ? parseSemanticVersion(leftValue) : leftValue;
|
|
300
|
+
const right = typeof rightValue === "string" ? parseSemanticVersion(rightValue) : rightValue;
|
|
301
|
+
return left.major - right.major || left.minor - right.minor || left.patch - right.patch || comparePrerelease(left.prerelease, right.prerelease);
|
|
302
|
+
}
|
|
303
|
+
function assertVersionRange(range) {
|
|
304
|
+
compileRange(range);
|
|
305
|
+
}
|
|
306
|
+
function satisfiesVersionRange(versionValue, range) {
|
|
307
|
+
const version = parseSemanticVersion(versionValue);
|
|
308
|
+
return compileRange(range).some((group) => {
|
|
309
|
+
if (version.prerelease.length > 0 && !group.explicitPrereleases.has(coreKey(version))) return false;
|
|
310
|
+
return group.predicates.every((predicate) => predicate(version));
|
|
311
|
+
});
|
|
312
|
+
}
|
|
313
|
+
function compileRange(range) {
|
|
314
|
+
const values = typeof range === "string" ? [range] : range;
|
|
315
|
+
if (!Array.isArray(values) || values.length === 0) throw new TypeError("version range must be a string or non-empty array");
|
|
316
|
+
return Object.freeze(values.flatMap((value) => {
|
|
317
|
+
if (typeof value !== "string" || value.trim() === "") throw new TypeError("version range must not be empty");
|
|
318
|
+
return value.split("||").map((part) => compileGroup(part.trim()));
|
|
319
|
+
}));
|
|
320
|
+
}
|
|
321
|
+
function compileGroup(value) {
|
|
322
|
+
if (value === "") throw new TypeError("version range contains an empty alternative");
|
|
323
|
+
if (value === "*" || /^x$/iu.test(value)) return {
|
|
324
|
+
predicates: [],
|
|
325
|
+
explicitPrereleases: /* @__PURE__ */ new Set()
|
|
326
|
+
};
|
|
327
|
+
const predicates = [];
|
|
328
|
+
const explicitPrereleases = /* @__PURE__ */ new Set();
|
|
329
|
+
for (const token of value.split(/\s+/u)) {
|
|
330
|
+
const parsed = compileComparator(token);
|
|
331
|
+
predicates.push(...parsed.predicates);
|
|
332
|
+
if (parsed.explicitPrerelease !== void 0) explicitPrereleases.add(parsed.explicitPrerelease);
|
|
333
|
+
}
|
|
334
|
+
return Object.freeze({
|
|
335
|
+
predicates: Object.freeze(predicates),
|
|
336
|
+
explicitPrereleases
|
|
337
|
+
});
|
|
338
|
+
}
|
|
339
|
+
function compileComparator(token) {
|
|
340
|
+
const match = /^(<=|>=|<|>|=|\^|~)?(.+)$/u.exec(token);
|
|
341
|
+
if (match === null) throw new TypeError(`invalid version comparator ${JSON.stringify(token)}`);
|
|
342
|
+
const operator = match[1] ?? "=";
|
|
343
|
+
const body = match[2];
|
|
344
|
+
const partial = /^(0|[1-9]\d*|[xX*])(?:\.(0|[1-9]\d*|[xX*]))?(?:\.(0|[1-9]\d*|[xX*]))?$/u.exec(body);
|
|
345
|
+
if (partial !== null && (partial[2] === void 0 || partial[3] === void 0 || [
|
|
346
|
+
partial[1],
|
|
347
|
+
partial[2],
|
|
348
|
+
partial[3]
|
|
349
|
+
].some(wild))) {
|
|
350
|
+
if (operator !== "=") {
|
|
351
|
+
if ((operator === "~" || operator === "^") && ![partial[1], partial[2]].some(wild)) {
|
|
352
|
+
const lower = version(Number(partial[1]), Number(partial[2]), partial[3] === void 0 || wild(partial[3]) ? 0 : Number(partial[3]));
|
|
353
|
+
return bounded(lower, operator === "~" ? version(lower.major, lower.minor + 1, 0) : caretUpper(lower));
|
|
354
|
+
}
|
|
355
|
+
throw new TypeError(`partial version cannot use ${JSON.stringify(operator)}`);
|
|
356
|
+
}
|
|
357
|
+
return wildcardRange(partial);
|
|
358
|
+
}
|
|
359
|
+
const target = parseSemanticVersion(body);
|
|
360
|
+
const explicitPrerelease = target.prerelease.length === 0 ? void 0 : coreKey(target);
|
|
361
|
+
if (operator === "^") return {
|
|
362
|
+
...bounded(target, caretUpper(target)),
|
|
363
|
+
...explicitPrerelease === void 0 ? {} : { explicitPrerelease }
|
|
364
|
+
};
|
|
365
|
+
if (operator === "~") return {
|
|
366
|
+
...bounded(target, version(target.major, target.minor + 1, 0)),
|
|
367
|
+
...explicitPrerelease === void 0 ? {} : { explicitPrerelease }
|
|
368
|
+
};
|
|
369
|
+
const comparison = (candidate) => compareSemanticVersions(candidate, target);
|
|
370
|
+
return {
|
|
371
|
+
predicates: [operator === "=" ? (candidate) => comparison(candidate) === 0 : operator === "<" ? (candidate) => comparison(candidate) < 0 : operator === "<=" ? (candidate) => comparison(candidate) <= 0 : operator === ">" ? (candidate) => comparison(candidate) > 0 : (candidate) => comparison(candidate) >= 0],
|
|
372
|
+
...explicitPrerelease === void 0 ? {} : { explicitPrerelease }
|
|
373
|
+
};
|
|
374
|
+
}
|
|
375
|
+
function wildcardRange(match) {
|
|
376
|
+
if (wild(match[1])) return { predicates: [] };
|
|
377
|
+
const major = Number(match[1]);
|
|
378
|
+
if (match[2] === void 0 || wild(match[2])) return bounded(version(major, 0, 0), version(major + 1, 0, 0));
|
|
379
|
+
const minor = Number(match[2]);
|
|
380
|
+
if (match[3] === void 0 || wild(match[3])) return bounded(version(major, minor, 0), version(major, minor + 1, 0));
|
|
381
|
+
throw new TypeError("unreachable complete version range");
|
|
382
|
+
}
|
|
383
|
+
function bounded(lower, upper) {
|
|
384
|
+
return { predicates: [(candidate) => compareSemanticVersions(candidate, lower) >= 0, (candidate) => compareSemanticVersions(candidate, upper) < 0] };
|
|
385
|
+
}
|
|
386
|
+
function caretUpper(lower) {
|
|
387
|
+
if (lower.major > 0) return version(lower.major + 1, 0, 0);
|
|
388
|
+
if (lower.minor > 0) return version(0, lower.minor + 1, 0);
|
|
389
|
+
return version(0, 0, lower.patch + 1);
|
|
390
|
+
}
|
|
391
|
+
function version(major, minor, patch) {
|
|
392
|
+
return {
|
|
393
|
+
major,
|
|
394
|
+
minor,
|
|
395
|
+
patch,
|
|
396
|
+
prerelease: [],
|
|
397
|
+
build: []
|
|
398
|
+
};
|
|
399
|
+
}
|
|
400
|
+
function wild(value) {
|
|
401
|
+
return value === "*" || /^x$/iu.test(value ?? "");
|
|
402
|
+
}
|
|
403
|
+
function coreKey(value) {
|
|
404
|
+
return `${value.major}.${value.minor}.${value.patch}`;
|
|
405
|
+
}
|
|
406
|
+
function comparePrerelease(left, right) {
|
|
407
|
+
if (left.length === 0) return right.length === 0 ? 0 : 1;
|
|
408
|
+
if (right.length === 0) return -1;
|
|
409
|
+
for (let index = 0; index < Math.max(left.length, right.length); index += 1) {
|
|
410
|
+
const leftPart = left[index];
|
|
411
|
+
const rightPart = right[index];
|
|
412
|
+
if (leftPart === void 0) return -1;
|
|
413
|
+
if (rightPart === void 0) return 1;
|
|
414
|
+
if (leftPart === rightPart) continue;
|
|
415
|
+
if (typeof leftPart === "number" && typeof rightPart === "string") return -1;
|
|
416
|
+
if (typeof leftPart === "string" && typeof rightPart === "number") return 1;
|
|
417
|
+
return leftPart < rightPart ? -1 : 1;
|
|
418
|
+
}
|
|
419
|
+
return 0;
|
|
420
|
+
}
|
|
421
|
+
//#endregion
|
|
422
|
+
export { ProtocolCatalog, assertVersionRange, compareSemanticVersions, defineProtocolDeclaration, parseApiVersion, parseSemanticVersion, protocolFamilyKey, protocolKey, sameProtocol, satisfiesVersionRange, validateApiReference, validateProtocolDeclaration };
|
|
423
|
+
|
|
424
|
+
//# sourceMappingURL=index.js.map
|