@rkrupinski/stan 1.5.0 → 1.5.1-rc1

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
@@ -3,6 +3,7 @@
3
3
  # Stan
4
4
 
5
5
  [![CI](https://github.com/rkrupinski/stan/actions/workflows/ci.yml/badge.svg)](https://github.com/rkrupinski/stan/actions/workflows/ci.yml)
6
+ ![NPM Version](https://img.shields.io/npm/v/@rkrupinski/stan)
6
7
  ![Bundle size](https://img.shields.io/bundlejs/size/@rkrupinski/stan)
7
8
 
8
9
  Minimal, type-safe state management
package/dist/react.esm.js CHANGED
@@ -1 +1 @@
1
- import{jsx as r}from"react/jsx-runtime";import{createContext as t,useContext as e,useMemo as o,useRef as s,useState as n,useEffect as c,useCallback as u}from"react";import{D as a,m as i,r as m,f as p}from"./store-D_uSq-w8.js";const l=t({store:a}),d=({store:t,children:e})=>{const s=o((()=>({store:t??i()})),[t]);return r(l.Provider,{value:s,children:e})},y=()=>e(l),f=r=>{const{store:t}=y(),e=r(t),o=s(e),[u,a]=n((()=>e.get()));return c((()=>(e!==o.current&&(o.current=e,a(e.get())),e.subscribe(a))),[e]),u},g=r=>{const{store:t}=y();return r(t).set},h=r=>[f(r),g(r)],v=r=>{const t=f(r),[e,o]=n({type:"loading"});return c((()=>{let r=!0;return o({type:"loading"}),t.then((t=>{r&&o({type:"ready",value:t})}),(t=>{r&&o({type:"error",reason:t})})),()=>{r=!1}}),[t]),e},b=r=>{const{store:t}=y(),e=r(t);return u((()=>{m(e)}),[e])},j=r=>{const{store:t}=y(),e=r(t);return u((()=>{p(e)}),[e])};export{d as StanProvider,g as useSetStanValue,h as useStan,y as useStanCtx,b as useStanRefresh,j as useStanReset,f as useStanValue,v as useStanValueAsync};
1
+ import{jsx as r}from"react/jsx-runtime";import{createContext as e,useContext as t,useMemo as n,useRef as o,useState as s,useEffect as c,useCallback as u}from"react";import{D as a,m as i,r as l,f as p}from"./store-D_uSq-w8.js";const m=e({store:a}),d=({store:e,children:t})=>{const o=n((()=>({store:e??i()})),[e]);return r(m.Provider,{value:o,children:t})},g=()=>t(m),y=r=>{const{store:e}=g(),t=r(e),n=o(t),[u,a]=s((()=>t.get()));let i=u;t!==n.current&&(i=t.get(),n.current=t,a(i));const l=o(new WeakMap);return l.current.has(t)||l.current.set(t,t.subscribe(a)),c((()=>{const r=l.current;return()=>{const e=r.get(t);e&&(e(),r.delete(t))}}),[t]),i},f=r=>{const{store:e}=g();return r(e).set},h=r=>[y(r),f(r)],v=r=>{const e=y(r),[t,n]=s({type:"loading"});return c((()=>{let r=!0;return n({type:"loading"}),e.then((e=>{r&&n({type:"ready",value:e})}),(e=>{r&&n({type:"error",reason:e})})),()=>{r=!1}}),[e]),t},b=r=>{const{store:e}=g(),t=r(e);return u((()=>{l(t)}),[t])},j=r=>{const{store:e}=g(),t=r(e);return u((()=>{p(t)}),[t])};export{d as StanProvider,f as useSetStanValue,h as useStan,g as useStanCtx,b as useStanRefresh,j as useStanReset,y as useStanValue,v as useStanValueAsync};
package/dist/react.js CHANGED
@@ -1 +1 @@
1
- "use strict";var e=require("react/jsx-runtime"),t=require("react"),r=require("./store-DiTSwUBS.js");const s=t.createContext({store:r.DEFAULT_STORE}),u=()=>t.useContext(s),n=e=>{const{store:r}=u(),s=e(r),n=t.useRef(s),[o,a]=t.useState((()=>s.get()));return t.useEffect((()=>(s!==n.current&&(n.current=s,a(s.get())),s.subscribe(a))),[s]),o},o=e=>{const{store:t}=u();return e(t).set};exports.StanProvider=({store:u,children:n})=>{const o=t.useMemo((()=>({store:u??r.makeStore()})),[u]);return e.jsx(s.Provider,{value:o,children:n})},exports.useSetStanValue=o,exports.useStan=e=>[n(e),o(e)],exports.useStanCtx=u,exports.useStanRefresh=e=>{const{store:s}=u(),n=e(s);return t.useCallback((()=>{r.refresh(n)}),[n])},exports.useStanReset=e=>{const{store:s}=u(),n=e(s);return t.useCallback((()=>{r.reset(n)}),[n])},exports.useStanValue=n,exports.useStanValueAsync=e=>{const r=n(e),[s,u]=t.useState({type:"loading"});return t.useEffect((()=>{let e=!0;return u({type:"loading"}),r.then((t=>{e&&u({type:"ready",value:t})}),(t=>{e&&u({type:"error",reason:t})})),()=>{e=!1}}),[r]),s};
1
+ "use strict";var e=require("react/jsx-runtime"),t=require("react"),r=require("./store-DiTSwUBS.js");const s=t.createContext({store:r.DEFAULT_STORE}),n=()=>t.useContext(s),u=e=>{const{store:r}=n(),s=e(r),u=t.useRef(s),[o,a]=t.useState((()=>s.get()));let c=o;s!==u.current&&(c=s.get(),u.current=s,a(c));const l=t.useRef(new WeakMap);return l.current.has(s)||l.current.set(s,s.subscribe(a)),t.useEffect((()=>{const e=l.current;return()=>{const t=e.get(s);t&&(t(),e.delete(s))}}),[s]),c},o=e=>{const{store:t}=n();return e(t).set};exports.StanProvider=({store:n,children:u})=>{const o=t.useMemo((()=>({store:n??r.makeStore()})),[n]);return e.jsx(s.Provider,{value:o,children:u})},exports.useSetStanValue=o,exports.useStan=e=>[u(e),o(e)],exports.useStanCtx=n,exports.useStanRefresh=e=>{const{store:s}=n(),u=e(s);return t.useCallback((()=>{r.refresh(u)}),[u])},exports.useStanReset=e=>{const{store:s}=n(),u=e(s);return t.useCallback((()=>{r.reset(u)}),[u])},exports.useStanValue=u,exports.useStanValueAsync=e=>{const r=u(e),[s,n]=t.useState({type:"loading"});return t.useEffect((()=>{let e=!0;return n({type:"loading"}),r.then((t=>{e&&n({type:"ready",value:t})}),(t=>{e&&n({type:"error",reason:t})})),()=>{e=!1}}),[r]),s};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@rkrupinski/stan",
3
3
  "description": "Minimal, type-safe state management",
4
- "version": "1.5.0",
4
+ "version": "1.5.1-rc1",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.esm.js",
7
7
  "types": "./dist/index.d.ts",