reaxify 0.0.66 → 0.0.67

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.
@@ -1 +1 @@
1
- "use client";"use strict";const u=require("../../_virtual/jsx-runtime.cjs.js");require("react");const i=require("../../hooks/useClasses.cjs.js"),o=require("../../node_modules/tailwind-merge/dist/bundle-mjs.cjs.js");function a({className:e,children:s,...t}){const r=i(n=>n.skeleton.base);return u.jsxRuntimeExports.jsx("div",{className:o.twMerge("size-10 rounded bg-gray-200 text-gray-200 animate-pulse",r,e),...t,children:s})}module.exports=a;
1
+ "use client";"use strict";const u=require("../../_virtual/jsx-runtime.cjs.js");require("react");const i=require("../../hooks/useClasses.cjs.js"),o=require("../../node_modules/tailwind-merge/dist/bundle-mjs.cjs.js");function a({className:e,children:s,...t}){const n=i(r=>r.skeleton.base);return u.jsxRuntimeExports.jsx("span",{className:o.twMerge("inline-block size-10 rounded bg-gray-200 text-gray-200 animate-pulse",n,e),...t,children:s})}module.exports=a;
@@ -1,20 +1,20 @@
1
1
  "use client";
2
2
  import { j as a } from "../../_virtual/jsx-runtime.es.js";
3
3
  import "react";
4
- import i from "../../hooks/useClasses.es.js";
5
- import { twMerge as m } from "../../node_modules/tailwind-merge/dist/bundle-mjs.es.js";
4
+ import n from "../../hooks/useClasses.es.js";
5
+ import { twMerge as i } from "../../node_modules/tailwind-merge/dist/bundle-mjs.es.js";
6
6
  function c({
7
7
  className: e,
8
8
  children: s,
9
9
  ...t
10
10
  }) {
11
- const r = i((o) => o.skeleton.base);
11
+ const o = n((r) => r.skeleton.base);
12
12
  return /* @__PURE__ */ a.jsx(
13
- "div",
13
+ "span",
14
14
  {
15
- className: m(
16
- "size-10 rounded bg-gray-200 text-gray-200 animate-pulse",
17
- r,
15
+ className: i(
16
+ "inline-block size-10 rounded bg-gray-200 text-gray-200 animate-pulse",
17
+ o,
18
18
  e
19
19
  ),
20
20
  ...t,
@@ -1 +1 @@
1
- "use client";"use strict";const r=require("react");function u(s){const c=r.useRef(new AbortController);r.useEffect(()=>{var t,o;const e=c.current;return(o=(t=navigator==null?void 0:navigator.credentials)==null?void 0:t.get)==null||o.call(t,{otp:{transport:["sms"]},signal:e.signal}).then(i=>{const n=i;s((n==null?void 0:n.code)||null)}),()=>{e==null||e.abort("signal has been aborted.")}},[s])}module.exports=u;
1
+ "use client";"use strict";const u=require("react");function l(o){const s=u.useRef(null);u.useEffect(()=>{var t,c;s.current=new AbortController;const e=s.current;return(c=(t=navigator==null?void 0:navigator.credentials)==null?void 0:t.get)==null||c.call(t,{otp:{transport:["sms"]},signal:e.signal}).then(n=>{const r=n;o((r==null?void 0:r.code)||null)}).catch(n=>{console.error(n)}),()=>{e==null||e.abort("signal has been aborted.")}},[o])}module.exports=l;
@@ -1,21 +1,26 @@
1
1
  "use client";
2
- import { useRef as i, useEffect as l } from "react";
3
- function c(o) {
4
- const s = i(new AbortController());
5
- l(() => {
6
- var e, r;
7
- const t = s.current;
8
- return (r = (e = navigator == null ? void 0 : navigator.credentials) == null ? void 0 : e.get) == null || r.call(e, {
2
+ import { useRef as a, useEffect as c } from "react";
3
+ function i(r) {
4
+ const s = a(null);
5
+ c(() => {
6
+ var t, l;
7
+ s.current = new AbortController();
8
+ const e = s.current;
9
+ return (l = (t = navigator == null ? void 0 : navigator.credentials) == null ? void 0 : t.get) == null || l.call(t, {
10
+ // eslint-disable-next-line
11
+ // @ts-ignore
9
12
  otp: { transport: ["sms"] },
10
- signal: t.signal
11
- }).then((a) => {
12
- const n = a;
13
- o((n == null ? void 0 : n.code) || null);
13
+ signal: e.signal
14
+ }).then((n) => {
15
+ const o = n;
16
+ r((o == null ? void 0 : o.code) || null);
17
+ }).catch((n) => {
18
+ console.error(n);
14
19
  }), () => {
15
- t == null || t.abort("signal has been aborted.");
20
+ e == null || e.abort("signal has been aborted.");
16
21
  };
17
- }, [o]);
22
+ }, [r]);
18
23
  }
19
24
  export {
20
- c as default
25
+ i as default
21
26
  };
@@ -1 +1 @@
1
- "use client";"use strict";const s=require("react");function m(t,c,r="localStorage"){const o=s.useCallback(e=>{try{window[r].setItem(t,JSON.stringify(e))}catch(S){console.error(S)}},[t,r]),a=s.useCallback(()=>{try{const e=window[r].getItem(t);return e?JSON.parse(e):void 0}catch(e){console.error(e)}},[t,r]),[n,u]=s.useState(()=>a()||c),l=()=>{u(c),o(c)};return s.useEffect(()=>{o(n)},[n,o]),[n,u,l]}module.exports=m;
1
+ "use client";"use strict";const s=require("react");function w(c,r){const o=s.useMemo(()=>r.name,[r.name]),n=s.useMemo(()=>r.storage??"localStorage",[r.storage]),a=s.useMemo(()=>r.version??1,[r.version]),u=s.useCallback(e=>{try{const t=JSON.stringify({state:e,version:a});window[n].setItem(o,t)}catch(t){console.error(t)}},[o,n,a]),m=s.useCallback(()=>{try{const e=window[n].getItem(o);if(!e)return;const t=JSON.parse(e);return t.version!==a?void 0:"state"in t?t.state:void 0}catch(e){console.error(e);return}},[o,n,a]),[d,i]=s.useState(()=>m()||c),v=s.useCallback(e=>{i(t=>{const l=typeof e=="function"?e(t):e;return u(l),l})},[u]),S=s.useCallback(()=>{i(c),localStorage.removeItem(o)},[c,o]);return[d,v,S]}module.exports=w;
@@ -1,3 +1,9 @@
1
- type Variant = "localStorage" | "sessionStorage";
2
- export default function usePersistedState<T>(key: string, initialValue: T, variant?: Variant): readonly [T, import('react').Dispatch<import('react').SetStateAction<T>>, () => void];
1
+ import { Dispatch, SetStateAction } from 'react';
2
+ type Storage = "localStorage" | "sessionStorage";
3
+ type Config = {
4
+ name: string;
5
+ storage?: Storage;
6
+ version?: number;
7
+ };
8
+ export default function usePersistedState<T>(initialValue: T, config: Config): readonly [T, Dispatch<SetStateAction<T>>, () => void];
3
9
  export {};
@@ -1,29 +1,45 @@
1
1
  "use client";
2
- import { useCallback as u, useState as S, useEffect as f } from "react";
3
- function g(e, o, r = "localStorage") {
4
- const s = u(
2
+ import { useMemo as u, useCallback as a, useState as w } from "react";
3
+ function f(c, r) {
4
+ const s = u(() => r.name, [r.name]), o = u(
5
+ () => r.storage ?? "localStorage",
6
+ [r.storage]
7
+ ), n = u(() => r.version ?? 1, [r.version]), m = a(
5
8
  (t) => {
6
9
  try {
7
- window[r].setItem(e, JSON.stringify(t));
8
- } catch (m) {
9
- console.error(m);
10
+ const e = JSON.stringify({ state: t, version: n });
11
+ window[o].setItem(s, e);
12
+ } catch (e) {
13
+ console.error(e);
10
14
  }
11
15
  },
12
- [e, r]
13
- ), a = u(() => {
16
+ [s, o, n]
17
+ ), v = a(() => {
14
18
  try {
15
- const t = window[r].getItem(e);
16
- return t ? JSON.parse(t) : void 0;
19
+ const t = window[o].getItem(s);
20
+ if (!t) return;
21
+ const e = JSON.parse(t);
22
+ return e.version !== n ? void 0 : "state" in e ? e.state : void 0;
17
23
  } catch (t) {
18
24
  console.error(t);
25
+ return;
19
26
  }
20
- }, [e, r]), [c, n] = S(() => a() || o), l = () => {
21
- n(o), s(o);
22
- };
23
- return f(() => {
24
- s(c);
25
- }, [c, s]), [c, n, l];
27
+ }, [s, o, n]), [S, i] = w(() => v() || c), l = a(
28
+ (t) => {
29
+ i((e) => {
30
+ const d = (
31
+ // eslint-disable-next-line
32
+ typeof t == "function" ? t(e) : t
33
+ );
34
+ return m(d), d;
35
+ });
36
+ },
37
+ [m]
38
+ ), p = a(() => {
39
+ i(c), localStorage.removeItem(s);
40
+ }, [c, s]);
41
+ return [S, l, p];
26
42
  }
27
43
  export {
28
- g as default
44
+ f as default
29
45
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "reaxify",
3
3
  "private": false,
4
- "version": "0.0.66",
4
+ "version": "0.0.67",
5
5
  "type": "module",
6
6
  "types": "./dist/index.d.ts",
7
7
  "files": [
@@ -12,29 +12,29 @@
12
12
  },
13
13
  "exports": {
14
14
  "./axios": {
15
+ "types": "./dist/axios/index.d.ts",
15
16
  "import": "./dist/axios/index.es.js",
16
- "require": "./dist/axios/index.cjs.js",
17
- "types": "./dist/axios/index.d.ts"
17
+ "require": "./dist/axios/index.cjs.js"
18
18
  },
19
19
  "./components": {
20
+ "types": "./dist/components/index.d.ts",
20
21
  "import": "./dist/components/index.es.js",
21
- "require": "./dist/components/index.cjs.js",
22
- "types": "./dist/components/index.d.ts"
22
+ "require": "./dist/components/index.cjs.js"
23
23
  },
24
24
  "./helpers": {
25
+ "types": "./dist/helpers/index.d.ts",
25
26
  "import": "./dist/helpers/index.es.js",
26
- "require": "./dist/helpers/index.cjs.js",
27
- "types": "./dist/helpers/index.d.ts"
27
+ "require": "./dist/helpers/index.cjs.js"
28
28
  },
29
29
  "./hooks": {
30
+ "types": "./dist/hooks/index.d.ts",
30
31
  "import": "./dist/hooks/index.es.js",
31
- "require": "./dist/hooks/index.cjs.js",
32
- "types": "./dist/hooks/index.d.ts"
32
+ "require": "./dist/hooks/index.cjs.js"
33
33
  },
34
34
  "./providers": {
35
+ "types": "./dist/providers/index.d.ts",
35
36
  "import": "./dist/providers/index.es.js",
36
- "require": "./dist/providers/index.cjs.js",
37
- "types": "./dist/providers/index.d.ts"
37
+ "require": "./dist/providers/index.cjs.js"
38
38
  },
39
39
  "./types": {
40
40
  "types": "./dist/types/index.d.ts"