tinybase 1.0.1 → 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.
Files changed (53) hide show
  1. package/package.json +9 -2
  2. package/lib/checkpoints.d.ts +0 -879
  3. package/lib/checkpoints.js +0 -1
  4. package/lib/checkpoints.js.gz +0 -0
  5. package/lib/common.d.ts +0 -115
  6. package/lib/common.js +0 -1
  7. package/lib/common.js.gz +0 -0
  8. package/lib/debug/checkpoints.js +0 -326
  9. package/lib/debug/common.js +0 -3
  10. package/lib/debug/indexes.js +0 -398
  11. package/lib/debug/metrics.js +0 -391
  12. package/lib/debug/persisters.js +0 -191
  13. package/lib/debug/relationships.js +0 -418
  14. package/lib/debug/store.js +0 -725
  15. package/lib/indexes.d.ts +0 -778
  16. package/lib/indexes.js +0 -1
  17. package/lib/indexes.js.gz +0 -0
  18. package/lib/metrics.d.ts +0 -757
  19. package/lib/metrics.js +0 -1
  20. package/lib/metrics.js.gz +0 -0
  21. package/lib/persisters.d.ts +0 -711
  22. package/lib/persisters.js +0 -1
  23. package/lib/persisters.js.gz +0 -0
  24. package/lib/relationships.d.ts +0 -1116
  25. package/lib/relationships.js +0 -1
  26. package/lib/relationships.js.gz +0 -0
  27. package/lib/store.d.ts +0 -2506
  28. package/lib/store.js +0 -1
  29. package/lib/store.js.gz +0 -0
  30. package/lib/tinybase.d.ts +0 -13
  31. package/lib/tinybase.js +0 -1
  32. package/lib/tinybase.js.gz +0 -0
  33. package/lib/ui-react.d.ts +0 -7185
  34. package/lib/ui-react.js +0 -1
  35. package/lib/ui-react.js.gz +0 -0
  36. package/lib/umd/checkpoints.js +0 -1
  37. package/lib/umd/checkpoints.js.gz +0 -0
  38. package/lib/umd/common.js +0 -1
  39. package/lib/umd/common.js.gz +0 -0
  40. package/lib/umd/indexes.js +0 -1
  41. package/lib/umd/indexes.js.gz +0 -0
  42. package/lib/umd/metrics.js +0 -1
  43. package/lib/umd/metrics.js.gz +0 -0
  44. package/lib/umd/persisters.js +0 -1
  45. package/lib/umd/persisters.js.gz +0 -0
  46. package/lib/umd/relationships.js +0 -1
  47. package/lib/umd/relationships.js.gz +0 -0
  48. package/lib/umd/store.js +0 -1
  49. package/lib/umd/store.js.gz +0 -0
  50. package/lib/umd/tinybase.js +0 -1
  51. package/lib/umd/tinybase.js.gz +0 -0
  52. package/lib/umd/ui-react.js +0 -1
  53. 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};
Binary file