dphelper 4.2.0 → 4.2.3

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 (59) hide show
  1. package/README.md +6 -5
  2. package/index.cjs +1 -1
  3. package/index.js +1 -1
  4. package/package.json +3 -3
  5. package/markdown/ai.md +0 -345
  6. package/markdown/anchor.md +0 -156
  7. package/markdown/array.md +0 -208
  8. package/markdown/audio.md +0 -113
  9. package/markdown/avoid.md +0 -53
  10. package/markdown/biometric.md +0 -338
  11. package/markdown/browser.md +0 -203
  12. package/markdown/check.md +0 -65
  13. package/markdown/color.md +0 -159
  14. package/markdown/compress.md +0 -310
  15. package/markdown/cookie.md +0 -115
  16. package/markdown/coords.md +0 -127
  17. package/markdown/credits.md +0 -56
  18. package/markdown/date.md +0 -260
  19. package/markdown/disable.md +0 -109
  20. package/markdown/dispatch.md +0 -108
  21. package/markdown/element.md +0 -53
  22. package/markdown/event.md +0 -85
  23. package/markdown/fetch.md +0 -122
  24. package/markdown/form.md +0 -302
  25. package/markdown/format.md +0 -122
  26. package/markdown/i18n.md +0 -292
  27. package/markdown/image.md +0 -298
  28. package/markdown/json.md +0 -269
  29. package/markdown/load.md +0 -133
  30. package/markdown/logging.md +0 -99
  31. package/markdown/math.md +0 -172
  32. package/markdown/memory.md +0 -85
  33. package/markdown/navigation.md +0 -152
  34. package/markdown/net.md +0 -60
  35. package/markdown/obj.md +0 -242
  36. package/markdown/path.md +0 -46
  37. package/markdown/promise.md +0 -94
  38. package/markdown/sanitize.md +0 -118
  39. package/markdown/screen.md +0 -78
  40. package/markdown/scrollbar.md +0 -82
  41. package/markdown/security.md +0 -289
  42. package/markdown/shortcut.md +0 -100
  43. package/markdown/socket.md +0 -134
  44. package/markdown/sse.md +0 -120
  45. package/markdown/svg.md +0 -167
  46. package/markdown/sync.md +0 -147
  47. package/markdown/system.md +0 -78
  48. package/markdown/terminal.md +0 -73
  49. package/markdown/text.md +0 -245
  50. package/markdown/timer.md +0 -98
  51. package/markdown/tools.md +0 -111
  52. package/markdown/translators.md +0 -65
  53. package/markdown/trigger.md +0 -99
  54. package/markdown/triggers.md +0 -133
  55. package/markdown/type.md +0 -109
  56. package/markdown/types.md +0 -102
  57. package/markdown/ui.md +0 -45
  58. package/markdown/window.md +0 -211
  59. package/markdown/worker.md +0 -223
@@ -1,203 +0,0 @@
1
- # browser
2
-
3
- Complete browser navigation and state management utilities with connection monitoring and HTTP status handling.
4
-
5
- ## Functions
6
-
7
- | Function | Description | Example |
8
- |----------|-------------|---------|
9
- | `state` | Pushes a new state to browser history without reload | `dphelper.browser.state(state, title, url)` |
10
- | `forw` | Moves forward in browser history by n steps | `dphelper.browser.forw(1)` |
11
- | `back` | Moves backward in browser history by n steps | `dphelper.browser.back(1)` |
12
- | `reload` | Reloads the current page | `dphelper.browser.reload()` |
13
- | `href` | Navigates to a specific URL | `dphelper.browser.href('https://example.com')` |
14
- | `offLine` | Displays an offline message overlay when connection is lost | `dphelper.browser.offLine('Custom offline message')` |
15
- | `zoom` | Returns the current browser zoom level as percentage | `dphelper.browser.zoom()` |
16
- | `status` | Returns human-readable description of HTTP status codes | `dphelper.browser.status(404)` |
17
- | `interlock` | Detects and monitors other active tabs of the same app | `dphelper.browser.interlock((count) => console.log(count))` |
18
-
19
- ## Description
20
-
21
- Comprehensive browser management tool that provides:
22
- - **History Navigation** - Push state, go forward/back, reload
23
- - **URL Management** - Navigate to specific URLs
24
- - **Connection Monitoring** - Detect online/offline status
25
- - **Display Information** - Get zoom level, HTTP status descriptions
26
- - **Multi-tab Detection** - Monitor concurrent tab usage
27
-
28
- ## Usage Examples
29
-
30
- ### Changing URL Without Reload (SPA Routing)
31
-
32
- ```javascript
33
- // Add a new history entry without page reload
34
- dphelper.browser.state({ page: 'dashboard', userId: 123 }, 'Dashboard', '/dashboard');
35
-
36
- // The browser's back button will now work
37
- window.addEventListener('popstate', (event) => {
38
- console.log('Navigated to:', event.state);
39
- });
40
- ```
41
-
42
- ### Programmatic Navigation
43
-
44
- ```javascript
45
- // Navigate to a specific URL
46
- dphelper.browser.href('/search?q=javascript');
47
-
48
- // Navigate to external site
49
- dphelper.browser.href('https://google.com');
50
-
51
- // Go forward 2 pages in history
52
- dphelper.browser.forw(2);
53
-
54
- // Go back 1 page in history
55
- dphelper.browser.back(1);
56
-
57
- // Reload the page
58
- dphelper.browser.reload();
59
- ```
60
-
61
- ### Offline Detection Overlay
62
-
63
- ```javascript
64
- // Show default offline message
65
- dphelper.browser.offLine();
66
-
67
- // Show custom offline message (text is sanitized for security)
68
- dphelper.browser.offLine('⚠️ Connection Lost. Please check your internet.');
69
-
70
- // The overlay appears automatically when offline
71
- // and disappears when connection is restored
72
- ```
73
-
74
- ### Get Browser Zoom Level
75
-
76
- ```javascript
77
- const zoom = dphelper.browser.zoom();
78
- console.log(zoom); // 100 (or 150, 200, etc. depending on zoom)
79
-
80
- // Responsive design based on zoom
81
- if (zoom > 100) {
82
- document.body.classList.add('zoomed-in');
83
- }
84
- ```
85
-
86
- ### HTTP Status Code Descriptions
87
-
88
- ```javascript
89
- // Get description for common status codes
90
- console.log(dphelper.browser.status(200)); // "200 OK"
91
- console.log(dphelper.browser.status(201)); // "201 Created"
92
- console.log(dphelper.browser.status(301)); // "301 Moved Permanently"
93
- console.log(dphelper.browser.status(400)); // "400 Bad Request"
94
- console.log(dphelper.browser.status(401)); // "401 Unauthorized"
95
- console.log(dphelper.browser.status(403)); // "403 Forbidden"
96
- console.log(dphelper.browser.status(404)); // "404 Not Found"
97
- console.log(dphelper.browser.status(500)); // "500 Internal Server Error"
98
-
99
- // Display user-friendly error messages
100
- function handleApiError(statusCode) {
101
- const message = dphelper.browser.status(statusCode);
102
- alert(`Error: ${message}`);
103
- }
104
- ```
105
-
106
- ### Multi-Tab Synchronization
107
-
108
- ```javascript
109
- // Monitor active tabs of your application
110
- dphelper.browser.interlock((tabCount) => {
111
- console.log(`Active tabs: ${tabCount}`);
112
-
113
- if (tabCount > 1) {
114
- // Warn user about multiple tabs
115
- showNotification('This app is open in multiple tabs. Changes may conflict.');
116
- }
117
- });
118
-
119
- // Use BroadcastChannel for real-time sync between tabs
120
- const channel = new BroadcastChannel('app_sync');
121
- channel.postMessage({ type: 'UPDATE', data: 'new value' });
122
- ```
123
-
124
- ## Advanced Usage
125
-
126
- ### Complete SPA Navigation Handler
127
-
128
- ```javascript
129
- class Router {
130
- constructor() {
131
- this.routes = {};
132
-
133
- // Handle browser back/forward
134
- window.addEventListener('popstate', (e) => {
135
- this.navigate(window.location.pathname, false);
136
- });
137
- }
138
-
139
- addRoute(path, handler) {
140
- this.routes[path] = handler;
141
- }
142
-
143
- navigate(path, addToHistory = true) {
144
- const handler = this.routes[path];
145
- if (handler) {
146
- if (addToHistory) {
147
- dphelper.browser.state({ path }, 'App', path);
148
- }
149
- handler();
150
- }
151
- }
152
- }
153
-
154
- // Usage
155
- const router = new Router();
156
- router.addRoute('/', () => renderHome());
157
- router.addRoute('/about', () => renderAbout());
158
- router.addRoute('/dashboard', () => renderDashboard());
159
- ```
160
-
161
- ### Connection Status Manager
162
-
163
- ```javascript
164
- class ConnectionManager {
165
- constructor() {
166
- this.isOnline = navigator.onLine;
167
- this.listeners = [];
168
-
169
- window.addEventListener('online', () => {
170
- this.isOnline = true;
171
- this.notifyListeners();
172
- });
173
-
174
- window.addEventListener('offline', () => {
175
- this.isOnline = false;
176
- this.notifyListeners();
177
- });
178
-
179
- // Show offline overlay
180
- dphelper.browser.offLine('🔌 You are offline. Some features are disabled.');
181
- }
182
-
183
- onStatusChange(callback) {
184
- this.listeners.push(callback);
185
- }
186
-
187
- notifyListeners() {
188
- this.listeners.forEach(cb => cb(this.isOnline));
189
- }
190
- }
191
- ```
192
-
193
- ## Details
194
-
195
- - **Author:** Dario Passariello
196
- - **Version:** 0.0.2
197
- - **Creation Date:** 20210101
198
- - **Last Modified:** 20260220
199
- - **Environment:** Client-side only (browser)
200
-
201
- ---
202
-
203
- *Automatically generated document*
package/markdown/check.md DELETED
@@ -1,65 +0,0 @@
1
- # check
2
-
3
- Validation utilities for version comparison and other checks.
4
-
5
- ## Functions
6
-
7
- | Function | Description | Example |
8
- |----------|-------------|---------|
9
- | `version` | Compare two version strings | `dphelper.check.version('1.2.0', '1.1.0')` |
10
-
11
- ## Description
12
-
13
- Version comparison utilities:
14
- - **Semantic Versioning** - Compare version numbers
15
- - **Custom Options** - Lexicographic and zero-pad support
16
-
17
- ## Usage Examples
18
-
19
- ### Version Comparison
20
-
21
- ```javascript
22
- // Compare versions
23
- console.log(dphelper.check.version('1.2.0', '1.1.0')); // 1 (v1 > v2)
24
- console.log(dphelper.check.version('1.1.0', '1.2.0')); // -1 (v1 < v2)
25
- console.log(dphelper.check.version('1.0.0', '1.0.0')); // 0 (equal)
26
-
27
- // With zero padding
28
- console.log(dphelper.check.version('1.2', '1.2.0', { zero: true })); // 0
29
-
30
- // With lexicographic comparison
31
- console.log(dphelper.check.version('1.0.0a', '1.0.0b', { lex: true })); // -1
32
- ```
33
-
34
- ### Software Update Checker
35
-
36
- ```javascript
37
- function checkForUpdate(currentVersion, latestVersion) {
38
- const result = dphelper.check.version(currentVersion, latestVersion);
39
-
40
- if (result === 1) {
41
- console.log('Update available!');
42
- return 'Update available';
43
- } else if (result === 0) {
44
- console.log('You have the latest version.');
45
- return 'Up to date';
46
- } else {
47
- console.log('You are on a newer version.');
48
- return 'Ahead';
49
- }
50
- }
51
-
52
- checkForUpdate('1.0.0', '1.1.0'); // "Update available!"
53
- ```
54
-
55
- ## Details
56
-
57
- - **Author:** Dario Passariello
58
- - **Version:** 0.0.2
59
- - **Creation Date:** 20240829
60
- - **Last Modified:** 20240829
61
- - **Environment:** Works in both client and server environments
62
-
63
- ---
64
-
65
- *Automatically generated document*
package/markdown/color.md DELETED
@@ -1,159 +0,0 @@
1
- # color
2
-
3
- Color manipulation utilities for converting between color formats and generating color gradients.
4
-
5
- ## Functions
6
-
7
- | Function | Description | Example |
8
- |----------|-------------|---------|
9
- | `hex` | Converts a number (0-255) to hexadecimal | `dphelper.color.hex(255)` |
10
- | `toHex` | Converts RGB array to hex string | `dphelper.color.toHex([255, 128, 0])` |
11
- | `toRGB` | Converts hex string to RGB array | `dphelper.color.toRGB('#ff8000')` |
12
- | `oleColor` | Converts hex to OLE color format | `dphelper.color.oleColor('#ffffff')` |
13
- | `gradient` | Generates gradient between two colors | `dphelper.color.gradient('#ff0000', '#0000ff', 10)` |
14
-
15
- ## Description
16
-
17
- Comprehensive color manipulation tools:
18
- - **Format Conversion** - RGB ↔ Hex, OLE color format
19
- - **Gradient Generation** - Create smooth color transitions
20
- - **Number Formatting** - Convert color values to hex
21
-
22
- ## Usage Examples
23
-
24
- ### Number to Hex
25
-
26
- ```javascript
27
- // Convert a number to 2-digit hex
28
- console.log(dphelper.color.hex(0)); // "00"
29
- console.log(dphelper.color.hex(255)); // "ff"
30
- console.log(dphelper.color.hex(128)); // "80"
31
-
32
- // Clamps values outside 0-255
33
- console.log(dphelper.color.hex(300)); // "ff"
34
- console.log(dphelper.color.hex(-10)); // "00"
35
- ```
36
-
37
- ### RGB to Hex Conversion
38
-
39
- ```javascript
40
- // Convert RGB array to hex
41
- console.log(dphelper.color.toHex([255, 255, 255])); // "ffffff"
42
- console.log(dphelper.color.toHex([255, 0, 0])); // "ff0000"
43
- console.log(dphelper.color.toHex([0, 255, 0])); // "00ff00"
44
- console.log(dphelper.color.toHex([0, 0, 255])); // "0000ff"
45
- console.log(dphelper.color.toHex([255, 128, 0])); // "ff8000"
46
-
47
- // Common colors
48
- const orange = [255, 165, 0];
49
- console.log('#' + dphelper.color.toHex(orange)); // "#ffa500"
50
- ```
51
-
52
- ### Hex to RGB Conversion
53
-
54
- ```javascript
55
- // Convert hex to RGB array
56
- console.log(dphelper.color.toRGB('#ffffff')); // [255, 255, 255]
57
- console.log(dphelper.color.toRGB('#ff0000')); // [255, 0, 0]
58
- console.log(dphelper.color.toRGB('#00ff00')); // [0, 255, 0]
59
- console.log(dphelper.color.toRGB('#0000ff')); // [0, 0, 255]
60
-
61
- // Without hash
62
- console.log(dphelper.color.toRGB('ff8000')); // [255, 128, 0]
63
- ```
64
-
65
- ### OLE Color Conversion
66
-
67
- ```javascript
68
- // Convert to OLE color (used in older Windows APIs)
69
- console.log(dphelper.color.oleColor('#000000')); // "0"
70
- console.log(dphelper.color.oleColor('#ffffff')); // "16777215"
71
- console.log(dphelper.color.oleColor('#ff0000')); // "255"
72
- console.log(dphelper.color.oleColor('#00ff00')); // "65280"
73
- console.log(dphelper.color.oleColor('#0000ff')); // "16711680"
74
- ```
75
-
76
- ### Gradient Generation
77
-
78
- ```javascript
79
- // Generate gradient from red to blue
80
- const gradient = dphelper.color.gradient('#ff0000', '#0000ff', 10);
81
- console.log(gradient);
82
- // ["ff0000", "e61b1b", "cc3636", "b35151", "996c6c", "808080", "669696", "4dabab", "33c0c0", "1ad6d6", "0000ff"]
83
-
84
- // Useful for creating color scales
85
- const heatmapColors = dphelper.color.gradient('#0000ff', '#ff0000', 20);
86
-
87
- // Cool to warm gradient
88
- const sunrise = dphelper.color.gradient('#ff9a9e', '#fecfef', 15);
89
- ```
90
-
91
- ## Advanced Usage
92
-
93
- ### Color Utilities Class
94
-
95
- ```javascript
96
- class ColorUtils {
97
- static random() {
98
- const r = Math.floor(Math.random() * 256);
99
- const g = Math.floor(Math.random() * 256);
100
- const b = Math.floor(Math.random() * 256);
101
- return '#' + dphelper.color.toHex([r, g, b]);
102
- }
103
-
104
- static invert(hex) {
105
- const [r, g, b] = dphelper.color.toRGB(hex);
106
- return '#' + dphelper.color.toHex([255 - r, 255 - g, 255 - b]);
107
- }
108
-
109
- static lighten(hex, percent) {
110
- const [r, g, b] = dphelper.color.toRGB(hex);
111
- return '#' + dphelper.color.toHex([
112
- Math.min(255, Math.floor(r + (255 - r) * percent)),
113
- Math.min(255, Math.floor(g + (255 - g) * percent)),
114
- Math.min(255, Math.floor(b + (255 - b) * percent))
115
- ]);
116
- }
117
-
118
- static darken(hex, percent) {
119
- const [r, g, b] = dphelper.color.toRGB(hex);
120
- return '#' + dphelper.color.toHex([
121
- Math.max(0, Math.floor(r * (1 - percent))),
122
- Math.max(0, Math.floor(g * (1 - percent))),
123
- Math.max(0, Math.floor(b * (1 - percent)))
124
- ]);
125
- }
126
- }
127
-
128
- // Usage
129
- console.log(ColorUtils.random()); // "#a3b21c"
130
- console.log(ColorUtils.invert('#ff0000')); // "#00ffff"
131
- console.log(ColorUtils.lighten('#888888', 0.2)); // "#adadad"
132
- console.log(ColorUtils.darken('#888888', 0.2)); // "#636363"
133
- ```
134
-
135
- ### Dynamic Chart Colors
136
-
137
- ```javascript
138
- function generateChartColors(count) {
139
- const colors = [];
140
- for (let i = 0; i < count; i++) {
141
- const hue = (i * 360 / count) % 360;
142
- const rgb = this.hslToRgb(hue, 70, 50);
143
- colors.push('#' + dphelper.color.toHex(rgb));
144
- }
145
- return colors;
146
- }
147
- ```
148
-
149
- ## Details
150
-
151
- - **Author:** Dario Passariello
152
- - **Version:** 0.0.2
153
- - **Creation Date:** 20210101
154
- - **Last Modified:** 20260220
155
- - **Environment:** Client-side only (browser)
156
-
157
- ---
158
-
159
- *Automatically generated document*