@amaster.ai/vite-plugins 1.0.0-beta.4 → 1.0.0-beta.41
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 +153 -0
- package/dist/bridge.bridge.js +1 -24
- package/dist/index.cjs +516 -7
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +238 -4
- package/dist/index.d.ts +238 -4
- package/dist/index.js +516 -7
- package/dist/index.js.map +1 -1
- package/package.json +22 -6
package/README.md
CHANGED
|
@@ -1 +1,154 @@
|
|
|
1
1
|
# @amaster.ai/vite-plugins
|
|
2
|
+
|
|
3
|
+
Vite plugins collection for Amaster.ai projects, including Taro development tools.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
pnpm add @amaster.ai/vite-plugins
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Plugins
|
|
12
|
+
|
|
13
|
+
### 1. taroStyleAdapterPlugin
|
|
14
|
+
|
|
15
|
+
Automatically injects Taro page style adaptations in development mode to hide scrollbars while maintaining scroll functionality.
|
|
16
|
+
|
|
17
|
+
**Features:**
|
|
18
|
+
- Direct style injection into HTML (no postMessage needed)
|
|
19
|
+
- Only active in development mode (`serve`)
|
|
20
|
+
- Hides Taro page container scrollbar while maintaining scroll functionality
|
|
21
|
+
- **Automatically included in `devTools()`** - no separate import needed
|
|
22
|
+
|
|
23
|
+
**Usage:**
|
|
24
|
+
|
|
25
|
+
Already included when you use `devTools()`:
|
|
26
|
+
|
|
27
|
+
```typescript
|
|
28
|
+
import devTools from '@amaster.ai/vite-plugins'
|
|
29
|
+
|
|
30
|
+
export default {
|
|
31
|
+
compiler: {
|
|
32
|
+
type: 'vite',
|
|
33
|
+
vitePlugins: [
|
|
34
|
+
...devTools() // ✅ taroStyleAdapterPlugin is already included
|
|
35
|
+
]
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
Or use it standalone if needed:
|
|
41
|
+
|
|
42
|
+
```typescript
|
|
43
|
+
import { taroStyleAdapterPlugin } from '@amaster.ai/vite-plugins'
|
|
44
|
+
|
|
45
|
+
export default {
|
|
46
|
+
compiler: {
|
|
47
|
+
type: 'vite',
|
|
48
|
+
vitePlugins: [
|
|
49
|
+
taroStyleAdapterPlugin()
|
|
50
|
+
]
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
**How it works:**
|
|
56
|
+
|
|
57
|
+
The plugin uses Vite's `transformIndexHtml` hook to inject styles directly into the HTML `<head>`:
|
|
58
|
+
|
|
59
|
+
```html
|
|
60
|
+
<style data-taro-adapter="true">
|
|
61
|
+
/* 隐藏 Taro 页面容器滚动条 */
|
|
62
|
+
.taro_page {
|
|
63
|
+
-ms-overflow-style: none;
|
|
64
|
+
scrollbar-width: none;
|
|
65
|
+
}
|
|
66
|
+
.taro_page::-webkit-scrollbar {
|
|
67
|
+
width: 0;
|
|
68
|
+
height: 0;
|
|
69
|
+
display: none;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/* 隐藏 Taro ScrollView 组件滚动条 */
|
|
73
|
+
.taro-scroll-view__scroll-y,
|
|
74
|
+
.taro-scroll-view__scroll-x {
|
|
75
|
+
-ms-overflow-style: none;
|
|
76
|
+
scrollbar-width: none;
|
|
77
|
+
}
|
|
78
|
+
.taro-scroll-view__scroll-y::-webkit-scrollbar,
|
|
79
|
+
.taro-scroll-view__scroll-x::-webkit-scrollbar {
|
|
80
|
+
width: 0;
|
|
81
|
+
height: 0;
|
|
82
|
+
display: none;
|
|
83
|
+
}
|
|
84
|
+
</style>
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
This approach is simpler and more reliable than message-based communication.
|
|
88
|
+
|
|
89
|
+
### 2. injectTaroEnv / injectAmasterEnv
|
|
90
|
+
|
|
91
|
+
Environment variable injection helpers for Taro's `defineConstants`.
|
|
92
|
+
|
|
93
|
+
**Usage:**
|
|
94
|
+
|
|
95
|
+
```typescript
|
|
96
|
+
import { injectAmasterEnv, injectTaroEnv } from '@amaster.ai/vite-plugins'
|
|
97
|
+
|
|
98
|
+
export default defineConfig({
|
|
99
|
+
defineConstants: {
|
|
100
|
+
...injectAmasterEnv(),
|
|
101
|
+
// or
|
|
102
|
+
...injectTaroEnv({
|
|
103
|
+
additional: ['CUSTOM_VAR'],
|
|
104
|
+
autoInjectTaroApp: true,
|
|
105
|
+
autoInjectVite: true
|
|
106
|
+
})
|
|
107
|
+
}
|
|
108
|
+
})
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
### 3. componentIdPlugin
|
|
112
|
+
|
|
113
|
+
Adds unique IDs to components for development tools tracking.
|
|
114
|
+
|
|
115
|
+
### 4. editorBridgePlugin
|
|
116
|
+
|
|
117
|
+
Enables communication bridge between Taro app and editor.
|
|
118
|
+
|
|
119
|
+
### 5. routesExposePlugin
|
|
120
|
+
|
|
121
|
+
Exposes route information for editor integration.
|
|
122
|
+
|
|
123
|
+
### 6. browserLogsPlugin
|
|
124
|
+
|
|
125
|
+
Captures and forwards browser console logs (auto-enabled in sandbox environment).
|
|
126
|
+
|
|
127
|
+
## Development Tools Collection
|
|
128
|
+
|
|
129
|
+
Use `devTools()` to quickly enable all development plugins:
|
|
130
|
+
|
|
131
|
+
```typescript
|
|
132
|
+
import devTools from '@amaster.ai/vite-plugins'
|
|
133
|
+
|
|
134
|
+
export default defineConfig({
|
|
135
|
+
compiler: {
|
|
136
|
+
type: 'vite',
|
|
137
|
+
vitePlugins: [
|
|
138
|
+
...devTools(),
|
|
139
|
+
// ... other plugins
|
|
140
|
+
]
|
|
141
|
+
}
|
|
142
|
+
})
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
This includes:
|
|
146
|
+
- **taroStyleAdapterPlugin** - Taro H5 scrollbar hiding
|
|
147
|
+
- **componentIdPlugin** - Component ID tracking
|
|
148
|
+
- **editorBridgePlugin** - Editor communication
|
|
149
|
+
- **routesExposePlugin** - Route information exposure
|
|
150
|
+
- **browserLogsPlugin** - Browser console forwarding (when in sandbox)
|
|
151
|
+
|
|
152
|
+
## License
|
|
153
|
+
|
|
154
|
+
MIT
|