directix 1.8.0 → 1.10.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/README.md CHANGED
@@ -21,6 +21,227 @@ A comprehensive, easy-to-use, and high-performance Vue custom directives library
21
21
  - ⚡ **Zero Dependencies** - Lightweight with minimal bundle size
22
22
  - 🎨 **Composables** - Every directive has a corresponding composable for Composition API
23
23
  - 🔧 **Utility Exports** - Export `configurePermission`, `getPermissionConfig` and other utilities for advanced usage
24
+ - 🌐 **i18n Support** - Built-in internationalization with Chinese, English, and Japanese translations
25
+ - 🔌 **Plugin System** - Extensible plugin architecture for community contributions
26
+
27
+ ## What's New in v1.10.0
28
+
29
+ ### Vue 3 Optimization Preview
30
+
31
+ Vue 3-specific optimizations leveraging the reactive system for better performance.
32
+
33
+ ```typescript
34
+ import { useLazyOptimized, useSuspenseDirective, teleportContent } from 'directix'
35
+
36
+ // Optimized lazy loading with shallowRef
37
+ const { state, observe } = useLazyOptimized({
38
+ onLoad: (entry) => console.log('Visible!')
39
+ })
40
+
41
+ // Suspense-ready async directive
42
+ const { state, load } = useSuspenseDirective({
43
+ loader: () => fetchData()
44
+ })
45
+
46
+ // Teleport content to target
47
+ teleportContent(element, { to: '#modal-container' })
48
+ ```
49
+
50
+ ### Mobile Optimization
51
+
52
+ Enhanced touch gestures with haptic feedback and PWA support.
53
+
54
+ ```typescript
55
+ import { useEnhancedTouch, triggerHaptic, usePWA } from 'directix'
56
+
57
+ // 12+ gesture types with haptic feedback
58
+ const { activeGesture, bind } = useEnhancedTouch({
59
+ feedback: { haptic: true, visual: true },
60
+ onSwipe: (e) => console.log(`Swiped ${e.direction}`),
61
+ onPinch: (e) => console.log(`Scale: ${e.scale}`),
62
+ })
63
+
64
+ // PWA support
65
+ const { isOnline, needsUpdate } = usePWA({ serviceWorker: { enabled: true } })
66
+ ```
67
+
68
+ ### Accessibility (A11y)
69
+
70
+ Comprehensive ARIA support, screen reader announcements, and keyboard navigation.
71
+
72
+ ```typescript
73
+ import {
74
+ applyAriaAttributes,
75
+ announce,
76
+ useKeyboardNavigation,
77
+ useFocusTrap
78
+ } from 'directix'
79
+
80
+ // Apply ARIA attributes
81
+ applyAriaAttributes(element, {
82
+ role: 'button',
83
+ ariaLabel: 'Submit',
84
+ ariaDisabled: true,
85
+ })
86
+
87
+ // Screen reader announcements
88
+ announce('Form submitted successfully')
89
+
90
+ // Keyboard navigation with focus trap
91
+ const { bind } = useKeyboardNavigation({ focusTrap: true, rovingTabindex: true })
92
+ ```
93
+
94
+ ### Security Enhancement
95
+
96
+ Advanced XSS protection, CSP compatibility, and security audit tools.
97
+
98
+ ```typescript
99
+ import { sanitizeHtml, SecurityAudit, getCSPNonce } from 'directix'
100
+
101
+ // Advanced HTML sanitization
102
+ const clean = sanitizeHtml(userInput, {
103
+ allowedTags: ['b', 'i', 'p'],
104
+ detectDangerousPatterns: true,
105
+ })
106
+
107
+ // Security audit
108
+ const report = SecurityAudit.generateReport(htmlContent)
109
+ console.log(SecurityAudit.formatReport(report, 'json'))
110
+
111
+ // Check dependencies for vulnerabilities
112
+ const vulns = await SecurityAudit.checkDependencies()
113
+ ```
114
+
115
+ ## What's New in v1.9.0
116
+
117
+ ### Internationalization (i18n)
118
+
119
+ Full i18n support for directive messages and documentation.
120
+
121
+ ```typescript
122
+ import { createI18n, setLocale } from 'directix'
123
+
124
+ // Initialize with locale
125
+ createI18n({
126
+ locale: 'en-US',
127
+ fallbackLocale: 'en-US',
128
+ messages: { 'en-US': enUS, 'zh-CN': zhCN, 'ja-JP': jaJP }
129
+ })
130
+
131
+ // Switch locale at runtime
132
+ setLocale('zh-CN')
133
+ ```
134
+
135
+ ### Unified Warning System
136
+
137
+ Improved developer experience with structured error messages.
138
+
139
+ ```typescript
140
+ import { warn, directiveWarn, assertType } from 'directix'
141
+
142
+ // Directive-specific warnings
143
+ directiveWarn('debounce', 'errors.invalid_wait', { wait: 'abc' })
144
+
145
+ // Type assertions
146
+ assertType<number>(value, 'number', 'debounce', 'wait')
147
+ ```
148
+
149
+ ### Plugin System
150
+
151
+ Extensible plugin architecture for community contributions.
152
+
153
+ ```typescript
154
+ import { definePlugin, getPluginManager } from 'directix'
155
+
156
+ const myPlugin = definePlugin({
157
+ meta: { name: 'my-plugin', version: '1.0.0' },
158
+ install(ctx) {
159
+ ctx.registerDirective('my-directive', vMyDirective)
160
+ }
161
+ })
162
+
163
+ getPluginManager().register(myPlugin)
164
+ ```
165
+
166
+ ### Community Plugin Registry
167
+
168
+ Discover and install community plugins programmatically.
169
+
170
+ ```typescript
171
+ import { getPluginRegistry } from 'directix'
172
+
173
+ const registry = getPluginRegistry()
174
+
175
+ // Search plugins
176
+ const results = await registry.search('animation')
177
+
178
+ // Get all plugins
179
+ const plugins = await registry.getAll()
180
+
181
+ // Install a plugin
182
+ await registry.install('directix-animate', manager)
183
+ ```
184
+
185
+ ### Timezone & Locale Utilities
186
+
187
+ Region-specific formatting for dates, numbers, and currencies.
188
+
189
+ ```typescript
190
+ import { getTimezoneInfo, formatDateLocale, formatCurrencyLocale } from 'directix'
191
+
192
+ // Get timezone info
193
+ const tz = getTimezoneInfo() // { id: 'Asia/Shanghai', offset: 8, ... }
194
+
195
+ // Format date by locale
196
+ formatDateLocale(new Date()) // Auto-detects user locale
197
+
198
+ // Format currency
199
+ formatCurrencyLocale(99.99) // '$99.99' (US) or '99,99€' (DE)
200
+ ```
201
+
202
+ ### Vue DevTools Integration
203
+
204
+ Debug directives directly in Vue DevTools.
205
+
206
+ ```typescript
207
+ import { enableDevtools, trackDirective } from 'directix'
208
+
209
+ // Enable DevTools integration
210
+ enableDevtools()
211
+
212
+ // Track directive usage
213
+ trackDirective('debounce', { element: 'input' })
214
+ ```
215
+
216
+ ### Performance Monitoring
217
+
218
+ Measure directive performance with detailed metrics.
219
+
220
+ ```typescript
221
+ import { enablePerformance, getPerformanceReport } from 'directix'
222
+
223
+ // Enable monitoring
224
+ enablePerformance()
225
+
226
+ // Get performance report
227
+ const report = getPerformanceReport()
228
+ // [{ name: 'debounce', mount: { p50: 0.5ms, p95: 1.2ms }, ... }]
229
+ ```
230
+
231
+ ### Scenario Examples
232
+
233
+ 10+ real-world examples demonstrating directive combinations:
234
+
235
+ - **Form Validation** - v-debounce, v-mask, v-trim, v-focus
236
+ - **Permission Management** - v-permission, v-click-outside
237
+ - **Image Gallery** - v-lazy, v-image-preview, v-swipe
238
+ - **Infinite Scroll** - v-infinite-scroll, v-virtual-list, v-loading
239
+ - **Rich Text Editor** - v-sanitize, v-highlight, v-emoji
240
+ - **Gesture Interaction** - v-touch, v-swipe, v-pan, v-pinch
241
+ - **Data Visualization** - v-progress, v-counter, v-countdown
242
+ - **Drag & Sort** - v-draggable, v-intersect
243
+ - **Print & Export** - v-print, v-export
244
+ - **Fullscreen Media** - v-fullscreen, v-lottie
24
245
 
25
246
  ## Online Demo
26
247