@songtonyli/dsh-cli 0.1.90 → 0.1.92
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 +1 -1
- package/bin/dsh.mjs +1 -1
- package/node_modules/@aws-sdk/core/dist-cjs/submodules/client/index.js +26 -13
- package/node_modules/@aws-sdk/core/dist-cjs/submodules/httpAuthSchemes/index.js +6 -3
- package/node_modules/@aws-sdk/core/dist-cjs/submodules/protocols/index.js +51 -1
- package/node_modules/@aws-sdk/core/dist-cjs/submodules/util/index.js +2 -1
- package/node_modules/@aws-sdk/core/dist-es/submodules/client/middleware-host-header/hostHeaderMiddleware.js +4 -2
- package/node_modules/@aws-sdk/core/dist-es/submodules/client/util-endpoints/lib/aws/parseArn.js +4 -2
- package/node_modules/@aws-sdk/core/dist-es/submodules/client/util-user-agent-browser/defaultUserAgent.js +18 -9
- package/node_modules/@aws-sdk/core/dist-es/submodules/httpAuthSchemes/aws_sdk/NODE_AUTH_SCHEME_PREFERENCE_OPTIONS.js +6 -3
- package/node_modules/@aws-sdk/core/dist-es/submodules/protocols/index.js +1 -0
- package/node_modules/@aws-sdk/core/dist-es/submodules/protocols/json/AwsSmithyRpcV2JsonProtocol.js +51 -0
- package/node_modules/@aws-sdk/core/dist-es/submodules/util/util-arn-parser/arn.js +2 -1
- package/node_modules/@aws-sdk/core/package.json +2 -2
- package/node_modules/@aws-sdk/credential-provider-env/package.json +2 -2
- package/node_modules/@aws-sdk/credential-provider-http/package.json +2 -2
- package/node_modules/@aws-sdk/credential-provider-ini/package.json +9 -9
- package/node_modules/@aws-sdk/credential-provider-login/package.json +3 -3
- package/node_modules/@aws-sdk/credential-provider-node/package.json +7 -7
- package/node_modules/@aws-sdk/credential-provider-process/package.json +2 -2
- package/node_modules/@aws-sdk/credential-provider-sso/package.json +4 -4
- package/node_modules/@aws-sdk/credential-provider-web-identity/package.json +3 -3
- package/node_modules/@aws-sdk/middleware-eventstream/dist-cjs/index.js +4 -2
- package/node_modules/@aws-sdk/middleware-eventstream/dist-es/eventStreamHandlingMiddleware.js +2 -1
- package/node_modules/@aws-sdk/middleware-eventstream/dist-es/eventStreamHeaderMiddleware.js +2 -1
- package/node_modules/@aws-sdk/middleware-eventstream/package.json +1 -1
- package/node_modules/@aws-sdk/middleware-websocket/package.json +2 -2
- package/node_modules/@aws-sdk/nested-clients/dist-cjs/submodules/cognito-identity/index.js +1 -1
- package/node_modules/@aws-sdk/nested-clients/dist-cjs/submodules/signin/index.js +1 -1
- package/node_modules/@aws-sdk/nested-clients/dist-cjs/submodules/sso/index.js +1 -1
- package/node_modules/@aws-sdk/nested-clients/dist-cjs/submodules/sso-oidc/index.js +1 -1
- package/node_modules/@aws-sdk/nested-clients/dist-cjs/submodules/sts/index.js +1 -1
- package/node_modules/@aws-sdk/nested-clients/package.json +3 -3
- package/node_modules/@aws-sdk/signature-v4-multi-region/package.json +1 -1
- package/node_modules/@aws-sdk/token-providers/package.json +3 -3
- package/node_modules/@aws-sdk/xml-builder/package.json +1 -1
- package/node_modules/@deepseek-ai/cordis/README.md +6 -2
- package/node_modules/@deepseek-ai/cordis/lib/index.js +955 -909
- package/node_modules/@deepseek-ai/cordis/src/context.ts +1 -1
- package/node_modules/@deepseek-ai/cordis/src/events.ts +81 -62
- package/node_modules/@deepseek-ai/cordis/src/fiber.ts +95 -58
- package/node_modules/@deepseek-ai/cordis/src/logger.ts +10 -5
- package/node_modules/@deepseek-ai/cordis/src/reflect.ts +37 -19
- package/node_modules/@deepseek-ai/cordis/src/utils.ts +28 -21
- package/node_modules/@deepseek-ai/cordis-plugin-include/lib/index.js +2 -2
- package/node_modules/@deepseek-ai/cordis-plugin-include/src/index.ts +2 -6
- package/node_modules/@deepseek-ai/cordis-plugin-loader/README.md +4 -0
- package/node_modules/@deepseek-ai/cordis-plugin-loader/lib/index.js +40 -39
- package/node_modules/@deepseek-ai/cordis-plugin-loader/src/config/entry.ts +13 -13
- package/node_modules/@deepseek-ai/cordis-plugin-loader/src/config/group.ts +1 -3
- package/node_modules/@deepseek-ai/cordis-plugin-loader/src/config/isolate.ts +10 -7
- package/node_modules/@deepseek-ai/cordis-plugin-loader/src/index.ts +17 -20
- package/node_modules/@deepseek-ai/dsh/package.json +0 -1
- package/node_modules/@deepseek-ai/dsh-action-cards/lib/typert.host.js +1 -1
- package/node_modules/@deepseek-ai/dsh-agent-preset/skills/cordis-composition-reference/references/packages.md +5 -3
- package/node_modules/@deepseek-ai/dsh-agent-preset/skills/cordis-plugin-development/references/host-plugin.md +13 -0
- package/node_modules/@deepseek-ai/dsh-agent-preset-registry/lib/index.js +2 -2
- package/node_modules/@deepseek-ai/dsh-agent-preset-registry/lib/typert.host.js +1 -1
- package/node_modules/@deepseek-ai/dsh-agent-preset-registry/lib/types/mount.js +2 -2
- package/node_modules/@deepseek-ai/dsh-api-gateway/lib/client.browser.js +1 -1
- package/node_modules/@deepseek-ai/dsh-api-gateway/lib/client.node.js +1 -1
- package/node_modules/@deepseek-ai/dsh-api-gateway/lib/types/client/remote-events.js +1 -1
- package/node_modules/@deepseek-ai/dsh-api-remotes/lib/client.js +7464 -2004
- package/node_modules/@deepseek-ai/dsh-api-session-controller/lib/client.js +77 -92
- package/node_modules/@deepseek-ai/dsh-api-session-controller/lib/typert.host.js +47 -3
- package/node_modules/@deepseek-ai/dsh-api-terminal-controller/lib/typert.host.js +1 -1
- package/node_modules/@deepseek-ai/dsh-app-boot/lib/index.js +8 -19
- package/node_modules/@deepseek-ai/dsh-base/cordis.patch.yml +3 -0
- package/node_modules/@deepseek-ai/dsh-client-file-upload/lib/typert.host.js +1 -1
- package/node_modules/@deepseek-ai/dsh-client-modules/README.i18n.yaml +2 -2
- package/node_modules/@deepseek-ai/dsh-client-modules/README.md +3 -1
- package/node_modules/@deepseek-ai/dsh-client-modules/README.zh.md +3 -1
- package/node_modules/@deepseek-ai/dsh-client-modules/lib/client.js +1 -1
- package/node_modules/@deepseek-ai/dsh-client-modules/lib/index.js +37 -15
- package/node_modules/@deepseek-ai/dsh-client-ui-attachment/README.i18n.yaml +4 -4
- package/node_modules/@deepseek-ai/dsh-client-ui-attachment/README.md +3 -1
- package/node_modules/@deepseek-ai/dsh-client-ui-attachment/README.zh.md +3 -1
- package/node_modules/@deepseek-ai/dsh-client-ui-attachment/lib/client.js +19 -6
- package/node_modules/@deepseek-ai/dsh-client-ui-attachment/package.json +4 -2
- package/node_modules/@deepseek-ai/dsh-client-ui-chat/README.i18n.yaml +10 -10
- package/node_modules/@deepseek-ai/dsh-client-ui-chat/README.md +8 -2
- package/node_modules/@deepseek-ai/dsh-client-ui-chat/README.zh.md +8 -2
- package/node_modules/@deepseek-ai/dsh-client-ui-chat/lib/client.js +146 -30
- package/node_modules/@deepseek-ai/dsh-client-ui-chat/package.json +4 -2
- package/node_modules/@deepseek-ai/dsh-client-ui-commands/README.i18n.yaml +2 -2
- package/node_modules/@deepseek-ai/dsh-client-ui-commands/README.md +1 -1
- package/node_modules/@deepseek-ai/dsh-client-ui-commands/README.zh.md +1 -1
- package/node_modules/@deepseek-ai/dsh-client-ui-commands/lib/client.js +295 -274
- package/node_modules/@deepseek-ai/dsh-client-ui-context-menu/README.i18n.yaml +40 -0
- package/node_modules/@deepseek-ai/dsh-client-ui-context-menu/README.md +100 -0
- package/node_modules/@deepseek-ai/dsh-client-ui-context-menu/README.zh.md +100 -0
- package/node_modules/@deepseek-ai/dsh-client-ui-context-menu/lib/client.js +1445 -0
- package/node_modules/@deepseek-ai/dsh-client-ui-context-menu/lib/index.js +6 -0
- package/node_modules/@deepseek-ai/dsh-client-ui-context-menu/locale/de.json +5 -0
- package/node_modules/@deepseek-ai/dsh-client-ui-context-menu/locale/en.json +5 -0
- package/node_modules/@deepseek-ai/dsh-client-ui-context-menu/locale/es.json +5 -0
- package/node_modules/@deepseek-ai/dsh-client-ui-context-menu/locale/fr.json +5 -0
- package/node_modules/@deepseek-ai/dsh-client-ui-context-menu/locale/ja.json +5 -0
- package/node_modules/@deepseek-ai/dsh-client-ui-context-menu/locale/pt.json +5 -0
- package/node_modules/@deepseek-ai/dsh-client-ui-context-menu/locale/ru.json +5 -0
- package/node_modules/@deepseek-ai/dsh-client-ui-context-menu/locale/zh.json +5 -0
- package/node_modules/@deepseek-ai/dsh-client-ui-context-menu/package.json +61 -0
- package/node_modules/@deepseek-ai/dsh-client-ui-conversation/README.i18n.yaml +4 -4
- package/node_modules/@deepseek-ai/dsh-client-ui-conversation/README.md +4 -0
- package/node_modules/@deepseek-ai/dsh-client-ui-conversation/README.zh.md +4 -0
- package/node_modules/@deepseek-ai/dsh-client-ui-conversation/lib/client.js +119 -55
- package/node_modules/@deepseek-ai/dsh-client-ui-conversation/package.json +4 -2
- package/node_modules/@deepseek-ai/dsh-client-ui-deliverables/README.i18n.yaml +2 -2
- package/node_modules/@deepseek-ai/dsh-client-ui-deliverables/README.md +2 -0
- package/node_modules/@deepseek-ai/dsh-client-ui-deliverables/README.zh.md +2 -0
- package/node_modules/@deepseek-ai/dsh-client-ui-deliverables/lib/client.js +19 -7
- package/node_modules/@deepseek-ai/dsh-client-ui-deliverables/package.json +4 -2
- package/node_modules/@deepseek-ai/dsh-client-ui-file-actions/README.i18n.yaml +40 -0
- package/node_modules/@deepseek-ai/dsh-client-ui-file-actions/README.md +92 -0
- package/node_modules/@deepseek-ai/dsh-client-ui-file-actions/README.zh.md +92 -0
- package/node_modules/@deepseek-ai/dsh-client-ui-file-actions/lib/client.js +1875 -0
- package/node_modules/@deepseek-ai/dsh-client-ui-file-actions/lib/index.js +6 -0
- package/node_modules/@deepseek-ai/dsh-client-ui-file-actions/locale/de.json +5 -0
- package/node_modules/@deepseek-ai/dsh-client-ui-file-actions/locale/en.json +5 -0
- package/node_modules/@deepseek-ai/dsh-client-ui-file-actions/locale/es.json +5 -0
- package/node_modules/@deepseek-ai/dsh-client-ui-file-actions/locale/fr.json +5 -0
- package/node_modules/@deepseek-ai/dsh-client-ui-file-actions/locale/ja.json +5 -0
- package/node_modules/@deepseek-ai/dsh-client-ui-file-actions/locale/pt.json +5 -0
- package/node_modules/@deepseek-ai/dsh-client-ui-file-actions/locale/ru.json +5 -0
- package/node_modules/@deepseek-ai/dsh-client-ui-file-actions/locale/zh.json +5 -0
- package/node_modules/@deepseek-ai/dsh-client-ui-file-actions/package.json +65 -0
- package/node_modules/@deepseek-ai/dsh-client-ui-layout/README.i18n.yaml +6 -6
- package/node_modules/@deepseek-ai/dsh-client-ui-layout/README.md +9 -3
- package/node_modules/@deepseek-ai/dsh-client-ui-layout/README.zh.md +9 -3
- package/node_modules/@deepseek-ai/dsh-client-ui-layout/lib/client.js +91 -26
- package/node_modules/@deepseek-ai/dsh-client-ui-open-in-app/README.i18n.yaml +2 -2
- package/node_modules/@deepseek-ai/dsh-client-ui-open-in-app/README.md +8 -0
- package/node_modules/@deepseek-ai/dsh-client-ui-open-in-app/README.zh.md +8 -0
- package/node_modules/@deepseek-ai/dsh-client-ui-open-in-app/lib/client.js +431 -2
- package/node_modules/@deepseek-ai/dsh-client-ui-open-in-app/package.json +13 -2
- package/node_modules/@deepseek-ai/dsh-client-ui-plugin-manager/README.i18n.yaml +8 -8
- package/node_modules/@deepseek-ai/dsh-client-ui-plugin-manager/README.md +6 -3
- package/node_modules/@deepseek-ai/dsh-client-ui-plugin-manager/README.zh.md +6 -3
- package/node_modules/@deepseek-ai/dsh-client-ui-plugin-manager/lib/client.js +111 -48
- package/node_modules/@deepseek-ai/dsh-client-ui-plugin-market/README.i18n.yaml +2 -2
- package/node_modules/@deepseek-ai/dsh-client-ui-plugin-market/README.md +1 -1
- package/node_modules/@deepseek-ai/dsh-client-ui-plugin-market/README.zh.md +1 -1
- package/node_modules/@deepseek-ai/dsh-client-ui-plugin-market/lib/client.js +2 -1
- package/node_modules/@deepseek-ai/dsh-client-ui-reference/README.i18n.yaml +2 -2
- package/node_modules/@deepseek-ai/dsh-client-ui-reference/README.md +2 -0
- package/node_modules/@deepseek-ai/dsh-client-ui-reference/README.zh.md +2 -0
- package/node_modules/@deepseek-ai/dsh-client-ui-reference/lib/client.js +28 -5
- package/node_modules/@deepseek-ai/dsh-client-ui-reference/package.json +4 -2
- package/node_modules/@deepseek-ai/dsh-client-ui-schedule/README.i18n.yaml +19 -19
- package/node_modules/@deepseek-ai/dsh-client-ui-schedule/README.md +25 -39
- package/node_modules/@deepseek-ai/dsh-client-ui-schedule/README.zh.md +23 -37
- package/node_modules/@deepseek-ai/dsh-client-ui-schedule/lib/client.js +10359 -3743
- package/node_modules/@deepseek-ai/dsh-client-ui-schedule/package.json +1 -0
- package/node_modules/@deepseek-ai/dsh-client-ui-settings-models/README.i18n.yaml +2 -2
- package/node_modules/@deepseek-ai/dsh-client-ui-settings-models/README.md +1 -1
- package/node_modules/@deepseek-ai/dsh-client-ui-settings-models/README.zh.md +1 -1
- package/node_modules/@deepseek-ai/dsh-client-ui-settings-models/lib/client.js +76 -58
- package/node_modules/@deepseek-ai/dsh-client-ui-sidebar/README.i18n.yaml +6 -6
- package/node_modules/@deepseek-ai/dsh-client-ui-sidebar/README.md +5 -1
- package/node_modules/@deepseek-ai/dsh-client-ui-sidebar/README.zh.md +5 -1
- package/node_modules/@deepseek-ai/dsh-client-ui-sidebar/lib/client.js +46 -18
- package/node_modules/@deepseek-ai/dsh-client-ui-sidebar-documentpreview/README.i18n.yaml +8 -8
- package/node_modules/@deepseek-ai/dsh-client-ui-sidebar-documentpreview/README.md +7 -5
- package/node_modules/@deepseek-ai/dsh-client-ui-sidebar-documentpreview/README.zh.md +7 -5
- package/node_modules/@deepseek-ai/dsh-client-ui-sidebar-documentpreview/lib/client.js +349 -251
- package/node_modules/@deepseek-ai/dsh-client-ui-sidebar-documentpreview/package.json +5 -2
- package/node_modules/@deepseek-ai/dsh-client-ui-sidebar-files/README.i18n.yaml +20 -14
- package/node_modules/@deepseek-ai/dsh-client-ui-sidebar-files/README.md +44 -11
- package/node_modules/@deepseek-ai/dsh-client-ui-sidebar-files/README.zh.md +44 -11
- package/node_modules/@deepseek-ai/dsh-client-ui-sidebar-files/lib/client.js +1571 -472
- package/node_modules/@deepseek-ai/dsh-client-ui-sidebar-files/package.json +5 -3
- package/node_modules/@deepseek-ai/dsh-client-ui-sidebar-right/README.i18n.yaml +12 -12
- package/node_modules/@deepseek-ai/dsh-client-ui-sidebar-right/README.md +15 -7
- package/node_modules/@deepseek-ai/dsh-client-ui-sidebar-right/README.zh.md +15 -7
- package/node_modules/@deepseek-ai/dsh-client-ui-sidebar-right/lib/client.js +435 -52
- package/node_modules/@deepseek-ai/dsh-client-ui-sidebar-right/package.json +4 -2
- package/node_modules/@deepseek-ai/dsh-client-ui-subagent/lib/client.js +8 -0
- package/node_modules/@deepseek-ai/dsh-client-ui-theme/README.i18n.yaml +2 -2
- package/node_modules/@deepseek-ai/dsh-client-ui-theme/README.md +1 -1
- package/node_modules/@deepseek-ai/dsh-client-ui-theme/README.zh.md +1 -1
- package/node_modules/@deepseek-ai/dsh-client-ui-theme/lib/client.js +1 -1
- package/node_modules/@deepseek-ai/dsh-client-ui-tool/README.i18n.yaml +4 -4
- package/node_modules/@deepseek-ai/dsh-client-ui-tool/README.md +5 -1
- package/node_modules/@deepseek-ai/dsh-client-ui-tool/README.zh.md +5 -1
- package/node_modules/@deepseek-ai/dsh-client-ui-tool/lib/client.js +195 -59
- package/node_modules/@deepseek-ai/dsh-client-ui-tool/package.json +5 -2
- package/node_modules/@deepseek-ai/dsh-client-ui-trajectory/README.i18n.yaml +4 -4
- package/node_modules/@deepseek-ai/dsh-client-ui-trajectory/README.md +6 -2
- package/node_modules/@deepseek-ai/dsh-client-ui-trajectory/README.zh.md +6 -2
- package/node_modules/@deepseek-ai/dsh-client-ui-trajectory/lib/client.js +127 -27
- package/node_modules/@deepseek-ai/dsh-client-ui-workspace/README.i18n.yaml +15 -15
- package/node_modules/@deepseek-ai/dsh-client-ui-workspace/README.md +16 -8
- package/node_modules/@deepseek-ai/dsh-client-ui-workspace/README.zh.md +17 -8
- package/node_modules/@deepseek-ai/dsh-client-ui-workspace/lib/client.js +523 -480
- package/node_modules/@deepseek-ai/dsh-client-ui-workspace/package.json +4 -2
- package/node_modules/@deepseek-ai/dsh-commands/README.i18n.yaml +4 -4
- package/node_modules/@deepseek-ai/dsh-commands/README.md +3 -0
- package/node_modules/@deepseek-ai/dsh-commands/README.zh.md +3 -0
- package/node_modules/@deepseek-ai/dsh-commands/lib/typert.host.js +1 -1
- package/node_modules/@deepseek-ai/dsh-commands/lib/types/builtin.js +39 -0
- package/node_modules/@deepseek-ai/dsh-commands/package.json +5 -1
- package/node_modules/@deepseek-ai/dsh-compaction-basic/README.i18n.yaml +4 -10
- package/node_modules/@deepseek-ai/dsh-compaction-basic/README.md +2 -0
- package/node_modules/@deepseek-ai/dsh-compaction-basic/README.zh.md +2 -0
- package/node_modules/@deepseek-ai/dsh-cordis-client-runner/lib/client.js +233 -56
- package/node_modules/@deepseek-ai/dsh-cordis-host-runner/lib/typert.host.js +2 -2
- package/node_modules/@deepseek-ai/dsh-deepseek-llm-api-extensions/README.i18n.yaml +2 -2
- package/node_modules/@deepseek-ai/dsh-deepseek-llm-api-extensions/README.md +2 -0
- package/node_modules/@deepseek-ai/dsh-deepseek-llm-api-extensions/README.zh.md +2 -0
- package/node_modules/@deepseek-ai/dsh-experimental-auto-review/README.i18n.yaml +16 -19
- package/node_modules/@deepseek-ai/dsh-experimental-auto-review/README.md +11 -22
- package/node_modules/@deepseek-ai/dsh-experimental-auto-review/README.zh.md +11 -22
- package/node_modules/@deepseek-ai/dsh-experimental-auto-review/lib/index.js +2 -0
- package/node_modules/@deepseek-ai/dsh-experimental-client-ui-cot-translation/lib/client.js +1 -1
- package/node_modules/@deepseek-ai/dsh-experimental-client-ui-forge/README.i18n.yaml +12 -12
- package/node_modules/@deepseek-ai/dsh-experimental-client-ui-forge/README.md +18 -10
- package/node_modules/@deepseek-ai/dsh-experimental-client-ui-forge/README.zh.md +20 -12
- package/node_modules/@deepseek-ai/dsh-experimental-client-ui-forge/lib/client.js +3338 -297
- package/node_modules/@deepseek-ai/dsh-experimental-client-ui-forge/lib/index.js +159 -52
- package/node_modules/@deepseek-ai/dsh-experimental-client-ui-forge/lib/typert.host.js +298 -18
- package/node_modules/@deepseek-ai/dsh-experimental-client-ui-forge/lib/typert.remote-client.js +267 -13
- package/node_modules/@deepseek-ai/dsh-experimental-forge/README.i18n.yaml +2 -2
- package/node_modules/@deepseek-ai/dsh-experimental-forge/README.md +5 -1
- package/node_modules/@deepseek-ai/dsh-experimental-forge/README.zh.md +5 -1
- package/node_modules/@deepseek-ai/dsh-experimental-forge/lib/index.js +48 -6
- package/node_modules/@deepseek-ai/dsh-experimental-forge-github/README.i18n.yaml +8 -8
- package/node_modules/@deepseek-ai/dsh-experimental-forge-github/README.md +9 -5
- package/node_modules/@deepseek-ai/dsh-experimental-forge-github/README.zh.md +9 -5
- package/node_modules/@deepseek-ai/dsh-experimental-forge-github/lib/index.js +301 -31
- package/node_modules/@deepseek-ai/dsh-experimental-forge-github/package.json +1 -0
- package/node_modules/@deepseek-ai/dsh-experimental-liveshare/lib/client.js +5 -58
- package/node_modules/@deepseek-ai/dsh-experimental-liveshare/lib/index.js +5 -2
- package/node_modules/@deepseek-ai/dsh-experimental-liveshare/package.json +1 -1
- package/node_modules/@deepseek-ai/dsh-experimental-session-inspector/lib/client.js +77 -92
- package/node_modules/@deepseek-ai/dsh-experimental-translator/lib/index.js +2 -2
- package/node_modules/@deepseek-ai/dsh-experimental-translator/lib/types/deepseek.js +2 -2
- package/node_modules/@deepseek-ai/dsh-fs/README.i18n.yaml +12 -12
- package/node_modules/@deepseek-ai/dsh-fs/README.md +15 -7
- package/node_modules/@deepseek-ai/dsh-fs/README.zh.md +15 -7
- package/node_modules/@deepseek-ai/dsh-fs/lib/index.js +21 -2
- package/node_modules/@deepseek-ai/dsh-fs/package.json +3 -0
- package/node_modules/@deepseek-ai/dsh-fs-local/README.i18n.yaml +4 -4
- package/node_modules/@deepseek-ai/dsh-fs-local/README.md +4 -2
- package/node_modules/@deepseek-ai/dsh-fs-local/README.zh.md +4 -2
- package/node_modules/@deepseek-ai/dsh-fs-local/lib/index.js +156 -30
- package/node_modules/@deepseek-ai/dsh-fs-local/package.json +2 -1
- package/node_modules/@deepseek-ai/dsh-fs-observation-policy/README.i18n.yaml +6 -6
- package/node_modules/@deepseek-ai/dsh-fs-observation-policy/README.md +4 -2
- package/node_modules/@deepseek-ai/dsh-fs-observation-policy/README.zh.md +4 -2
- package/node_modules/@deepseek-ai/dsh-fs-observation-policy/lib/index.js +12 -4
- package/node_modules/@deepseek-ai/dsh-fs-patch/LICENSE +235 -0
- package/node_modules/@deepseek-ai/dsh-fs-patch/README.i18n.yaml +40 -0
- package/node_modules/@deepseek-ai/dsh-fs-patch/README.md +112 -0
- package/node_modules/@deepseek-ai/dsh-fs-patch/README.zh.md +112 -0
- package/node_modules/@deepseek-ai/dsh-fs-patch/lib/index.js +275 -0
- package/node_modules/@deepseek-ai/dsh-fs-patch/package.json +35 -0
- package/node_modules/@deepseek-ai/dsh-fs-sandbox/README.i18n.yaml +6 -6
- package/node_modules/@deepseek-ai/dsh-fs-sandbox/README.md +4 -2
- package/node_modules/@deepseek-ai/dsh-fs-sandbox/README.zh.md +4 -2
- package/node_modules/@deepseek-ai/dsh-fs-sandbox/lib/index.js +24 -1
- package/node_modules/@deepseek-ai/dsh-goal/lib/typert.host.js +1 -1
- package/node_modules/@deepseek-ai/dsh-hmr/lib/index.js +4 -3
- package/node_modules/@deepseek-ai/dsh-llm/README.i18n.yaml +2 -2
- package/node_modules/@deepseek-ai/dsh-llm/README.md +2 -0
- package/node_modules/@deepseek-ai/dsh-llm/README.zh.md +2 -0
- package/node_modules/@deepseek-ai/dsh-llm/lib/typert.host.js +9 -1
- package/node_modules/@deepseek-ai/dsh-llm-deepseek/lib/index.js +4 -3
- package/node_modules/@deepseek-ai/dsh-llm-pi-ai/README.i18n.yaml +5 -2
- package/node_modules/@deepseek-ai/dsh-llm-pi-ai/README.md +7 -0
- package/node_modules/@deepseek-ai/dsh-llm-pi-ai/README.zh.md +7 -0
- package/node_modules/@deepseek-ai/dsh-llm-pi-ai/lib/index.js +27 -11
- package/node_modules/@deepseek-ai/dsh-official-bundles/README.i18n.yaml +2 -2
- package/node_modules/@deepseek-ai/dsh-official-bundles/README.md +1 -1
- package/node_modules/@deepseek-ai/dsh-official-bundles/README.zh.md +1 -1
- package/node_modules/@deepseek-ai/dsh-official-bundles/lib/index.js +86 -52
- package/node_modules/@deepseek-ai/dsh-permission-presets/lib/typert.host.js +1 -1
- package/node_modules/@deepseek-ai/dsh-plugin-manager/README.i18n.yaml +2 -2
- package/node_modules/@deepseek-ai/dsh-plugin-manager/README.md +4 -4
- package/node_modules/@deepseek-ai/dsh-plugin-manager/README.zh.md +4 -4
- package/node_modules/@deepseek-ai/dsh-plugin-manager/lib/index.js +32 -12
- package/node_modules/@deepseek-ai/dsh-plugin-manager/lib/typert.host.js +31 -31
- package/node_modules/@deepseek-ai/dsh-plugin-manager/lib/typert.remote-client.js +27 -27
- package/node_modules/@deepseek-ai/dsh-plugin-manager/lib/types/github-connection.js +13 -3
- package/node_modules/@deepseek-ai/dsh-plugin-manager/lib/types/index.js +14 -2
- package/node_modules/@deepseek-ai/dsh-plugin-manager/lib/types/install-spec.js +1 -1
- package/node_modules/@deepseek-ai/dsh-plugin-manager/lib/types/operations.js +2 -0
- package/node_modules/@deepseek-ai/dsh-plugin-recommendations/lib/typert.host.js +1 -1
- package/node_modules/@deepseek-ai/dsh-schedule/README.i18n.yaml +72 -39
- package/node_modules/@deepseek-ai/dsh-schedule/README.md +180 -56
- package/node_modules/@deepseek-ai/dsh-schedule/README.zh.md +185 -61
- package/node_modules/@deepseek-ai/dsh-schedule/lib/index.js +1270 -992
- package/node_modules/@deepseek-ai/dsh-schedule/lib/typert.host.js +1842 -274
- package/node_modules/@deepseek-ai/dsh-schedule/lib/typert.remote-client.js +1712 -194
- package/node_modules/@deepseek-ai/dsh-schedule/lib/types/delivery-history.js +7 -20
- package/node_modules/@deepseek-ai/dsh-schedule/lib/types/domain.js +199 -655
- package/node_modules/@deepseek-ai/dsh-schedule/lib/types/index.js +452 -204
- package/node_modules/@deepseek-ai/dsh-schedule/lib/types/runtime.js +389 -70
- package/node_modules/@deepseek-ai/dsh-schedule/lib/types/storage.js +85 -16
- package/node_modules/@deepseek-ai/dsh-schedule/lib/types/types.js +1 -1
- package/node_modules/@deepseek-ai/dsh-schedule/lib/types/update.js +72 -144
- package/node_modules/@deepseek-ai/dsh-schedule/package.json +5 -2
- package/node_modules/@deepseek-ai/dsh-sdk-app/README.i18n.yaml +12 -12
- package/node_modules/@deepseek-ai/dsh-sdk-app/README.md +7 -4
- package/node_modules/@deepseek-ai/dsh-sdk-app/README.zh.md +7 -4
- package/node_modules/@deepseek-ai/dsh-sdk-app/cordis.patch.yml +3 -0
- package/node_modules/@deepseek-ai/dsh-sdk-jsonrpc-server/README.i18n.yaml +52 -4
- package/node_modules/@deepseek-ai/dsh-sdk-jsonrpc-server/README.md +77 -1
- package/node_modules/@deepseek-ai/dsh-sdk-jsonrpc-server/README.zh.md +77 -1
- package/node_modules/@deepseek-ai/dsh-sdk-jsonrpc-server/lib/index.js +306 -2
- package/node_modules/@deepseek-ai/dsh-sdk-jsonrpc-server/package.json +15 -0
- package/node_modules/@deepseek-ai/dsh-sdk-protocol/README.i18n.yaml +4 -4
- package/node_modules/@deepseek-ai/dsh-sdk-protocol/README.md +10 -2
- package/node_modules/@deepseek-ai/dsh-sdk-protocol/README.zh.md +10 -2
- package/node_modules/@deepseek-ai/dsh-sdk-protocol/package.json +2 -0
- package/node_modules/@deepseek-ai/dsh-session-log-deepseek/README.i18n.yaml +9 -6
- package/node_modules/@deepseek-ai/dsh-session-log-deepseek/README.md +20 -1
- package/node_modules/@deepseek-ai/dsh-session-log-deepseek/README.zh.md +20 -1
- package/node_modules/@deepseek-ai/dsh-session-log-deepseek/lib/index.js +91 -57
- package/node_modules/@deepseek-ai/dsh-session-log-deepseek/lib/types/index.js +100 -66
- package/node_modules/@deepseek-ai/dsh-session-persistence-jsonl/lib/worker.cjs +947 -917
- package/node_modules/@deepseek-ai/dsh-session-reference/lib/typert.host.js +1 -1
- package/node_modules/@deepseek-ai/dsh-session-title-llm/README.i18n.yaml +2 -2
- package/node_modules/@deepseek-ai/dsh-session-title-llm/README.md +1 -1
- package/node_modules/@deepseek-ai/dsh-session-title-llm/README.zh.md +1 -1
- package/node_modules/@deepseek-ai/dsh-settings/lib/index.js +2 -2
- package/node_modules/@deepseek-ai/dsh-settings/lib/types/index.js +2 -2
- package/node_modules/@deepseek-ai/dsh-subagent/lib/typert.host.js +1 -1
- package/node_modules/@deepseek-ai/dsh-system-prompt/lib/index.js +2 -0
- package/node_modules/@deepseek-ai/dsh-tool-cordis/lib/types/api-catalog.js +260 -92
- package/node_modules/@deepseek-ai/dsh-tool-fs/README.i18n.yaml +38 -20
- package/node_modules/@deepseek-ai/dsh-tool-fs/README.md +63 -5
- package/node_modules/@deepseek-ai/dsh-tool-fs/README.zh.md +63 -5
- package/node_modules/@deepseek-ai/dsh-tool-fs/lib/index.js +784 -27
- package/node_modules/@deepseek-ai/dsh-tool-fs/package.json +4 -1
- package/node_modules/@deepseek-ai/dsh-tool-schedule/README.i18n.yaml +50 -32
- package/node_modules/@deepseek-ai/dsh-tool-schedule/README.md +47 -20
- package/node_modules/@deepseek-ai/dsh-tool-schedule/README.zh.md +47 -20
- package/node_modules/@deepseek-ai/dsh-tool-schedule/lib/index.js +477 -445
- package/node_modules/@deepseek-ai/dsh-tool-schedule/package.json +7 -2
- package/node_modules/@deepseek-ai/dsh-user-questions/lib/typert.host.js +1 -1
- package/node_modules/@deepseek-ai/dsh-util-time/README.i18n.yaml +10 -10
- package/node_modules/@deepseek-ai/dsh-util-time/README.md +11 -7
- package/node_modules/@deepseek-ai/dsh-util-time/README.zh.md +11 -7
- package/node_modules/@deepseek-ai/dsh-util-time/lib/index.js +1020 -3
- package/node_modules/@deepseek-ai/dsh-util-time/package.json +4 -2
- package/node_modules/@deepseek-ai/dsh-util-values/README.i18n.yaml +2 -2
- package/node_modules/@deepseek-ai/dsh-util-values/README.md +1 -1
- package/node_modules/@deepseek-ai/dsh-util-values/README.zh.md +1 -1
- package/node_modules/@deepseek-ai/dsh-util-values/lib/index.js +77 -92
- package/node_modules/@deepseek-ai/dsh-web-app/cordis.patch.yml +5 -1
- package/node_modules/@deepseek-ai/dsh-web-app/package.json +3 -1
- package/node_modules/@deepseek-ai/dsh-web-app/presets/cordis.patch.yml +3 -0
- package/node_modules/@deepseek-ai/dsh-web-app/presets/ptc.patch.yml +3 -0
- package/node_modules/@deepseek-ai/dsh-web-app/presets/standard.patch.yml +3 -0
- package/node_modules/@deepseek-ai/dsh-web-frontend/dist/assets/index-BCbHmUSs.js +197 -0
- package/node_modules/@deepseek-ai/dsh-web-frontend/dist/assets/index-BUDGJY4R.css +1 -0
- package/node_modules/@deepseek-ai/dsh-web-frontend/dist/index.html +2 -2
- package/node_modules/@deepseek-ai/dsh-workflow-ptc/lib/index.js +1 -1
- package/node_modules/@deepseek-ai/dsh-workspace-changes/README.i18n.yaml +4 -4
- package/node_modules/@deepseek-ai/dsh-workspace-changes/README.md +3 -1
- package/node_modules/@deepseek-ai/dsh-workspace-changes/README.zh.md +4 -2
- package/node_modules/@deepseek-ai/dsh-workspace-changes/lib/index.js +5 -0
- package/node_modules/@deepseek-ai/dsh-workspace-changes/lib/types/index.js +5 -0
- package/node_modules/@deepseek-ai/dsh-workspace-changes/package.json +4 -1
- package/node_modules/@opentelemetry/semantic-conventions/dist/experimental_attributes.cjs +16917 -0
- package/node_modules/@opentelemetry/semantic-conventions/dist/experimental_attributes.mjs +15193 -0
- package/node_modules/@opentelemetry/semantic-conventions/dist/experimental_events.cjs +325 -0
- package/node_modules/@opentelemetry/semantic-conventions/dist/experimental_events.mjs +295 -0
- package/node_modules/@opentelemetry/semantic-conventions/dist/experimental_metrics.cjs +4642 -0
- package/node_modules/@opentelemetry/semantic-conventions/dist/experimental_metrics.mjs +4155 -0
- package/node_modules/@opentelemetry/semantic-conventions/dist/index-incubating.cjs +2495 -0
- package/node_modules/@opentelemetry/semantic-conventions/dist/index-incubating.mjs +7 -0
- package/node_modules/@opentelemetry/semantic-conventions/dist/index.cjs +662 -0
- package/node_modules/@opentelemetry/semantic-conventions/dist/index.mjs +6 -0
- package/node_modules/@opentelemetry/semantic-conventions/dist/internal/utils.cjs +20 -0
- package/node_modules/@opentelemetry/semantic-conventions/dist/internal/utils.mjs +20 -0
- package/node_modules/@opentelemetry/semantic-conventions/dist/resource/SemanticResourceAttributes.cjs +1326 -0
- package/node_modules/@opentelemetry/semantic-conventions/dist/resource/SemanticResourceAttributes.mjs +1188 -0
- package/node_modules/@opentelemetry/semantic-conventions/dist/stable_attributes.cjs +1947 -0
- package/node_modules/@opentelemetry/semantic-conventions/dist/stable_attributes.mjs +1756 -0
- package/node_modules/@opentelemetry/semantic-conventions/dist/stable_events.cjs +9 -0
- package/node_modules/@opentelemetry/semantic-conventions/dist/stable_events.mjs +9 -0
- package/node_modules/@opentelemetry/semantic-conventions/dist/stable_metrics.cjs +362 -0
- package/node_modules/@opentelemetry/semantic-conventions/dist/stable_metrics.mjs +312 -0
- package/node_modules/@opentelemetry/semantic-conventions/dist/trace/SemanticAttributes.cjs +2508 -0
- package/node_modules/@opentelemetry/semantic-conventions/dist/trace/SemanticAttributes.mjs +2236 -0
- package/node_modules/@opentelemetry/semantic-conventions/package.json +22 -35
- package/node_modules/@smithy/core/dist-cjs/index.js +4 -2
- package/node_modules/@smithy/core/dist-cjs/submodules/cbor/index.js +32 -16
- package/node_modules/@smithy/core/dist-cjs/submodules/client/index.js +26 -13
- package/node_modules/@smithy/core/dist-cjs/submodules/config/index.browser.js +8 -4
- package/node_modules/@smithy/core/dist-cjs/submodules/config/index.js +16 -8
- package/node_modules/@smithy/core/dist-cjs/submodules/config/index.native.js +8 -4
- package/node_modules/@smithy/core/dist-cjs/submodules/endpoints/index.browser.js +2 -1
- package/node_modules/@smithy/core/dist-cjs/submodules/endpoints/index.js +10 -5
- package/node_modules/@smithy/core/dist-cjs/submodules/event-streams/index.browser.js +18 -9
- package/node_modules/@smithy/core/dist-cjs/submodules/event-streams/index.js +18 -9
- package/node_modules/@smithy/core/dist-cjs/submodules/protocols/index.js +42 -24
- package/node_modules/@smithy/core/dist-cjs/submodules/retry/index.browser.js +20 -10
- package/node_modules/@smithy/core/dist-cjs/submodules/retry/index.js +24 -12
- package/node_modules/@smithy/core/dist-cjs/submodules/serde/index.browser.js +13 -4
- package/node_modules/@smithy/core/dist-cjs/submodules/serde/index.js +7 -1
- package/node_modules/@smithy/core/dist-cjs/submodules/serde/index.native.js +13 -4
- package/node_modules/@smithy/core/dist-cjs/submodules/transport/index.js +6 -3
- package/node_modules/@smithy/core/dist-es/legacy-root-exports/util-identity-and-auth/DefaultIdentityProviderConfig.js +2 -1
- package/node_modules/@smithy/core/dist-es/normalizeProvider.js +2 -1
- package/node_modules/@smithy/core/dist-es/submodules/cbor/codec-v1/CborShapeDeserializer.js +8 -4
- package/node_modules/@smithy/core/dist-es/submodules/cbor/codec-v1/CborShapeSerializer.js +6 -3
- package/node_modules/@smithy/core/dist-es/submodules/cbor/codec-v2/CborShapeDeserializer2.js +12 -6
- package/node_modules/@smithy/core/dist-es/submodules/cbor/codec-v2/CborShapeSerializer2.js +4 -2
- package/node_modules/@smithy/core/dist-es/submodules/cbor/parseCborBody.js +2 -1
- package/node_modules/@smithy/core/dist-es/submodules/client/middleware-stack/MiddlewareStack.js +10 -5
- package/node_modules/@smithy/core/dist-es/submodules/client/smithy-client/create-aggregated-client.js +2 -1
- package/node_modules/@smithy/core/dist-es/submodules/client/smithy-client/exceptions.js +4 -2
- package/node_modules/@smithy/core/dist-es/submodules/client/smithy-client/extensions/checksum.js +2 -1
- package/node_modules/@smithy/core/dist-es/submodules/client/smithy-client/get-value-from-text-node.js +2 -1
- package/node_modules/@smithy/core/dist-es/submodules/client/smithy-client/object-mapping.js +4 -2
- package/node_modules/@smithy/core/dist-es/submodules/client/smithy-client/serde-json.js +2 -1
- package/node_modules/@smithy/core/dist-es/submodules/config/shared-ini-file-loader/getHomeDir.js +8 -4
- package/node_modules/@smithy/core/dist-es/submodules/config/util-config-provider/booleanSelector.js +6 -3
- package/node_modules/@smithy/core/dist-es/submodules/config/util-config-provider/numberSelector.js +2 -1
- package/node_modules/@smithy/core/dist-es/submodules/endpoints/middleware-endpoint/adaptors/getEndpointUrlConfig.js +8 -4
- package/node_modules/@smithy/core/dist-es/submodules/endpoints/util-endpoints/resolveEndpoint.js +2 -1
- package/node_modules/@smithy/core/dist-es/submodules/event-streams/EventStreamSerde.js +6 -3
- package/node_modules/@smithy/core/dist-es/submodules/event-streams/eventstream-codec/HeaderMarshaller.js +2 -1
- package/node_modules/@smithy/core/dist-es/submodules/event-streams/eventstream-codec/Int64.js +2 -1
- package/node_modules/@smithy/core/dist-es/submodules/event-streams/eventstream-codec/SmithyMessageDecoderStream.js +2 -1
- package/node_modules/@smithy/core/dist-es/submodules/event-streams/eventstream-serde/utils.js +2 -1
- package/node_modules/@smithy/core/dist-es/submodules/event-streams/eventstream-serde-universal/getUnmarshalledStream.js +4 -2
- package/node_modules/@smithy/core/dist-es/submodules/protocols/HttpBindingProtocol.js +8 -4
- package/node_modules/@smithy/core/dist-es/submodules/protocols/HttpProtocol.js +4 -2
- package/node_modules/@smithy/core/dist-es/submodules/protocols/RpcProtocol.js +2 -1
- package/node_modules/@smithy/core/dist-es/submodules/protocols/json/codec-v1/JsonShapeDeserializer.js +7 -5
- package/node_modules/@smithy/core/dist-es/submodules/protocols/json/codec-v1/JsonShapeSerializer.js +7 -5
- package/node_modules/@smithy/core/dist-es/submodules/protocols/json/codec-v2/JsonShapeDeserializer2.js +7 -5
- package/node_modules/@smithy/core/dist-es/submodules/protocols/json/codec-v2/JsonShapeSerializer2.js +6 -3
- package/node_modules/@smithy/core/dist-es/submodules/protocols/protocol-http/extensions/httpExtensionConfiguration.js +3 -0
- package/node_modules/@smithy/core/dist-es/submodules/retry/middleware-retry/configurations.js +4 -2
- package/node_modules/@smithy/core/dist-es/submodules/retry/middleware-retry/parseRetryAfterHeader.js +2 -1
- package/node_modules/@smithy/core/dist-es/submodules/retry/middleware-retry/retry-pre-sra-deprecated/StandardRetryStrategy.js +6 -3
- package/node_modules/@smithy/core/dist-es/submodules/retry/middleware-retry/retryMiddleware.js +6 -3
- package/node_modules/@smithy/core/dist-es/submodules/retry/middleware-retry/util.js +6 -3
- package/node_modules/@smithy/core/dist-es/submodules/serde/index.browser.js +1 -0
- package/node_modules/@smithy/core/dist-es/submodules/serde/index.js +1 -0
- package/node_modules/@smithy/core/dist-es/submodules/serde/index.native.js +1 -0
- package/node_modules/@smithy/core/dist-es/submodules/serde/parse-utils.js +2 -1
- package/node_modules/@smithy/core/dist-es/submodules/serde/util-body-length/calculateBodyLength.browser.js +6 -3
- package/node_modules/@smithy/core/dist-es/submodules/transport/httpResponse.js +2 -1
- package/node_modules/@smithy/core/dist-es/submodules/transport/normalizeProvider.js +2 -1
- package/node_modules/@smithy/core/dist-es/submodules/transport/toEndpointV1.js +2 -1
- package/node_modules/@smithy/core/package.json +1 -1
- package/node_modules/@smithy/node-http-handler/dist-cjs/index.js +19 -7
- package/node_modules/@smithy/node-http-handler/dist-es/get-transformed-headers.js +2 -1
- package/node_modules/@smithy/node-http-handler/dist-es/node-http-handler.js +11 -6
- package/node_modules/@smithy/node-http-handler/dist-es/node-http2-handler.js +6 -0
- package/node_modules/@smithy/node-http-handler/package.json +2 -2
- package/node_modules/@smithy/signature-v4/dist-cjs/index.js +23 -11
- package/node_modules/@smithy/signature-v4/dist-es/HeaderFormatter.js +4 -2
- package/node_modules/@smithy/signature-v4/dist-es/SignatureV4Base.js +4 -2
- package/node_modules/@smithy/signature-v4/dist-es/getCanonicalHeaders.js +5 -1
- package/node_modules/@smithy/signature-v4/dist-es/getCanonicalQuery.js +2 -1
- package/node_modules/@smithy/signature-v4/dist-es/getPayloadHash.js +2 -1
- package/node_modules/@smithy/signature-v4/dist-es/headerUtil.js +6 -3
- package/node_modules/@smithy/signature-v4/dist-es/moveHeadersToQuery.js +2 -1
- package/node_modules/@smithy/signature-v4/dist-es/prepareRequest.js +2 -1
- package/node_modules/@smithy/signature-v4/package.json +2 -2
- package/node_modules/@types/node/README.md +1 -1
- package/node_modules/@types/node/package.json +2 -2
- package/node_modules/encodeurl/README.md +14 -0
- package/node_modules/encodeurl/index.js +5 -10
- package/node_modules/encodeurl/package.json +7 -3
- package/node_modules/hast-util-to-html/lib/handle/comment.js +6 -1
- package/node_modules/hast-util-to-html/lib/handle/doctype.js +1 -1
- package/node_modules/hast-util-to-html/lib/handle/element.js +33 -9
- package/node_modules/hast-util-to-html/lib/handle/index.js +1 -1
- package/node_modules/hast-util-to-html/lib/handle/raw.js +1 -1
- package/node_modules/hast-util-to-html/lib/handle/root.js +1 -1
- package/node_modules/hast-util-to-html/lib/handle/text.js +1 -1
- package/node_modules/hast-util-to-html/lib/index.js +9 -4
- package/node_modules/hast-util-to-html/lib/omission/closing.js +7 -5
- package/node_modules/hast-util-to-html/lib/omission/omission.js +0 -1
- package/node_modules/hast-util-to-html/lib/omission/opening.js +4 -2
- package/node_modules/hast-util-to-html/lib/omission/util/siblings.js +3 -0
- package/node_modules/hast-util-to-html/package.json +5 -23
- package/node_modules/hast-util-to-html/readme.md +3 -2
- package/node_modules/jose/dist/webapi/jwks/remote.js +1 -1
- package/node_modules/jose/package.json +1 -1
- package/node_modules/rrule/LICENCE +65 -0
- package/node_modules/rrule/README.md +837 -0
- package/node_modules/rrule/dist/es5/rrule.js +3803 -0
- package/node_modules/rrule/dist/es5/rrule.min.js +2 -0
- package/node_modules/rrule/dist/esm/cache.js +95 -0
- package/node_modules/rrule/dist/esm/callbackiterresult.js +24 -0
- package/node_modules/rrule/dist/esm/datetime.js +186 -0
- package/node_modules/rrule/dist/esm/dateutil.js +161 -0
- package/node_modules/rrule/dist/esm/datewithzone.js +36 -0
- package/node_modules/rrule/dist/esm/helpers.js +118 -0
- package/node_modules/rrule/dist/esm/index.js +22 -0
- package/node_modules/rrule/dist/esm/iter/index.js +138 -0
- package/node_modules/rrule/dist/esm/iter/poslist.js +42 -0
- package/node_modules/rrule/dist/esm/iterinfo/easter.js +21 -0
- package/node_modules/rrule/dist/esm/iterinfo/index.js +188 -0
- package/node_modules/rrule/dist/esm/iterinfo/monthinfo.js +51 -0
- package/node_modules/rrule/dist/esm/iterinfo/yearinfo.js +128 -0
- package/node_modules/rrule/dist/esm/iterresult.js +88 -0
- package/node_modules/rrule/dist/esm/iterset.js +63 -0
- package/node_modules/rrule/dist/esm/masks.js +30 -0
- package/node_modules/rrule/dist/esm/nlp/i18n.js +74 -0
- package/node_modules/rrule/dist/esm/nlp/index.js +122 -0
- package/node_modules/rrule/dist/esm/nlp/parsetext.js +391 -0
- package/node_modules/rrule/dist/esm/nlp/totext.js +395 -0
- package/node_modules/rrule/dist/esm/optionstostring.js +98 -0
- package/node_modules/rrule/dist/esm/parseoptions.js +201 -0
- package/node_modules/rrule/dist/esm/parsestring.js +128 -0
- package/node_modules/rrule/dist/esm/rrule.js +232 -0
- package/node_modules/rrule/dist/esm/rruleset.js +182 -0
- package/node_modules/rrule/dist/esm/rrulestr.js +188 -0
- package/node_modules/rrule/dist/esm/types.js +14 -0
- package/node_modules/rrule/dist/esm/weekday.js +45 -0
- package/node_modules/rrule/package.json +79 -0
- package/package.json +32 -31
- package/node_modules/@deepseek-ai/dsh-computer-use/README.i18n.yaml +0 -37
- package/node_modules/@deepseek-ai/dsh-computer-use/README.md +0 -90
- package/node_modules/@deepseek-ai/dsh-computer-use/README.zh.md +0 -90
- package/node_modules/@deepseek-ai/dsh-computer-use/lib/index.js +0 -35
- package/node_modules/@deepseek-ai/dsh-computer-use/lib/types/brand.js +0 -10
- package/node_modules/@deepseek-ai/dsh-computer-use/lib/types/index.js +0 -36
- package/node_modules/@deepseek-ai/dsh-computer-use/locale/de.json +0 -6
- package/node_modules/@deepseek-ai/dsh-computer-use/locale/en.json +0 -6
- package/node_modules/@deepseek-ai/dsh-computer-use/locale/es.json +0 -6
- package/node_modules/@deepseek-ai/dsh-computer-use/locale/fr.json +0 -6
- package/node_modules/@deepseek-ai/dsh-computer-use/locale/ja.json +0 -6
- package/node_modules/@deepseek-ai/dsh-computer-use/locale/pt.json +0 -6
- package/node_modules/@deepseek-ai/dsh-computer-use/locale/ru.json +0 -6
- package/node_modules/@deepseek-ai/dsh-computer-use/locale/zh.json +0 -6
- package/node_modules/@deepseek-ai/dsh-computer-use/package.json +0 -44
- package/node_modules/@deepseek-ai/dsh-cua/README.i18n.yaml +0 -49
- package/node_modules/@deepseek-ai/dsh-cua/README.md +0 -130
- package/node_modules/@deepseek-ai/dsh-cua/README.zh.md +0 -130
- package/node_modules/@deepseek-ai/dsh-cua/lib/api.js +0 -597
- package/node_modules/@deepseek-ai/dsh-cua/lib/bridge.js +0 -611
- package/node_modules/@deepseek-ai/dsh-cua/lib/client.js +0 -1758
- package/node_modules/@deepseek-ai/dsh-cua/lib/index.js +0 -1916
- package/node_modules/@deepseek-ai/dsh-cua/lib/native-client.js +0 -285
- package/node_modules/@deepseek-ai/dsh-cua/lib/protocol.js +0 -305
- package/node_modules/@deepseek-ai/dsh-cua/lib/remote-types.js +0 -1
- package/node_modules/@deepseek-ai/dsh-cua/lib/typert.host.js +0 -416
- package/node_modules/@deepseek-ai/dsh-cua/lib/typert.remote-client.js +0 -301
- package/node_modules/@deepseek-ai/dsh-cua/locale/de.json +0 -6
- package/node_modules/@deepseek-ai/dsh-cua/locale/en.json +0 -6
- package/node_modules/@deepseek-ai/dsh-cua/locale/es.json +0 -6
- package/node_modules/@deepseek-ai/dsh-cua/locale/fr.json +0 -6
- package/node_modules/@deepseek-ai/dsh-cua/locale/ja.json +0 -6
- package/node_modules/@deepseek-ai/dsh-cua/locale/pt.json +0 -6
- package/node_modules/@deepseek-ai/dsh-cua/locale/ru.json +0 -6
- package/node_modules/@deepseek-ai/dsh-cua/locale/zh.json +0 -6
- package/node_modules/@deepseek-ai/dsh-cua/package.json +0 -151
- package/node_modules/@deepseek-ai/dsh-cua-bundle/README.i18n.yaml +0 -46
- package/node_modules/@deepseek-ai/dsh-cua-bundle/README.md +0 -94
- package/node_modules/@deepseek-ai/dsh-cua-bundle/README.zh.md +0 -94
- package/node_modules/@deepseek-ai/dsh-cua-bundle/cordis.patch.yml +0 -10
- package/node_modules/@deepseek-ai/dsh-cua-bundle/docs/DETAIL.md +0 -1
- package/node_modules/@deepseek-ai/dsh-cua-bundle/docs/DETAIL.zh.md +0 -1
- package/node_modules/@deepseek-ai/dsh-cua-bundle/docs/preview.svg +0 -33
- package/node_modules/@deepseek-ai/dsh-cua-bundle/docs/preview.zh.svg +0 -33
- package/node_modules/@deepseek-ai/dsh-cua-bundle/icon.svg +0 -35
- package/node_modules/@deepseek-ai/dsh-cua-bundle/lib/index.js +0 -1
- package/node_modules/@deepseek-ai/dsh-cua-bundle/locale/de.json +0 -7
- package/node_modules/@deepseek-ai/dsh-cua-bundle/locale/en.json +0 -7
- package/node_modules/@deepseek-ai/dsh-cua-bundle/locale/es.json +0 -7
- package/node_modules/@deepseek-ai/dsh-cua-bundle/locale/fr.json +0 -7
- package/node_modules/@deepseek-ai/dsh-cua-bundle/locale/ja.json +0 -7
- package/node_modules/@deepseek-ai/dsh-cua-bundle/locale/pt.json +0 -7
- package/node_modules/@deepseek-ai/dsh-cua-bundle/locale/ru.json +0 -7
- package/node_modules/@deepseek-ai/dsh-cua-bundle/locale/zh.json +0 -7
- package/node_modules/@deepseek-ai/dsh-cua-bundle/package.json +0 -58
- package/node_modules/@deepseek-ai/dsh-web-frontend/dist/assets/index--TtJvO-i.js +0 -197
- package/node_modules/@deepseek-ai/dsh-web-frontend/dist/assets/index-Jtzf36XE.css +0 -1
- package/node_modules/@opentelemetry/semantic-conventions/build/esm/experimental_attributes.js +0 -14991
- package/node_modules/@opentelemetry/semantic-conventions/build/esm/experimental_events.js +0 -298
- package/node_modules/@opentelemetry/semantic-conventions/build/esm/experimental_metrics.js +0 -4060
- package/node_modules/@opentelemetry/semantic-conventions/build/esm/index-incubating.js +0 -13
- package/node_modules/@opentelemetry/semantic-conventions/build/esm/index.js +0 -16
- package/node_modules/@opentelemetry/semantic-conventions/build/esm/internal/utils.js +0 -23
- package/node_modules/@opentelemetry/semantic-conventions/build/esm/resource/SemanticResourceAttributes.js +0 -1250
- package/node_modules/@opentelemetry/semantic-conventions/build/esm/resource/index.js +0 -10
- package/node_modules/@opentelemetry/semantic-conventions/build/esm/stable_attributes.js +0 -1733
- package/node_modules/@opentelemetry/semantic-conventions/build/esm/stable_events.js +0 -12
- package/node_modules/@opentelemetry/semantic-conventions/build/esm/stable_metrics.js +0 -315
- package/node_modules/@opentelemetry/semantic-conventions/build/esm/trace/SemanticAttributes.js +0 -2360
- package/node_modules/@opentelemetry/semantic-conventions/build/esm/trace/index.js +0 -10
- package/node_modules/@opentelemetry/semantic-conventions/build/esm/version.js +0 -7
- package/node_modules/@opentelemetry/semantic-conventions/build/esnext/experimental_attributes.js +0 -14991
- package/node_modules/@opentelemetry/semantic-conventions/build/esnext/experimental_events.js +0 -298
- package/node_modules/@opentelemetry/semantic-conventions/build/esnext/experimental_metrics.js +0 -4060
- package/node_modules/@opentelemetry/semantic-conventions/build/esnext/index-incubating.js +0 -13
- package/node_modules/@opentelemetry/semantic-conventions/build/esnext/index.js +0 -16
- package/node_modules/@opentelemetry/semantic-conventions/build/esnext/internal/utils.js +0 -23
- package/node_modules/@opentelemetry/semantic-conventions/build/esnext/resource/SemanticResourceAttributes.js +0 -1250
- package/node_modules/@opentelemetry/semantic-conventions/build/esnext/resource/index.js +0 -10
- package/node_modules/@opentelemetry/semantic-conventions/build/esnext/stable_attributes.js +0 -1733
- package/node_modules/@opentelemetry/semantic-conventions/build/esnext/stable_events.js +0 -12
- package/node_modules/@opentelemetry/semantic-conventions/build/esnext/stable_metrics.js +0 -315
- package/node_modules/@opentelemetry/semantic-conventions/build/esnext/trace/SemanticAttributes.js +0 -2360
- package/node_modules/@opentelemetry/semantic-conventions/build/esnext/trace/index.js +0 -10
- package/node_modules/@opentelemetry/semantic-conventions/build/esnext/version.js +0 -7
- package/node_modules/@opentelemetry/semantic-conventions/build/src/experimental_attributes.js +0 -15049
- package/node_modules/@opentelemetry/semantic-conventions/build/src/experimental_events.js +0 -301
- package/node_modules/@opentelemetry/semantic-conventions/build/src/experimental_metrics.js +0 -4072
- package/node_modules/@opentelemetry/semantic-conventions/build/src/index-incubating.js +0 -29
- package/node_modules/@opentelemetry/semantic-conventions/build/src/index.js +0 -32
- package/node_modules/@opentelemetry/semantic-conventions/build/src/internal/utils.js +0 -27
- package/node_modules/@opentelemetry/semantic-conventions/build/src/resource/SemanticResourceAttributes.js +0 -1255
- package/node_modules/@opentelemetry/semantic-conventions/build/src/resource/index.js +0 -26
- package/node_modules/@opentelemetry/semantic-conventions/build/src/stable_attributes.js +0 -1759
- package/node_modules/@opentelemetry/semantic-conventions/build/src/stable_events.js +0 -15
- package/node_modules/@opentelemetry/semantic-conventions/build/src/stable_metrics.js +0 -319
- package/node_modules/@opentelemetry/semantic-conventions/build/src/trace/SemanticAttributes.js +0 -2368
- package/node_modules/@opentelemetry/semantic-conventions/build/src/trace/index.js +0 -26
- package/node_modules/@opentelemetry/semantic-conventions/build/src/version.js +0 -10
- /package/node_modules/@smithy/core/dist-es/submodules/{protocols → serde}/writeKey.js +0 -0
|
@@ -34,6 +34,7 @@ var DisposableList = class {
|
|
|
34
34
|
/** Shared symbols used to avoid public property-name collisions. */
|
|
35
35
|
const symbols = {
|
|
36
36
|
shadow: Symbol.for("cordis.shadow"),
|
|
37
|
+
caller: Symbol.for("cordis.caller"),
|
|
37
38
|
receiver: Symbol.for("cordis.receiver"),
|
|
38
39
|
original: Symbol.for("cordis.original"),
|
|
39
40
|
metadata: Symbol.for("cordis.metadata"),
|
|
@@ -108,11 +109,12 @@ function withProp(target, prop, value) {
|
|
|
108
109
|
writable: false
|
|
109
110
|
}));
|
|
110
111
|
}
|
|
111
|
-
function createShadow(
|
|
112
|
+
function createShadow(useSite, target, property, receiver) {
|
|
112
113
|
if (!property) return receiver;
|
|
113
|
-
const
|
|
114
|
-
if (!
|
|
115
|
-
|
|
114
|
+
const value = getPropertyDescriptor(target, property)?.value;
|
|
115
|
+
if (!value) return receiver;
|
|
116
|
+
const defSite = value[symbols.shadow] ?? value;
|
|
117
|
+
return withProp(receiver, property, useSite.extend({ [symbols.shadow]: defSite }));
|
|
116
118
|
}
|
|
117
119
|
function createShadowMethod(ctx, value, outer, shadow) {
|
|
118
120
|
return new Proxy(value, { apply: (target, thisArg, args) => {
|
|
@@ -121,37 +123,40 @@ function createShadowMethod(ctx, value, outer, shadow) {
|
|
|
121
123
|
} });
|
|
122
124
|
}
|
|
123
125
|
function createTraceable(ctx, value, tracker) {
|
|
124
|
-
|
|
126
|
+
const defSite = ctx[symbols.shadow] ?? ctx;
|
|
127
|
+
const useSite = ctx[symbols.shadow] ? Object.getPrototypeOf(ctx) : ctx;
|
|
125
128
|
const proxy = new Proxy(value, {
|
|
126
129
|
get: (target, prop, receiver) => {
|
|
127
130
|
if (prop === symbols.original) return target;
|
|
128
|
-
if (prop ===
|
|
131
|
+
if (prop === symbols.caller) return defSite;
|
|
132
|
+
if (prop === tracker.property) return useSite;
|
|
129
133
|
if (typeof prop === "symbol") return Reflect.get(target, prop, receiver);
|
|
130
|
-
if (tracker.associate &&
|
|
134
|
+
if (tracker.associate && useSite.reflect.props[`${tracker.associate}.${prop}`]) return Reflect.get(ctx, `${tracker.associate}.${prop}`, withProp(ctx, symbols.receiver, receiver));
|
|
131
135
|
let shadow, innerValue;
|
|
132
136
|
const desc = getPropertyDescriptor(target, prop);
|
|
133
137
|
if (desc && "value" in desc) innerValue = desc.value;
|
|
134
138
|
else {
|
|
135
|
-
shadow = createShadow(
|
|
139
|
+
shadow = createShadow(useSite, target, tracker.property, receiver);
|
|
136
140
|
innerValue = Reflect.get(target, prop, shadow);
|
|
137
141
|
}
|
|
138
142
|
const innerTracker = innerValue?.[symbols.tracker];
|
|
139
|
-
if (innerTracker) return createTraceable(
|
|
143
|
+
if (innerTracker) return createTraceable(useSite, innerValue, innerTracker);
|
|
140
144
|
else if (!tracker.noShadow && typeof innerValue === "function") {
|
|
141
|
-
shadow ??= createShadow(
|
|
142
|
-
return createShadowMethod(
|
|
145
|
+
shadow ??= createShadow(useSite, target, tracker.property, receiver);
|
|
146
|
+
return createShadowMethod(useSite, innerValue, receiver, shadow);
|
|
143
147
|
} else return innerValue;
|
|
144
148
|
},
|
|
145
149
|
set: (target, prop, value, receiver) => {
|
|
146
150
|
if (prop === symbols.original) return false;
|
|
151
|
+
if (prop === symbols.caller) return false;
|
|
147
152
|
if (prop === tracker.property) return false;
|
|
148
153
|
if (typeof prop === "symbol") return Reflect.set(target, prop, value, receiver);
|
|
149
|
-
if (tracker.associate &&
|
|
150
|
-
const shadow = createShadow(
|
|
154
|
+
if (tracker.associate && useSite.reflect.props[`${tracker.associate}.${prop}`]) return Reflect.set(ctx, `${tracker.associate}.${prop}`, value, withProp(ctx, symbols.receiver, receiver));
|
|
155
|
+
const shadow = createShadow(useSite, target, tracker.property, receiver);
|
|
151
156
|
return Reflect.set(target, prop, value, shadow);
|
|
152
157
|
},
|
|
153
158
|
apply: (target, thisArg, args) => {
|
|
154
|
-
return applyTraceable(proxy, target, thisArg, args);
|
|
159
|
+
return applyTraceable(tracker.noShadow ? proxy : createShadow(useSite, target, tracker.property, proxy), target, thisArg, args);
|
|
155
160
|
}
|
|
156
161
|
});
|
|
157
162
|
return proxy;
|
|
@@ -163,7 +168,8 @@ function applyTraceable(proxy, value, thisArg, args) {
|
|
|
163
168
|
/** Create a callable service object that dispatches through `symbols.invoke`. */
|
|
164
169
|
function createCallable(name, proto, tracker) {
|
|
165
170
|
const self = function(...args) {
|
|
166
|
-
|
|
171
|
+
const proxy = createTraceable(self["ctx"], self, tracker);
|
|
172
|
+
return Reflect.apply(proxy, this, args);
|
|
167
173
|
};
|
|
168
174
|
defineProperty(self, "name", name);
|
|
169
175
|
return Object.setPrototypeOf(self, proto);
|
|
@@ -209,199 +215,772 @@ function buildOuterStack(offset = 0) {
|
|
|
209
215
|
return () => outerError.stack.split("\n").slice(3 + offset);
|
|
210
216
|
}
|
|
211
217
|
//#endregion
|
|
212
|
-
//#region lib/types/
|
|
218
|
+
//#region lib/types/fiber.js
|
|
219
|
+
const kValidationError = Symbol.for("ValidationError");
|
|
220
|
+
/** Error raised when plugin configuration fails standard-schema validation. */
|
|
221
|
+
var ValidationError = class extends TypeError {
|
|
222
|
+
name = "ValidationError";
|
|
223
|
+
/**
|
|
224
|
+
* Build the aggregated message from schema issues.
|
|
225
|
+
*
|
|
226
|
+
* @param issues — the standard-schema issues, one message line each.
|
|
227
|
+
*/
|
|
228
|
+
constructor(issues) {
|
|
229
|
+
super(`invalid config:\n` + issues.map((issue) => {
|
|
230
|
+
if (issue.path) return ` - ${issue.message} (at ${issue.path.join(".")})`;
|
|
231
|
+
else return ` - ${issue.message}`;
|
|
232
|
+
}).join("\n"));
|
|
233
|
+
}
|
|
234
|
+
};
|
|
235
|
+
Object.defineProperty(ValidationError.prototype, kValidationError, { value: true });
|
|
213
236
|
/**
|
|
214
|
-
*
|
|
237
|
+
* Validate and normalize config for a plugin runtime before it starts.
|
|
215
238
|
*
|
|
216
|
-
* @param
|
|
217
|
-
* @
|
|
239
|
+
* @param runtime — the plugin runtime whose `Config` schema to apply.
|
|
240
|
+
* @param config — the raw user config.
|
|
241
|
+
* @returns the validated config, or `config` unchanged if the runtime has no schema.
|
|
242
|
+
* @throws {ValidationError} when validation reports issues.
|
|
218
243
|
*/
|
|
219
|
-
function
|
|
220
|
-
|
|
244
|
+
function resolveConfig(runtime, config) {
|
|
245
|
+
if (!runtime.Config) return config;
|
|
246
|
+
const result = runtime.Config["~standard"].validate(config);
|
|
247
|
+
if ("then" in result) throw new TypeError("Async config validation is not supported");
|
|
248
|
+
if (result.issues) throw new ValidationError(result.issues);
|
|
249
|
+
else return result.value;
|
|
221
250
|
}
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
*/
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
});
|
|
237
|
-
this.on("internal/listener", function(name, listener, options) {
|
|
238
|
-
if (name === "internal/update" && !options.global) return (this.fiber._hooks["internal/update"] ??= new DisposableList())[options.prepend ? "unshift" : "push"](listener);
|
|
239
|
-
});
|
|
240
|
-
this.on("internal/update", function(config, noSave, next) {
|
|
241
|
-
const cbs = [...this._hooks["internal/update"] || []];
|
|
242
|
-
const _next = () => {
|
|
243
|
-
return (cbs.shift() ?? next).call(this, config, noSave, _next);
|
|
244
|
-
};
|
|
245
|
-
return _next();
|
|
246
|
-
}, {
|
|
247
|
-
global: true,
|
|
248
|
-
prepend: true
|
|
249
|
-
});
|
|
250
|
-
}
|
|
251
|
-
/**
|
|
252
|
-
* Resolve listeners for one dispatch and apply context filtering.
|
|
253
|
-
*
|
|
254
|
-
* @param type — the dispatch mode, reported on `internal/dispatch`.
|
|
255
|
-
* @param args — the raw dispatch arguments; consumed up to the event name.
|
|
256
|
-
* @returns the matching listener callbacks, bound to the dispatch `this`.
|
|
257
|
-
*/
|
|
258
|
-
dispatch(type, args) {
|
|
259
|
-
const thisArg = typeof args[0] === "object" || typeof args[0] === "function" ? args.shift() : null;
|
|
260
|
-
const name = args.shift();
|
|
261
|
-
if (!name.startsWith("internal/")) this.emit("internal/dispatch", type, name, args, thisArg);
|
|
262
|
-
const filter = thisArg?.[Context.filter];
|
|
263
|
-
return (this._hooks[name] || []).filter((hook) => hook.global || !filter || filter.call(thisArg, hook.ctx)).map((hook) => hook.callback.bind(thisArg));
|
|
251
|
+
const effectInertia = /* @__PURE__ */ new WeakMap();
|
|
252
|
+
function runDisposable(dispose) {
|
|
253
|
+
const result = dispose();
|
|
254
|
+
return effectInertia.get(dispose)?.() ?? result;
|
|
255
|
+
}
|
|
256
|
+
/** Notify plugin teardown without allowing one observer to break ownership cleanup. */
|
|
257
|
+
function emitPluginDisposed(context, fiber) {
|
|
258
|
+
const args = ["internal/plugin", fiber];
|
|
259
|
+
let callbacks;
|
|
260
|
+
try {
|
|
261
|
+
callbacks = context.events.dispatch("emit", args);
|
|
262
|
+
} catch (error) {
|
|
263
|
+
context.logger.error(error);
|
|
264
|
+
return;
|
|
264
265
|
}
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
*/
|
|
271
|
-
async parallel(...args) {
|
|
272
|
-
const errors = (await Promise.allSettled(this.dispatch("emit", args).map(async (cb) => cb(...args)))).filter((result) => result.status === "rejected");
|
|
273
|
-
if (errors.length) throw new AggregateError(errors.map((error) => error.reason));
|
|
266
|
+
for (const callback of callbacks) try {
|
|
267
|
+
const returned = callback(...args);
|
|
268
|
+
Promise.resolve(returned).catch((error) => context.logger.error(error));
|
|
269
|
+
} catch (error) {
|
|
270
|
+
context.logger.error(error);
|
|
274
271
|
}
|
|
272
|
+
}
|
|
273
|
+
/** Framework error with a stable machine-readable code. */
|
|
274
|
+
var CordisError = class CordisError extends Error {
|
|
275
|
+
code;
|
|
275
276
|
/**
|
|
276
|
-
*
|
|
277
|
-
*
|
|
278
|
-
* @param args — optional `this`, the event name, then listener arguments.
|
|
277
|
+
* @param code — the stable error code; also the default message.
|
|
278
|
+
* @param message — optional human-readable override.
|
|
279
279
|
*/
|
|
280
|
-
|
|
281
|
-
|
|
280
|
+
constructor(code, message) {
|
|
281
|
+
super(message ?? CordisError.Code[code]);
|
|
282
|
+
this.code = code;
|
|
282
283
|
}
|
|
284
|
+
};
|
|
285
|
+
/** Cordis error code definitions. */
|
|
286
|
+
(function(CordisError) {
|
|
287
|
+
CordisError.Code = { INACTIVE_EFFECT: "cannot create effect on inactive context" };
|
|
288
|
+
})(CordisError || (CordisError = {}));
|
|
289
|
+
const INACTIVE = "__INACTIVE__";
|
|
290
|
+
/**
|
|
291
|
+
* Runtime instance of one plugin application.
|
|
292
|
+
*
|
|
293
|
+
* A fiber tracks dependency state, raw and effective config, lifecycle effects, and
|
|
294
|
+
* cleanup for the plugin context returned by `ctx.plugin()`.
|
|
295
|
+
*/
|
|
296
|
+
var Fiber = class {
|
|
297
|
+
parent;
|
|
298
|
+
inject;
|
|
299
|
+
runtime;
|
|
300
|
+
/** Unique id within the registry; 0 for the root fiber, `null` once disposed. */
|
|
301
|
+
uid;
|
|
302
|
+
/** The context this fiber's plugin runs in (extends the parent context). */
|
|
303
|
+
ctx;
|
|
304
|
+
/** Raw plugin input retained for the next activation. */
|
|
305
|
+
config;
|
|
306
|
+
/** Current lifecycle state; transitions emit `internal/status`. */
|
|
307
|
+
state = 0;
|
|
308
|
+
/** Dispose this fiber: unload the plugin, then settle once cleanup finished. */
|
|
309
|
+
dispose;
|
|
310
|
+
/** Required implementations retained through dependent teardown. */
|
|
311
|
+
committed;
|
|
312
|
+
/** Service implementations owned by this fiber, including isolated provisions. */
|
|
313
|
+
provisions = /* @__PURE__ */ new Set();
|
|
314
|
+
/** The in-flight load/unload transition, if one is currently running. */
|
|
315
|
+
inertia;
|
|
316
|
+
_hooks = Object.create(null);
|
|
317
|
+
_disposables = new DisposableList();
|
|
318
|
+
context;
|
|
319
|
+
_error;
|
|
320
|
+
_revision = 0;
|
|
321
|
+
_configRevision = 0;
|
|
322
|
+
_effectiveConfig;
|
|
323
|
+
_runner;
|
|
324
|
+
_store = Object.create(null);
|
|
325
|
+
_release;
|
|
283
326
|
/**
|
|
284
|
-
*
|
|
327
|
+
* Create a fiber. Plugin authors normally obtain fibers from `ctx.plugin()`
|
|
328
|
+
* rather than constructing them directly.
|
|
285
329
|
*
|
|
286
|
-
* @param
|
|
287
|
-
* @
|
|
330
|
+
* @param parent — the context the plugin was loaded from.
|
|
331
|
+
* @param config — raw config, validated against the runtime's schema.
|
|
332
|
+
* @param inject — resolved dependency map (service name → intercept config).
|
|
333
|
+
* @param runtime — the shared plugin runtime, or `null` for the root fiber.
|
|
334
|
+
* @param getOuterStack — captures the caller stack for effect diagnostics.
|
|
288
335
|
*/
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
336
|
+
constructor(parent, config, inject, runtime, getOuterStack) {
|
|
337
|
+
this.parent = parent;
|
|
338
|
+
this.inject = inject;
|
|
339
|
+
this.runtime = runtime;
|
|
340
|
+
this.config = config;
|
|
341
|
+
const collect = (dispose) => {
|
|
342
|
+
this._disposables.push(dispose);
|
|
343
|
+
};
|
|
344
|
+
if (runtime) {
|
|
345
|
+
this.uid = parent.registry.counter;
|
|
346
|
+
this.ctx = this.context = parent.extend({ fiber: this });
|
|
347
|
+
const injectEntries = Object.entries(this.inject);
|
|
348
|
+
if (injectEntries.length) {
|
|
349
|
+
this.ctx[Context.intercept] = Object.create(parent[Context.intercept]);
|
|
350
|
+
for (const [name, config] of injectEntries) {
|
|
351
|
+
if (isNullable(config)) continue;
|
|
352
|
+
this.ctx[Context.intercept][name] = config;
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
this._runner = {
|
|
356
|
+
epoch: INACTIVE,
|
|
357
|
+
getOuterStack,
|
|
358
|
+
execute: function() {
|
|
359
|
+
const config = this.resolveConfig(this.config);
|
|
360
|
+
this._effectiveConfig = config;
|
|
361
|
+
if (isConstructor(runtime.callback)) {
|
|
362
|
+
const instance = new runtime.callback(this.ctx, config);
|
|
363
|
+
for (const hook of instance?.[symbols.initHooks] ?? []) hook();
|
|
364
|
+
return instance?.[symbols.init]?.();
|
|
365
|
+
} else return runtime.callback(this.ctx, config);
|
|
366
|
+
},
|
|
367
|
+
collect
|
|
368
|
+
};
|
|
369
|
+
this.dispose = parent.fiber.effect(() => {
|
|
370
|
+
const remove = runtime.fibers.push(this);
|
|
371
|
+
return async () => {
|
|
372
|
+
this.uid = null;
|
|
373
|
+
emitPluginDisposed(this.context, this);
|
|
374
|
+
if (this.ctx.registry.has(runtime.callback)) {
|
|
375
|
+
remove();
|
|
376
|
+
if (!runtime.fibers.length) this.ctx.registry.delete(runtime.callback);
|
|
377
|
+
}
|
|
378
|
+
this._setEpoch(INACTIVE);
|
|
379
|
+
if (!this.inertia) this._updateState(() => {
|
|
380
|
+
this.inertia = this._unload();
|
|
381
|
+
return 5;
|
|
382
|
+
});
|
|
383
|
+
while (this.inertia) await this.inertia;
|
|
384
|
+
};
|
|
385
|
+
}, "ctx.plugin()");
|
|
386
|
+
try {
|
|
387
|
+
this.context.emit("internal/plugin", this);
|
|
388
|
+
} catch (error) {
|
|
389
|
+
Promise.resolve(this.dispose()).catch((reason) => this.ctx.logger.error(reason));
|
|
390
|
+
throw error;
|
|
391
|
+
}
|
|
392
|
+
if (this.uid !== null && parent.fiber.state !== 5) {
|
|
393
|
+
for (const name of Object.keys(this.inject)) this._checkImpl(name);
|
|
394
|
+
this._refresh();
|
|
395
|
+
}
|
|
396
|
+
} else {
|
|
397
|
+
this.uid = 0;
|
|
398
|
+
this.ctx = this.context = parent;
|
|
399
|
+
this.state = 2;
|
|
400
|
+
this.committed = Object.create(null);
|
|
401
|
+
this._runner = {
|
|
402
|
+
epoch: "0",
|
|
403
|
+
getOuterStack,
|
|
404
|
+
execute: () => {},
|
|
405
|
+
collect
|
|
406
|
+
};
|
|
407
|
+
this.dispose = () => this.restart();
|
|
293
408
|
}
|
|
294
409
|
}
|
|
295
|
-
/**
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
const result = cb(...args);
|
|
304
|
-
if (isBailed(result)) return result;
|
|
305
|
-
}
|
|
410
|
+
/** The plugin's display name, inherited from the nearest named ancestor, else `'root'`. */
|
|
411
|
+
get name() {
|
|
412
|
+
let fiber = this;
|
|
413
|
+
do {
|
|
414
|
+
if (fiber.runtime?.name) return fiber.runtime.name;
|
|
415
|
+
fiber = fiber.parent.fiber;
|
|
416
|
+
} while (fiber !== fiber.parent.fiber);
|
|
417
|
+
return "root";
|
|
306
418
|
}
|
|
307
419
|
/**
|
|
308
|
-
*
|
|
309
|
-
*
|
|
310
|
-
* The last dispatch argument is treated as the innermost `next`. Listeners
|
|
311
|
-
* run outermost-first; a listener that does not call `next()` vetoes the
|
|
312
|
-
* rest of the chain, including the built-in behavior.
|
|
420
|
+
* Throw if the fiber has already been disposed.
|
|
313
421
|
*
|
|
314
|
-
* @
|
|
315
|
-
* @
|
|
422
|
+
* @returns nothing when the fiber is still active.
|
|
423
|
+
* @throws {CordisError} `INACTIVE_EFFECT` when the fiber's uid has been cleared.
|
|
316
424
|
*/
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
const next = () => {
|
|
321
|
-
return (cbs.shift() ?? inner)(...args);
|
|
322
|
-
};
|
|
323
|
-
args.push(next);
|
|
324
|
-
return next();
|
|
425
|
+
assertActive() {
|
|
426
|
+
if (this.uid !== null) return;
|
|
427
|
+
throw new CordisError("INACTIVE_EFFECT");
|
|
325
428
|
}
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
429
|
+
_execute(runner) {
|
|
430
|
+
const oldEpoch = runner.epoch;
|
|
431
|
+
return composeError((info) => {
|
|
432
|
+
const safeCollect = (dispose) => {
|
|
433
|
+
if (typeof dispose === "function") runner.collect(dispose);
|
|
434
|
+
else if (!isNullable(dispose)) throw new TypeError("Invalid effect");
|
|
435
|
+
};
|
|
436
|
+
const effect = runner.execute.call(this);
|
|
437
|
+
if (typeof effect === "function") return runner.collect(effect);
|
|
438
|
+
else if (isNullable(effect)) {} else if (!isObject(effect)) throw new TypeError("Invalid effect");
|
|
439
|
+
else if ("then" in effect) return effect.then(safeCollect);
|
|
440
|
+
else if (Symbol.iterator in effect) {
|
|
441
|
+
info.error = /* @__PURE__ */ new Error();
|
|
442
|
+
const iter = effect[Symbol.iterator]();
|
|
443
|
+
while (true) {
|
|
444
|
+
const result = iter.next();
|
|
445
|
+
safeCollect(result.value);
|
|
446
|
+
if (result.done) return;
|
|
447
|
+
}
|
|
448
|
+
} else if (Symbol.asyncIterator in effect) {
|
|
449
|
+
const iter = effect[Symbol.asyncIterator]();
|
|
450
|
+
return (async () => {
|
|
451
|
+
await Promise.resolve();
|
|
452
|
+
info.error = /* @__PURE__ */ new Error();
|
|
453
|
+
while (true) {
|
|
454
|
+
if (runner.epoch !== oldEpoch) return;
|
|
455
|
+
const result = await iter.next();
|
|
456
|
+
safeCollect(result.value);
|
|
457
|
+
if (result.done) return;
|
|
458
|
+
}
|
|
459
|
+
})();
|
|
460
|
+
} else throw new TypeError("Invalid effect");
|
|
461
|
+
}, runner.getOuterStack);
|
|
462
|
+
}
|
|
463
|
+
effect(execute, label = "anonymous") {
|
|
464
|
+
this.assertActive();
|
|
465
|
+
if (this.state === 5) throw new CordisError("INACTIVE_EFFECT");
|
|
466
|
+
const disposables = [];
|
|
467
|
+
let disposing = false;
|
|
468
|
+
let disposalTask;
|
|
469
|
+
const dispose = () => {
|
|
470
|
+
if (disposing) return disposalTask;
|
|
471
|
+
disposing = true;
|
|
472
|
+
let task;
|
|
473
|
+
for (const disposable of disposables.splice(0).reverse()) if (task) task = task.then(() => runDisposable(disposable));
|
|
474
|
+
else {
|
|
475
|
+
const result = runDisposable(disposable);
|
|
476
|
+
if (isObject(result) && "then" in result) task = result;
|
|
477
|
+
}
|
|
478
|
+
return disposalTask = task;
|
|
479
|
+
};
|
|
480
|
+
const meta = {
|
|
481
|
+
label,
|
|
482
|
+
children: []
|
|
483
|
+
};
|
|
484
|
+
const runner = {
|
|
485
|
+
execute,
|
|
486
|
+
epoch: true,
|
|
487
|
+
collect: (dispose) => {
|
|
488
|
+
disposables.push(dispose);
|
|
489
|
+
this._disposables.delete(dispose);
|
|
490
|
+
if (dispose[symbols.effect]) meta.children.push(dispose[symbols.effect]);
|
|
491
|
+
},
|
|
492
|
+
getOuterStack: buildOuterStack()
|
|
493
|
+
};
|
|
494
|
+
let task;
|
|
495
|
+
let executing = true;
|
|
496
|
+
let resolveSetup;
|
|
497
|
+
let rejectSetup;
|
|
498
|
+
let setupBarrier;
|
|
499
|
+
let setupFailed = false;
|
|
500
|
+
let inFlight;
|
|
501
|
+
let removeWrapper = () => false;
|
|
502
|
+
const waitForSetup = () => {
|
|
503
|
+
setupBarrier ??= new Promise((resolve, reject) => {
|
|
504
|
+
resolveSetup = resolve;
|
|
505
|
+
rejectSetup = reject;
|
|
342
506
|
});
|
|
343
|
-
return
|
|
344
|
-
}
|
|
507
|
+
return setupBarrier;
|
|
508
|
+
};
|
|
509
|
+
const disposeAfter = (setup) => {
|
|
510
|
+
return Promise.resolve(setup).then(() => dispose(), async (reason) => {
|
|
511
|
+
await dispose();
|
|
512
|
+
throw reason;
|
|
513
|
+
});
|
|
514
|
+
};
|
|
515
|
+
const finalizeDisposal = (callback) => {
|
|
516
|
+
let result;
|
|
517
|
+
try {
|
|
518
|
+
result = callback();
|
|
519
|
+
} catch (error) {
|
|
520
|
+
removeWrapper();
|
|
521
|
+
throw error;
|
|
522
|
+
}
|
|
523
|
+
if (isObject(result) && "then" in result) {
|
|
524
|
+
const pending = Promise.resolve(result).finally(() => {
|
|
525
|
+
removeWrapper();
|
|
526
|
+
if (inFlight === pending) inFlight = void 0;
|
|
527
|
+
});
|
|
528
|
+
return inFlight = pending;
|
|
529
|
+
}
|
|
530
|
+
removeWrapper();
|
|
531
|
+
return result;
|
|
532
|
+
};
|
|
533
|
+
const wrapper = defineProperty(() => {
|
|
534
|
+
if (!runner.epoch) return setupFailed ? inFlight : void 0;
|
|
535
|
+
runner.epoch = false;
|
|
536
|
+
return finalizeDisposal(() => {
|
|
537
|
+
if (executing) return disposeAfter(waitForSetup());
|
|
538
|
+
return task ? disposeAfter(task) : dispose();
|
|
539
|
+
});
|
|
540
|
+
}, symbols.effect, meta);
|
|
541
|
+
effectInertia.set(wrapper, () => inFlight);
|
|
542
|
+
removeWrapper = this._disposables.push(wrapper);
|
|
543
|
+
try {
|
|
544
|
+
task = this._execute(runner);
|
|
545
|
+
} catch (reason) {
|
|
546
|
+
executing = false;
|
|
547
|
+
setupFailed = true;
|
|
548
|
+
runner.epoch = false;
|
|
549
|
+
let cleanup;
|
|
550
|
+
try {
|
|
551
|
+
cleanup = finalizeDisposal(dispose);
|
|
552
|
+
} finally {
|
|
553
|
+
rejectSetup?.(reason);
|
|
554
|
+
}
|
|
555
|
+
if (isObject(cleanup) && "then" in cleanup) cleanup.catch((error) => this.ctx.logger.error(error));
|
|
556
|
+
throw reason;
|
|
557
|
+
}
|
|
558
|
+
executing = false;
|
|
559
|
+
if (setupBarrier) Promise.resolve(task).then(resolveSetup, rejectSetup);
|
|
560
|
+
task?.catch(() => {
|
|
561
|
+
if (!runner.epoch) return dispose();
|
|
562
|
+
return finalizeDisposal(dispose);
|
|
563
|
+
}).catch((error) => this.ctx.logger.error(error));
|
|
564
|
+
const disposeAsync = () => {
|
|
565
|
+
if (!runner.epoch) return;
|
|
566
|
+
runner.epoch = false;
|
|
567
|
+
return finalizeDisposal(dispose);
|
|
568
|
+
};
|
|
569
|
+
wrapper.then = async (onFulfilled, onRejected) => {
|
|
570
|
+
return Promise.resolve(task).then(() => disposeAsync).then(onFulfilled, onRejected);
|
|
571
|
+
};
|
|
572
|
+
return wrapper;
|
|
345
573
|
}
|
|
346
574
|
/**
|
|
347
|
-
*
|
|
575
|
+
* Return metadata for currently registered effects.
|
|
348
576
|
*
|
|
349
|
-
* @
|
|
350
|
-
* @param callback — the listener to remove.
|
|
351
|
-
* @returns `true` if the listener was found and removed.
|
|
577
|
+
* @returns one {@link EffectMeta} tree per labeled live effect.
|
|
352
578
|
*/
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
579
|
+
getEffects() {
|
|
580
|
+
return [...this._disposables].map((dispose) => dispose[symbols.effect]).filter(Boolean);
|
|
581
|
+
}
|
|
582
|
+
_getState() {
|
|
583
|
+
if (this.uid === null) return 4;
|
|
584
|
+
if (this._error) return 3;
|
|
585
|
+
if (this._runner.epoch !== INACTIVE) return 2;
|
|
586
|
+
return 0;
|
|
587
|
+
}
|
|
588
|
+
_updateState(callback) {
|
|
589
|
+
const oldState = this.state;
|
|
590
|
+
this.state = callback() ?? this._getState();
|
|
591
|
+
if (oldState === this.state) return;
|
|
592
|
+
this.context.emit("internal/status", this, oldState);
|
|
593
|
+
if (oldState !== 2 && this.state !== 2) return;
|
|
594
|
+
for (const key of Reflect.ownKeys(this.ctx.reflect.store)) {
|
|
595
|
+
const impl = this.ctx.reflect.store[key];
|
|
596
|
+
if (impl.ctx.fiber !== this) continue;
|
|
597
|
+
this.ctx.isolate(impl.name, impl.isolate).reflect.notify([impl.name]);
|
|
598
|
+
}
|
|
599
|
+
}
|
|
600
|
+
_checkImpl(name) {
|
|
601
|
+
const impl = this.ctx.reflect._getImpl(name, true);
|
|
602
|
+
if (!impl) return delete this._store[name];
|
|
603
|
+
try {
|
|
604
|
+
if (impl.check && !impl.check.call(getTraceable(this.ctx, impl.value))) return delete this._store[name];
|
|
605
|
+
} catch (error) {
|
|
606
|
+
impl.ctx.logger.error(error);
|
|
607
|
+
return delete this._store[name];
|
|
608
|
+
}
|
|
609
|
+
this._store[name] = impl;
|
|
610
|
+
}
|
|
611
|
+
_refresh() {
|
|
612
|
+
let epoch = `${this._revision}`;
|
|
613
|
+
for (const name of Object.keys(this.inject)) {
|
|
614
|
+
const impl = this._store[name];
|
|
615
|
+
if (!impl) {
|
|
616
|
+
epoch = INACTIVE;
|
|
617
|
+
break;
|
|
618
|
+
}
|
|
619
|
+
epoch += ":" + impl.uid;
|
|
358
620
|
}
|
|
621
|
+
this._setEpoch(epoch);
|
|
622
|
+
}
|
|
623
|
+
_setEpoch(epoch) {
|
|
624
|
+
const oldEpoch = this._runner.epoch;
|
|
625
|
+
if (epoch === oldEpoch) return;
|
|
626
|
+
if (this._error) return;
|
|
627
|
+
this._runner.epoch = epoch;
|
|
628
|
+
if (this.inertia) return;
|
|
629
|
+
this._updateState(() => {
|
|
630
|
+
if (epoch !== INACTIVE && oldEpoch === INACTIVE) {
|
|
631
|
+
this.inertia = this._reload();
|
|
632
|
+
return 1;
|
|
633
|
+
} else {
|
|
634
|
+
this.inertia = this._unload();
|
|
635
|
+
return 5;
|
|
636
|
+
}
|
|
637
|
+
});
|
|
638
|
+
}
|
|
639
|
+
/** Raw input retained for the next activation, without evaluating expressions or validating it. */
|
|
640
|
+
get rawConfig() {
|
|
641
|
+
return this.ctx.fiber.config;
|
|
642
|
+
}
|
|
643
|
+
/** Retain raw input without changing the running config or triggering an update. */
|
|
644
|
+
set rawConfig(config) {
|
|
645
|
+
this.ctx.fiber.config = config;
|
|
646
|
+
this.ctx.fiber._configRevision++;
|
|
359
647
|
}
|
|
360
648
|
/**
|
|
361
|
-
*
|
|
362
|
-
*
|
|
363
|
-
*
|
|
364
|
-
* `CordisError('INACTIVE_EFFECT')` if the fiber is already disposed.
|
|
365
|
-
*
|
|
366
|
-
* @param name — the event name to listen for.
|
|
367
|
-
* @param listener — called with the dispatch arguments.
|
|
368
|
-
* @param options — listener options; a boolean is shorthand for `prepend`.
|
|
369
|
-
* @returns a disposer removing the listener; `true` if it was still registered.
|
|
649
|
+
* The object passed to plugin activation or the latest successful update that retained the instance.
|
|
650
|
+
* Candidate resolution does not publish it; volatile updates retain its references.
|
|
651
|
+
* Undefined before activation and readable after unload; callers requiring a live instance check `state`.
|
|
370
652
|
*/
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
this.ctx.fiber.assertActive();
|
|
374
|
-
listener = this.ctx.reflect.bind(listener);
|
|
375
|
-
const result = this.bail(this.ctx, "internal/listener", name, listener, options);
|
|
376
|
-
if (result) return result;
|
|
377
|
-
const hooks = this._hooks[name] ||= [];
|
|
378
|
-
const label = `ctx.on(${typeof name === "string" ? JSON.stringify(name) : name.toString()})`;
|
|
379
|
-
return this.register(label, hooks, listener, options);
|
|
653
|
+
get effectiveConfig() {
|
|
654
|
+
return this.ctx.fiber._effectiveConfig;
|
|
380
655
|
}
|
|
381
656
|
/**
|
|
382
|
-
*
|
|
383
|
-
*
|
|
384
|
-
*
|
|
385
|
-
* @param
|
|
386
|
-
* @
|
|
387
|
-
* @
|
|
657
|
+
* Evaluate and validate a candidate using this fiber's `internal/config` hooks and runtime schema.
|
|
658
|
+
* Does not publish the result, replace raw input, or commit running volatile references.
|
|
659
|
+
* Required injections must be available when a hook uses them.
|
|
660
|
+
* @param config Raw candidate input.
|
|
661
|
+
* @returns The candidate's resolved config, retaining the schema's result identity.
|
|
662
|
+
* @throws {ValidationError} when the runtime schema rejects the candidate; hook errors propagate.
|
|
388
663
|
*/
|
|
389
|
-
|
|
390
|
-
const
|
|
391
|
-
|
|
392
|
-
return listener.apply(this, args);
|
|
393
|
-
}, options);
|
|
394
|
-
return dispose;
|
|
664
|
+
resolveConfig(config) {
|
|
665
|
+
const fiber = this.ctx.fiber;
|
|
666
|
+
return fiber.context.waterfall("internal/config", fiber, () => config);
|
|
395
667
|
}
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
668
|
+
async _reload() {
|
|
669
|
+
this.committed = { ...this._store };
|
|
670
|
+
for (const impl of Object.values(this.committed)) {
|
|
671
|
+
if (impl.ctx.fiber === this) continue;
|
|
672
|
+
impl.dependents.add(this);
|
|
673
|
+
}
|
|
674
|
+
const oldEpoch = this._runner.epoch;
|
|
675
|
+
try {
|
|
676
|
+
await Promise.resolve();
|
|
677
|
+
if (this._runner.epoch === oldEpoch) await this._execute(this._runner);
|
|
678
|
+
} catch (reason) {
|
|
679
|
+
this.ctx.logger.error(reason);
|
|
680
|
+
if (this._runner.epoch === oldEpoch) {
|
|
681
|
+
this._error = reason;
|
|
682
|
+
this._runner.epoch = INACTIVE;
|
|
683
|
+
}
|
|
684
|
+
}
|
|
685
|
+
this._updateState(() => {
|
|
686
|
+
if (this._runner.epoch === oldEpoch) this.inertia = void 0;
|
|
687
|
+
else {
|
|
688
|
+
this.inertia = this._unload();
|
|
689
|
+
return 5;
|
|
690
|
+
}
|
|
691
|
+
});
|
|
692
|
+
}
|
|
693
|
+
async _unload() {
|
|
694
|
+
while ([...this.provisions].some((impl) => impl.dependents.size)) await new Promise((resolve) => this._release = resolve);
|
|
695
|
+
this._release = void 0;
|
|
696
|
+
await Promise.all(this._disposables.clear().map(async (dispose) => {
|
|
697
|
+
try {
|
|
698
|
+
await composeError(async (info) => {
|
|
699
|
+
await Promise.resolve();
|
|
700
|
+
info.error = /* @__PURE__ */ new Error();
|
|
701
|
+
await runDisposable(dispose);
|
|
702
|
+
}, this._runner.getOuterStack);
|
|
703
|
+
} catch (reason) {
|
|
704
|
+
this.ctx.logger.error(reason);
|
|
705
|
+
}
|
|
706
|
+
}));
|
|
707
|
+
for (const impl of Object.values(this.committed ?? {})) {
|
|
708
|
+
if (!impl.dependents.delete(this) || impl.dependents.size) continue;
|
|
709
|
+
impl.release?.();
|
|
710
|
+
impl.ctx.fiber._release?.();
|
|
711
|
+
}
|
|
712
|
+
this.committed = void 0;
|
|
713
|
+
this._updateState(() => {
|
|
714
|
+
if (this._runner.epoch === INACTIVE) this.inertia = void 0;
|
|
715
|
+
else {
|
|
716
|
+
this.inertia = this._reload();
|
|
717
|
+
return 1;
|
|
718
|
+
}
|
|
719
|
+
});
|
|
720
|
+
}
|
|
721
|
+
/**
|
|
722
|
+
* Wait for current lifecycle work and rethrow startup errors.
|
|
723
|
+
*
|
|
724
|
+
* @returns this fiber, once it has settled into a stable state.
|
|
725
|
+
* @throws the config-validation or plugin-startup error, if any.
|
|
726
|
+
*/
|
|
727
|
+
async await() {
|
|
728
|
+
while (this.inertia) await this.inertia;
|
|
729
|
+
if (this._error) throw this._error;
|
|
730
|
+
return this;
|
|
731
|
+
}
|
|
732
|
+
/**
|
|
733
|
+
* Dispose and immediately reload this plugin with its current config.
|
|
734
|
+
*
|
|
735
|
+
* @returns a promise resolving once the reload settled.
|
|
736
|
+
* @throws {CordisError} `INACTIVE_EFFECT` when the fiber is already disposed.
|
|
737
|
+
*/
|
|
738
|
+
async restart() {
|
|
739
|
+
const fiber = this.ctx.fiber;
|
|
740
|
+
fiber.assertActive();
|
|
741
|
+
fiber._revision++;
|
|
742
|
+
fiber._refresh();
|
|
743
|
+
await fiber.await();
|
|
744
|
+
}
|
|
745
|
+
/**
|
|
746
|
+
* Resolve a candidate, retain its raw config and apply it through the update waterfall.
|
|
747
|
+
* @param config Raw config; pending fibers defer resolution until activation.
|
|
748
|
+
* @param noSave Suppress the persistence notification when true.
|
|
749
|
+
* @returns The awaited update/restart result, or undefined when a synchronous listener handles it.
|
|
750
|
+
* @throws {ValidationError} when an active fiber's candidate is invalid.
|
|
751
|
+
*/
|
|
752
|
+
update(config, noSave = false) {
|
|
753
|
+
const fiber = this.ctx.fiber;
|
|
754
|
+
fiber.assertActive();
|
|
755
|
+
const loaded = fiber._runner.epoch !== INACTIVE;
|
|
756
|
+
const resolved = loaded ? fiber.resolveConfig(config) : void 0;
|
|
757
|
+
if (!noSave) fiber.context.emit("internal/commit", fiber, config);
|
|
758
|
+
fiber.config = config;
|
|
759
|
+
fiber._error = void 0;
|
|
760
|
+
const configRevision = ++fiber._configRevision;
|
|
761
|
+
const epoch = fiber._runner.epoch;
|
|
762
|
+
const committed = fiber.committed;
|
|
763
|
+
let restarted = false;
|
|
764
|
+
const restart = () => {
|
|
765
|
+
restarted = true;
|
|
766
|
+
return fiber.restart();
|
|
767
|
+
};
|
|
768
|
+
const publish = () => {
|
|
769
|
+
if (!restarted && fiber.uid !== null && fiber._configRevision === configRevision && fiber._runner.epoch === epoch && fiber.committed === committed) fiber._effectiveConfig = resolved;
|
|
770
|
+
};
|
|
771
|
+
const result = loaded ? fiber.context.waterfall(fiber, "internal/update", resolved, restart) : restart();
|
|
772
|
+
if (result === void 0) {
|
|
773
|
+
publish();
|
|
774
|
+
return;
|
|
775
|
+
}
|
|
776
|
+
const task = Promise.resolve(result).then(publish);
|
|
777
|
+
task.catch(() => {});
|
|
778
|
+
return task;
|
|
779
|
+
}
|
|
780
|
+
};
|
|
781
|
+
//#endregion
|
|
782
|
+
//#region lib/types/events.js
|
|
783
|
+
/**
|
|
784
|
+
* Return whether an event result should stop a bail-style dispatch.
|
|
785
|
+
*
|
|
786
|
+
* @param value — a listener's return value.
|
|
787
|
+
* @returns `true` unless `value` is `null`, `false`, or `undefined`.
|
|
788
|
+
*/
|
|
789
|
+
function isBailed(value) {
|
|
790
|
+
return value !== null && value !== false && value !== void 0;
|
|
791
|
+
}
|
|
792
|
+
/**
|
|
793
|
+
* Event bus installed as `ctx.events` and mixed into every context.
|
|
794
|
+
*
|
|
795
|
+
* The service supports concurrent, synchronous, serial, bail, and waterfall
|
|
796
|
+
* dispatch and automatically disposes listeners with their owning fiber.
|
|
797
|
+
*/
|
|
798
|
+
var EventsService = class {
|
|
799
|
+
ctx;
|
|
800
|
+
_hooks = Object.create(null);
|
|
801
|
+
constructor(ctx) {
|
|
802
|
+
this.ctx = ctx;
|
|
803
|
+
defineProperty(this, symbols.tracker, {
|
|
804
|
+
property: "ctx",
|
|
805
|
+
noShadow: true
|
|
806
|
+
});
|
|
807
|
+
this.on("internal/listener", function(name, listener, options) {
|
|
808
|
+
if (name === "internal/update" && !options.global) {
|
|
809
|
+
const hooks = this.fiber._hooks["internal/update"] ??= new DisposableList();
|
|
810
|
+
const method = options.prepend ? "unshift" : "push";
|
|
811
|
+
return this.fiber.effect(() => hooks[method](listener), "ctx.on(\"internal/update\")");
|
|
812
|
+
}
|
|
813
|
+
});
|
|
814
|
+
this.on("internal/update", function(config, next) {
|
|
815
|
+
const cbs = [...this._hooks["internal/update"] || []];
|
|
816
|
+
const _next = () => {
|
|
817
|
+
return (cbs.shift() ?? next).call(this, config, _next);
|
|
818
|
+
};
|
|
819
|
+
return _next();
|
|
820
|
+
}, {
|
|
821
|
+
global: true,
|
|
822
|
+
prepend: true
|
|
823
|
+
});
|
|
824
|
+
this.on("internal/config", (fiber, next) => {
|
|
825
|
+
const config = next();
|
|
826
|
+
return fiber.runtime ? resolveConfig(fiber.runtime, config) : config;
|
|
827
|
+
});
|
|
828
|
+
}
|
|
829
|
+
_resolve(type, args) {
|
|
830
|
+
const thisArg = typeof args[0] === "object" || typeof args[0] === "function" ? args.shift() : null;
|
|
831
|
+
const name = args.shift();
|
|
832
|
+
if ((typeof name !== "string" || !name.startsWith("internal/")) && this._hooks["internal/dispatch"]?.length) this.emit("internal/dispatch", type, name, args, thisArg);
|
|
833
|
+
const filter = thisArg?.[Context.filter];
|
|
834
|
+
return [thisArg, (this._hooks[name] || []).filter((hook) => hook.global || !filter || filter.call(thisArg, hook.ctx)).map((hook) => hook.callback)];
|
|
835
|
+
}
|
|
836
|
+
/**
|
|
837
|
+
* Resolve bound callbacks using the event's context filter.
|
|
838
|
+
* @param type Dispatch mode reported to observers.
|
|
839
|
+
* @param args Dispatch arguments, consumed through the event name.
|
|
840
|
+
* @returns Matching callbacks bound to the dispatch receiver.
|
|
841
|
+
* DSH retains callback enumeration for per-listener error containment.
|
|
842
|
+
*/
|
|
843
|
+
dispatch(type, args) {
|
|
844
|
+
const [thisArg, callbacks] = this._resolve(type, args);
|
|
845
|
+
return callbacks.map((callback) => callback.bind(thisArg));
|
|
846
|
+
}
|
|
847
|
+
/**
|
|
848
|
+
* Run listeners concurrently and wait for all of them.
|
|
849
|
+
*
|
|
850
|
+
* @param args — optional `this`, the event name, then listener arguments.
|
|
851
|
+
* @returns a promise resolving once every listener has settled.
|
|
852
|
+
*/
|
|
853
|
+
async parallel(...args) {
|
|
854
|
+
const [thisArg, callbacks] = this._resolve("parallel", args);
|
|
855
|
+
const errors = (await Promise.allSettled(callbacks.map(async (callback) => Reflect.apply(callback, thisArg, args)))).filter((result) => result.status === "rejected");
|
|
856
|
+
if (errors.length) throw new AggregateError(errors.map((error) => error.reason));
|
|
857
|
+
}
|
|
858
|
+
/**
|
|
859
|
+
* Run listeners synchronously without waiting for returned promises.
|
|
860
|
+
*
|
|
861
|
+
* @param args — optional `this`, the event name, then listener arguments.
|
|
862
|
+
*/
|
|
863
|
+
emit(...args) {
|
|
864
|
+
const [thisArg, callbacks] = this._resolve("emit", args);
|
|
865
|
+
for (const callback of callbacks) Reflect.apply(callback, thisArg, args);
|
|
866
|
+
}
|
|
867
|
+
/**
|
|
868
|
+
* Run listeners in order, awaiting each, until one returns a bail value.
|
|
869
|
+
*
|
|
870
|
+
* @param args — optional `this`, the event name, then listener arguments.
|
|
871
|
+
* @returns the first bail value (see {@link isBailed}), if any.
|
|
872
|
+
*/
|
|
873
|
+
async serial(...args) {
|
|
874
|
+
const [thisArg, callbacks] = this._resolve("serial", args);
|
|
875
|
+
for (const callback of callbacks) {
|
|
876
|
+
const result = await Reflect.apply(callback, thisArg, args);
|
|
877
|
+
if (isBailed(result)) return result;
|
|
878
|
+
}
|
|
879
|
+
}
|
|
880
|
+
/**
|
|
881
|
+
* Run listeners synchronously until one returns a bail value.
|
|
882
|
+
*
|
|
883
|
+
* @param args — optional `this`, the event name, then listener arguments.
|
|
884
|
+
* @returns the first bail value (see {@link isBailed}), if any.
|
|
885
|
+
*/
|
|
886
|
+
bail(...args) {
|
|
887
|
+
const [thisArg, callbacks] = this._resolve("bail", args);
|
|
888
|
+
for (const callback of callbacks) {
|
|
889
|
+
const result = Reflect.apply(callback, thisArg, args);
|
|
890
|
+
if (isBailed(result)) return result;
|
|
891
|
+
}
|
|
892
|
+
}
|
|
893
|
+
/**
|
|
894
|
+
* Compose listeners around the final `next` callback.
|
|
895
|
+
*
|
|
896
|
+
* The last dispatch argument is treated as the innermost `next`. Listeners
|
|
897
|
+
* run outermost-first; a listener that does not call `next()` vetoes the
|
|
898
|
+
* rest of the chain, including the built-in behavior.
|
|
899
|
+
*
|
|
900
|
+
* @param args — optional `this`, the event name, listener arguments, then `next`.
|
|
901
|
+
* @returns the outermost listener's return value.
|
|
902
|
+
*/
|
|
903
|
+
waterfall(...args) {
|
|
904
|
+
const [thisArg, callbacks] = this._resolve("waterfall", args);
|
|
905
|
+
const inner = args.pop();
|
|
906
|
+
const dispatch = () => {
|
|
907
|
+
const callback = callbacks.shift();
|
|
908
|
+
if (!callback) return inner();
|
|
909
|
+
let called = false;
|
|
910
|
+
const next = () => {
|
|
911
|
+
if (called) throw new Error("next() called multiple times");
|
|
912
|
+
called = true;
|
|
913
|
+
return dispatch();
|
|
914
|
+
};
|
|
915
|
+
return Reflect.apply(callback, thisArg, [...args, next]);
|
|
916
|
+
};
|
|
917
|
+
return dispatch();
|
|
918
|
+
}
|
|
919
|
+
register(label, name, callback, options) {
|
|
920
|
+
const method = options.prepend ? "unshift" : "push";
|
|
921
|
+
return this.ctx.fiber.effect(() => {
|
|
922
|
+
(this._hooks[name] ??= [])[method]({
|
|
923
|
+
ctx: this.ctx,
|
|
924
|
+
callback,
|
|
925
|
+
...options
|
|
926
|
+
});
|
|
927
|
+
return () => this.unregister(name, callback);
|
|
928
|
+
}, label);
|
|
929
|
+
}
|
|
930
|
+
unregister(name, callback) {
|
|
931
|
+
const hooks = this._hooks[name];
|
|
932
|
+
if (!hooks) return;
|
|
933
|
+
const index = hooks.findIndex((hook) => hook.callback === callback);
|
|
934
|
+
if (index >= 0) {
|
|
935
|
+
hooks.splice(index, 1);
|
|
936
|
+
if (!hooks.length) delete this._hooks[name];
|
|
937
|
+
return true;
|
|
938
|
+
}
|
|
939
|
+
}
|
|
940
|
+
/**
|
|
941
|
+
* Register an event listener owned by the current fiber.
|
|
942
|
+
*
|
|
943
|
+
* The listener is removed automatically when the fiber unloads. Throws
|
|
944
|
+
* `CordisError('INACTIVE_EFFECT')` if the fiber is already disposed.
|
|
945
|
+
*
|
|
946
|
+
* @param name — the event name to listen for.
|
|
947
|
+
* @param listener — called with the dispatch arguments.
|
|
948
|
+
* @param options — listener options; a boolean is shorthand for `prepend`.
|
|
949
|
+
* @returns a disposer removing the listener; `true` if it was still registered.
|
|
950
|
+
*/
|
|
951
|
+
on(name, listener, options) {
|
|
952
|
+
if (typeof options !== "object") options = { prepend: options };
|
|
953
|
+
this.ctx.fiber.assertActive();
|
|
954
|
+
listener = this.ctx.reflect.bind(listener);
|
|
955
|
+
const result = this.bail(this.ctx, "internal/listener", name, listener, options);
|
|
956
|
+
if (result) return result;
|
|
957
|
+
const label = `ctx.on(${typeof name === "string" ? JSON.stringify(name) : name.toString()})`;
|
|
958
|
+
return this.register(label, name, listener, options);
|
|
959
|
+
}
|
|
960
|
+
/**
|
|
961
|
+
* Register an event listener that disposes itself after the first call.
|
|
962
|
+
*
|
|
963
|
+
* @param name — the event name to listen for.
|
|
964
|
+
* @param listener — called at most once with the dispatch arguments.
|
|
965
|
+
* @param options — listener options; a boolean is shorthand for `prepend`.
|
|
966
|
+
* @returns a disposer removing the listener; `true` if it was still registered.
|
|
967
|
+
*/
|
|
968
|
+
once(name, listener, options) {
|
|
969
|
+
const dispose = this.on(name, function(...args) {
|
|
970
|
+
dispose();
|
|
971
|
+
return listener.apply(this, args);
|
|
972
|
+
}, options);
|
|
973
|
+
return dispose;
|
|
974
|
+
}
|
|
975
|
+
};
|
|
976
|
+
//#endregion
|
|
977
|
+
//#region lib/types/logger.js
|
|
978
|
+
/** Built-in placeholder formatters used by `Logger.format()`. */
|
|
979
|
+
const defaultFormatters = {
|
|
980
|
+
s: (value) => String(value),
|
|
981
|
+
d: (value) => Math.trunc(Number(value)),
|
|
982
|
+
i: (value) => Math.trunc(Number(value)),
|
|
983
|
+
f: (value) => Number(value),
|
|
405
984
|
o: (value) => JSON.stringify(value),
|
|
406
985
|
O: (value) => JSON.stringify(value),
|
|
407
986
|
c: () => "",
|
|
@@ -455,8 +1034,8 @@ var Logger = class {
|
|
|
455
1034
|
this.service = service;
|
|
456
1035
|
Object.assign(this, options);
|
|
457
1036
|
this.error = this._method("error", 0);
|
|
458
|
-
this.info = this._method("info",
|
|
459
|
-
this.warn = this._method("warn",
|
|
1037
|
+
this.info = this._method("info", 2);
|
|
1038
|
+
this.warn = this._method("warn", 1);
|
|
460
1039
|
this.debug = this._method("debug", 3);
|
|
461
1040
|
}
|
|
462
1041
|
_method(type, level) {
|
|
@@ -471,7 +1050,7 @@ var Logger = class {
|
|
|
471
1050
|
const sn = ++this.service._snMessage;
|
|
472
1051
|
const ts = Date.now();
|
|
473
1052
|
for (const exporter of this.service.exporters.values()) {
|
|
474
|
-
if ((exporter.levels?.[this.name] ?? exporter.levels?.default ?? this.level ??
|
|
1053
|
+
if ((exporter.levels?.[this.name] ?? exporter.levels?.default ?? this.level ?? 2) < level) continue;
|
|
475
1054
|
const message = {
|
|
476
1055
|
sn,
|
|
477
1056
|
ts,
|
|
@@ -599,7 +1178,9 @@ var LoggerService = class LoggerService {
|
|
|
599
1178
|
colors: 3,
|
|
600
1179
|
export: (message) => {
|
|
601
1180
|
self.buffer.push(message);
|
|
602
|
-
|
|
1181
|
+
const overflow = self.buffer.length - self.bufferSize;
|
|
1182
|
+
if (overflow === 1) self.buffer.shift();
|
|
1183
|
+
else if (overflow > 1) self.buffer.splice(0, overflow);
|
|
603
1184
|
}
|
|
604
1185
|
});
|
|
605
1186
|
return self;
|
|
@@ -628,7 +1209,7 @@ var LoggerService = class LoggerService {
|
|
|
628
1209
|
}
|
|
629
1210
|
[symbols.invoke](name) {
|
|
630
1211
|
const config = this._resolveConfig();
|
|
631
|
-
const fiber = (this
|
|
1212
|
+
const fiber = (this[symbols.caller] ?? this.ctx).fiber;
|
|
632
1213
|
name ??= config.name;
|
|
633
1214
|
name ??= hyphenate(fiber.name);
|
|
634
1215
|
return new Logger({
|
|
@@ -677,12 +1258,14 @@ var ReflectService = class {
|
|
|
677
1258
|
try {
|
|
678
1259
|
const def = target.reflect.props[prop];
|
|
679
1260
|
if (def?.type === "accessor") return def.get.call(ctx, ctx[symbols.receiver], error);
|
|
680
|
-
|
|
1261
|
+
const defSite = ctx[symbols.shadow] ?? ctx;
|
|
1262
|
+
if (!defSite.fiber.runtime) return ctx.reflect.get(prop, false);
|
|
681
1263
|
return ctx.events.waterfall("internal/get", ctx, prop, error, () => {
|
|
682
|
-
const key =
|
|
683
|
-
let fiber =
|
|
1264
|
+
const key = defSite[symbols.isolate][prop];
|
|
1265
|
+
let fiber = defSite.fiber;
|
|
684
1266
|
while (true) {
|
|
685
|
-
|
|
1267
|
+
let impl = fiber.committed?.[prop];
|
|
1268
|
+
for (const provision of fiber.provisions) if (provision.name === prop && provision.ctx[symbols.isolate][prop] === key) impl = provision;
|
|
686
1269
|
if (impl) return getTraceable(ctx, impl.value);
|
|
687
1270
|
if (prop in fiber.inject) {
|
|
688
1271
|
error.message = `cannot get required service "${prop}" in inactive context`;
|
|
@@ -713,757 +1296,220 @@ var ReflectService = class {
|
|
|
713
1296
|
return ctx.events.waterfall("internal/set", ctx, prop, value, error, () => {
|
|
714
1297
|
return ctx.reflect.set(prop, value, error);
|
|
715
1298
|
});
|
|
716
|
-
} catch (e) {
|
|
717
|
-
throw e === error ? enhanceError(e) : e;
|
|
718
|
-
}
|
|
719
|
-
},
|
|
720
|
-
has: (target, prop) => {
|
|
721
|
-
if (isSpecialProperty(prop)) return Reflect.has(target, prop);
|
|
722
|
-
if (Reflect.has(target, prop)) return true;
|
|
723
|
-
return !!target.reflect.props[prop];
|
|
724
|
-
}
|
|
725
|
-
};
|
|
726
|
-
/** Service implementations, keyed by isolation label. */
|
|
727
|
-
store = Object.create(null);
|
|
728
|
-
/** Declared context properties (services and accessors), by name. */
|
|
729
|
-
props = Object.create(null);
|
|
730
|
-
constructor(ctx) {
|
|
731
|
-
this.ctx = ctx;
|
|
732
|
-
defineProperty(this, symbols.tracker, {
|
|
733
|
-
property: "ctx",
|
|
734
|
-
noShadow: true
|
|
735
|
-
});
|
|
736
|
-
this.mixin("reflect", [
|
|
737
|
-
"get",
|
|
738
|
-
"set",
|
|
739
|
-
"provide",
|
|
740
|
-
"accessor",
|
|
741
|
-
"mixin"
|
|
742
|
-
]);
|
|
743
|
-
this.mixin("fiber", ["runtime", "effect"]);
|
|
744
|
-
this.mixin("registry", ["inject", "plugin"]);
|
|
745
|
-
this.mixin("events", [
|
|
746
|
-
"on",
|
|
747
|
-
"once",
|
|
748
|
-
"parallel",
|
|
749
|
-
"emit",
|
|
750
|
-
"serial",
|
|
751
|
-
"bail",
|
|
752
|
-
"waterfall"
|
|
753
|
-
]);
|
|
754
|
-
}
|
|
755
|
-
/**
|
|
756
|
-
* Read a service from the store without the inject requirement.
|
|
757
|
-
*
|
|
758
|
-
* @param name — the service name.
|
|
759
|
-
* @param strict — when `true`, only return implementations whose providing
|
|
760
|
-
* fiber is currently active.
|
|
761
|
-
* @returns the service value, or `undefined` when not (yet) provided.
|
|
762
|
-
*/
|
|
763
|
-
get(name, strict = true) {
|
|
764
|
-
return getTraceable(this.ctx, this._getImpl(name, strict)?.value);
|
|
765
|
-
}
|
|
766
|
-
_getImpl(name, strict = true) {
|
|
767
|
-
const key = this.ctx[symbols.isolate][name];
|
|
768
|
-
const impl = key && this.store[key];
|
|
769
|
-
if (!impl) return;
|
|
770
|
-
if (strict && impl.fiber.state !== 2) return;
|
|
771
|
-
return impl;
|
|
772
|
-
}
|
|
773
|
-
/**
|
|
774
|
-
* Overwrite a provided service's value.
|
|
775
|
-
*
|
|
776
|
-
* @param name — the service name.
|
|
777
|
-
* @param value — the new service value.
|
|
778
|
-
* @param error — carrier for the caller stack in diagnostics.
|
|
779
|
-
* @returns `true` on success.
|
|
780
|
-
* @throws when `name` was never provided, or was provided by another fiber.
|
|
781
|
-
*/
|
|
782
|
-
set(name, value, error) {
|
|
783
|
-
const key = this.ctx[symbols.isolate][name];
|
|
784
|
-
const impl = this.store[key];
|
|
785
|
-
if (!impl) throw new Error(`cannot set property "${name}" without provide`);
|
|
786
|
-
if (impl.fiber !== this.ctx.fiber) throw new Error(`cannot set property "${name}" in multiple fibers`);
|
|
787
|
-
impl.value = value;
|
|
788
|
-
return true;
|
|
789
|
-
}
|
|
790
|
-
/**
|
|
791
|
-
* Register a service implementation owned by the current fiber.
|
|
792
|
-
*
|
|
793
|
-
* See the `ctx.provide()` overload above for the full contract.
|
|
794
|
-
*
|
|
795
|
-
* @param name — the service name.
|
|
796
|
-
* @param value — the service value.
|
|
797
|
-
* @param check — optional availability predicate for dependents.
|
|
798
|
-
* @returns a disposer that unregisters the service.
|
|
799
|
-
*/
|
|
800
|
-
provide(name, value, check) {
|
|
801
|
-
return this.ctx.fiber.effect(() => {
|
|
802
|
-
if (!this.props[name]) this.props[name] ??= { type: "service" };
|
|
803
|
-
else if (this.props[name].type !== "service") throw new Error(`property "${name}" is already declared as ${this.props[name].type}`);
|
|
804
|
-
this.props[name] = { type: "service" };
|
|
805
|
-
this.ctx.root[symbols.isolate][name] ??= Symbol(name);
|
|
806
|
-
const key = this.ctx[symbols.isolate][name];
|
|
807
|
-
const impl = {
|
|
808
|
-
name,
|
|
809
|
-
value,
|
|
810
|
-
fiber: this.ctx.fiber,
|
|
811
|
-
check
|
|
812
|
-
};
|
|
813
|
-
if (this.store[key]) throw new Error(`service "${name}" has been registered at <${this.store[key].fiber.name}>`);
|
|
814
|
-
this.store[key] = impl;
|
|
815
|
-
this.ctx.fiber.store[name] = impl;
|
|
816
|
-
if (this.ctx.fiber.state === 2) this.notify([name]);
|
|
817
|
-
return async () => {
|
|
818
|
-
delete this.store[key];
|
|
819
|
-
const fibers = this.notify([name]);
|
|
820
|
-
await Promise.allSettled(fibers.map((fiber) => fiber.await()));
|
|
821
|
-
delete this.ctx.fiber.store[name];
|
|
822
|
-
};
|
|
823
|
-
}, `ctx.provide(${JSON.stringify(name)})`);
|
|
824
|
-
}
|
|
825
|
-
/**
|
|
826
|
-
* Re-evaluate every fiber that requires one of the given services.
|
|
827
|
-
*
|
|
828
|
-
* @param names — the service names that changed.
|
|
829
|
-
* @param filter — restricts notification to matching isolation scopes.
|
|
830
|
-
* @returns the fibers whose dependency state was refreshed.
|
|
831
|
-
*/
|
|
832
|
-
notify(names, filter = (ctx, name) => ctx[symbols.isolate][name] === this.ctx[symbols.isolate][name]) {
|
|
833
|
-
const fibers = [];
|
|
834
|
-
for (const runtime of this.ctx.registry.values()) for (const fiber of runtime.fibers) {
|
|
835
|
-
let hasUpdate = false;
|
|
836
|
-
for (const name of names) {
|
|
837
|
-
if (!(name in fiber.inject)) continue;
|
|
838
|
-
if (!filter(fiber.ctx, name)) continue;
|
|
839
|
-
hasUpdate = true;
|
|
840
|
-
fiber._checkImpl(name);
|
|
841
|
-
}
|
|
842
|
-
if (!hasUpdate) continue;
|
|
843
|
-
fiber._refresh();
|
|
844
|
-
fibers.push(fiber);
|
|
845
|
-
}
|
|
846
|
-
for (const name of names) {
|
|
847
|
-
const self = Object.create(this.ctx);
|
|
848
|
-
self[symbols.filter] = (target) => filter(target, name);
|
|
849
|
-
this.ctx.events.emit(self, "internal/service", name, this._getImpl(name, false)?.value);
|
|
850
|
-
}
|
|
851
|
-
return fibers;
|
|
852
|
-
}
|
|
853
|
-
/**
|
|
854
|
-
* Define a computed context property backed by get/set hooks.
|
|
855
|
-
*
|
|
856
|
-
* @param name — the context property name.
|
|
857
|
-
* @param options — the `get` hook and optional `set` hook.
|
|
858
|
-
* @returns a disposer that removes the accessor.
|
|
859
|
-
*/
|
|
860
|
-
accessor(name, options) {
|
|
861
|
-
return this.ctx.fiber.effect(() => {
|
|
862
|
-
if (name in this.props) throw new Error(`property "${name}" is already declared as ${this.props[name].type}`);
|
|
863
|
-
this.props[name] = {
|
|
864
|
-
type: "accessor",
|
|
865
|
-
...options
|
|
866
|
-
};
|
|
867
|
-
return () => delete this.props[name];
|
|
868
|
-
}, `ctx.accessor(${JSON.stringify(name)})`);
|
|
869
|
-
}
|
|
870
|
-
/**
|
|
871
|
-
* Expose selected members of a service directly on `ctx`.
|
|
872
|
-
*
|
|
873
|
-
* See the `ctx.mixin()` overload above for the full contract.
|
|
874
|
-
*
|
|
875
|
-
* @param source — a context property name or a source object.
|
|
876
|
-
* @param mixins — keys to forward, or a source-key → ctx-key map.
|
|
877
|
-
* @returns a disposer that removes all created accessors.
|
|
878
|
-
*/
|
|
879
|
-
mixin(source, mixins) {
|
|
880
|
-
const self = this;
|
|
881
|
-
return this.ctx.fiber.effect(function* () {
|
|
882
|
-
const entries = Array.isArray(mixins) ? mixins.map((key) => [key, key]) : Object.entries(mixins);
|
|
883
|
-
const getTarget = (ctx, error) => {
|
|
884
|
-
return ctx[source];
|
|
885
|
-
};
|
|
886
|
-
for (const [key, value] of entries) yield self.accessor(value, {
|
|
887
|
-
get(receiver, error) {
|
|
888
|
-
const service = getTarget(this, error);
|
|
889
|
-
if (isNullable(service)) return service;
|
|
890
|
-
const mixin = receiver ? withProps(receiver, service) : service;
|
|
891
|
-
const value = Reflect.get(service, key, mixin);
|
|
892
|
-
if (typeof value !== "function") return value;
|
|
893
|
-
return value.bind(mixin ?? service);
|
|
894
|
-
},
|
|
895
|
-
set(value, receiver, error) {
|
|
896
|
-
const service = getTarget(this, error);
|
|
897
|
-
const mixin = receiver ? withProps(receiver, service) : service;
|
|
898
|
-
return Reflect.set(service, key, value, mixin);
|
|
899
|
-
}
|
|
900
|
-
});
|
|
901
|
-
}, `ctx.mixin(${JSON.stringify(source)})`);
|
|
902
|
-
}
|
|
903
|
-
/**
|
|
904
|
-
* Attach this context's tracing wrapper to a value.
|
|
905
|
-
*
|
|
906
|
-
* @param value — the value to wrap.
|
|
907
|
-
* @returns the traceable wrapper (or the value itself when not applicable).
|
|
908
|
-
*/
|
|
909
|
-
trace(value) {
|
|
910
|
-
return getTraceable(this.ctx, value);
|
|
911
|
-
}
|
|
912
|
-
/**
|
|
913
|
-
* Wrap a callback so calls trace `this` and arguments to this context.
|
|
914
|
-
*
|
|
915
|
-
* @param callback — the function to wrap.
|
|
916
|
-
* @returns a proxy delegating to `callback` with traced values.
|
|
917
|
-
*/
|
|
918
|
-
bind(callback) {
|
|
919
|
-
return new Proxy(callback, {
|
|
920
|
-
apply: (target, thisArg, args) => {
|
|
921
|
-
return Reflect.apply(target, this.trace(thisArg), args.map((arg) => this.trace(arg)));
|
|
922
|
-
},
|
|
923
|
-
construct: (target, args, newTarget) => {
|
|
924
|
-
return Reflect.construct(target, args.map((arg) => this.trace(arg)), newTarget);
|
|
925
|
-
}
|
|
926
|
-
});
|
|
927
|
-
}
|
|
928
|
-
};
|
|
929
|
-
//#endregion
|
|
930
|
-
//#region lib/types/fiber.js
|
|
931
|
-
const kValidationError = Symbol.for("ValidationError");
|
|
932
|
-
/** Error raised when plugin configuration fails standard-schema validation. */
|
|
933
|
-
var ValidationError = class extends TypeError {
|
|
934
|
-
name = "ValidationError";
|
|
935
|
-
/**
|
|
936
|
-
* Build the aggregated message from schema issues.
|
|
937
|
-
*
|
|
938
|
-
* @param issues — the standard-schema issues, one message line each.
|
|
939
|
-
*/
|
|
940
|
-
constructor(issues) {
|
|
941
|
-
super(`invalid config:\n` + issues.map((issue) => {
|
|
942
|
-
if (issue.path) return ` - ${issue.message} (at ${issue.path.join(".")})`;
|
|
943
|
-
else return ` - ${issue.message}`;
|
|
944
|
-
}).join("\n"));
|
|
945
|
-
}
|
|
946
|
-
};
|
|
947
|
-
Object.defineProperty(ValidationError.prototype, kValidationError, { value: true });
|
|
948
|
-
/**
|
|
949
|
-
* Validate and normalize config for a plugin runtime before it starts.
|
|
950
|
-
*
|
|
951
|
-
* @param runtime — the plugin runtime whose `Config` schema to apply.
|
|
952
|
-
* @param config — the raw user config.
|
|
953
|
-
* @returns the validated config, or `config` unchanged if the runtime has no schema.
|
|
954
|
-
* @throws {ValidationError} when validation reports issues.
|
|
955
|
-
*/
|
|
956
|
-
function resolveConfig(runtime, config) {
|
|
957
|
-
if (!runtime.Config) return config;
|
|
958
|
-
const result = runtime.Config["~standard"].validate(config);
|
|
959
|
-
if ("then" in result) throw new TypeError("Async config validation is not supported");
|
|
960
|
-
if (result.issues) throw new ValidationError(result.issues);
|
|
961
|
-
else return result.value;
|
|
962
|
-
}
|
|
963
|
-
const effectInertia = /* @__PURE__ */ new WeakMap();
|
|
964
|
-
function runDisposable(dispose) {
|
|
965
|
-
const result = dispose();
|
|
966
|
-
return effectInertia.get(dispose)?.() ?? result;
|
|
967
|
-
}
|
|
968
|
-
/** Notify plugin teardown without allowing one observer to break ownership cleanup. */
|
|
969
|
-
function emitPluginDisposed(context, fiber) {
|
|
970
|
-
const args = ["internal/plugin", fiber];
|
|
971
|
-
let callbacks;
|
|
972
|
-
try {
|
|
973
|
-
callbacks = context.events.dispatch("emit", args);
|
|
974
|
-
} catch (error) {
|
|
975
|
-
context.logger.error(error);
|
|
976
|
-
return;
|
|
977
|
-
}
|
|
978
|
-
for (const callback of callbacks) try {
|
|
979
|
-
const returned = callback(...args);
|
|
980
|
-
Promise.resolve(returned).catch((error) => context.logger.error(error));
|
|
981
|
-
} catch (error) {
|
|
982
|
-
context.logger.error(error);
|
|
983
|
-
}
|
|
984
|
-
}
|
|
985
|
-
/** Framework error with a stable machine-readable code. */
|
|
986
|
-
var CordisError = class CordisError extends Error {
|
|
987
|
-
code;
|
|
988
|
-
/**
|
|
989
|
-
* @param code — the stable error code; also the default message.
|
|
990
|
-
* @param message — optional human-readable override.
|
|
991
|
-
*/
|
|
992
|
-
constructor(code, message) {
|
|
993
|
-
super(message ?? CordisError.Code[code]);
|
|
994
|
-
this.code = code;
|
|
995
|
-
}
|
|
996
|
-
};
|
|
997
|
-
/** Cordis error code definitions. */
|
|
998
|
-
(function(CordisError) {
|
|
999
|
-
CordisError.Code = { INACTIVE_EFFECT: "cannot create effect on inactive context" };
|
|
1000
|
-
})(CordisError || (CordisError = {}));
|
|
1001
|
-
const INACTIVE = "__INACTIVE__";
|
|
1002
|
-
/**
|
|
1003
|
-
* Runtime instance of one plugin application.
|
|
1004
|
-
*
|
|
1005
|
-
* A fiber tracks dependency state, validated config, lifecycle effects, and
|
|
1006
|
-
* cleanup for the plugin context returned by `ctx.plugin()`.
|
|
1007
|
-
*/
|
|
1008
|
-
var Fiber = class {
|
|
1009
|
-
parent;
|
|
1010
|
-
inject;
|
|
1011
|
-
runtime;
|
|
1012
|
-
/** Unique id within the registry; 0 for the root fiber, `null` once disposed. */
|
|
1013
|
-
uid;
|
|
1014
|
-
/** The context this fiber's plugin runs in (extends the parent context). */
|
|
1015
|
-
ctx;
|
|
1016
|
-
/** The validated plugin config (updated by `update()`); read through {@link effectiveConfig}. */
|
|
1017
|
-
config;
|
|
1018
|
-
/** The raw plugin config, re-resolved before activation; use {@link rawConfig} to read or retain it. */
|
|
1019
|
-
_config;
|
|
1020
|
-
/** Current lifecycle state; transitions emit `internal/status`. */
|
|
1021
|
-
state = 0;
|
|
1022
|
-
/** Dispose this fiber: unload the plugin, then settle once cleanup finished. */
|
|
1023
|
-
dispose;
|
|
1024
|
-
/** Snapshot of required service implementations while loaded; `undefined` otherwise. */
|
|
1025
|
-
store;
|
|
1026
|
-
/** The in-flight load/unload transition, if one is currently running. */
|
|
1027
|
-
inertia;
|
|
1028
|
-
_hooks = Object.create(null);
|
|
1029
|
-
_disposables = new DisposableList();
|
|
1030
|
-
context;
|
|
1031
|
-
_error;
|
|
1032
|
-
_runner;
|
|
1033
|
-
_store = Object.create(null);
|
|
1034
|
-
/**
|
|
1035
|
-
* Create a fiber. Plugin authors normally obtain fibers from `ctx.plugin()`
|
|
1036
|
-
* rather than constructing them directly.
|
|
1037
|
-
*
|
|
1038
|
-
* @param parent — the context the plugin was loaded from.
|
|
1039
|
-
* @param config — raw config, validated against the runtime's schema.
|
|
1040
|
-
* @param inject — resolved dependency map (service name → intercept config).
|
|
1041
|
-
* @param runtime — the shared plugin runtime, or `null` for the root fiber.
|
|
1042
|
-
* @param getOuterStack — captures the caller stack for effect diagnostics.
|
|
1043
|
-
*/
|
|
1044
|
-
constructor(parent, config, inject, runtime, getOuterStack) {
|
|
1045
|
-
this.parent = parent;
|
|
1046
|
-
this.inject = inject;
|
|
1047
|
-
this.runtime = runtime;
|
|
1048
|
-
this._config = config;
|
|
1049
|
-
const collect = (dispose) => {
|
|
1050
|
-
this._disposables.push(dispose);
|
|
1051
|
-
};
|
|
1052
|
-
if (runtime) {
|
|
1053
|
-
this.uid = parent.registry.counter;
|
|
1054
|
-
this.ctx = this.context = parent.extend({ fiber: this });
|
|
1055
|
-
const injectEntries = Object.entries(this.inject);
|
|
1056
|
-
if (injectEntries.length) {
|
|
1057
|
-
this.ctx[Context.intercept] = Object.create(parent[Context.intercept]);
|
|
1058
|
-
for (const [name, config] of injectEntries) {
|
|
1059
|
-
if (isNullable(config)) continue;
|
|
1060
|
-
this.ctx[Context.intercept][name] = config;
|
|
1061
|
-
}
|
|
1062
|
-
}
|
|
1063
|
-
this._runner = {
|
|
1064
|
-
epoch: INACTIVE,
|
|
1065
|
-
getOuterStack,
|
|
1066
|
-
execute: function() {
|
|
1067
|
-
if (isConstructor(runtime.callback)) {
|
|
1068
|
-
const instance = new runtime.callback(this.ctx, this.config);
|
|
1069
|
-
for (const hook of instance?.[symbols.initHooks] ?? []) hook();
|
|
1070
|
-
return instance?.[symbols.init]?.();
|
|
1071
|
-
} else return runtime.callback(this.ctx, this.config);
|
|
1072
|
-
},
|
|
1073
|
-
collect
|
|
1074
|
-
};
|
|
1075
|
-
this.dispose = parent.fiber.effect(() => {
|
|
1076
|
-
const remove = runtime.fibers.push(this);
|
|
1077
|
-
return async () => {
|
|
1078
|
-
this.uid = null;
|
|
1079
|
-
emitPluginDisposed(this.context, this);
|
|
1080
|
-
if (this.ctx.registry.has(runtime.callback)) {
|
|
1081
|
-
remove();
|
|
1082
|
-
if (!runtime.fibers.length) this.ctx.registry.delete(runtime.callback);
|
|
1083
|
-
}
|
|
1084
|
-
this._setEpoch(INACTIVE);
|
|
1085
|
-
if (!this.inertia) this._updateState(() => {
|
|
1086
|
-
this.inertia = this._unload();
|
|
1087
|
-
return 5;
|
|
1088
|
-
});
|
|
1089
|
-
while (this.inertia) await this.inertia;
|
|
1090
|
-
};
|
|
1091
|
-
}, "ctx.plugin()");
|
|
1092
|
-
try {
|
|
1093
|
-
this.context.emit("internal/plugin", this);
|
|
1094
|
-
} catch (error) {
|
|
1095
|
-
Promise.resolve(this.dispose()).catch((reason) => this.ctx.logger.error(reason));
|
|
1096
|
-
throw error;
|
|
1097
|
-
}
|
|
1098
|
-
if (this.uid !== null && parent.fiber.state !== 5) {
|
|
1099
|
-
for (const name of Object.keys(this.inject)) this._checkImpl(name);
|
|
1100
|
-
this._refresh();
|
|
1101
|
-
}
|
|
1102
|
-
} else {
|
|
1103
|
-
this.uid = 0;
|
|
1104
|
-
this.ctx = this.context = parent;
|
|
1105
|
-
this.state = 2;
|
|
1106
|
-
this.store = Object.create(null);
|
|
1107
|
-
this._runner = {
|
|
1108
|
-
epoch: "",
|
|
1109
|
-
getOuterStack,
|
|
1110
|
-
execute: () => {},
|
|
1111
|
-
collect
|
|
1112
|
-
};
|
|
1113
|
-
this.dispose = () => this.restart();
|
|
1114
|
-
}
|
|
1115
|
-
}
|
|
1116
|
-
/** The plugin's display name, inherited from the nearest named ancestor, else `'root'`. */
|
|
1117
|
-
get name() {
|
|
1118
|
-
let fiber = this;
|
|
1119
|
-
do {
|
|
1120
|
-
if (fiber.runtime?.name) return fiber.runtime.name;
|
|
1121
|
-
fiber = fiber.parent.fiber;
|
|
1122
|
-
} while (fiber !== fiber.parent.fiber);
|
|
1123
|
-
return "root";
|
|
1124
|
-
}
|
|
1125
|
-
/**
|
|
1126
|
-
* Throw if the fiber has already been disposed.
|
|
1127
|
-
*
|
|
1128
|
-
* @returns nothing when the fiber is still active.
|
|
1129
|
-
* @throws {CordisError} `INACTIVE_EFFECT` when the fiber's uid has been cleared.
|
|
1130
|
-
*/
|
|
1131
|
-
assertActive() {
|
|
1132
|
-
if (this.uid !== null) return;
|
|
1133
|
-
throw new CordisError("INACTIVE_EFFECT");
|
|
1134
|
-
}
|
|
1135
|
-
_execute(runner) {
|
|
1136
|
-
const oldEpoch = runner.epoch;
|
|
1137
|
-
return composeError((info) => {
|
|
1138
|
-
const safeCollect = (dispose) => {
|
|
1139
|
-
if (typeof dispose === "function") runner.collect(dispose);
|
|
1140
|
-
else if (!isNullable(dispose)) throw new TypeError("Invalid effect");
|
|
1141
|
-
};
|
|
1142
|
-
const effect = runner.execute.call(this);
|
|
1143
|
-
if (typeof effect === "function") return runner.collect(effect);
|
|
1144
|
-
else if (isNullable(effect)) {} else if (!isObject(effect)) throw new TypeError("Invalid effect");
|
|
1145
|
-
else if ("then" in effect) return effect.then(safeCollect);
|
|
1146
|
-
else if (Symbol.iterator in effect) {
|
|
1147
|
-
info.error = /* @__PURE__ */ new Error();
|
|
1148
|
-
const iter = effect[Symbol.iterator]();
|
|
1149
|
-
while (true) {
|
|
1150
|
-
const result = iter.next();
|
|
1151
|
-
safeCollect(result.value);
|
|
1152
|
-
if (result.done) return;
|
|
1153
|
-
}
|
|
1154
|
-
} else if (Symbol.asyncIterator in effect) {
|
|
1155
|
-
const iter = effect[Symbol.asyncIterator]();
|
|
1156
|
-
return (async () => {
|
|
1157
|
-
await Promise.resolve();
|
|
1158
|
-
info.error = /* @__PURE__ */ new Error();
|
|
1159
|
-
while (true) {
|
|
1160
|
-
if (runner.epoch !== oldEpoch) return;
|
|
1161
|
-
const result = await iter.next();
|
|
1162
|
-
safeCollect(result.value);
|
|
1163
|
-
if (result.done) return;
|
|
1164
|
-
}
|
|
1165
|
-
})();
|
|
1166
|
-
} else throw new TypeError("Invalid effect");
|
|
1167
|
-
}, runner.getOuterStack);
|
|
1168
|
-
}
|
|
1169
|
-
effect(execute, label = "anonymous") {
|
|
1170
|
-
this.assertActive();
|
|
1171
|
-
if (this.state === 5) throw new CordisError("INACTIVE_EFFECT");
|
|
1172
|
-
const disposables = [];
|
|
1173
|
-
let disposing = false;
|
|
1174
|
-
let disposalTask;
|
|
1175
|
-
const dispose = () => {
|
|
1176
|
-
if (disposing) return disposalTask;
|
|
1177
|
-
disposing = true;
|
|
1178
|
-
let task;
|
|
1179
|
-
for (const disposable of disposables.splice(0).reverse()) if (task) task = task.then(() => runDisposable(disposable));
|
|
1180
|
-
else {
|
|
1181
|
-
const result = runDisposable(disposable);
|
|
1182
|
-
if (isObject(result) && "then" in result) task = result;
|
|
1183
|
-
}
|
|
1184
|
-
return disposalTask = task;
|
|
1185
|
-
};
|
|
1186
|
-
const meta = {
|
|
1187
|
-
label,
|
|
1188
|
-
children: []
|
|
1189
|
-
};
|
|
1190
|
-
const runner = {
|
|
1191
|
-
execute,
|
|
1192
|
-
epoch: true,
|
|
1193
|
-
collect: (dispose) => {
|
|
1194
|
-
disposables.push(dispose);
|
|
1195
|
-
this._disposables.delete(dispose);
|
|
1196
|
-
if (dispose[symbols.effect]) meta.children.push(dispose[symbols.effect]);
|
|
1197
|
-
},
|
|
1198
|
-
getOuterStack: buildOuterStack()
|
|
1199
|
-
};
|
|
1200
|
-
let task;
|
|
1201
|
-
let executing = true;
|
|
1202
|
-
let resolveSetup;
|
|
1203
|
-
let rejectSetup;
|
|
1204
|
-
let setupBarrier;
|
|
1205
|
-
let setupFailed = false;
|
|
1206
|
-
let inFlight;
|
|
1207
|
-
let removeWrapper = () => false;
|
|
1208
|
-
const waitForSetup = () => {
|
|
1209
|
-
setupBarrier ??= new Promise((resolve, reject) => {
|
|
1210
|
-
resolveSetup = resolve;
|
|
1211
|
-
rejectSetup = reject;
|
|
1212
|
-
});
|
|
1213
|
-
return setupBarrier;
|
|
1214
|
-
};
|
|
1215
|
-
const disposeAfter = (setup) => {
|
|
1216
|
-
return Promise.resolve(setup).then(() => dispose(), async (reason) => {
|
|
1217
|
-
await dispose();
|
|
1218
|
-
throw reason;
|
|
1219
|
-
});
|
|
1220
|
-
};
|
|
1221
|
-
const finalizeDisposal = (callback) => {
|
|
1222
|
-
let result;
|
|
1223
|
-
try {
|
|
1224
|
-
result = callback();
|
|
1225
|
-
} catch (error) {
|
|
1226
|
-
removeWrapper();
|
|
1227
|
-
throw error;
|
|
1228
|
-
}
|
|
1229
|
-
if (isObject(result) && "then" in result) {
|
|
1230
|
-
const pending = Promise.resolve(result).finally(() => {
|
|
1231
|
-
removeWrapper();
|
|
1232
|
-
if (inFlight === pending) inFlight = void 0;
|
|
1233
|
-
});
|
|
1234
|
-
return inFlight = pending;
|
|
1235
|
-
}
|
|
1236
|
-
removeWrapper();
|
|
1237
|
-
return result;
|
|
1238
|
-
};
|
|
1239
|
-
const wrapper = defineProperty(() => {
|
|
1240
|
-
if (!runner.epoch) return setupFailed ? inFlight : void 0;
|
|
1241
|
-
runner.epoch = false;
|
|
1242
|
-
return finalizeDisposal(() => {
|
|
1243
|
-
if (executing) return disposeAfter(waitForSetup());
|
|
1244
|
-
return task ? disposeAfter(task) : dispose();
|
|
1245
|
-
});
|
|
1246
|
-
}, symbols.effect, meta);
|
|
1247
|
-
effectInertia.set(wrapper, () => inFlight);
|
|
1248
|
-
removeWrapper = this._disposables.push(wrapper);
|
|
1249
|
-
try {
|
|
1250
|
-
task = this._execute(runner);
|
|
1251
|
-
} catch (reason) {
|
|
1252
|
-
executing = false;
|
|
1253
|
-
setupFailed = true;
|
|
1254
|
-
runner.epoch = false;
|
|
1255
|
-
let cleanup;
|
|
1256
|
-
try {
|
|
1257
|
-
cleanup = finalizeDisposal(dispose);
|
|
1258
|
-
} finally {
|
|
1259
|
-
rejectSetup?.(reason);
|
|
1260
|
-
}
|
|
1261
|
-
if (isObject(cleanup) && "then" in cleanup) cleanup.catch((error) => this.ctx.logger.error(error));
|
|
1262
|
-
throw reason;
|
|
1263
|
-
}
|
|
1264
|
-
executing = false;
|
|
1265
|
-
if (setupBarrier) Promise.resolve(task).then(resolveSetup, rejectSetup);
|
|
1266
|
-
task?.catch(() => {
|
|
1267
|
-
if (!runner.epoch) return dispose();
|
|
1268
|
-
return finalizeDisposal(dispose);
|
|
1269
|
-
}).catch((error) => this.ctx.logger.error(error));
|
|
1270
|
-
const disposeAsync = () => {
|
|
1271
|
-
if (!runner.epoch) return;
|
|
1272
|
-
runner.epoch = false;
|
|
1273
|
-
return finalizeDisposal(dispose);
|
|
1274
|
-
};
|
|
1275
|
-
wrapper.then = async (onFulfilled, onRejected) => {
|
|
1276
|
-
return Promise.resolve(task).then(() => disposeAsync).then(onFulfilled, onRejected);
|
|
1277
|
-
};
|
|
1278
|
-
return wrapper;
|
|
1279
|
-
}
|
|
1280
|
-
/**
|
|
1281
|
-
* Return metadata for currently registered effects.
|
|
1282
|
-
*
|
|
1283
|
-
* @returns one {@link EffectMeta} tree per labeled live effect.
|
|
1284
|
-
*/
|
|
1285
|
-
getEffects() {
|
|
1286
|
-
return [...this._disposables].map((dispose) => dispose[symbols.effect]).filter(Boolean);
|
|
1287
|
-
}
|
|
1288
|
-
_getState() {
|
|
1289
|
-
if (this.uid === null) return 4;
|
|
1290
|
-
if (this._error) return 3;
|
|
1291
|
-
if (this._runner.epoch !== INACTIVE) return 2;
|
|
1292
|
-
return 0;
|
|
1293
|
-
}
|
|
1294
|
-
_updateState(callback) {
|
|
1295
|
-
const oldState = this.state;
|
|
1296
|
-
this.state = callback() ?? this._getState();
|
|
1297
|
-
if (oldState === this.state) return;
|
|
1298
|
-
this.context.emit("internal/status", this, oldState);
|
|
1299
|
-
if (oldState !== 2 && this.state !== 2) return;
|
|
1300
|
-
for (const key of Reflect.ownKeys(this.ctx.reflect.store)) {
|
|
1301
|
-
const impl = this.ctx.reflect.store[key];
|
|
1302
|
-
if (impl.fiber !== this) continue;
|
|
1303
|
-
this.ctx.reflect.notify([impl.name]);
|
|
1304
|
-
}
|
|
1305
|
-
}
|
|
1306
|
-
_checkImpl(name) {
|
|
1307
|
-
const impl = this.ctx.reflect._getImpl(name, true);
|
|
1308
|
-
if (!impl) return delete this._store[name];
|
|
1309
|
-
try {
|
|
1310
|
-
if (impl.check && !impl.check.call(getTraceable(this.ctx, impl.value))) return delete this._store[name];
|
|
1311
|
-
} catch (error) {
|
|
1312
|
-
impl.fiber.ctx.logger.error(error);
|
|
1313
|
-
return delete this._store[name];
|
|
1314
|
-
}
|
|
1315
|
-
this._store[name] = impl;
|
|
1316
|
-
}
|
|
1317
|
-
_refresh() {
|
|
1318
|
-
let epoch = false;
|
|
1319
|
-
epoch = "";
|
|
1320
|
-
for (const name of Object.keys(this.inject)) {
|
|
1321
|
-
const impl = this._store[name];
|
|
1322
|
-
if (!impl) {
|
|
1323
|
-
epoch = INACTIVE;
|
|
1324
|
-
break;
|
|
1299
|
+
} catch (e) {
|
|
1300
|
+
throw e === error ? enhanceError(e) : e;
|
|
1325
1301
|
}
|
|
1326
|
-
|
|
1302
|
+
},
|
|
1303
|
+
has: (target, prop) => {
|
|
1304
|
+
if (isSpecialProperty(prop)) return Reflect.has(target, prop);
|
|
1305
|
+
if (Reflect.has(target, prop)) return true;
|
|
1306
|
+
return !!target.reflect.props[prop];
|
|
1327
1307
|
}
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
this.
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
} else {
|
|
1340
|
-
this.inertia = this._unload();
|
|
1341
|
-
return 5;
|
|
1342
|
-
}
|
|
1308
|
+
};
|
|
1309
|
+
/** Service implementations, keyed by isolation label. */
|
|
1310
|
+
store = Object.create(null);
|
|
1311
|
+
/** Declared context properties (services and accessors), by name. */
|
|
1312
|
+
props = Object.create(null);
|
|
1313
|
+
_implCounter = 0;
|
|
1314
|
+
constructor(ctx) {
|
|
1315
|
+
this.ctx = ctx;
|
|
1316
|
+
defineProperty(this, symbols.tracker, {
|
|
1317
|
+
property: "ctx",
|
|
1318
|
+
noShadow: true
|
|
1343
1319
|
});
|
|
1320
|
+
this.mixin("reflect", [
|
|
1321
|
+
"get",
|
|
1322
|
+
"set",
|
|
1323
|
+
"provide",
|
|
1324
|
+
"accessor",
|
|
1325
|
+
"mixin"
|
|
1326
|
+
]);
|
|
1327
|
+
this.mixin("fiber", ["runtime", "effect"]);
|
|
1328
|
+
this.mixin("registry", ["inject", "plugin"]);
|
|
1329
|
+
this.mixin("events", [
|
|
1330
|
+
"on",
|
|
1331
|
+
"once",
|
|
1332
|
+
"parallel",
|
|
1333
|
+
"emit",
|
|
1334
|
+
"serial",
|
|
1335
|
+
"bail",
|
|
1336
|
+
"waterfall"
|
|
1337
|
+
]);
|
|
1344
1338
|
}
|
|
1345
|
-
/**
|
|
1346
|
-
|
|
1347
|
-
|
|
1339
|
+
/**
|
|
1340
|
+
* Read a service from the store without the inject requirement.
|
|
1341
|
+
*
|
|
1342
|
+
* @param name — the service name.
|
|
1343
|
+
* @param strict — when `true`, only return implementations whose providing
|
|
1344
|
+
* fiber is currently active.
|
|
1345
|
+
* @returns the service value, or `undefined` when not (yet) provided.
|
|
1346
|
+
*/
|
|
1347
|
+
get(name, strict = true) {
|
|
1348
|
+
return getTraceable(this.ctx, this._getImpl(name, strict)?.value);
|
|
1348
1349
|
}
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1350
|
+
_getImpl(name, strict = true) {
|
|
1351
|
+
const key = this.ctx[symbols.isolate][name];
|
|
1352
|
+
const impl = key && this.store[key];
|
|
1353
|
+
if (!impl) return;
|
|
1354
|
+
if (strict && impl.ctx.fiber.state !== 2) return;
|
|
1355
|
+
return impl;
|
|
1352
1356
|
}
|
|
1353
1357
|
/**
|
|
1354
|
-
*
|
|
1355
|
-
*
|
|
1358
|
+
* Overwrite a provided service's value.
|
|
1359
|
+
*
|
|
1360
|
+
* @param name — the service name.
|
|
1361
|
+
* @param value — the new service value.
|
|
1362
|
+
* @param error — carrier for the caller stack in diagnostics.
|
|
1363
|
+
* @returns `true` on success.
|
|
1364
|
+
* @throws when `name` was never provided, or was provided by another fiber.
|
|
1356
1365
|
*/
|
|
1357
|
-
|
|
1358
|
-
|
|
1366
|
+
set(name, value, error) {
|
|
1367
|
+
const key = this.ctx[symbols.isolate][name];
|
|
1368
|
+
const impl = this.store[key];
|
|
1369
|
+
if (!impl) throw new Error(`cannot set property "${name}" without provide`);
|
|
1370
|
+
if (impl.ctx.fiber !== this.ctx.fiber) throw new Error(`cannot set property "${name}" in multiple fibers`);
|
|
1371
|
+
impl.value = value;
|
|
1372
|
+
return true;
|
|
1359
1373
|
}
|
|
1360
1374
|
/**
|
|
1361
|
-
*
|
|
1362
|
-
*
|
|
1363
|
-
*
|
|
1364
|
-
*
|
|
1365
|
-
* @
|
|
1366
|
-
* @
|
|
1375
|
+
* Register a service implementation owned by the current fiber.
|
|
1376
|
+
*
|
|
1377
|
+
* See the `ctx.provide()` overload above for the full contract.
|
|
1378
|
+
*
|
|
1379
|
+
* @param name — the service name.
|
|
1380
|
+
* @param value — the service value.
|
|
1381
|
+
* @param check — optional availability predicate for dependents.
|
|
1382
|
+
* @returns a disposer that unregisters the service.
|
|
1367
1383
|
*/
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1384
|
+
provide(name, value, check) {
|
|
1385
|
+
return this.ctx.fiber.effect(() => {
|
|
1386
|
+
if (!this.props[name]) this.props[name] ??= { type: "service" };
|
|
1387
|
+
else if (this.props[name].type !== "service") throw new Error(`property "${name}" is already declared as ${this.props[name].type}`);
|
|
1388
|
+
this.props[name] = { type: "service" };
|
|
1389
|
+
this.ctx.root[symbols.isolate][name] ??= Symbol(name);
|
|
1390
|
+
const key = this.ctx[symbols.isolate][name];
|
|
1391
|
+
const impl = {
|
|
1392
|
+
uid: ++this._implCounter,
|
|
1393
|
+
name,
|
|
1394
|
+
value,
|
|
1395
|
+
ctx: this.ctx,
|
|
1396
|
+
check,
|
|
1397
|
+
isolate: key,
|
|
1398
|
+
dependents: /* @__PURE__ */ new Set()
|
|
1399
|
+
};
|
|
1400
|
+
if (this.store[key]) throw new Error(`service "${name}" has been registered at <${this.store[key].ctx.fiber.name}>`);
|
|
1401
|
+
this.store[key] = impl;
|
|
1402
|
+
this.ctx.fiber.provisions.add(impl);
|
|
1403
|
+
if (this.ctx.fiber.state === 2) this.notify([name]);
|
|
1404
|
+
return async () => {
|
|
1405
|
+
if (this.store[impl.isolate] === impl) delete this.store[impl.isolate];
|
|
1406
|
+
this.ctx.isolate(name, impl.isolate).reflect.notify([name]);
|
|
1407
|
+
await new Promise((resolve) => {
|
|
1408
|
+
impl.release = resolve;
|
|
1409
|
+
if (!impl.dependents.size) resolve();
|
|
1410
|
+
});
|
|
1411
|
+
impl.release = void 0;
|
|
1412
|
+
this.ctx.fiber.provisions.delete(impl);
|
|
1413
|
+
};
|
|
1414
|
+
}, `ctx.provide(${JSON.stringify(name)})`);
|
|
1372
1415
|
}
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1416
|
+
/**
|
|
1417
|
+
* Re-evaluate every fiber that requires one of the given services.
|
|
1418
|
+
*
|
|
1419
|
+
* @param names — the service names that changed.
|
|
1420
|
+
* @param filter — restricts notification to matching isolation scopes.
|
|
1421
|
+
*/
|
|
1422
|
+
notify(names, filter = (ctx, name) => ctx[symbols.isolate][name] === this.ctx[symbols.isolate][name]) {
|
|
1423
|
+
for (const runtime of this.ctx.registry.values()) for (const fiber of runtime.fibers) {
|
|
1424
|
+
let hasUpdate = false;
|
|
1425
|
+
for (const name of names) {
|
|
1426
|
+
if (!(name in fiber.inject)) continue;
|
|
1427
|
+
if (!filter(fiber.ctx, name)) continue;
|
|
1428
|
+
hasUpdate = true;
|
|
1429
|
+
fiber._checkImpl(name);
|
|
1382
1430
|
}
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1431
|
+
if (!hasUpdate) continue;
|
|
1432
|
+
fiber._refresh();
|
|
1433
|
+
}
|
|
1434
|
+
for (const name of names) {
|
|
1435
|
+
const self = Object.create(this.ctx);
|
|
1436
|
+
self[symbols.filter] = (target) => filter(target, name);
|
|
1437
|
+
this.ctx.events.emit(self, "internal/service", name, this._getImpl(name, false)?.value);
|
|
1387
1438
|
}
|
|
1388
|
-
this._updateState(() => {
|
|
1389
|
-
if (this._runner.epoch === oldEpoch) this.inertia = void 0;
|
|
1390
|
-
else {
|
|
1391
|
-
this.inertia = this._unload();
|
|
1392
|
-
return 5;
|
|
1393
|
-
}
|
|
1394
|
-
});
|
|
1395
|
-
}
|
|
1396
|
-
async _unload() {
|
|
1397
|
-
await Promise.all(this._disposables.clear().map(async (dispose) => {
|
|
1398
|
-
try {
|
|
1399
|
-
await composeError(async (info) => {
|
|
1400
|
-
await Promise.resolve();
|
|
1401
|
-
info.error = /* @__PURE__ */ new Error();
|
|
1402
|
-
await runDisposable(dispose);
|
|
1403
|
-
}, this._runner.getOuterStack);
|
|
1404
|
-
} catch (reason) {
|
|
1405
|
-
this.ctx.logger.error(reason);
|
|
1406
|
-
}
|
|
1407
|
-
}));
|
|
1408
|
-
this.store = void 0;
|
|
1409
|
-
this._updateState(() => {
|
|
1410
|
-
if (this._runner.epoch === INACTIVE) this.inertia = void 0;
|
|
1411
|
-
else {
|
|
1412
|
-
this.inertia = this._reload();
|
|
1413
|
-
return 1;
|
|
1414
|
-
}
|
|
1415
|
-
});
|
|
1416
1439
|
}
|
|
1417
1440
|
/**
|
|
1418
|
-
*
|
|
1441
|
+
* Define a computed context property backed by get/set hooks.
|
|
1419
1442
|
*
|
|
1420
|
-
* @
|
|
1421
|
-
* @
|
|
1443
|
+
* @param name — the context property name.
|
|
1444
|
+
* @param options — the `get` hook and optional `set` hook.
|
|
1445
|
+
* @returns a disposer that removes the accessor.
|
|
1422
1446
|
*/
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1447
|
+
accessor(name, options) {
|
|
1448
|
+
return this.ctx.fiber.effect(() => {
|
|
1449
|
+
if (name in this.props) throw new Error(`property "${name}" is already declared as ${this.props[name].type}`);
|
|
1450
|
+
this.props[name] = {
|
|
1451
|
+
type: "accessor",
|
|
1452
|
+
...options
|
|
1453
|
+
};
|
|
1454
|
+
return () => delete this.props[name];
|
|
1455
|
+
}, `ctx.accessor(${JSON.stringify(name)})`);
|
|
1427
1456
|
}
|
|
1428
1457
|
/**
|
|
1429
|
-
*
|
|
1458
|
+
* Expose selected members of a service directly on `ctx`.
|
|
1430
1459
|
*
|
|
1431
|
-
*
|
|
1432
|
-
*
|
|
1460
|
+
* See the `ctx.mixin()` overload above for the full contract.
|
|
1461
|
+
*
|
|
1462
|
+
* @param source — a context property name or a source object.
|
|
1463
|
+
* @param mixins — keys to forward, or a source-key → ctx-key map.
|
|
1464
|
+
* @returns a disposer that removes all created accessors.
|
|
1433
1465
|
*/
|
|
1434
|
-
|
|
1435
|
-
const
|
|
1436
|
-
fiber.
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1466
|
+
mixin(source, mixins) {
|
|
1467
|
+
const self = this;
|
|
1468
|
+
return this.ctx.fiber.effect(function* () {
|
|
1469
|
+
const entries = Array.isArray(mixins) ? mixins.map((key) => [key, key]) : Object.entries(mixins);
|
|
1470
|
+
const getTarget = (ctx, error) => {
|
|
1471
|
+
return ctx[source];
|
|
1472
|
+
};
|
|
1473
|
+
for (const [key, value] of entries) yield self.accessor(value, {
|
|
1474
|
+
get(receiver, error) {
|
|
1475
|
+
const service = getTarget(this, error);
|
|
1476
|
+
if (isNullable(service)) return service;
|
|
1477
|
+
const mixin = receiver ? withProps(receiver, service) : service;
|
|
1478
|
+
const value = Reflect.get(service, key, mixin);
|
|
1479
|
+
if (typeof value !== "function") return value;
|
|
1480
|
+
return value.bind(mixin ?? service);
|
|
1481
|
+
},
|
|
1482
|
+
set(value, receiver, error) {
|
|
1483
|
+
const service = getTarget(this, error);
|
|
1484
|
+
const mixin = receiver ? withProps(receiver, service) : service;
|
|
1485
|
+
return Reflect.set(service, key, value, mixin);
|
|
1486
|
+
}
|
|
1487
|
+
});
|
|
1488
|
+
}, `ctx.mixin(${JSON.stringify(source)})`);
|
|
1440
1489
|
}
|
|
1441
1490
|
/**
|
|
1442
|
-
*
|
|
1491
|
+
* Attach this context's tracing wrapper to a value.
|
|
1443
1492
|
*
|
|
1444
|
-
*
|
|
1445
|
-
*
|
|
1493
|
+
* @param value — the value to wrap.
|
|
1494
|
+
* @returns the traceable wrapper (or the value itself when not applicable).
|
|
1495
|
+
*/
|
|
1496
|
+
trace(value) {
|
|
1497
|
+
return getTraceable(this.ctx, value);
|
|
1498
|
+
}
|
|
1499
|
+
/**
|
|
1500
|
+
* Wrap a callback so calls trace `this` and arguments to this context.
|
|
1446
1501
|
*
|
|
1447
|
-
* @param
|
|
1448
|
-
* @
|
|
1449
|
-
* @returns nothing; the restart runs behind the `internal/update` waterfall.
|
|
1450
|
-
* @throws {ValidationError} when the new config fails validation.
|
|
1502
|
+
* @param callback — the function to wrap.
|
|
1503
|
+
* @returns a proxy delegating to `callback` with traced values.
|
|
1451
1504
|
*/
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
return;
|
|
1461
|
-
}
|
|
1462
|
-
config = fiber.resolveConfig(config);
|
|
1463
|
-
fiber.context.waterfall(fiber, "internal/update", config, noSave, () => {
|
|
1464
|
-
fiber.config = config;
|
|
1465
|
-
fiber._error = void 0;
|
|
1466
|
-
return fiber.restart();
|
|
1505
|
+
bind(callback) {
|
|
1506
|
+
return new Proxy(callback, {
|
|
1507
|
+
apply: (target, thisArg, args) => {
|
|
1508
|
+
return Reflect.apply(target, this.trace(thisArg), args.map((arg) => this.trace(arg)));
|
|
1509
|
+
},
|
|
1510
|
+
construct: (target, args, newTarget) => {
|
|
1511
|
+
return Reflect.construct(target, args.map((arg) => this.trace(arg)), newTarget);
|
|
1512
|
+
}
|
|
1467
1513
|
});
|
|
1468
1514
|
}
|
|
1469
1515
|
};
|