dphelper 3.5.5 → 3.7.2

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.
Files changed (63) hide show
  1. package/README.md +0 -21
  2. package/docs/README.md +385 -0
  3. package/docs/SUMMARY.md +83 -0
  4. package/docs/_config.yml +1 -0
  5. package/docs/markdown/ai.md +345 -0
  6. package/docs/markdown/anchor.md +156 -0
  7. package/docs/markdown/array.md +208 -0
  8. package/docs/markdown/audio.md +113 -0
  9. package/docs/markdown/avoid.md +53 -0
  10. package/docs/markdown/biometric.md +338 -0
  11. package/docs/markdown/browser.md +203 -0
  12. package/docs/markdown/check.md +65 -0
  13. package/docs/markdown/color.md +159 -0
  14. package/docs/markdown/compress.md +310 -0
  15. package/docs/markdown/cookie.md +115 -0
  16. package/docs/markdown/coords.md +127 -0
  17. package/docs/markdown/credits.md +56 -0
  18. package/docs/markdown/date.md +260 -0
  19. package/docs/markdown/disable.md +109 -0
  20. package/docs/markdown/dispatch.md +108 -0
  21. package/docs/markdown/element.md +53 -0
  22. package/docs/markdown/event.md +85 -0
  23. package/docs/markdown/fetch.md +122 -0
  24. package/docs/markdown/form.md +302 -0
  25. package/docs/markdown/format.md +122 -0
  26. package/docs/markdown/i18n.md +292 -0
  27. package/docs/markdown/image.md +298 -0
  28. package/docs/markdown/json.md +269 -0
  29. package/docs/markdown/load.md +133 -0
  30. package/docs/markdown/logging.md +99 -0
  31. package/docs/markdown/math.md +172 -0
  32. package/docs/markdown/memory.md +85 -0
  33. package/docs/markdown/navigation.md +152 -0
  34. package/docs/markdown/net.md +60 -0
  35. package/docs/markdown/obj.md +242 -0
  36. package/docs/markdown/path.md +46 -0
  37. package/docs/markdown/promise.md +94 -0
  38. package/docs/markdown/sanitize.md +118 -0
  39. package/docs/markdown/screen.md +78 -0
  40. package/docs/markdown/scrollbar.md +82 -0
  41. package/docs/markdown/security.md +289 -0
  42. package/docs/markdown/shortcut.md +100 -0
  43. package/docs/markdown/socket.md +134 -0
  44. package/docs/markdown/sse.md +120 -0
  45. package/docs/markdown/svg.md +167 -0
  46. package/docs/markdown/sync.md +147 -0
  47. package/docs/markdown/system.md +78 -0
  48. package/docs/markdown/terminal.md +73 -0
  49. package/docs/markdown/text.md +245 -0
  50. package/docs/markdown/timer.md +98 -0
  51. package/docs/markdown/tools.md +111 -0
  52. package/docs/markdown/translators.md +65 -0
  53. package/docs/markdown/trigger.md +99 -0
  54. package/docs/markdown/triggers.md +133 -0
  55. package/docs/markdown/type.md +109 -0
  56. package/docs/markdown/types.md +102 -0
  57. package/docs/markdown/ui.md +45 -0
  58. package/docs/markdown/window.md +211 -0
  59. package/docs/markdown/worker.md +223 -0
  60. package/index.cjs +1 -1
  61. package/index.js +1 -1
  62. package/package.json +4 -6
  63. package/types/dphelper.d.ts +0 -15
package/README.md CHANGED
@@ -76,27 +76,6 @@ If you need to use state management please consider:
76
76
 
77
77
  ---
78
78
 
79
- ## 💾 IndexedDB Module
80
-
81
- ```javascript
82
- // Open/create database
83
- const db = await dphelper.idb.open('mydb', 1, { users: 'id++,name,email' });
84
-
85
- // Add record
86
- await dphelper.idb.put('mydb', 'users', { name: 'John', email: 'john@example.com' });
87
-
88
- // Query records
89
- const users = await dphelper.idb.getAll('mydb', 'users');
90
-
91
- // Query by index
92
- const johns = await dphelper.idb.query('mydb', 'users', 'name', 'John');
93
-
94
- // Bulk operations
95
- await dphelper.idb.bulkPut('mydb', 'users', [{name: 'A'}, {name: 'B'}]);
96
- ```
97
-
98
- ---
99
-
100
79
  ## ⚙️ Web Worker Module
101
80
 
102
81
  ```javascript
package/docs/README.md ADDED
@@ -0,0 +1,385 @@
1
+ # [dphelper](https://npmjs.com/package/dphelper)
2
+
3
+ ![dpHelper](https://raw.githubusercontent.com/passariello/container/refs/heads/main/dphelper/assets/images/banner.svg)
4
+
5
+ > **The supercharged toolkit for modern web development, AI engineering & DevTools.**
6
+
7
+ [![version](https://img.shields.io/npm/v/dphelper.svg)](https://npmjs.org/package/dphelper)
8
+ [![install size](https://img.shields.io/badge/dynamic/json?url=https://packagephobia.com/v2/api.json?p=dphelper&query=$.install.pretty&label=install%20size&style=flat-square)](https://packagephobia.now.sh/result?p=dphelper)
9
+ [![downloads](https://img.shields.io/npm/dm/dphelper.svg)](https://npmjs.org/package/dphelper)
10
+
11
+ ![Node.js](https://img.shields.io/badge/Node.js-gray?logo=node.js)
12
+ ![React](https://img.shields.io/badge/React-gray?logo=React)
13
+ ![Javascript](https://img.shields.io/badge/Javascript-gray?logo=Javascript)
14
+ ![TypeScript](https://img.shields.io/badge/TypeScript-gray?logo=typescript)
15
+ ![esbuild](https://img.shields.io/badge/esbuild-gray?logo=esbuild)
16
+
17
+ ![Jest](https://img.shields.io/badge/Jest-gray?logo=jest)
18
+ ![ESLint](https://img.shields.io/badge/Eslint-gray?logo=eslint)
19
+ ![Playwright](https://img.shields.io/badge/Playwright-gray?logo=playwright)
20
+ ![AI Ready](https://img.shields.io/badge/AI-Ready-brightgreen?logo=openai)
21
+ ![TOON](https://img.shields.io/badge/TOON-Format-blue)
22
+
23
+ [![GitBook](https://img.shields.io/static/v1?message=Documented%20on%20GitBook&logo=gitbook&logoColor=ffffff&label=%20&labelColor=5c5c5c&color=3F89A1)](https://a51.gitbook.io/dphelper)
24
+
25
+
26
+ ---
27
+
28
+ ## About
29
+
30
+ **dphelper** is a powerful, zero-dependency utility library that brings together **303 production-ready tools** for web developers, AI engineers, and DevTools creators.
31
+
32
+ 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.
33
+
34
+ ### Why dphelper?
35
+
36
+ - **⚡ Zero Dependencies** - Pure vanilla JavaScript/TypeScript. No bloat, no surprises.
37
+ - **🤖 AI-First Design** - Built for LLM apps with TOON optimization, token counting, and RAG support.
38
+ - **🌐 Universal** - Works in browser, Node.js, Bun, and Deno.
39
+ - **🔒 Type-Safe** - Full TypeScript definitions auto-generated for every tool.
40
+ - **📦 Tiny Bundle** - Only ~171KB minified, tree-shakeable.
41
+ - **🔐 Security First** - NIST/NSA compliant, CNSA algorithms, PBKDF2 310k iterations
42
+
43
+ > [!NOTE]
44
+ > **Network Access:** This library includes networking primitives (`fetch`, `sse`, `socket`) by design for modern web development. Callers are responsible for validating and sanitizing URLs before use. See the [Security](#security) section for best practices.
45
+
46
+ > *"dphelper is what you'd build if you combined lodash, socket.io, and an AI SDK - but lighter."*
47
+
48
+ ---
49
+
50
+ ## State and Store removed from dpHelper
51
+
52
+ > [!IMPORTANT]
53
+ > dpHelper do not integrate state management directly anymore
54
+ >
55
+ > Application state is currently handled through **Memorio** or **RGS**.
56
+
57
+ If you need to use state management please consider:
58
+
59
+ - Simple State and Store Manager [Memorio](http://www.npmjs.com/package/memorio)
60
+ - Enterprise Lever State Manager [Argis RGS](https://www.npmjs.com/package/@biglogic/rgs)
61
+
62
+ ---
63
+
64
+ ## 🚀 New Powerful Modules
65
+
66
+ `dphelper` has expanded with powerful new modules for modern web development:
67
+
68
+ ### ✨ Highlights
69
+
70
+ - **💾 IndexedDB Module**: Full-featured wrapper for IndexedDB with query builder, transactions, and bulk operations.
71
+ - **⚙️ Web Worker Module**: Create and manage workers, worker pools for parallel processing, and SharedWorkers for cross-tab communication.
72
+ - **🌍 i18n Module**: Complete internationalization with translations, pluralization, date/number formatting, and relative time.
73
+ - **🖼️ Image Module**: Image processing including resize, crop, filters, rotation, flip, and compositing.
74
+ - **🗜️ Compression Module**: Gzip, deflate, LZW compression, plus base64, URL, and HTML encoding/decoding.
75
+ - **🔐 Biometric Module**: WebAuthn support for fingerprint, face recognition, and secure credential management.
76
+
77
+ ---
78
+
79
+ ## ⚙️ Web Worker Module
80
+
81
+ ```javascript
82
+ // Create worker from file
83
+ const worker = dphelper.worker.create('worker.js', {
84
+ onmessage: (e) => console.log(e.data)
85
+ });
86
+
87
+ // Create inline worker
88
+ const inlineWorker = dphelper.worker.createInline(`
89
+ self.onmessage = e => postMessage(e.data * 2);
90
+ `);
91
+
92
+ // Worker pool for parallel processing
93
+ const pool = dphelper.worker.pool('worker.js', 4);
94
+ const results = await dphelper.worker.poolExec(pool, [1, 2, 3, 4]);
95
+
96
+ // SharedWorker for cross-tab communication
97
+ const shared = dphelper.worker.shared('worker.js', { name: 'my-shared' });
98
+ ```
99
+
100
+ ---
101
+
102
+ ## 🌍 i18n Module
103
+
104
+ ```javascript
105
+ // Set locale
106
+ dphelper.i18n.setLocale('it');
107
+
108
+ // Add translations
109
+ dphelper.i18n.addTranslations('it', {
110
+ hello: 'Ciao {name}!',
111
+ items: '{count, plural, one{# item} other{# items}}'
112
+ });
113
+
114
+ // Translate with interpolation
115
+ dphelper.i18n.t('hello', { name: 'World' }); // "Ciao World!"
116
+
117
+ // Pluralize
118
+ dphelper.i18n.pluralize(5, { one: 'item', other: 'items' }); // "items"
119
+
120
+ // Format number/currency
121
+ dphelper.i18n.number(1234.56, 'de-DE', { style: 'currency', currency: 'EUR' });
122
+
123
+ // Relative time
124
+ dphelper.i18n.relativeTime(Date.now() - 3600000); // "1 hour ago"
125
+ ```
126
+
127
+ ---
128
+
129
+ ## 🖼️ Image Module
130
+
131
+ ```javascript
132
+ // Load image
133
+ const img = await dphelper.image.load('photo.jpg');
134
+
135
+ // Resize
136
+ const resized = dphelper.image.resize(img, 100, 100);
137
+
138
+ // Crop
139
+ const cropped = dphelper.image.crop(img, { x: 0, y: 0, width: 50, height: 50 });
140
+
141
+ // Apply filters
142
+ const filtered = dphelper.image.filter(img, { brightness: 1.2, sepia: 0.5 });
143
+
144
+ // Rotate/Flip
145
+ const rotated = dphelper.image.rotate(img, 90);
146
+ const flipped = dphelper.image.flip(img, 'horizontal');
147
+
148
+ // Grayscale/Blur
149
+ const gray = dphelper.image.grayscale(img);
150
+ const blurred = dphelper.image.blur(img, 5);
151
+ ```
152
+
153
+ ---
154
+
155
+ ## 🗜️ Compression Module
156
+
157
+ ```javascript
158
+ // Gzip compression
159
+ const compressed = await dphelper.compress.gzip('Hello World');
160
+ const decompressed = await dphelper.compress.gunzip(compressed);
161
+
162
+ // Base64 encoding
163
+ const encoded = dphelper.compress.base64Encode('Hello');
164
+ const decoded = dphelper.compress.base64Decode(encoded);
165
+
166
+ // URL encoding
167
+ const urlEncoded = dphelper.compress.urlEncode('Hello World!');
168
+ const urlDecoded = dphelper.compress.urlDecode(urlEncoded);
169
+
170
+ // HTML encoding
171
+ const htmlEncoded = dphelper.compress.htmlEncode('<script>');
172
+ const htmlDecoded = dphelper.compress.htmlDecode('&lt;script&gt;');
173
+ ```
174
+
175
+ ---
176
+
177
+ ## 🔐 Biometric Module (WebAuthn)
178
+
179
+ ```javascript
180
+ // Check availability
181
+ const available = dphelper.biometric.isAvailable();
182
+
183
+ // Get support details
184
+ const support = dphelper.biometric.getWebAuthnSupport();
185
+
186
+ // Register credential
187
+ const { success, credentialId } = await dphelper.biometric.register('user123');
188
+
189
+ // Authenticate
190
+ const { success } = await dphelper.biometric.authenticate('user123');
191
+
192
+ // Check specific sensor
193
+ const hasFingerprint = await dphelper.biometric.isSensorAvailable('fingerprint');
194
+ ```
195
+
196
+ ---
197
+
198
+ ## Table of Contents
199
+
200
+ 1. [About](#about)
201
+ 2. [Installation](#installation)
202
+ 3. [AI Power User Guide](#ai-power-user-guide)
203
+ 4. [Modular Architecture](#modular-architecture)
204
+ 5. [Browser Extension (Chrome/Edge)](#browser-extension-chromeedge)
205
+ 6. [Environment Compatibility](#environment-compatibility)
206
+ 7. [Security](#security)
207
+
208
+ ---
209
+
210
+ ## Installation
211
+
212
+ ```shell
213
+ npm i dphelper --save-dev
214
+ ```
215
+
216
+ ### Usage
217
+
218
+ Import it precisely **once** in your entry point (e.g., `index.js`, `main.ts`, or `App.tsx`):
219
+
220
+ ```js
221
+ import "dphelper";
222
+ // dphelper is now available globally across your entire project!
223
+ ```
224
+
225
+ For plain HTML/CDN:
226
+
227
+ ```html
228
+ <script src="https://unpkg.com/dphelper/dphelper.js"></script>
229
+
230
+ <!-- Optional check -->
231
+ <script>
232
+ console.debug(dphelper.version); // latest version
233
+ console.debud(dphelper.isBrowser); // true
234
+ </script>
235
+ ```
236
+
237
+ ---
238
+
239
+ ## AI Power User Guide
240
+
241
+ The new `dphelper.ai` module is designed for the modern AI stack (LLMs, RAG, Vector Search).
242
+
243
+ ```javascript
244
+ // ⚡ TOON: The ultimate JSON alternative for prompts
245
+ const toonData = dphelper.ai.toon(myJsonObject);
246
+ // Efficient, compact, and deterministic.
247
+
248
+ // 📏 Context-Aware Token Counting
249
+ const tokens = dphelper.ai.tokenCount(myJsonObject);
250
+ // Automatically calculates tokens based on the optimal TOON representation.
251
+
252
+ // 🧩 Smart Chunker (RAG Ready)
253
+ const chunks = dphelper.ai.chunker(longText, { size: 1000, overlap: 200 });
254
+
255
+ // 🔍 Semantic Similarity
256
+ const score = dphelper.ai.similarity(embeddingA, embeddingB);
257
+
258
+ // 🧠 Reasoning Extractor (DeepSeek/O1 support)
259
+ const { reasoning, content } = dphelper.ai.extractReasoning(rawAiReply);
260
+
261
+ // 📸 The AI Black Box (Snapshot)
262
+ const appStateToon = dphelper.ai.snapshot();
263
+ // Generates a complete app "mental dump" (URL, gState, Logs) optimized for LLMs.
264
+ ```
265
+
266
+ ---
267
+
268
+ ## Modular Architecture
269
+
270
+ Every tool in `dphelper` is now a self-contained module. Our new build system automatically:
271
+
272
+ 1. Scans the `tools/` directory.
273
+ 2. Generates dynamic imports for the core.
274
+ 3. Synchronizes TypeScript interfaces in `dphelper.d.ts`.
275
+
276
+ This ensures that adding new tools is instantaneous and always documented with full Intellisense support.
277
+
278
+ ---
279
+
280
+ ## 🔄 UI Mirror & Auto-Recovery
281
+
282
+ `dphelper` makes your web app feel like a native desktop application with cross-tab intelligence.
283
+
284
+ ```javascript
285
+ // ⚓ Auto-Recovery: Save scroll and input values across reloads/crashes
286
+ dphelper.UI.anchorContext();
287
+
288
+ // 💓 Pulse: Real-time event bus between all open tabs (No Backend needed!)
289
+ const bus = dphelper.sync.pulse('my-app', (msg) => {
290
+ console.debug('Received from another tab:', msg);
291
+ });
292
+ bus.emit({ action: 'theme-change', value: 'dark' });
293
+
294
+ // 🔒 Interlock: Monitor how many tabs of your app are active
295
+ dphelper.browser.interlock((count) => {
296
+ console.debug(`Active tabs: ${count}`);
297
+ });
298
+
299
+ // 🌊 SSE: Modern streaming (Support for POST & Headers)
300
+ const stream = dphelper.sse.open('/api/ai', {
301
+ method: 'POST',
302
+ headers: { 'Authorization': 'Bearer ...' },
303
+ body: JSON.stringify({ prompt: 'Hello AI' })
304
+ });
305
+
306
+ stream.on('message', (data) => console.debug('Chunk:', data));
307
+ stream.on('error', (err) => console.error('Stream failure:', err));
308
+ ```
309
+
310
+ ---
311
+
312
+ ## Browser Extension (Chrome/Edge)
313
+
314
+ ![dphelper Banner](https://raw.githubusercontent.com/passariello/container/refs/heads/main/dphelper/assets/images/screenshot.png)
315
+
316
+ Manage your `dphelper` environment, monitor memory usage, and access documentation directly from your browser.
317
+
318
+ - [Download for Chrome](https://chrome.google.com/webstore/detail/dphelper-manager-dev-tool/oppppldaoknfddeikfloonnialijngbk)
319
+ - [Download for Edge](https://microsoftedge.microsoft.com/addons/detail/dphelper-manager-dev-to/kphabkbdpaljlfagldhojilhfammepnk)
320
+
321
+ ---
322
+
323
+ ---
324
+
325
+ ## Environment Compatibility
326
+
327
+ `dphelper` tools are classified by their execution target to ensure stability across the stack.
328
+
329
+ | Icon | Type | Description |
330
+ | :--- | :--- | :--- |
331
+ | 🌐 | **Client** | Browser only (requires DOM, window, or navigator). |
332
+ | 🖥️ | **Server** | Node.js / Bun / Deno only (access to process, fs, etc). |
333
+ | 🧬 | **Isomorphic** | Universal. Works in both Browser and Server (AI, Logic, Math). |
334
+
335
+ ### Core Module Status
336
+
337
+ - `dphelper.ai`: 🧬 Isomorphic
338
+ - `dphelper.fetch`: 🧬 Isomorphic (Supports Node 18+)
339
+ - `dphelper.sse`: 🌐 Client (Streaming fetch)
340
+ - `dphelper.socket`: 🌐 Client (WebSocket)
341
+ - `dphelper.sync`: 🌐 Client (BroadcastChannel)
342
+ - `dphelper.UI`: 🌐 Client (DOM based)
343
+
344
+ ---
345
+
346
+ ## Security
347
+
348
+ dphelper follows **NIST SP 800-53** and **NSA** security standards:
349
+
350
+ ### Cryptography (CNSA Compliant)
351
+ - **AES-256-GCM** encryption
352
+ - **SHA-256** only (SHA-1 deprecated)
353
+ - **PBKDF2** with 310,000 iterations (OWASP 2023)
354
+
355
+ ### Network Security
356
+ - HTTPS required for `fetch` and `SSE`
357
+ - TLS enforced for `socket` (wss:// only)
358
+ - URL validation built-in
359
+
360
+ > [!IMPORTANT]
361
+ > **For Library Users:** Network functions require **input validation** by the caller. Always sanitize URLs before passing to dphelper networking tools.
362
+
363
+ ```javascript
364
+ // Correct
365
+ const safeUrl = dphelper.sanitize.url(userInput);
366
+ await dphelper.fetch.get(safeUrl);
367
+
368
+ // Never do this
369
+ await dphelper.fetch.get(userInput); // ❌ Unvalidated
370
+ ```
371
+
372
+ ### Compliance
373
+ - 100% NIST/NSA compliant
374
+ - No known vulnerabilities
375
+ - Automated security scanning in CI
376
+
377
+ ---
378
+
379
+ ## License
380
+
381
+ MIT License
382
+
383
+ ## Credits
384
+
385
+ Copyrigth (c) [Dario Passariello](https://dario.passariello.ca/)
@@ -0,0 +1,83 @@
1
+ # Table of Contents
2
+
3
+ - [dpHelper](../README.md)
4
+
5
+ ---
6
+
7
+ ## Core Tools
8
+
9
+ - [ai](markdown/ai.md)
10
+ - [array](markdown/array.md)
11
+ - [browser](markdown/browser.md)
12
+ - [check](markdown/check.md)
13
+ - [date](markdown/date.md)
14
+ - [form](markdown/form.md)
15
+ - [json](markdown/json.md)
16
+ - [load](markdown/load.md)
17
+ - [navigation](markdown/navigation.md)
18
+ - [security](markdown/security.md)
19
+ - [socket](markdown/socket.md)
20
+ - [svg](markdown/svg.md)
21
+ - [markdown](markdown/markdown.md)
22
+ - [window](markdown/window.md)
23
+
24
+ ---
25
+
26
+ ## UI & DOM
27
+
28
+ - [anchor](markdown/anchor.md)
29
+ - [audio](markdown/audio.md)
30
+ - [color](markdown/color.md)
31
+ - [coords](markdown/coords.md)
32
+ - [disable](markdown/disable.md)
33
+ - [dispatch](markdown/dispatch.md)
34
+ - [element](markdown/element.md)
35
+ - [event](markdown/event.md)
36
+ - [scrollbar](markdown/scrollbar.md)
37
+ - [screen](markdown/screen.md)
38
+ - [trigger](markdown/trigger.md)
39
+ - [type](markdown/type.md)
40
+ - [types](markdown/types.md)
41
+ - [ui](markdown/ui.md)
42
+
43
+ ---
44
+
45
+ ## Data & Text
46
+
47
+ - [format](markdown/format.md)
48
+ - [math](markdown/math.md)
49
+ - [objects](markdown/objects.md)
50
+ - [path](markdown/path.md)
51
+ - [sanitize](markdown/sanitize.md)
52
+ - [text](markdown/text.md)
53
+ - [translators](markdown/translators.md)
54
+
55
+ ---
56
+
57
+ ## Network & Storage
58
+
59
+ - [cookie](markdown/cookie.md)
60
+ - [compress](markdown/compress.md)
61
+ - [fetch](markdown/fetch.md)
62
+ - [net](markdown/net.md)
63
+ - [sse](markdown/sse.md)
64
+ - [sync](markdown/sync.md)
65
+
66
+ ---
67
+
68
+ ## Advanced
69
+
70
+ - [avoid](markdown/avoid.md)
71
+ - [biometric](markdown/biometric.md)
72
+ - [credits](markdown/credits.md)
73
+ - [i18n](markdown/i18n.md)
74
+ - [image](markdown/image.md)
75
+ - [logging](markdown/logging.md)
76
+ - [memory](markdown/memory.md)
77
+ - [promise](markdown/promise.md)
78
+ - [shortcut](markdown/shortcut.md)
79
+ - [system](markdown/system.md)
80
+ - [terminal](markdown/terminal.md)
81
+ - [timer](markdown/timer.md)
82
+ - [triggers](markdown/triggers.md)
83
+ - [worker](markdown/worker.md)
@@ -0,0 +1 @@
1
+ theme: jekyll-theme-modernist