Comparing version 0.1.0 to 0.1.1
# r18gs | ||
## 0.1.1 | ||
### Patch Changes | ||
- Refactor without changing the exposed APIs. Some libraries using internal APIs may face temporary issues. | ||
## 0.1.0 | ||
@@ -4,0 +10,0 @@ |
@@ -1,1 +0,1 @@ | ||
import{a as o}from"./chunk-ZTUXLR3P.js";var e=o;export{e as default}; | ||
import{a as o}from"./chunk-PNYILPYU.js";var e=o;export{e as default}; |
@@ -1,1 +0,1 @@ | ||
import{a}from"./chunk-ZTUXLR3P.js";export{a as default}; | ||
import{a}from"./chunk-PNYILPYU.js";export{a as default}; |
@@ -1,1 +0,1 @@ | ||
"use strict";var n=Object.defineProperty;var T=Object.getOwnPropertyDescriptor;var c=Object.getOwnPropertyNames;var u=Object.prototype.hasOwnProperty;var d=(s,e)=>{for(var i in e)n(s,i,{get:e[i],enumerable:!0})},S=(s,e,i,l)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of c(e))!u.call(s,o)&&o!==i&&n(s,o,{get:()=>e[o],enumerable:!(l=T(e,o))||l.enumerable});return s};var f=s=>S(n({},"__esModule",{value:!0}),s);var h={};d(h,{default:()=>v});module.exports=f(h);var b=require("react");globalThis.rgs={};globalThis.setters={};globalThis.subscribers={};function g(s,e){globalThis.subscribers[s]||(globalThis.subscribers[s]=r=>{globalThis.rgs[s]||(globalThis.rgs[s]={listeners:[],value:e});let t=globalThis.rgs[s];return t.listeners.push(r),()=>{t.listeners=t.listeners.filter(a=>a!==r)}});let i=globalThis.subscribers[s];globalThis.setters[s]||(globalThis.setters[s]=r=>{let t=globalThis.rgs[s];t.value=r instanceof Function?r(t.value):r;for(let a of t.listeners)a()});let l=globalThis.setters[s],o=()=>{var r,t;return(t=(r=globalThis.rgs[s])==null?void 0:r.value)!=null?t:e};return[(0,b.useSyncExternalStore)(i,o,o),l]}var v=g; | ||
"use strict";var g=Object.defineProperty;var f=Object.getOwnPropertyDescriptor;var l=Object.getOwnPropertyNames;var d=Object.prototype.hasOwnProperty;var A=(t,e)=>{for(var n in e)g(t,n,{get:e[n],enumerable:!0})},G=(t,e,n,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of l(e))!d.call(t,r)&&r!==n&&g(t,r,{get:()=>e[r],enumerable:!(s=f(e,r))||s.enumerable});return t};var E=t=>G(g({},"__esModule",{value:!0}),t);var h={};A(h,{default:()=>y});module.exports=E(h);var u=require("react"),[T,p,L,m]=[0,1,2,3],R=globalThis;R.rgs={};var a=R.rgs;function x(t,e){let n=[],s=o=>{let i=a[t];i[T]=o instanceof Function?o(i[T]):o,i[p].forEach(c=>c())},r=o=>{let i=a[t],c=i[p];return c.push(o),()=>{i[p]=c.filter(S=>S!==o)}};a[t]=[e,n,s,r]}function b(t,e,n){a[t]||x(t,e);let s=a[t],r=s[L],o=()=>{var S;return(S=s[T])!=null?S:e},i=()=>{var S;return(S=n!=null?n:s[T])!=null?S:e};return[(0,u.useSyncExternalStore)(s[m],o,i),r]}var y=b; |
@@ -5,3 +5,3 @@ { | ||
"private": false, | ||
"version": "0.1.0", | ||
"version": "0.1.1", | ||
"description": "A simple yet elegant, light weight, react18 global store to replace Zustand for better tree shaking.", | ||
@@ -28,19 +28,19 @@ "main": "index.js", | ||
"devDependencies": { | ||
"@testing-library/react": "^14.2.1", | ||
"@turbo/gen": "^1.12.4", | ||
"@types/node": "^20.11.20", | ||
"@types/react": "^18.2.58", | ||
"@types/react-dom": "^18.2.19", | ||
"@testing-library/react": "^15.0.2", | ||
"@turbo/gen": "^1.13.2", | ||
"@types/node": "^20.12.7", | ||
"@types/react": "^18.2.79", | ||
"@types/react-dom": "^18.2.25", | ||
"@vitejs/plugin-react": "^4.2.1", | ||
"@vitest/coverage-v8": "^1.3.1", | ||
"@vitest/coverage-v8": "^1.5.0", | ||
"eslint-config-custom": "workspace:*", | ||
"jsdom": "^24.0.0", | ||
"octokit": "^3.1.2", | ||
"octokit": "^3.2.0", | ||
"react": "^18.2.0", | ||
"tsconfig": "workspace:*", | ||
"tsup": "^8.0.2", | ||
"typedoc": "^0.25.8", | ||
"typescript": "^5.3.3", | ||
"vite-tsconfig-paths": "^4.3.1", | ||
"vitest": "^1.3.1" | ||
"typedoc": "^0.25.13", | ||
"typescript": "^5.4.5", | ||
"vite-tsconfig-paths": "^4.3.2", | ||
"vitest": "^1.5.0" | ||
}, | ||
@@ -47,0 +47,0 @@ "peerDependencies": { |
# React18GlobalStore | ||
[![test](https://github.com/react18-tools/react18-global-store/actions/workflows/test.yml/badge.svg)](https://github.com/react18-tools/react18-global-store/actions/workflows/test.yml) [![Maintainability](https://api.codeclimate.com/v1/badges/ec3140063acd8df82481/maintainability)](https://codeclimate.com/github/react18-tools/react18-global-store/maintainability) [![codecov](https://codecov.io/gh/react18-tools/react18-global-store/graph/badge.svg)](https://codecov.io/gh/react18-tools/react18-global-store) [![Version](https://img.shields.io/npm/v/r18gs.svg?colorB=green)](https://www.npmjs.com/package/r18gs) [![Downloads](https://img.jsdelivr.com/img.shields.io/npm/dt/r18gs.svg)](https://www.npmjs.com/package/r18gs) ![npm bundle size](https://img.shields.io/bundlephobia/minzip/r18gs) [![Gitpod ready-to-code](https://img.shields.io/badge/Gitpod-ready--to--code-blue?logo=gitpod)](https://gitpod.io/from-referrer/) | ||
[![test](https://github.com/react18-tools/react18-global-store/actions/workflows/test.yml/badge.svg)](https://github.com/react18-tools/react18-global-store/actions/workflows/test.yml) [![Maintainability](https://api.codeclimate.com/v1/badges/ec3140063acd8df82481/maintainability)](https://codeclimate.com/github/react18-tools/react18-global-store/maintainability) [![codecov](https://codecov.io/gh/react18-tools/react18-global-store/graph/badge.svg)](https://codecov.io/gh/react18-tools/react18-global-store) [![Version](https://img.shields.io/npm/v/r18gs.svg?colorB=green)](https://www.npmjs.com/package/r18gs) [![Downloads](https://img.jsdelivr.com/img.shields.io/npm/d18m/r18gs.svg)](https://www.npmjs.com/package/r18gs) ![npm bundle size](https://img.shields.io/bundlephobia/minzip/r18gs) [![Gitpod ready-to-code](https://img.shields.io/badge/Gitpod-ready--to--code-blue?logo=gitpod)](https://gitpod.io/from-referrer/) | ||
@@ -5,0 +5,0 @@ ## Motivation |
@@ -1,11 +0,8 @@ | ||
interface React18GlobalStore { | ||
listeners: (() => void)[]; | ||
value: unknown; | ||
} | ||
export type SetterArgType<T> = T | ((prevState: T) => T); | ||
type Listener = () => void; | ||
type SetterArgType<T> = T | ((prevState: T) => T); | ||
type Subscriber = (l: Listener) => () => void; | ||
export type SetStateAction<T> = (val: SetterArgType<T>) => void; | ||
type RGS = [unknown, Listener[], SetStateAction<unknown>, Subscriber]; | ||
declare global { | ||
var rgs: Record<string, React18GlobalStore | undefined>; | ||
var setters: Record<string, SetStateAction<unknown> | undefined>; | ||
var subscribers: Record<string, ((listener: () => void) => () => void) | undefined>; | ||
var rgs: Record<string, RGS | undefined>; | ||
} | ||
@@ -23,4 +20,4 @@ /** | ||
*/ | ||
export default function useRGS<T>(key: string, value?: T): [T, (val: SetterArgType<T>) => void]; | ||
export default function useRGS<T>(key: string, value?: T, serverValue?: T): [T, (val: SetterArgType<T>) => void]; | ||
export {}; | ||
//# sourceMappingURL=use-rgs.d.ts.map |
@@ -1,1 +0,1 @@ | ||
"use strict";var n=Object.defineProperty;var T=Object.getOwnPropertyDescriptor;var c=Object.getOwnPropertyNames;var u=Object.prototype.hasOwnProperty;var d=(s,e)=>{for(var i in e)n(s,i,{get:e[i],enumerable:!0})},S=(s,e,i,l)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of c(e))!u.call(s,o)&&o!==i&&n(s,o,{get:()=>e[o],enumerable:!(l=T(e,o))||l.enumerable});return s};var v=s=>S(n({},"__esModule",{value:!0}),s);var h={};d(h,{default:()=>b});module.exports=v(h);var g=require("react");globalThis.rgs={};globalThis.setters={};globalThis.subscribers={};function b(s,e){globalThis.subscribers[s]||(globalThis.subscribers[s]=r=>{globalThis.rgs[s]||(globalThis.rgs[s]={listeners:[],value:e});let t=globalThis.rgs[s];return t.listeners.push(r),()=>{t.listeners=t.listeners.filter(a=>a!==r)}});let i=globalThis.subscribers[s];globalThis.setters[s]||(globalThis.setters[s]=r=>{let t=globalThis.rgs[s];t.value=r instanceof Function?r(t.value):r;for(let a of t.listeners)a()});let l=globalThis.setters[s],o=()=>{var r,t;return(t=(r=globalThis.rgs[s])==null?void 0:r.value)!=null?t:e};return[(0,g.useSyncExternalStore)(i,o,o),l]} | ||
"use strict";var g=Object.defineProperty;var f=Object.getOwnPropertyDescriptor;var l=Object.getOwnPropertyNames;var d=Object.prototype.hasOwnProperty;var A=(t,n)=>{for(var e in n)g(t,e,{get:n[e],enumerable:!0})},E=(t,n,e,s)=>{if(n&&typeof n=="object"||typeof n=="function")for(let r of l(n))!d.call(t,r)&&r!==e&&g(t,r,{get:()=>n[r],enumerable:!(s=f(n,r))||s.enumerable});return t};var G=t=>E(g({},"__esModule",{value:!0}),t);var v={};A(v,{default:()=>u});module.exports=G(v);var b=require("react"),[T,p,L,y]=[0,1,2,3],R=globalThis;R.rgs={};var a=R.rgs;function h(t,n){let e=[],s=o=>{let i=a[t];i[T]=o instanceof Function?o(i[T]):o,i[p].forEach(c=>c())},r=o=>{let i=a[t],c=i[p];return c.push(o),()=>{i[p]=c.filter(S=>S!==o)}};a[t]=[n,e,s,r]}function u(t,n,e){a[t]||h(t,n);let s=a[t],r=s[L],o=()=>{var S;return(S=s[T])!=null?S:n},i=()=>{var S;return(S=e!=null?e:s[T])!=null?S:n};return[(0,b.useSyncExternalStore)(s[y],o,i),r]} |
Sorry, the diff of this file is not supported yet
11518
36