@tianshu-ai/tianshu 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +200 -0
- package/README.md +284 -0
- package/README.zh-CN.md +136 -0
- package/bin/tianshu.mjs +32 -0
- package/package.json +60 -0
- package/packages/plugin-sdk/dist/agent-loop.d.ts +96 -0
- package/packages/plugin-sdk/dist/agent-loop.d.ts.map +1 -0
- package/packages/plugin-sdk/dist/agent-loop.js +11 -0
- package/packages/plugin-sdk/dist/agent-loop.js.map +1 -0
- package/packages/plugin-sdk/dist/capabilities.d.ts +48 -0
- package/packages/plugin-sdk/dist/capabilities.d.ts.map +1 -0
- package/packages/plugin-sdk/dist/capabilities.js +61 -0
- package/packages/plugin-sdk/dist/capabilities.js.map +1 -0
- package/packages/plugin-sdk/dist/catalog.d.ts +60 -0
- package/packages/plugin-sdk/dist/catalog.d.ts.map +1 -0
- package/packages/plugin-sdk/dist/catalog.js +11 -0
- package/packages/plugin-sdk/dist/catalog.js.map +1 -0
- package/packages/plugin-sdk/dist/client.d.ts +171 -0
- package/packages/plugin-sdk/dist/client.d.ts.map +1 -0
- package/packages/plugin-sdk/dist/client.js +96 -0
- package/packages/plugin-sdk/dist/client.js.map +1 -0
- package/packages/plugin-sdk/dist/index.d.ts +9 -0
- package/packages/plugin-sdk/dist/index.d.ts.map +1 -0
- package/packages/plugin-sdk/dist/index.js +19 -0
- package/packages/plugin-sdk/dist/index.js.map +1 -0
- package/packages/plugin-sdk/dist/lsp.d.ts +32 -0
- package/packages/plugin-sdk/dist/lsp.d.ts.map +1 -0
- package/packages/plugin-sdk/dist/lsp.js +19 -0
- package/packages/plugin-sdk/dist/lsp.js.map +1 -0
- package/packages/plugin-sdk/dist/manifest.d.ts +423 -0
- package/packages/plugin-sdk/dist/manifest.d.ts.map +1 -0
- package/packages/plugin-sdk/dist/manifest.js +7 -0
- package/packages/plugin-sdk/dist/manifest.js.map +1 -0
- package/packages/plugin-sdk/dist/mcp-client.d.ts +74 -0
- package/packages/plugin-sdk/dist/mcp-client.d.ts.map +1 -0
- package/packages/plugin-sdk/dist/mcp-client.js +226 -0
- package/packages/plugin-sdk/dist/mcp-client.js.map +1 -0
- package/packages/plugin-sdk/dist/mcp-fetch.d.ts +10 -0
- package/packages/plugin-sdk/dist/mcp-fetch.d.ts.map +1 -0
- package/packages/plugin-sdk/dist/mcp-fetch.js +130 -0
- package/packages/plugin-sdk/dist/mcp-fetch.js.map +1 -0
- package/packages/plugin-sdk/dist/mcp-toolset.d.ts +128 -0
- package/packages/plugin-sdk/dist/mcp-toolset.d.ts.map +1 -0
- package/packages/plugin-sdk/dist/mcp-toolset.js +246 -0
- package/packages/plugin-sdk/dist/mcp-toolset.js.map +1 -0
- package/packages/plugin-sdk/dist/server.d.ts +486 -0
- package/packages/plugin-sdk/dist/server.d.ts.map +1 -0
- package/packages/plugin-sdk/dist/server.js +10 -0
- package/packages/plugin-sdk/dist/server.js.map +1 -0
- package/packages/plugin-sdk/dist/session-inbox.d.ts +56 -0
- package/packages/plugin-sdk/dist/session-inbox.d.ts.map +1 -0
- package/packages/plugin-sdk/dist/session-inbox.js +12 -0
- package/packages/plugin-sdk/dist/session-inbox.js.map +1 -0
- package/packages/plugin-sdk/package.json +36 -0
- package/packages/server/builtinConfig/plugins/README.md +1 -0
- package/packages/server/builtinConfig/plugins/files/manifest.json +100 -0
- package/packages/server/builtinConfig/plugins/files/skills/files-workspace-layout.md +29 -0
- package/packages/server/builtinConfig/plugins/microsandbox/manifest.json +177 -0
- package/packages/server/builtinConfig/plugins/microsandbox/skills/microsandbox-browser-howto.md +155 -0
- package/packages/server/builtinConfig/plugins/microsandbox/skills/microsandbox-build-use.md +201 -0
- package/packages/server/builtinConfig/plugins/microsandbox/skills/microsandbox-config.md +38 -0
- package/packages/server/builtinConfig/plugins/microsandbox/skills/microsandbox-exec-howto.md +144 -0
- package/packages/server/builtinConfig/plugins/microsandbox/skills/microsandbox-libreoffice.md +159 -0
- package/packages/server/builtinConfig/plugins/microsandbox/skills/microsandbox-main-orchestration.md +75 -0
- package/packages/server/builtinConfig/plugins/microsandbox/templates/README.md +26 -0
- package/packages/server/builtinConfig/plugins/microsandbox/templates/browser.yaml +105 -0
- package/packages/server/builtinConfig/plugins/microsandbox/templates/task-runner-with-browser.yaml +80 -0
- package/packages/server/builtinConfig/plugins/microsandbox/templates/task-runner.yaml +80 -0
- package/packages/server/builtinConfig/plugins/web-search/manifest.json +65 -0
- package/packages/server/builtinConfig/plugins/web-search/skills/web-search-howto.md +69 -0
- package/packages/server/builtinConfig/plugins/workboard/agent-seeds/echo-demo/agent.json +7 -0
- package/packages/server/builtinConfig/plugins/workboard/agent-seeds/llm-default/SOUL.md +53 -0
- package/packages/server/builtinConfig/plugins/workboard/agent-seeds/llm-default/agent.json +7 -0
- package/packages/server/builtinConfig/plugins/workboard/manifest.json +180 -0
- package/packages/server/builtinConfig/plugins/workboard/skills/large-input-large-output.md +185 -0
- package/packages/server/builtinConfig/plugins/workboard/skills/workboard-howto.md +166 -0
- package/packages/server/builtinConfig/plugins/workboard/skills/worker-creator.md +267 -0
- package/packages/server/builtinConfig/plugins/workboard/skills/worker-fleet.md +431 -0
- package/packages/server/dist/catalog.d.ts +52 -0
- package/packages/server/dist/catalog.d.ts.map +1 -0
- package/packages/server/dist/catalog.js +189 -0
- package/packages/server/dist/catalog.js.map +1 -0
- package/packages/server/dist/chat/active-harnesses.d.ts +34 -0
- package/packages/server/dist/chat/active-harnesses.d.ts.map +1 -0
- package/packages/server/dist/chat/active-harnesses.js +118 -0
- package/packages/server/dist/chat/active-harnesses.js.map +1 -0
- package/packages/server/dist/chat/agent-loop.d.ts +64 -0
- package/packages/server/dist/chat/agent-loop.d.ts.map +1 -0
- package/packages/server/dist/chat/agent-loop.js +597 -0
- package/packages/server/dist/chat/agent-loop.js.map +1 -0
- package/packages/server/dist/chat/agent-tool-adapter.d.ts +33 -0
- package/packages/server/dist/chat/agent-tool-adapter.d.ts.map +1 -0
- package/packages/server/dist/chat/agent-tool-adapter.js +260 -0
- package/packages/server/dist/chat/agent-tool-adapter.js.map +1 -0
- package/packages/server/dist/chat/compact.d.ts +52 -0
- package/packages/server/dist/chat/compact.d.ts.map +1 -0
- package/packages/server/dist/chat/compact.js +248 -0
- package/packages/server/dist/chat/compact.js.map +1 -0
- package/packages/server/dist/chat/dump-system-prompt.d.ts +17 -0
- package/packages/server/dist/chat/dump-system-prompt.d.ts.map +1 -0
- package/packages/server/dist/chat/dump-system-prompt.js +58 -0
- package/packages/server/dist/chat/dump-system-prompt.js.map +1 -0
- package/packages/server/dist/chat/handler.d.ts +186 -0
- package/packages/server/dist/chat/handler.d.ts.map +1 -0
- package/packages/server/dist/chat/handler.js +1248 -0
- package/packages/server/dist/chat/handler.js.map +1 -0
- package/packages/server/dist/chat/image-fit.d.ts +34 -0
- package/packages/server/dist/chat/image-fit.d.ts.map +1 -0
- package/packages/server/dist/chat/image-fit.js +157 -0
- package/packages/server/dist/chat/image-fit.js.map +1 -0
- package/packages/server/dist/chat/messages.d.ts +118 -0
- package/packages/server/dist/chat/messages.d.ts.map +1 -0
- package/packages/server/dist/chat/messages.js +341 -0
- package/packages/server/dist/chat/messages.js.map +1 -0
- package/packages/server/dist/chat/session-inbox.d.ts +114 -0
- package/packages/server/dist/chat/session-inbox.d.ts.map +1 -0
- package/packages/server/dist/chat/session-inbox.js +418 -0
- package/packages/server/dist/chat/session-inbox.js.map +1 -0
- package/packages/server/dist/chat/sqlite-session-repo.d.ts +26 -0
- package/packages/server/dist/chat/sqlite-session-repo.d.ts.map +1 -0
- package/packages/server/dist/chat/sqlite-session-repo.js +132 -0
- package/packages/server/dist/chat/sqlite-session-repo.js.map +1 -0
- package/packages/server/dist/chat/sqlite-session-storage.d.ts +83 -0
- package/packages/server/dist/chat/sqlite-session-storage.d.ts.map +1 -0
- package/packages/server/dist/chat/sqlite-session-storage.js +418 -0
- package/packages/server/dist/chat/sqlite-session-storage.js.map +1 -0
- package/packages/server/dist/chat/stub-execution-env.d.ts +3 -0
- package/packages/server/dist/chat/stub-execution-env.d.ts.map +1 -0
- package/packages/server/dist/chat/stub-execution-env.js +87 -0
- package/packages/server/dist/chat/stub-execution-env.js.map +1 -0
- package/packages/server/dist/chat/token-estimate.d.ts +11 -0
- package/packages/server/dist/chat/token-estimate.d.ts.map +1 -0
- package/packages/server/dist/chat/token-estimate.js +67 -0
- package/packages/server/dist/chat/token-estimate.js.map +1 -0
- package/packages/server/dist/chat/ws-protocol.d.ts +244 -0
- package/packages/server/dist/chat/ws-protocol.d.ts.map +1 -0
- package/packages/server/dist/chat/ws-protocol.js +193 -0
- package/packages/server/dist/chat/ws-protocol.js.map +1 -0
- package/packages/server/dist/cli.d.ts +9 -0
- package/packages/server/dist/cli.d.ts.map +1 -0
- package/packages/server/dist/cli.js +329 -0
- package/packages/server/dist/cli.js.map +1 -0
- package/packages/server/dist/core/agent-seeds.d.ts +25 -0
- package/packages/server/dist/core/agent-seeds.d.ts.map +1 -0
- package/packages/server/dist/core/agent-seeds.js +69 -0
- package/packages/server/dist/core/agent-seeds.js.map +1 -0
- package/packages/server/dist/core/config.d.ts +172 -0
- package/packages/server/dist/core/config.d.ts.map +1 -0
- package/packages/server/dist/core/config.js +155 -0
- package/packages/server/dist/core/config.js.map +1 -0
- package/packages/server/dist/core/db-pool.d.ts +32 -0
- package/packages/server/dist/core/db-pool.d.ts.map +1 -0
- package/packages/server/dist/core/db-pool.js +108 -0
- package/packages/server/dist/core/db-pool.js.map +1 -0
- package/packages/server/dist/core/dev-mode.d.ts +13 -0
- package/packages/server/dist/core/dev-mode.d.ts.map +1 -0
- package/packages/server/dist/core/dev-mode.js +51 -0
- package/packages/server/dist/core/dev-mode.js.map +1 -0
- package/packages/server/dist/core/global-ops.d.ts +54 -0
- package/packages/server/dist/core/global-ops.d.ts.map +1 -0
- package/packages/server/dist/core/global-ops.js +143 -0
- package/packages/server/dist/core/global-ops.js.map +1 -0
- package/packages/server/dist/core/identity-resolvers.d.ts +102 -0
- package/packages/server/dist/core/identity-resolvers.d.ts.map +1 -0
- package/packages/server/dist/core/identity-resolvers.js +176 -0
- package/packages/server/dist/core/identity-resolvers.js.map +1 -0
- package/packages/server/dist/core/index.d.ts +13 -0
- package/packages/server/dist/core/index.d.ts.map +1 -0
- package/packages/server/dist/core/index.js +18 -0
- package/packages/server/dist/core/index.js.map +1 -0
- package/packages/server/dist/core/llm.d.ts +45 -0
- package/packages/server/dist/core/llm.d.ts.map +1 -0
- package/packages/server/dist/core/llm.js +140 -0
- package/packages/server/dist/core/llm.js.map +1 -0
- package/packages/server/dist/core/mcp-manager.d.ts +47 -0
- package/packages/server/dist/core/mcp-manager.d.ts.map +1 -0
- package/packages/server/dist/core/mcp-manager.js +129 -0
- package/packages/server/dist/core/mcp-manager.js.map +1 -0
- package/packages/server/dist/core/middleware.d.ts +31 -0
- package/packages/server/dist/core/middleware.d.ts.map +1 -0
- package/packages/server/dist/core/middleware.js +102 -0
- package/packages/server/dist/core/middleware.js.map +1 -0
- package/packages/server/dist/core/migrations/001-initial.d.ts +4 -0
- package/packages/server/dist/core/migrations/001-initial.d.ts.map +1 -0
- package/packages/server/dist/core/migrations/001-initial.js +66 -0
- package/packages/server/dist/core/migrations/001-initial.js.map +1 -0
- package/packages/server/dist/core/migrations/002-task-dependencies.d.ts +4 -0
- package/packages/server/dist/core/migrations/002-task-dependencies.d.ts.map +1 -0
- package/packages/server/dist/core/migrations/002-task-dependencies.js +20 -0
- package/packages/server/dist/core/migrations/002-task-dependencies.js.map +1 -0
- package/packages/server/dist/core/migrations/003-session-tree.d.ts +4 -0
- package/packages/server/dist/core/migrations/003-session-tree.d.ts.map +1 -0
- package/packages/server/dist/core/migrations/003-session-tree.js +96 -0
- package/packages/server/dist/core/migrations/003-session-tree.js.map +1 -0
- package/packages/server/dist/core/migrations/003-worker-agents.d.ts +4 -0
- package/packages/server/dist/core/migrations/003-worker-agents.d.ts.map +1 -0
- package/packages/server/dist/core/migrations/003-worker-agents.js +65 -0
- package/packages/server/dist/core/migrations/003-worker-agents.js.map +1 -0
- package/packages/server/dist/core/migrations/004-rebuild-message-chain.d.ts +4 -0
- package/packages/server/dist/core/migrations/004-rebuild-message-chain.d.ts.map +1 -0
- package/packages/server/dist/core/migrations/004-rebuild-message-chain.js +52 -0
- package/packages/server/dist/core/migrations/004-rebuild-message-chain.js.map +1 -0
- package/packages/server/dist/core/migrations/005-task-status-rename.d.ts +4 -0
- package/packages/server/dist/core/migrations/005-task-status-rename.d.ts.map +1 -0
- package/packages/server/dist/core/migrations/005-task-status-rename.js +64 -0
- package/packages/server/dist/core/migrations/005-task-status-rename.js.map +1 -0
- package/packages/server/dist/core/migrations/006-task-labels.d.ts +4 -0
- package/packages/server/dist/core/migrations/006-task-labels.d.ts.map +1 -0
- package/packages/server/dist/core/migrations/006-task-labels.js +43 -0
- package/packages/server/dist/core/migrations/006-task-labels.js.map +1 -0
- package/packages/server/dist/core/migrations/007-session-inbox.d.ts +4 -0
- package/packages/server/dist/core/migrations/007-session-inbox.d.ts.map +1 -0
- package/packages/server/dist/core/migrations/007-session-inbox.js +67 -0
- package/packages/server/dist/core/migrations/007-session-inbox.js.map +1 -0
- package/packages/server/dist/core/migrations/008-task-intervention.d.ts +4 -0
- package/packages/server/dist/core/migrations/008-task-intervention.d.ts.map +1 -0
- package/packages/server/dist/core/migrations/008-task-intervention.js +60 -0
- package/packages/server/dist/core/migrations/008-task-intervention.js.map +1 -0
- package/packages/server/dist/core/migrations/index.d.ts +12 -0
- package/packages/server/dist/core/migrations/index.d.ts.map +1 -0
- package/packages/server/dist/core/migrations/index.js +58 -0
- package/packages/server/dist/core/migrations/index.js.map +1 -0
- package/packages/server/dist/core/paths.d.ts +53 -0
- package/packages/server/dist/core/paths.d.ts.map +1 -0
- package/packages/server/dist/core/paths.js +125 -0
- package/packages/server/dist/core/paths.js.map +1 -0
- package/packages/server/dist/core/plugins/builtin-loader.d.ts +56 -0
- package/packages/server/dist/core/plugins/builtin-loader.d.ts.map +1 -0
- package/packages/server/dist/core/plugins/builtin-loader.js +153 -0
- package/packages/server/dist/core/plugins/builtin-loader.js.map +1 -0
- package/packages/server/dist/core/plugins/discovery.d.ts +28 -0
- package/packages/server/dist/core/plugins/discovery.d.ts.map +1 -0
- package/packages/server/dist/core/plugins/discovery.js +97 -0
- package/packages/server/dist/core/plugins/discovery.js.map +1 -0
- package/packages/server/dist/core/plugins/index.d.ts +6 -0
- package/packages/server/dist/core/plugins/index.d.ts.map +1 -0
- package/packages/server/dist/core/plugins/index.js +6 -0
- package/packages/server/dist/core/plugins/index.js.map +1 -0
- package/packages/server/dist/core/plugins/manifest.d.ts +9 -0
- package/packages/server/dist/core/plugins/manifest.d.ts.map +1 -0
- package/packages/server/dist/core/plugins/manifest.js +584 -0
- package/packages/server/dist/core/plugins/manifest.js.map +1 -0
- package/packages/server/dist/core/plugins/registry.d.ts +269 -0
- package/packages/server/dist/core/plugins/registry.d.ts.map +1 -0
- package/packages/server/dist/core/plugins/registry.js +1003 -0
- package/packages/server/dist/core/plugins/registry.js.map +1 -0
- package/packages/server/dist/core/plugins/secrets.d.ts +46 -0
- package/packages/server/dist/core/plugins/secrets.d.ts.map +1 -0
- package/packages/server/dist/core/plugins/secrets.js +174 -0
- package/packages/server/dist/core/plugins/secrets.js.map +1 -0
- package/packages/server/dist/core/plugins/skills.d.ts +131 -0
- package/packages/server/dist/core/plugins/skills.d.ts.map +1 -0
- package/packages/server/dist/core/plugins/skills.js +389 -0
- package/packages/server/dist/core/plugins/skills.js.map +1 -0
- package/packages/server/dist/core/templates.d.ts +28 -0
- package/packages/server/dist/core/templates.d.ts.map +1 -0
- package/packages/server/dist/core/templates.js +103 -0
- package/packages/server/dist/core/templates.js.map +1 -0
- package/packages/server/dist/core/tenant-context.d.ts +18 -0
- package/packages/server/dist/core/tenant-context.d.ts.map +1 -0
- package/packages/server/dist/core/tenant-context.js +42 -0
- package/packages/server/dist/core/tenant-context.js.map +1 -0
- package/packages/server/dist/core/tenant-id.d.ts +8 -0
- package/packages/server/dist/core/tenant-id.d.ts.map +1 -0
- package/packages/server/dist/core/tenant-id.js +53 -0
- package/packages/server/dist/core/tenant-id.js.map +1 -0
- package/packages/server/dist/core/tenant-skills.d.ts +29 -0
- package/packages/server/dist/core/tenant-skills.d.ts.map +1 -0
- package/packages/server/dist/core/tenant-skills.js +77 -0
- package/packages/server/dist/core/tenant-skills.js.map +1 -0
- package/packages/server/dist/core/worker-agents-fs.d.ts +44 -0
- package/packages/server/dist/core/worker-agents-fs.d.ts.map +1 -0
- package/packages/server/dist/core/worker-agents-fs.js +86 -0
- package/packages/server/dist/core/worker-agents-fs.js.map +1 -0
- package/packages/server/dist/core/worker-agents.d.ts +77 -0
- package/packages/server/dist/core/worker-agents.d.ts.map +1 -0
- package/packages/server/dist/core/worker-agents.js +191 -0
- package/packages/server/dist/core/worker-agents.js.map +1 -0
- package/packages/server/dist/index.d.ts +2 -0
- package/packages/server/dist/index.d.ts.map +1 -0
- package/packages/server/dist/index.js +623 -0
- package/packages/server/dist/index.js.map +1 -0
- package/packages/server/dist/lsp/client.d.ts +53 -0
- package/packages/server/dist/lsp/client.d.ts.map +1 -0
- package/packages/server/dist/lsp/client.js +258 -0
- package/packages/server/dist/lsp/client.js.map +1 -0
- package/packages/server/dist/lsp/format.d.ts +13 -0
- package/packages/server/dist/lsp/format.d.ts.map +1 -0
- package/packages/server/dist/lsp/format.js +55 -0
- package/packages/server/dist/lsp/format.js.map +1 -0
- package/packages/server/dist/lsp/index.d.ts +20 -0
- package/packages/server/dist/lsp/index.d.ts.map +1 -0
- package/packages/server/dist/lsp/index.js +32 -0
- package/packages/server/dist/lsp/index.js.map +1 -0
- package/packages/server/dist/lsp/language-registry.d.ts +29 -0
- package/packages/server/dist/lsp/language-registry.d.ts.map +1 -0
- package/packages/server/dist/lsp/language-registry.js +62 -0
- package/packages/server/dist/lsp/language-registry.js.map +1 -0
- package/packages/server/dist/lsp/manager.d.ts +77 -0
- package/packages/server/dist/lsp/manager.d.ts.map +1 -0
- package/packages/server/dist/lsp/manager.js +300 -0
- package/packages/server/dist/lsp/manager.js.map +1 -0
- package/packages/server/dist/plugins-routes.d.ts +96 -0
- package/packages/server/dist/plugins-routes.d.ts.map +1 -0
- package/packages/server/dist/plugins-routes.js +627 -0
- package/packages/server/dist/plugins-routes.js.map +1 -0
- package/packages/server/dist/setup/checks/config.d.ts +9 -0
- package/packages/server/dist/setup/checks/config.d.ts.map +1 -0
- package/packages/server/dist/setup/checks/config.js +66 -0
- package/packages/server/dist/setup/checks/config.js.map +1 -0
- package/packages/server/dist/setup/checks/db.d.ts +6 -0
- package/packages/server/dist/setup/checks/db.d.ts.map +1 -0
- package/packages/server/dist/setup/checks/db.js +79 -0
- package/packages/server/dist/setup/checks/db.js.map +1 -0
- package/packages/server/dist/setup/checks/known-models.d.ts +18 -0
- package/packages/server/dist/setup/checks/known-models.d.ts.map +1 -0
- package/packages/server/dist/setup/checks/known-models.js +119 -0
- package/packages/server/dist/setup/checks/known-models.js.map +1 -0
- package/packages/server/dist/setup/checks/network.d.ts +11 -0
- package/packages/server/dist/setup/checks/network.d.ts.map +1 -0
- package/packages/server/dist/setup/checks/network.js +176 -0
- package/packages/server/dist/setup/checks/network.js.map +1 -0
- package/packages/server/dist/setup/checks/plugins.d.ts +9 -0
- package/packages/server/dist/setup/checks/plugins.d.ts.map +1 -0
- package/packages/server/dist/setup/checks/plugins.js +194 -0
- package/packages/server/dist/setup/checks/plugins.js.map +1 -0
- package/packages/server/dist/setup/checks/providers.d.ts +12 -0
- package/packages/server/dist/setup/checks/providers.d.ts.map +1 -0
- package/packages/server/dist/setup/checks/providers.js +368 -0
- package/packages/server/dist/setup/checks/providers.js.map +1 -0
- package/packages/server/dist/setup/checks/runtime.d.ts +3 -0
- package/packages/server/dist/setup/checks/runtime.d.ts.map +1 -0
- package/packages/server/dist/setup/checks/runtime.js +44 -0
- package/packages/server/dist/setup/checks/runtime.js.map +1 -0
- package/packages/server/dist/setup/checks/sandbox.d.ts +9 -0
- package/packages/server/dist/setup/checks/sandbox.d.ts.map +1 -0
- package/packages/server/dist/setup/checks/sandbox.js +110 -0
- package/packages/server/dist/setup/checks/sandbox.js.map +1 -0
- package/packages/server/dist/setup/checks/tenants.d.ts +9 -0
- package/packages/server/dist/setup/checks/tenants.d.ts.map +1 -0
- package/packages/server/dist/setup/checks/tenants.js +509 -0
- package/packages/server/dist/setup/checks/tenants.js.map +1 -0
- package/packages/server/dist/setup/cli-agent.d.ts +39 -0
- package/packages/server/dist/setup/cli-agent.d.ts.map +1 -0
- package/packages/server/dist/setup/cli-agent.js +1353 -0
- package/packages/server/dist/setup/cli-agent.js.map +1 -0
- package/packages/server/dist/setup/doctor.d.ts +32 -0
- package/packages/server/dist/setup/doctor.d.ts.map +1 -0
- package/packages/server/dist/setup/doctor.js +80 -0
- package/packages/server/dist/setup/doctor.js.map +1 -0
- package/packages/server/dist/setup/launchd.d.ts +107 -0
- package/packages/server/dist/setup/launchd.d.ts.map +1 -0
- package/packages/server/dist/setup/launchd.js +309 -0
- package/packages/server/dist/setup/launchd.js.map +1 -0
- package/packages/server/dist/setup/load-env.d.ts +21 -0
- package/packages/server/dist/setup/load-env.d.ts.map +1 -0
- package/packages/server/dist/setup/load-env.js +88 -0
- package/packages/server/dist/setup/load-env.js.map +1 -0
- package/packages/server/dist/setup/probe-default-model.d.ts +28 -0
- package/packages/server/dist/setup/probe-default-model.d.ts.map +1 -0
- package/packages/server/dist/setup/probe-default-model.js +133 -0
- package/packages/server/dist/setup/probe-default-model.js.map +1 -0
- package/packages/server/dist/setup/render.d.ts +28 -0
- package/packages/server/dist/setup/render.d.ts.map +1 -0
- package/packages/server/dist/setup/render.js +60 -0
- package/packages/server/dist/setup/render.js.map +1 -0
- package/packages/server/dist/setup/repo-root.d.ts +3 -0
- package/packages/server/dist/setup/repo-root.d.ts.map +1 -0
- package/packages/server/dist/setup/repo-root.js +43 -0
- package/packages/server/dist/setup/repo-root.js.map +1 -0
- package/packages/server/dist/setup/service.d.ts +60 -0
- package/packages/server/dist/setup/service.d.ts.map +1 -0
- package/packages/server/dist/setup/service.js +345 -0
- package/packages/server/dist/setup/service.js.map +1 -0
- package/packages/server/dist/setup/start-server.d.ts +23 -0
- package/packages/server/dist/setup/start-server.d.ts.map +1 -0
- package/packages/server/dist/setup/start-server.js +465 -0
- package/packages/server/dist/setup/start-server.js.map +1 -0
- package/packages/server/dist/setup/wizard.d.ts +59 -0
- package/packages/server/dist/setup/wizard.d.ts.map +1 -0
- package/packages/server/dist/setup/wizard.js +556 -0
- package/packages/server/dist/setup/wizard.js.map +1 -0
- package/packages/server/dist/tools/edit-file.d.ts +13 -0
- package/packages/server/dist/tools/edit-file.d.ts.map +1 -0
- package/packages/server/dist/tools/edit-file.js +90 -0
- package/packages/server/dist/tools/edit-file.js.map +1 -0
- package/packages/server/dist/tools/glob.d.ts +12 -0
- package/packages/server/dist/tools/glob.d.ts.map +1 -0
- package/packages/server/dist/tools/glob.js +82 -0
- package/packages/server/dist/tools/glob.js.map +1 -0
- package/packages/server/dist/tools/index.d.ts +82 -0
- package/packages/server/dist/tools/index.d.ts.map +1 -0
- package/packages/server/dist/tools/index.js +72 -0
- package/packages/server/dist/tools/index.js.map +1 -0
- package/packages/server/dist/tools/list-dir.d.ts +24 -0
- package/packages/server/dist/tools/list-dir.d.ts.map +1 -0
- package/packages/server/dist/tools/list-dir.js +99 -0
- package/packages/server/dist/tools/list-dir.js.map +1 -0
- package/packages/server/dist/tools/path-helper.d.ts +15 -0
- package/packages/server/dist/tools/path-helper.d.ts.map +1 -0
- package/packages/server/dist/tools/path-helper.js +72 -0
- package/packages/server/dist/tools/path-helper.js.map +1 -0
- package/packages/server/dist/tools/read-file.d.ts +17 -0
- package/packages/server/dist/tools/read-file.d.ts.map +1 -0
- package/packages/server/dist/tools/read-file.js +94 -0
- package/packages/server/dist/tools/read-file.js.map +1 -0
- package/packages/server/dist/tools/sandbox.d.ts +57 -0
- package/packages/server/dist/tools/sandbox.d.ts.map +1 -0
- package/packages/server/dist/tools/sandbox.js +291 -0
- package/packages/server/dist/tools/sandbox.js.map +1 -0
- package/packages/server/dist/tools/write-file.d.ts +12 -0
- package/packages/server/dist/tools/write-file.d.ts.map +1 -0
- package/packages/server/dist/tools/write-file.js +67 -0
- package/packages/server/dist/tools/write-file.js.map +1 -0
- package/packages/server/dist/worker-agents-routes.d.ts +11 -0
- package/packages/server/dist/worker-agents-routes.d.ts.map +1 -0
- package/packages/server/dist/worker-agents-routes.js +253 -0
- package/packages/server/dist/worker-agents-routes.js.map +1 -0
- package/packages/server/package.json +41 -0
- package/packages/web/dist/assets/index-DH-gJ09_.js +60 -0
- package/packages/web/dist/assets/index-xU4lYYqY.css +2 -0
- package/packages/web/dist/index.html +14 -0
- package/packages/web/package.json +36 -0
- package/plugins/README.md +64 -0
- package/plugins/files/dist/client.d.ts +5 -0
- package/plugins/files/dist/client.d.ts.map +1 -0
- package/plugins/files/dist/client.js +354 -0
- package/plugins/files/dist/client.js.map +1 -0
- package/plugins/files/dist/server.d.ts +32 -0
- package/plugins/files/dist/server.d.ts.map +1 -0
- package/plugins/files/dist/server.js +514 -0
- package/plugins/files/dist/server.js.map +1 -0
- package/plugins/files/dist/tools/edit-file.d.ts +29 -0
- package/plugins/files/dist/tools/edit-file.d.ts.map +1 -0
- package/plugins/files/dist/tools/edit-file.js +230 -0
- package/plugins/files/dist/tools/edit-file.js.map +1 -0
- package/plugins/files/dist/tools/edit-file.prompt.md +36 -0
- package/plugins/files/dist/tools/glob.d.ts +12 -0
- package/plugins/files/dist/tools/glob.d.ts.map +1 -0
- package/plugins/files/dist/tools/glob.js +84 -0
- package/plugins/files/dist/tools/glob.js.map +1 -0
- package/plugins/files/dist/tools/index.d.ts +13 -0
- package/plugins/files/dist/tools/index.d.ts.map +1 -0
- package/plugins/files/dist/tools/index.js +158 -0
- package/plugins/files/dist/tools/index.js.map +1 -0
- package/plugins/files/dist/tools/list-dir.d.ts +24 -0
- package/plugins/files/dist/tools/list-dir.d.ts.map +1 -0
- package/plugins/files/dist/tools/list-dir.js +104 -0
- package/plugins/files/dist/tools/list-dir.js.map +1 -0
- package/plugins/files/dist/tools/load-prompt.d.ts +5 -0
- package/plugins/files/dist/tools/load-prompt.d.ts.map +1 -0
- package/plugins/files/dist/tools/load-prompt.js +39 -0
- package/plugins/files/dist/tools/load-prompt.js.map +1 -0
- package/plugins/files/dist/tools/path-helper.d.ts +32 -0
- package/plugins/files/dist/tools/path-helper.d.ts.map +1 -0
- package/plugins/files/dist/tools/path-helper.js +113 -0
- package/plugins/files/dist/tools/path-helper.js.map +1 -0
- package/plugins/files/dist/tools/read-file.d.ts +17 -0
- package/plugins/files/dist/tools/read-file.d.ts.map +1 -0
- package/plugins/files/dist/tools/read-file.js +109 -0
- package/plugins/files/dist/tools/read-file.js.map +1 -0
- package/plugins/files/dist/tools/read-tracker.d.ts +28 -0
- package/plugins/files/dist/tools/read-tracker.d.ts.map +1 -0
- package/plugins/files/dist/tools/read-tracker.js +135 -0
- package/plugins/files/dist/tools/read-tracker.js.map +1 -0
- package/plugins/files/dist/tools/replacers.d.ts +27 -0
- package/plugins/files/dist/tools/replacers.d.ts.map +1 -0
- package/plugins/files/dist/tools/replacers.js +221 -0
- package/plugins/files/dist/tools/replacers.js.map +1 -0
- package/plugins/files/dist/tools/tenant-config-delete.d.ts +12 -0
- package/plugins/files/dist/tools/tenant-config-delete.d.ts.map +1 -0
- package/plugins/files/dist/tools/tenant-config-delete.js +70 -0
- package/plugins/files/dist/tools/tenant-config-delete.js.map +1 -0
- package/plugins/files/dist/tools/tenant-config-edit.d.ts +25 -0
- package/plugins/files/dist/tools/tenant-config-edit.d.ts.map +1 -0
- package/plugins/files/dist/tools/tenant-config-edit.js +142 -0
- package/plugins/files/dist/tools/tenant-config-edit.js.map +1 -0
- package/plugins/files/dist/tools/tenant-config-glob.d.ts +12 -0
- package/plugins/files/dist/tools/tenant-config-glob.d.ts.map +1 -0
- package/plugins/files/dist/tools/tenant-config-glob.js +64 -0
- package/plugins/files/dist/tools/tenant-config-glob.js.map +1 -0
- package/plugins/files/dist/tools/tenant-config-helper.d.ts +64 -0
- package/plugins/files/dist/tools/tenant-config-helper.d.ts.map +1 -0
- package/plugins/files/dist/tools/tenant-config-helper.js +162 -0
- package/plugins/files/dist/tools/tenant-config-helper.js.map +1 -0
- package/plugins/files/dist/tools/tenant-config-list.d.ts +20 -0
- package/plugins/files/dist/tools/tenant-config-list.d.ts.map +1 -0
- package/plugins/files/dist/tools/tenant-config-list.js +95 -0
- package/plugins/files/dist/tools/tenant-config-list.js.map +1 -0
- package/plugins/files/dist/tools/tenant-config-read.d.ts +17 -0
- package/plugins/files/dist/tools/tenant-config-read.d.ts.map +1 -0
- package/plugins/files/dist/tools/tenant-config-read.js +87 -0
- package/plugins/files/dist/tools/tenant-config-read.js.map +1 -0
- package/plugins/files/dist/tools/tenant-config-write.d.ts +14 -0
- package/plugins/files/dist/tools/tenant-config-write.d.ts.map +1 -0
- package/plugins/files/dist/tools/tenant-config-write.js +78 -0
- package/plugins/files/dist/tools/tenant-config-write.js.map +1 -0
- package/plugins/files/dist/tools/text-shape.d.ts +20 -0
- package/plugins/files/dist/tools/text-shape.d.ts.map +1 -0
- package/plugins/files/dist/tools/text-shape.js +57 -0
- package/plugins/files/dist/tools/text-shape.js.map +1 -0
- package/plugins/files/dist/tools/write-file.d.ts +12 -0
- package/plugins/files/dist/tools/write-file.d.ts.map +1 -0
- package/plugins/files/dist/tools/write-file.js +89 -0
- package/plugins/files/dist/tools/write-file.js.map +1 -0
- package/plugins/files/dist/tools/write-file.prompt.md +14 -0
- package/plugins/files/manifest.json +100 -0
- package/plugins/files/package.json +39 -0
- package/plugins/files/skills/files-workspace-layout.md +29 -0
- package/plugins/microsandbox/dist/admin/browser-routes.d.ts +41 -0
- package/plugins/microsandbox/dist/admin/browser-routes.d.ts.map +1 -0
- package/plugins/microsandbox/dist/admin/browser-routes.js +208 -0
- package/plugins/microsandbox/dist/admin/browser-routes.js.map +1 -0
- package/plugins/microsandbox/dist/admin/preview-exec.d.ts +38 -0
- package/plugins/microsandbox/dist/admin/preview-exec.d.ts.map +1 -0
- package/plugins/microsandbox/dist/admin/preview-exec.js +185 -0
- package/plugins/microsandbox/dist/admin/preview-exec.js.map +1 -0
- package/plugins/microsandbox/dist/admin/routes.d.ts +35 -0
- package/plugins/microsandbox/dist/admin/routes.d.ts.map +1 -0
- package/plugins/microsandbox/dist/admin/routes.js +728 -0
- package/plugins/microsandbox/dist/admin/routes.js.map +1 -0
- package/plugins/microsandbox/dist/admin/sandboxfile-io.d.ts +11 -0
- package/plugins/microsandbox/dist/admin/sandboxfile-io.d.ts.map +1 -0
- package/plugins/microsandbox/dist/admin/sandboxfile-io.js +72 -0
- package/plugins/microsandbox/dist/admin/sandboxfile-io.js.map +1 -0
- package/plugins/microsandbox/dist/admin/templates.d.ts +16 -0
- package/plugins/microsandbox/dist/admin/templates.d.ts.map +1 -0
- package/plugins/microsandbox/dist/admin/templates.js +66 -0
- package/plugins/microsandbox/dist/admin/templates.js.map +1 -0
- package/plugins/microsandbox/dist/admin.d.ts +5 -0
- package/plugins/microsandbox/dist/admin.d.ts.map +1 -0
- package/plugins/microsandbox/dist/admin.js +256 -0
- package/plugins/microsandbox/dist/admin.js.map +1 -0
- package/plugins/microsandbox/dist/build/builder.d.ts +69 -0
- package/plugins/microsandbox/dist/build/builder.d.ts.map +1 -0
- package/plugins/microsandbox/dist/build/builder.js +257 -0
- package/plugins/microsandbox/dist/build/builder.js.map +1 -0
- package/plugins/microsandbox/dist/build/metadata.d.ts +27 -0
- package/plugins/microsandbox/dist/build/metadata.d.ts.map +1 -0
- package/plugins/microsandbox/dist/build/metadata.js +55 -0
- package/plugins/microsandbox/dist/build/metadata.js.map +1 -0
- package/plugins/microsandbox/dist/build/pointer.d.ts +51 -0
- package/plugins/microsandbox/dist/build/pointer.d.ts.map +1 -0
- package/plugins/microsandbox/dist/build/pointer.js +130 -0
- package/plugins/microsandbox/dist/build/pointer.js.map +1 -0
- package/plugins/microsandbox/dist/build/sandboxfile.d.ts +15 -0
- package/plugins/microsandbox/dist/build/sandboxfile.d.ts.map +1 -0
- package/plugins/microsandbox/dist/build/sandboxfile.js +176 -0
- package/plugins/microsandbox/dist/build/sandboxfile.js.map +1 -0
- package/plugins/microsandbox/dist/client.d.ts +5 -0
- package/plugins/microsandbox/dist/client.d.ts.map +1 -0
- package/plugins/microsandbox/dist/client.js +941 -0
- package/plugins/microsandbox/dist/client.js.map +1 -0
- package/plugins/microsandbox/dist/runner/browser.d.ts +50 -0
- package/plugins/microsandbox/dist/runner/browser.d.ts.map +1 -0
- package/plugins/microsandbox/dist/runner/browser.js +142 -0
- package/plugins/microsandbox/dist/runner/browser.js.map +1 -0
- package/plugins/microsandbox/dist/runner/free-port.d.ts +6 -0
- package/plugins/microsandbox/dist/runner/free-port.d.ts.map +1 -0
- package/plugins/microsandbox/dist/runner/free-port.js +53 -0
- package/plugins/microsandbox/dist/runner/free-port.js.map +1 -0
- package/plugins/microsandbox/dist/runner/index.d.ts +28 -0
- package/plugins/microsandbox/dist/runner/index.d.ts.map +1 -0
- package/plugins/microsandbox/dist/runner/index.js +72 -0
- package/plugins/microsandbox/dist/runner/index.js.map +1 -0
- package/plugins/microsandbox/dist/runner/microsandbox.d.ts +64 -0
- package/plugins/microsandbox/dist/runner/microsandbox.d.ts.map +1 -0
- package/plugins/microsandbox/dist/runner/microsandbox.js +668 -0
- package/plugins/microsandbox/dist/runner/microsandbox.js.map +1 -0
- package/plugins/microsandbox/dist/runner/nullable.d.ts +36 -0
- package/plugins/microsandbox/dist/runner/nullable.d.ts.map +1 -0
- package/plugins/microsandbox/dist/runner/nullable.js +82 -0
- package/plugins/microsandbox/dist/runner/nullable.js.map +1 -0
- package/plugins/microsandbox/dist/runner/pool.d.ts +97 -0
- package/plugins/microsandbox/dist/runner/pool.d.ts.map +1 -0
- package/plugins/microsandbox/dist/runner/pool.js +494 -0
- package/plugins/microsandbox/dist/runner/pool.js.map +1 -0
- package/plugins/microsandbox/dist/runner/types.d.ts +33 -0
- package/plugins/microsandbox/dist/runner/types.d.ts.map +1 -0
- package/plugins/microsandbox/dist/runner/types.js +79 -0
- package/plugins/microsandbox/dist/runner/types.js.map +1 -0
- package/plugins/microsandbox/dist/server.d.ts +7 -0
- package/plugins/microsandbox/dist/server.d.ts.map +1 -0
- package/plugins/microsandbox/dist/server.js +276 -0
- package/plugins/microsandbox/dist/server.js.map +1 -0
- package/plugins/microsandbox/dist/tools/browser.d.ts +25 -0
- package/plugins/microsandbox/dist/tools/browser.d.ts.map +1 -0
- package/plugins/microsandbox/dist/tools/browser.js +78 -0
- package/plugins/microsandbox/dist/tools/browser.js.map +1 -0
- package/plugins/microsandbox/dist/tools/build.d.ts +5 -0
- package/plugins/microsandbox/dist/tools/build.d.ts.map +1 -0
- package/plugins/microsandbox/dist/tools/build.js +243 -0
- package/plugins/microsandbox/dist/tools/build.js.map +1 -0
- package/plugins/microsandbox/dist/tools/index.d.ts +9 -0
- package/plugins/microsandbox/dist/tools/index.d.ts.map +1 -0
- package/plugins/microsandbox/dist/tools/index.js +430 -0
- package/plugins/microsandbox/dist/tools/index.js.map +1 -0
- package/plugins/microsandbox/dist/tools/mcp-client.d.ts +63 -0
- package/plugins/microsandbox/dist/tools/mcp-client.d.ts.map +1 -0
- package/plugins/microsandbox/dist/tools/mcp-client.js +226 -0
- package/plugins/microsandbox/dist/tools/mcp-client.js.map +1 -0
- package/plugins/microsandbox/manifest.json +177 -0
- package/plugins/microsandbox/package.json +38 -0
- package/plugins/microsandbox/skills/microsandbox-browser-howto.md +155 -0
- package/plugins/microsandbox/skills/microsandbox-build-use.md +201 -0
- package/plugins/microsandbox/skills/microsandbox-config.md +38 -0
- package/plugins/microsandbox/skills/microsandbox-exec-howto.md +144 -0
- package/plugins/microsandbox/skills/microsandbox-libreoffice.md +159 -0
- package/plugins/microsandbox/templates/README.md +26 -0
- package/plugins/web-search/dist/server.d.ts +4 -0
- package/plugins/web-search/dist/server.d.ts.map +1 -0
- package/plugins/web-search/dist/server.js +73 -0
- package/plugins/web-search/dist/server.js.map +1 -0
- package/plugins/web-search/dist/tools/health.d.ts +31 -0
- package/plugins/web-search/dist/tools/health.d.ts.map +1 -0
- package/plugins/web-search/dist/tools/health.js +59 -0
- package/plugins/web-search/dist/tools/health.js.map +1 -0
- package/plugins/web-search/dist/tools/index.d.ts +3 -0
- package/plugins/web-search/dist/tools/index.d.ts.map +1 -0
- package/plugins/web-search/dist/tools/index.js +2 -0
- package/plugins/web-search/dist/tools/index.js.map +1 -0
- package/plugins/web-search/dist/tools/providers.d.ts +43 -0
- package/plugins/web-search/dist/tools/providers.d.ts.map +1 -0
- package/plugins/web-search/dist/tools/providers.js +140 -0
- package/plugins/web-search/dist/tools/providers.js.map +1 -0
- package/plugins/web-search/dist/tools/web-search.d.ts +15 -0
- package/plugins/web-search/dist/tools/web-search.d.ts.map +1 -0
- package/plugins/web-search/dist/tools/web-search.js +244 -0
- package/plugins/web-search/dist/tools/web-search.js.map +1 -0
- package/plugins/web-search/manifest.json +65 -0
- package/plugins/web-search/node_modules/@esbuild/darwin-arm64/README.md +3 -0
- package/plugins/web-search/node_modules/@esbuild/darwin-arm64/package.json +20 -0
- package/plugins/web-search/node_modules/@vitest/expect/LICENSE +21 -0
- package/plugins/web-search/node_modules/@vitest/expect/README.md +21 -0
- package/plugins/web-search/node_modules/@vitest/expect/dist/index.d.ts +808 -0
- package/plugins/web-search/node_modules/@vitest/expect/dist/index.js +1799 -0
- package/plugins/web-search/node_modules/@vitest/expect/package.json +46 -0
- package/plugins/web-search/node_modules/@vitest/mocker/LICENSE +21 -0
- package/plugins/web-search/node_modules/@vitest/mocker/README.md +5 -0
- package/plugins/web-search/node_modules/@vitest/mocker/dist/auto-register.d.ts +2 -0
- package/plugins/web-search/node_modules/@vitest/mocker/dist/auto-register.js +9 -0
- package/plugins/web-search/node_modules/@vitest/mocker/dist/browser.d.ts +53 -0
- package/plugins/web-search/node_modules/@vitest/mocker/dist/browser.js +91 -0
- package/plugins/web-search/node_modules/@vitest/mocker/dist/chunk-interceptor-native.js +15 -0
- package/plugins/web-search/node_modules/@vitest/mocker/dist/chunk-mocker.js +1602 -0
- package/plugins/web-search/node_modules/@vitest/mocker/dist/chunk-pathe.M-eThtNZ.js +174 -0
- package/plugins/web-search/node_modules/@vitest/mocker/dist/chunk-registry.js +182 -0
- package/plugins/web-search/node_modules/@vitest/mocker/dist/chunk-utils.js +16 -0
- package/plugins/web-search/node_modules/@vitest/mocker/dist/index.d.ts +21 -0
- package/plugins/web-search/node_modules/@vitest/mocker/dist/index.js +174 -0
- package/plugins/web-search/node_modules/@vitest/mocker/dist/mocker.d-Ce9_ySj5.d.ts +83 -0
- package/plugins/web-search/node_modules/@vitest/mocker/dist/node.d.ts +821 -0
- package/plugins/web-search/node_modules/@vitest/mocker/dist/node.js +1306 -0
- package/plugins/web-search/node_modules/@vitest/mocker/dist/redirect.d.ts +3 -0
- package/plugins/web-search/node_modules/@vitest/mocker/dist/redirect.js +75 -0
- package/plugins/web-search/node_modules/@vitest/mocker/dist/register.d.ts +9 -0
- package/plugins/web-search/node_modules/@vitest/mocker/dist/register.js +41 -0
- package/plugins/web-search/node_modules/@vitest/mocker/dist/registry.d-D765pazg.d.ts +87 -0
- package/plugins/web-search/node_modules/@vitest/mocker/dist/types.d-D_aRZRdy.d.ts +8 -0
- package/plugins/web-search/node_modules/@vitest/mocker/package.json +82 -0
- package/plugins/web-search/node_modules/@vitest/pretty-format/LICENSE +21 -0
- package/plugins/web-search/node_modules/@vitest/pretty-format/dist/index.d.ts +119 -0
- package/plugins/web-search/node_modules/@vitest/pretty-format/dist/index.js +1387 -0
- package/plugins/web-search/node_modules/@vitest/pretty-format/package.json +44 -0
- package/plugins/web-search/node_modules/@vitest/runner/LICENSE +21 -0
- package/plugins/web-search/node_modules/@vitest/runner/README.md +5 -0
- package/plugins/web-search/node_modules/@vitest/runner/dist/chunk-hooks.js +2254 -0
- package/plugins/web-search/node_modules/@vitest/runner/dist/index.d.ts +261 -0
- package/plugins/web-search/node_modules/@vitest/runner/dist/index.js +6 -0
- package/plugins/web-search/node_modules/@vitest/runner/dist/tasks.d-CkscK4of.d.ts +558 -0
- package/plugins/web-search/node_modules/@vitest/runner/dist/types.d.ts +163 -0
- package/plugins/web-search/node_modules/@vitest/runner/dist/types.js +1 -0
- package/plugins/web-search/node_modules/@vitest/runner/dist/utils.d.ts +47 -0
- package/plugins/web-search/node_modules/@vitest/runner/dist/utils.js +6 -0
- package/plugins/web-search/node_modules/@vitest/runner/package.json +49 -0
- package/plugins/web-search/node_modules/@vitest/snapshot/LICENSE +21 -0
- package/plugins/web-search/node_modules/@vitest/snapshot/README.md +84 -0
- package/plugins/web-search/node_modules/@vitest/snapshot/dist/environment.d-DHdQ1Csl.d.ts +22 -0
- package/plugins/web-search/node_modules/@vitest/snapshot/dist/environment.d.ts +16 -0
- package/plugins/web-search/node_modules/@vitest/snapshot/dist/environment.js +40 -0
- package/plugins/web-search/node_modules/@vitest/snapshot/dist/index.d.ts +137 -0
- package/plugins/web-search/node_modules/@vitest/snapshot/dist/index.js +2305 -0
- package/plugins/web-search/node_modules/@vitest/snapshot/dist/manager.d.ts +18 -0
- package/plugins/web-search/node_modules/@vitest/snapshot/dist/manager.js +73 -0
- package/plugins/web-search/node_modules/@vitest/snapshot/dist/rawSnapshot.d-lFsMJFUd.d.ts +61 -0
- package/plugins/web-search/node_modules/@vitest/snapshot/package.json +54 -0
- package/plugins/web-search/node_modules/@vitest/spy/LICENSE +21 -0
- package/plugins/web-search/node_modules/@vitest/spy/README.md +3 -0
- package/plugins/web-search/node_modules/@vitest/spy/dist/index.d.ts +356 -0
- package/plugins/web-search/node_modules/@vitest/spy/dist/index.js +191 -0
- package/plugins/web-search/node_modules/@vitest/spy/package.json +38 -0
- package/plugins/web-search/node_modules/@vitest/utils/LICENSE +21 -0
- package/plugins/web-search/node_modules/@vitest/utils/dist/chunk-_commonjsHelpers.js +158 -0
- package/plugins/web-search/node_modules/@vitest/utils/dist/diff.d.ts +104 -0
- package/plugins/web-search/node_modules/@vitest/utils/dist/diff.js +2185 -0
- package/plugins/web-search/node_modules/@vitest/utils/dist/error.d.ts +9 -0
- package/plugins/web-search/node_modules/@vitest/utils/dist/error.js +162 -0
- package/plugins/web-search/node_modules/@vitest/utils/dist/helpers.d.ts +56 -0
- package/plugins/web-search/node_modules/@vitest/utils/dist/helpers.js +251 -0
- package/plugins/web-search/node_modules/@vitest/utils/dist/index.d.ts +57 -0
- package/plugins/web-search/node_modules/@vitest/utils/dist/index.js +633 -0
- package/plugins/web-search/node_modules/@vitest/utils/dist/source-map.d.ts +139 -0
- package/plugins/web-search/node_modules/@vitest/utils/dist/source-map.js +996 -0
- package/plugins/web-search/node_modules/@vitest/utils/dist/types.d-BCElaP-c.d.ts +53 -0
- package/plugins/web-search/node_modules/@vitest/utils/dist/types.d.ts +53 -0
- package/plugins/web-search/node_modules/@vitest/utils/dist/types.js +1 -0
- package/plugins/web-search/node_modules/@vitest/utils/package.json +77 -0
- package/plugins/web-search/node_modules/chai/LICENSE +21 -0
- package/plugins/web-search/node_modules/chai/README.md +162 -0
- package/plugins/web-search/node_modules/chai/package.json +74 -0
- package/plugins/web-search/node_modules/esbuild/README.md +3 -0
- package/plugins/web-search/node_modules/esbuild/package.json +49 -0
- package/plugins/web-search/node_modules/std-env/README.md +118 -0
- package/plugins/web-search/node_modules/std-env/dist/index.cjs +1 -0
- package/plugins/web-search/node_modules/std-env/dist/index.d.cts +92 -0
- package/plugins/web-search/node_modules/std-env/dist/index.d.mts +92 -0
- package/plugins/web-search/node_modules/std-env/dist/index.d.ts +92 -0
- package/plugins/web-search/node_modules/std-env/dist/index.mjs +1 -0
- package/plugins/web-search/node_modules/std-env/package.json +46 -0
- package/plugins/web-search/node_modules/tinyexec/LICENSE +21 -0
- package/plugins/web-search/node_modules/tinyexec/README.md +256 -0
- package/plugins/web-search/node_modules/tinyexec/dist/main.cjs +575 -0
- package/plugins/web-search/node_modules/tinyexec/dist/main.d.cts +70 -0
- package/plugins/web-search/node_modules/tinyexec/dist/main.d.ts +70 -0
- package/plugins/web-search/node_modules/tinyexec/dist/main.js +578 -0
- package/plugins/web-search/node_modules/tinyexec/package.json +66 -0
- package/plugins/web-search/node_modules/tinyrainbow/README.md +28 -0
- package/plugins/web-search/node_modules/tinyrainbow/dist/browser.d.ts +8 -0
- package/plugins/web-search/node_modules/tinyrainbow/dist/browser.js +20 -0
- package/plugins/web-search/node_modules/tinyrainbow/dist/chunk-BVHSVHOK.js +90 -0
- package/plugins/web-search/node_modules/tinyrainbow/dist/index-8b61d5bc.d.ts +59 -0
- package/plugins/web-search/node_modules/tinyrainbow/dist/node.d.ts +8 -0
- package/plugins/web-search/node_modules/tinyrainbow/dist/node.js +22 -0
- package/plugins/web-search/node_modules/tinyrainbow/package.json +37 -0
- package/plugins/web-search/node_modules/typescript/README.md +50 -0
- package/plugins/web-search/node_modules/typescript/package.json +120 -0
- package/plugins/web-search/node_modules/vite/README.md +20 -0
- package/plugins/web-search/node_modules/vite/dist/client/client.mjs +1106 -0
- package/plugins/web-search/node_modules/vite/dist/client/env.mjs +19 -0
- package/plugins/web-search/node_modules/vite/dist/node/chunks/build.js +4 -0
- package/plugins/web-search/node_modules/vite/dist/node/chunks/build2.js +5538 -0
- package/plugins/web-search/node_modules/vite/dist/node/chunks/chunk.js +48 -0
- package/plugins/web-search/node_modules/vite/dist/node/chunks/config.js +36065 -0
- package/plugins/web-search/node_modules/vite/dist/node/chunks/config2.js +4 -0
- package/plugins/web-search/node_modules/vite/dist/node/chunks/dist.js +6758 -0
- package/plugins/web-search/node_modules/vite/dist/node/chunks/lib.js +377 -0
- package/plugins/web-search/node_modules/vite/dist/node/chunks/logger.js +329 -0
- package/plugins/web-search/node_modules/vite/dist/node/chunks/moduleRunnerTransport.d.ts +96 -0
- package/plugins/web-search/node_modules/vite/dist/node/chunks/optimizer.js +4 -0
- package/plugins/web-search/node_modules/vite/dist/node/chunks/postcss-import.js +479 -0
- package/plugins/web-search/node_modules/vite/dist/node/chunks/preview.js +4 -0
- package/plugins/web-search/node_modules/vite/dist/node/chunks/server.js +4 -0
- package/plugins/web-search/node_modules/vite/dist/node/cli.js +698 -0
- package/plugins/web-search/node_modules/vite/dist/node/index.d.ts +3717 -0
- package/plugins/web-search/node_modules/vite/dist/node/index.js +30 -0
- package/plugins/web-search/node_modules/vite/dist/node/module-runner.d.ts +311 -0
- package/plugins/web-search/node_modules/vite/dist/node/module-runner.js +1160 -0
- package/plugins/web-search/node_modules/vite/package.json +199 -0
- package/plugins/web-search/node_modules/vite/types/package.json +4 -0
- package/plugins/web-search/node_modules/vitest/README.md +7 -0
- package/plugins/web-search/node_modules/vitest/dist/browser.d.ts +34 -0
- package/plugins/web-search/node_modules/vitest/dist/browser.js +8 -0
- package/plugins/web-search/node_modules/vitest/dist/chunks/_commonjsHelpers.BFTU3MAI.js +7 -0
- package/plugins/web-search/node_modules/vitest/dist/chunks/base.DfmxU-tU.js +38 -0
- package/plugins/web-search/node_modules/vitest/dist/chunks/benchmark.CYdenmiT.js +37 -0
- package/plugins/web-search/node_modules/vitest/dist/chunks/benchmark.d.BwvBVTda.d.ts +24 -0
- package/plugins/web-search/node_modules/vitest/dist/chunks/cac.0BJqEUeA.js +1469 -0
- package/plugins/web-search/node_modules/vitest/dist/chunks/cli-api.DWGBtMmz.js +10660 -0
- package/plugins/web-search/node_modules/vitest/dist/chunks/config.d.BKdhh7Zx.d.ts +224 -0
- package/plugins/web-search/node_modules/vitest/dist/chunks/console.CtFJOzRO.js +153 -0
- package/plugins/web-search/node_modules/vitest/dist/chunks/constants.DnKduX2e.js +44 -0
- package/plugins/web-search/node_modules/vitest/dist/chunks/coverage.DVF1vEu8.js +25 -0
- package/plugins/web-search/node_modules/vitest/dist/chunks/coverage.DfSpMS-b.js +4350 -0
- package/plugins/web-search/node_modules/vitest/dist/chunks/coverage.d.S9RMNXIe.d.ts +35 -0
- package/plugins/web-search/node_modules/vitest/dist/chunks/creator.GK6I-cL4.js +640 -0
- package/plugins/web-search/node_modules/vitest/dist/chunks/date.Bq6ZW5rf.js +73 -0
- package/plugins/web-search/node_modules/vitest/dist/chunks/defaults.B7q_naMc.js +115 -0
- package/plugins/web-search/node_modules/vitest/dist/chunks/env.D4Lgay0q.js +8 -0
- package/plugins/web-search/node_modules/vitest/dist/chunks/environment.d.cL3nLXbE.d.ts +119 -0
- package/plugins/web-search/node_modules/vitest/dist/chunks/execute.B7h3T_Hc.js +708 -0
- package/plugins/web-search/node_modules/vitest/dist/chunks/git.BVQ8w_Sw.js +72 -0
- package/plugins/web-search/node_modules/vitest/dist/chunks/global.d.MAmajcmJ.d.ts +136 -0
- package/plugins/web-search/node_modules/vitest/dist/chunks/globals.DEHgCU4V.js +26 -0
- package/plugins/web-search/node_modules/vitest/dist/chunks/index.B521nVV-.js +157 -0
- package/plugins/web-search/node_modules/vitest/dist/chunks/index.BCWujgDG.js +231 -0
- package/plugins/web-search/node_modules/vitest/dist/chunks/index.CdQS2e2Q.js +37 -0
- package/plugins/web-search/node_modules/vitest/dist/chunks/index.CmSc2RE5.js +587 -0
- package/plugins/web-search/node_modules/vitest/dist/chunks/index.CwejwG0H.js +105 -0
- package/plugins/web-search/node_modules/vitest/dist/chunks/index.D3XRDfWc.js +213 -0
- package/plugins/web-search/node_modules/vitest/dist/chunks/index.VByaPkjc.js +2183 -0
- package/plugins/web-search/node_modules/vitest/dist/chunks/index.X0nbfr6-.js +6584 -0
- package/plugins/web-search/node_modules/vitest/dist/chunks/inspector.C914Efll.js +57 -0
- package/plugins/web-search/node_modules/vitest/dist/chunks/mocker.d.BE_2ls6u.d.ts +17 -0
- package/plugins/web-search/node_modules/vitest/dist/chunks/node.fjCdwEIl.js +15 -0
- package/plugins/web-search/node_modules/vitest/dist/chunks/reporters.d.BuRON0I0.d.ts +3168 -0
- package/plugins/web-search/node_modules/vitest/dist/chunks/rpc.-pEldfrD.js +83 -0
- package/plugins/web-search/node_modules/vitest/dist/chunks/runBaseTests.9Ij9_de-.js +129 -0
- package/plugins/web-search/node_modules/vitest/dist/chunks/setup-common.Dd054P77.js +60 -0
- package/plugins/web-search/node_modules/vitest/dist/chunks/suite.d.FvehnV49.d.ts +10 -0
- package/plugins/web-search/node_modules/vitest/dist/chunks/typechecker.DRKU1-1g.js +874 -0
- package/plugins/web-search/node_modules/vitest/dist/chunks/utils.CAioKnHs.js +61 -0
- package/plugins/web-search/node_modules/vitest/dist/chunks/utils.XdZDrNZV.js +65 -0
- package/plugins/web-search/node_modules/vitest/dist/chunks/vi.bdSIJ99Y.js +4015 -0
- package/plugins/web-search/node_modules/vitest/dist/chunks/vite.d.BnOPPc46.d.ts +25 -0
- package/plugins/web-search/node_modules/vitest/dist/chunks/vm.BThCzidc.js +756 -0
- package/plugins/web-search/node_modules/vitest/dist/chunks/worker.d.CUgIPz9V.d.ts +176 -0
- package/plugins/web-search/node_modules/vitest/dist/chunks/worker.d.uzWsCv9X.d.ts +8 -0
- package/plugins/web-search/node_modules/vitest/dist/cli.js +27 -0
- package/plugins/web-search/node_modules/vitest/dist/config.cjs +148 -0
- package/plugins/web-search/node_modules/vitest/dist/config.d.ts +100 -0
- package/plugins/web-search/node_modules/vitest/dist/config.js +21 -0
- package/plugins/web-search/node_modules/vitest/dist/coverage.d.ts +108 -0
- package/plugins/web-search/node_modules/vitest/dist/coverage.js +34 -0
- package/plugins/web-search/node_modules/vitest/dist/environments.d.ts +26 -0
- package/plugins/web-search/node_modules/vitest/dist/environments.js +2 -0
- package/plugins/web-search/node_modules/vitest/dist/execute.d.ts +150 -0
- package/plugins/web-search/node_modules/vitest/dist/execute.js +13 -0
- package/plugins/web-search/node_modules/vitest/dist/index.d.ts +651 -0
- package/plugins/web-search/node_modules/vitest/dist/index.js +18 -0
- package/plugins/web-search/node_modules/vitest/dist/mocker.d.ts +1 -0
- package/plugins/web-search/node_modules/vitest/dist/mocker.js +1 -0
- package/plugins/web-search/node_modules/vitest/dist/node.d.ts +158 -0
- package/plugins/web-search/node_modules/vitest/dist/node.js +105 -0
- package/plugins/web-search/node_modules/vitest/dist/path.js +7 -0
- package/plugins/web-search/node_modules/vitest/dist/reporters.d.ts +25 -0
- package/plugins/web-search/node_modules/vitest/dist/reporters.js +23 -0
- package/plugins/web-search/node_modules/vitest/dist/runners.d.ts +46 -0
- package/plugins/web-search/node_modules/vitest/dist/runners.js +235 -0
- package/plugins/web-search/node_modules/vitest/dist/snapshot.d.ts +9 -0
- package/plugins/web-search/node_modules/vitest/dist/snapshot.js +4 -0
- package/plugins/web-search/node_modules/vitest/dist/spy.js +1 -0
- package/plugins/web-search/node_modules/vitest/dist/suite.d.ts +5 -0
- package/plugins/web-search/node_modules/vitest/dist/suite.js +5 -0
- package/plugins/web-search/node_modules/vitest/dist/worker.js +124 -0
- package/plugins/web-search/node_modules/vitest/dist/workers/forks.js +43 -0
- package/plugins/web-search/node_modules/vitest/dist/workers/runVmTests.js +90 -0
- package/plugins/web-search/node_modules/vitest/dist/workers/threads.js +31 -0
- package/plugins/web-search/node_modules/vitest/dist/workers/vmForks.js +47 -0
- package/plugins/web-search/node_modules/vitest/dist/workers/vmThreads.js +37 -0
- package/plugins/web-search/node_modules/vitest/dist/workers.d.ts +40 -0
- package/plugins/web-search/node_modules/vitest/dist/workers.js +30 -0
- package/plugins/web-search/node_modules/vitest/package.json +207 -0
- package/plugins/web-search/package.json +30 -0
- package/plugins/web-search/skills/web-search-howto.md +69 -0
- package/plugins/workboard/agent-seeds/echo-demo/agent.json +7 -0
- package/plugins/workboard/agent-seeds/llm-default/SOUL.md +53 -0
- package/plugins/workboard/agent-seeds/llm-default/agent.json +7 -0
- package/plugins/workboard/dist/client.d.ts +5 -0
- package/plugins/workboard/dist/client.d.ts.map +1 -0
- package/plugins/workboard/dist/client.js +895 -0
- package/plugins/workboard/dist/client.js.map +1 -0
- package/plugins/workboard/dist/db/agents.d.ts +100 -0
- package/plugins/workboard/dist/db/agents.d.ts.map +1 -0
- package/plugins/workboard/dist/db/agents.js +280 -0
- package/plugins/workboard/dist/db/agents.js.map +1 -0
- package/plugins/workboard/dist/db/schema.d.ts +3 -0
- package/plugins/workboard/dist/db/schema.d.ts.map +1 -0
- package/plugins/workboard/dist/db/schema.js +31 -0
- package/plugins/workboard/dist/db/schema.js.map +1 -0
- package/plugins/workboard/dist/db/session-history.d.ts +28 -0
- package/plugins/workboard/dist/db/session-history.d.ts.map +1 -0
- package/plugins/workboard/dist/db/session-history.js +224 -0
- package/plugins/workboard/dist/db/session-history.js.map +1 -0
- package/plugins/workboard/dist/db/tasks.d.ts +260 -0
- package/plugins/workboard/dist/db/tasks.d.ts.map +1 -0
- package/plugins/workboard/dist/db/tasks.js +451 -0
- package/plugins/workboard/dist/db/tasks.js.map +1 -0
- package/plugins/workboard/dist/db/worker-agents.d.ts +16 -0
- package/plugins/workboard/dist/db/worker-agents.d.ts.map +1 -0
- package/plugins/workboard/dist/db/worker-agents.js +62 -0
- package/plugins/workboard/dist/db/worker-agents.js.map +1 -0
- package/plugins/workboard/dist/effective-skills.d.ts +13 -0
- package/plugins/workboard/dist/effective-skills.d.ts.map +1 -0
- package/plugins/workboard/dist/effective-skills.js +126 -0
- package/plugins/workboard/dist/effective-skills.js.map +1 -0
- package/plugins/workboard/dist/fs-worker-agents.d.ts +35 -0
- package/plugins/workboard/dist/fs-worker-agents.d.ts.map +1 -0
- package/plugins/workboard/dist/fs-worker-agents.js +199 -0
- package/plugins/workboard/dist/fs-worker-agents.js.map +1 -0
- package/plugins/workboard/dist/migrate-worker-agents.d.ts +11 -0
- package/plugins/workboard/dist/migrate-worker-agents.d.ts.map +1 -0
- package/plugins/workboard/dist/migrate-worker-agents.js +89 -0
- package/plugins/workboard/dist/migrate-worker-agents.js.map +1 -0
- package/plugins/workboard/dist/routes/handlers.d.ts +106 -0
- package/plugins/workboard/dist/routes/handlers.d.ts.map +1 -0
- package/plugins/workboard/dist/routes/handlers.js +668 -0
- package/plugins/workboard/dist/routes/handlers.js.map +1 -0
- package/plugins/workboard/dist/server.d.ts +6 -0
- package/plugins/workboard/dist/server.d.ts.map +1 -0
- package/plugins/workboard/dist/server.js +368 -0
- package/plugins/workboard/dist/server.js.map +1 -0
- package/plugins/workboard/dist/tools/index.d.ts +70 -0
- package/plugins/workboard/dist/tools/index.d.ts.map +1 -0
- package/plugins/workboard/dist/tools/index.js +963 -0
- package/plugins/workboard/dist/tools/index.js.map +1 -0
- package/plugins/workboard/dist/types.d.ts +27 -0
- package/plugins/workboard/dist/types.d.ts.map +1 -0
- package/plugins/workboard/dist/types.js +16 -0
- package/plugins/workboard/dist/types.js.map +1 -0
- package/plugins/workboard/dist/worker/pool.d.ts +220 -0
- package/plugins/workboard/dist/worker/pool.d.ts.map +1 -0
- package/plugins/workboard/dist/worker/pool.js +866 -0
- package/plugins/workboard/dist/worker/pool.js.map +1 -0
- package/plugins/workboard/dist/worker/tool-policy.d.ts +27 -0
- package/plugins/workboard/dist/worker/tool-policy.d.ts.map +1 -0
- package/plugins/workboard/dist/worker/tool-policy.js +76 -0
- package/plugins/workboard/dist/worker/tool-policy.js.map +1 -0
- package/plugins/workboard/dist/worker-agents-page.d.ts +4 -0
- package/plugins/workboard/dist/worker-agents-page.d.ts.map +1 -0
- package/plugins/workboard/dist/worker-agents-page.js +193 -0
- package/plugins/workboard/dist/worker-agents-page.js.map +1 -0
- package/plugins/workboard/manifest.json +180 -0
- package/plugins/workboard/package.json +37 -0
- package/plugins/workboard/skills/large-input-large-output.md +185 -0
- package/plugins/workboard/skills/workboard-howto.md +166 -0
- package/plugins/workboard/skills/worker-creator.md +267 -0
- package/plugins/workboard/skills/worker-fleet.md +431 -0
|
@@ -0,0 +1,1306 @@
|
|
|
1
|
+
import { a as cleanUrl, c as createManualModuleSource } from './chunk-utils.js';
|
|
2
|
+
import MagicString from 'magic-string';
|
|
3
|
+
import { walk } from 'estree-walker';
|
|
4
|
+
import { createFilter } from 'vite';
|
|
5
|
+
import { readFile } from 'node:fs/promises';
|
|
6
|
+
import { join } from 'node:path/posix';
|
|
7
|
+
import { M as MockerRegistry, a as ManualMockedModule } from './chunk-registry.js';
|
|
8
|
+
import { fileURLToPath } from 'node:url';
|
|
9
|
+
import { existsSync, readFileSync } from 'node:fs';
|
|
10
|
+
import { findMockRedirect } from './redirect.js';
|
|
11
|
+
import { i as isAbsolute, j as join$1, r as resolve } from './chunk-pathe.M-eThtNZ.js';
|
|
12
|
+
import 'node:module';
|
|
13
|
+
|
|
14
|
+
const isNodeInPatternWeakSet = new WeakSet();
|
|
15
|
+
function setIsNodeInPattern(node) {
|
|
16
|
+
return isNodeInPatternWeakSet.add(node);
|
|
17
|
+
}
|
|
18
|
+
function isNodeInPattern(node) {
|
|
19
|
+
return isNodeInPatternWeakSet.has(node);
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Same logic from \@vue/compiler-core & \@vue/compiler-sfc
|
|
23
|
+
* Except this is using acorn AST
|
|
24
|
+
*/
|
|
25
|
+
function esmWalker(root, { onIdentifier, onImportMeta, onDynamicImport, onCallExpression }) {
|
|
26
|
+
const parentStack = [];
|
|
27
|
+
const varKindStack = [];
|
|
28
|
+
const scopeMap = new WeakMap();
|
|
29
|
+
const identifiers = [];
|
|
30
|
+
const setScope = (node, name) => {
|
|
31
|
+
let scopeIds = scopeMap.get(node);
|
|
32
|
+
if (scopeIds && scopeIds.has(name)) {
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
if (!scopeIds) {
|
|
36
|
+
scopeIds = new Set();
|
|
37
|
+
scopeMap.set(node, scopeIds);
|
|
38
|
+
}
|
|
39
|
+
scopeIds.add(name);
|
|
40
|
+
};
|
|
41
|
+
function isInScope(name, parents) {
|
|
42
|
+
return parents.some((node) => {
|
|
43
|
+
var _scopeMap$get;
|
|
44
|
+
return node && ((_scopeMap$get = scopeMap.get(node)) === null || _scopeMap$get === void 0 ? void 0 : _scopeMap$get.has(name));
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
function handlePattern(p, parentScope) {
|
|
48
|
+
if (p.type === "Identifier") {
|
|
49
|
+
setScope(parentScope, p.name);
|
|
50
|
+
} else if (p.type === "RestElement") {
|
|
51
|
+
handlePattern(p.argument, parentScope);
|
|
52
|
+
} else if (p.type === "ObjectPattern") {
|
|
53
|
+
p.properties.forEach((property) => {
|
|
54
|
+
if (property.type === "RestElement") {
|
|
55
|
+
setScope(parentScope, property.argument.name);
|
|
56
|
+
} else {
|
|
57
|
+
handlePattern(property.value, parentScope);
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
} else if (p.type === "ArrayPattern") {
|
|
61
|
+
p.elements.forEach((element) => {
|
|
62
|
+
if (element) {
|
|
63
|
+
handlePattern(element, parentScope);
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
} else if (p.type === "AssignmentPattern") {
|
|
67
|
+
handlePattern(p.left, parentScope);
|
|
68
|
+
} else {
|
|
69
|
+
setScope(parentScope, p.name);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
walk(root, {
|
|
73
|
+
enter(node, parent) {
|
|
74
|
+
if (node.type === "ImportDeclaration") {
|
|
75
|
+
return this.skip();
|
|
76
|
+
}
|
|
77
|
+
// track parent stack, skip for "else-if"/"else" branches as acorn nests
|
|
78
|
+
// the ast within "if" nodes instead of flattening them
|
|
79
|
+
if (parent && !(parent.type === "IfStatement" && node === parent.alternate)) {
|
|
80
|
+
parentStack.unshift(parent);
|
|
81
|
+
}
|
|
82
|
+
// track variable declaration kind stack used by VariableDeclarator
|
|
83
|
+
if (node.type === "VariableDeclaration") {
|
|
84
|
+
varKindStack.unshift(node.kind);
|
|
85
|
+
}
|
|
86
|
+
if (node.type === "CallExpression") {
|
|
87
|
+
onCallExpression === null || onCallExpression === void 0 ? void 0 : onCallExpression(node);
|
|
88
|
+
}
|
|
89
|
+
if (node.type === "MetaProperty" && node.meta.name === "import") {
|
|
90
|
+
onImportMeta === null || onImportMeta === void 0 ? void 0 : onImportMeta(node);
|
|
91
|
+
} else if (node.type === "ImportExpression") {
|
|
92
|
+
onDynamicImport === null || onDynamicImport === void 0 ? void 0 : onDynamicImport(node);
|
|
93
|
+
}
|
|
94
|
+
if (node.type === "Identifier") {
|
|
95
|
+
if (!isInScope(node.name, parentStack) && isRefIdentifier(node, parent, parentStack)) {
|
|
96
|
+
// record the identifier, for DFS -> BFS
|
|
97
|
+
identifiers.push([node, parentStack.slice(0)]);
|
|
98
|
+
}
|
|
99
|
+
} else if (isFunctionNode(node)) {
|
|
100
|
+
// If it is a function declaration, it could be shadowing an import
|
|
101
|
+
// Add its name to the scope so it won't get replaced
|
|
102
|
+
if (node.type === "FunctionDeclaration") {
|
|
103
|
+
const parentScope = findParentScope(parentStack);
|
|
104
|
+
if (parentScope) {
|
|
105
|
+
setScope(parentScope, node.id.name);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
// walk function expressions and add its arguments to known identifiers
|
|
109
|
+
// so that we don't prefix them
|
|
110
|
+
node.params.forEach((p) => {
|
|
111
|
+
if (p.type === "ObjectPattern" || p.type === "ArrayPattern") {
|
|
112
|
+
handlePattern(p, node);
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
walk(p.type === "AssignmentPattern" ? p.left : p, { enter(child, parent) {
|
|
116
|
+
// skip params default value of destructure
|
|
117
|
+
if ((parent === null || parent === void 0 ? void 0 : parent.type) === "AssignmentPattern" && (parent === null || parent === void 0 ? void 0 : parent.right) === child) {
|
|
118
|
+
return this.skip();
|
|
119
|
+
}
|
|
120
|
+
if (child.type !== "Identifier") {
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
// do not record as scope variable if is a destructuring keyword
|
|
124
|
+
if (isStaticPropertyKey(child, parent)) {
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
// do not record if this is a default value
|
|
128
|
+
// assignment of a destructuring variable
|
|
129
|
+
if ((parent === null || parent === void 0 ? void 0 : parent.type) === "TemplateLiteral" && (parent === null || parent === void 0 ? void 0 : parent.expressions.includes(child)) || (parent === null || parent === void 0 ? void 0 : parent.type) === "CallExpression" && (parent === null || parent === void 0 ? void 0 : parent.callee) === child) {
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
132
|
+
setScope(node, child.name);
|
|
133
|
+
} });
|
|
134
|
+
});
|
|
135
|
+
} else if (node.type === "Property" && parent.type === "ObjectPattern") {
|
|
136
|
+
// mark property in destructuring pattern
|
|
137
|
+
setIsNodeInPattern(node);
|
|
138
|
+
} else if (node.type === "VariableDeclarator") {
|
|
139
|
+
const parentFunction = findParentScope(parentStack, varKindStack[0] === "var");
|
|
140
|
+
if (parentFunction) {
|
|
141
|
+
handlePattern(node.id, parentFunction);
|
|
142
|
+
}
|
|
143
|
+
} else if (node.type === "CatchClause" && node.param) {
|
|
144
|
+
handlePattern(node.param, node);
|
|
145
|
+
}
|
|
146
|
+
},
|
|
147
|
+
leave(node, parent) {
|
|
148
|
+
// untrack parent stack from above
|
|
149
|
+
if (parent && !(parent.type === "IfStatement" && node === parent.alternate)) {
|
|
150
|
+
parentStack.shift();
|
|
151
|
+
}
|
|
152
|
+
if (node.type === "VariableDeclaration") {
|
|
153
|
+
varKindStack.shift();
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
});
|
|
157
|
+
// emit the identifier events in BFS so the hoisted declarations
|
|
158
|
+
// can be captured correctly
|
|
159
|
+
identifiers.forEach(([node, stack]) => {
|
|
160
|
+
if (!isInScope(node.name, stack)) {
|
|
161
|
+
const parent = stack[0];
|
|
162
|
+
const grandparent = stack[1];
|
|
163
|
+
const hasBindingShortcut = isStaticProperty(parent) && parent.shorthand && (!isNodeInPattern(parent) || isInDestructuringAssignment(parent, parentStack));
|
|
164
|
+
const classDeclaration = parent.type === "PropertyDefinition" && (grandparent === null || grandparent === void 0 ? void 0 : grandparent.type) === "ClassBody" || parent.type === "ClassDeclaration" && node === parent.superClass;
|
|
165
|
+
const classExpression = parent.type === "ClassExpression" && node === parent.id;
|
|
166
|
+
onIdentifier === null || onIdentifier === void 0 ? void 0 : onIdentifier(node, {
|
|
167
|
+
hasBindingShortcut,
|
|
168
|
+
classDeclaration,
|
|
169
|
+
classExpression
|
|
170
|
+
}, stack);
|
|
171
|
+
}
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
function isRefIdentifier(id, parent, parentStack) {
|
|
175
|
+
// declaration id
|
|
176
|
+
if (parent.type === "CatchClause" || (parent.type === "VariableDeclarator" || parent.type === "ClassDeclaration") && parent.id === id) {
|
|
177
|
+
return false;
|
|
178
|
+
}
|
|
179
|
+
if (isFunctionNode(parent)) {
|
|
180
|
+
// function declaration/expression id
|
|
181
|
+
if (parent.id === id) {
|
|
182
|
+
return false;
|
|
183
|
+
}
|
|
184
|
+
// params list
|
|
185
|
+
if (parent.params.includes(id)) {
|
|
186
|
+
return false;
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
// class method name
|
|
190
|
+
if (parent.type === "MethodDefinition" && !parent.computed) {
|
|
191
|
+
return false;
|
|
192
|
+
}
|
|
193
|
+
// property key
|
|
194
|
+
if (isStaticPropertyKey(id, parent)) {
|
|
195
|
+
return false;
|
|
196
|
+
}
|
|
197
|
+
// object destructuring pattern
|
|
198
|
+
if (isNodeInPattern(parent) && parent.value === id) {
|
|
199
|
+
return false;
|
|
200
|
+
}
|
|
201
|
+
// non-assignment array destructuring pattern
|
|
202
|
+
if (parent.type === "ArrayPattern" && !isInDestructuringAssignment(parent, parentStack)) {
|
|
203
|
+
return false;
|
|
204
|
+
}
|
|
205
|
+
// member expression property
|
|
206
|
+
if (parent.type === "MemberExpression" && parent.property === id && !parent.computed) {
|
|
207
|
+
return false;
|
|
208
|
+
}
|
|
209
|
+
if (parent.type === "ExportSpecifier") {
|
|
210
|
+
return false;
|
|
211
|
+
}
|
|
212
|
+
// is a special keyword but parsed as identifier
|
|
213
|
+
if (id.name === "arguments") {
|
|
214
|
+
return false;
|
|
215
|
+
}
|
|
216
|
+
return true;
|
|
217
|
+
}
|
|
218
|
+
function isStaticProperty(node) {
|
|
219
|
+
return node && node.type === "Property" && !node.computed;
|
|
220
|
+
}
|
|
221
|
+
function isStaticPropertyKey(node, parent) {
|
|
222
|
+
return isStaticProperty(parent) && parent.key === node;
|
|
223
|
+
}
|
|
224
|
+
const functionNodeTypeRE = /Function(?:Expression|Declaration)$|Method$/;
|
|
225
|
+
function isFunctionNode(node) {
|
|
226
|
+
return functionNodeTypeRE.test(node.type);
|
|
227
|
+
}
|
|
228
|
+
const blockNodeTypeRE = /^BlockStatement$|^For(?:In|Of)?Statement$/;
|
|
229
|
+
function isBlock(node) {
|
|
230
|
+
return blockNodeTypeRE.test(node.type);
|
|
231
|
+
}
|
|
232
|
+
function findParentScope(parentStack, isVar = false) {
|
|
233
|
+
return parentStack.find(isVar ? isFunctionNode : isBlock);
|
|
234
|
+
}
|
|
235
|
+
function isInDestructuringAssignment(parent, parentStack) {
|
|
236
|
+
if (parent && (parent.type === "Property" || parent.type === "ArrayPattern")) {
|
|
237
|
+
return parentStack.some((i) => i.type === "AssignmentExpression");
|
|
238
|
+
}
|
|
239
|
+
return false;
|
|
240
|
+
}
|
|
241
|
+
function getArbitraryModuleIdentifier(node) {
|
|
242
|
+
return node.type === "Identifier" ? node.name : node.raw;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
function automockPlugin(options = {}) {
|
|
246
|
+
return {
|
|
247
|
+
name: "vitest:automock",
|
|
248
|
+
enforce: "post",
|
|
249
|
+
transform(code, id) {
|
|
250
|
+
if (id.includes("mock=automock") || id.includes("mock=autospy")) {
|
|
251
|
+
const mockType = id.includes("mock=automock") ? "automock" : "autospy";
|
|
252
|
+
const ms = automockModule(code, mockType, this.parse, options);
|
|
253
|
+
return {
|
|
254
|
+
code: ms.toString(),
|
|
255
|
+
map: ms.generateMap({
|
|
256
|
+
hires: "boundary",
|
|
257
|
+
source: cleanUrl(id)
|
|
258
|
+
})
|
|
259
|
+
};
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
};
|
|
263
|
+
}
|
|
264
|
+
// TODO: better source map replacement
|
|
265
|
+
function automockModule(code, mockType, parse, options = {}) {
|
|
266
|
+
const globalThisAccessor = options.globalThisAccessor || "\"__vitest_mocker__\"";
|
|
267
|
+
const ast = parse(code);
|
|
268
|
+
const m = new MagicString(code);
|
|
269
|
+
const allSpecifiers = [];
|
|
270
|
+
let importIndex = 0;
|
|
271
|
+
for (const _node of ast.body) {
|
|
272
|
+
if (_node.type === "ExportAllDeclaration") {
|
|
273
|
+
throw new Error(`automocking files with \`export *\` is not supported in browser mode because it cannot be statically analysed`);
|
|
274
|
+
}
|
|
275
|
+
if (_node.type === "ExportNamedDeclaration") {
|
|
276
|
+
const node = _node;
|
|
277
|
+
const declaration = node.declaration;
|
|
278
|
+
function traversePattern(expression) {
|
|
279
|
+
// export const test = '1'
|
|
280
|
+
if (expression.type === "Identifier") {
|
|
281
|
+
allSpecifiers.push({ name: expression.name });
|
|
282
|
+
} else if (expression.type === "ArrayPattern") {
|
|
283
|
+
expression.elements.forEach((element) => {
|
|
284
|
+
if (!element) {
|
|
285
|
+
return;
|
|
286
|
+
}
|
|
287
|
+
traversePattern(element);
|
|
288
|
+
});
|
|
289
|
+
} else if (expression.type === "ObjectPattern") {
|
|
290
|
+
expression.properties.forEach((property) => {
|
|
291
|
+
// export const { ...rest } = {}
|
|
292
|
+
if (property.type === "RestElement") {
|
|
293
|
+
traversePattern(property);
|
|
294
|
+
} else if (property.type === "Property") {
|
|
295
|
+
traversePattern(property.value);
|
|
296
|
+
} else ;
|
|
297
|
+
});
|
|
298
|
+
} else if (expression.type === "RestElement") {
|
|
299
|
+
traversePattern(expression.argument);
|
|
300
|
+
} else if (expression.type === "AssignmentPattern") {
|
|
301
|
+
throw new Error(`AssignmentPattern is not supported. Please open a new bug report.`);
|
|
302
|
+
} else if (expression.type === "MemberExpression") {
|
|
303
|
+
throw new Error(`MemberExpression is not supported. Please open a new bug report.`);
|
|
304
|
+
} else ;
|
|
305
|
+
}
|
|
306
|
+
if (declaration) {
|
|
307
|
+
if (declaration.type === "FunctionDeclaration") {
|
|
308
|
+
allSpecifiers.push({ name: declaration.id.name });
|
|
309
|
+
} else if (declaration.type === "VariableDeclaration") {
|
|
310
|
+
declaration.declarations.forEach((declaration) => {
|
|
311
|
+
traversePattern(declaration.id);
|
|
312
|
+
});
|
|
313
|
+
} else if (declaration.type === "ClassDeclaration") {
|
|
314
|
+
allSpecifiers.push({ name: declaration.id.name });
|
|
315
|
+
} else ;
|
|
316
|
+
m.remove(node.start, declaration.start);
|
|
317
|
+
}
|
|
318
|
+
const specifiers = node.specifiers || [];
|
|
319
|
+
const source = node.source;
|
|
320
|
+
if (!source && specifiers.length) {
|
|
321
|
+
specifiers.forEach((specifier) => {
|
|
322
|
+
allSpecifiers.push({
|
|
323
|
+
alias: getArbitraryModuleIdentifier(specifier.exported),
|
|
324
|
+
name: getArbitraryModuleIdentifier(specifier.local)
|
|
325
|
+
});
|
|
326
|
+
});
|
|
327
|
+
m.remove(node.start, node.end);
|
|
328
|
+
} else if (source && specifiers.length) {
|
|
329
|
+
const importNames = [];
|
|
330
|
+
specifiers.forEach((specifier) => {
|
|
331
|
+
const importedName = `__vitest_imported_${importIndex++}__`;
|
|
332
|
+
importNames.push([getArbitraryModuleIdentifier(specifier.local), importedName]);
|
|
333
|
+
allSpecifiers.push({
|
|
334
|
+
name: importedName,
|
|
335
|
+
alias: getArbitraryModuleIdentifier(specifier.exported)
|
|
336
|
+
});
|
|
337
|
+
});
|
|
338
|
+
const importString = `import { ${importNames.map(([name, alias]) => `${name} as ${alias}`).join(", ")} } from '${source.value}'`;
|
|
339
|
+
m.overwrite(node.start, node.end, importString);
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
if (_node.type === "ExportDefaultDeclaration") {
|
|
343
|
+
const node = _node;
|
|
344
|
+
const declaration = node.declaration;
|
|
345
|
+
allSpecifiers.push({
|
|
346
|
+
name: "__vitest_default",
|
|
347
|
+
alias: "default"
|
|
348
|
+
});
|
|
349
|
+
m.overwrite(node.start, declaration.start, `const __vitest_default = `);
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
const moduleObject = `
|
|
353
|
+
const __vitest_current_es_module__ = {
|
|
354
|
+
__esModule: true,
|
|
355
|
+
${allSpecifiers.map(({ name }) => `["${name}"]: ${name},`).join("\n ")}
|
|
356
|
+
}
|
|
357
|
+
const __vitest_mocked_module__ = globalThis[${globalThisAccessor}].mockObject(__vitest_current_es_module__, "${mockType}")
|
|
358
|
+
`;
|
|
359
|
+
const assigning = allSpecifiers.map(({ name }, index) => {
|
|
360
|
+
return `const __vitest_mocked_${index}__ = __vitest_mocked_module__["${name}"]`;
|
|
361
|
+
}).join("\n");
|
|
362
|
+
const redeclarations = allSpecifiers.map(({ name, alias }, index) => {
|
|
363
|
+
return ` __vitest_mocked_${index}__ as ${alias || name},`;
|
|
364
|
+
}).join("\n");
|
|
365
|
+
const specifiersExports = `
|
|
366
|
+
export {
|
|
367
|
+
${redeclarations}
|
|
368
|
+
}
|
|
369
|
+
`;
|
|
370
|
+
m.append(moduleObject + assigning + specifiersExports);
|
|
371
|
+
return m;
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
const regexDynamicImport = /import\s*\(/;
|
|
375
|
+
function dynamicImportPlugin(options = {}) {
|
|
376
|
+
return {
|
|
377
|
+
name: "vitest:browser:esm-injector",
|
|
378
|
+
enforce: "post",
|
|
379
|
+
transform(source, id) {
|
|
380
|
+
// TODO: test is not called for static imports
|
|
381
|
+
if (!regexDynamicImport.test(source)) {
|
|
382
|
+
return;
|
|
383
|
+
}
|
|
384
|
+
if (options.filter && !options.filter(id)) {
|
|
385
|
+
return;
|
|
386
|
+
}
|
|
387
|
+
return injectDynamicImport(source, id, this.parse, options);
|
|
388
|
+
}
|
|
389
|
+
};
|
|
390
|
+
}
|
|
391
|
+
function injectDynamicImport(code, id, parse, options = {}) {
|
|
392
|
+
const s = new MagicString(code);
|
|
393
|
+
let ast;
|
|
394
|
+
try {
|
|
395
|
+
ast = parse(code);
|
|
396
|
+
} catch (err) {
|
|
397
|
+
console.error(`Cannot parse ${id}:\n${err.message}`);
|
|
398
|
+
return;
|
|
399
|
+
}
|
|
400
|
+
// 3. convert references to import bindings & import.meta references
|
|
401
|
+
esmWalker(ast, {
|
|
402
|
+
onImportMeta() {
|
|
403
|
+
// s.update(node.start, node.end, viImportMetaKey)
|
|
404
|
+
},
|
|
405
|
+
onDynamicImport(node) {
|
|
406
|
+
const globalThisAccessor = options.globalThisAccessor || "\"__vitest_mocker__\"";
|
|
407
|
+
const replaceString = `globalThis[${globalThisAccessor}].wrapDynamicImport(() => import(`;
|
|
408
|
+
const importSubstring = code.substring(node.start, node.end);
|
|
409
|
+
const hasIgnore = importSubstring.includes("/* @vite-ignore */");
|
|
410
|
+
s.overwrite(node.start, node.source.start, replaceString + (hasIgnore ? "/* @vite-ignore */ " : ""));
|
|
411
|
+
s.overwrite(node.end - 1, node.end, "))");
|
|
412
|
+
}
|
|
413
|
+
});
|
|
414
|
+
return {
|
|
415
|
+
code: s.toString(),
|
|
416
|
+
map: s.generateMap({
|
|
417
|
+
hires: "boundary",
|
|
418
|
+
source: id
|
|
419
|
+
})
|
|
420
|
+
};
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
// AST walker module for ESTree compatible trees
|
|
424
|
+
|
|
425
|
+
|
|
426
|
+
function makeTest(test) {
|
|
427
|
+
if (typeof test === "string")
|
|
428
|
+
{ return function (type) { return type === test; } }
|
|
429
|
+
else if (!test)
|
|
430
|
+
{ return function () { return true; } }
|
|
431
|
+
else
|
|
432
|
+
{ return test }
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
var Found = function Found(node, state) { this.node = node; this.state = state; };
|
|
436
|
+
|
|
437
|
+
// Find the innermost node of a given type that contains the given
|
|
438
|
+
// position. Interface similar to findNodeAt.
|
|
439
|
+
function findNodeAround(node, pos, test, baseVisitor, state) {
|
|
440
|
+
test = makeTest(test);
|
|
441
|
+
if (!baseVisitor) { baseVisitor = base; }
|
|
442
|
+
try {
|
|
443
|
+
(function c(node, st, override) {
|
|
444
|
+
var type = override || node.type;
|
|
445
|
+
if (node.start > pos || node.end < pos) { return }
|
|
446
|
+
baseVisitor[type](node, st, c);
|
|
447
|
+
if (test(type, node)) { throw new Found(node, st) }
|
|
448
|
+
})(node, state);
|
|
449
|
+
} catch (e) {
|
|
450
|
+
if (e instanceof Found) { return e }
|
|
451
|
+
throw e
|
|
452
|
+
}
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
function skipThrough(node, st, c) { c(node, st); }
|
|
456
|
+
function ignore(_node, _st, _c) {}
|
|
457
|
+
|
|
458
|
+
// Node walkers.
|
|
459
|
+
|
|
460
|
+
var base = {};
|
|
461
|
+
|
|
462
|
+
base.Program = base.BlockStatement = base.StaticBlock = function (node, st, c) {
|
|
463
|
+
for (var i = 0, list = node.body; i < list.length; i += 1)
|
|
464
|
+
{
|
|
465
|
+
var stmt = list[i];
|
|
466
|
+
|
|
467
|
+
c(stmt, st, "Statement");
|
|
468
|
+
}
|
|
469
|
+
};
|
|
470
|
+
base.Statement = skipThrough;
|
|
471
|
+
base.EmptyStatement = ignore;
|
|
472
|
+
base.ExpressionStatement = base.ParenthesizedExpression = base.ChainExpression =
|
|
473
|
+
function (node, st, c) { return c(node.expression, st, "Expression"); };
|
|
474
|
+
base.IfStatement = function (node, st, c) {
|
|
475
|
+
c(node.test, st, "Expression");
|
|
476
|
+
c(node.consequent, st, "Statement");
|
|
477
|
+
if (node.alternate) { c(node.alternate, st, "Statement"); }
|
|
478
|
+
};
|
|
479
|
+
base.LabeledStatement = function (node, st, c) { return c(node.body, st, "Statement"); };
|
|
480
|
+
base.BreakStatement = base.ContinueStatement = ignore;
|
|
481
|
+
base.WithStatement = function (node, st, c) {
|
|
482
|
+
c(node.object, st, "Expression");
|
|
483
|
+
c(node.body, st, "Statement");
|
|
484
|
+
};
|
|
485
|
+
base.SwitchStatement = function (node, st, c) {
|
|
486
|
+
c(node.discriminant, st, "Expression");
|
|
487
|
+
for (var i = 0, list = node.cases; i < list.length; i += 1) {
|
|
488
|
+
var cs = list[i];
|
|
489
|
+
|
|
490
|
+
c(cs, st);
|
|
491
|
+
}
|
|
492
|
+
};
|
|
493
|
+
base.SwitchCase = function (node, st, c) {
|
|
494
|
+
if (node.test) { c(node.test, st, "Expression"); }
|
|
495
|
+
for (var i = 0, list = node.consequent; i < list.length; i += 1)
|
|
496
|
+
{
|
|
497
|
+
var cons = list[i];
|
|
498
|
+
|
|
499
|
+
c(cons, st, "Statement");
|
|
500
|
+
}
|
|
501
|
+
};
|
|
502
|
+
base.ReturnStatement = base.YieldExpression = base.AwaitExpression = function (node, st, c) {
|
|
503
|
+
if (node.argument) { c(node.argument, st, "Expression"); }
|
|
504
|
+
};
|
|
505
|
+
base.ThrowStatement = base.SpreadElement =
|
|
506
|
+
function (node, st, c) { return c(node.argument, st, "Expression"); };
|
|
507
|
+
base.TryStatement = function (node, st, c) {
|
|
508
|
+
c(node.block, st, "Statement");
|
|
509
|
+
if (node.handler) { c(node.handler, st); }
|
|
510
|
+
if (node.finalizer) { c(node.finalizer, st, "Statement"); }
|
|
511
|
+
};
|
|
512
|
+
base.CatchClause = function (node, st, c) {
|
|
513
|
+
if (node.param) { c(node.param, st, "Pattern"); }
|
|
514
|
+
c(node.body, st, "Statement");
|
|
515
|
+
};
|
|
516
|
+
base.WhileStatement = base.DoWhileStatement = function (node, st, c) {
|
|
517
|
+
c(node.test, st, "Expression");
|
|
518
|
+
c(node.body, st, "Statement");
|
|
519
|
+
};
|
|
520
|
+
base.ForStatement = function (node, st, c) {
|
|
521
|
+
if (node.init) { c(node.init, st, "ForInit"); }
|
|
522
|
+
if (node.test) { c(node.test, st, "Expression"); }
|
|
523
|
+
if (node.update) { c(node.update, st, "Expression"); }
|
|
524
|
+
c(node.body, st, "Statement");
|
|
525
|
+
};
|
|
526
|
+
base.ForInStatement = base.ForOfStatement = function (node, st, c) {
|
|
527
|
+
c(node.left, st, "ForInit");
|
|
528
|
+
c(node.right, st, "Expression");
|
|
529
|
+
c(node.body, st, "Statement");
|
|
530
|
+
};
|
|
531
|
+
base.ForInit = function (node, st, c) {
|
|
532
|
+
if (node.type === "VariableDeclaration") { c(node, st); }
|
|
533
|
+
else { c(node, st, "Expression"); }
|
|
534
|
+
};
|
|
535
|
+
base.DebuggerStatement = ignore;
|
|
536
|
+
|
|
537
|
+
base.FunctionDeclaration = function (node, st, c) { return c(node, st, "Function"); };
|
|
538
|
+
base.VariableDeclaration = function (node, st, c) {
|
|
539
|
+
for (var i = 0, list = node.declarations; i < list.length; i += 1)
|
|
540
|
+
{
|
|
541
|
+
var decl = list[i];
|
|
542
|
+
|
|
543
|
+
c(decl, st);
|
|
544
|
+
}
|
|
545
|
+
};
|
|
546
|
+
base.VariableDeclarator = function (node, st, c) {
|
|
547
|
+
c(node.id, st, "Pattern");
|
|
548
|
+
if (node.init) { c(node.init, st, "Expression"); }
|
|
549
|
+
};
|
|
550
|
+
|
|
551
|
+
base.Function = function (node, st, c) {
|
|
552
|
+
if (node.id) { c(node.id, st, "Pattern"); }
|
|
553
|
+
for (var i = 0, list = node.params; i < list.length; i += 1)
|
|
554
|
+
{
|
|
555
|
+
var param = list[i];
|
|
556
|
+
|
|
557
|
+
c(param, st, "Pattern");
|
|
558
|
+
}
|
|
559
|
+
c(node.body, st, node.expression ? "Expression" : "Statement");
|
|
560
|
+
};
|
|
561
|
+
|
|
562
|
+
base.Pattern = function (node, st, c) {
|
|
563
|
+
if (node.type === "Identifier")
|
|
564
|
+
{ c(node, st, "VariablePattern"); }
|
|
565
|
+
else if (node.type === "MemberExpression")
|
|
566
|
+
{ c(node, st, "MemberPattern"); }
|
|
567
|
+
else
|
|
568
|
+
{ c(node, st); }
|
|
569
|
+
};
|
|
570
|
+
base.VariablePattern = ignore;
|
|
571
|
+
base.MemberPattern = skipThrough;
|
|
572
|
+
base.RestElement = function (node, st, c) { return c(node.argument, st, "Pattern"); };
|
|
573
|
+
base.ArrayPattern = function (node, st, c) {
|
|
574
|
+
for (var i = 0, list = node.elements; i < list.length; i += 1) {
|
|
575
|
+
var elt = list[i];
|
|
576
|
+
|
|
577
|
+
if (elt) { c(elt, st, "Pattern"); }
|
|
578
|
+
}
|
|
579
|
+
};
|
|
580
|
+
base.ObjectPattern = function (node, st, c) {
|
|
581
|
+
for (var i = 0, list = node.properties; i < list.length; i += 1) {
|
|
582
|
+
var prop = list[i];
|
|
583
|
+
|
|
584
|
+
if (prop.type === "Property") {
|
|
585
|
+
if (prop.computed) { c(prop.key, st, "Expression"); }
|
|
586
|
+
c(prop.value, st, "Pattern");
|
|
587
|
+
} else if (prop.type === "RestElement") {
|
|
588
|
+
c(prop.argument, st, "Pattern");
|
|
589
|
+
}
|
|
590
|
+
}
|
|
591
|
+
};
|
|
592
|
+
|
|
593
|
+
base.Expression = skipThrough;
|
|
594
|
+
base.ThisExpression = base.Super = base.MetaProperty = ignore;
|
|
595
|
+
base.ArrayExpression = function (node, st, c) {
|
|
596
|
+
for (var i = 0, list = node.elements; i < list.length; i += 1) {
|
|
597
|
+
var elt = list[i];
|
|
598
|
+
|
|
599
|
+
if (elt) { c(elt, st, "Expression"); }
|
|
600
|
+
}
|
|
601
|
+
};
|
|
602
|
+
base.ObjectExpression = function (node, st, c) {
|
|
603
|
+
for (var i = 0, list = node.properties; i < list.length; i += 1)
|
|
604
|
+
{
|
|
605
|
+
var prop = list[i];
|
|
606
|
+
|
|
607
|
+
c(prop, st);
|
|
608
|
+
}
|
|
609
|
+
};
|
|
610
|
+
base.FunctionExpression = base.ArrowFunctionExpression = base.FunctionDeclaration;
|
|
611
|
+
base.SequenceExpression = function (node, st, c) {
|
|
612
|
+
for (var i = 0, list = node.expressions; i < list.length; i += 1)
|
|
613
|
+
{
|
|
614
|
+
var expr = list[i];
|
|
615
|
+
|
|
616
|
+
c(expr, st, "Expression");
|
|
617
|
+
}
|
|
618
|
+
};
|
|
619
|
+
base.TemplateLiteral = function (node, st, c) {
|
|
620
|
+
for (var i = 0, list = node.quasis; i < list.length; i += 1)
|
|
621
|
+
{
|
|
622
|
+
var quasi = list[i];
|
|
623
|
+
|
|
624
|
+
c(quasi, st);
|
|
625
|
+
}
|
|
626
|
+
|
|
627
|
+
for (var i$1 = 0, list$1 = node.expressions; i$1 < list$1.length; i$1 += 1)
|
|
628
|
+
{
|
|
629
|
+
var expr = list$1[i$1];
|
|
630
|
+
|
|
631
|
+
c(expr, st, "Expression");
|
|
632
|
+
}
|
|
633
|
+
};
|
|
634
|
+
base.TemplateElement = ignore;
|
|
635
|
+
base.UnaryExpression = base.UpdateExpression = function (node, st, c) {
|
|
636
|
+
c(node.argument, st, "Expression");
|
|
637
|
+
};
|
|
638
|
+
base.BinaryExpression = base.LogicalExpression = function (node, st, c) {
|
|
639
|
+
c(node.left, st, "Expression");
|
|
640
|
+
c(node.right, st, "Expression");
|
|
641
|
+
};
|
|
642
|
+
base.AssignmentExpression = base.AssignmentPattern = function (node, st, c) {
|
|
643
|
+
c(node.left, st, "Pattern");
|
|
644
|
+
c(node.right, st, "Expression");
|
|
645
|
+
};
|
|
646
|
+
base.ConditionalExpression = function (node, st, c) {
|
|
647
|
+
c(node.test, st, "Expression");
|
|
648
|
+
c(node.consequent, st, "Expression");
|
|
649
|
+
c(node.alternate, st, "Expression");
|
|
650
|
+
};
|
|
651
|
+
base.NewExpression = base.CallExpression = function (node, st, c) {
|
|
652
|
+
c(node.callee, st, "Expression");
|
|
653
|
+
if (node.arguments)
|
|
654
|
+
{ for (var i = 0, list = node.arguments; i < list.length; i += 1)
|
|
655
|
+
{
|
|
656
|
+
var arg = list[i];
|
|
657
|
+
|
|
658
|
+
c(arg, st, "Expression");
|
|
659
|
+
} }
|
|
660
|
+
};
|
|
661
|
+
base.MemberExpression = function (node, st, c) {
|
|
662
|
+
c(node.object, st, "Expression");
|
|
663
|
+
if (node.computed) { c(node.property, st, "Expression"); }
|
|
664
|
+
};
|
|
665
|
+
base.ExportNamedDeclaration = base.ExportDefaultDeclaration = function (node, st, c) {
|
|
666
|
+
if (node.declaration)
|
|
667
|
+
{ c(node.declaration, st, node.type === "ExportNamedDeclaration" || node.declaration.id ? "Statement" : "Expression"); }
|
|
668
|
+
if (node.source) { c(node.source, st, "Expression"); }
|
|
669
|
+
};
|
|
670
|
+
base.ExportAllDeclaration = function (node, st, c) {
|
|
671
|
+
if (node.exported)
|
|
672
|
+
{ c(node.exported, st); }
|
|
673
|
+
c(node.source, st, "Expression");
|
|
674
|
+
};
|
|
675
|
+
base.ImportDeclaration = function (node, st, c) {
|
|
676
|
+
for (var i = 0, list = node.specifiers; i < list.length; i += 1)
|
|
677
|
+
{
|
|
678
|
+
var spec = list[i];
|
|
679
|
+
|
|
680
|
+
c(spec, st);
|
|
681
|
+
}
|
|
682
|
+
c(node.source, st, "Expression");
|
|
683
|
+
};
|
|
684
|
+
base.ImportExpression = function (node, st, c) {
|
|
685
|
+
c(node.source, st, "Expression");
|
|
686
|
+
};
|
|
687
|
+
base.ImportSpecifier = base.ImportDefaultSpecifier = base.ImportNamespaceSpecifier = base.Identifier = base.PrivateIdentifier = base.Literal = ignore;
|
|
688
|
+
|
|
689
|
+
base.TaggedTemplateExpression = function (node, st, c) {
|
|
690
|
+
c(node.tag, st, "Expression");
|
|
691
|
+
c(node.quasi, st, "Expression");
|
|
692
|
+
};
|
|
693
|
+
base.ClassDeclaration = base.ClassExpression = function (node, st, c) { return c(node, st, "Class"); };
|
|
694
|
+
base.Class = function (node, st, c) {
|
|
695
|
+
if (node.id) { c(node.id, st, "Pattern"); }
|
|
696
|
+
if (node.superClass) { c(node.superClass, st, "Expression"); }
|
|
697
|
+
c(node.body, st);
|
|
698
|
+
};
|
|
699
|
+
base.ClassBody = function (node, st, c) {
|
|
700
|
+
for (var i = 0, list = node.body; i < list.length; i += 1)
|
|
701
|
+
{
|
|
702
|
+
var elt = list[i];
|
|
703
|
+
|
|
704
|
+
c(elt, st);
|
|
705
|
+
}
|
|
706
|
+
};
|
|
707
|
+
base.MethodDefinition = base.PropertyDefinition = base.Property = function (node, st, c) {
|
|
708
|
+
if (node.computed) { c(node.key, st, "Expression"); }
|
|
709
|
+
if (node.value) { c(node.value, st, "Expression"); }
|
|
710
|
+
};
|
|
711
|
+
|
|
712
|
+
function hoistMocksPlugin(options = {}) {
|
|
713
|
+
const filter = options.filter || createFilter(options.include, options.exclude);
|
|
714
|
+
const { hoistableMockMethodNames = ["mock", "unmock"], dynamicImportMockMethodNames = [
|
|
715
|
+
"mock",
|
|
716
|
+
"unmock",
|
|
717
|
+
"doMock",
|
|
718
|
+
"doUnmock"
|
|
719
|
+
], hoistedMethodNames = ["hoisted"], utilsObjectNames = ["vi", "vitest"] } = options;
|
|
720
|
+
const methods = new Set([
|
|
721
|
+
...hoistableMockMethodNames,
|
|
722
|
+
...hoistedMethodNames,
|
|
723
|
+
...dynamicImportMockMethodNames
|
|
724
|
+
]);
|
|
725
|
+
const regexpHoistable = new RegExp(`\\b(?:${utilsObjectNames.join("|")})\\s*\.\\s*(?:${Array.from(methods).join("|")})\\(`);
|
|
726
|
+
return {
|
|
727
|
+
name: "vitest:mocks",
|
|
728
|
+
enforce: "post",
|
|
729
|
+
transform(code, id) {
|
|
730
|
+
if (!filter(id)) {
|
|
731
|
+
return;
|
|
732
|
+
}
|
|
733
|
+
return hoistMocks(code, id, this.parse, {
|
|
734
|
+
regexpHoistable,
|
|
735
|
+
hoistableMockMethodNames,
|
|
736
|
+
hoistedMethodNames,
|
|
737
|
+
utilsObjectNames,
|
|
738
|
+
dynamicImportMockMethodNames,
|
|
739
|
+
...options
|
|
740
|
+
});
|
|
741
|
+
}
|
|
742
|
+
};
|
|
743
|
+
}
|
|
744
|
+
const API_NOT_FOUND_ERROR = `There are some problems in resolving the mocks API.
|
|
745
|
+
You may encounter this issue when importing the mocks API from another module other than 'vitest'.
|
|
746
|
+
To fix this issue you can either:
|
|
747
|
+
- import the mocks API directly from 'vitest'
|
|
748
|
+
- enable the 'globals' options`;
|
|
749
|
+
function API_NOT_FOUND_CHECK(names) {
|
|
750
|
+
return `\nif (${names.map((name) => `typeof globalThis["${name}"] === "undefined"`).join(" && ")}) ` + `{ throw new Error(${JSON.stringify(API_NOT_FOUND_ERROR)}) }\n`;
|
|
751
|
+
}
|
|
752
|
+
function isIdentifier(node) {
|
|
753
|
+
return node.type === "Identifier";
|
|
754
|
+
}
|
|
755
|
+
function getNodeTail(code, node) {
|
|
756
|
+
let end = node.end;
|
|
757
|
+
if (code[node.end] === ";") {
|
|
758
|
+
end += 1;
|
|
759
|
+
}
|
|
760
|
+
if (code[node.end] === "\n") {
|
|
761
|
+
return end + 1;
|
|
762
|
+
}
|
|
763
|
+
if (code[node.end + 1] === "\n") {
|
|
764
|
+
end += 1;
|
|
765
|
+
}
|
|
766
|
+
return end;
|
|
767
|
+
}
|
|
768
|
+
const regexpHoistable = /\b(?:vi|vitest)\s*\.\s*(?:mock|unmock|hoisted|doMock|doUnmock)\(/;
|
|
769
|
+
const hashbangRE = /^#!.*\n/;
|
|
770
|
+
// this is a fork of Vite SSR transform
|
|
771
|
+
function hoistMocks(code, id, parse, options = {}) {
|
|
772
|
+
var _hashbangRE$exec;
|
|
773
|
+
const needHoisting = (options.regexpHoistable || regexpHoistable).test(code);
|
|
774
|
+
if (!needHoisting) {
|
|
775
|
+
return;
|
|
776
|
+
}
|
|
777
|
+
const s = new MagicString(code);
|
|
778
|
+
let ast;
|
|
779
|
+
try {
|
|
780
|
+
ast = parse(code);
|
|
781
|
+
} catch (err) {
|
|
782
|
+
console.error(`Cannot parse ${id}:\n${err.message}.`);
|
|
783
|
+
return;
|
|
784
|
+
}
|
|
785
|
+
const { hoistableMockMethodNames = ["mock", "unmock"], dynamicImportMockMethodNames = [
|
|
786
|
+
"mock",
|
|
787
|
+
"unmock",
|
|
788
|
+
"doMock",
|
|
789
|
+
"doUnmock"
|
|
790
|
+
], hoistedMethodNames = ["hoisted"], utilsObjectNames = ["vi", "vitest"], hoistedModule = "vitest" } = options;
|
|
791
|
+
// hoist at the start of the file, after the hashbang
|
|
792
|
+
let hoistIndex = ((_hashbangRE$exec = hashbangRE.exec(code)) === null || _hashbangRE$exec === void 0 ? void 0 : _hashbangRE$exec[0].length) ?? 0;
|
|
793
|
+
let hoistedModuleImported = false;
|
|
794
|
+
let uid = 0;
|
|
795
|
+
const idToImportMap = new Map();
|
|
796
|
+
const imports = [];
|
|
797
|
+
// this will transform import statements into dynamic ones, if there are imports
|
|
798
|
+
// it will keep the import as is, if we don't need to mock anything
|
|
799
|
+
// in browser environment it will wrap the module value with "vitest_wrap_module" function
|
|
800
|
+
// that returns a proxy to the module so that named exports can be mocked
|
|
801
|
+
function defineImport(importNode) {
|
|
802
|
+
const source = importNode.source.value;
|
|
803
|
+
// always hoist vitest import to top of the file, so
|
|
804
|
+
// "vi" helpers can access it
|
|
805
|
+
if (hoistedModule === source) {
|
|
806
|
+
hoistedModuleImported = true;
|
|
807
|
+
return;
|
|
808
|
+
}
|
|
809
|
+
const importId = `__vi_import_${uid++}__`;
|
|
810
|
+
imports.push({
|
|
811
|
+
id: importId,
|
|
812
|
+
node: importNode
|
|
813
|
+
});
|
|
814
|
+
return importId;
|
|
815
|
+
}
|
|
816
|
+
// 1. check all import statements and record id -> importName map
|
|
817
|
+
for (const node of ast.body) {
|
|
818
|
+
// import foo from 'foo' --> foo -> __import_foo__.default
|
|
819
|
+
// import { baz } from 'foo' --> baz -> __import_foo__.baz
|
|
820
|
+
// import * as ok from 'foo' --> ok -> __import_foo__
|
|
821
|
+
if (node.type === "ImportDeclaration") {
|
|
822
|
+
const importId = defineImport(node);
|
|
823
|
+
if (!importId) {
|
|
824
|
+
continue;
|
|
825
|
+
}
|
|
826
|
+
for (const spec of node.specifiers) {
|
|
827
|
+
if (spec.type === "ImportSpecifier") {
|
|
828
|
+
if (spec.imported.type === "Identifier") {
|
|
829
|
+
idToImportMap.set(spec.local.name, `${importId}.${spec.imported.name}`);
|
|
830
|
+
} else {
|
|
831
|
+
idToImportMap.set(spec.local.name, `${importId}[${JSON.stringify(spec.imported.value)}]`);
|
|
832
|
+
}
|
|
833
|
+
} else if (spec.type === "ImportDefaultSpecifier") {
|
|
834
|
+
idToImportMap.set(spec.local.name, `${importId}.default`);
|
|
835
|
+
} else {
|
|
836
|
+
// namespace specifier
|
|
837
|
+
idToImportMap.set(spec.local.name, importId);
|
|
838
|
+
}
|
|
839
|
+
}
|
|
840
|
+
}
|
|
841
|
+
}
|
|
842
|
+
const declaredConst = new Set();
|
|
843
|
+
const hoistedNodes = [];
|
|
844
|
+
function createSyntaxError(node, message) {
|
|
845
|
+
const _error = new SyntaxError(message);
|
|
846
|
+
Error.captureStackTrace(_error, createSyntaxError);
|
|
847
|
+
const serializedError = {
|
|
848
|
+
name: "SyntaxError",
|
|
849
|
+
message: _error.message,
|
|
850
|
+
stack: _error.stack
|
|
851
|
+
};
|
|
852
|
+
if (options.codeFrameGenerator) {
|
|
853
|
+
serializedError.frame = options.codeFrameGenerator(node, id, code);
|
|
854
|
+
}
|
|
855
|
+
return serializedError;
|
|
856
|
+
}
|
|
857
|
+
function assertNotDefaultExport(node, error) {
|
|
858
|
+
var _findNodeAround;
|
|
859
|
+
const defaultExport = (_findNodeAround = findNodeAround(ast, node.start, "ExportDefaultDeclaration")) === null || _findNodeAround === void 0 ? void 0 : _findNodeAround.node;
|
|
860
|
+
if ((defaultExport === null || defaultExport === void 0 ? void 0 : defaultExport.declaration) === node || (defaultExport === null || defaultExport === void 0 ? void 0 : defaultExport.declaration.type) === "AwaitExpression" && defaultExport.declaration.argument === node) {
|
|
861
|
+
throw createSyntaxError(defaultExport, error);
|
|
862
|
+
}
|
|
863
|
+
}
|
|
864
|
+
function assertNotNamedExport(node, error) {
|
|
865
|
+
var _findNodeAround2;
|
|
866
|
+
const nodeExported = (_findNodeAround2 = findNodeAround(ast, node.start, "ExportNamedDeclaration")) === null || _findNodeAround2 === void 0 ? void 0 : _findNodeAround2.node;
|
|
867
|
+
if ((nodeExported === null || nodeExported === void 0 ? void 0 : nodeExported.declaration) === node) {
|
|
868
|
+
throw createSyntaxError(nodeExported, error);
|
|
869
|
+
}
|
|
870
|
+
}
|
|
871
|
+
function getVariableDeclaration(node) {
|
|
872
|
+
var _findNodeAround3, _declarationNode$decl;
|
|
873
|
+
const declarationNode = (_findNodeAround3 = findNodeAround(ast, node.start, "VariableDeclaration")) === null || _findNodeAround3 === void 0 ? void 0 : _findNodeAround3.node;
|
|
874
|
+
const init = declarationNode === null || declarationNode === void 0 || (_declarationNode$decl = declarationNode.declarations[0]) === null || _declarationNode$decl === void 0 ? void 0 : _declarationNode$decl.init;
|
|
875
|
+
if (init && (init === node || init.type === "AwaitExpression" && init.argument === node)) {
|
|
876
|
+
return declarationNode;
|
|
877
|
+
}
|
|
878
|
+
}
|
|
879
|
+
const usedUtilityExports = new Set();
|
|
880
|
+
esmWalker(ast, {
|
|
881
|
+
onIdentifier(id, info, parentStack) {
|
|
882
|
+
const binding = idToImportMap.get(id.name);
|
|
883
|
+
if (!binding) {
|
|
884
|
+
return;
|
|
885
|
+
}
|
|
886
|
+
if (info.hasBindingShortcut) {
|
|
887
|
+
s.appendLeft(id.end, `: ${binding}`);
|
|
888
|
+
} else if (info.classDeclaration) {
|
|
889
|
+
if (!declaredConst.has(id.name)) {
|
|
890
|
+
declaredConst.add(id.name);
|
|
891
|
+
// locate the top-most node containing the class declaration
|
|
892
|
+
const topNode = parentStack[parentStack.length - 2];
|
|
893
|
+
s.prependRight(topNode.start, `const ${id.name} = ${binding};\n`);
|
|
894
|
+
}
|
|
895
|
+
} else if (!info.classExpression) {
|
|
896
|
+
s.update(id.start, id.end, binding);
|
|
897
|
+
}
|
|
898
|
+
},
|
|
899
|
+
onCallExpression(node) {
|
|
900
|
+
if (node.callee.type === "MemberExpression" && isIdentifier(node.callee.object) && utilsObjectNames.includes(node.callee.object.name) && isIdentifier(node.callee.property)) {
|
|
901
|
+
const methodName = node.callee.property.name;
|
|
902
|
+
usedUtilityExports.add(node.callee.object.name);
|
|
903
|
+
if (hoistableMockMethodNames.includes(methodName)) {
|
|
904
|
+
const method = `${node.callee.object.name}.${methodName}`;
|
|
905
|
+
assertNotDefaultExport(node, `Cannot export the result of "${method}". Remove export declaration because "${method}" doesn\'t return anything.`);
|
|
906
|
+
const declarationNode = getVariableDeclaration(node);
|
|
907
|
+
if (declarationNode) {
|
|
908
|
+
assertNotNamedExport(declarationNode, `Cannot export the result of "${method}". Remove export declaration because "${method}" doesn\'t return anything.`);
|
|
909
|
+
}
|
|
910
|
+
// rewrite vi.mock(import('..')) into vi.mock('..')
|
|
911
|
+
if (node.type === "CallExpression" && node.callee.type === "MemberExpression" && dynamicImportMockMethodNames.includes(node.callee.property.name)) {
|
|
912
|
+
const moduleInfo = node.arguments[0];
|
|
913
|
+
// vi.mock(import('./path')) -> vi.mock('./path')
|
|
914
|
+
if (moduleInfo.type === "ImportExpression") {
|
|
915
|
+
const source = moduleInfo.source;
|
|
916
|
+
s.overwrite(moduleInfo.start, moduleInfo.end, s.slice(source.start, source.end));
|
|
917
|
+
}
|
|
918
|
+
// vi.mock(await import('./path')) -> vi.mock('./path')
|
|
919
|
+
if (moduleInfo.type === "AwaitExpression" && moduleInfo.argument.type === "ImportExpression") {
|
|
920
|
+
const source = moduleInfo.argument.source;
|
|
921
|
+
s.overwrite(moduleInfo.start, moduleInfo.end, s.slice(source.start, source.end));
|
|
922
|
+
}
|
|
923
|
+
}
|
|
924
|
+
hoistedNodes.push(node);
|
|
925
|
+
} else if (dynamicImportMockMethodNames.includes(methodName)) {
|
|
926
|
+
const moduleInfo = node.arguments[0];
|
|
927
|
+
let source = null;
|
|
928
|
+
if (moduleInfo.type === "ImportExpression") {
|
|
929
|
+
source = moduleInfo.source;
|
|
930
|
+
}
|
|
931
|
+
if (moduleInfo.type === "AwaitExpression" && moduleInfo.argument.type === "ImportExpression") {
|
|
932
|
+
source = moduleInfo.argument.source;
|
|
933
|
+
}
|
|
934
|
+
if (source) {
|
|
935
|
+
s.overwrite(moduleInfo.start, moduleInfo.end, s.slice(source.start, source.end));
|
|
936
|
+
}
|
|
937
|
+
}
|
|
938
|
+
if (hoistedMethodNames.includes(methodName)) {
|
|
939
|
+
assertNotDefaultExport(node, "Cannot export hoisted variable. You can control hoisting behavior by placing the import from this file first.");
|
|
940
|
+
const declarationNode = getVariableDeclaration(node);
|
|
941
|
+
if (declarationNode) {
|
|
942
|
+
assertNotNamedExport(declarationNode, "Cannot export hoisted variable. You can control hoisting behavior by placing the import from this file first.");
|
|
943
|
+
// hoist "const variable = vi.hoisted(() => {})"
|
|
944
|
+
hoistedNodes.push(declarationNode);
|
|
945
|
+
} else {
|
|
946
|
+
var _findNodeAround4;
|
|
947
|
+
const awaitedExpression = (_findNodeAround4 = findNodeAround(ast, node.start, "AwaitExpression")) === null || _findNodeAround4 === void 0 ? void 0 : _findNodeAround4.node;
|
|
948
|
+
// hoist "await vi.hoisted(async () => {})" or "vi.hoisted(() => {})"
|
|
949
|
+
const moveNode = (awaitedExpression === null || awaitedExpression === void 0 ? void 0 : awaitedExpression.argument) === node ? awaitedExpression : node;
|
|
950
|
+
hoistedNodes.push(moveNode);
|
|
951
|
+
}
|
|
952
|
+
}
|
|
953
|
+
}
|
|
954
|
+
}
|
|
955
|
+
});
|
|
956
|
+
function getNodeName(node) {
|
|
957
|
+
const callee = node.callee || {};
|
|
958
|
+
if (callee.type === "MemberExpression" && isIdentifier(callee.property) && isIdentifier(callee.object)) {
|
|
959
|
+
return `${callee.object.name}.${callee.property.name}()`;
|
|
960
|
+
}
|
|
961
|
+
return "\"hoisted method\"";
|
|
962
|
+
}
|
|
963
|
+
function getNodeCall(node) {
|
|
964
|
+
if (node.type === "CallExpression") {
|
|
965
|
+
return node;
|
|
966
|
+
}
|
|
967
|
+
if (node.type === "VariableDeclaration") {
|
|
968
|
+
const { declarations } = node;
|
|
969
|
+
const init = declarations[0].init;
|
|
970
|
+
if (init) {
|
|
971
|
+
return getNodeCall(init);
|
|
972
|
+
}
|
|
973
|
+
}
|
|
974
|
+
if (node.type === "AwaitExpression") {
|
|
975
|
+
const { argument } = node;
|
|
976
|
+
if (argument.type === "CallExpression") {
|
|
977
|
+
return getNodeCall(argument);
|
|
978
|
+
}
|
|
979
|
+
}
|
|
980
|
+
return node;
|
|
981
|
+
}
|
|
982
|
+
function createError(outsideNode, insideNode) {
|
|
983
|
+
const outsideCall = getNodeCall(outsideNode);
|
|
984
|
+
const insideCall = getNodeCall(insideNode);
|
|
985
|
+
throw createSyntaxError(insideCall, `Cannot call ${getNodeName(insideCall)} inside ${getNodeName(outsideCall)}: both methods are hoisted to the top of the file and not actually called inside each other.`);
|
|
986
|
+
}
|
|
987
|
+
// validate hoistedNodes doesn't have nodes inside other nodes
|
|
988
|
+
for (let i = 0; i < hoistedNodes.length; i++) {
|
|
989
|
+
const node = hoistedNodes[i];
|
|
990
|
+
for (let j = i + 1; j < hoistedNodes.length; j++) {
|
|
991
|
+
const otherNode = hoistedNodes[j];
|
|
992
|
+
if (node.start >= otherNode.start && node.end <= otherNode.end) {
|
|
993
|
+
throw createError(otherNode, node);
|
|
994
|
+
}
|
|
995
|
+
if (otherNode.start >= node.start && otherNode.end <= node.end) {
|
|
996
|
+
throw createError(node, otherNode);
|
|
997
|
+
}
|
|
998
|
+
}
|
|
999
|
+
}
|
|
1000
|
+
// hoist vi.mock/vi.hoisted
|
|
1001
|
+
for (const node of hoistedNodes) {
|
|
1002
|
+
const end = getNodeTail(code, node);
|
|
1003
|
+
// don't hoist into itself if it's already at the top
|
|
1004
|
+
if (hoistIndex === end || hoistIndex === node.start) {
|
|
1005
|
+
hoistIndex = end;
|
|
1006
|
+
} else {
|
|
1007
|
+
s.move(node.start, end, hoistIndex);
|
|
1008
|
+
}
|
|
1009
|
+
}
|
|
1010
|
+
// hoist actual dynamic imports last so they are inserted after all hoisted mocks
|
|
1011
|
+
for (const { node: importNode, id: importId } of imports) {
|
|
1012
|
+
const source = importNode.source.value;
|
|
1013
|
+
s.update(importNode.start, importNode.end, `const ${importId} = await import(${JSON.stringify(source)});\n`);
|
|
1014
|
+
if (importNode.start === hoistIndex) {
|
|
1015
|
+
// no need to hoist, but update hoistIndex to keep the order
|
|
1016
|
+
hoistIndex = importNode.end;
|
|
1017
|
+
} else {
|
|
1018
|
+
// There will be an error if the module is called before it is imported,
|
|
1019
|
+
// so the module import statement is hoisted to the top
|
|
1020
|
+
s.move(importNode.start, importNode.end, hoistIndex);
|
|
1021
|
+
}
|
|
1022
|
+
}
|
|
1023
|
+
if (!hoistedModuleImported && hoistedNodes.length) {
|
|
1024
|
+
const utilityImports = [...usedUtilityExports];
|
|
1025
|
+
// "vi" or "vitest" is imported from a module other than "vitest"
|
|
1026
|
+
if (utilityImports.some((name) => idToImportMap.has(name))) {
|
|
1027
|
+
s.prepend(API_NOT_FOUND_CHECK(utilityImports));
|
|
1028
|
+
} else if (utilityImports.length) {
|
|
1029
|
+
s.prepend(`import { ${[...usedUtilityExports].join(", ")} } from ${JSON.stringify(hoistedModule)}\n`);
|
|
1030
|
+
}
|
|
1031
|
+
}
|
|
1032
|
+
return {
|
|
1033
|
+
code: s.toString(),
|
|
1034
|
+
map: s.generateMap({
|
|
1035
|
+
hires: "boundary",
|
|
1036
|
+
source: id
|
|
1037
|
+
})
|
|
1038
|
+
};
|
|
1039
|
+
}
|
|
1040
|
+
|
|
1041
|
+
function interceptorPlugin(options = {}) {
|
|
1042
|
+
const registry = options.registry || new MockerRegistry();
|
|
1043
|
+
return {
|
|
1044
|
+
name: "vitest:mocks:interceptor",
|
|
1045
|
+
enforce: "pre",
|
|
1046
|
+
load: {
|
|
1047
|
+
order: "pre",
|
|
1048
|
+
async handler(id) {
|
|
1049
|
+
const mock = registry.getById(id);
|
|
1050
|
+
if (!mock) {
|
|
1051
|
+
return;
|
|
1052
|
+
}
|
|
1053
|
+
if (mock.type === "manual") {
|
|
1054
|
+
const exports = Object.keys(await mock.resolve());
|
|
1055
|
+
const accessor = options.globalThisAccessor || "\"__vitest_mocker__\"";
|
|
1056
|
+
return createManualModuleSource(mock.url, exports, accessor);
|
|
1057
|
+
}
|
|
1058
|
+
if (mock.type === "redirect") {
|
|
1059
|
+
return readFile(mock.redirect, "utf-8");
|
|
1060
|
+
}
|
|
1061
|
+
}
|
|
1062
|
+
},
|
|
1063
|
+
transform: {
|
|
1064
|
+
order: "post",
|
|
1065
|
+
handler(code, id) {
|
|
1066
|
+
const mock = registry.getById(id);
|
|
1067
|
+
if (!mock) {
|
|
1068
|
+
return;
|
|
1069
|
+
}
|
|
1070
|
+
if (mock.type === "automock" || mock.type === "autospy") {
|
|
1071
|
+
const m = automockModule(code, mock.type, this.parse, { globalThisAccessor: options.globalThisAccessor });
|
|
1072
|
+
return {
|
|
1073
|
+
code: m.toString(),
|
|
1074
|
+
map: m.generateMap({
|
|
1075
|
+
hires: "boundary",
|
|
1076
|
+
source: cleanUrl(id)
|
|
1077
|
+
})
|
|
1078
|
+
};
|
|
1079
|
+
}
|
|
1080
|
+
}
|
|
1081
|
+
},
|
|
1082
|
+
configureServer(server) {
|
|
1083
|
+
server.ws.on("vitest:interceptor:register", (event) => {
|
|
1084
|
+
if (event.type === "manual") {
|
|
1085
|
+
const module = ManualMockedModule.fromJSON(event, async () => {
|
|
1086
|
+
const keys = await getFactoryExports(event.url);
|
|
1087
|
+
return Object.fromEntries(keys.map((key) => [key, null]));
|
|
1088
|
+
});
|
|
1089
|
+
registry.add(module);
|
|
1090
|
+
} else {
|
|
1091
|
+
if (event.type === "redirect") {
|
|
1092
|
+
const redirectUrl = new URL(event.redirect);
|
|
1093
|
+
event.redirect = join(server.config.root, redirectUrl.pathname);
|
|
1094
|
+
}
|
|
1095
|
+
registry.register(event);
|
|
1096
|
+
}
|
|
1097
|
+
server.ws.send("vitest:interceptor:register:result");
|
|
1098
|
+
});
|
|
1099
|
+
server.ws.on("vitest:interceptor:delete", (id) => {
|
|
1100
|
+
registry.delete(id);
|
|
1101
|
+
server.ws.send("vitest:interceptor:delete:result");
|
|
1102
|
+
});
|
|
1103
|
+
server.ws.on("vitest:interceptor:invalidate", () => {
|
|
1104
|
+
registry.clear();
|
|
1105
|
+
server.ws.send("vitest:interceptor:invalidate:result");
|
|
1106
|
+
});
|
|
1107
|
+
function getFactoryExports(url) {
|
|
1108
|
+
server.ws.send("vitest:interceptor:resolve", url);
|
|
1109
|
+
let timeout;
|
|
1110
|
+
return new Promise((resolve, reject) => {
|
|
1111
|
+
timeout = setTimeout(() => {
|
|
1112
|
+
reject(new Error(`Timeout while waiting for factory exports of ${url}`));
|
|
1113
|
+
}, 1e4);
|
|
1114
|
+
server.ws.on("vitest:interceptor:resolved", ({ url: resolvedUrl, keys }) => {
|
|
1115
|
+
if (resolvedUrl === url) {
|
|
1116
|
+
clearTimeout(timeout);
|
|
1117
|
+
resolve(keys);
|
|
1118
|
+
}
|
|
1119
|
+
});
|
|
1120
|
+
});
|
|
1121
|
+
}
|
|
1122
|
+
}
|
|
1123
|
+
};
|
|
1124
|
+
}
|
|
1125
|
+
|
|
1126
|
+
const VALID_ID_PREFIX = "/@id/";
|
|
1127
|
+
class ServerMockResolver {
|
|
1128
|
+
constructor(server, options = {}) {
|
|
1129
|
+
this.server = server;
|
|
1130
|
+
this.options = options;
|
|
1131
|
+
}
|
|
1132
|
+
async resolveMock(rawId, importer, options) {
|
|
1133
|
+
const { id, fsPath, external } = await this.resolveMockId(rawId, importer);
|
|
1134
|
+
const resolvedUrl = this.normalizeResolveIdToUrl({ id }).url;
|
|
1135
|
+
if (options.mock === "factory") {
|
|
1136
|
+
var _manifest$fsPath;
|
|
1137
|
+
const manifest = getViteDepsManifest(this.server.config);
|
|
1138
|
+
const needsInterop = (manifest === null || manifest === void 0 || (_manifest$fsPath = manifest[fsPath]) === null || _manifest$fsPath === void 0 ? void 0 : _manifest$fsPath.needsInterop) ?? false;
|
|
1139
|
+
return {
|
|
1140
|
+
mockType: "manual",
|
|
1141
|
+
resolvedId: id,
|
|
1142
|
+
resolvedUrl,
|
|
1143
|
+
needsInterop
|
|
1144
|
+
};
|
|
1145
|
+
}
|
|
1146
|
+
if (options.mock === "spy") {
|
|
1147
|
+
return {
|
|
1148
|
+
mockType: "autospy",
|
|
1149
|
+
resolvedId: id,
|
|
1150
|
+
resolvedUrl
|
|
1151
|
+
};
|
|
1152
|
+
}
|
|
1153
|
+
const redirectUrl = findMockRedirect(this.server.config.root, fsPath, external);
|
|
1154
|
+
return {
|
|
1155
|
+
mockType: redirectUrl === null ? "automock" : "redirect",
|
|
1156
|
+
redirectUrl,
|
|
1157
|
+
resolvedId: id,
|
|
1158
|
+
resolvedUrl
|
|
1159
|
+
};
|
|
1160
|
+
}
|
|
1161
|
+
invalidate(ids) {
|
|
1162
|
+
ids.forEach((id) => {
|
|
1163
|
+
const moduleGraph = this.server.moduleGraph;
|
|
1164
|
+
const module = moduleGraph.getModuleById(id);
|
|
1165
|
+
if (module) {
|
|
1166
|
+
module.transformResult = null;
|
|
1167
|
+
}
|
|
1168
|
+
});
|
|
1169
|
+
}
|
|
1170
|
+
async resolveId(id, importer) {
|
|
1171
|
+
const resolved = await this.server.pluginContainer.resolveId(id, importer, { ssr: false });
|
|
1172
|
+
if (!resolved) {
|
|
1173
|
+
return null;
|
|
1174
|
+
}
|
|
1175
|
+
return this.normalizeResolveIdToUrl(resolved);
|
|
1176
|
+
}
|
|
1177
|
+
normalizeResolveIdToUrl(resolved) {
|
|
1178
|
+
const isOptimized = resolved.id.startsWith(withTrailingSlash(this.server.config.cacheDir));
|
|
1179
|
+
let url;
|
|
1180
|
+
// normalise the URL to be acceptable by the browser
|
|
1181
|
+
// https://github.com/vitejs/vite/blob/14027b0f2a9b01c14815c38aab22baf5b29594bb/packages/vite/src/node/plugins/importAnalysis.ts#L103
|
|
1182
|
+
const root = this.server.config.root;
|
|
1183
|
+
if (resolved.id.startsWith(withTrailingSlash(root))) {
|
|
1184
|
+
url = resolved.id.slice(root.length);
|
|
1185
|
+
} else if (resolved.id !== "/@react-refresh" && isAbsolute(resolved.id) && existsSync(cleanUrl(resolved.id))) {
|
|
1186
|
+
url = join$1("/@fs/", resolved.id);
|
|
1187
|
+
} else {
|
|
1188
|
+
url = resolved.id;
|
|
1189
|
+
}
|
|
1190
|
+
if (url[0] !== "." && url[0] !== "/") {
|
|
1191
|
+
url = resolved.id.startsWith(VALID_ID_PREFIX) ? resolved.id : VALID_ID_PREFIX + resolved.id.replace("\0", "__x00__");
|
|
1192
|
+
}
|
|
1193
|
+
return {
|
|
1194
|
+
id: resolved.id,
|
|
1195
|
+
url,
|
|
1196
|
+
optimized: isOptimized
|
|
1197
|
+
};
|
|
1198
|
+
}
|
|
1199
|
+
async resolveMockId(rawId, importer) {
|
|
1200
|
+
if (!this.server.moduleGraph.getModuleById(importer) && !importer.startsWith(this.server.config.root)) {
|
|
1201
|
+
importer = join$1(this.server.config.root, importer);
|
|
1202
|
+
}
|
|
1203
|
+
const resolved = await this.server.pluginContainer.resolveId(rawId, importer, { ssr: false });
|
|
1204
|
+
return this.resolveModule(rawId, resolved);
|
|
1205
|
+
}
|
|
1206
|
+
resolveModule(rawId, resolved) {
|
|
1207
|
+
const id = (resolved === null || resolved === void 0 ? void 0 : resolved.id) || rawId;
|
|
1208
|
+
const external = !isAbsolute(id) || isModuleDirectory(this.options, id) ? rawId : null;
|
|
1209
|
+
return {
|
|
1210
|
+
id,
|
|
1211
|
+
fsPath: cleanUrl(id),
|
|
1212
|
+
external
|
|
1213
|
+
};
|
|
1214
|
+
}
|
|
1215
|
+
}
|
|
1216
|
+
function isModuleDirectory(config, path) {
|
|
1217
|
+
const moduleDirectories = config.moduleDirectories || ["/node_modules/"];
|
|
1218
|
+
return moduleDirectories.some((dir) => path.includes(dir));
|
|
1219
|
+
}
|
|
1220
|
+
const metadata = new WeakMap();
|
|
1221
|
+
function getViteDepsManifest(config) {
|
|
1222
|
+
if (metadata.has(config)) {
|
|
1223
|
+
return metadata.get(config);
|
|
1224
|
+
}
|
|
1225
|
+
const cacheDirPath = getDepsCacheDir(config);
|
|
1226
|
+
const metadataPath = resolve(cacheDirPath, "_metadata.json");
|
|
1227
|
+
if (!existsSync(metadataPath)) {
|
|
1228
|
+
return null;
|
|
1229
|
+
}
|
|
1230
|
+
const { optimized } = JSON.parse(readFileSync(metadataPath, "utf-8"));
|
|
1231
|
+
const newManifest = {};
|
|
1232
|
+
for (const name in optimized) {
|
|
1233
|
+
const dep = optimized[name];
|
|
1234
|
+
const file = resolve(cacheDirPath, dep.file);
|
|
1235
|
+
newManifest[file] = {
|
|
1236
|
+
hash: dep.fileHash,
|
|
1237
|
+
needsInterop: dep.needsInterop
|
|
1238
|
+
};
|
|
1239
|
+
}
|
|
1240
|
+
metadata.set(config, newManifest);
|
|
1241
|
+
return newManifest;
|
|
1242
|
+
}
|
|
1243
|
+
function getDepsCacheDir(config) {
|
|
1244
|
+
return resolve(config.cacheDir, "deps");
|
|
1245
|
+
}
|
|
1246
|
+
function withTrailingSlash(path) {
|
|
1247
|
+
if (path[path.length - 1] !== "/") {
|
|
1248
|
+
return `${path}/`;
|
|
1249
|
+
}
|
|
1250
|
+
return path;
|
|
1251
|
+
}
|
|
1252
|
+
|
|
1253
|
+
// this is an implementation for public usage
|
|
1254
|
+
// vitest doesn't use this plugin directly
|
|
1255
|
+
function mockerPlugin(options = {}) {
|
|
1256
|
+
let server;
|
|
1257
|
+
const registerPath = resolve(fileURLToPath(new URL("./register.js", import.meta.url)));
|
|
1258
|
+
return [
|
|
1259
|
+
{
|
|
1260
|
+
name: "vitest:mocker:ws-rpc",
|
|
1261
|
+
config(_, { command }) {
|
|
1262
|
+
if (command !== "serve") {
|
|
1263
|
+
return;
|
|
1264
|
+
}
|
|
1265
|
+
return {
|
|
1266
|
+
server: { preTransformRequests: false },
|
|
1267
|
+
optimizeDeps: { exclude: ["@vitest/mocker/register", "@vitest/mocker/browser"] }
|
|
1268
|
+
};
|
|
1269
|
+
},
|
|
1270
|
+
configureServer(server_) {
|
|
1271
|
+
server = server_;
|
|
1272
|
+
const mockResolver = new ServerMockResolver(server);
|
|
1273
|
+
server.ws.on("vitest:mocks:resolveId", async ({ id, importer }) => {
|
|
1274
|
+
const resolved = await mockResolver.resolveId(id, importer);
|
|
1275
|
+
server.ws.send("vitest:mocks:resolvedId:result", resolved);
|
|
1276
|
+
});
|
|
1277
|
+
server.ws.on("vitest:mocks:resolveMock", async ({ id, importer, options }) => {
|
|
1278
|
+
const resolved = await mockResolver.resolveMock(id, importer, options);
|
|
1279
|
+
server.ws.send("vitest:mocks:resolveMock:result", resolved);
|
|
1280
|
+
});
|
|
1281
|
+
server.ws.on("vitest:mocks:invalidate", async ({ ids }) => {
|
|
1282
|
+
mockResolver.invalidate(ids);
|
|
1283
|
+
server.ws.send("vitest:mocks:invalidate:result");
|
|
1284
|
+
});
|
|
1285
|
+
},
|
|
1286
|
+
async load(id) {
|
|
1287
|
+
if (id !== registerPath) {
|
|
1288
|
+
return;
|
|
1289
|
+
}
|
|
1290
|
+
if (!server) {
|
|
1291
|
+
// mocker doesn't work during build
|
|
1292
|
+
return "export {}";
|
|
1293
|
+
}
|
|
1294
|
+
const content = await readFile(registerPath, "utf-8");
|
|
1295
|
+
const result = content.replace(/__VITEST_GLOBAL_THIS_ACCESSOR__/g, options.globalThisAccessor ?? "\"__vitest_mocker__\"").replace("__VITEST_MOCKER_ROOT__", JSON.stringify(server.config.root));
|
|
1296
|
+
return result;
|
|
1297
|
+
}
|
|
1298
|
+
},
|
|
1299
|
+
hoistMocksPlugin(options.hoistMocks),
|
|
1300
|
+
interceptorPlugin(options),
|
|
1301
|
+
automockPlugin(options),
|
|
1302
|
+
dynamicImportPlugin(options)
|
|
1303
|
+
];
|
|
1304
|
+
}
|
|
1305
|
+
|
|
1306
|
+
export { ServerMockResolver, automockModule, automockPlugin, createManualModuleSource, dynamicImportPlugin, findMockRedirect, hoistMocks, hoistMocksPlugin, interceptorPlugin, mockerPlugin };
|