dphelper 3.8.8 → 3.9.5
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 +64 -44
- package/SECURITY.md +27 -3
- package/ai-plugin.json +18 -0
- package/index.cjs +1 -1
- package/index.js +1 -1
- package/llms.txt +73 -0
- package/package.json +80 -2
- package/types/dphelper.d.ts +0 -3
- package/docs/README.md +0 -382
- package/docs/SUMMARY.md +0 -83
- package/docs/_config.yml +0 -1
- package/docs/markdown/ai.md +0 -345
- package/docs/markdown/anchor.md +0 -156
- package/docs/markdown/array.md +0 -208
- package/docs/markdown/audio.md +0 -113
- package/docs/markdown/avoid.md +0 -53
- package/docs/markdown/biometric.md +0 -338
- package/docs/markdown/browser.md +0 -203
- package/docs/markdown/check.md +0 -65
- package/docs/markdown/color.md +0 -159
- package/docs/markdown/compress.md +0 -310
- package/docs/markdown/cookie.md +0 -115
- package/docs/markdown/coords.md +0 -127
- package/docs/markdown/credits.md +0 -56
- package/docs/markdown/date.md +0 -260
- package/docs/markdown/disable.md +0 -109
- package/docs/markdown/dispatch.md +0 -108
- package/docs/markdown/element.md +0 -53
- package/docs/markdown/event.md +0 -85
- package/docs/markdown/fetch.md +0 -122
- package/docs/markdown/form.md +0 -302
- package/docs/markdown/format.md +0 -122
- package/docs/markdown/i18n.md +0 -292
- package/docs/markdown/image.md +0 -298
- package/docs/markdown/json.md +0 -269
- package/docs/markdown/load.md +0 -133
- package/docs/markdown/logging.md +0 -99
- package/docs/markdown/math.md +0 -172
- package/docs/markdown/memory.md +0 -85
- package/docs/markdown/navigation.md +0 -152
- package/docs/markdown/net.md +0 -60
- package/docs/markdown/obj.md +0 -242
- package/docs/markdown/path.md +0 -46
- package/docs/markdown/promise.md +0 -94
- package/docs/markdown/sanitize.md +0 -118
- package/docs/markdown/screen.md +0 -78
- package/docs/markdown/scrollbar.md +0 -82
- package/docs/markdown/security.md +0 -289
- package/docs/markdown/shortcut.md +0 -100
- package/docs/markdown/socket.md +0 -134
- package/docs/markdown/sse.md +0 -120
- package/docs/markdown/svg.md +0 -167
- package/docs/markdown/sync.md +0 -147
- package/docs/markdown/system.md +0 -78
- package/docs/markdown/terminal.md +0 -73
- package/docs/markdown/text.md +0 -245
- package/docs/markdown/timer.md +0 -98
- package/docs/markdown/tools.md +0 -111
- package/docs/markdown/translators.md +0 -65
- package/docs/markdown/trigger.md +0 -99
- package/docs/markdown/triggers.md +0 -133
- package/docs/markdown/type.md +0 -109
- package/docs/markdown/types.md +0 -102
- package/docs/markdown/ui.md +0 -45
- package/docs/markdown/window.md +0 -211
- package/docs/markdown/worker.md +0 -223
package/llms.txt
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
# dphelper
|
|
2
|
+
|
|
3
|
+
> [!IMPORTANT]
|
|
4
|
+
> **ARCHITECTURAL CHANGE:** State management has been COMPLETELY REMOVED from the `dphelper` library.
|
|
5
|
+
> Application state is now handled exclusively through dedicated external managers: **Memorio** (for simple global state) or **Argis RGS** (for enterprise-level state).
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## About dphelper
|
|
10
|
+
|
|
11
|
+
`dphelper` is a powerful, **zero-dependency, stateless utility library** that packs 303 production-ready tools for modern web developers, AI engineers, and DevTools creators. It is fully isomorphic, running flawlessly across the Browser, Node.js, Bun, and Deno with a tiny minified footprint of ~171KB.
|
|
12
|
+
|
|
13
|
+
### ⚡ Key Capabilities
|
|
14
|
+
* **AI-First Engineering:** Built-in support for the modern LLM stack, featuring **TOON optimization** (the efficient JSON alternative for prompts), context-aware token counting, smart RAG-ready chunking, and deep reasoning extraction (supporting architectures like DeepSeek and OpenAI o1/o3).
|
|
15
|
+
* **Modern Web Primitives:** Sophisticated wrappers for Web Workers (including worker pool orchestration and multi-tab SharedWorkers), full IndexedDB query builders, and native client-side compression (Gzip/Deflate/LZW).
|
|
16
|
+
* **Cross-Tab Intelligence:** Desktop-grade synchronization without a backend, powered by `dphelper.sync.pulse` cross-tab event buses and active browser tab interlocks.
|
|
17
|
+
* **Biometric Authentication:** Built-in async WebAuthn primitives for effortless fingerprint and facial recognition integrations.
|
|
18
|
+
* **Enterprise Security:** NIST SP 800-53 and NSA CNSA compliant, utilizing AES-256-GCM and strict OWASP-aligned PBKDF2 with 310,000 iterations.
|
|
19
|
+
|
|
20
|
+
---
|
|
21
|
+
|
|
22
|
+
## Quick Usage Syntax
|
|
23
|
+
|
|
24
|
+
`dphelper` maps its modules globally. Import it **exactly once** at your application's absolute entry point (e.g., `index.js`, `main.ts`, or `App.tsx`):
|
|
25
|
+
|
|
26
|
+
```javascript
|
|
27
|
+
import "dphelper";
|
|
28
|
+
|
|
29
|
+
### 🧬 The Core Architectural Ecosystem
|
|
30
|
+
|
|
31
|
+
`dphelper` operates as a completely stateless, high-performance toolkit. To ensure clean separation of concerns and prevent race conditions or state contamination across asynchronous modules, state management has been extracted into dedicated standalone libraries.
|
|
32
|
+
|
|
33
|
+
Always map your application architecture according to the following layout:
|
|
34
|
+
|
|
35
|
+
| Layer & Purpose | Package | Operational Target | Design Philosophy |
|
|
36
|
+
| :--- | :--- | :--- | :--- |
|
|
37
|
+
| **Stateless Utilities & AI Tools** | `dphelper` | Isomorphic (Browser, Node.js, Bun, Deno) | **Zero-Dependency Universal Core.** Packs 303 production-ready modules including `ai` (TOON optimization, smart chunking), `worker` multi-threaded pools, `biometric` WebAuthn, `i18n`, desktop-grade cross-tab `sync.pulse`, and NIST-compliant cryptography. |
|
|
38
|
+
| **Simple Global State** | `memorio` | Application-Wide Runtime | **Global Singleton Pattern.** High-performance, lightweight state management that eliminates boilerplate. It registers globally upon initial import and removes the need for custom context providers, actions, or dispatch files. |
|
|
39
|
+
| **Enterprise State Architecture** | `Argis RGS` | Distributed / Complex SaaS Systems | **Heavy-Duty Reactive Structure.** Built for multi-module, enterprise-grade applications requiring strict state rules, relational data synchronization, and heavy concurrent data pipelines. |
|
|
40
|
+
|
|
41
|
+
---
|
|
42
|
+
|
|
43
|
+
### ⚠️ Integration Best Practices for AI & Humans
|
|
44
|
+
|
|
45
|
+
1. **Do Not Bundle State Logic in dphelper:** Any legacy codebase referencing `dphelper.store` or namespace getters/setters must be migrated to `memorio` or `Argis RGS`.
|
|
46
|
+
2. **Single-Entry Side Effect:** `dphelper` is designed to be imported exactly once in your root file (`import "dphelper";`). It will automatically map its 303 tools safely to the global scope.
|
|
47
|
+
3. **State Integrity:** When building micro-frontends or multi-tab web applications, use `dphelper.sync` primitives to handle cross-tab events, while allowing `memorio` to manage the underlying atomic state memory.
|
|
48
|
+
|
|
49
|
+
// dphelper attaches to the global scope and is ready across your entire project
|
|
50
|
+
console.debug(dphelper.version);
|
|
51
|
+
|
|
52
|
+
// 🤖 AI Stack Snapshot & TOON Optimization
|
|
53
|
+
const appStateToon = dphelper.ai.snapshot();
|
|
54
|
+
const textChunks = dphelper.ai.chunker(longText, { size: 1000, overlap: 200 });
|
|
55
|
+
const { reasoning, content } = dphelper.ai.extractReasoning(rawAiReply);
|
|
56
|
+
|
|
57
|
+
// ⚙️ Multi-Threaded Worker Pools
|
|
58
|
+
const pool = dphelper.worker.pool('worker.js', 4);
|
|
59
|
+
const results = await dphelper.worker.poolExec(pool, [1, 2, 3, 4]);
|
|
60
|
+
|
|
61
|
+
// 💓 Real-Time Cross-Tab Sync (No Backend Required)
|
|
62
|
+
const bus = dphelper.sync.pulse('my-app', (msg) => console.log(msg));
|
|
63
|
+
bus.emit({ action: 'theme-change', value: 'dark' });
|
|
64
|
+
|
|
65
|
+
// 🌍 Full i18n Internationalization Suite
|
|
66
|
+
dphelper.i18n.setLocale('it');
|
|
67
|
+
dphelper.i18n.addTranslations('it', { hello: 'Ciao {name}!' });
|
|
68
|
+
|
|
69
|
+
## DEVELOPMENT ENVIRONMENT GUIDELINES:
|
|
70
|
+
- We are using dphelper (Stateless Core). Never generate code using 'dphelper.store'.
|
|
71
|
+
- Global state must be managed exclusively via 'memorio' (lightweight) or 'Argis RGS' (enterprise).
|
|
72
|
+
- dphelper is initialized as a global side-effect: 'import "dphelper";' in the root file. Do not generate inline imports for it in sub-modules.
|
|
73
|
+
- For cross-tab/micro-frontend synchronization, use 'dphelper.sync.pulse' for events, but delegate data persistence to memorio.
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dphelper",
|
|
3
|
-
"
|
|
4
|
-
"version": "3.
|
|
3
|
+
"codeName": "dphelper",
|
|
4
|
+
"version": "3.9.5",
|
|
5
5
|
"description": "dphelper devtools for developers",
|
|
6
6
|
"main": "./index.cjs",
|
|
7
7
|
"browser": "./index.cjs",
|
|
@@ -48,6 +48,9 @@
|
|
|
48
48
|
"url": "https://www.patreon.com/passariello"
|
|
49
49
|
}
|
|
50
50
|
],
|
|
51
|
+
"workspaces": [
|
|
52
|
+
"tests"
|
|
53
|
+
],
|
|
51
54
|
"engines": {
|
|
52
55
|
"node": ">=18.0.0"
|
|
53
56
|
},
|
|
@@ -67,6 +70,81 @@
|
|
|
67
70
|
"optional": false
|
|
68
71
|
}
|
|
69
72
|
},
|
|
73
|
+
"overrides": {
|
|
74
|
+
"array-buffer-byte-length": "npm:@socketregistry/array-buffer-byte-length@^1",
|
|
75
|
+
"array-includes": "npm:@socketregistry/array-includes@^1",
|
|
76
|
+
"array.prototype.findlast": "npm:@socketregistry/array.prototype.findlast@^1",
|
|
77
|
+
"array.prototype.flat": "npm:@socketregistry/array.prototype.flat@^1",
|
|
78
|
+
"array.prototype.flatmap": "npm:@socketregistry/array.prototype.flatmap@^1",
|
|
79
|
+
"array.prototype.tosorted": "npm:@socketregistry/array.prototype.tosorted@^1",
|
|
80
|
+
"arraybuffer.prototype.slice": "npm:@socketregistry/arraybuffer.prototype.slice@^1",
|
|
81
|
+
"available-typed-arrays": "npm:@socketregistry/available-typed-arrays@^1",
|
|
82
|
+
"define-properties": "npm:@socketregistry/define-properties@^1",
|
|
83
|
+
"es-define-property": "npm:@socketregistry/es-define-property@^1",
|
|
84
|
+
"es-iterator-helpers": "npm:@socketregistry/es-iterator-helpers@^1",
|
|
85
|
+
"es-set-tostringtag": "npm:@socketregistry/es-set-tostringtag@^1",
|
|
86
|
+
"for-each": "npm:@socketregistry/for-each@^1",
|
|
87
|
+
"function-bind": "npm:@socketregistry/function-bind@^1",
|
|
88
|
+
"function.prototype.name": "npm:@socketregistry/function.prototype.name@^1",
|
|
89
|
+
"functions-have-names": "npm:@socketregistry/functions-have-names@^1",
|
|
90
|
+
"get-symbol-description": "npm:@socketregistry/get-symbol-description@^1",
|
|
91
|
+
"globalthis": "npm:@socketregistry/globalthis@^1",
|
|
92
|
+
"gopd": "npm:@socketregistry/gopd@^1",
|
|
93
|
+
"has-property-descriptors": "npm:@socketregistry/has-property-descriptors@^1",
|
|
94
|
+
"has-proto": "npm:@socketregistry/has-proto@^1",
|
|
95
|
+
"has-symbols": "npm:@socketregistry/has-symbols@^1",
|
|
96
|
+
"has-tostringtag": "npm:@socketregistry/has-tostringtag@^1",
|
|
97
|
+
"hasown": "npm:@socketregistry/hasown@^1",
|
|
98
|
+
"indent-string": "npm:@socketregistry/indent-string@^1",
|
|
99
|
+
"internal-slot": "npm:@socketregistry/internal-slot@^1",
|
|
100
|
+
"is-array-buffer": "npm:@socketregistry/is-array-buffer@^1",
|
|
101
|
+
"is-bigint": "npm:@socketregistry/is-bigint@^1",
|
|
102
|
+
"is-boolean-object": "npm:@socketregistry/is-boolean-object@^1",
|
|
103
|
+
"is-core-module": "npm:@socketregistry/is-core-module@^1",
|
|
104
|
+
"is-date-object": "npm:@socketregistry/is-date-object@^1",
|
|
105
|
+
"is-generator-function": "npm:@socketregistry/is-generator-function@^1",
|
|
106
|
+
"is-map": "npm:@socketregistry/is-map@^1",
|
|
107
|
+
"is-negative-zero": "npm:@socketregistry/is-negative-zero@^1",
|
|
108
|
+
"is-number-object": "npm:@socketregistry/is-number-object@^1",
|
|
109
|
+
"is-regex": "npm:@socketregistry/is-regex@^1",
|
|
110
|
+
"is-set": "npm:@socketregistry/is-set@^1",
|
|
111
|
+
"is-shared-array-buffer": "npm:@socketregistry/is-shared-array-buffer@^1",
|
|
112
|
+
"is-string": "npm:@socketregistry/is-string@^1",
|
|
113
|
+
"is-symbol": "npm:@socketregistry/is-symbol@^1",
|
|
114
|
+
"is-typed-array": "npm:@socketregistry/is-typed-array@^1",
|
|
115
|
+
"is-weakmap": "npm:@socketregistry/is-weakmap@^1",
|
|
116
|
+
"is-weakref": "npm:@socketregistry/is-weakref@^1",
|
|
117
|
+
"is-weakset": "npm:@socketregistry/is-weakset@^1",
|
|
118
|
+
"isarray": "npm:@socketregistry/isarray@^1",
|
|
119
|
+
"iterator.prototype": "npm:@socketregistry/iterator.prototype@^1",
|
|
120
|
+
"object-assign": "npm:@socketregistry/object-assign@^1",
|
|
121
|
+
"object-keys": "npm:@socketregistry/object-keys@^1",
|
|
122
|
+
"object.assign": "npm:@socketregistry/object.assign@^1",
|
|
123
|
+
"object.entries": "npm:@socketregistry/object.entries@^1",
|
|
124
|
+
"object.fromentries": "npm:@socketregistry/object.fromentries@^1",
|
|
125
|
+
"object.values": "npm:@socketregistry/object.values@^1",
|
|
126
|
+
"path-parse": "npm:@socketregistry/path-parse@^1",
|
|
127
|
+
"reflect.getprototypeof": "npm:@socketregistry/reflect.getprototypeof@^1",
|
|
128
|
+
"regexp.prototype.flags": "npm:@socketregistry/regexp.prototype.flags@^1",
|
|
129
|
+
"safe-array-concat": "npm:@socketregistry/safe-array-concat@^1",
|
|
130
|
+
"safe-regex-test": "npm:@socketregistry/safe-regex-test@^1",
|
|
131
|
+
"safer-buffer": "npm:@socketregistry/safer-buffer@^1",
|
|
132
|
+
"set-function-length": "npm:@socketregistry/set-function-length@^1",
|
|
133
|
+
"side-channel": "npm:@socketregistry/side-channel@^1",
|
|
134
|
+
"string.prototype.matchall": "npm:@socketregistry/string.prototype.matchall@^1",
|
|
135
|
+
"string.prototype.repeat": "npm:@socketregistry/string.prototype.repeat@^1",
|
|
136
|
+
"string.prototype.trim": "npm:@socketregistry/string.prototype.trim@^1",
|
|
137
|
+
"string.prototype.trimend": "npm:@socketregistry/string.prototype.trimend@^1",
|
|
138
|
+
"string.prototype.trimstart": "npm:@socketregistry/string.prototype.trimstart@^1",
|
|
139
|
+
"typed-array-buffer": "npm:@socketregistry/typed-array-buffer@^1",
|
|
140
|
+
"typed-array-byte-length": "npm:@socketregistry/typed-array-byte-length@^1",
|
|
141
|
+
"typed-array-byte-offset": "npm:@socketregistry/typed-array-byte-offset@^1",
|
|
142
|
+
"typed-array-length": "npm:@socketregistry/typed-array-length@^1",
|
|
143
|
+
"unbox-primitive": "npm:@socketregistry/unbox-primitive@^1",
|
|
144
|
+
"which-boxed-primitive": "npm:@socketregistry/which-boxed-primitive@^1",
|
|
145
|
+
"which-collection": "npm:@socketregistry/which-collection@^1",
|
|
146
|
+
"which-typed-array": "npm:@socketregistry/which-typed-array@^1"
|
|
147
|
+
},
|
|
70
148
|
"module": "./index.js",
|
|
71
149
|
"exports": {
|
|
72
150
|
".": {
|
package/types/dphelper.d.ts
CHANGED
|
@@ -747,9 +747,6 @@ interface globalThis {
|
|
|
747
747
|
[key: string]: any
|
|
748
748
|
}
|
|
749
749
|
|
|
750
|
-
declare var DPH_APP_CODE: string
|
|
751
|
-
declare var DPH_APP_VERSION: string
|
|
752
|
-
|
|
753
750
|
declare function confirm(message: string, func1: Function, func2?: Function): boolean
|
|
754
751
|
|
|
755
752
|
declare var dphelper: _dphelper
|
package/docs/README.md
DELETED
|
@@ -1,382 +0,0 @@
|
|
|
1
|
-
# [dphelper](https://npmjs.com/package/dphelper)
|
|
2
|
-
|
|
3
|
-

|
|
4
|
-
|
|
5
|
-
> **The supercharged toolkit for modern web development, AI engineering & DevTools.**
|
|
6
|
-
|
|
7
|
-
[](https://npmjs.org/package/dphelper)
|
|
8
|
-
[](https://packagephobia.now.sh/result?p=dphelper)
|
|
9
|
-
[](https://npmjs.org/package/dphelper)
|
|
10
|
-
|
|
11
|
-

|
|
12
|
-

|
|
13
|
-

|
|
14
|
-

|
|
15
|
-

|
|
16
|
-
|
|
17
|
-

|
|
18
|
-

|
|
19
|
-

|
|
20
|
-

|
|
21
|
-

|
|
22
|
-
|
|
23
|
-
---
|
|
24
|
-
|
|
25
|
-
## About
|
|
26
|
-
|
|
27
|
-
**dphelper** is a powerful, zero-dependency utility library that brings together **303 production-ready tools** for web developers, AI engineers, and DevTools creators.
|
|
28
|
-
|
|
29
|
-
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.
|
|
30
|
-
|
|
31
|
-
### Why dphelper?
|
|
32
|
-
|
|
33
|
-
- **⚡ Zero Dependencies** - Pure vanilla JavaScript/TypeScript. No bloat, no surprises.
|
|
34
|
-
- **🤖 AI-First Design** - Built for LLM apps with TOON optimization, token counting, and RAG support.
|
|
35
|
-
- **🌐 Universal** - Works in browser, Node.js, Bun, and Deno.
|
|
36
|
-
- **🔒 Type-Safe** - Full TypeScript definitions auto-generated for every tool.
|
|
37
|
-
- **📦 Tiny Bundle** - Only ~171KB minified, tree-shakeable.
|
|
38
|
-
- **🔐 Security First** - NIST/NSA compliant, CNSA algorithms, PBKDF2 310k iterations
|
|
39
|
-
|
|
40
|
-
> [!NOTE]
|
|
41
|
-
> **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.
|
|
42
|
-
|
|
43
|
-
> *"dphelper is what you'd build if you combined lodash, socket.io, and an AI SDK - but lighter."*
|
|
44
|
-
|
|
45
|
-
---
|
|
46
|
-
|
|
47
|
-
## State and Store removed from dpHelper
|
|
48
|
-
|
|
49
|
-
> [!IMPORTANT]
|
|
50
|
-
> dpHelper do not integrate state management directly anymore
|
|
51
|
-
>
|
|
52
|
-
> Application state is currently handled through **Memorio** or **RGS**.
|
|
53
|
-
|
|
54
|
-
If you need to use state management please consider:
|
|
55
|
-
|
|
56
|
-
- Simple State and Store Manager [Memorio](http://www.npmjs.com/package/memorio)
|
|
57
|
-
- Enterprise Lever State Manager [Argis RGS](https://www.npmjs.com/package/@biglogic/rgs)
|
|
58
|
-
|
|
59
|
-
---
|
|
60
|
-
|
|
61
|
-
## 🚀 New Powerful Modules
|
|
62
|
-
|
|
63
|
-
`dphelper` has expanded with powerful new modules for modern web development:
|
|
64
|
-
|
|
65
|
-
### ✨ Highlights
|
|
66
|
-
|
|
67
|
-
- **💾 IndexedDB Module**: Full-featured wrapper for IndexedDB with query builder, transactions, and bulk operations.
|
|
68
|
-
- **⚙️ Web Worker Module**: Create and manage workers, worker pools for parallel processing, and SharedWorkers for cross-tab communication.
|
|
69
|
-
- **🌍 i18n Module**: Complete internationalization with translations, pluralization, date/number formatting, and relative time.
|
|
70
|
-
- **🖼️ Image Module**: Image processing including resize, crop, filters, rotation, flip, and compositing.
|
|
71
|
-
- **🗜️ Compression Module**: Gzip, deflate, LZW compression, plus base64, URL, and HTML encoding/decoding.
|
|
72
|
-
- **🔐 Biometric Module**: WebAuthn support for fingerprint, face recognition, and secure credential management.
|
|
73
|
-
|
|
74
|
-
---
|
|
75
|
-
|
|
76
|
-
## ⚙️ Web Worker Module
|
|
77
|
-
|
|
78
|
-
```javascript
|
|
79
|
-
// Create worker from file
|
|
80
|
-
const worker = dphelper.worker.create('worker.js', {
|
|
81
|
-
onmessage: (e) => console.log(e.data)
|
|
82
|
-
});
|
|
83
|
-
|
|
84
|
-
// Create inline worker
|
|
85
|
-
const inlineWorker = dphelper.worker.createInline(`
|
|
86
|
-
self.onmessage = e => postMessage(e.data * 2);
|
|
87
|
-
`);
|
|
88
|
-
|
|
89
|
-
// Worker pool for parallel processing
|
|
90
|
-
const pool = dphelper.worker.pool('worker.js', 4);
|
|
91
|
-
const results = await dphelper.worker.poolExec(pool, [1, 2, 3, 4]);
|
|
92
|
-
|
|
93
|
-
// SharedWorker for cross-tab communication
|
|
94
|
-
const shared = dphelper.worker.shared('worker.js', { name: 'my-shared' });
|
|
95
|
-
```
|
|
96
|
-
|
|
97
|
-
---
|
|
98
|
-
|
|
99
|
-
## 🌍 i18n Module
|
|
100
|
-
|
|
101
|
-
```javascript
|
|
102
|
-
// Set locale
|
|
103
|
-
dphelper.i18n.setLocale('it');
|
|
104
|
-
|
|
105
|
-
// Add translations
|
|
106
|
-
dphelper.i18n.addTranslations('it', {
|
|
107
|
-
hello: 'Ciao {name}!',
|
|
108
|
-
items: '{count, plural, one{# item} other{# items}}'
|
|
109
|
-
});
|
|
110
|
-
|
|
111
|
-
// Translate with interpolation
|
|
112
|
-
dphelper.i18n.t('hello', { name: 'World' }); // "Ciao World!"
|
|
113
|
-
|
|
114
|
-
// Pluralize
|
|
115
|
-
dphelper.i18n.pluralize(5, { one: 'item', other: 'items' }); // "items"
|
|
116
|
-
|
|
117
|
-
// Format number/currency
|
|
118
|
-
dphelper.i18n.number(1234.56, 'de-DE', { style: 'currency', currency: 'EUR' });
|
|
119
|
-
|
|
120
|
-
// Relative time
|
|
121
|
-
dphelper.i18n.relativeTime(Date.now() - 3600000); // "1 hour ago"
|
|
122
|
-
```
|
|
123
|
-
|
|
124
|
-
---
|
|
125
|
-
|
|
126
|
-
## 🖼️ Image Module
|
|
127
|
-
|
|
128
|
-
```javascript
|
|
129
|
-
// Load image
|
|
130
|
-
const img = await dphelper.image.load('photo.jpg');
|
|
131
|
-
|
|
132
|
-
// Resize
|
|
133
|
-
const resized = dphelper.image.resize(img, 100, 100);
|
|
134
|
-
|
|
135
|
-
// Crop
|
|
136
|
-
const cropped = dphelper.image.crop(img, { x: 0, y: 0, width: 50, height: 50 });
|
|
137
|
-
|
|
138
|
-
// Apply filters
|
|
139
|
-
const filtered = dphelper.image.filter(img, { brightness: 1.2, sepia: 0.5 });
|
|
140
|
-
|
|
141
|
-
// Rotate/Flip
|
|
142
|
-
const rotated = dphelper.image.rotate(img, 90);
|
|
143
|
-
const flipped = dphelper.image.flip(img, 'horizontal');
|
|
144
|
-
|
|
145
|
-
// Grayscale/Blur
|
|
146
|
-
const gray = dphelper.image.grayscale(img);
|
|
147
|
-
const blurred = dphelper.image.blur(img, 5);
|
|
148
|
-
```
|
|
149
|
-
|
|
150
|
-
---
|
|
151
|
-
|
|
152
|
-
## 🗜️ Compression Module
|
|
153
|
-
|
|
154
|
-
```javascript
|
|
155
|
-
// Gzip compression
|
|
156
|
-
const compressed = await dphelper.compress.gzip('Hello World');
|
|
157
|
-
const decompressed = await dphelper.compress.gunzip(compressed);
|
|
158
|
-
|
|
159
|
-
// Base64 encoding
|
|
160
|
-
const encoded = dphelper.compress.base64Encode('Hello');
|
|
161
|
-
const decoded = dphelper.compress.base64Decode(encoded);
|
|
162
|
-
|
|
163
|
-
// URL encoding
|
|
164
|
-
const urlEncoded = dphelper.compress.urlEncode('Hello World!');
|
|
165
|
-
const urlDecoded = dphelper.compress.urlDecode(urlEncoded);
|
|
166
|
-
|
|
167
|
-
// HTML encoding
|
|
168
|
-
const htmlEncoded = dphelper.compress.htmlEncode('<script>');
|
|
169
|
-
const htmlDecoded = dphelper.compress.htmlDecode('<script>');
|
|
170
|
-
```
|
|
171
|
-
|
|
172
|
-
---
|
|
173
|
-
|
|
174
|
-
## 🔐 Biometric Module (WebAuthn)
|
|
175
|
-
|
|
176
|
-
```javascript
|
|
177
|
-
// Check availability
|
|
178
|
-
const available = dphelper.biometric.isAvailable();
|
|
179
|
-
|
|
180
|
-
// Get support details
|
|
181
|
-
const support = dphelper.biometric.getWebAuthnSupport();
|
|
182
|
-
|
|
183
|
-
// Register credential
|
|
184
|
-
const { success, credentialId } = await dphelper.biometric.register('user123');
|
|
185
|
-
|
|
186
|
-
// Authenticate
|
|
187
|
-
const { success } = await dphelper.biometric.authenticate('user123');
|
|
188
|
-
|
|
189
|
-
// Check specific sensor
|
|
190
|
-
const hasFingerprint = await dphelper.biometric.isSensorAvailable('fingerprint');
|
|
191
|
-
```
|
|
192
|
-
|
|
193
|
-
---
|
|
194
|
-
|
|
195
|
-
## Table of Contents
|
|
196
|
-
|
|
197
|
-
1. [About](#about)
|
|
198
|
-
2. [Installation](#installation)
|
|
199
|
-
3. [AI Power User Guide](#ai-power-user-guide)
|
|
200
|
-
4. [Modular Architecture](#modular-architecture)
|
|
201
|
-
5. [Browser Extension (Chrome/Edge)](#browser-extension-chromeedge)
|
|
202
|
-
6. [Environment Compatibility](#environment-compatibility)
|
|
203
|
-
7. [Security](#security)
|
|
204
|
-
|
|
205
|
-
---
|
|
206
|
-
|
|
207
|
-
## Installation
|
|
208
|
-
|
|
209
|
-
```shell
|
|
210
|
-
npm i dphelper --save-dev
|
|
211
|
-
```
|
|
212
|
-
|
|
213
|
-
### Usage
|
|
214
|
-
|
|
215
|
-
Import it precisely **once** in your entry point (e.g., `index.js`, `main.ts`, or `App.tsx`):
|
|
216
|
-
|
|
217
|
-
```js
|
|
218
|
-
import "dphelper";
|
|
219
|
-
// dphelper is now available globally across your entire project!
|
|
220
|
-
```
|
|
221
|
-
|
|
222
|
-
For plain HTML/CDN:
|
|
223
|
-
|
|
224
|
-
```html
|
|
225
|
-
<script src="https://unpkg.com/dphelper/dphelper.js"></script>
|
|
226
|
-
|
|
227
|
-
<!-- Optional check -->
|
|
228
|
-
<script>
|
|
229
|
-
console.debug(dphelper.version); // latest version
|
|
230
|
-
console.debud(dphelper.isBrowser); // true
|
|
231
|
-
</script>
|
|
232
|
-
```
|
|
233
|
-
|
|
234
|
-
---
|
|
235
|
-
|
|
236
|
-
## AI Power User Guide
|
|
237
|
-
|
|
238
|
-
The new `dphelper.ai` module is designed for the modern AI stack (LLMs, RAG, Vector Search).
|
|
239
|
-
|
|
240
|
-
```javascript
|
|
241
|
-
// ⚡ TOON: The ultimate JSON alternative for prompts
|
|
242
|
-
const toonData = dphelper.ai.toon(myJsonObject);
|
|
243
|
-
// Efficient, compact, and deterministic.
|
|
244
|
-
|
|
245
|
-
// 📏 Context-Aware Token Counting
|
|
246
|
-
const tokens = dphelper.ai.tokenCount(myJsonObject);
|
|
247
|
-
// Automatically calculates tokens based on the optimal TOON representation.
|
|
248
|
-
|
|
249
|
-
// 🧩 Smart Chunker (RAG Ready)
|
|
250
|
-
const chunks = dphelper.ai.chunker(longText, { size: 1000, overlap: 200 });
|
|
251
|
-
|
|
252
|
-
// 🔍 Semantic Similarity
|
|
253
|
-
const score = dphelper.ai.similarity(embeddingA, embeddingB);
|
|
254
|
-
|
|
255
|
-
// 🧠 Reasoning Extractor (DeepSeek/O1 support)
|
|
256
|
-
const { reasoning, content } = dphelper.ai.extractReasoning(rawAiReply);
|
|
257
|
-
|
|
258
|
-
// 📸 The AI Black Box (Snapshot)
|
|
259
|
-
const appStateToon = dphelper.ai.snapshot();
|
|
260
|
-
// Generates a complete app "mental dump" (URL, gState, Logs) optimized for LLMs.
|
|
261
|
-
```
|
|
262
|
-
|
|
263
|
-
---
|
|
264
|
-
|
|
265
|
-
## Modular Architecture
|
|
266
|
-
|
|
267
|
-
Every tool in `dphelper` is now a self-contained module. Our new build system automatically:
|
|
268
|
-
|
|
269
|
-
1. Scans the `tools/` directory.
|
|
270
|
-
2. Generates dynamic imports for the core.
|
|
271
|
-
3. Synchronizes TypeScript interfaces in `dphelper.d.ts`.
|
|
272
|
-
|
|
273
|
-
This ensures that adding new tools is instantaneous and always documented with full Intellisense support.
|
|
274
|
-
|
|
275
|
-
---
|
|
276
|
-
|
|
277
|
-
## 🔄 UI Mirror & Auto-Recovery
|
|
278
|
-
|
|
279
|
-
`dphelper` makes your web app feel like a native desktop application with cross-tab intelligence.
|
|
280
|
-
|
|
281
|
-
```javascript
|
|
282
|
-
// ⚓ Auto-Recovery: Save scroll and input values across reloads/crashes
|
|
283
|
-
dphelper.UI.anchorContext();
|
|
284
|
-
|
|
285
|
-
// 💓 Pulse: Real-time event bus between all open tabs (No Backend needed!)
|
|
286
|
-
const bus = dphelper.sync.pulse('my-app', (msg) => {
|
|
287
|
-
console.debug('Received from another tab:', msg);
|
|
288
|
-
});
|
|
289
|
-
bus.emit({ action: 'theme-change', value: 'dark' });
|
|
290
|
-
|
|
291
|
-
// 🔒 Interlock: Monitor how many tabs of your app are active
|
|
292
|
-
dphelper.browser.interlock((count) => {
|
|
293
|
-
console.debug(`Active tabs: ${count}`);
|
|
294
|
-
});
|
|
295
|
-
|
|
296
|
-
// 🌊 SSE: Modern streaming (Support for POST & Headers)
|
|
297
|
-
const stream = dphelper.sse.open('/api/ai', {
|
|
298
|
-
method: 'POST',
|
|
299
|
-
headers: { 'Authorization': 'Bearer ...' },
|
|
300
|
-
body: JSON.stringify({ prompt: 'Hello AI' })
|
|
301
|
-
});
|
|
302
|
-
|
|
303
|
-
stream.on('message', (data) => console.debug('Chunk:', data));
|
|
304
|
-
stream.on('error', (err) => console.error('Stream failure:', err));
|
|
305
|
-
```
|
|
306
|
-
|
|
307
|
-
---
|
|
308
|
-
|
|
309
|
-
## Browser Extension (Chrome/Edge)
|
|
310
|
-
|
|
311
|
-

|
|
312
|
-
|
|
313
|
-
Manage your `dphelper` environment, monitor memory usage, and access documentation directly from your browser.
|
|
314
|
-
|
|
315
|
-
- [Download for Chrome](https://chrome.google.com/webstore/detail/dphelper-manager-dev-tool/oppppldaoknfddeikfloonnialijngbk)
|
|
316
|
-
- [Download for Edge](https://microsoftedge.microsoft.com/addons/detail/dphelper-manager-dev-to/kphabkbdpaljlfagldhojilhfammepnk)
|
|
317
|
-
|
|
318
|
-
---
|
|
319
|
-
|
|
320
|
-
---
|
|
321
|
-
|
|
322
|
-
## Environment Compatibility
|
|
323
|
-
|
|
324
|
-
`dphelper` tools are classified by their execution target to ensure stability across the stack.
|
|
325
|
-
|
|
326
|
-
| Icon | Type | Description |
|
|
327
|
-
| :--- | :--- | :--- |
|
|
328
|
-
| 🌐 | **Client** | Browser only (requires DOM, window, or navigator). |
|
|
329
|
-
| 🖥️ | **Server** | Node.js / Bun / Deno only (access to process, fs, etc). |
|
|
330
|
-
| 🧬 | **Isomorphic** | Universal. Works in both Browser and Server (AI, Logic, Math). |
|
|
331
|
-
|
|
332
|
-
### Core Module Status
|
|
333
|
-
|
|
334
|
-
- `dphelper.ai`: 🧬 Isomorphic
|
|
335
|
-
- `dphelper.fetch`: 🧬 Isomorphic (Supports Node 18+)
|
|
336
|
-
- `dphelper.sse`: 🌐 Client (Streaming fetch)
|
|
337
|
-
- `dphelper.socket`: 🌐 Client (WebSocket)
|
|
338
|
-
- `dphelper.sync`: 🌐 Client (BroadcastChannel)
|
|
339
|
-
- `dphelper.UI`: 🌐 Client (DOM based)
|
|
340
|
-
|
|
341
|
-
---
|
|
342
|
-
|
|
343
|
-
## Security
|
|
344
|
-
|
|
345
|
-
dphelper follows **NIST SP 800-53** and **NSA** security standards:
|
|
346
|
-
|
|
347
|
-
### Cryptography (CNSA Compliant)
|
|
348
|
-
- **AES-256-GCM** encryption
|
|
349
|
-
- **SHA-256** only (SHA-1 deprecated)
|
|
350
|
-
- **PBKDF2** with 310,000 iterations (OWASP 2023)
|
|
351
|
-
|
|
352
|
-
### Network Security
|
|
353
|
-
- HTTPS required for `fetch` and `SSE`
|
|
354
|
-
- TLS enforced for `socket` (wss:// only)
|
|
355
|
-
- URL validation built-in
|
|
356
|
-
|
|
357
|
-
> [!IMPORTANT]
|
|
358
|
-
> **For Library Users:** Network functions require **input validation** by the caller. Always sanitize URLs before passing to dphelper networking tools.
|
|
359
|
-
|
|
360
|
-
```javascript
|
|
361
|
-
// Correct
|
|
362
|
-
const safeUrl = dphelper.sanitize.url(userInput);
|
|
363
|
-
await dphelper.fetch.get(safeUrl);
|
|
364
|
-
|
|
365
|
-
// Never do this
|
|
366
|
-
await dphelper.fetch.get(userInput); // ❌ Unvalidated
|
|
367
|
-
```
|
|
368
|
-
|
|
369
|
-
### Compliance
|
|
370
|
-
- 100% NIST/NSA compliant
|
|
371
|
-
- No known vulnerabilities
|
|
372
|
-
- Automated security scanning in CI
|
|
373
|
-
|
|
374
|
-
---
|
|
375
|
-
|
|
376
|
-
## License
|
|
377
|
-
|
|
378
|
-
MIT License
|
|
379
|
-
|
|
380
|
-
## Credits
|
|
381
|
-
|
|
382
|
-
Copyrigth (c) [Dario Passariello](https://dario.passariello.ca/)
|
package/docs/SUMMARY.md
DELETED
|
@@ -1,83 +0,0 @@
|
|
|
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)
|
package/docs/_config.yml
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
theme: jekyll-theme-modernist
|