tinybase 0.9.3 → 1.0.2
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/LICENSE +1 -1
- package/lib/debug/checkpoints.d.ts +3 -0
- package/lib/debug/common.d.ts +56 -0
- package/lib/debug/indexes.d.ts +7 -58
- package/lib/debug/metrics.d.ts +6 -2
- package/lib/debug/persisters.d.ts +15 -8
- package/lib/debug/relationships.d.ts +3 -1
- package/lib/debug/store.d.ts +13 -10
- package/lib/debug/tinybase.js +16 -8
- package/lib/debug/ui-react.d.ts +29 -2
- package/lib/debug/ui-react.js +8 -2
- package/package.json +28 -12
- package/readme.md +2 -2
- package/lib/checkpoints.d.ts +0 -876
- package/lib/checkpoints.js +0 -1
- package/lib/checkpoints.js.gz +0 -0
- package/lib/common.d.ts +0 -59
- package/lib/debug/checkpoints.js +0 -326
- package/lib/debug/indexes.js +0 -390
- package/lib/debug/metrics.js +0 -391
- package/lib/debug/persisters.js +0 -191
- package/lib/debug/relationships.js +0 -418
- package/lib/debug/store.js +0 -725
- package/lib/indexes.d.ts +0 -829
- package/lib/indexes.js +0 -1
- package/lib/indexes.js.gz +0 -0
- package/lib/metrics.d.ts +0 -753
- package/lib/metrics.js +0 -1
- package/lib/metrics.js.gz +0 -0
- package/lib/persisters.d.ts +0 -704
- package/lib/persisters.js +0 -1
- package/lib/persisters.js.gz +0 -0
- package/lib/relationships.d.ts +0 -1114
- package/lib/relationships.js +0 -1
- package/lib/relationships.js.gz +0 -0
- package/lib/store.d.ts +0 -2503
- package/lib/store.js +0 -1
- package/lib/store.js.gz +0 -0
- package/lib/tinybase.d.ts +0 -13
- package/lib/tinybase.js +0 -1
- package/lib/tinybase.js.gz +0 -0
- package/lib/ui-react.d.ts +0 -7158
- package/lib/ui-react.js +0 -1
- package/lib/ui-react.js.gz +0 -0
- package/lib/umd/checkpoints.js +0 -1
- package/lib/umd/checkpoints.js.gz +0 -0
- package/lib/umd/indexes.js +0 -1
- package/lib/umd/indexes.js.gz +0 -0
- package/lib/umd/metrics.js +0 -1
- package/lib/umd/metrics.js.gz +0 -0
- package/lib/umd/persisters.js +0 -1
- package/lib/umd/persisters.js.gz +0 -0
- package/lib/umd/relationships.js +0 -1
- package/lib/umd/relationships.js.gz +0 -0
- package/lib/umd/store.js +0 -1
- package/lib/umd/store.js.gz +0 -0
- package/lib/umd/tinybase.js +0 -1
- package/lib/umd/tinybase.js.gz +0 -0
- package/lib/umd/ui-react.js +0 -1
- package/lib/umd/ui-react.js.gz +0 -0
package/lib/persisters.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{promises as t,watch as e}from"fs";const a=t=>null==t,o=(t,e,o)=>a(t)?o?.():e(t),s=Object.freeze,r=(t,e,r,n,c)=>{let i,d=0;const l={load:async o=>{if(2!=d){d=1;const s=await e();a(s)||""==s?t.setTables(o):t.setJson(s),d=0}return l},startAutoLoad:async t=>(l.stopAutoLoad(),await l.load(t),n(l.load),l),stopAutoLoad:()=>(c(),l),save:async()=>(1!=d&&(d=2,await r(t.getJson()),d=0),l),startAutoSave:async()=>(await l.stopAutoSave().save(),i=t.addTablesListener((()=>l.save())),l),stopAutoSave:()=>(o(i,t.delListener),l),getStore:()=>t,destroy:()=>l.stopAutoLoad().stopAutoSave(),getStats:()=>({})};return s(l)},n=globalThis.window,c=(t,e,a)=>{let o;return r(t,(async()=>a.getItem(e)),(async t=>a.setItem(e,t)),(t=>{o=o=>{o.storageArea===a&&o.key===e&&t()},n.addEventListener("storage",o)}),(()=>{n.removeEventListener("storage",o),o=void 0}))},i=(t,e)=>c(t,e,localStorage),d=(t,e)=>c(t,e,sessionStorage),l=(a,o)=>{let s;return r(a,(async()=>{try{return await t.readFile(o,"utf8")}catch{}}),(async e=>{try{await t.writeFile(o,e,"utf8")}catch{}}),(t=>{s=e(o,t)}),(()=>{s?.close(),s=void 0}))},u=t=>t.headers.get("ETag"),y=(t,e,s,n)=>{let c,i;return r(t,(async()=>{const t=await fetch(e);return i=u(t),t.text()}),(async t=>await fetch(s,{method:"POST",headers:{"Content-Type":"application/json"},body:t})),(t=>{c=setInterval((async()=>{const o=await fetch(e,{method:"HEAD"}),s=u(o);a(i)||a(s)||s==i||(i=s,t())}),1e3*n)}),(()=>{o(c,clearInterval),c=void 0}))};export{r as createCustomPersister,l as createFilePersister,i as createLocalPersister,y as createRemotePersister,d as createSessionPersister};
|
package/lib/persisters.js.gz
DELETED
|
Binary file
|