{"_id":"@blyou/vite-plugin-uni-launcher","name":"@blyou/vite-plugin-uni-launcher","dist-tags":{"latest":"0.0.1"},"versions":{"0.0.1":{"name":"@blyou/vite-plugin-uni-launcher","version":"0.0.1","description":"A Vite plugin that auto-launches the matching mini-program devtool after a uni-app build.","keywords":["devtool","launcher","miniprogram","uni-app"],"homepage":"https://github.com/blyou/vite-plugin-uni-launcher#readme","bugs":{"url":"https://github.com/blyou/vite-plugin-uni-launcher/issues"},"license":"MIT","author":{"name":"blyou","email":"youbolincode@163.com"},"repository":{"type":"git","url":"git+https://github.com/blyou/vite-plugin-uni-launcher.git"},"type":"module","main":"./dist/index.cjs","module":"./dist/index.mjs","types":"./dist/index.d.cts","exports":{".":{"import":"./dist/index.mjs","require":"./dist/index.cjs"},"./package.json":"./package.json"},"publishConfig":{"access":"public"},"scripts":{"build":"tsdown","dev":"tsdown --watch","test":"vitest","typecheck":"tsc --noEmit","release":"bumpp","prepublishOnly":"pnpm run build","lint":"run-s lint:*","lint:oxlint":"oxlint . --fix","lint:eslint":"eslint . --fix --cache","format":"oxfmt src/","git:hooks":"pnpm simple-git-hooks","taze":"pnpx taze -I"},"dependencies":{"minidev":"^2.2.5","picocolors":"^1.1.1","tt-ide-cli":"^0.1.33","zx":"^8.8.5"},"devDependencies":{"@commitlint/cli":"^21.2.1","@commitlint/config-conventional":"^21.2.0","@commitlint/types":"^21.2.0","@types/node":"^26.1.1","@typescript/native-preview":"7.0.0-dev.20260707.2","@vue/eslint-config-typescript":"^14.9.0","bumpp":"^12.0.0","eslint":"^10.7.0","eslint-config-prettier":"^10.1.8","eslint-plugin-oxlint":"^1.75.0","eslint-plugin-vue":"^10.10.0","lint-staged":"^17.1.1","npm-run-all2":"^9.0.2","oxfmt":"^0.60.0","oxlint":"^1.75.0","simple-git-hooks":"^2.13.1","tsdown":"^0.22.13","typescript":"^6.0.3","vitest":"^4.1.10"},"peerDependencies":{"vite":">=5.0.0 <8.0.0"},"packageManager":"pnpm@11.16.0+sha512.b767e9a98fc87aec0f42daefcd0e84941c2cdb45d73c4e1e68860fb2bdfdbe032ab592105479e5e05c237f740c8a5ffdbbb52385797ddc2296745a1bbb883e8d","gitHead":"605b50d429206cbe0e47a8bdb05c894e4a60bf56","_id":"@blyou/vite-plugin-uni-launcher@0.0.1","_nodeVersion":"24.16.0","_npmVersion":"11.13.0","dist":{"integrity":"sha512-k9Sqeb5kb8ekcV4VC6hGWHxdSLnOWKpalp0QjRUHqevq2WM1MWY/bNesv2yqlyB9Kt6pCch+cgJAyxdTWVu3wg==","shasum":"8df9e5682c9fa96bb10629d4d299445476da85a5","tarball":"https://registry.npmjs.org/@blyou/vite-plugin-uni-launcher/-/vite-plugin-uni-launcher-0.0.1.tgz","fileCount":7,"unpackedSize":29603,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIG+Re0CbBjsTFNmisEFUPkzqWfvxOmvuzOpGzljjfZU2AiEAlAoX8zqAdliWsyWpLNvVkUZ6D5UkL3BRG8rNS1GtJ3s="}]},"_npmUser":{"name":"blyou","email":"youbolincode@163.com"},"directories":{},"maintainers":[{"name":"blyou","email":"youbolincode@163.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/vite-plugin-uni-launcher_0.0.1_1784829813028_0.20303440789654403"},"_hasShrinkwrap":false}},"time":{"created":"2026-07-23T18:03:32.923Z","0.0.1":"2026-07-23T18:03:33.179Z","modified":"2026-07-23T18:03:33.409Z"},"maintainers":[{"name":"blyou","email":"youbolincode@163.com"}],"description":"A Vite plugin that auto-launches the matching mini-program devtool after a uni-app build.","homepage":"https://github.com/blyou/vite-plugin-uni-launcher#readme","keywords":["devtool","launcher","miniprogram","uni-app"],"repository":{"type":"git","url":"git+https://github.com/blyou/vite-plugin-uni-launcher.git"},"author":{"name":"blyou","email":"youbolincode@163.com"},"bugs":{"url":"https://github.com/blyou/vite-plugin-uni-launcher/issues"},"license":"MIT","readme":"# vite-plugin-uni-launcher\n\n一个用于 **uni-app（cli 工程）** 的 Vite 插件：构建/开发完成后，**自动拉起对应小程序开发者工具并打开当前项目**，省去手动在 IDE 里定位 `dist` 目录的重复操作。\n\n> 适用场景：使用 `@vue/cli-plugin-uni` / `vite` 的 uni-app 项目，需要「打包完成即打开微信/支付宝/抖音开发者工具」。\n\n## 特性\n\n- 🚀 资源就绪后**自动打开**对应平台的开发者工具，无需手动操作\n- 🧩 **平台适配层**：新增平台只需实现一个 `LauncherAdapter`，核心逻辑零改动\n- 🔌 支持运行时通过 `adapters` 选项注册自定义适配器（扩展点）\n- ⏱ 资源未就绪时按 `maxWait` 轮询等待，超时自动跳过\n\n## 安装\n\nnpm\n\n```bash\nnpm i -D @blyou/vite-plugin-uni-launcher\n```\n\npnpm\n\n```bash\npnpm add -D @blyou/vite-plugin-uni-launcher\n```\n\n## 快速上手\n\n插件会读取 `process.env.UNI_PLATFORM`（uni-app 在构建时自动注入，如 `mp-weixin`），\n据此匹配内置适配器并自动启用，因此**通常无需任何配置**：\n\n```ts\n// vite.config.ts\nimport { defineConfig } from 'vite'\nimport UniLauncher from '@blyou/vite-plugin-uni-launcher'\n\nexport default defineConfig({\n  plugins: [UniLauncher()],\n})\n```\n\n启动开发/构建后，产物资源生成即会自动打开对应开发者工具：\n\n```bash\n# 以微信小程序为例（UNI_PLATFORM 由 uni-app 注入）\nnpm run dev:mp-weixin\n```\n\n## 配置项\n\n`UniLauncher(options?: UniLauncherOptions)`\n\n| 选项       | 类型                | 默认值                    | 说明                                             |\n| ---------- | ------------------- | ------------------------- | ------------------------------------------------ |\n| `enabled`  | `boolean`           | 匹配到适配器时自动 `true` | 是否启用。仅在 uni-app cli 项目下有意义          |\n| `adapters` | `LauncherAdapter[]` | `[]`                      | 额外注册的自定义适配器（扩展点）                 |\n| `maxWait`  | `number`            | `30000`                   | 资源未就绪时轮询等待的最长毫秒数，超时则跳过打开 |\n\n```ts\nUniLauncher({\n  enabled: true,\n  maxWait: 60_000,\n  adapters: [myCustomAdapter],\n})\n```\n\n## 支持的平台\n\n内置以下适配器；当 `UNI_PLATFORM` 命中对应 `platform` 时自动启用。\n\n| 平台         | `platform`   | 开发者工具             | 路径环境变量      | 打开方式                           |\n| ------------ | ------------ | ---------------------- | ----------------- | ---------------------------------- |\n| 微信小程序   | `mp-weixin`  | 微信开发者工具         | `WEIXIN_IDE_PATH` | `cli.bat open --project <project>` |\n| 支付宝小程序 | `mp-alipay`  | 支付宝小程序开发者工具 | `ALIPAY_IDE_PATH` | `minidev.startIde(...)`            |\n| 抖音小程序   | `mp-toutiao` | 抖音开发者工具         | `TT_IDE_PATH`     | `tt-ide-cli open(...)`             |\n\n若自动探测失败，请用对应的**环境变量**指定开发者工具的绝对路径，优先级最高。\n\n## 工作原理\n\n1. `configResolved` 阶段根据 `config.root` 与当前 `mode`（development → `dev`，build → `build`）及平台，算出待打开的项目目录：\n\n   ```\n   <root>/dist/<mode>/<platform>\n   ```\n\n2. `closeBundle` 阶段若已启用且匹配到适配器，则轮询等待上述目录生成（最多 `maxWait` 毫秒）。\n3. 目录就绪后，调用适配器 `runOpenScript`，由适配器用已配置好 `shell` / `prefix` 的 `$` 拉起开发者工具。\n\n## 自定义适配器（扩展点）\n\n实现 `LauncherAdapter` 接口，再通过 `adapters` 选项注册即可：\n\n```ts\nimport type { LauncherAdapter } from '@blyou/vite-plugin-uni-launcher'\n\nconst myAdapter: LauncherAdapter = {\n  platform: 'mp-myplatform',\n  name: '我的开发者工具',\n  envKey: 'MY_DEVTOOLS', // 可选：用环境变量指定工具路径\n  resolveAppPath({ buildWindowsPath }) {\n    // 返回候选路径；path 优先级最高，其次按平台用 Windows / macOS\n    return { Windows: buildWindowsPath('MyTool/MyTool.exe') }\n  },\n  async runOpenScript({ $, appDir, project }) {\n    // 用透传的 $ 执行打开命令 或者调用 Node.JS API\n    await $`${appDir}/cli open --project ${project}`\n  },\n}\n\nUniLauncher({ adapters: [myAdapter] })\n```\n\n## 开发\n\n```bash\npnpm install        # 安装依赖\npnpm test           # 运行单元测试（vitest，监听模式）\npnpm run build      # 构建库（tsdown，输出 dist/）\npnpm run typecheck  # 类型检查\npnpm run lint       # 代码检查（oxlint + eslint）\n```\n\n## License\n\n[MIT](./LICENSE)\n","readmeFilename":"README.md","_rev":"1-d136b8f2fd83414b223036220da61869"}