Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

rko

Package Overview
Dependencies
Maintainers
1
Versions
32
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rko - npm Package Compare versions

Comparing version 0.5.10 to 0.5.11

dist/types/idbchen.d.ts

2

dist/cjs/index.js

@@ -1,1 +0,1 @@

var U=Object.defineProperty;var _=Object.getOwnPropertySymbols;var D=Object.prototype.hasOwnProperty,I=Object.prototype.propertyIsEnumerable;var P=(n,t,e)=>t in n?U(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,v=(n,t)=>{for(var e in t||(t={}))D.call(t,e)&&P(n,e,t[e]);if(_)for(var e of _(t))I.call(t,e)&&P(n,e,t[e]);return n};var k=(n,t,e)=>new Promise((r,i)=>{var o=u=>{try{f(e.next(u))}catch(s){i(s)}},d=u=>{try{f(e.throw(u))}catch(s){i(s)}},f=u=>u.done?r(u.value):Promise.resolve(u.value).then(o,d);f((e=e.apply(n,t)).next())});function R(n){let t,e=new Set,r=(s,c)=>{let a=typeof s=="function"?s(t):s;if(a!==t){let h=t;t=c?a:Object.assign({},t,a),e.forEach(p=>p(t,h))}},i=()=>t,o=(s,c=i,a=Object.is)=>{let h=c(t);function p(){let S=c(t);if(!a(h,S)){let l=h;s(h=S,l)}}return e.add(p),()=>e.delete(p)},u={setState:r,getState:i,subscribe:(s,c,a)=>c||a?o(s,c,a):(e.add(s),()=>e.delete(s)),destroy:()=>e.clear()};return t=n(r,i,u),u}import{useReducer as B,useRef as b,useEffect as V,useLayoutEffect as z}from"react";function G(n){let t,e=new Set,r=(s,c)=>{let a=typeof s=="function"?s(t):s;if(a!==t){let h=t;t=c?a:Object.assign({},t,a),e.forEach(p=>p(t,h))}},i=()=>t,o=(s,c=i,a=Object.is)=>{let h=c(t);function p(){let S=c(t);if(!a(h,S)){let l=h;s(h=S,l)}}return e.add(p),()=>e.delete(p)},u={setState:r,getState:i,subscribe:(s,c,a)=>c||a?o(s,c,a):(e.add(s),()=>e.delete(s)),destroy:()=>e.clear()};return t=n(r,i,u),u}var H=typeof window=="undefined"||!window.navigator||/ServerSideRendering|^Deno\//.test(window.navigator.userAgent),j=H?V:z;function A(n){let t=typeof n=="function"?G(n):n,e=(r=t.getState,i=Object.is)=>{let[,o]=B(l=>l+1,0),d=t.getState(),f=b(d),u=b(r),s=b(i),c=b(!1),a=b();a.current===void 0&&(a.current=r(d));let h,p=!1;(f.current!==d||u.current!==r||s.current!==i||c.current)&&(h=r(d),p=!i(a.current,h)),j(()=>{p&&(a.current=h),f.current=d,u.current=r,s.current=i,c.current=!1});let S=b(d);return j(()=>{let l=()=>{try{let g=t.getState(),w=u.current(g);s.current(a.current,w)||(f.current=g,a.current=w,o())}catch(g){c.current=!0,o()}},E=t.subscribe(l);return t.getState()!==S.current&&l(),E},[]),p?h:a.current};return Object.assign(e,t),e[Symbol.iterator]=function(){console.warn("[useStore, api] = create() is deprecated and will be removed in v4");let r=[e,t];return{next(){let i=r.length<=0;return{value:r.shift(),done:i}}}},e}function L(){if(!(!navigator.userAgentData&&/Safari\//.test(navigator.userAgent)&&!/Chrom(e|ium)\//.test(navigator.userAgent))||!indexedDB.databases)return Promise.resolve();let t;return new Promise(e=>{let r=()=>indexedDB.databases().finally(e);t=setInterval(r,100),r()}).finally(()=>clearInterval(t))}var M=L;function y(n){return new Promise((t,e)=>{n.oncomplete=n.onsuccess=()=>t(n.result),n.onabort=n.onerror=()=>e(n.error)})}function W(n,t){let e=M().then(()=>{let r=indexedDB.open(n);return r.onupgradeneeded=()=>r.result.createObjectStore(t),y(r)});return(r,i)=>e.then(o=>i(o.transaction(t,r).objectStore(t)))}var m;function O(){return m||(m=W("keyval-store","keyval")),m}function x(n,t=O()){return t("readonly",e=>y(e.get(n)))}function T(n,t,e=O()){return e("readwrite",r=>(r.put(t,n),y(r.transaction)))}function C(n,t){let e=v({},n),r=Object.entries(t);for(let[i,o]of r)e[i]=o===Object(o)&&!Array.isArray(o)?C(e[i],o):o;return e}var $=class{constructor(t,e,r,i){this.stack=[];this.pointer=-1;this._status="loading";this.persist=()=>{this.id&&T(this.id,this._state)};this.applyPatch=t=>{let e=this._state,r=C(this._state,t);return this._state=this.cleanup(r,e,t),this.store.setState(this._state,!0),this};this.cleanup=(t,e,r)=>t;this.patchState=t=>(this.applyPatch(t),this);this.replaceState=t=>(this._state=this.cleanup(t,this._state,t),this.store.setState(this._state,!0),this);this.setState=t=>(this.pointer++,this.stack=this.stack.slice(0,this.pointer),this.stack.push(t),this.applyPatch(t.after),this.persist(),this);this.reset=()=>(this._state=this.initialState,this.store.setState(this.initialState,!0),this.resetHistory(),this.persist(),this);this.resetHistory=()=>(this.stack=[],this.pointer=-1,this);this.undo=()=>{if(!this.canUndo)return this;let t=this.stack[this.pointer];return this.pointer--,this.applyPatch(t.before),this.persist(),this};this.redo=()=>{if(!this.canRedo)return this;this.pointer++;let t=this.stack[this.pointer];return this.applyPatch(t.after),this.persist(),this};this.setSnapshot=()=>(this.snapshot=v({},this._state),this);this.forceUpdate=()=>{this.store.setState(this._state,!0)};this.id=e,this._state=t,this.snapshot=t,this.initialState=t,this.store=R(()=>t),this.useStore=A(this.store),this.id&&x(this.id).then(o=>k(this,null,function*(){if(o){let d=o;if(r){let f=yield x(e+"_version");f&&f<r&&(d=i?i(o,t,f):t)}yield T(e+"_version",r||-1),this._state=d,this.snapshot=d,this.initialState=d,this._status="ready",this.store.setState(this._state,!0)}else yield T(e+"_version",r||-1),this._status="ready"}))}get canUndo(){return this.pointer>-1}get canRedo(){return this.pointer<this.stack.length-1}get state(){return this._state}get status(){return this._status}};export{$ as StateManager};
var A=Object.defineProperty;var k=Object.getOwnPropertySymbols;var B=Object.prototype.hasOwnProperty,C=Object.prototype.propertyIsEnumerable;var U=(s,t,e)=>t in s?A(s,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):s[t]=e,g=(s,t)=>{for(var e in t||(t={}))B.call(t,e)&&U(s,e,t[e]);if(k)for(var e of k(t))C.call(t,e)&&U(s,e,t[e]);return s};var w=(s,t,e)=>new Promise((r,a)=>{var i=u=>{try{S(e.next(u))}catch(n){a(n)}},o=u=>{try{S(e.throw(u))}catch(n){a(n)}},S=u=>u.done?r(u.value):Promise.resolve(u.value).then(i,o);S((e=e.apply(s,t)).next())});import{useEffect as E,useLayoutEffect as M,useReducer as O,useRef as T}from"react";var G=typeof window=="undefined"||!window.navigator||/ServerSideRendering|^Deno\//.test(window.navigator.userAgent),D=G?E:M;function V(s){let t=s,e=new Set,r=n=>{let l=n;if(l!==t){let c=t;t=l,e.forEach(h=>h(t,c))}},a=()=>t,i=(n,l=a,c=Object.is)=>{let h=l(t);function d(){let f=l(t);if(!c(h,f)){let p=h;n(h=f,p)}}return e.add(d),()=>e.delete(d)};return{setState:r,getState:a,subscribe:(n,l,c)=>l||c?i(n,l,c):(e.add(n),()=>e.delete(n)),destroy:()=>e.clear()}}function v(s){let t=V(s),e=(r=t.getState,a=Object.is)=>{let[,i]=O(p=>p+1,0),o=t.getState(),S=T(o),u=T(r),n=T(a),l=T(!1),c=T();c.current===void 0&&(c.current=r(o));let h,d=!1;(S.current!==o||u.current!==r||n.current!==a||l.current)&&(h=r(o),d=!a(c.current,h)),D(()=>{d&&(c.current=h),S.current=o,u.current=r,n.current=a,l.current=!1});let f=T(o);return D(()=>{let p=()=>{try{let y=t.getState(),_=u.current(y);n.current(c.current,_)||(S.current=y,c.current=_,i())}catch(y){l.current=!0,i()}},I=t.subscribe(p);return t.getState()!==f.current&&p(),I},[]),d?h:c.current};return Object.assign(e,t),e}function q(){if(!(!navigator.userAgentData&&/Safari\//.test(navigator.userAgent)&&!/Chrom(e|ium)\//.test(navigator.userAgent))||!indexedDB.databases)return Promise.resolve();let t;return new Promise(e=>{let r=()=>indexedDB.databases().finally(e);t=setInterval(r,100),r()}).finally(()=>clearInterval(t))}var R=q;function x(s){return new Promise((t,e)=>{s.oncomplete=s.onsuccess=()=>t(s.result),s.onabort=s.onerror=()=>e(s.error)})}function H(s,t){let e=R().then(()=>{let r=indexedDB.open(s);return r.onupgradeneeded=()=>r.result.createObjectStore(t),x(r)});return(r,a)=>e.then(i=>a(i.transaction(t,r).objectStore(t)))}var m;function L(){return m||(m=H("keyval-store","keyval")),m}function P(s,t=L()){return t("readonly",e=>x(e.get(s)))}function b(s,t,e=L()){return e("readwrite",r=>(r.put(t,s),x(r.transaction)))}function j(s,t){let e=g({},s),r=Object.entries(t);for(let[a,i]of r)e[a]=i===Object(i)&&!Array.isArray(i)?j(e[a],i):i;return e}var K=class{constructor(t,e,r,a){this.stack=[];this.pointer=-1;this._status="loading";this.persist=()=>{this.id&&b(this.id,this._state)};this.applyPatch=t=>{let e=this._state,r=j(this._state,t);return this._state=this.cleanup(r,e,t),this.useStore.setState(this._state),this};this.cleanup=(t,e,r)=>t;this.patchState=t=>(this.applyPatch(t),this);this.replaceState=t=>(this._state=this.cleanup(t,this._state,t),this.useStore.setState(this._state),this);this.setState=t=>(this.pointer++,this.stack=this.stack.slice(0,this.pointer),this.stack.push(t),this.applyPatch(t.after),this.persist(),this);this.reset=()=>(this._state=this.initialState,this.useStore.setState(this.initialState),this.resetHistory(),this.persist(),this);this.resetHistory=()=>(this.stack=[],this.pointer=-1,this);this.undo=()=>{if(!this.canUndo)return this;let t=this.stack[this.pointer];return this.pointer--,this.applyPatch(t.before),this.persist(),this};this.redo=()=>{if(!this.canRedo)return this;this.pointer++;let t=this.stack[this.pointer];return this.applyPatch(t.after),this.persist(),this};this.setSnapshot=()=>(this.snapshot=g({},this._state),this);this.forceUpdate=()=>{this.useStore.setState(this._state)};this.id=e,this._state=t,this.snapshot=t,this.initialState=t,this.useStore=v(t),this.id&&P(this.id).then(i=>w(this,null,function*(){if(i){let o=i;if(r){let S=yield P(e+"_version");S&&S<r&&(o=a?a(i,t,S):t)}yield b(e+"_version",r||-1),this._state=o,this.snapshot=o,this.initialState=o,this._status="ready",this.useStore.setState(this._state)}else yield b(e+"_version",r||-1),this._status="ready"}))}get canUndo(){return this.pointer>-1}get canRedo(){return this.pointer<this.stack.length-1}get state(){return this._state}get status(){return this._status}};export{K as StateManager};

@@ -1,1 +0,1 @@

var V=Object.create;var T=Object.defineProperty;var z=Object.getOwnPropertyDescriptor;var G=Object.getOwnPropertyNames,P=Object.getOwnPropertySymbols,H=Object.getPrototypeOf,k=Object.prototype.hasOwnProperty,L=Object.prototype.propertyIsEnumerable;var R=(r,t,e)=>t in r?T(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,y=(r,t)=>{for(var e in t||(t={}))k.call(t,e)&&R(r,e,t[e]);if(P)for(var e of P(t))L.call(t,e)&&R(r,e,t[e]);return r};var j=r=>T(r,"__esModule",{value:!0});var W=(r,t)=>{j(r);for(var e in t)T(r,e,{get:t[e],enumerable:!0})},$=(r,t,e)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of G(t))!k.call(r,n)&&n!=="default"&&T(r,n,{get:()=>t[n],enumerable:!(e=z(t,n))||e.enumerable});return r},J=r=>$(j(T(r!=null?V(H(r)):{},"default",r&&r.__esModule&&"default"in r?{get:()=>r.default,enumerable:!0}:{value:r,enumerable:!0})),r);var A=(r,t,e)=>new Promise((n,i)=>{var o=u=>{try{f(e.next(u))}catch(s){i(s)}},d=u=>{try{f(e.throw(u))}catch(s){i(s)}},f=u=>u.done?n(u.value):Promise.resolve(u.value).then(o,d);f((e=e.apply(r,t)).next())});W(exports,{StateManager:()=>I});function M(r){let t,e=new Set,n=(s,c)=>{let a=typeof s=="function"?s(t):s;if(a!==t){let h=t;t=c?a:Object.assign({},t,a),e.forEach(p=>p(t,h))}},i=()=>t,o=(s,c=i,a=Object.is)=>{let h=c(t);function p(){let b=c(t);if(!a(h,b)){let S=h;s(h=b,S)}}return e.add(p),()=>e.delete(p)},u={setState:n,getState:i,subscribe:(s,c,a)=>c||a?o(s,c,a):(e.add(s),()=>e.delete(s)),destroy:()=>e.clear()};return t=r(n,i,u),u}var l=J(require("react"));function K(r){let t,e=new Set,n=(s,c)=>{let a=typeof s=="function"?s(t):s;if(a!==t){let h=t;t=c?a:Object.assign({},t,a),e.forEach(p=>p(t,h))}},i=()=>t,o=(s,c=i,a=Object.is)=>{let h=c(t);function p(){let b=c(t);if(!a(h,b)){let S=h;s(h=b,S)}}return e.add(p),()=>e.delete(p)},u={setState:n,getState:i,subscribe:(s,c,a)=>c||a?o(s,c,a):(e.add(s),()=>e.delete(s)),destroy:()=>e.clear()};return t=r(n,i,u),u}var Q=typeof window=="undefined"||!window.navigator||/ServerSideRendering|^Deno\//.test(window.navigator.userAgent),O=Q?l.useEffect:l.useLayoutEffect;function C(r){let t=typeof r=="function"?K(r):r,e=(n=t.getState,i=Object.is)=>{let[,o]=(0,l.useReducer)(S=>S+1,0),d=t.getState(),f=(0,l.useRef)(d),u=(0,l.useRef)(n),s=(0,l.useRef)(i),c=(0,l.useRef)(!1),a=(0,l.useRef)();a.current===void 0&&(a.current=n(d));let h,p=!1;(f.current!==d||u.current!==n||s.current!==i||c.current)&&(h=n(d),p=!i(a.current,h)),O(()=>{p&&(a.current=h),f.current=d,u.current=n,s.current=i,c.current=!1});let b=(0,l.useRef)(d);return O(()=>{let S=()=>{try{let v=t.getState(),_=u.current(v);s.current(a.current,_)||(f.current=v,a.current=_,o())}catch(v){c.current=!0,o()}},B=t.subscribe(S);return t.getState()!==b.current&&S(),B},[]),p?h:a.current};return Object.assign(e,t),e[Symbol.iterator]=function(){console.warn("[useStore, api] = create() is deprecated and will be removed in v4");let n=[e,t];return{next(){let i=n.length<=0;return{value:n.shift(),done:i}}}},e}function X(){if(!(!navigator.userAgentData&&/Safari\//.test(navigator.userAgent)&&!/Chrom(e|ium)\//.test(navigator.userAgent))||!indexedDB.databases)return Promise.resolve();let t;return new Promise(e=>{let n=()=>indexedDB.databases().finally(e);t=setInterval(n,100),n()}).finally(()=>clearInterval(t))}var E=X;function m(r){return new Promise((t,e)=>{r.oncomplete=r.onsuccess=()=>t(r.result),r.onabort=r.onerror=()=>e(r.error)})}function Y(r,t){let e=E().then(()=>{let n=indexedDB.open(r);return n.onupgradeneeded=()=>n.result.createObjectStore(t),m(n)});return(n,i)=>e.then(o=>i(o.transaction(t,n).objectStore(t)))}var x;function U(){return x||(x=Y("keyval-store","keyval")),x}function w(r,t=U()){return t("readonly",e=>m(e.get(r)))}function g(r,t,e=U()){return e("readwrite",n=>(n.put(t,r),m(n.transaction)))}function D(r,t){let e=y({},r),n=Object.entries(t);for(let[i,o]of n)e[i]=o===Object(o)&&!Array.isArray(o)?D(e[i],o):o;return e}var I=class{constructor(t,e,n,i){this.stack=[];this.pointer=-1;this._status="loading";this.persist=()=>{this.id&&g(this.id,this._state)};this.applyPatch=t=>{let e=this._state,n=D(this._state,t);return this._state=this.cleanup(n,e,t),this.store.setState(this._state,!0),this};this.cleanup=(t,e,n)=>t;this.patchState=t=>(this.applyPatch(t),this);this.replaceState=t=>(this._state=this.cleanup(t,this._state,t),this.store.setState(this._state,!0),this);this.setState=t=>(this.pointer++,this.stack=this.stack.slice(0,this.pointer),this.stack.push(t),this.applyPatch(t.after),this.persist(),this);this.reset=()=>(this._state=this.initialState,this.store.setState(this.initialState,!0),this.resetHistory(),this.persist(),this);this.resetHistory=()=>(this.stack=[],this.pointer=-1,this);this.undo=()=>{if(!this.canUndo)return this;let t=this.stack[this.pointer];return this.pointer--,this.applyPatch(t.before),this.persist(),this};this.redo=()=>{if(!this.canRedo)return this;this.pointer++;let t=this.stack[this.pointer];return this.applyPatch(t.after),this.persist(),this};this.setSnapshot=()=>(this.snapshot=y({},this._state),this);this.forceUpdate=()=>{this.store.setState(this._state,!0)};this.id=e,this._state=t,this.snapshot=t,this.initialState=t,this.store=M(()=>t),this.useStore=C(this.store),this.id&&w(this.id).then(o=>A(this,null,function*(){if(o){let d=o;if(n){let f=yield w(e+"_version");f&&f<n&&(d=i?i(o,t,f):t)}yield g(e+"_version",n||-1),this._state=d,this.snapshot=d,this.initialState=d,this._status="ready",this.store.setState(this._state,!0)}else yield g(e+"_version",n||-1),this._status="ready"}))}get canUndo(){return this.pointer>-1}get canRedo(){return this.pointer<this.stack.length-1}get state(){return this._state}get status(){return this._status}};
var M=Object.create;var f=Object.defineProperty;var O=Object.getOwnPropertyDescriptor;var G=Object.getOwnPropertyNames,U=Object.getOwnPropertySymbols,V=Object.getPrototypeOf,w=Object.prototype.hasOwnProperty,q=Object.prototype.propertyIsEnumerable;var D=(r,t,e)=>t in r?f(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,v=(r,t)=>{for(var e in t||(t={}))w.call(t,e)&&D(r,e,t[e]);if(U)for(var e of U(t))q.call(t,e)&&D(r,e,t[e]);return r};var R=r=>f(r,"__esModule",{value:!0});var H=(r,t)=>{R(r);for(var e in t)f(r,e,{get:t[e],enumerable:!0})},K=(r,t,e)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of G(t))!w.call(r,s)&&s!=="default"&&f(r,s,{get:()=>t[s],enumerable:!(e=O(t,s))||e.enumerable});return r},z=r=>K(R(f(r!=null?M(V(r)):{},"default",r&&r.__esModule&&"default"in r?{get:()=>r.default,enumerable:!0}:{value:r,enumerable:!0})),r);var L=(r,t,e)=>new Promise((s,a)=>{var i=l=>{try{u(e.next(l))}catch(n){a(n)}},o=l=>{try{u(e.throw(l))}catch(n){a(n)}},u=l=>l.done?s(l.value):Promise.resolve(l.value).then(i,o);u((e=e.apply(r,t)).next())});H(exports,{StateManager:()=>C});var S=z(require("react")),F=typeof window=="undefined"||!window.navigator||/ServerSideRendering|^Deno\//.test(window.navigator.userAgent),j=F?S.useEffect:S.useLayoutEffect;function W(r){let t=r,e=new Set,s=n=>{let h=n;if(h!==t){let c=t;t=h,e.forEach(d=>d(t,c))}},a=()=>t,i=(n,h=a,c=Object.is)=>{let d=h(t);function p(){let b=h(t);if(!c(d,b)){let T=d;n(d=b,T)}}return e.add(p),()=>e.delete(p)};return{setState:s,getState:a,subscribe:(n,h,c)=>h||c?i(n,h,c):(e.add(n),()=>e.delete(n)),destroy:()=>e.clear()}}function x(r){let t=W(r),e=(s=t.getState,a=Object.is)=>{let[,i]=(0,S.useReducer)(T=>T+1,0),o=t.getState(),u=(0,S.useRef)(o),l=(0,S.useRef)(s),n=(0,S.useRef)(a),h=(0,S.useRef)(!1),c=(0,S.useRef)();c.current===void 0&&(c.current=s(o));let d,p=!1;(u.current!==o||l.current!==s||n.current!==a||h.current)&&(d=s(o),p=!a(c.current,d)),j(()=>{p&&(c.current=d),u.current=o,l.current=s,n.current=a,h.current=!1});let b=(0,S.useRef)(o);return j(()=>{let T=()=>{try{let g=t.getState(),k=l.current(g);n.current(c.current,k)||(u.current=g,c.current=k,i())}catch(g){h.current=!0,i()}},E=t.subscribe(T);return t.getState()!==b.current&&T(),E},[]),p?d:c.current};return Object.assign(e,t),e}function J(){if(!(!navigator.userAgentData&&/Safari\//.test(navigator.userAgent)&&!/Chrom(e|ium)\//.test(navigator.userAgent))||!indexedDB.databases)return Promise.resolve();let t;return new Promise(e=>{let s=()=>indexedDB.databases().finally(e);t=setInterval(s,100),s()}).finally(()=>clearInterval(t))}var I=J;function m(r){return new Promise((t,e)=>{r.oncomplete=r.onsuccess=()=>t(r.result),r.onabort=r.onerror=()=>e(r.error)})}function Q(r,t){let e=I().then(()=>{let s=indexedDB.open(r);return s.onupgradeneeded=()=>s.result.createObjectStore(t),m(s)});return(s,a)=>e.then(i=>a(i.transaction(t,s).objectStore(t)))}var P;function A(){return P||(P=Q("keyval-store","keyval")),P}function _(r,t=A()){return t("readonly",e=>m(e.get(r)))}function y(r,t,e=A()){return e("readwrite",s=>(s.put(t,r),m(s.transaction)))}function B(r,t){let e=v({},r),s=Object.entries(t);for(let[a,i]of s)e[a]=i===Object(i)&&!Array.isArray(i)?B(e[a],i):i;return e}var C=class{constructor(t,e,s,a){this.stack=[];this.pointer=-1;this._status="loading";this.persist=()=>{this.id&&y(this.id,this._state)};this.applyPatch=t=>{let e=this._state,s=B(this._state,t);return this._state=this.cleanup(s,e,t),this.useStore.setState(this._state),this};this.cleanup=(t,e,s)=>t;this.patchState=t=>(this.applyPatch(t),this);this.replaceState=t=>(this._state=this.cleanup(t,this._state,t),this.useStore.setState(this._state),this);this.setState=t=>(this.pointer++,this.stack=this.stack.slice(0,this.pointer),this.stack.push(t),this.applyPatch(t.after),this.persist(),this);this.reset=()=>(this._state=this.initialState,this.useStore.setState(this.initialState),this.resetHistory(),this.persist(),this);this.resetHistory=()=>(this.stack=[],this.pointer=-1,this);this.undo=()=>{if(!this.canUndo)return this;let t=this.stack[this.pointer];return this.pointer--,this.applyPatch(t.before),this.persist(),this};this.redo=()=>{if(!this.canRedo)return this;this.pointer++;let t=this.stack[this.pointer];return this.applyPatch(t.after),this.persist(),this};this.setSnapshot=()=>(this.snapshot=v({},this._state),this);this.forceUpdate=()=>{this.useStore.setState(this._state)};this.id=e,this._state=t,this.snapshot=t,this.initialState=t,this.useStore=x(t),this.id&&_(this.id).then(i=>L(this,null,function*(){if(i){let o=i;if(s){let u=yield _(e+"_version");u&&u<s&&(o=a?a(i,t,u):t)}yield y(e+"_version",s||-1),this._state=o,this.snapshot=o,this.initialState=o,this._status="ready",this.useStore.setState(this._state)}else yield y(e+"_version",s||-1),this._status="ready"}))}get canUndo(){return this.pointer>-1}get canRedo(){return this.pointer<this.stack.length-1}get state(){return this._state}get status(){return this._status}};

@@ -1,2 +0,2 @@

import { UseStore } from 'zustand';
import { UseStore } from './zustanchen';
export declare type Patch<T> = Partial<{

@@ -19,6 +19,2 @@ [P in keyof T]: Patch<T[P]>;

/**
* A zustand store that also holds the state.
*/
private store;
/**
* A stack of commands used for history (undo and redo_.

@@ -25,0 +21,0 @@ */

{
"private": false,
"version": "0.5.10",
"version": "0.5.11",
"name": "rko",

@@ -32,3 +32,3 @@ "author": {

"@types/node": "^15.0.1",
"@types/react": "^17.0.16",
"@types/react": "^17.0.19",
"@types/react-dom": "^17.0.9",

@@ -50,6 +50,5 @@ "esbuild": "^0.12.21",

"dependencies": {
"idb-keyval": "^5.1.3",
"zustand": "^3.5.9"
"safari-14-idb-fix": "^1.0.4"
},
"gitHead": "c9de8e6c129dfe9edddf971cf37980c4a8367e4d"
"gitHead": "89e2306a7f570d5016a1e9e369d865793333d29e"
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc