react-globo-state 1.3.0 → 2.0.0

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-globo-state",
3
- "version": "1.3.0",
3
+ "version": "2.0.0",
4
4
  "description": "A react state everywhere made easy",
5
5
  "keywords": [
6
6
  "gState",
@@ -14,40 +14,61 @@
14
14
  "dario",
15
15
  "passariello"
16
16
  ],
17
- "files": [
18
- "index.js",
19
- "global.d.ts"
20
- ],
21
17
  "license": "MIT",
22
18
  "author": "Dario Passariello",
23
19
  "type": "module",
24
- "main": "./index.js",
25
- "types": "./global.d.ts",
26
- "typings": "./global",
27
- "extends": "./tsconfig.json",
28
20
  "exports": {
29
21
  ".": {
30
- "types": "./global.d.ts",
31
- "default": "./index.js"
22
+ "types": "./dist/index.d.ts",
23
+ "default": "./dist/index.js"
24
+ },
25
+ "./advanced": {
26
+ "types": "./dist/advanced.d.ts",
27
+ "default": "./dist/advanced.js"
32
28
  },
33
- "./package.json": "./package.json",
34
- "./*": "./*"
29
+ "./package.json": "./package.json"
35
30
  },
31
+ "main": "./dist/index.js",
32
+ "types": "./dist/global.d.ts",
33
+ "typings": "./dist/global.d.ts",
34
+ "files": [
35
+ "dist"
36
+ ],
36
37
  "scripts": {
37
- "build": "node ./esbuild.config.mjs",
38
+ "build": "tsc --emitDeclarationOnly --outDir dist && node ./esbuild.config.mjs",
39
+ "type-check": "tsc --noEmit",
40
+ "test": "jest --config tests/jest/jest.config.ts",
41
+ "test:pw": "playwright test --config tests/playwright/playwright.config.ts",
42
+ "lint": "eslint . --ext .ts,.tsx",
43
+ "lint:fix": "eslint . --ext .ts,.tsx --fix",
38
44
  "npm:publish": "npm run build && npm publish ./dist"
39
45
  },
40
46
  "dependencies": {
41
- "react": "^19.2.4"
47
+ "immer": "^11.1.4"
48
+ },
49
+ "peerDependencies": {
50
+ "react": ">=16.8.0",
51
+ "react-dom": ">=16.8.0"
42
52
  },
43
53
  "devDependencies": {
44
- "@typescript-eslint/eslint-plugin": "8.54.0",
45
- "@typescript-eslint/parser": "8.54.0",
46
- "esbuild": "0.27.2",
54
+ "@playwright/test": "1.58.2",
55
+ "@testing-library/dom": "10.4.1",
56
+ "@testing-library/jest-dom": "6.9.1",
57
+ "@testing-library/react": "16.3.2",
58
+ "@types/jest": "30.0.0",
59
+ "@types/node": "25.2.3",
60
+ "@types/react": "19.2.14",
61
+ "@types/react-dom": "19.2.3",
62
+ "@typescript-eslint/eslint-plugin": "^8.55.0",
63
+ "@typescript-eslint/parser": "^8.55.0",
64
+ "dphelper": "2.6.3",
65
+ "esbuild": "0.27.3",
47
66
  "esbuild-plugin-copy": "2.1.1",
48
- "eslint": "9.39.2",
67
+ "eslint": "^10.0.0",
68
+ "jest": "30.2.0",
69
+ "jest-environment-jsdom": "30.2.0",
49
70
  "ts-jest": "29.4.6",
50
71
  "tslib": "^2.8.1",
51
72
  "typescript": "^5.9.3"
52
73
  }
53
- }
74
+ }
package/LICENSE DELETED
@@ -1,9 +0,0 @@
1
- # MIT license
2
-
3
- Copyright 1995 - 2026 Dario Passariello
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6
-
7
- The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8
-
9
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
package/README.md DELETED
@@ -1,140 +0,0 @@
1
- # [React Globo State - gState.](https://npmjs.com/package/react-globo-state)
2
-
3
- **React Globo State** by [Dario Passariello](https://dario.passariello.ca) (c)
4
-
5
- [![version](https://img.shields.io/npm/v/react-globo-state.svg)](https://npmjs.org/package/react-globo-state)
6
- [![downloads](https://img.shields.io/npm/dm/react-globo-state.svg)](https://npmjs.org/package/react-globo-state)
7
-
8
- ![TypeScript](https://img.shields.io/badge/TypeScript-gray?logo=typescript)
9
- ![React](https://img.shields.io/badge/React-gray?logo=react)
10
- ![ESLint](https://img.shields.io/badge/ESLint-gray?logo=eslint)
11
- ![License](https://img.shields.io/badge/license-MIT-blue.svg)
12
-
13
- ## 🚀 Ultra-Optimized React State Engine
14
-
15
- A tiny, blazing-fast state container designed for modern React applications. Built for developers who demand **maximum performance**, **minimal re-renders**, and **predictable reactivity** without the overhead of traditional state managers.
16
-
17
- ### ⚡ Why this package exists
18
-
19
- React's built-in state works well for small components, but as your app scales, you start battling unnecessary renders, complex memoization, and context bloat. This package delivers a **super-optimized state layer** that updates only what truly needs to update.
20
-
21
- ### 🧠 Key Features
22
-
23
- - **Granular subscriptions** - Components re-render only when the specific data they use changes.
24
- - **Reduce useMEmo use** - Help you to architect a better structure of your application avoid tons of useMemo.
25
- - **Single container** - Only one container for entire state. No more lost states or not necessary data in memory.
26
- - **No more imports** - Only one import and ready to work... everywhere.
27
- - **Zero dependencies** - Lightweight and ideal for high-performance apps or micro-frontend.
28
- - **Immutable-friendly** - Works seamlessly with immutable patterns while staying fast.
29
- - **Concurrent-mode ready** - Designed for React and future-proofed for modern rendering.
30
- - **TypeScript first** - Fully typed API for safe, predictable state flows.
31
-
32
- ### 🧩 Perfect for
33
-
34
- - High-frequency UI updates (dashboards, 3D apps, visualizers)
35
- - Enterprise-scale applications
36
- - Performance-critical components
37
- - Developers who want a simple API with extreme optimization
38
-
39
- ### 🛠️ How it works
40
-
41
- The engine uses a **subscription-based reactive core** with micro-level diffing. Only the components that depend on changed values re-render. No proxies, no global invalidation, no magic just deterministic, high-performance state management.
42
-
43
- ## install
44
-
45
- ```bash
46
- npm i -D react-globo-state
47
- ```
48
-
49
- You use:
50
-
51
- ```javascript
52
-
53
- // Import the init
54
- import "react-globo-state"
55
-
56
- // start the state
57
- // * need to be inside your App() only at top and one time...
58
-
59
- globoState()
60
-
61
- ```
62
-
63
- > now you can use your global react state everywhere.
64
-
65
- ## EXAMPLE
66
-
67
- ```js
68
- import "react-globo-state"
69
-
70
- const App = () => {
71
-
72
- // init gState
73
- globoState()
74
-
75
- useEffect(
76
- ()=>{
77
- gState.set("test",{ myNewReactState: "hello world!" })
78
- },[]
79
- )
80
-
81
- return <div>
82
- {
83
- gState.get("test").myNewReactState // result -> hello world!
84
- }
85
- </div>
86
-
87
- }
88
-
89
- ```
90
-
91
- ## how works and use
92
-
93
- ```js
94
-
95
- // now you can use your global react state everywhere.
96
- // you can use also in useEffect and Dispatch
97
-
98
- /**
99
- * Create a state
100
- * @param name - Name of the gstate
101
- * @param item - Object, string, number, boolean, array
102
- * @returns - true
103
- */
104
- gState.set("name", { test:"test" })
105
-
106
- /**
107
- * Get a state
108
- * @param name - Name of the gstate
109
- * @returns - items
110
- */
111
- gState.get("name")
112
-
113
- /**
114
- * Remove a state
115
- * @param name - Name of the gstate
116
- * @returns - items
117
- */
118
- gState.remove("name")
119
- // or
120
- gState.delete("name")
121
-
122
- /**
123
- * Delete all items from gState
124
- * @returns - true
125
- */
126
- gState.deleteAll()
127
-
128
- /**
129
- * List all states
130
- * @returns - items
131
- */
132
- gState.list()
133
-
134
- ```
135
-
136
- ## See a demo
137
-
138
- If you are interested to see a demo live visit [EXAMPLEPAGE](https://examplepage.picla.net) and look the console.
139
-
140
- Thank you!
package/global.d.ts DELETED
@@ -1,60 +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
- declare module 'gState'
8
- declare module 'globoState'
9
-
10
- interface _gState {
11
-
12
- /**
13
- * Dynamic index signature for additional properties
14
- * @private
15
- */
16
- [key: string]: any
17
-
18
-
19
- /**
20
- * Create a state
21
- * @param name - Name of the gstate
22
- * @param item - Object, string, number, boolean, array
23
- * @returns - true
24
- */
25
- set: (name: string, value: string | number | string[] | object) => true,
26
-
27
- /**
28
- * Get a state
29
- * @param name - Name of the gstate
30
- * @returns - value
31
- */
32
- get: (name: string) => value,
33
-
34
- /**
35
- * Remove a state
36
- * @param name - Name of the gstate
37
- * @returns - true
38
- */
39
- remove: (name: string) => true,
40
- delete: (name: string) => true,
41
-
42
- /**
43
- * Delete all items from gState
44
- * @returns - Void
45
- */
46
- deleteAll: () => true,
47
-
48
- /**
49
- * List all states
50
- * @returns - Void
51
- */
52
- list: () => values
53
- }
54
-
55
- declare var globoState: () => void
56
-
57
- declare var gState: _gState
58
- type gState = _gState
59
-
60
- globalThis.gState = _gState
package/index.js DELETED
@@ -1 +0,0 @@
1
- import{useState as n}from"react";const t={};Object.defineProperty(globalThis,"globoState",{value:()=>{const[r,u]=n(null);Object.defineProperty(globalThis,"gState",{value:{get:e=>{if(e)return r?.[e]?r[e]:null},set:(e,l)=>{if(!(!e||!l))return t[e]=l,u({...t}),!0},remove:e=>{if(e)return delete t[e],u({...t}),!0},delete:e=>{if(e)return gState.remove(e),!0},deleteAll:()=>(u({}),!0),list:()=>r},configurable:!0,enumerable:!1}),Object.freeze("gState")},configurable:!0,enumerable:!1});Object.freeze("globoState");