@amaster.ai/vite-plugins 1.1.0-beta.6 → 1.1.0-beta.60
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/dist/index.cjs +268 -383
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +55 -34
- package/dist/index.d.ts +55 -34
- package/dist/index.js +268 -383
- package/dist/index.js.map +1 -1
- package/package.json +22 -6
- package/dist/bridge.bridge.js +0 -24
package/dist/index.d.ts
CHANGED
|
@@ -1,14 +1,9 @@
|
|
|
1
1
|
import { Plugin } from 'vite';
|
|
2
2
|
|
|
3
|
-
/**
|
|
4
|
-
* Vite plugin: Add data-node-component-id to React components
|
|
5
|
-
* Only enabled in development mode
|
|
6
|
-
*/
|
|
7
|
-
declare function componentIdPlugin(): Plugin;
|
|
8
|
-
|
|
9
3
|
/**
|
|
10
4
|
* Vite plugin: Inject editor bridge script
|
|
11
|
-
* Injects bridge
|
|
5
|
+
* Injects minimal bridge that loads external script from platform
|
|
6
|
+
* Also provides virtual module for HMR and Tailwind config monitoring
|
|
12
7
|
*/
|
|
13
8
|
declare function editorBridgePlugin(): Plugin;
|
|
14
9
|
|
|
@@ -20,30 +15,6 @@ declare function routesExposePlugin(options?: {
|
|
|
20
15
|
routesFilePath?: string;
|
|
21
16
|
}): Plugin;
|
|
22
17
|
|
|
23
|
-
/**
|
|
24
|
-
* Smart Reload 插件
|
|
25
|
-
*
|
|
26
|
-
* 在 Vite 服务器重启期间(如 PM2 重启 web-server),拦截浏览器端的刷新行为,
|
|
27
|
-
* 让浏览器静默等待 WebSocket 重连,重连成功后不刷新页面(除非有实际的模块变更)。
|
|
28
|
-
*
|
|
29
|
-
* 场景说明:
|
|
30
|
-
* - PM2 杀掉 Vite 进程 → WebSocket 断开 → PM2 重启 → 新 Vite 启动
|
|
31
|
-
* - Vite 客户端检测到 WebSocket 断开后会通过 HTTP ping 轮询等待服务器恢复
|
|
32
|
-
* - 服务器恢复后 Vite 客户端会调用 location.reload() 刷新页面
|
|
33
|
-
* - 本插件拦截这个刷新行为,让页面保持当前状态
|
|
34
|
-
*
|
|
35
|
-
* 区分两种 full-reload 场景:
|
|
36
|
-
* 1. 服务器重启 → full-reload 后 WebSocket 断开 → 静默等待重连,不刷新
|
|
37
|
-
* 2. 模块变更需要 full-reload → WebSocket 保持连接 → 正常刷新
|
|
38
|
-
*
|
|
39
|
-
* 纯浏览器端方案,对用户完全无感:
|
|
40
|
-
* - 不依赖服务端发送特殊消息
|
|
41
|
-
* - WebSocket 断开 → 进入静默等待模式 → 抑制 location.reload
|
|
42
|
-
* - Vite 客户端 HTTP ping 成功后调用 location.reload → 被拦截
|
|
43
|
-
* - 拦截后延迟执行一次 soft-reload 恢复 HMR 连接
|
|
44
|
-
*/
|
|
45
|
-
declare function smartReloadPlugin(): Plugin;
|
|
46
|
-
|
|
47
18
|
interface TaroStyleAdapterOptions {
|
|
48
19
|
/**
|
|
49
20
|
* Design width for responsive scaling (default: 375)
|
|
@@ -208,32 +179,82 @@ interface PostCSSPlugin {
|
|
|
208
179
|
}
|
|
209
180
|
declare function rpx2pxPlugin(options?: Rpx2pxPluginOptions): PostCSSPlugin;
|
|
210
181
|
|
|
182
|
+
/**
|
|
183
|
+
* Vite plugin: JSX Source Tagger
|
|
184
|
+
* Intercepts react/jsx-dev-runtime to add source information to DOM elements
|
|
185
|
+
* Only enabled in development mode
|
|
186
|
+
*/
|
|
187
|
+
declare function jsxSourceTaggerPlugin(): Plugin;
|
|
188
|
+
|
|
189
|
+
/**
|
|
190
|
+
* Vite plugin: Tailwind Config Sync
|
|
191
|
+
* Simplified version - just return raw config without resolveConfig
|
|
192
|
+
*/
|
|
193
|
+
declare function tailwindConfigSyncPlugin(options?: {
|
|
194
|
+
configPath?: string;
|
|
195
|
+
}): Plugin;
|
|
196
|
+
|
|
211
197
|
interface DevToolsOptions {
|
|
198
|
+
/**
|
|
199
|
+
* 是否为 Taro 项目
|
|
200
|
+
* - true: 启用 Taro 相关插件(taroStyleAdapterPlugin、rpx2pxPlugin)
|
|
201
|
+
* - false: 禁用 Taro 相关插件
|
|
202
|
+
* - undefined: 自动检测(通过 process.env.TARO_ENV 判断,默认为 false)
|
|
203
|
+
*/
|
|
204
|
+
isTaro?: boolean;
|
|
212
205
|
/**
|
|
213
206
|
* Taro style adapter options
|
|
214
207
|
* Controls H5 responsive scaling to match mini-program rpx behavior
|
|
208
|
+
* 仅在 isTaro 为 true 时生效
|
|
215
209
|
*/
|
|
216
210
|
styleAdapter?: TaroStyleAdapterOptions;
|
|
211
|
+
/**
|
|
212
|
+
* 是否启用 JSX Source Tagger(通过 Symbol 标记元素源码位置)
|
|
213
|
+
* 默认:开发模式启用
|
|
214
|
+
*/
|
|
215
|
+
jsxSourceTagger?: boolean;
|
|
216
|
+
/**
|
|
217
|
+
* 是否启用 Tailwind Config 同步(生成 JSON 文件)
|
|
218
|
+
* 默认:开发模式启用
|
|
219
|
+
*/
|
|
220
|
+
tailwindConfigSync?: boolean;
|
|
221
|
+
/**
|
|
222
|
+
* Tailwind 配置文件路径
|
|
223
|
+
* 默认:./tailwind.config.ts
|
|
224
|
+
*/
|
|
225
|
+
tailwindConfigPath?: string;
|
|
217
226
|
}
|
|
218
227
|
/**
|
|
219
228
|
* 开发工具插件集合,简化调用,vite.config.ts 直接 devTools() 即可
|
|
229
|
+
*
|
|
220
230
|
* @param options 配置项
|
|
231
|
+
* @param options.isTaro 是否为 Taro 项目(默认根据 TARO_ENV 自动判断)
|
|
221
232
|
* @param options.styleAdapter Taro H5 样式适配配置,designWidth 应与 Taro config 一致
|
|
222
233
|
* @returns Plugin[] Vite 插件数组
|
|
223
234
|
*
|
|
224
235
|
* @example
|
|
225
236
|
* ```ts
|
|
226
|
-
* // config/dev.ts
|
|
237
|
+
* // Taro 项目 - config/dev.ts
|
|
227
238
|
* import devTools from "@amaster.ai/vite-plugins";
|
|
228
239
|
*
|
|
229
240
|
* export default {
|
|
230
241
|
* compiler: {
|
|
231
242
|
* type: 'vite',
|
|
232
|
-
* vitePlugins: [devTools()]
|
|
243
|
+
* vitePlugins: [devTools({ isTaro: true })]
|
|
233
244
|
* }
|
|
234
245
|
* }
|
|
235
246
|
* ```
|
|
247
|
+
*
|
|
248
|
+
* @example
|
|
249
|
+
* ```ts
|
|
250
|
+
* // React 项目 - vite.config.ts
|
|
251
|
+
* import devTools from "@amaster.ai/vite-plugins";
|
|
252
|
+
*
|
|
253
|
+
* export default {
|
|
254
|
+
* plugins: [devTools()] // isTaro 默认为 false
|
|
255
|
+
* }
|
|
256
|
+
* ```
|
|
236
257
|
*/
|
|
237
258
|
declare function devTools(options?: DevToolsOptions): Plugin[];
|
|
238
259
|
|
|
239
|
-
export { type DevToolsOptions, type Rpx2pxPluginOptions, type TaroStyleAdapterOptions,
|
|
260
|
+
export { type DevToolsOptions, type Rpx2pxPluginOptions, type TaroStyleAdapterOptions, devTools as default, editorBridgePlugin, injectAmasterEnv, injectTaroEnv, jsxSourceTaggerPlugin, routesExposePlugin, rpx2pxPlugin, tailwindConfigSyncPlugin, taroStyleAdapterPlugin };
|