@rkrupinski/stan 1.0.0-rc11 → 1.0.0-rc13
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/dist/index.js +1 -1
- package/dist/react.d.ts +1 -1
- package/dist/react.js +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{s as e,i as t,R as s,d as a,a as c}from"./utils-D5tiXDeQ.js";export{r as refresh}from"./utils-D5tiXDeQ.js";class
|
|
1
|
+
import{s as e,i as t,R as s,d as a,a as c}from"./utils-D5tiXDeQ.js";export{r as refresh}from"./utils-D5tiXDeQ.js";class h{#e;#t;constructor(e){this.#e=new Map,this.#t=e}#s(){const e=this.#e.keys().next().value;void 0!==e&&this.#e.delete(e)}has(e){return this.#e.has(e)}get(e){if(!this.has(e))return;const t=this.#e.get(e);return this.#e.delete(e),this.#e.set(e,t),t}set(e,t){this.#e.has(e)?this.#e.delete(e):this.#e.size>=this.#t&&this.#s(),this.#e.set(e,t)}delete(e){return this.#e.delete(e)}clear(){this.#e.clear()}}class n extends Map{}const i=e=>{switch(e.type){case"keep-all":return new n;case"most-recent":return new h(1);case"lru":return new h(e.maxSize);default:return e}},l=(e,{effects:s}={})=>{let a=!1,c=e;const r=new Set,h=new Set,n=(e=!1)=>s=>{c=t(s)?s(c):s,r.forEach((e=>e(c))),e||h.forEach((e=>e(c)))};return s?.forEach((e=>e({init(e){a||(c=e)},set:n(!0),onSet(e){h.add(e)}}))),a=!0,{get:()=>c,set:n(),subscribe:e=>(r.add(e),()=>{r.delete(e)})}},u=(s,a)=>{const c=i({type:"keep-all"});return r=>{const h=e(r);return c.has(h)||c.set(h,l(t(s)?s(r):s,a)),c.get(h)}},o=(e,{areValuesEqual:t=a}={})=>{let r,h=!1,n=!1;const i=new Set,l=new Set,u=new Set,o=e=>{let s=e.get();if(!l.has(e)){l.add(e);const a=e.subscribe((e=>{t(s,e)||(s=e,d(),f())}));u.add(a)}return s},d=()=>{r=e({get:o}),c(r)&&r.then(void 0,(()=>{h=!1}))},f=()=>{i.forEach((e=>e(r)))};return{get:()=>(h||(h=!0,d()),r),subscribe:e=>(0===i.size&&(n=!0),i.add(e),function(){i.delete(e),0===i.size&&(n=!1,u.forEach((e=>e())),u.clear(),l.clear())}),[s](){n?(d(),f()):h=!1}}},d=(t,{areValuesEqual:s=a,cachePolicy:c={type:"keep-all"}}={})=>{const r=i(c);return a=>{const c=e(a);return r.has(c)||r.set(c,o(t(a),{areValuesEqual:s})),r.get(c)}};export{l as atom,u as atomFamily,o as selector,d as selectorFamily};
|
package/dist/react.d.ts
CHANGED
|
@@ -8,8 +8,8 @@ export type AsyncValue<T> = {
|
|
|
8
8
|
type: 'error';
|
|
9
9
|
reason: string;
|
|
10
10
|
};
|
|
11
|
-
export declare const useStan: <T>(state: WritableState<T>) => readonly [T, import("./state").SetterOrUpdater<T>];
|
|
12
11
|
export declare const useStanValue: <T>(state: State<T>) => T;
|
|
12
|
+
export declare const useStan: <T>(state: WritableState<T>) => readonly [T, import("./state").SetterOrUpdater<T>];
|
|
13
13
|
export declare const useStanValueAsync: <T>(state: ReadonlyState<PromiseLike<T>>) => AsyncValue<T>;
|
|
14
14
|
export declare const useSetStanValue: <T>(state: WritableState<T>) => import("./state").SetterOrUpdater<T>;
|
|
15
15
|
export declare const useStanRefresher: (state: ReadonlyState<any>) => () => void;
|
package/dist/react.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{useCallback as e,useRef as t,useState as r,useEffect as n}from"react";import{r as o}from"./utils-D5tiXDeQ.js";const s=e=>{const o=t(e),[s,a]=r(e.get());return n((()=>(e!==o.current&&(a(e.get()),o.current=e),e.subscribe(a))),[e]),s},a=e=>[s(e),e.set],u=e=>{const t=s(e),[o,a]=r({type:"loading"});return n((()=>{let e=!0;return"loading"!==o.type&&a({type:"loading"}),t.then((t=>{e&&a({type:"ready",value:t})}),(t=>{e&&a({type:"error",reason:t?.message??"unknown"})})),()=>{e=!1}}),[t]),o},p=e=>e.set,c=t=>e((()=>{o(t)}),[t]);export{p as useSetStanValue,a as useStan,c as useStanRefresher,s as useStanValue,u as useStanValueAsync};
|