dphelper 3.3.4 → 3.3.6

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,7 +31,7 @@
31
31
 
32
32
  ## About
33
33
 
34
- **dphelper** is a powerful, zero-dependency utility library that brings together 45+ production-ready tools for web developers, AI engineers, and DevTools creators.
34
+ **dphelper** is a powerful, zero-dependency utility library that brings together **53 production-ready tools** for web developers, AI engineers, and DevTools creators.
35
35
 
36
36
  Think of it as your **universal toolbox** - from DOM manipulation to cryptographic operations, from real-time WebSocket handling to AI-powered token optimization. No more juggling multiple packages. One import, infinite possibilities.
37
37
 
@@ -41,7 +41,7 @@ Think of it as your **universal toolbox** - from DOM manipulation to cryptograph
41
41
  - **🤖 AI-First Design** - Built for LLM apps with TOON optimization, token counting, and RAG support.
42
42
  - **🌐 Universal** - Works in browser, Node.js, Bun, and Deno.
43
43
  - **🔒 Type-Safe** - Full TypeScript definitions auto-generated for every tool.
44
- - **📦 Tiny Bundle** - Only ~136KB minified, tree-shakeable.
44
+ - **📦 Tiny Bundle** - Only ~171KB minified, tree-shakeable.
45
45
 
46
46
  > *"dphelper is what you'd build if you combined lodash, socket.io, and an AI SDK - but lighter."*
47
47
 
@@ -57,21 +57,158 @@ Think of it as your **universal toolbox** - from DOM manipulation to cryptograph
57
57
 
58
58
  ---
59
59
 
60
- ## 🚀 Version 3.0: The AI Leap
60
+ ## 🚀 Version 3.3: New Powerful Modules
61
61
 
62
- `dphelper` has evolved into a powerhouse for AI-driven applications. We've removed legacy dependencies (bye-bye jQuery!) and shifted focus to **performance**, **modularity**, and **LLM optimization**.
62
+ `dphelper` has expanded with powerful new modules for modern web development:
63
63
 
64
64
  ### ✨ Highlights
65
65
 
66
- - **🤖 Advanced AI Module**: Built-in support for RAG, token counting, and prompt engineering.
67
- - **🚀 AI Black Box (Snapshot)**: The first "Flight Recorder" for apps, capturing the internal state in TOON for instant AI debugging.
68
- - **🎒 TOON Integration**: Native support for **Token-Oriented Object Notation** (3.0), reducing LLM context usage by up to 50%.
69
- - **🛠️ Zero Dependencies**: Pure vanilla JavaScript/TypeScript architecture.
70
- - **🌐 Fetch & SSE Pro**: High-level networking with automatic retries and custom headers.
71
- - **⚡ Bulletproof Dispatcher**: Integrated listener management with automatic cleanup.
72
- - **🔄 UI Mirror & Pulse**: Cross-tab synchronization and automatic UI state recovery (Zero-Code Persistence).
73
- - **🌊 SSE Pro**: Server-Sent Events with POST & Custom Header support (modern AI streaming ready).
74
- - **🧬 Modular Types**: Auto-generated Type definitions for all 200+ tools.
66
+ - **💾 IndexedDB Module**: Full-featured wrapper for IndexedDB with query builder, transactions, and bulk operations.
67
+ - **⚙️ Web Worker Module**: Create and manage workers, worker pools for parallel processing, and SharedWorkers for cross-tab communication.
68
+ - **🌍 i18n Module**: Complete internationalization with translations, pluralization, date/number formatting, and relative time.
69
+ - **🖼️ Image Module**: Image processing including resize, crop, filters, rotation, flip, and compositing.
70
+ - **🗜️ Compression Module**: Gzip, deflate, LZW compression, plus base64, URL, and HTML encoding/decoding.
71
+ - **🔐 Biometric Module**: WebAuthn support for fingerprint, face recognition, and secure credential management.
72
+
73
+ ---
74
+
75
+ ## 💾 IndexedDB Module
76
+
77
+ ```javascript
78
+ // Open/create database
79
+ const db = await dphelper.idb.open('mydb', 1, { users: 'id++,name,email' });
80
+
81
+ // Add record
82
+ await dphelper.idb.put('mydb', 'users', { name: 'John', email: 'john@example.com' });
83
+
84
+ // Query records
85
+ const users = await dphelper.idb.getAll('mydb', 'users');
86
+
87
+ // Query by index
88
+ const johns = await dphelper.idb.query('mydb', 'users', 'name', 'John');
89
+
90
+ // Bulk operations
91
+ await dphelper.idb.bulkPut('mydb', 'users', [{name: 'A'}, {name: 'B'}]);
92
+ ```
93
+
94
+ ---
95
+
96
+ ## ⚙️ Web Worker Module
97
+
98
+ ```javascript
99
+ // Create worker from file
100
+ const worker = dphelper.worker.create('worker.js', {
101
+ onmessage: (e) => console.log(e.data)
102
+ });
103
+
104
+ // Create inline worker
105
+ const inlineWorker = dphelper.worker.createInline(`
106
+ self.onmessage = e => postMessage(e.data * 2);
107
+ `);
108
+
109
+ // Worker pool for parallel processing
110
+ const pool = dphelper.worker.pool('worker.js', 4);
111
+ const results = await dphelper.worker.poolExec(pool, [1, 2, 3, 4]);
112
+
113
+ // SharedWorker for cross-tab communication
114
+ const shared = dphelper.worker.shared('worker.js', { name: 'my-shared' });
115
+ ```
116
+
117
+ ---
118
+
119
+ ## 🌍 i18n Module
120
+
121
+ ```javascript
122
+ // Set locale
123
+ dphelper.i18n.setLocale('it');
124
+
125
+ // Add translations
126
+ dphelper.i18n.addTranslations('it', {
127
+ hello: 'Ciao {name}!',
128
+ items: '{count, plural, one{# item} other{# items}}'
129
+ });
130
+
131
+ // Translate with interpolation
132
+ dphelper.i18n.t('hello', { name: 'World' }); // "Ciao World!"
133
+
134
+ // Pluralize
135
+ dphelper.i18n.pluralize(5, { one: 'item', other: 'items' }); // "items"
136
+
137
+ // Format number/currency
138
+ dphelper.i18n.number(1234.56, 'de-DE', { style: 'currency', currency: 'EUR' });
139
+
140
+ // Relative time
141
+ dphelper.i18n.relativeTime(Date.now() - 3600000); // "1 hour ago"
142
+ ```
143
+
144
+ ---
145
+
146
+ ## 🖼️ Image Module
147
+
148
+ ```javascript
149
+ // Load image
150
+ const img = await dphelper.image.load('photo.jpg');
151
+
152
+ // Resize
153
+ const resized = dphelper.image.resize(img, 100, 100);
154
+
155
+ // Crop
156
+ const cropped = dphelper.image.crop(img, { x: 0, y: 0, width: 50, height: 50 });
157
+
158
+ // Apply filters
159
+ const filtered = dphelper.image.filter(img, { brightness: 1.2, sepia: 0.5 });
160
+
161
+ // Rotate/Flip
162
+ const rotated = dphelper.image.rotate(img, 90);
163
+ const flipped = dphelper.image.flip(img, 'horizontal');
164
+
165
+ // Grayscale/Blur
166
+ const gray = dphelper.image.grayscale(img);
167
+ const blurred = dphelper.image.blur(img, 5);
168
+ ```
169
+
170
+ ---
171
+
172
+ ## 🗜️ Compression Module
173
+
174
+ ```javascript
175
+ // Gzip compression
176
+ const compressed = await dphelper.compress.gzip('Hello World');
177
+ const decompressed = await dphelper.compress.gunzip(compressed);
178
+
179
+ // Base64 encoding
180
+ const encoded = dphelper.compress.base64Encode('Hello');
181
+ const decoded = dphelper.compress.base64Decode(encoded);
182
+
183
+ // URL encoding
184
+ const urlEncoded = dphelper.compress.urlEncode('Hello World!');
185
+ const urlDecoded = dphelper.compress.urlDecode(urlEncoded);
186
+
187
+ // HTML encoding
188
+ const htmlEncoded = dphelper.compress.htmlEncode('<script>');
189
+ const htmlDecoded = dphelper.compress.htmlDecode('&lt;script&gt;');
190
+ ```
191
+
192
+ ---
193
+
194
+ ## 🔐 Biometric Module (WebAuthn)
195
+
196
+ ```javascript
197
+ // Check availability
198
+ const available = dphelper.biometric.isAvailable();
199
+
200
+ // Get support details
201
+ const support = dphelper.biometric.getWebAuthnSupport();
202
+
203
+ // Register credential
204
+ const { success, credentialId } = await dphelper.biometric.register('user123');
205
+
206
+ // Authenticate
207
+ const { success } = await dphelper.biometric.authenticate('user123');
208
+
209
+ // Check specific sensor
210
+ const hasFingerprint = await dphelper.biometric.isSensorAvailable('fingerprint');
211
+ ```
75
212
 
76
213
  ---
77
214