dphelper 1.8.122 → 1.8.124

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.
@@ -28,17 +28,17 @@ All types of contributions are encouraged and valued. See the [Table of Contents
28
28
 
29
29
  ## Code of Conduct
30
30
 
31
- This project and everyone participating in it is governed by the [dphelper Code of Conduct](https://github.com/passariello/dphelper/blob/CODE_OF_CONDUCT.md). By participating, you are expected to uphold this code. Please report unacceptable behavior to [dariopassariello@gmail.com](mailto:dariopassariello@gmail.com).
31
+ This project and everyone participating in it is governed by the [dphelper Code of Conduct](https://github.com/a51-dev/a51.dphelper.public/blob/CODE_OF_CONDUCT.md). By participating, you are expected to uphold this code. Please report unacceptable behavior to [dariopassariello@gmail.com](mailto:dariopassariello@gmail.com).
32
32
 
33
33
  ## I Have a Question
34
34
 
35
35
  > If you want to ask a question, we assume that you have read the available [Documentation](https://passariello.gitbook.io/dphelper-devtools/).
36
36
 
37
- Before you ask a question, it is best to search for existing [Issues](https://github.com/passariello/dphelper/issues) that might help you. In case you have found a suitable issue and still need clarification, you can write your question in this issue. It is also advisable to search the internet for answers first.
37
+ Before you ask a question, it is best to search for existing [Issues](https://github.com/a51-dev/a51.dphelper.public/issues) that might help you. In case you have found a suitable issue and still need clarification, you can write your question in this issue. It is also advisable to search the internet for answers first.
38
38
 
39
39
  If you then still feel the need to ask a question and need clarification, we recommend the following:
40
40
 
41
- * Open an [Issue](https://github.com/passariello/dphelper/issues/new).
41
+ * Open an [Issue](https://github.com/a51-dev/a51.dphelper.public/issues/new).
42
42
  * Provide as much context as you can about what you're running into.
43
43
  * Provide project and platform versions (nodejs, npm, etc), depending on what seems relevant.
44
44
 
@@ -58,7 +58,7 @@ A good bug report shouldn't leave others needing to chase you up for more inform
58
58
 
59
59
  * Make sure that you are using the latest version.
60
60
  * Determine if your bug is really a bug and not an error on your side e.g. using incompatible environment components/versions (Make sure that you have read the [documentation](https://passariello.gitbook.io/dphelper-devtools/). If you are looking for support, you might want to check [this section](contributing.md#i-have-a-question)).
61
- * To see if other users have experienced (and potentially already solved) the same issue you are having, check if there is not already a bug report existing for your bug or error in the [bug tracker](https://github.com/passariello/dphelper/issues?q=label%3Abug).
61
+ * To see if other users have experienced (and potentially already solved) the same issue you are having, check if there is not already a bug report existing for your bug or error in the [bug tracker](https://github.com/a51-dev/a51.dphelper.public/issues?q=label%3Abug).
62
62
  * Also make sure to search the internet (including Stack Overflow) to see if users outside of the GitHub community have discussed the issue.
63
63
  * Collect information about the bug:
64
64
  * Stack trace (Traceback)
@@ -73,7 +73,7 @@ A good bug report shouldn't leave others needing to chase you up for more inform
73
73
 
74
74
  We use GitHub issues to track bugs and errors. If you run into an issue with the project:
75
75
 
76
- * Open an [Issue](https://github.com/passariello/dphelper/issues/new). (Since we can't be sure at this point whether it is a bug or not, we ask you not to talk about a bug yet and not to label the issue.)
76
+ * Open an [Issue](https://github.com/a51-dev/a51.dphelper.public/issues/new). (Since we can't be sure at this point whether it is a bug or not, we ask you not to talk about a bug yet and not to label the issue.)
77
77
  * Explain the behavior you would expect and the actual behavior.
78
78
  * Please provide as much context as possible and describe the _reproduction steps_ that someone else can follow to recreate the issue on their own. This usually includes your code. For good bug reports you should isolate the problem and create a reduced test case.
79
79
  * Provide the information you collected in the previous section.
@@ -92,12 +92,12 @@ This section guides you through submitting an enhancement suggestion for dphelpe
92
92
 
93
93
  * Make sure that you are using the latest version.
94
94
  * Read the [documentation](https://passariello.gitbook.io/dphelper-devtools/) carefully and find out if the functionality is already covered, maybe by an individual configuration.
95
- * Perform a [search](https://github.com/passariello/dphelper/issues) to see if the enhancement has already been suggested. If it has, add a comment to the existing issue instead of opening a new one.
95
+ * Perform a [search](https://github.com/a51-dev/a51.dphelper.public/issues) to see if the enhancement has already been suggested. If it has, add a comment to the existing issue instead of opening a new one.
96
96
  * Find out whether your idea fits with the scope and aims of the project. It's up to you to make a strong case to convince the project's developers of the merits of this feature. Keep in mind that we want features that will be useful to the majority of our users and not just a small subset. If you're just targeting a minority of users, consider writing an add-on/plugin library.
97
97
 
98
98
  #### How Do I Submit a Good Enhancement Suggestion?
99
99
 
100
- Enhancement suggestions are tracked as [GitHub issues](https://github.com/passariello/boilerplate/issues).
100
+ Enhancement suggestions are tracked as [GitHub issues](https://github.com/a51-dev/a51.dphelper.public/issues).
101
101
 
102
102
  * Use a **clear and descriptive title** for the issue to identify the suggestion.
103
103
  * Provide a **step-by-step description of the suggested enhancement** in as many details as possible.
@@ -0,0 +1,311 @@
1
+ # dpHelper
2
+
3
+ ![dpHelper](https://raw.githubusercontent.com/passariello/container/refs/heads/main/dphelper/assets/images/banner.svg)
4
+
5
+ **Manager | DevTools** by [Dario Passariello](https://dario.passariello.ca) (c)
6
+
7
+ [![version](https://img.shields.io/npm/v/dphelper.svg)](https://npmjs.org/package/dphelper)
8
+ [![downloads](https://img.shields.io/npm/dm/dphelper.svg)](https://npmjs.org/package/dphelper)
9
+ ![TypeScript](https://img.shields.io/badge/TypeScript-006b98?logo=TypeScript&logoColor=white)
10
+
11
+ ![dphelper](https://img.shields.io/badge/dphelper-npm-green?logo=dphelper&logoColor=white)
12
+ ![browser extension](https://img.shields.io/badge/browser%20extension-beta-orange.svg)
13
+
14
+ <!--
15
+ [![dphelper](https://snyk.io/advisor/npm-package/dphelper/badge.svg)](https://snyk.io/advisor/npm-package/dphelper)
16
+ [![Socket Badge](https://socket.dev/api/badge/npm/package/dphelper)](https://socket.dev/npm/package/dphelper)
17
+ -->
18
+
19
+ ## About 🔥
20
+
21
+ dpHelper is a precise and complete collection of 190+ tools ready to use in all web/SaaS applications. State and Store Management are now easy, accessible everywhere in your application, including Ajax or React apps, without the need for extra files.
22
+
23
+ 1. __Single Source of Truth__: The application's entire state is held within a single object in one store, ensuring consistent and accessible state management throughout the app.
24
+
25
+ 2. __State is flexible__: State changes are facilitated exclusively through actions. These actions, which are straightforward JavaScript objects, delineate what has occurred. This methodology ensures that state changes remain predictable.
26
+
27
+ 3. __Changes are made with proxy handle function__: To define state changes, dpHelper employs pure functions as intermediaries. These functions accept the current state as input and produce a new state as output, ensuring predictability and ease of testing in the system.
28
+
29
+ ### Example in React
30
+
31
+ ```javascript
32
+ import { useEffect } from 'react';
33
+ import 'dphelper';
34
+
35
+ function App() {
36
+ // Store a value in the state
37
+ state.test = 'Hello, World!';
38
+
39
+ // Use the stored value in a React component
40
+ useEffect(() => {
41
+ console.log("You can recall from all pages: " + state.test); // Output: "Hello, World!"
42
+ }, []);
43
+
44
+ return (
45
+ <div>
46
+ <h1>{state.test}</h1>
47
+ </div>
48
+ );
49
+ }
50
+
51
+ export default App;
52
+ ```
53
+
54
+ ## Live Demo
55
+
56
+ [https://a51.dev/tests/](https://a51.dev/tests/)
57
+
58
+ You can see an HTML version where dpHelper and LayerPro work together seamlessly. dpHelper is compatible with a variety of frontend libraries, including:
59
+ * HTML
60
+ * React
61
+ * Vue
62
+ * And any other frontend library
63
+
64
+ ## Documentation
65
+
66
+ You can see:
67
+ - [State](https://passariello.gitbook.io/dphelper-devtools/general/state)
68
+ - [Store](https://passariello.gitbook.io/dphelper-devtools/general/store)
69
+ - [Observer](https://passariello.gitbook.io/dphelper-devtools/general/observer)
70
+ - [List of functions](https://passariello.gitbook.io/dphelper-devtools/general/tools)
71
+
72
+ You can see more tutorials, information, and examples about **dpHelper** [clicking here](https://passariello.gitbook.io/dphelper-devtools).
73
+
74
+ ## Usage
75
+
76
+ Install dpHelper.
77
+
78
+ ```shell
79
+ npm i dphelper --save-dev
80
+ ```
81
+
82
+ or update:
83
+
84
+ ```shell
85
+ npm i dphelper@latest --save-dev
86
+ ```
87
+
88
+ Use it in the main root file (and only there):
89
+
90
+ ```javascript
91
+ import "dphelper";
92
+ ```
93
+
94
+ or
95
+
96
+ ```javascript
97
+ require("dphelper");
98
+ ```
99
+
100
+ ## Install for EJS or Other Types of Projects (like HTML)
101
+
102
+ Note: You don't need to use npm install in this case, or you will get an error.
103
+
104
+ ```html
105
+ <script src="https://cdn.jsdelivr.net/npm/dphelper@latest"></script>
106
+ ```
107
+
108
+ ## The Best Way To Use State 💥
109
+
110
+ ### Using the "state" Function
111
+
112
+ You can use the state function to store and reuse data throughout your application. Similar to other state managers, you can save state information in JSON format and access it easily in various contexts, including React useEffect and/or dispatch.
113
+
114
+ For example, you can store a value like this: _state.test = 'I am ready'_ and then retrieve it later using state.test.
115
+
116
+ _example:_
117
+
118
+ You can use the browser's devtools console and type " **state.test = 'I am ready'** ". Every time you want to use '**test**' values, you need just recall **state.test**.
119
+
120
+ ```javascript
121
+ // Set a state
122
+ state.test = "I am ready" *
123
+
124
+ // Get the state
125
+ state.test *
126
+
127
+ // List all states
128
+ state.list // or just "state" to see the proxy
129
+
130
+ // Lock a state from edit (Only for Objects or Array)
131
+ state.test.lock() *
132
+
133
+ // Remove a state
134
+ state.remove("test")
135
+
136
+ // Remove all states
137
+ state.removeAll()
138
+
139
+ *["test" is only an example]
140
+
141
+ ```
142
+
143
+ ### Observer 😎 for States
144
+
145
+ **Note**: _Observer works only with states. Stores are excluded at the moment._
146
+
147
+ If you want to run a function every time a state changes, you can use:
148
+
149
+ ```javascript
150
+ /**
151
+ * Observer is a non-cumulative listener,
152
+ * triggered from customEvent / dispatch from state
153
+ * @parameters
154
+ * [ state | store, function ]
155
+ */
156
+ observer( "state.test", () => alert("Test Changes to: " + state.test) )
157
+ |__________| |___________________________________________|
158
+ State: string Function
159
+
160
+ PS: you need to use the name of state | store as string
161
+ ```
162
+
163
+ You can use it everywhere. Works like "useState" in React but with more flexibility (use one observer for each state!).
164
+
165
+ ### Example:
166
+
167
+ ```javascript
168
+ import 'dphelper';
169
+
170
+ // Use the observer to log the changing state value
171
+ observer(
172
+ 'state.count',
173
+ () => console.log("State changed: ", state.count)
174
+ );
175
+
176
+ // Store a value in the state that changes every 5 seconds
177
+ setInterval(() => state.count = Date.now(), 5000);
178
+ ```
179
+
180
+ #### Another Simple Example:
181
+
182
+ ```javascript
183
+ import 'dphelper';
184
+
185
+ // Set a state
186
+ state.myData = 'Hello, world!';
187
+
188
+ // Retrieve the state
189
+ console.log(state.myData); // Output: Hello, world!
190
+
191
+ // Observe state changes
192
+ observer('myData', () => {
193
+ console.log('myData has changed to:', state.myData);
194
+ });
195
+
196
+ // Change the state
197
+ state.myData = 'New value';
198
+ ```
199
+
200
+ ## The Best Way To Use Store 🫙
201
+
202
+ ### Persistent Storage with dpHelper
203
+
204
+ When using dpHelper for permanent storage, you should use the **store**, which stores data persistently across sessions.
205
+
206
+ #### Important Security Note
207
+
208
+ 1. **Use store for persistent storage:** If you want to store data permanently, use store to ensure it is saved in localStorage.
209
+
210
+ 2. **Remove data when necessary:** To maintain security, remove stored data when it is no longer needed, such as during logout.
211
+
212
+ 3. **Remove all stored data:** Use store.removeAll() to securely remove all stored data from your application.
213
+
214
+ ```javascript
215
+ // Set a store:
216
+ store.set("test", { test: "test" })
217
+
218
+ // Get a store:
219
+ store.get("test") // Output: { test: "test" }
220
+
221
+ // Remove a store:
222
+ store.remove("test") // Output: "ok"
223
+
224
+ // Remove all stores:
225
+ store.removeAll() // Output: "ok"
226
+ ```
227
+
228
+ ### Example in React
229
+
230
+ ```javascript
231
+ import { useEffect } from 'react';
232
+ import 'dphelper';
233
+
234
+ function App() {
235
+
236
+ // Store a value in the store (persistent storage)
237
+ store.set(
238
+ 'user',
239
+ {
240
+ name: 'John Doe',
241
+ age: 30
242
+ }
243
+ );
244
+
245
+ // Use the stored value in a React component
246
+ useEffect(
247
+ () => {
248
+ console.log(store.get("user")); // Output: { name: "John Doe", age: 30 }
249
+ $("#name").text(store.get("user").name)
250
+ }, []
251
+ );
252
+
253
+ // Remove all stored data if necessary
254
+ // store.removeAll();
255
+
256
+ return (
257
+ <div>
258
+ <h1 id="name">...</h1>
259
+ </div>
260
+ );
261
+ }
262
+
263
+ export default App;
264
+ ```
265
+
266
+ ## Console It!
267
+
268
+ Type **dphelper** in the devtool console of your browser to have a look at all available tools that you can use! You can call these from everywhere without import (just one time in the main/root page).
269
+
270
+ ## Browser Extension (Chrome/Edge) ♥️
271
+
272
+ ![browser extension](https://img.shields.io/badge/browser%20extension-beta-orange.svg)
273
+
274
+ ![dphelper Banner](https://raw.githubusercontent.com/passariello/container/refs/heads/main/dphelper/assets/images/banner.png)
275
+
276
+ ![dphelper Banner](https://raw.githubusercontent.com/passariello/container/refs/heads/main/dphelper/assets/images/screenshot.png)
277
+
278
+ Chrome: [Download from Google Web Store](https://chrome.google.com/webstore/detail/dphelper-manager-dev-tool/oppppldaoknfddeikfloonnialijngbk)
279
+
280
+ Edge: [Download from Microsoft Addons](https://microsoftedge.microsoft.com/addons/detail/dphelper-manager-dev-to/kphabkbdpaljlfagldhojilhfammepnk)
281
+
282
+ PS: **dpHelper** is compatible with all Chromium-based browsers like **Edge or Brave**!
283
+
284
+ ## dpHelper Browser Extension
285
+
286
+ The dpHelper browser extension allows you to manage your application's dpHelper NPM. Key features include:
287
+
288
+ 1. Simplified API operations: Easily manage and manipulate data with dpHelper's collection of scripts.
289
+ 2. Real-time monitoring: Track memory usage and localStorage to optimize your application's performance.
290
+ 3. Stay up-to-date: Receive updates and tips to improve your daily workflow.
291
+ 4. Easy installation: Simply import 'dphelper' in your project index to get started.
292
+ 5. Global accessibility: All scripts are available globally and can be accessed from anywhere in your application.
293
+
294
+ ## Check
295
+
296
+ [Socket.dev](https://socket.dev/npm/package/dphelper)
297
+
298
+ [Snyk.io](https://security.snyk.io/package/npm/dphelper)
299
+
300
+ ## License
301
+
302
+ [MIT - https://en.wikipedia.org/wiki/MIT_License](https://en.wikipedia.org/wiki/MIT_License)
303
+
304
+ - [LICENCE](https://passariello.gitbook.io/dphelper-devtools/documents/license)
305
+ - [CODE OF CONDUCT](https://passariello.gitbook.io/dphelper-devtools/documents/code_of_conduct)
306
+ - [SECURITY](https://passariello.gitbook.io/dphelper-devtools/documents/security)
307
+ - [CONTRIBUTING](https://passariello.gitbook.io/dphelper-devtools/documents/contributing)
308
+
309
+ ---
310
+
311
+ Dario Passariello - dariopassariello@gmail.com, All rights reserved - Copyright (c) 2019 - 2024