Skip to content

Commit e05f885

Browse files
authored
Merge pull request #24 from react18-tools/minify
Minify
2 parents d651845 + f52cf79 commit e05f885

13 files changed

Lines changed: 73 additions & 44 deletions

File tree

examples/nextjs/CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
# nextjs-example
22

3+
## 0.0.14
4+
5+
### Patch Changes
6+
7+
- Updated dependencies
8+
- r18gs@1.0.2
9+
- shared-ui@0.0.0
10+
311
## 0.0.13
412

513
### Patch Changes

examples/nextjs/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "nextjs-example",
3-
"version": "0.0.13",
3+
"version": "0.0.14",
44
"private": true,
55
"scripts": {
66
"dev": "next dev",
@@ -20,7 +20,7 @@
2020
},
2121
"devDependencies": {
2222
"@next/eslint-plugin-next": "^14.2.3",
23-
"@types/node": "^20.12.7",
23+
"@types/node": "^20.12.8",
2424
"@types/react": "^18.3.1",
2525
"@types/react-dom": "^18.3.0",
2626
"eslint-config-custom": "workspace:*",

examples/remix/CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
# remix-example
22

3+
## 0.0.14
4+
5+
### Patch Changes
6+
7+
- Updated dependencies
8+
- r18gs@1.0.2
9+
- shared-ui@0.0.0
10+
311
## 0.0.13
412

513
### Patch Changes

examples/remix/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "remix-example",
3-
"version": "0.0.13",
3+
"version": "0.0.14",
44
"private": true,
55
"sideEffects": false,
66
"type": "module",

examples/vite/CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
# vite-example
22

3+
## 0.0.14
4+
5+
### Patch Changes
6+
7+
- Updated dependencies
8+
- r18gs@1.0.2
9+
- shared-ui@0.0.0
10+
311
## 0.0.13
412

513
### Patch Changes

examples/vite/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "vite-example",
33
"private": true,
4-
"version": "0.0.13",
4+
"version": "0.0.14",
55
"type": "module",
66
"scripts": {
77
"dev": "vite --port 3001",
@@ -27,6 +27,6 @@
2727
"eslint-plugin-react-hooks": "^4.6.2",
2828
"eslint-plugin-react-refresh": "^0.4.6",
2929
"typescript": "^5.4.5",
30-
"vite": "^5.2.10"
30+
"vite": "^5.2.11"
3131
}
3232
}

lib/r18gs/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# r18gs
22

3+
## 1.0.2
4+
5+
### Patch Changes
6+
7+
- Refactor to reduce minzip size
8+
39
## 1.0.1
410

511
### Patch Changes

lib/r18gs/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "r18gs",
33
"author": "Mayank Kumar Chaudhari <https://mayank-chaudhari.vercel.app>",
44
"private": false,
5-
"version": "1.0.1",
5+
"version": "1.0.2",
66
"description": "A simple yet elegant, light weight, react18 global store to replace Zustand for better tree shaking.",
77
"main": "./dist/index.js",
88
"types": "./dist/index.d.ts",
@@ -28,9 +28,9 @@
2828
"lint": "eslint ."
2929
},
3030
"devDependencies": {
31-
"@testing-library/react": "^15.0.5",
31+
"@testing-library/react": "^15.0.6",
3232
"@turbo/gen": "^1.13.3",
33-
"@types/node": "^20.12.7",
33+
"@types/node": "^20.12.8",
3434
"@types/react": "^18.3.1",
3535
"@types/react-dom": "^18.3.0",
3636
"@vitejs/plugin-react": "^4.2.1",

lib/r18gs/src/index.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,11 @@ export type { SetterArgType, SetStateAction, Plugin } from "./utils";
2020
* @param value - Initial value of the store.
2121
* @returns - A tuple (Ordered sequance of values) containing the state and a function to set the state.
2222
*/
23-
export default function useRGS<T>(key: string, value?: T): [T, SetStateAction<T>] {
23+
const useRGS = <T>(key: string, value?: T): [T, SetStateAction<T>] => {
2424
/** Initialize the named store when invoked for the first time. */
2525
if (!globalRGS[key]) globalRGS[key] = [value, [], createSetter(key), createSubcriber(key)];
2626

2727
return createHook<T>(key);
28-
}
28+
};
29+
30+
export default useRGS;

lib/r18gs/src/plugins/persist.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export interface PersistOptions {
88
}
99

1010
/** get stored item */
11-
function getItem(key: string, options?: PersistOptions) {
11+
const getItem = (key: string, options?: PersistOptions) => {
1212
const cookie = document.cookie.split("; ").find(c => c.startsWith(key));
1313
switch (options?.storage) {
1414
case "cookie":
@@ -18,10 +18,10 @@ function getItem(key: string, options?: PersistOptions) {
1818
default:
1919
return localStorage.getItem(key);
2020
}
21-
}
21+
};
2222

2323
/** set item to persistant store */
24-
function setItem(key: string, value: string, options?: PersistOptions) {
24+
const setItem = (key: string, value: string, options?: PersistOptions) => {
2525
switch (options?.storage) {
2626
case "cookie":
2727
document.cookie = `${key}=${value}; max-age=31536000; SameSite=Strict;`;
@@ -33,13 +33,13 @@ function setItem(key: string, value: string, options?: PersistOptions) {
3333
default:
3434
localStorage.setItem(key, value);
3535
}
36-
}
36+
};
3737
/**
3838
* A plugin that persists and syncs RGS store between tabs.
3939
*
4040
* @returns A plugin that persists and syncs a value between tabs.
4141
*/
42-
export function persist<T>(options?: PersistOptions): Plugin<T> {
42+
export const persist = <T>(options?: PersistOptions): Plugin<T> => {
4343
return {
4444
init(key, _, mutate) {
4545
if (typeof window === "undefined") return;
@@ -62,4 +62,4 @@ export function persist<T>(options?: PersistOptions): Plugin<T> {
6262
}
6363
},
6464
};
65-
}
65+
};

0 commit comments

Comments
 (0)