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.
Files changed (60) hide show
  1. package/LICENSE +1 -1
  2. package/lib/debug/checkpoints.d.ts +3 -0
  3. package/lib/debug/common.d.ts +56 -0
  4. package/lib/debug/indexes.d.ts +7 -58
  5. package/lib/debug/metrics.d.ts +6 -2
  6. package/lib/debug/persisters.d.ts +15 -8
  7. package/lib/debug/relationships.d.ts +3 -1
  8. package/lib/debug/store.d.ts +13 -10
  9. package/lib/debug/tinybase.js +16 -8
  10. package/lib/debug/ui-react.d.ts +29 -2
  11. package/lib/debug/ui-react.js +8 -2
  12. package/package.json +28 -12
  13. package/readme.md +2 -2
  14. package/lib/checkpoints.d.ts +0 -876
  15. package/lib/checkpoints.js +0 -1
  16. package/lib/checkpoints.js.gz +0 -0
  17. package/lib/common.d.ts +0 -59
  18. package/lib/debug/checkpoints.js +0 -326
  19. package/lib/debug/indexes.js +0 -390
  20. package/lib/debug/metrics.js +0 -391
  21. package/lib/debug/persisters.js +0 -191
  22. package/lib/debug/relationships.js +0 -418
  23. package/lib/debug/store.js +0 -725
  24. package/lib/indexes.d.ts +0 -829
  25. package/lib/indexes.js +0 -1
  26. package/lib/indexes.js.gz +0 -0
  27. package/lib/metrics.d.ts +0 -753
  28. package/lib/metrics.js +0 -1
  29. package/lib/metrics.js.gz +0 -0
  30. package/lib/persisters.d.ts +0 -704
  31. package/lib/persisters.js +0 -1
  32. package/lib/persisters.js.gz +0 -0
  33. package/lib/relationships.d.ts +0 -1114
  34. package/lib/relationships.js +0 -1
  35. package/lib/relationships.js.gz +0 -0
  36. package/lib/store.d.ts +0 -2503
  37. package/lib/store.js +0 -1
  38. package/lib/store.js.gz +0 -0
  39. package/lib/tinybase.d.ts +0 -13
  40. package/lib/tinybase.js +0 -1
  41. package/lib/tinybase.js.gz +0 -0
  42. package/lib/ui-react.d.ts +0 -7158
  43. package/lib/ui-react.js +0 -1
  44. package/lib/ui-react.js.gz +0 -0
  45. package/lib/umd/checkpoints.js +0 -1
  46. package/lib/umd/checkpoints.js.gz +0 -0
  47. package/lib/umd/indexes.js +0 -1
  48. package/lib/umd/indexes.js.gz +0 -0
  49. package/lib/umd/metrics.js +0 -1
  50. package/lib/umd/metrics.js.gz +0 -0
  51. package/lib/umd/persisters.js +0 -1
  52. package/lib/umd/persisters.js.gz +0 -0
  53. package/lib/umd/relationships.js +0 -1
  54. package/lib/umd/relationships.js.gz +0 -0
  55. package/lib/umd/store.js +0 -1
  56. package/lib/umd/store.js.gz +0 -0
  57. package/lib/umd/tinybase.js +0 -1
  58. package/lib/umd/tinybase.js.gz +0 -0
  59. package/lib/umd/ui-react.js +0 -1
  60. 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