weapp-vite 6.11.9 → 6.12.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -31,6 +31,8 @@
31
31
 
32
32
  ## 快速开始
33
33
 
34
+ > 说明:CLI 同时支持完整命令 `weapp-vite` 与简写命令 `wv`,两者等价。下面的示例默认使用 `weapp-vite`,你也可以按个人习惯替换成 `wv`。
35
+
34
36
  ### Vue 项目
35
37
 
36
38
  ```typescript
@@ -85,6 +87,42 @@ function handleClick() {
85
87
  - Vite 插件识别 weapp-vite 宿主:https://vite.icebreaker.top/guide/vite-plugin-host
86
88
  - MCP 集成使用指南:[docs/mcp.md](./docs/mcp.md)
87
89
 
90
+ ## AI 项目指引
91
+
92
+ 通过 `create-weapp-vite` 创建的新项目,现在会默认携带一个根目录 `AGENTS.md`。同时,`weapp-vite` npm 包会随版本发布一份本地文档目录:`node_modules/weapp-vite/dist/docs/`。
93
+
94
+ 这个文件会告诉常见 AI 编程代理:
95
+
96
+ - 安装依赖后,优先阅读 `node_modules/weapp-vite/dist/docs/README.md`、`node_modules/weapp-vite/dist/docs/mcp.md` 等本地版本文档
97
+ - CLI 同时支持 `weapp-vite` 与 `wv`
98
+ - 需要做小程序截图验收时,优先使用 `weapp-vite screenshot` 或 `wv screenshot`
99
+ - 不要把小程序运行时截图退化成通用浏览器截图
100
+ - 需要看 DevTools 终端日志时,优先使用 `weapp-vite ide logs --open` 或 `wv ide logs --open`
101
+
102
+ `dist/docs` 当前会内置这些文件:
103
+
104
+ - `README.md`
105
+ - `getting-started.md`
106
+ - `ai-workflows.md`
107
+ - `project-structure.md`
108
+ - `weapp-config.md`
109
+ - `wevu-authoring.md`
110
+ - `vue-sfc.md`
111
+ - `troubleshooting.md`
112
+ - `mcp.md`
113
+ - `volar.md`
114
+ - `define-config-overloads.md`
115
+ - `index.md`
116
+
117
+ 推荐的截图命令示例:
118
+
119
+ ```sh
120
+ weapp-vite screenshot --project ./dist/build/mp-weixin --page pages/index/index --output .tmp/acceptance.png --json
121
+
122
+ # 等价写法
123
+ wv screenshot --project ./dist/build/mp-weixin --page pages/index/index --output .tmp/acceptance.png --json
124
+ ```
125
+
88
126
  ## DevTools 日志桥接
89
127
 
90
128
  `weapp-vite` 现在支持把微信开发者工具里的小程序 `console` 输出桥接到当前终端。
@@ -116,6 +154,9 @@ export default defineConfig({
116
154
  ```sh
117
155
  weapp-vite ide logs
118
156
  weapp-vite ide logs --open
157
+ # 等价写法
158
+ wv ide logs
159
+ wv ide logs --open
119
160
  ```
120
161
 
121
162
  ## CLI 中调用 weapp-ide-cli
@@ -127,6 +168,8 @@ weapp-vite preview --project ./dist/build/mp-weixin
127
168
  weapp-vite upload --project ./dist/build/mp-weixin -v 1.0.0 -d "release"
128
169
  weapp-vite config lang zh
129
170
  weapp-vite navigate pages/index/index --project ./dist/build/mp-weixin
171
+ # 等价写法
172
+ wv preview --project ./dist/build/mp-weixin
130
173
  ```
131
174
 
132
175
  也支持命名空间写法:
@@ -135,6 +178,8 @@ weapp-vite navigate pages/index/index --project ./dist/build/mp-weixin
135
178
  weapp-vite ide preview --project ./dist/build/mp-weixin
136
179
  weapp-vite ide config show
137
180
  weapp-vite ide logs --open
181
+ # 等价写法
182
+ wv ide preview --project ./dist/build/mp-weixin
138
183
  ```
139
184
 
140
185
  ## CLI 启动 MCP
@@ -146,12 +191,16 @@ weapp-vite ide logs --open
146
191
 
147
192
  ```sh
148
193
  weapp-vite mcp
194
+ # 等价写法
195
+ wv mcp
149
196
  ```
150
197
 
151
198
  指定工作区根路径:
152
199
 
153
200
  ```sh
154
201
  weapp-vite mcp --workspace-root /absolute/path/to/weapp-vite
202
+ # 等价写法
203
+ wv mcp --workspace-root /absolute/path/to/weapp-vite
155
204
  ```
156
205
 
157
206
  在 `vite.config.ts` 中开启自动启动:
@@ -1,4 +1,4 @@
1
- import { i as getCompilerContext } from "./createContext-DZgOqIMU.mjs";
1
+ import { i as getCompilerContext, l as getRouteRuntimeGlobalKeys } from "./createContext-Dk8fZ9cf.mjs";
2
2
  //#region src/auto-routes.ts
3
3
  const ROUTE_RUNTIME_OVERRIDE_KEY = Symbol.for("weapp-vite.route-runtime");
4
4
  function createGetter(resolver) {
@@ -28,7 +28,10 @@ function resolveMiniProgramGlobal() {
28
28
  const runtime = globalThis;
29
29
  const overrideRuntime = runtime[ROUTE_RUNTIME_OVERRIDE_KEY];
30
30
  if (overrideRuntime) return overrideRuntime;
31
- return runtime.wx ?? runtime.tt ?? runtime.my;
31
+ for (const key of getRouteRuntimeGlobalKeys()) {
32
+ const candidate = runtime[key];
33
+ if (candidate) return candidate;
34
+ }
32
35
  }
33
36
  function callRouteMethod(methodName, option) {
34
37
  const miniProgramGlobal = resolveMiniProgramGlobal();