@rkrupinski/stan 1.0.0-rc10 → 1.0.0-rc11

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 CHANGED
@@ -1 +1 @@
1
- import{s as e,R as t,d as s}from"./utils-BY8H9TPH.js";export{r as refresh}from"./utils-BY8H9TPH.js";class c{#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 a extends Map{}const n=e=>{switch(e.type){case"keep-all":return new a;case"most-recent":return new c(1);case"lru":return new c(e.maxSize);default:return e}},i=(e,{effects:t}={})=>{let s=!1,c=e;const a=new Set,r=new Set,n=(e=!1)=>t=>{c=t instanceof Function?t(c):t,a.forEach((e=>e(c))),e||r.forEach((e=>e(c)))};return t?.forEach((e=>e({init(e){s||(c=e)},set:n(!0),onSet(e){r.add(e)}}))),s=!0,{get:()=>c,set:n(),subscribe:e=>(a.add(e),()=>{a.delete(e)})}},h=(t,s)=>{const c=n({type:"keep-all"});return a=>{const r=e(a);return c.has(r)||c.set(r,i(t instanceof Function?t(a):t,s)),c.get(r)}},l=(e,{areValuesEqual:c=s}={})=>{let a,r=!1,n=!1;const i=new Set,h=new Set,l=new Set,o=e=>{let t=e.get();if(!h.has(e)){h.add(e);const s=e.subscribe((e=>{c(t,e)||(t=e,u(),d())}));l.add(s)}return t},u=()=>{a=e({get:o})},d=()=>{i.forEach((e=>e(a)))};return{get:()=>(r||(r=!0,u()),a),subscribe:e=>(0===i.size&&(n=!0),i.add(e),function(){i.delete(e),0===i.size&&(n=!1,l.forEach((e=>e())),l.clear(),h.clear())}),[t](){n?(u(),d()):r=!1}}},o=(t,{areValuesEqual:c=s,cachePolicy:a={type:"keep-all"}}={})=>{const r=n(a);return s=>{const a=e(s);if(!r.has(a)){const e=l(t(s),{areValuesEqual:c}),n=e.get.bind(e);e.get=()=>{const e=n();return e instanceof Promise&&e.catch((()=>{r.delete(a)})),e},r.set(a,e)}return r.get(a)}};export{i as atom,h as atomFamily,l as selector,o as selectorFamily};
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 n{#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 h extends Map{}const i=e=>{switch(e.type){case"keep-all":return new h;case"most-recent":return new n(1);case"lru":return new n(e.maxSize);default:return e}},l=(e,{effects:s}={})=>{let a=!1,c=e;const r=new Set,n=new Set,h=(e=!1)=>s=>{c=t(s)?s(c):s,r.forEach((e=>e(c))),e||n.forEach((e=>e(c)))};return s?.forEach((e=>e({init(e){a||(c=e)},set:h(!0),onSet(e){n.add(e)}}))),a=!0,{get:()=>c,set:h(),subscribe:e=>(r.add(e),()=>{r.delete(e)})}},u=(s,a)=>{const c=i({type:"keep-all"});return r=>{const n=e(r);return c.has(n)||c.set(n,l(t(s)?s(r):s,a)),c.get(n)}},o=(e,{areValuesEqual:t=a}={})=>{let c,r=!1,n=!1;const h=new Set,i=new Set,l=new Set,u=e=>{let s=e.get();if(!i.has(e)){i.add(e);const a=e.subscribe((e=>{t(s,e)||(s=e,o(),d())}));l.add(a)}return s},o=()=>{c=e({get:u})},d=()=>{h.forEach((e=>e(c)))};return{get:()=>(r||(r=!0,o()),c),subscribe:e=>(0===h.size&&(n=!0),h.add(e),function(){h.delete(e),0===h.size&&(n=!1,l.forEach((e=>e())),l.clear(),i.clear())}),[s](){n?(o(),d()):r=!1}}},d=(t,{areValuesEqual:s=a,cachePolicy:r={type:"keep-all"}}={})=>{const n=i(r);return a=>{const r=e(a);if(!n.has(r)){const e=o(t(a),{areValuesEqual:s}),h=e.get.bind(e);e.get=()=>{const e=h();return c(e)&&e.then(void 0,(()=>{n.delete(r)})),e},n.set(r,e)}return n.get(r)}};export{l as atom,u as atomFamily,o as selector,d as selectorFamily};
package/dist/misc.d.ts CHANGED
@@ -5,3 +5,5 @@ type Json = string | number | boolean | null | {
5
5
  export type SerializableParam = Json;
6
6
  export declare const REFRESH_TAG: unique symbol;
7
7
  export declare const dejaVu: <T>(a: T, b: T) => boolean;
8
+ export declare const isFunction: (candidate: any) => candidate is (...args: any[]) => any;
9
+ export declare const isPromiseLike: (candidate: any) => candidate is PromiseLike<any>;
package/dist/react.js CHANGED
@@ -1 +1 @@
1
- import{useSyncExternalStore as e,useCallback as t,useState as r,useEffect as s}from"react";import{r as o}from"./utils-BY8H9TPH.js";const n=t=>[e(t.subscribe,t.get),t.set],a=t=>e(t.subscribe,t.get),i=t=>{const o=e(t.subscribe,t.get),[n,a]=r({type:"loading"});return s((()=>{let e=!0;return"loading"!==n.type&&a({type:"loading"}),o.then((t=>{e&&a({type:"ready",value:t})}),(t=>{e&&a({type:"error",reason:t?.message??"unknown"})})),()=>{e=!1}}),[o]),n},p=e=>e.set,u=e=>t((()=>{o(e)}),[e]);export{p as useSetStanValue,n as useStan,u as useStanRefresher,a as useStanValue,i as useStanValueAsync};
1
+ import{useSyncExternalStore as e,useCallback as t,useState as r,useEffect as s}from"react";import{r as o}from"./utils-D5tiXDeQ.js";const n=t=>[e(t.subscribe,t.get),t.set],a=t=>e(t.subscribe,t.get),i=t=>{const o=e(t.subscribe,t.get),[n,a]=r({type:"loading"});return s((()=>{let e=!0;return"loading"!==n.type&&a({type:"loading"}),o.then((t=>{e&&a({type:"ready",value:t})}),(t=>{e&&a({type:"error",reason:t?.message??"unknown"})})),()=>{e=!1}}),[o]),n},p=e=>e.set,u=e=>t((()=>{o(e)}),[e]);export{p as useSetStanValue,n as useStan,u as useStanRefresher,a as useStanValue,i as useStanValueAsync};
@@ -0,0 +1 @@
1
+ function t(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var r,e;var n=t(e?r:(e=1,r=function(t,r){r||(r={}),"function"==typeof r&&(r={cmp:r});var e,n="boolean"==typeof r.cycles&&r.cycles,o=r.cmp&&(e=r.cmp,function(t){return function(r,n){var o={key:r,value:t[r]},c={key:n,value:t[n]};return e(o,c)}}),c=[];return function t(r){if(r&&r.toJSON&&"function"==typeof r.toJSON&&(r=r.toJSON()),void 0!==r){if("number"==typeof r)return isFinite(r)?""+r:"null";if("object"!=typeof r)return JSON.stringify(r);var e,i;if(Array.isArray(r)){for(i="[",e=0;e<r.length;e++)e&&(i+=","),i+=t(r[e])||"null";return i+"]"}if(null===r)return"null";if(-1!==c.indexOf(r)){if(n)return JSON.stringify("__cycle__");throw new TypeError("Converting circular structure to JSON")}var u=c.push(r)-1,f=Object.keys(r).sort(o&&o(r));for(i="",e=0;e<f.length;e++){var a=f[e],l=t(r[a]);l&&(i&&(i+=","),i+=JSON.stringify(a)+":"+l)}return c.splice(u,1),"{"+i+"}"}}(t)}));const o=Symbol("__refresh__"),c=(t,r)=>t===r,i=["[object AsyncFunction]","[object AsyncGeneratorFunction]","[object GeneratorFunction]","[object Function]"],u=t=>i.includes(Object.prototype.toString.call(t)),f=t=>!!t&&u(t.then),a=t=>{t[o]()};export{o as R,f as a,c as d,u as i,a as r,n as 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.0.0-rc10",
4
+ "version": "1.0.0-rc11",
5
5
  "exports": {
6
6
  ".": "./dist/index.js",
7
7
  "./react": "./dist/react.js"
@@ -1 +0,0 @@
1
- function r(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var t,e;var n=r(e?t:(e=1,t=function(r,t){t||(t={}),"function"==typeof t&&(t={cmp:t});var e,n="boolean"==typeof t.cycles&&t.cycles,o=t.cmp&&(e=t.cmp,function(r){return function(t,n){var o={key:t,value:r[t]},u={key:n,value:r[n]};return e(o,u)}}),u=[];return function r(t){if(t&&t.toJSON&&"function"==typeof t.toJSON&&(t=t.toJSON()),void 0!==t){if("number"==typeof t)return isFinite(t)?""+t:"null";if("object"!=typeof t)return JSON.stringify(t);var e,i;if(Array.isArray(t)){for(i="[",e=0;e<t.length;e++)e&&(i+=","),i+=r(t[e])||"null";return i+"]"}if(null===t)return"null";if(-1!==u.indexOf(t)){if(n)return JSON.stringify("__cycle__");throw new TypeError("Converting circular structure to JSON")}var f=u.push(t)-1,c=Object.keys(t).sort(o&&o(t));for(i="",e=0;e<c.length;e++){var l=c[e],a=r(t[l]);a&&(i&&(i+=","),i+=JSON.stringify(l)+":"+a)}return u.splice(f,1),"{"+i+"}"}}(r)}));const o=Symbol("__refresh__"),u=(r,t)=>r===t,i=r=>{r[o]()};export{o as R,u as d,i as r,n as s};