react-globo-state 1.0.2 → 1.0.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
@@ -57,20 +57,40 @@ const App = () => {
57
57
  // now you can use your global react state everywhere.
58
58
  // you can use also in useEffect and Dispatch
59
59
 
60
- // Create a state
60
+ /**
61
+ * Create a state
62
+ * @param name - Name of the gstate
63
+ * @param item - Object, string, number, boolean, array
64
+ * @returns - Void
65
+ */
61
66
  gState.set("name", { test:"test" })
62
67
 
63
- // Get a state
68
+ /**
69
+ * Get a state
70
+ * @param name - Name of the gstate
71
+ * @returns - Void
72
+ */
64
73
  gState.get("name")
65
74
 
66
- // Remove a state
75
+ /**
76
+ * Remove a state
77
+ * @param name - Name of the gstate
78
+ * @returns - Void
79
+ */
67
80
  gState.remove("name")
68
81
  // or
69
82
  gState.delete("name")
70
83
 
71
- // gState.deleteAll() // coming soon
84
+ /**
85
+ * Delete all items from gState
86
+ * @returns - Void
87
+ */
88
+ gState.deleteAll()
72
89
 
73
- // List all states
90
+ /**
91
+ * List all states
92
+ * @returns - Void
93
+ */
74
94
  gState.list()
75
95
 
76
96
  ```
package/global.d.ts ADDED
@@ -0,0 +1,50 @@
1
+ /*!
2
+ Copyright (c) 2025 Dario Passariello <dariopassariello@gmail.com>
3
+ Licensed under MIT License, see
4
+ https://dario.passariello.ca
5
+ */
6
+
7
+ declare module 'gState'
8
+ declare module 'globoState'
9
+
10
+ interface _gState {
11
+ /**
12
+ * Create a state
13
+ * @param name - Name of the gstate
14
+ * @param item - Object, string, number, boolean, array
15
+ * @returns - Void
16
+ */
17
+ set: (name: string, value: string | number | string[] | object) => void,
18
+
19
+ /**
20
+ * Get a state
21
+ * @param name - Name of the gstate
22
+ * @returns - Void
23
+ */
24
+ get: (name: string) => void,
25
+
26
+ /**
27
+ * Remove a state
28
+ * @param name - Name of the gstate
29
+ * @returns - Void
30
+ */
31
+ remove: (name: string) => void,
32
+ delete: (name: string) => void,
33
+
34
+ /**
35
+ * Delete all items from gState
36
+ * @returns - Void
37
+ */
38
+ deleteAll: () => void,
39
+
40
+ /**
41
+ * List all states
42
+ * @returns - Void
43
+ */
44
+ list: () => void
45
+ }
46
+
47
+ declare var gState: _gState
48
+ type gState = _gState
49
+
50
+ globalThis.gState = _gState
package/index.js CHANGED
@@ -1 +1 @@
1
- import{useState as n}from"react";const e={},u=()=>{const[r,o]=n(null);return globalThis.gState={get:t=>{if(t&&t)return r?.[t]?r[t]:null},set:(t,l)=>{!t||!l||(e[t]=l,o({...e}))},remove:t=>{t&&(delete e[t],o({...e}))},delete:t=>{t&&gState.remove(t)},list:()=>r},u};var f=u;export{f as default,u as globoState};
1
+ import{useState as u}from"react";const e={},n=()=>{const[r,l]=u(null);globalThis.gState={get:t=>{if(t&&t)return r?.[t]?r[t]:null},set:(t,o)=>{!t||!o||(e[t]=o,l({...e}))},remove:t=>{t&&(delete e[t],l({...e}))},delete:t=>{t&&gState.remove(t)},deleteAll:()=>{l({})},list:()=>r}};var g=n;export{g as default};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-globo-state",
3
- "version": "1.0.2",
3
+ "version": "1.0.6",
4
4
  "description": "A react state everywhere made easy",
5
5
  "keywords": [
6
6
  "react",
@@ -10,18 +10,32 @@
10
10
  "dario",
11
11
  "passariello"
12
12
  ],
13
+ "files": [
14
+ "index.js",
15
+ "global.d.ts"
16
+ ],
13
17
  "license": "MIT",
14
18
  "author": "Dario Passariello",
15
19
  "type": "module",
16
20
  "main": "./index.js",
17
- "types": "./index.d.ts",
18
- "dependencies": {
19
- "react": "^19.2.3"
21
+ "types": "./global.d.ts",
22
+ "typings": "./global",
23
+ "extends": "./tsconfig.json",
24
+ "exports": {
25
+ ".": {
26
+ "types": "./global.d.ts",
27
+ "default": "./index.js"
28
+ },
29
+ "./package.json": "./package.json",
30
+ "./*": "./*"
20
31
  },
21
32
  "scripts": {
22
33
  "build": "node ./esbuild.config.mjs",
23
34
  "npm:publish": "npm run build && npm publish ./dist"
24
35
  },
36
+ "dependencies": {
37
+ "react": "^19.2.3"
38
+ },
25
39
  "devDependencies": {
26
40
  "@typescript-eslint/eslint-plugin": "8.53.0",
27
41
  "@typescript-eslint/parser": "8.53.0",
@@ -29,7 +43,6 @@
29
43
  "esbuild-plugin-copy": "2.1.1",
30
44
  "eslint": "9.39.2",
31
45
  "ts-jest": "29.4.6",
32
- "ts-node": "^10.9.2",
33
46
  "tslib": "^2.8.1",
34
47
  "typescript": "^5.9.3"
35
48
  }
package/CODEOWNERS DELETED
@@ -1 +0,0 @@
1
- * @passariello
package/COPYRIGHT.md DELETED
@@ -1,4 +0,0 @@
1
- # Copyright
2
-
3
- Copyright (c) 2025, Dario Passariello. All rights reserved.
4
- <https://dario.passariello.ca>
package/SECURITY.md DELETED
@@ -1,3 +0,0 @@
1
- # Security
2
-
3
- Please email [@passariello](https://github.com/passariello) or see <https://dario.passariello.ca/contact/> if you have a potential security vulnerability to report.
package/index.d.ts DELETED
@@ -1,9 +0,0 @@
1
- /*!
2
- Copyright (c) 2025 Dario Passariello <dariopassariello@gmail.com>
3
- Licensed under MIT License, see
4
- https://dario.passariello.ca
5
- */
6
-
7
-
8
- declare var gState = {} as any
9
- type gState = {}