tinybase 4.0.3 → 4.0.4

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 (165) hide show
  1. package/lib/cjs/persisters/persister-automerge.cjs +1 -1
  2. package/lib/cjs/persisters/persister-automerge.cjs.gz +0 -0
  3. package/lib/cjs/persisters/persister-browser.cjs +1 -1
  4. package/lib/cjs/persisters/persister-browser.cjs.gz +0 -0
  5. package/lib/cjs/persisters/persister-cr-sqlite-wasm.cjs +1 -1
  6. package/lib/cjs/persisters/persister-cr-sqlite-wasm.cjs.gz +0 -0
  7. package/lib/cjs/persisters/persister-expo-sqlite.cjs +1 -1
  8. package/lib/cjs/persisters/persister-expo-sqlite.cjs.gz +0 -0
  9. package/lib/cjs/persisters/persister-file.cjs +1 -1
  10. package/lib/cjs/persisters/persister-file.cjs.gz +0 -0
  11. package/lib/cjs/persisters/persister-remote.cjs +1 -1
  12. package/lib/cjs/persisters/persister-remote.cjs.gz +0 -0
  13. package/lib/cjs/persisters/persister-sqlite-wasm.cjs +1 -1
  14. package/lib/cjs/persisters/persister-sqlite-wasm.cjs.gz +0 -0
  15. package/lib/cjs/persisters/persister-sqlite3.cjs +1 -1
  16. package/lib/cjs/persisters/persister-sqlite3.cjs.gz +0 -0
  17. package/lib/cjs/persisters/persister-yjs.cjs +1 -1
  18. package/lib/cjs/persisters/persister-yjs.cjs.gz +0 -0
  19. package/lib/cjs/persisters.cjs +1 -1
  20. package/lib/cjs/persisters.cjs.gz +0 -0
  21. package/lib/cjs/tinybase.cjs +1 -1
  22. package/lib/cjs/tinybase.cjs.gz +0 -0
  23. package/lib/cjs-es6/persisters/persister-automerge.cjs +1 -1
  24. package/lib/cjs-es6/persisters/persister-automerge.cjs.gz +0 -0
  25. package/lib/cjs-es6/persisters/persister-browser.cjs +1 -1
  26. package/lib/cjs-es6/persisters/persister-browser.cjs.gz +0 -0
  27. package/lib/cjs-es6/persisters/persister-cr-sqlite-wasm.cjs +1 -1
  28. package/lib/cjs-es6/persisters/persister-cr-sqlite-wasm.cjs.gz +0 -0
  29. package/lib/cjs-es6/persisters/persister-expo-sqlite.cjs +1 -1
  30. package/lib/cjs-es6/persisters/persister-expo-sqlite.cjs.gz +0 -0
  31. package/lib/cjs-es6/persisters/persister-file.cjs +1 -1
  32. package/lib/cjs-es6/persisters/persister-file.cjs.gz +0 -0
  33. package/lib/cjs-es6/persisters/persister-remote.cjs +1 -1
  34. package/lib/cjs-es6/persisters/persister-remote.cjs.gz +0 -0
  35. package/lib/cjs-es6/persisters/persister-sqlite-wasm.cjs +1 -1
  36. package/lib/cjs-es6/persisters/persister-sqlite-wasm.cjs.gz +0 -0
  37. package/lib/cjs-es6/persisters/persister-sqlite3.cjs +1 -1
  38. package/lib/cjs-es6/persisters/persister-sqlite3.cjs.gz +0 -0
  39. package/lib/cjs-es6/persisters/persister-yjs.cjs +1 -1
  40. package/lib/cjs-es6/persisters/persister-yjs.cjs.gz +0 -0
  41. package/lib/cjs-es6/persisters.cjs +1 -1
  42. package/lib/cjs-es6/persisters.cjs.gz +0 -0
  43. package/lib/cjs-es6/tinybase.cjs +1 -1
  44. package/lib/cjs-es6/tinybase.cjs.gz +0 -0
  45. package/lib/debug/persisters/persister-automerge.js +56 -18
  46. package/lib/debug/persisters/persister-browser.js +55 -22
  47. package/lib/debug/persisters/persister-cr-sqlite-wasm.js +106 -62
  48. package/lib/debug/persisters/persister-expo-sqlite.js +111 -62
  49. package/lib/debug/persisters/persister-file.js +51 -18
  50. package/lib/debug/persisters/persister-remote.js +51 -17
  51. package/lib/debug/persisters/persister-sqlite-wasm.js +106 -62
  52. package/lib/debug/persisters/persister-sqlite3.js +111 -62
  53. package/lib/debug/persisters/persister-yjs.js +63 -27
  54. package/lib/debug/persisters.js +49 -17
  55. package/lib/debug/tinybase.js +35 -17
  56. package/lib/es6/persisters/persister-automerge.js +1 -1
  57. package/lib/es6/persisters/persister-automerge.js.gz +0 -0
  58. package/lib/es6/persisters/persister-browser.js +1 -1
  59. package/lib/es6/persisters/persister-browser.js.gz +0 -0
  60. package/lib/es6/persisters/persister-cr-sqlite-wasm.js +1 -1
  61. package/lib/es6/persisters/persister-cr-sqlite-wasm.js.gz +0 -0
  62. package/lib/es6/persisters/persister-expo-sqlite.js +1 -1
  63. package/lib/es6/persisters/persister-expo-sqlite.js.gz +0 -0
  64. package/lib/es6/persisters/persister-file.js +1 -1
  65. package/lib/es6/persisters/persister-file.js.gz +0 -0
  66. package/lib/es6/persisters/persister-remote.js +1 -1
  67. package/lib/es6/persisters/persister-remote.js.gz +0 -0
  68. package/lib/es6/persisters/persister-sqlite-wasm.js +1 -1
  69. package/lib/es6/persisters/persister-sqlite-wasm.js.gz +0 -0
  70. package/lib/es6/persisters/persister-sqlite3.js +1 -1
  71. package/lib/es6/persisters/persister-sqlite3.js.gz +0 -0
  72. package/lib/es6/persisters/persister-yjs.js +1 -1
  73. package/lib/es6/persisters/persister-yjs.js.gz +0 -0
  74. package/lib/es6/persisters.js +1 -1
  75. package/lib/es6/persisters.js.gz +0 -0
  76. package/lib/es6/tinybase.js +1 -1
  77. package/lib/es6/tinybase.js.gz +0 -0
  78. package/lib/persisters/persister-automerge.js +1 -1
  79. package/lib/persisters/persister-automerge.js.gz +0 -0
  80. package/lib/persisters/persister-browser.js +1 -1
  81. package/lib/persisters/persister-browser.js.gz +0 -0
  82. package/lib/persisters/persister-cr-sqlite-wasm.js +1 -1
  83. package/lib/persisters/persister-cr-sqlite-wasm.js.gz +0 -0
  84. package/lib/persisters/persister-expo-sqlite.js +1 -1
  85. package/lib/persisters/persister-expo-sqlite.js.gz +0 -0
  86. package/lib/persisters/persister-file.js +1 -1
  87. package/lib/persisters/persister-file.js.gz +0 -0
  88. package/lib/persisters/persister-remote.js +1 -1
  89. package/lib/persisters/persister-remote.js.gz +0 -0
  90. package/lib/persisters/persister-sqlite-wasm.js +1 -1
  91. package/lib/persisters/persister-sqlite-wasm.js.gz +0 -0
  92. package/lib/persisters/persister-sqlite3.js +1 -1
  93. package/lib/persisters/persister-sqlite3.js.gz +0 -0
  94. package/lib/persisters/persister-yjs.js +1 -1
  95. package/lib/persisters/persister-yjs.js.gz +0 -0
  96. package/lib/persisters.js +1 -1
  97. package/lib/persisters.js.gz +0 -0
  98. package/lib/tinybase.js +1 -1
  99. package/lib/tinybase.js.gz +0 -0
  100. package/lib/types/persisters/persister-automerge.d.ts +4 -0
  101. package/lib/types/persisters/persister-browser.d.ts +8 -0
  102. package/lib/types/persisters/persister-cr-sqlite-wasm.d.ts +10 -2
  103. package/lib/types/persisters/persister-expo-sqlite.d.ts +8 -0
  104. package/lib/types/persisters/persister-file.d.ts +8 -1
  105. package/lib/types/persisters/persister-remote.d.ts +4 -0
  106. package/lib/types/persisters/persister-sqlite-wasm.d.ts +8 -0
  107. package/lib/types/persisters/persister-sqlite3.d.ts +8 -0
  108. package/lib/types/persisters/persister-yjs.d.ts +4 -0
  109. package/lib/types/persisters.d.ts +16 -3
  110. package/lib/types/with-schemas/persisters/persister-automerge.d.ts +5 -0
  111. package/lib/types/with-schemas/persisters/persister-browser.d.ts +10 -0
  112. package/lib/types/with-schemas/persisters/persister-cr-sqlite-wasm.d.ts +12 -2
  113. package/lib/types/with-schemas/persisters/persister-expo-sqlite.d.ts +10 -0
  114. package/lib/types/with-schemas/persisters/persister-file.d.ts +9 -1
  115. package/lib/types/with-schemas/persisters/persister-remote.d.ts +5 -0
  116. package/lib/types/with-schemas/persisters/persister-sqlite-wasm.d.ts +10 -0
  117. package/lib/types/with-schemas/persisters/persister-sqlite3.d.ts +10 -0
  118. package/lib/types/with-schemas/persisters/persister-yjs.d.ts +5 -0
  119. package/lib/types/with-schemas/persisters.d.ts +17 -3
  120. package/lib/umd/persisters/persister-automerge.js +1 -1
  121. package/lib/umd/persisters/persister-automerge.js.gz +0 -0
  122. package/lib/umd/persisters/persister-browser.js +1 -1
  123. package/lib/umd/persisters/persister-browser.js.gz +0 -0
  124. package/lib/umd/persisters/persister-cr-sqlite-wasm.js +1 -1
  125. package/lib/umd/persisters/persister-cr-sqlite-wasm.js.gz +0 -0
  126. package/lib/umd/persisters/persister-expo-sqlite.js +1 -1
  127. package/lib/umd/persisters/persister-expo-sqlite.js.gz +0 -0
  128. package/lib/umd/persisters/persister-file.js +1 -1
  129. package/lib/umd/persisters/persister-file.js.gz +0 -0
  130. package/lib/umd/persisters/persister-remote.js +1 -1
  131. package/lib/umd/persisters/persister-remote.js.gz +0 -0
  132. package/lib/umd/persisters/persister-sqlite-wasm.js +1 -1
  133. package/lib/umd/persisters/persister-sqlite-wasm.js.gz +0 -0
  134. package/lib/umd/persisters/persister-sqlite3.js +1 -1
  135. package/lib/umd/persisters/persister-sqlite3.js.gz +0 -0
  136. package/lib/umd/persisters/persister-yjs.js +1 -1
  137. package/lib/umd/persisters/persister-yjs.js.gz +0 -0
  138. package/lib/umd/persisters.js +1 -1
  139. package/lib/umd/persisters.js.gz +0 -0
  140. package/lib/umd/tinybase.js +1 -1
  141. package/lib/umd/tinybase.js.gz +0 -0
  142. package/lib/umd-es6/persisters/persister-automerge.js +1 -1
  143. package/lib/umd-es6/persisters/persister-automerge.js.gz +0 -0
  144. package/lib/umd-es6/persisters/persister-browser.js +1 -1
  145. package/lib/umd-es6/persisters/persister-browser.js.gz +0 -0
  146. package/lib/umd-es6/persisters/persister-cr-sqlite-wasm.js +1 -1
  147. package/lib/umd-es6/persisters/persister-cr-sqlite-wasm.js.gz +0 -0
  148. package/lib/umd-es6/persisters/persister-expo-sqlite.js +1 -1
  149. package/lib/umd-es6/persisters/persister-expo-sqlite.js.gz +0 -0
  150. package/lib/umd-es6/persisters/persister-file.js +1 -1
  151. package/lib/umd-es6/persisters/persister-file.js.gz +0 -0
  152. package/lib/umd-es6/persisters/persister-remote.js +1 -1
  153. package/lib/umd-es6/persisters/persister-remote.js.gz +0 -0
  154. package/lib/umd-es6/persisters/persister-sqlite-wasm.js +1 -1
  155. package/lib/umd-es6/persisters/persister-sqlite-wasm.js.gz +0 -0
  156. package/lib/umd-es6/persisters/persister-sqlite3.js +1 -1
  157. package/lib/umd-es6/persisters/persister-sqlite3.js.gz +0 -0
  158. package/lib/umd-es6/persisters/persister-yjs.js +1 -1
  159. package/lib/umd-es6/persisters/persister-yjs.js.gz +0 -0
  160. package/lib/umd-es6/persisters.js +1 -1
  161. package/lib/umd-es6/persisters.js.gz +0 -0
  162. package/lib/umd-es6/tinybase.js +1 -1
  163. package/lib/umd-es6/tinybase.js.gz +0 -0
  164. package/package.json +5 -5
  165. package/readme.md +2 -2
@@ -1 +1 @@
1
- var e,t;e=this,t=function(e){"use strict";const t=e=>typeof e,n="",l=t(n),s=t(!0),o=t(0),r=t(t),i="type",a="default",d="Listener",c="Result",u="add",v="Ids",h="Table",f=h+"s",g=h+v,L="Row",y=L+v,p="Sorted"+L+v,S="Cell",T=S+v,w="Value",I=w+"s",R=w+v,C=e=>n+e,b=Math.max,m=Math.min,V=isFinite,E=(e,t)=>e instanceof t,k=e=>null==e,x=(e,t,n)=>k(e)?null==n?void 0:n():t(e),M=e=>e==l||e==s,D=e=>t(e)==r,J=e=>Array.isArray(e),A=()=>{},O=(e,t)=>e.includes(t),F=(e,t)=>e.every(t),P=(e,t)=>W(e)===W(t)&&F(e,((e,n)=>t[n]===e)),j=(e,t)=>F(e,((n,l)=>0==l||t(e[l-1],n)<=0)),Q=(e,t)=>e.sort(t),z=(e,t)=>e.forEach(t),N=(e,t)=>e.map(t),B=e=>q(e,((e,t)=>e+t),0),W=e=>e.length,$=e=>0==W(e),q=(e,t,n)=>e.reduce(t,n),G=(e,t,n)=>e.slice(t,n),H=(e,...t)=>e.push(...t),K=e=>e.pop(),U=e=>e.shift(),X=Object,Y=X.keys,Z=X.isFrozen,_=X.freeze,ee=e=>E(e,X)&&e.constructor==X,te=(e,t)=>!k(((e,t)=>x(e,(e=>e[t])))(e,t)),ne=(e,t)=>(delete e[t],e),le=(e,t)=>N(X.entries(e),(([e,n])=>t(n,e))),se=e=>ee(e)&&0==(e=>W(Y(e)))(e),oe=e=>e.size,re=(e,t)=>{var n;return null!=(n=null==e?void 0:e.has(t))&&n},ie=e=>k(e)||0==oe(e),ae=e=>{var t;return[...null!=(t=null==e?void 0:e.values())?t:[]]},de=e=>e.clear(),ce=(e,t)=>null==e?void 0:e.forEach(t),ue=(e,t)=>null==e?void 0:e.delete(t),ve=e=>new Map(e),he=e=>{var t;return[...null!=(t=null==e?void 0:e.keys())?t:[]]},fe=(e,t)=>null==e?void 0:e.get(t),ge=(e,t)=>ce(e,((e,n)=>t(n,e))),Le=(e,t,n)=>k(n)?(ue(e,t),e):null==e?void 0:e.set(t,n),ye=(e,t,n)=>(re(e,t)||Le(e,t,n()),fe(e,t)),pe=(e,t,n,l=Le)=>(le(t,((t,l)=>n(e,l,t))),ge(e,(n=>te(t,n)?0:l(e,n))),e),Se=(e,t,n)=>{const l={};return ce(e,((e,s)=>{const o=t?t(e,s):e;!(null==n?void 0:n(o,e))&&(l[s]=o)})),l},Te=(e,t,n)=>Se(e,(e=>Se(e,t,n)),se),we=(e,t,n)=>Se(e,(e=>Te(e,t,n)),se),Ie=(e,t)=>{const n=ve();return ce(e,((e,l)=>{var s;return n.set(l,null!=(s=null==t?void 0:t(e))?s:e)})),n},Re=e=>Ie(e,Ie),Ce=e=>Ie(e,Re),be=(e,t,n,l,s=0)=>x((n?ye:fe)(e,t[s],s>W(t)-2?n:ve),(o=>{if(s>W(t)-2)return(null==l?void 0:l(o))&&Le(e,t[s]),o;const r=be(o,t,n,l,s+1);return ie(o)&&Le(e,t[s]),r})),me=e=>{const n=t(e);return M(n)||n==o&&V(e)?n:void 0},Ve=(e,t,n,l,s)=>k(s)?e.delCell(t,n,l,!0):e.setCell(t,n,l,s),Ee=(e,t,n)=>k(n)?e.delValue(t):e.setValue(t,n),ke=e=>new Set(J(e)||k(e)?e:[e]),xe=(e,t)=>null==e?void 0:e.add(t),Me=(e,t,n)=>{const l=e.hasRow,s=ve(),o=ve(),r=ve(),i=ve(),a=ve(),d=(t,n,...l)=>{const s=ye(a,t,ke);return z(l,(t=>xe(s,t)&&n&&e.callListener(t))),l},c=(t,...n)=>x(fe(a,t),(l=>{z($(n)?ae(l):n,(t=>{e.delListener(t),ue(l,t)})),ie(l)&&Le(a,t)})),u=(e,n)=>{Le(s,e,n),re(o,e)||(Le(o,e,t()),Le(r,e,ve()),Le(i,e,ve()))},v=e=>{Le(s,e),Le(o,e),Le(r,e),Le(i,e),c(e)};return[()=>e,()=>he(s),e=>ge(o,e),e=>re(o,e),e=>fe(s,e),e=>fe(o,e),(e,t)=>Le(o,e,t),u,(t,s,o,a,v)=>{u(t,s);const h=ve(),f=ve(),g=fe(r,t),L=fe(i,t),y=t=>{const o=n=>e.getCell(s,t,n),r=fe(g,t),i=l(s,t)?n(a(o,t)):void 0;if(r===i||J(r)&&J(i)&&P(r,i)||Le(h,t,[r,i]),!k(v)){const e=fe(L,t),n=l(s,t)?v(o,t):void 0;e!=n&&Le(f,t,n)}},p=e=>{o((()=>{ce(h,(([,e],t)=>Le(g,t,e))),ce(f,((e,t)=>Le(L,t,e)))}),h,f,g,L,e),de(h),de(f)};ge(g,y),e.hasTable(s)&&z(e.getRowIds(s),(e=>{re(g,e)||y(e)})),p(!0),c(t),d(t,0,e.addRowListener(s,null,((e,t,n)=>y(n))),e.addTableListener(s,(()=>p())))},v,()=>ge(a,v),d,c]},De=(e,s)=>t(e)==l?t=>t(e):null!=e?e:()=>null!=s?s:n,Je=e=>{const t=new WeakMap;return n=>(t.has(n)||t.set(n,e(n)),t.get(n))},Ae=/^\d+$/,Oe=()=>{const e=[];let t=0;return[l=>{var s;return null!=(s=l?U(e):null)?s:n+t++},t=>{Ae.test(t)&&W(e)<1e3&&H(e,t)}]},Fe=e=>{let t;const[l,s]=Oe(),o=ve();return[(s,r,i,a=[],d=(()=>[]))=>{null!=t||(t=e());const c=l(1);return Le(o,c,[s,r,i,a,d]),xe(be(r,null!=i?i:[n],ke),c),c},(e,l,...s)=>z(((e,t=[n])=>{const l=[],s=(e,n)=>n==W(t)?H(l,e):null===t[n]?ce(e,(e=>s(e,n+1))):z([t[n],null],(t=>s(fe(e,t),n+1)));return s(e,0),l})(e,l),(e=>ce(e,(e=>fe(o,e)[0](t,...null!=l?l:[],...s))))),e=>x(fe(o,e),(([,t,l])=>(be(t,null!=l?l:[n],void 0,(t=>(ue(t,e),ie(t)?1:0))),Le(o,e),s(e),l))),e=>x(fe(o,e),(([e,,n=[],l,s])=>{const o=(...r)=>{var i,a;const d=W(r);d==W(n)?e(t,...r,...s(r)):k(n[d])?z(null!=(a=null==(i=l[d])?void 0:i.call(l,...r))?a:[],(e=>o(...r,e))):o(...r,n[d])};o()}))]},Pe=Je((e=>{let t,l,s,o=100,r=ve(),i=ve(),a=1;const d=ve(),c=ve(),[u,v,h]=Fe((()=>F)),f=ve(),g=ve(),L=[],y=[],p=(t,n)=>{a=0,e.transaction((()=>{const[l,s]=fe(f,n);ce(l,((n,l)=>ce(n,((n,s)=>ce(n,((n,o)=>Ve(e,l,s,o,n[t]))))))),ce(s,((n,l)=>Ee(e,l,n[t])))})),a=1},S=e=>{Le(f,e),Le(g,e),v(c,[e])},T=(e,t)=>z(((e,t)=>e.splice(0,t))(e,null!=t?t:W(e)),S),w=()=>T(L,W(L)-o),I=()=>x(t,(()=>{H(L,t),w(),T(y),t=void 0,s=1})),R=()=>{t=K(L),s=1},C=e.addCellListener(null,null,null,((e,t,n,l,s,o)=>{if(a){I();const e=ye(r,t,ve),i=ye(e,n,ve),a=ye(i,l,(()=>[o,void 0]));a[1]=s,a[0]===s&&ie(Le(i,l))&&ie(Le(e,n))&&ie(Le(r,t))&&R(),M()}})),b=e.addValueListener(null,((e,t,n,l)=>{if(a){I();const e=ye(i,t,(()=>[l,void 0]));e[1]=n,e[0]===n&&ie(Le(i,t))&&R(),M()}})),m=(e="")=>(k(t)&&(t=n+l++,Le(f,t,[r,i]),J(t,e),r=ve(),i=ve(),s=1),t),V=()=>{$(L)||(((e,...t)=>{e.unshift(...t)})(y,m()),p(0,t),t=K(L),s=1)},E=()=>{$(y)||(H(L,t),t=U(y),p(1,t),s=1)},M=()=>{s&&(v(d),s=0)},D=e=>{const t=m(e);return M(),t},J=(e,t)=>(A(e)&&fe(g,e)!==t&&(Le(g,e,t),v(c,[e])),F),A=e=>re(f,e),F={setSize:e=>(o=e,w(),F),addCheckpoint:D,setCheckpoint:J,getStore:()=>e,getCheckpointIds:()=>[[...L],t,[...y]],forEachCheckpoint:e=>ge(g,e),hasCheckpoint:A,getCheckpoint:e=>fe(g,e),goBackward:()=>(V(),M(),F),goForward:()=>(E(),M(),F),goTo:e=>{const n=O(L,e)?V:O(y,e)?E:null;for(;!k(n)&&e!=t;)n();return M(),F},addCheckpointIdsListener:e=>u(e,d),addCheckpointListener:(e,t)=>u(t,c,[e]),delListener:e=>(h(e),F),clear:()=>(T(L),T(y),k(t)||S(t),t=void 0,l=0,D(),F),destroy:()=>{e.delListener(C),e.delListener(b)},getListenerStats:()=>({})};return _(F.clear())})),je=(e,t)=>e<t?-1:1,Qe=Je((e=>{const t=ve(),l=ve(),[s,o,r,i,a,d,c,,u,v,h]=Me(e,ve,(e=>k(e)?n:J(e)?N(e,C):C(e))),[f,g,L]=Fe((()=>p)),y=(t,n,l)=>{const s=a(t);ce(l,((t,l)=>n(l,(n=>ce(t,(t=>n(t,(n=>e.forEachCell(s,t,n)))))))))},p={setIndexDefinition:(e,n,s,o,r,i=je)=>{const a=k(r)?void 0:([e],[t])=>r(e,t);return u(e,n,((n,s,r,u,v,h)=>{let f=0;const L=ke(),y=ke(),p=d(e);if(ce(s,(([e,t],n)=>{const l=ke(e),s=ke(t);ce(l,(e=>ue(s,e)?ue(l,e):0)),ce(l,(e=>{xe(L,e),x(fe(p,e),(t=>{ue(t,n),ie(t)&&(Le(p,e),f=1)}))})),ce(s,(e=>{xe(L,e),re(p,e)||(Le(p,e,ke()),f=1),xe(fe(p,e),n),k(o)||xe(y,e)}))})),n(),ie(v)||(h?ge(p,(e=>xe(y,e))):ge(r,(e=>x(fe(u,e),(e=>xe(y,e))))),ce(y,(e=>{const t=(t,n)=>i(fe(v,t),fe(v,n),e),n=[...fe(p,e)];j(n,t)||(Le(p,e,ke(Q(n,t))),xe(L,e))}))),(f||h)&&!k(a)){const t=[...p];j(t,a)||(c(e,ve(Q(t,a))),f=1)}f&&g(t,[e]),ce(L,(t=>g(l,[e,t])))}),De(s),x(o,De)),p},delIndexDefinition:e=>(v(e),p),getStore:s,getIndexIds:o,forEachIndex:e=>r(((t,n)=>e(t,(e=>y(t,e,n))))),forEachSlice:(e,t)=>y(e,t,d(e)),hasIndex:i,hasSlice:(e,t)=>re(d(e),t),getTableId:a,getSliceIds:e=>he(d(e)),getSliceRowIds:(e,t)=>ae(fe(d(e),t)),addSliceIdsListener:(e,n)=>f(n,t,[e]),addSliceRowIdsListener:(e,t,n)=>f(n,l,[e,t]),delListener:e=>(L(e),p),destroy:h,getListenerStats:()=>({})};return _(p)})),ze=ve([["avg",[(e,t)=>B(e)/t,(e,t,n)=>e+(t-e)/(n+1),(e,t,n)=>e+(e-t)/(n-1),(e,t,n,l)=>e+(t-n)/l]],["max",[e=>b(...e),(e,t)=>b(t,e),(e,t)=>t==e?void 0:e,(e,t,n)=>n==e?void 0:b(t,e)]],["min",[e=>m(...e),(e,t)=>m(t,e),(e,t)=>t==e?void 0:e,(e,t,n)=>n==e?void 0:m(t,e)]],["sum",[e=>B(e),(e,t)=>e+t,(e,t)=>e-t,(e,t,n)=>e-n+t]]]),Ne=(e,t,n,l,s,o=!1)=>{if(ie(n))return;const[r,i,a,d]=s;return o||(o=k(e)),ce(l,(([n,l])=>{o||(e=k(n)?null==i?void 0:i(e,l,t++):k(l)?null==a?void 0:a(e,n,t--):null==d?void 0:d(e,l,n,t),o||(o=k(e)))})),o?r(ae(n),oe(n)):e},Be=Je((e=>{const t=ve(),[l,s,o,r,i,a,d,,c,u,v]=Me(e,A,(e=>isNaN(e)||k(e)||!0===e||!1===e||e===n?void 0:1*e)),[h,f,g]=Fe((()=>L)),L={setMetricDefinition:(e,n,l,s,o,r,i)=>{var u;const v=D(l)?[l,o,r,i]:null!=(u=fe(ze,l))?u:fe(ze,"sum");return c(e,n,((n,l,s,o,r,i)=>{const c=a(e),u=oe(o);i||(i=k(c)),n();let h=Ne(c,u,o,l,v,i);V(h)||(h=void 0),h!=c&&(d(e,h),f(t,[e],h,c))}),De(s,1)),L},delMetricDefinition:e=>(u(e),L),getStore:l,getMetricIds:s,forEachMetric:o,hasMetric:r,getTableId:i,getMetric:a,addMetricListener:(e,n)=>h(n,t,[e]),delListener:e=>(g(e),L),destroy:v,getListenerStats:()=>({})};return _(L)}));var We=(e,t,n)=>new Promise(((l,s)=>{var o=e=>{try{i(n.next(e))}catch(e){s(e)}},r=e=>{try{i(n.throw(e))}catch(e){s(e)}},i=e=>e.done?l(e.value):Promise.resolve(e.value).then(o,r);i((n=n.apply(e,t)).next())})),$e=Object.getOwnPropertySymbols,qe=Object.prototype.hasOwnProperty,Ge=Object.prototype.propertyIsEnumerable;const He=Je((e=>{const t=e.createStore,[l,s,o,r,i,,,a,,v,f,g,w]=Me(e,(()=>!0),A),I=t(),R=t(),C=ve(),b=(e,t,...n)=>z(n,(n=>xe(ye(ye(C,t,ve),e,ke),n))),m=e=>{x(fe(C,e),(e=>{ge(e,((e,t)=>ce(t,(t=>e.delListener(t))))),de(e)})),z([R,I],(t=>t.delTable(e)))},V=(e,t,n)=>b(t,e,t.addStartTransactionListener(n.startTransaction),t.addDidFinishTransactionListener((()=>n.finishTransaction()))),E={setQueryDefinition:(t,l,s)=>{a(t,l),m(t);const o=[],r=[[null,[l,null,null,[],ve()]]],i=[],d=[],c=[];s({select:(e,t)=>{const l=D(e)?[W(o)+n,e]:[k(t)?e:t,n=>n(e,t)];return H(o,l),{as:e=>l[0]=e}},join:(e,t,n)=>{const l=k(n)||D(t)?null:t,s=k(l)?t:n,o=[e,[e,l,D(s)?s:e=>e(s),[],ve()]];return H(r,o),{as:e=>o[0]=e}},where:(e,t,n)=>H(i,D(e)?e:k(n)?n=>n(e)===t:l=>l(e,t)===n),group:(e,t,n,l,s)=>{var o;const r=[e,[e,D(t)?[t,n,l,s]:null!=(o=fe(ze,t))?o:[(e,t)=>t]]];return H(d,r),{as:e=>r[0]=e}},having:(e,t)=>H(c,D(e)?e:n=>n(e)===t)});const u=ve(o);if(ie(u))return E;const v=ve(r);ge(v,((e,[,t])=>x(fe(v,t),(({3:t})=>k(e)?0:H(t,e)))));const h=ve(d);let f=I;if(ie(h)&&$(c))f=R;else{V(t,f,R);const e=ve();ge(h,((t,[n,l])=>xe(ye(e,n,ke),[t,l])));const n=ke();ge(u,(t=>re(e,t)?0:xe(n,t)));const l=ve(),s=(n,l,s,o)=>x(n,(([r,i,a,d])=>{ge(l,((t,[n])=>{const l=ye(r,t,ve),i=fe(l,s),a=o?void 0:n;if(i!==a){const n=ke([[i,a]]),o=oe(l);Le(l,s,a),ce(fe(e,t),(([e,t])=>{const s=Ne(d[e],o,l,n,t);d[e]=k(me(s))?null:s}))}})),ie(i)||!F(c,(e=>e((e=>d[e]))))?R.delRow(t,a):k(a)?n[2]=R.addRow(t,d):R.setRow(t,a,d)}));b(f,t,f.addRowListener(t,null,((o,r,i,a)=>{const d=[],c=[],u=ve(),v=f.hasRow(t,i);let h=!v;ce(n,(e=>{const[n,l,s]=a(t,i,e);H(d,l),H(c,s),h||(h=n)})),ge(e,(e=>{const[n,,l]=a(t,i,e);(h||n)&&Le(u,e,[l])})),h&&s(be(l,d,void 0,(([,e])=>(ue(e,i),ie(e)))),u,i,1),v&&s(be(l,c,(()=>{const e={};return ce(n,(n=>e[n]=f.getCell(t,i,n))),[ve(),ke(),void 0,e]}),(([,e])=>{xe(e,i)})),u,i)})))}V(t,e,f);const L=(n,s,o,r)=>{const a=t=>e.getCell(s,o,t);z(r,(l=>{var s;const[o,,r,i,d]=fe(v,l),c=null==r?void 0:r(a,n),[u,h]=null!=(s=fe(d,n))?s:[];c!=u&&(k(h)||w(t,h),Le(d,n,k(c)?null:[c,...g(t,1,e.addRowListener(o,c,(()=>L(n,o,c,i))))]))})),(n=>{const s=(t,s)=>{var o,r,i;return e.getCell(...k(s)?[l,n,t]:t===l?[l,n,s]:[null==(o=fe(v,t))?void 0:o[0],null==(i=fe(null==(r=fe(v,t))?void 0:r[4],n))?void 0:i[0],s])};f.transaction((()=>F(i,(e=>e(s)))?ge(u,((e,l)=>Ve(f,t,n,e,l(s,n)))):f.delRow(t,n)))})(n)},{3:y}=fe(v,null);return f.transaction((()=>g(t,1,e.addRowListener(l,null,((n,s,o)=>{e.hasRow(l,o)?L(o,l,o,y):(f.delRow(t,o),ce(v,(({4:e})=>x(fe(e,o),(([,n])=>{w(t,n),Le(e,o)})))))}))))),E},delQueryDefinition:e=>(m(e),v(e),E),getStore:l,getQueryIds:s,forEachQuery:o,hasQuery:r,getTableId:i,delListener:e=>(R.delListener(e),E),destroy:f,getListenerStats:()=>((e,t)=>{var n={};for(var l in e)qe.call(e,l)&&t.indexOf(l)<0&&(n[l]=e[l]);if(null!=e&&$e)for(var l of $e(e))t.indexOf(l)<0&&Ge.call(e,l)&&(n[l]=e[l]);return n})(R.getListenerStats(),["tables","tableIds","transaction"])};return le({[h]:[1,1],[y]:[0,1],[p]:[0,5],[L]:[1,2],[T]:[0,2],[S]:[1,3]},(([e,t],n)=>{z(e?["get","has","forEach"]:["get"],(e=>E[e+c+n]=(...t)=>R[e+n](...t))),E[u+c+n+d]=(...e)=>R[u+n+d](...G(e,0,t),((n,...l)=>e[t](E,...l)))})),_(E)})),Ke=Je((e=>{const t=ve(),l=ve(),s=ve(),o=ve(),[r,i,a,d,c,u,,,v,h,f]=Me(e,(()=>[ve(),ve(),ve(),ve()]),(e=>k(e)?void 0:e+n)),[g,L,y]=Fe((()=>w)),p=(e,t,n)=>x(u(e),(([l,,s])=>{if(!re(s,t)){const o=ke();if(c(e)!=T(e))xe(o,t);else{let e=t;for(;!k(e)&&!re(o,e);)xe(o,e),e=fe(l,e)}if(n)return o;Le(s,t,o)}return fe(s,t)})),S=(e,t)=>x(u(e),(([,,e])=>Le(e,t))),T=e=>fe(t,e),w={setRelationshipDefinition:(e,n,r,i)=>(Le(t,e,r),v(e,n,((t,n)=>{const r=ke(),i=ke(),a=ke(),[d,c]=u(e);ce(n,(([t,n],l)=>{k(t)||(xe(i,t),x(fe(c,t),(e=>{ue(e,l),ie(e)&&Le(c,t)}))),k(n)||(xe(i,n),re(c,n)||Le(c,n,ke()),xe(fe(c,n),l)),xe(r,l),Le(d,l,n),ge(fe(o,e),(t=>{re(p(e,t),l)&&xe(a,t)}))})),t(),ce(r,(t=>L(l,[e,t]))),ce(i,(t=>L(s,[e,t]))),ce(a,(t=>{S(e,t),L(o,[e,t])}))}),De(i)),w),delRelationshipDefinition:e=>(Le(t,e),h(e),w),getStore:r,getRelationshipIds:i,forEachRelationship:t=>a((n=>t(n,(t=>e.forEachRow(c(n),t))))),hasRelationship:d,getLocalTableId:c,getRemoteTableId:T,getRemoteRowId:(e,t)=>{var n;return fe(null==(n=u(e))?void 0:n[0],t)},getLocalRowIds:(e,t)=>{var n;return ae(fe(null==(n=u(e))?void 0:n[1],t))},getLinkedRowIds:(e,t)=>k(u(e))?[t]:ae(p(e,t,!0)),addRemoteRowIdListener:(e,t,n)=>g(n,l,[e,t]),addLocalRowIdsListener:(e,t,n)=>g(n,s,[e,t]),addLinkedRowIdsListener:(e,t,n)=>(p(e,t),g(n,o,[e,t])),delListener:e=>(S(...y(e)),w),destroy:f,getListenerStats:()=>({})};return _(w)})),Ue=e=>[e,e],Xe=()=>[ve(),ve()],Ye=e=>[...e],Ze=([e,t])=>e===t,_e=e=>JSON.stringify(e,((e,t)=>E(t,Map)?X.fromEntries([...t]):t)),et=JSON.parse,tt=(e,t,n)=>k(e)||!ee(e)||se(e)||Z(e)?(null==n||n(),!1):(le(e,((n,l)=>{t(n,l)||ne(e,l)})),!se(e)),nt=(e,t,n)=>Le(e,t,fe(e,t)==-n?void 0:n),lt=()=>{let e,t,n=!1,l=!1,s=0;const r=ve(),c=ve(),v=ve(),p=ve(),b=ve(),m=ve(),V=ve(),E=ve(),J=ve(),A=ve(),F=ve(),j=ve(),B=ve(),W=ke(),$=ve(),q=ve(),K=ve(),U=ve(),X=Xe(),Y=Xe(),Z=Xe(),ee=Xe(),oe=Xe(),ae=Xe(),be=Xe(),Me=Xe(),De=Xe(),Je=Xe(),Ae=Xe(),Pe=Xe(),Qe=Xe(),ze=Xe(),Ne=ve(),Be=Xe(),[We,$e,qe,Ge]=Fe((()=>gn)),He=e=>{if(!tt(e,((e,t)=>O([i,a],t))))return!1;const t=e[i];return!(!M(t)&&t!=o||(me(e[a])!=t&&ne(e,a),0))},Ke=(t,n)=>(!e||re(A,n)||Jt(n))&&tt(t,((e,t)=>st(n,t,e)),(()=>Jt(n))),st=(e,t,n,l)=>tt(l?n:at(n,e,t),((l,s)=>x(ot(e,t,s,l),(e=>(n[s]=e,!0)),(()=>!1))),(()=>Jt(e,t))),ot=(t,n,l,s)=>e?x(fe(fe(A,t),l),(e=>me(s)!=e[i]?Jt(t,n,l,s,e[a]):s),(()=>Jt(t,n,l,s))):k(me(s))?Jt(t,n,l,s):s,rt=(e,t)=>tt(t?e:dt(e),((t,n)=>x(it(n,t),(t=>(e[n]=t,!0)),(()=>!1))),(()=>At())),it=(e,n)=>t?x(fe(j,e),(t=>me(n)!=t[i]?At(e,n,t[a]):n),(()=>At(e,n))):k(me(n))?At(e,n):n,at=(e,t,n)=>(x(fe(F,t),(([l,s])=>{ce(l,((t,n)=>{te(e,n)||(e[n]=t)})),ce(s,(l=>{te(e,l)||Jt(t,n,l)}))})),e),dt=e=>(t&&(ce(B,((t,n)=>{te(e,n)||(e[n]=t)})),ce(W,(t=>{te(e,t)||At(t)}))),e),ct=e=>pe(A,e,((e,t,n)=>{const l=ve(),s=ke();pe(ye(A,t,ve),n,((e,t,n)=>{Le(e,t,n),x(n[a],(e=>Le(l,t,e)),(()=>xe(s,t)))})),Le(F,t,[l,s])}),((e,t)=>{Le(A,t),Le(F,t)})),ut=e=>pe(j,e,((e,t,n)=>{Le(j,t,n),x(n[a],(e=>Le(B,t,e)),(()=>xe(W,t)))}),((e,t)=>{Le(j,t),Le(B,t),ue(W,t)})),vt=e=>se(e)?on():en(e),ht=e=>pe(K,e,((e,t,n)=>ft(t,n)),((e,t)=>Rt(t))),ft=(e,t)=>pe(ye(K,e,(()=>(Vt(e,1),Le($,e,Oe()),Le(q,e,ve()),ve()))),t,((t,n,l)=>gt(e,t,n,l)),((t,n)=>Ct(e,t,n))),gt=(e,t,n,l,s)=>pe(ye(t,n,(()=>(Et(e,n,1),ve()))),l,((t,l,s)=>Lt(e,n,t,l,s)),((l,o)=>bt(e,t,n,l,o,s))),Lt=(e,t,n,l,s)=>{re(n,l)||kt(e,t,l,1);const o=fe(n,l);s!==o&&(xt(e,t,l,o,s),Le(n,l,s))},yt=(e,t,n,l,s)=>x(fe(t,n),(t=>Lt(e,n,t,l,s)),(()=>gt(e,t,n,at({[l]:s},e,n)))),pt=e=>se(e)?dn():tn(e),St=e=>pe(U,e,((e,t,n)=>Tt(t,n)),((e,t)=>mt(t))),Tt=(e,t)=>{re(U,e)||Mt(e,1);const n=fe(U,e);t!==n&&(Dt(e,n,t),Le(U,e,t))},wt=(e,t)=>{const[n]=fe($,e),l=n(t);return re(fe(K,e),l)?wt(e,t):l},It=e=>{var t;return null!=(t=fe(K,e))?t:ft(e,{})},Rt=e=>ft(e,{}),Ct=(e,t,n)=>{const[,l]=fe($,e);l(n),gt(e,t,n,{},!0)},bt=(e,t,n,l,s,o)=>{var r;const i=fe(null==(r=fe(F,e))?void 0:r[0],s);if(!k(i)&&!o)return Lt(e,n,l,s,i);const a=t=>{xt(e,n,t,fe(l,t)),kt(e,n,t,-1),Le(l,t)};k(i)?a(s):ge(l,a),ie(l)&&(Et(e,n,-1),ie(Le(t,n))&&(Vt(e,-1),Le(K,e),Le($,e),Le(q,e)))},mt=e=>{const t=fe(B,e);if(!k(t))return Tt(e,t);Dt(e,fe(U,e)),Mt(e,-1),Le(U,e)},Vt=(e,t)=>nt(r,e,t),Et=(e,t,n)=>nt(ye(v,e,ve),t,n),kt=(e,t,n,l)=>{var s;const o=fe(q,e),r=null!=(s=fe(o,n))?s:0;(0==r&&1==l||1==r&&-1==l)&&nt(ye(c,e,ve),n,l),Le(o,n,r!=-l?r+l:null),nt(ye(ye(p,e,ve),t,ve),n,l)},xt=(e,t,n,l,s)=>ye(ye(ye(b,e,ve),t,ve),n,(()=>[l,0]))[1]=s,Mt=(e,t)=>nt(m,e,t),Dt=(e,t,n)=>ye(V,e,(()=>[t,0]))[1]=n,Jt=(e,t,n,l,s)=>(H(ye(ye(ye(E,e,ve),t,ve),n,(()=>[])),l),s),At=(e,t,n)=>(H(ye(J,e,(()=>[])),t),n),Ot=(e,t,n)=>x(fe(fe(fe(b,e),t),n),(([e,t])=>[!0,e,t]),(()=>[!1,...Ue(Xt(e,t,n))])),Ft=e=>x(fe(V,e),(([e,t])=>[!0,e,t]),(()=>[!1,...Ue(_t(e))])),Pt=e=>ie(E)||ie(Je[e])?0:ce(e?Ce(E):E,((t,n)=>ce(t,((t,l)=>ce(t,((t,s)=>$e(Je[e],[n,l,s],t))))))),jt=e=>ie(J)||ie(Ae[e])?0:ce(e?Ie(J):J,((t,n)=>$e(Ae[e],[n],t))),Qt=(e,t,n)=>{if(!ie(t))return $e(e,n,(()=>Se(t))),1},zt=e=>{const t=ie(ae[e]),n=ie(Me[e])&&ie(ee[e])&&ie(oe[e])&&t&&ie(Y[e]),l=ie(De[e])&&ie(be[e])&&ie(Z[e])&&ie(X[e]);if(!n||!l){const s=e?[Ie(r),Re(c),Re(v),Ce(p),Ce(b)]:[r,c,v,p,b];if(!n){Qt(Y[e],s[0]),ce(s[1],((t,n)=>Qt(ee[e],t,[n])));const n=ke();ce(s[2],((l,s)=>{Qt(oe[e],l,[s])&&!t&&($e(ae[e],[s,null]),xe(n,s))})),t||ce(s[4],((t,l)=>{if(!re(n,l)){const n=ke();ce(t,(e=>ce(e,(([t,l],s)=>l!==t?xe(n,s):ue(e,s))))),ce(n,(t=>$e(ae[e],[l,t])))}})),ce(s[3],((t,n)=>ce(t,((t,l)=>Qt(Me[e],t,[n,l])))))}if(!l){let t;ce(s[4],((n,l)=>{let s;ce(n,((n,o)=>{let r;ce(n,(([n,i],a)=>{i!==n&&($e(De[e],[l,o,a],i,n,Ot),t=s=r=1)})),r&&$e(be[e],[l,o],Ot)})),s&&$e(Z[e],[l],Ot)})),t&&$e(X[e],void 0,Ot)}}},Nt=e=>{const t=ie(Qe[e]),n=ie(ze[e])&&ie(Pe[e]);if(!t||!n){const l=e?[Ie(m),Ie(V)]:[m,V];if(t||Qt(Qe[e],l[0]),!n){let t;ce(l[1],(([n,l],s)=>{l!==n&&($e(ze[e],[s],l,n,Ft),t=1)})),t&&$e(Pe[e],void 0,Ft)}}},Bt=(e,...t)=>(vn((()=>e(...N(t,C)))),gn),Wt=()=>[Se(b,((e,t)=>-1===fe(r,t)?null:Se(e,((e,n)=>-1===fe(fe(v,t),n)?null:Se(e,(([,e])=>null!=e?e:null),((e,t)=>Ze(t)))),se)),se),Se(V,(([,e])=>null!=e?e:null),((e,t)=>Ze(t)))],$t=()=>({cellsTouched:n,valuesTouched:l,changedCells:we(b,Ye,Ze),invalidCells:we(E),changedValues:Se(V,Ye,Ze),invalidValues:Se(J),changedTableIds:Se(r),changedRowIds:Te(v),changedCellIds:we(p),changedValueIds:Se(m)}),qt=()=>we(K),Gt=()=>he(K),Ht=e=>he(fe(K,C(e))),Kt=(e,t,n,l=0,s)=>{return N(G(Q((o=fe(K,C(e)),r=(e,n)=>[k(t)?n:fe(e,C(t)),n],N([...null!=(i=null==o?void 0:o.entries())?i:[]],(([e,t])=>r(t,e)))),(([e],[t])=>je(e,t)*(n?-1:1))),l,k(s)?s:l+s),(([,e])=>e));var o,r,i},Ut=(e,t)=>he(fe(fe(K,C(e)),C(t))),Xt=(e,t,n)=>fe(fe(fe(K,C(e)),C(t)),C(n)),Yt=()=>Se(U),Zt=()=>he(U),_t=e=>fe(U,C(e)),en=e=>Bt((()=>(e=>tt(e,Ke,Jt))(e)?ht(e):0)),tn=e=>Bt((()=>rt(e)?St(e):0)),nn=e=>{try{vt(et(e))}catch(e){}return gn},ln=t=>Bt((()=>{if((e=tt(t,(e=>tt(e,He))))&&(ct(t),!ie(K))){const e=qt();on(),en(e)}})),sn=e=>Bt((()=>{if(t=(e=>tt(e,He))(e)){const n=Yt();un(),dn(),t=!0,ut(e),tn(n)}})),on=()=>Bt((()=>ht({}))),rn=e=>Bt((e=>re(K,e)?Rt(e):0),e),an=(e,t)=>Bt(((e,t)=>x(fe(K,e),(n=>re(n,t)?Ct(e,n,t):0))),e,t),dn=()=>Bt((()=>St({}))),cn=()=>Bt((()=>{ct({}),e=!1})),un=()=>Bt((()=>{ut({}),t=!1})),vn=(e,t)=>{if(-1!=s){hn();const n=e();return fn(t),n}},hn=()=>(-1!=s&&s++,1==s&&$e(Ne,void 0,Wt,$t),gn),fn=e=>(s>0&&(s--,0==s&&(n=!ie(b),l=!ie(V),s=1,Pt(1),n&&zt(1),jt(1),l&&Nt(1),(null==e?void 0:e(Wt,$t))&&(ce(b,((e,t)=>ce(e,((e,n)=>ce(e,(([e],l)=>Ve(gn,t,n,l,e))))))),ce(V,(([e],t)=>Ee(gn,t,e))),n=l=!1),$e(Be[0],void 0,Wt,$t),s=-1,Pt(0),n&&zt(0),jt(0),l&&Nt(0),$e(Be[1],void 0,Wt,$t),s=0,n=l=!1,z([r,c,v,p,b,E,m,V,J],de))),gn),gn={getContent:()=>[qt(),Yt()],getTables:qt,getTableIds:Gt,getTable:e=>Te(fe(K,C(e))),getTableCellIds:e=>he(fe(q,C(e))),getRowIds:Ht,getSortedRowIds:Kt,getRow:(e,t)=>Se(fe(fe(K,C(e)),C(t))),getCellIds:Ut,getCell:Xt,getValues:Yt,getValueIds:Zt,getValue:_t,hasTables:()=>!ie(K),hasTable:e=>re(K,C(e)),hasTableCell:(e,t)=>re(fe(q,C(e)),C(t)),hasRow:(e,t)=>re(fe(K,C(e)),C(t)),hasCell:(e,t,n)=>re(fe(fe(K,C(e)),C(t)),C(n)),hasValues:()=>!ie(U),hasValue:e=>re(U,C(e)),getTablesJson:()=>_e(K),getValuesJson:()=>_e(U),getJson:()=>_e([K,U]),getTablesSchemaJson:()=>_e(A),getValuesSchemaJson:()=>_e(j),getSchemaJson:()=>_e([A,j]),setContent:([e,t])=>Bt((()=>{(se(e)?on:en)(e),(se(t)?dn:tn)(t)})),setTables:en,setTable:(e,t)=>Bt((e=>Ke(t,e)?ft(e,t):0),e),setRow:(e,t,n)=>Bt(((e,t)=>st(e,t,n)?gt(e,It(e),t,n):0),e,t),addRow:(e,t,n=!0)=>vn((()=>{let l;return st(e,l,t)&&(e=C(e),gt(e,It(e),l=wt(e,n?1:0),t)),l})),setPartialRow:(e,t,n)=>Bt(((e,t)=>{if(st(e,t,n,1)){const l=It(e);le(n,((n,s)=>yt(e,l,t,s,n)))}}),e,t),setCell:(e,t,n,l)=>Bt(((e,t,n)=>x(ot(e,t,n,D(l)?l(Xt(e,t,n)):l),(l=>yt(e,It(e),t,n,l)))),e,t,n),setValues:tn,setPartialValues:e=>Bt((()=>rt(e,1)?le(e,((e,t)=>Tt(t,e))):0)),setValue:(e,t)=>Bt((e=>x(it(e,D(t)?t(_t(e)):t),(t=>Tt(e,t)))),e),setTransactionChanges:e=>Bt((()=>{le(e[0],((e,t)=>k(e)?rn(t):le(e,((e,n)=>k(e)?an(t,n):le(e,((e,l)=>Ve(gn,t,n,l,e))))))),le(e[1],((e,t)=>Ee(gn,t,e)))})),setTablesJson:nn,setValuesJson:e=>{try{pt(et(e))}catch(e){}return gn},setJson:e=>{try{const[t,n]=et(e);vt(t),pt(n)}catch(t){nn(e)}return gn},setTablesSchema:ln,setValuesSchema:sn,setSchema:(e,t)=>Bt((()=>{ln(e),sn(t)})),delTables:on,delTable:rn,delRow:an,delCell:(e,t,n,l)=>Bt(((e,t,n)=>x(fe(K,e),(s=>x(fe(s,t),(o=>re(o,n)?bt(e,s,t,o,n,l):0))))),e,t,n),delValues:dn,delValue:e=>Bt((e=>re(U,e)?mt(e):0),e),delTablesSchema:cn,delValuesSchema:un,delSchema:()=>Bt((()=>{cn(),un()})),transaction:vn,startTransaction:hn,finishTransaction:fn,forEachTable:e=>ce(K,((t,n)=>e(n,(e=>ce(t,((t,n)=>e(n,(e=>ge(t,e))))))))),forEachTableCell:(e,t)=>ge(fe(q,C(e)),t),forEachRow:(e,t)=>ce(fe(K,C(e)),((e,n)=>t(n,(t=>ge(e,t))))),forEachCell:(e,t,n)=>ge(fe(fe(K,C(e)),C(t)),n),forEachValue:e=>ge(U,e),addSortedRowIdsListener:(e,t,n,l,s,o,r)=>{let i=Kt(e,t,n,l,s);return We((()=>{const r=Kt(e,t,n,l,s);P(r,i)||(i=r,o(gn,e,t,n,l,s,i))}),ae[r?1:0],[e,t],[Gt])},addStartTransactionListener:e=>We(e,Ne),addWillFinishTransactionListener:e=>We(e,Be[0]),addDidFinishTransactionListener:e=>We(e,Be[1]),callListener:e=>(Ge(e),gn),delListener:e=>(qe(e),gn),getListenerStats:()=>({}),createStore:lt};return le({[f]:[0,X],[g]:[0,Y],[h]:[1,Z,[Gt]],[h+T]:[1,ee,[Gt]],[y]:[1,oe,[Gt]],[L]:[2,be,[Gt,Ht]],[T]:[2,Me,[Gt,Ht]],[S]:[3,De,[Gt,Ht,Ut],e=>Ue(Xt(...e))],InvalidCell:[3,Je],[I]:[0,Pe],[R]:[0,Qe],[w]:[1,ze,[Zt],e=>Ue(_t(e[0]))],InvalidValue:[1,Ae]},(([e,t,n,l],s)=>{gn[u+s+d]=(...s)=>We(s[e],t[s[e+1]?1:0],e>0?G(s,0,e):void 0,n,l)})),_(gn)};e.createCheckpoints=Pe,e.createCustomPersister=(e,t,n,l,s)=>{let o,r,i,a=0,d=0,c=0;const u=[],v=e=>We(void 0,null,(function*(){return 2!=a&&(a=1,yield h.schedule((()=>We(void 0,null,(function*(){yield e(),a=0}))))),h})),h={load:(n,l)=>We(void 0,null,(function*(){return yield v((()=>We(void 0,null,(function*(){try{e.setContent(yield t())}catch(t){e.setContent([n,l])}}))))})),startAutoLoad:(...n)=>We(void 0,[...n],(function*(n={},s={}){return h.stopAutoLoad(),yield h.load(n,s),c=1,i=l(((n,l)=>We(void 0,null,(function*(){return yield v((()=>We(void 0,null,(function*(){var s;if(l)e.setTransactionChanges(l());else try{e.setContent(null!=(s=null==n?void 0:n())?s:yield t())}catch(e){}}))))})))),h})),stopAutoLoad:()=>(c&&(s(i),i=void 0,c=0),h),save:t=>We(void 0,null,(function*(){return 1!=a&&(a=2,yield h.schedule((()=>We(void 0,null,(function*(){try{yield n(e.getContent,t)}catch(e){}a=0}))))),h})),startAutoSave:()=>We(void 0,null,(function*(){return yield h.stopAutoSave().save(),o=e.addDidFinishTransactionListener(((e,t)=>{const[n,l]=t();se(n)&&se(l)||h.save((()=>[n,l]))})),h})),stopAutoSave:()=>(x(o,e.delListener),h),schedule:(...e)=>We(void 0,null,(function*(){return H(u,...e),yield We(void 0,null,(function*(){if(!d){for(d=1;!k(r=U(u));)try{yield r()}catch(e){}d=0}})),h})),getStore:()=>e,destroy:()=>h.stopAutoLoad().stopAutoSave(),getStats:()=>({})};return _(h)},e.createIndexes=Qe,e.createMetrics=Be,e.createQueries=He,e.createRelationships=Ke,e.createStore=lt,e.defaultSorter=je},"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).TinyBase={});
1
+ var e,t;e=this,t=function(e){"use strict";const t=e=>typeof e,n="",l=t(n),o=t(!0),s=t(0),r=t(t),i="type",a="default",d="Listener",c="Result",u="add",v="Ids",h="Table",f=h+"s",g=h+v,y="Row",L=y+v,p="Sorted"+y+v,S="Cell",T=S+v,w="Value",I=w+"s",R=w+v,C=e=>n+e,b=Math.max,m=Math.min,V=isFinite,E=(e,t)=>e instanceof t,k=e=>null==e,x=(e,t,n)=>k(e)?null==n?void 0:n():t(e),M=e=>e==l||e==o,D=e=>t(e)==r,J=e=>Array.isArray(e),A=()=>{},O=(e,t)=>e.includes(t),F=(e,t)=>e.every(t),P=(e,t)=>W(e)===W(t)&&F(e,((e,n)=>t[n]===e)),j=(e,t)=>F(e,((n,l)=>0==l||t(e[l-1],n)<=0)),Q=(e,t)=>e.sort(t),z=(e,t)=>e.forEach(t),N=(e,t)=>e.map(t),B=e=>q(e,((e,t)=>e+t),0),W=e=>e.length,$=e=>0==W(e),q=(e,t,n)=>e.reduce(t,n),G=(e,t,n)=>e.slice(t,n),H=(e,...t)=>e.push(...t),K=e=>e.pop(),U=e=>e.shift(),X=Object,Y=X.keys,Z=X.isFrozen,_=X.freeze,ee=e=>E(e,X)&&e.constructor==X,te=(e,t)=>!k(((e,t)=>x(e,(e=>e[t])))(e,t)),ne=(e,t)=>(delete e[t],e),le=(e,t)=>N(X.entries(e),(([e,n])=>t(n,e))),oe=e=>ee(e)&&0==(e=>W(Y(e)))(e),se=e=>e.size,re=(e,t)=>{var n;return null!=(n=null==e?void 0:e.has(t))&&n},ie=e=>k(e)||0==se(e),ae=e=>{var t;return[...null!=(t=null==e?void 0:e.values())?t:[]]},de=e=>e.clear(),ce=(e,t)=>null==e?void 0:e.forEach(t),ue=(e,t)=>null==e?void 0:e.delete(t),ve=e=>new Map(e),he=e=>{var t;return[...null!=(t=null==e?void 0:e.keys())?t:[]]},fe=(e,t)=>null==e?void 0:e.get(t),ge=(e,t)=>ce(e,((e,n)=>t(n,e))),ye=(e,t,n)=>k(n)?(ue(e,t),e):null==e?void 0:e.set(t,n),Le=(e,t,n)=>(re(e,t)||ye(e,t,n()),fe(e,t)),pe=(e,t,n,l=ye)=>(le(t,((t,l)=>n(e,l,t))),ge(e,(n=>te(t,n)?0:l(e,n))),e),Se=(e,t,n)=>{const l={};return ce(e,((e,o)=>{const s=t?t(e,o):e;!(null==n?void 0:n(s,e))&&(l[o]=s)})),l},Te=(e,t,n)=>Se(e,(e=>Se(e,t,n)),oe),we=(e,t,n)=>Se(e,(e=>Te(e,t,n)),oe),Ie=(e,t)=>{const n=ve();return ce(e,((e,l)=>{var o;return n.set(l,null!=(o=null==t?void 0:t(e))?o:e)})),n},Re=e=>Ie(e,Ie),Ce=e=>Ie(e,Re),be=(e,t,n,l,o=0)=>x((n?Le:fe)(e,t[o],o>W(t)-2?n:ve),(s=>{if(o>W(t)-2)return(null==l?void 0:l(s))&&ye(e,t[o]),s;const r=be(s,t,n,l,o+1);return ie(s)&&ye(e,t[o]),r})),me=e=>{const n=t(e);return M(n)||n==s&&V(e)?n:void 0},Ve=(e,t,n,l,o)=>k(o)?e.delCell(t,n,l,!0):e.setCell(t,n,l,o),Ee=(e,t,n)=>k(n)?e.delValue(t):e.setValue(t,n),ke=e=>new Set(J(e)||k(e)?e:[e]),xe=(e,t)=>null==e?void 0:e.add(t),Me=(e,t,n)=>{const l=e.hasRow,o=ve(),s=ve(),r=ve(),i=ve(),a=ve(),d=(t,n,...l)=>{const o=Le(a,t,ke);return z(l,(t=>xe(o,t)&&n&&e.callListener(t))),l},c=(t,...n)=>x(fe(a,t),(l=>{z($(n)?ae(l):n,(t=>{e.delListener(t),ue(l,t)})),ie(l)&&ye(a,t)})),u=(e,n)=>{ye(o,e,n),re(s,e)||(ye(s,e,t()),ye(r,e,ve()),ye(i,e,ve()))},v=e=>{ye(o,e),ye(s,e),ye(r,e),ye(i,e),c(e)};return[()=>e,()=>he(o),e=>ge(s,e),e=>re(s,e),e=>fe(o,e),e=>fe(s,e),(e,t)=>ye(s,e,t),u,(t,o,s,a,v)=>{u(t,o);const h=ve(),f=ve(),g=fe(r,t),y=fe(i,t),L=t=>{const s=n=>e.getCell(o,t,n),r=fe(g,t),i=l(o,t)?n(a(s,t)):void 0;if(r===i||J(r)&&J(i)&&P(r,i)||ye(h,t,[r,i]),!k(v)){const e=fe(y,t),n=l(o,t)?v(s,t):void 0;e!=n&&ye(f,t,n)}},p=e=>{s((()=>{ce(h,(([,e],t)=>ye(g,t,e))),ce(f,((e,t)=>ye(y,t,e)))}),h,f,g,y,e),de(h),de(f)};ge(g,L),e.hasTable(o)&&z(e.getRowIds(o),(e=>{re(g,e)||L(e)})),p(!0),c(t),d(t,0,e.addRowListener(o,null,((e,t,n)=>L(n))),e.addTableListener(o,(()=>p())))},v,()=>ge(a,v),d,c]},De=(e,o)=>t(e)==l?t=>t(e):null!=e?e:()=>null!=o?o:n,Je=e=>{const t=new WeakMap;return n=>(t.has(n)||t.set(n,e(n)),t.get(n))},Ae=/^\d+$/,Oe=()=>{const e=[];let t=0;return[l=>{var o;return null!=(o=l?U(e):null)?o:n+t++},t=>{Ae.test(t)&&W(e)<1e3&&H(e,t)}]},Fe=e=>{let t;const[l,o]=Oe(),s=ve();return[(o,r,i,a=[],d=(()=>[]))=>{null!=t||(t=e());const c=l(1);return ye(s,c,[o,r,i,a,d]),xe(be(r,null!=i?i:[n],ke),c),c},(e,l,...o)=>z(((e,t=[n])=>{const l=[],o=(e,n)=>n==W(t)?H(l,e):null===t[n]?ce(e,(e=>o(e,n+1))):z([t[n],null],(t=>o(fe(e,t),n+1)));return o(e,0),l})(e,l),(e=>ce(e,(e=>fe(s,e)[0](t,...null!=l?l:[],...o))))),e=>x(fe(s,e),(([,t,l])=>(be(t,null!=l?l:[n],void 0,(t=>(ue(t,e),ie(t)?1:0))),ye(s,e),o(e),l))),e=>x(fe(s,e),(([e,,n=[],l,o])=>{const s=(...r)=>{var i,a;const d=W(r);d==W(n)?e(t,...r,...o(r)):k(n[d])?z(null!=(a=null==(i=l[d])?void 0:i.call(l,...r))?a:[],(e=>s(...r,e))):s(...r,n[d])};s()}))]},Pe=Je((e=>{let t,l,o,s=100,r=ve(),i=ve(),a=1;const d=ve(),c=ve(),[u,v,h]=Fe((()=>F)),f=ve(),g=ve(),y=[],L=[],p=(t,n)=>{a=0,e.transaction((()=>{const[l,o]=fe(f,n);ce(l,((n,l)=>ce(n,((n,o)=>ce(n,((n,s)=>Ve(e,l,o,s,n[t]))))))),ce(o,((n,l)=>Ee(e,l,n[t])))})),a=1},S=e=>{ye(f,e),ye(g,e),v(c,[e])},T=(e,t)=>z(((e,t)=>e.splice(0,t))(e,null!=t?t:W(e)),S),w=()=>T(y,W(y)-s),I=()=>x(t,(()=>{H(y,t),w(),T(L),t=void 0,o=1})),R=()=>{t=K(y),o=1},C=e.addCellListener(null,null,null,((e,t,n,l,o,s)=>{if(a){I();const e=Le(r,t,ve),i=Le(e,n,ve),a=Le(i,l,(()=>[s,void 0]));a[1]=o,a[0]===o&&ie(ye(i,l))&&ie(ye(e,n))&&ie(ye(r,t))&&R(),M()}})),b=e.addValueListener(null,((e,t,n,l)=>{if(a){I();const e=Le(i,t,(()=>[l,void 0]));e[1]=n,e[0]===n&&ie(ye(i,t))&&R(),M()}})),m=(e="")=>(k(t)&&(t=n+l++,ye(f,t,[r,i]),J(t,e),r=ve(),i=ve(),o=1),t),V=()=>{$(y)||(((e,...t)=>{e.unshift(...t)})(L,m()),p(0,t),t=K(y),o=1)},E=()=>{$(L)||(H(y,t),t=U(L),p(1,t),o=1)},M=()=>{o&&(v(d),o=0)},D=e=>{const t=m(e);return M(),t},J=(e,t)=>(A(e)&&fe(g,e)!==t&&(ye(g,e,t),v(c,[e])),F),A=e=>re(f,e),F={setSize:e=>(s=e,w(),F),addCheckpoint:D,setCheckpoint:J,getStore:()=>e,getCheckpointIds:()=>[[...y],t,[...L]],forEachCheckpoint:e=>ge(g,e),hasCheckpoint:A,getCheckpoint:e=>fe(g,e),goBackward:()=>(V(),M(),F),goForward:()=>(E(),M(),F),goTo:e=>{const n=O(y,e)?V:O(L,e)?E:null;for(;!k(n)&&e!=t;)n();return M(),F},addCheckpointIdsListener:e=>u(e,d),addCheckpointListener:(e,t)=>u(t,c,[e]),delListener:e=>(h(e),F),clear:()=>(T(y),T(L),k(t)||S(t),t=void 0,l=0,D(),F),destroy:()=>{e.delListener(C),e.delListener(b)},getListenerStats:()=>({})};return _(F.clear())})),je=(e,t)=>e<t?-1:1,Qe=Je((e=>{const t=ve(),l=ve(),[o,s,r,i,a,d,c,,u,v,h]=Me(e,ve,(e=>k(e)?n:J(e)?N(e,C):C(e))),[f,g,y]=Fe((()=>p)),L=(t,n,l)=>{const o=a(t);ce(l,((t,l)=>n(l,(n=>ce(t,(t=>n(t,(n=>e.forEachCell(o,t,n)))))))))},p={setIndexDefinition:(e,n,o,s,r,i=je)=>{const a=k(r)?void 0:([e],[t])=>r(e,t);return u(e,n,((n,o,r,u,v,h)=>{let f=0;const y=ke(),L=ke(),p=d(e);if(ce(o,(([e,t],n)=>{const l=ke(e),o=ke(t);ce(l,(e=>ue(o,e)?ue(l,e):0)),ce(l,(e=>{xe(y,e),x(fe(p,e),(t=>{ue(t,n),ie(t)&&(ye(p,e),f=1)}))})),ce(o,(e=>{xe(y,e),re(p,e)||(ye(p,e,ke()),f=1),xe(fe(p,e),n),k(s)||xe(L,e)}))})),n(),ie(v)||(h?ge(p,(e=>xe(L,e))):ge(r,(e=>x(fe(u,e),(e=>xe(L,e))))),ce(L,(e=>{const t=(t,n)=>i(fe(v,t),fe(v,n),e),n=[...fe(p,e)];j(n,t)||(ye(p,e,ke(Q(n,t))),xe(y,e))}))),(f||h)&&!k(a)){const t=[...p];j(t,a)||(c(e,ve(Q(t,a))),f=1)}f&&g(t,[e]),ce(y,(t=>g(l,[e,t])))}),De(o),x(s,De)),p},delIndexDefinition:e=>(v(e),p),getStore:o,getIndexIds:s,forEachIndex:e=>r(((t,n)=>e(t,(e=>L(t,e,n))))),forEachSlice:(e,t)=>L(e,t,d(e)),hasIndex:i,hasSlice:(e,t)=>re(d(e),t),getTableId:a,getSliceIds:e=>he(d(e)),getSliceRowIds:(e,t)=>ae(fe(d(e),t)),addSliceIdsListener:(e,n)=>f(n,t,[e]),addSliceRowIdsListener:(e,t,n)=>f(n,l,[e,t]),delListener:e=>(y(e),p),destroy:h,getListenerStats:()=>({})};return _(p)})),ze=ve([["avg",[(e,t)=>B(e)/t,(e,t,n)=>e+(t-e)/(n+1),(e,t,n)=>e+(e-t)/(n-1),(e,t,n,l)=>e+(t-n)/l]],["max",[e=>b(...e),(e,t)=>b(t,e),(e,t)=>t==e?void 0:e,(e,t,n)=>n==e?void 0:b(t,e)]],["min",[e=>m(...e),(e,t)=>m(t,e),(e,t)=>t==e?void 0:e,(e,t,n)=>n==e?void 0:m(t,e)]],["sum",[e=>B(e),(e,t)=>e+t,(e,t)=>e-t,(e,t,n)=>e-n+t]]]),Ne=(e,t,n,l,o,s=!1)=>{if(ie(n))return;const[r,i,a,d]=o;return s||(s=k(e)),ce(l,(([n,l])=>{s||(e=k(n)?null==i?void 0:i(e,l,t++):k(l)?null==a?void 0:a(e,n,t--):null==d?void 0:d(e,l,n,t),s||(s=k(e)))})),s?r(ae(n),se(n)):e},Be=Je((e=>{const t=ve(),[l,o,s,r,i,a,d,,c,u,v]=Me(e,A,(e=>isNaN(e)||k(e)||!0===e||!1===e||e===n?void 0:1*e)),[h,f,g]=Fe((()=>y)),y={setMetricDefinition:(e,n,l,o,s,r,i)=>{var u;const v=D(l)?[l,s,r,i]:null!=(u=fe(ze,l))?u:fe(ze,"sum");return c(e,n,((n,l,o,s,r,i)=>{const c=a(e),u=se(s);i||(i=k(c)),n();let h=Ne(c,u,s,l,v,i);V(h)||(h=void 0),h!=c&&(d(e,h),f(t,[e],h,c))}),De(o,1)),y},delMetricDefinition:e=>(u(e),y),getStore:l,getMetricIds:o,forEachMetric:s,hasMetric:r,getTableId:i,getMetric:a,addMetricListener:(e,n)=>h(n,t,[e]),delListener:e=>(g(e),y),destroy:v,getListenerStats:()=>({})};return _(y)}));var We=(e,t,n)=>new Promise(((l,o)=>{var s=e=>{try{i(n.next(e))}catch(e){o(e)}},r=e=>{try{i(n.throw(e))}catch(e){o(e)}},i=e=>e.done?l(e.value):Promise.resolve(e.value).then(s,r);i((n=n.apply(e,t)).next())}));const $e=ve(),qe=ve();var Ge=Object.getOwnPropertySymbols,He=Object.prototype.hasOwnProperty,Ke=Object.prototype.propertyIsEnumerable;const Ue=Je((e=>{const t=e.createStore,[l,o,s,r,i,,,a,,v,f,g,w]=Me(e,(()=>!0),A),I=t(),R=t(),C=ve(),b=(e,t,...n)=>z(n,(n=>xe(Le(Le(C,t,ve),e,ke),n))),m=e=>{x(fe(C,e),(e=>{ge(e,((e,t)=>ce(t,(t=>e.delListener(t))))),de(e)})),z([R,I],(t=>t.delTable(e)))},V=(e,t,n)=>b(t,e,t.addStartTransactionListener(n.startTransaction),t.addDidFinishTransactionListener((()=>n.finishTransaction()))),E={setQueryDefinition:(t,l,o)=>{a(t,l),m(t);const s=[],r=[[null,[l,null,null,[],ve()]]],i=[],d=[],c=[];o({select:(e,t)=>{const l=D(e)?[W(s)+n,e]:[k(t)?e:t,n=>n(e,t)];return H(s,l),{as:e=>l[0]=e}},join:(e,t,n)=>{const l=k(n)||D(t)?null:t,o=k(l)?t:n,s=[e,[e,l,D(o)?o:e=>e(o),[],ve()]];return H(r,s),{as:e=>s[0]=e}},where:(e,t,n)=>H(i,D(e)?e:k(n)?n=>n(e)===t:l=>l(e,t)===n),group:(e,t,n,l,o)=>{var s;const r=[e,[e,D(t)?[t,n,l,o]:null!=(s=fe(ze,t))?s:[(e,t)=>t]]];return H(d,r),{as:e=>r[0]=e}},having:(e,t)=>H(c,D(e)?e:n=>n(e)===t)});const u=ve(s);if(ie(u))return E;const v=ve(r);ge(v,((e,[,t])=>x(fe(v,t),(({3:t})=>k(e)?0:H(t,e)))));const h=ve(d);let f=I;if(ie(h)&&$(c))f=R;else{V(t,f,R);const e=ve();ge(h,((t,[n,l])=>xe(Le(e,n,ke),[t,l])));const n=ke();ge(u,(t=>re(e,t)?0:xe(n,t)));const l=ve(),o=(n,l,o,s)=>x(n,(([r,i,a,d])=>{ge(l,((t,[n])=>{const l=Le(r,t,ve),i=fe(l,o),a=s?void 0:n;if(i!==a){const n=ke([[i,a]]),s=se(l);ye(l,o,a),ce(fe(e,t),(([e,t])=>{const o=Ne(d[e],s,l,n,t);d[e]=k(me(o))?null:o}))}})),ie(i)||!F(c,(e=>e((e=>d[e]))))?R.delRow(t,a):k(a)?n[2]=R.addRow(t,d):R.setRow(t,a,d)}));b(f,t,f.addRowListener(t,null,((s,r,i,a)=>{const d=[],c=[],u=ve(),v=f.hasRow(t,i);let h=!v;ce(n,(e=>{const[n,l,o]=a(t,i,e);H(d,l),H(c,o),h||(h=n)})),ge(e,(e=>{const[n,,l]=a(t,i,e);(h||n)&&ye(u,e,[l])})),h&&o(be(l,d,void 0,(([,e])=>(ue(e,i),ie(e)))),u,i,1),v&&o(be(l,c,(()=>{const e={};return ce(n,(n=>e[n]=f.getCell(t,i,n))),[ve(),ke(),void 0,e]}),(([,e])=>{xe(e,i)})),u,i)})))}V(t,e,f);const y=(n,o,s,r)=>{const a=t=>e.getCell(o,s,t);z(r,(l=>{var o;const[s,,r,i,d]=fe(v,l),c=null==r?void 0:r(a,n),[u,h]=null!=(o=fe(d,n))?o:[];c!=u&&(k(h)||w(t,h),ye(d,n,k(c)?null:[c,...g(t,1,e.addRowListener(s,c,(()=>y(n,s,c,i))))]))})),(n=>{const o=(t,o)=>{var s,r,i;return e.getCell(...k(o)?[l,n,t]:t===l?[l,n,o]:[null==(s=fe(v,t))?void 0:s[0],null==(i=fe(null==(r=fe(v,t))?void 0:r[4],n))?void 0:i[0],o])};f.transaction((()=>F(i,(e=>e(o)))?ge(u,((e,l)=>Ve(f,t,n,e,l(o,n)))):f.delRow(t,n)))})(n)},{3:L}=fe(v,null);return f.transaction((()=>g(t,1,e.addRowListener(l,null,((n,o,s)=>{e.hasRow(l,s)?y(s,l,s,L):(f.delRow(t,s),ce(v,(({4:e})=>x(fe(e,s),(([,n])=>{w(t,n),ye(e,s)})))))}))))),E},delQueryDefinition:e=>(m(e),v(e),E),getStore:l,getQueryIds:o,forEachQuery:s,hasQuery:r,getTableId:i,delListener:e=>(R.delListener(e),E),destroy:f,getListenerStats:()=>((e,t)=>{var n={};for(var l in e)He.call(e,l)&&t.indexOf(l)<0&&(n[l]=e[l]);if(null!=e&&Ge)for(var l of Ge(e))t.indexOf(l)<0&&Ke.call(e,l)&&(n[l]=e[l]);return n})(R.getListenerStats(),["tables","tableIds","transaction"])};return le({[h]:[1,1],[L]:[0,1],[p]:[0,5],[y]:[1,2],[T]:[0,2],[S]:[1,3]},(([e,t],n)=>{z(e?["get","has","forEach"]:["get"],(e=>E[e+c+n]=(...t)=>R[e+n](...t))),E[u+c+n+d]=(...e)=>R[u+n+d](...G(e,0,t),((n,...l)=>e[t](E,...l)))})),_(E)})),Xe=Je((e=>{const t=ve(),l=ve(),o=ve(),s=ve(),[r,i,a,d,c,u,,,v,h,f]=Me(e,(()=>[ve(),ve(),ve(),ve()]),(e=>k(e)?void 0:e+n)),[g,y,L]=Fe((()=>w)),p=(e,t,n)=>x(u(e),(([l,,o])=>{if(!re(o,t)){const s=ke();if(c(e)!=T(e))xe(s,t);else{let e=t;for(;!k(e)&&!re(s,e);)xe(s,e),e=fe(l,e)}if(n)return s;ye(o,t,s)}return fe(o,t)})),S=(e,t)=>x(u(e),(([,,e])=>ye(e,t))),T=e=>fe(t,e),w={setRelationshipDefinition:(e,n,r,i)=>(ye(t,e,r),v(e,n,((t,n)=>{const r=ke(),i=ke(),a=ke(),[d,c]=u(e);ce(n,(([t,n],l)=>{k(t)||(xe(i,t),x(fe(c,t),(e=>{ue(e,l),ie(e)&&ye(c,t)}))),k(n)||(xe(i,n),re(c,n)||ye(c,n,ke()),xe(fe(c,n),l)),xe(r,l),ye(d,l,n),ge(fe(s,e),(t=>{re(p(e,t),l)&&xe(a,t)}))})),t(),ce(r,(t=>y(l,[e,t]))),ce(i,(t=>y(o,[e,t]))),ce(a,(t=>{S(e,t),y(s,[e,t])}))}),De(i)),w),delRelationshipDefinition:e=>(ye(t,e),h(e),w),getStore:r,getRelationshipIds:i,forEachRelationship:t=>a((n=>t(n,(t=>e.forEachRow(c(n),t))))),hasRelationship:d,getLocalTableId:c,getRemoteTableId:T,getRemoteRowId:(e,t)=>{var n;return fe(null==(n=u(e))?void 0:n[0],t)},getLocalRowIds:(e,t)=>{var n;return ae(fe(null==(n=u(e))?void 0:n[1],t))},getLinkedRowIds:(e,t)=>k(u(e))?[t]:ae(p(e,t,!0)),addRemoteRowIdListener:(e,t,n)=>g(n,l,[e,t]),addLocalRowIdsListener:(e,t,n)=>g(n,o,[e,t]),addLinkedRowIdsListener:(e,t,n)=>(p(e,t),g(n,s,[e,t])),delListener:e=>(S(...L(e)),w),destroy:f,getListenerStats:()=>({})};return _(w)})),Ye=e=>[e,e],Ze=()=>[ve(),ve()],_e=e=>[...e],et=([e,t])=>e===t,tt=e=>JSON.stringify(e,((e,t)=>E(t,Map)?X.fromEntries([...t]):t)),nt=JSON.parse,lt=(e,t,n)=>k(e)||!ee(e)||oe(e)||Z(e)?(null==n||n(),!1):(le(e,((n,l)=>{t(n,l)||ne(e,l)})),!oe(e)),ot=(e,t,n)=>ye(e,t,fe(e,t)==-n?void 0:n),st=()=>{let e,t,n=!1,l=!1,o=0;const r=ve(),c=ve(),v=ve(),p=ve(),b=ve(),m=ve(),V=ve(),E=ve(),J=ve(),A=ve(),F=ve(),j=ve(),B=ve(),W=ke(),$=ve(),q=ve(),K=ve(),U=ve(),X=Ze(),Y=Ze(),Z=Ze(),ee=Ze(),se=Ze(),ae=Ze(),be=Ze(),Me=Ze(),De=Ze(),Je=Ze(),Ae=Ze(),Pe=Ze(),Qe=Ze(),ze=Ze(),Ne=ve(),Be=Ze(),[We,$e,qe,Ge]=Fe((()=>gn)),He=e=>{if(!lt(e,((e,t)=>O([i,a],t))))return!1;const t=e[i];return!(!M(t)&&t!=s||(me(e[a])!=t&&ne(e,a),0))},Ke=(t,n)=>(!e||re(A,n)||Jt(n))&&lt(t,((e,t)=>Ue(n,t,e)),(()=>Jt(n))),Ue=(e,t,n,l)=>lt(l?n:at(n,e,t),((l,o)=>x(Xe(e,t,o,l),(e=>(n[o]=e,!0)),(()=>!1))),(()=>Jt(e,t))),Xe=(t,n,l,o)=>e?x(fe(fe(A,t),l),(e=>me(o)!=e[i]?Jt(t,n,l,o,e[a]):o),(()=>Jt(t,n,l,o))):k(me(o))?Jt(t,n,l,o):o,rt=(e,t)=>lt(t?e:dt(e),((t,n)=>x(it(n,t),(t=>(e[n]=t,!0)),(()=>!1))),(()=>At())),it=(e,n)=>t?x(fe(j,e),(t=>me(n)!=t[i]?At(e,n,t[a]):n),(()=>At(e,n))):k(me(n))?At(e,n):n,at=(e,t,n)=>(x(fe(F,t),(([l,o])=>{ce(l,((t,n)=>{te(e,n)||(e[n]=t)})),ce(o,(l=>{te(e,l)||Jt(t,n,l)}))})),e),dt=e=>(t&&(ce(B,((t,n)=>{te(e,n)||(e[n]=t)})),ce(W,(t=>{te(e,t)||At(t)}))),e),ct=e=>pe(A,e,((e,t,n)=>{const l=ve(),o=ke();pe(Le(A,t,ve),n,((e,t,n)=>{ye(e,t,n),x(n[a],(e=>ye(l,t,e)),(()=>xe(o,t)))})),ye(F,t,[l,o])}),((e,t)=>{ye(A,t),ye(F,t)})),ut=e=>pe(j,e,((e,t,n)=>{ye(j,t,n),x(n[a],(e=>ye(B,t,e)),(()=>xe(W,t)))}),((e,t)=>{ye(j,t),ye(B,t),ue(W,t)})),vt=e=>oe(e)?sn():en(e),ht=e=>pe(K,e,((e,t,n)=>ft(t,n)),((e,t)=>Rt(t))),ft=(e,t)=>pe(Le(K,e,(()=>(Vt(e,1),ye($,e,Oe()),ye(q,e,ve()),ve()))),t,((t,n,l)=>gt(e,t,n,l)),((t,n)=>Ct(e,t,n))),gt=(e,t,n,l,o)=>pe(Le(t,n,(()=>(Et(e,n,1),ve()))),l,((t,l,o)=>yt(e,n,t,l,o)),((l,s)=>bt(e,t,n,l,s,o))),yt=(e,t,n,l,o)=>{re(n,l)||kt(e,t,l,1);const s=fe(n,l);o!==s&&(xt(e,t,l,s,o),ye(n,l,o))},Lt=(e,t,n,l,o)=>x(fe(t,n),(t=>yt(e,n,t,l,o)),(()=>gt(e,t,n,at({[l]:o},e,n)))),pt=e=>oe(e)?dn():tn(e),St=e=>pe(U,e,((e,t,n)=>Tt(t,n)),((e,t)=>mt(t))),Tt=(e,t)=>{re(U,e)||Mt(e,1);const n=fe(U,e);t!==n&&(Dt(e,n,t),ye(U,e,t))},wt=(e,t)=>{const[n]=fe($,e),l=n(t);return re(fe(K,e),l)?wt(e,t):l},It=e=>{var t;return null!=(t=fe(K,e))?t:ft(e,{})},Rt=e=>ft(e,{}),Ct=(e,t,n)=>{const[,l]=fe($,e);l(n),gt(e,t,n,{},!0)},bt=(e,t,n,l,o,s)=>{var r;const i=fe(null==(r=fe(F,e))?void 0:r[0],o);if(!k(i)&&!s)return yt(e,n,l,o,i);const a=t=>{xt(e,n,t,fe(l,t)),kt(e,n,t,-1),ye(l,t)};k(i)?a(o):ge(l,a),ie(l)&&(Et(e,n,-1),ie(ye(t,n))&&(Vt(e,-1),ye(K,e),ye($,e),ye(q,e)))},mt=e=>{const t=fe(B,e);if(!k(t))return Tt(e,t);Dt(e,fe(U,e)),Mt(e,-1),ye(U,e)},Vt=(e,t)=>ot(r,e,t),Et=(e,t,n)=>ot(Le(v,e,ve),t,n),kt=(e,t,n,l)=>{var o;const s=fe(q,e),r=null!=(o=fe(s,n))?o:0;(0==r&&1==l||1==r&&-1==l)&&ot(Le(c,e,ve),n,l),ye(s,n,r!=-l?r+l:null),ot(Le(Le(p,e,ve),t,ve),n,l)},xt=(e,t,n,l,o)=>Le(Le(Le(b,e,ve),t,ve),n,(()=>[l,0]))[1]=o,Mt=(e,t)=>ot(m,e,t),Dt=(e,t,n)=>Le(V,e,(()=>[t,0]))[1]=n,Jt=(e,t,n,l,o)=>(H(Le(Le(Le(E,e,ve),t,ve),n,(()=>[])),l),o),At=(e,t,n)=>(H(Le(J,e,(()=>[])),t),n),Ot=(e,t,n)=>x(fe(fe(fe(b,e),t),n),(([e,t])=>[!0,e,t]),(()=>[!1,...Ye(Xt(e,t,n))])),Ft=e=>x(fe(V,e),(([e,t])=>[!0,e,t]),(()=>[!1,...Ye(_t(e))])),Pt=e=>ie(E)||ie(Je[e])?0:ce(e?Ce(E):E,((t,n)=>ce(t,((t,l)=>ce(t,((t,o)=>$e(Je[e],[n,l,o],t))))))),jt=e=>ie(J)||ie(Ae[e])?0:ce(e?Ie(J):J,((t,n)=>$e(Ae[e],[n],t))),Qt=(e,t,n)=>{if(!ie(t))return $e(e,n,(()=>Se(t))),1},zt=e=>{const t=ie(ae[e]),n=ie(Me[e])&&ie(ee[e])&&ie(se[e])&&t&&ie(Y[e]),l=ie(De[e])&&ie(be[e])&&ie(Z[e])&&ie(X[e]);if(!n||!l){const o=e?[Ie(r),Re(c),Re(v),Ce(p),Ce(b)]:[r,c,v,p,b];if(!n){Qt(Y[e],o[0]),ce(o[1],((t,n)=>Qt(ee[e],t,[n])));const n=ke();ce(o[2],((l,o)=>{Qt(se[e],l,[o])&&!t&&($e(ae[e],[o,null]),xe(n,o))})),t||ce(o[4],((t,l)=>{if(!re(n,l)){const n=ke();ce(t,(e=>ce(e,(([t,l],o)=>l!==t?xe(n,o):ue(e,o))))),ce(n,(t=>$e(ae[e],[l,t])))}})),ce(o[3],((t,n)=>ce(t,((t,l)=>Qt(Me[e],t,[n,l])))))}if(!l){let t;ce(o[4],((n,l)=>{let o;ce(n,((n,s)=>{let r;ce(n,(([n,i],a)=>{i!==n&&($e(De[e],[l,s,a],i,n,Ot),t=o=r=1)})),r&&$e(be[e],[l,s],Ot)})),o&&$e(Z[e],[l],Ot)})),t&&$e(X[e],void 0,Ot)}}},Nt=e=>{const t=ie(Qe[e]),n=ie(ze[e])&&ie(Pe[e]);if(!t||!n){const l=e?[Ie(m),Ie(V)]:[m,V];if(t||Qt(Qe[e],l[0]),!n){let t;ce(l[1],(([n,l],o)=>{l!==n&&($e(ze[e],[o],l,n,Ft),t=1)})),t&&$e(Pe[e],void 0,Ft)}}},Bt=(e,...t)=>(vn((()=>e(...N(t,C)))),gn),Wt=()=>[Se(b,((e,t)=>-1===fe(r,t)?null:Se(e,((e,n)=>-1===fe(fe(v,t),n)?null:Se(e,(([,e])=>null!=e?e:null),((e,t)=>et(t)))),oe)),oe),Se(V,(([,e])=>null!=e?e:null),((e,t)=>et(t)))],$t=()=>({cellsTouched:n,valuesTouched:l,changedCells:we(b,_e,et),invalidCells:we(E),changedValues:Se(V,_e,et),invalidValues:Se(J),changedTableIds:Se(r),changedRowIds:Te(v),changedCellIds:we(p),changedValueIds:Se(m)}),qt=()=>we(K),Gt=()=>he(K),Ht=e=>he(fe(K,C(e))),Kt=(e,t,n,l=0,o)=>{return N(G(Q((s=fe(K,C(e)),r=(e,n)=>[k(t)?n:fe(e,C(t)),n],N([...null!=(i=null==s?void 0:s.entries())?i:[]],(([e,t])=>r(t,e)))),(([e],[t])=>je(e,t)*(n?-1:1))),l,k(o)?o:l+o),(([,e])=>e));var s,r,i},Ut=(e,t)=>he(fe(fe(K,C(e)),C(t))),Xt=(e,t,n)=>fe(fe(fe(K,C(e)),C(t)),C(n)),Yt=()=>Se(U),Zt=()=>he(U),_t=e=>fe(U,C(e)),en=e=>Bt((()=>(e=>lt(e,Ke,Jt))(e)?ht(e):0)),tn=e=>Bt((()=>rt(e)?St(e):0)),nn=e=>{try{vt(nt(e))}catch(e){}return gn},ln=t=>Bt((()=>{if((e=lt(t,(e=>lt(e,He))))&&(ct(t),!ie(K))){const e=qt();sn(),en(e)}})),on=e=>Bt((()=>{if(t=(e=>lt(e,He))(e)){const n=Yt();un(),dn(),t=!0,ut(e),tn(n)}})),sn=()=>Bt((()=>ht({}))),rn=e=>Bt((e=>re(K,e)?Rt(e):0),e),an=(e,t)=>Bt(((e,t)=>x(fe(K,e),(n=>re(n,t)?Ct(e,n,t):0))),e,t),dn=()=>Bt((()=>St({}))),cn=()=>Bt((()=>{ct({}),e=!1})),un=()=>Bt((()=>{ut({}),t=!1})),vn=(e,t)=>{if(-1!=o){hn();const n=e();return fn(t),n}},hn=()=>(-1!=o&&o++,1==o&&$e(Ne,void 0,Wt,$t),gn),fn=e=>(o>0&&(o--,0==o&&(n=!ie(b),l=!ie(V),o=1,Pt(1),n&&zt(1),jt(1),l&&Nt(1),(null==e?void 0:e(Wt,$t))&&(ce(b,((e,t)=>ce(e,((e,n)=>ce(e,(([e],l)=>Ve(gn,t,n,l,e))))))),ce(V,(([e],t)=>Ee(gn,t,e))),n=l=!1),$e(Be[0],void 0,Wt,$t),o=-1,Pt(0),n&&zt(0),jt(0),l&&Nt(0),$e(Be[1],void 0,Wt,$t),o=0,n=l=!1,z([r,c,v,p,b,E,m,V,J],de))),gn),gn={getContent:()=>[qt(),Yt()],getTables:qt,getTableIds:Gt,getTable:e=>Te(fe(K,C(e))),getTableCellIds:e=>he(fe(q,C(e))),getRowIds:Ht,getSortedRowIds:Kt,getRow:(e,t)=>Se(fe(fe(K,C(e)),C(t))),getCellIds:Ut,getCell:Xt,getValues:Yt,getValueIds:Zt,getValue:_t,hasTables:()=>!ie(K),hasTable:e=>re(K,C(e)),hasTableCell:(e,t)=>re(fe(q,C(e)),C(t)),hasRow:(e,t)=>re(fe(K,C(e)),C(t)),hasCell:(e,t,n)=>re(fe(fe(K,C(e)),C(t)),C(n)),hasValues:()=>!ie(U),hasValue:e=>re(U,C(e)),getTablesJson:()=>tt(K),getValuesJson:()=>tt(U),getJson:()=>tt([K,U]),getTablesSchemaJson:()=>tt(A),getValuesSchemaJson:()=>tt(j),getSchemaJson:()=>tt([A,j]),setContent:([e,t])=>Bt((()=>{(oe(e)?sn:en)(e),(oe(t)?dn:tn)(t)})),setTables:en,setTable:(e,t)=>Bt((e=>Ke(t,e)?ft(e,t):0),e),setRow:(e,t,n)=>Bt(((e,t)=>Ue(e,t,n)?gt(e,It(e),t,n):0),e,t),addRow:(e,t,n=!0)=>vn((()=>{let l;return Ue(e,l,t)&&(e=C(e),gt(e,It(e),l=wt(e,n?1:0),t)),l})),setPartialRow:(e,t,n)=>Bt(((e,t)=>{if(Ue(e,t,n,1)){const l=It(e);le(n,((n,o)=>Lt(e,l,t,o,n)))}}),e,t),setCell:(e,t,n,l)=>Bt(((e,t,n)=>x(Xe(e,t,n,D(l)?l(Xt(e,t,n)):l),(l=>Lt(e,It(e),t,n,l)))),e,t,n),setValues:tn,setPartialValues:e=>Bt((()=>rt(e,1)?le(e,((e,t)=>Tt(t,e))):0)),setValue:(e,t)=>Bt((e=>x(it(e,D(t)?t(_t(e)):t),(t=>Tt(e,t)))),e),setTransactionChanges:e=>Bt((()=>{le(e[0],((e,t)=>k(e)?rn(t):le(e,((e,n)=>k(e)?an(t,n):le(e,((e,l)=>Ve(gn,t,n,l,e))))))),le(e[1],((e,t)=>Ee(gn,t,e)))})),setTablesJson:nn,setValuesJson:e=>{try{pt(nt(e))}catch(e){}return gn},setJson:e=>{try{const[t,n]=nt(e);vt(t),pt(n)}catch(t){nn(e)}return gn},setTablesSchema:ln,setValuesSchema:on,setSchema:(e,t)=>Bt((()=>{ln(e),on(t)})),delTables:sn,delTable:rn,delRow:an,delCell:(e,t,n,l)=>Bt(((e,t,n)=>x(fe(K,e),(o=>x(fe(o,t),(s=>re(s,n)?bt(e,o,t,s,n,l):0))))),e,t,n),delValues:dn,delValue:e=>Bt((e=>re(U,e)?mt(e):0),e),delTablesSchema:cn,delValuesSchema:un,delSchema:()=>Bt((()=>{cn(),un()})),transaction:vn,startTransaction:hn,finishTransaction:fn,forEachTable:e=>ce(K,((t,n)=>e(n,(e=>ce(t,((t,n)=>e(n,(e=>ge(t,e))))))))),forEachTableCell:(e,t)=>ge(fe(q,C(e)),t),forEachRow:(e,t)=>ce(fe(K,C(e)),((e,n)=>t(n,(t=>ge(e,t))))),forEachCell:(e,t,n)=>ge(fe(fe(K,C(e)),C(t)),n),forEachValue:e=>ge(U,e),addSortedRowIdsListener:(e,t,n,l,o,s,r)=>{let i=Kt(e,t,n,l,o);return We((()=>{const r=Kt(e,t,n,l,o);P(r,i)||(i=r,s(gn,e,t,n,l,o,i))}),ae[r?1:0],[e,t],[Gt])},addStartTransactionListener:e=>We(e,Ne),addWillFinishTransactionListener:e=>We(e,Be[0]),addDidFinishTransactionListener:e=>We(e,Be[1]),callListener:e=>(Ge(e),gn),delListener:e=>(qe(e),gn),getListenerStats:()=>({}),createStore:st};return le({[f]:[0,X],[g]:[0,Y],[h]:[1,Z,[Gt]],[h+T]:[1,ee,[Gt]],[L]:[1,se,[Gt]],[y]:[2,be,[Gt,Ht]],[T]:[2,Me,[Gt,Ht]],[S]:[3,De,[Gt,Ht,Ut],e=>Ye(Xt(...e))],InvalidCell:[3,Je],[I]:[0,Pe],[R]:[0,Qe],[w]:[1,ze,[Zt],e=>Ye(_t(e[0]))],InvalidValue:[1,Ae]},(([e,t,n,l],o)=>{gn[u+o+d]=(...o)=>We(o[e],t[o[e+1]?1:0],e>0?G(o,0,e):void 0,n,l)})),_(gn)};e.createCheckpoints=Pe,e.createCustomPersister=(e,t,n,l,o,s,r=[])=>{let i,a,d,c=0,u=0;Le($e,r,(()=>0)),Le(qe,r,(()=>[]));const v=e=>We(void 0,null,(function*(){return 2!=c&&(c=1,yield h.schedule((()=>We(void 0,null,(function*(){yield e(),c=0}))))),h})),h={load:(n,l)=>We(void 0,null,(function*(){return yield v((()=>We(void 0,null,(function*(){try{e.setContent(yield t())}catch(t){e.setContent([n,l])}}))))})),startAutoLoad:(...n)=>We(void 0,[...n],(function*(n={},o={}){return h.stopAutoLoad(),yield h.load(n,o),u=1,d=l(((n,l)=>We(void 0,null,(function*(){if(l){const t=l();yield v((()=>We(void 0,null,(function*(){return e.setTransactionChanges(t)}))))}else yield v((()=>We(void 0,null,(function*(){var l;try{e.setContent(null!=(l=null==n?void 0:n())?l:yield t())}catch(e){null==s||s(e)}}))))})))),h})),stopAutoLoad:()=>(u&&(o(d),d=void 0,u=0),h),save:t=>We(void 0,null,(function*(){return 1!=c&&(c=2,yield h.schedule((()=>We(void 0,null,(function*(){try{yield n(e.getContent,t)}catch(e){null==s||s(e)}c=0}))))),h})),startAutoSave:()=>We(void 0,null,(function*(){return yield h.stopAutoSave().save(),i=e.addDidFinishTransactionListener(((e,t)=>{const[n,l]=t();oe(n)&&oe(l)||h.save((()=>[n,l]))})),h})),stopAutoSave:()=>(x(i,e.delListener),h),schedule:(...e)=>We(void 0,null,(function*(){return H(fe(qe,r),...e),yield We(void 0,null,(function*(){if(!fe($e,r)){for(ye($e,r,1);!k(a=U(fe(qe,r)));)try{yield a()}catch(e){null==s||s(e)}ye($e,r,0)}})),h})),getStore:()=>e,destroy:()=>h.stopAutoLoad().stopAutoSave(),getStats:()=>({})};return _(h)},e.createIndexes=Qe,e.createMetrics=Be,e.createQueries=Ue,e.createRelationships=Xe,e.createStore=st,e.defaultSorter=je},"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).TinyBase={});
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tinybase",
3
- "version": "4.0.3",
3
+ "version": "4.0.4",
4
4
  "author": "jamesgpearce",
5
5
  "repository": "github:tinyplex/tinybase",
6
6
  "license": "MIT",
@@ -225,7 +225,7 @@
225
225
  "@types/jest": "^29.5.3",
226
226
  "@types/jest-environment-puppeteer": "^5.0.3",
227
227
  "@types/less": "^3.0.3",
228
- "@types/node": "^20.4.9",
228
+ "@types/node": "^20.4.10",
229
229
  "@types/puppeteer": "^5.4.7",
230
230
  "@types/react": "^18.2.20",
231
231
  "@types/react-dom": "^18.2.7",
@@ -243,8 +243,8 @@
243
243
  "buffer-replace": "^1.0.0",
244
244
  "country-flag-emoji-json": "^2.0.0",
245
245
  "cspell": "^7.0.0",
246
- "esbuild": "^0.19.0",
247
- "eslint": "^8.46.0",
246
+ "esbuild": "^0.19.1",
247
+ "eslint": "^8.47.0",
248
248
  "eslint-config-prettier": "^9.0.0",
249
249
  "eslint-plugin-jest": "^27.2.3",
250
250
  "eslint-plugin-jsdoc": "^46.4.6",
@@ -261,7 +261,7 @@
261
261
  "jest-puppeteer": "^9.0.0",
262
262
  "less": "^4.2.0",
263
263
  "prettier": "^2.8.8",
264
- "puppeteer": "^21.0.2",
264
+ "puppeteer": "^21.0.3",
265
265
  "react": "^18.2.0",
266
266
  "react-dom": "^18.2.0",
267
267
  "react-test-renderer": "^18.2.0",
package/readme.md CHANGED
@@ -1,4 +1,4 @@
1
- <section id="hero"><h2 id="the-reactive-data-store-for-local-first-apps">The <em>reactive</em> data store for <span>local-first apps</span>.</h2><p>Modern apps deserve better. Why trade reactive user experiences to be able to use relational data? Why sacrifice features for bundle size? And why does the cloud do all the work <a href="https://localfirstweb.dev/" target="_blank">anyway</a>?</p><p><em>TinyBase is a smart new way to structure your local app data:</em></p><ul><li>Manage <a href="#start-with-a-simple-key-value-store">key-value data</a>, <a href="#level-up-to-use-tabular-data">tabular data</a> - or both - with optional <a href="#apply-schemas-to-tables-values">schematization</a> to model it.</li><li><a href="#register-listeners-at-any-granularity">Flexibly reactive</a> to reconciled updates, so you only spend cycles on things that change.</li><li><a href="#build-complex-queries-with-tinyql">Powerful query engine</a> to select, join, filter, group, sort and paginate data - reactively.</li><li><a href="#create-indexes-for-fast-lookups">Indexing</a>, <a href="#define-metrics-and-aggregations">metrics</a>, <a href="#model-relationships-between-tables">relationships</a> - and even an <a href="#use-checkpoints-for-an-easy-undo-stack">undo stack</a> for your app state.</li><li><a href="#type-definitions-orm-like-apis">Type definitions &amp; ORM-like APIs</a> (<em>new!</em>), based on a schema or inference.</li><li>Easily <a href="#persist-to-storage-sqlite-or-crdts">sync your data</a> to storage, (<em>new!</em>) SQLite, or (<em>new!</em>) CRDTs.</li><li>Use idiomatic, optional, <a href="#call-hooks-to-bind-to-data">bindings to React</a> for a fully reactive UI.</li></ul><p><em>Tiny by name, tiny by nature</em>, TinyBase only costs <a href="#did-we-say-tiny">4.7kB - 8.9kB</a> when compressed, and has zero dependencies. And of course it&#x27;s <a href="#well-tested-and-documented">well tested</a>, <a href="https://tinybase.org/guides/the-basics/getting-started/">fully documented</a>, and <a href="https://github.com/tinyplex/tinybase">open source</a>.</p></section><p><a id="new" href="https://tinybase.org/guides/releases/#v4-0"><em>NEW!</em> v4.0 release</a></p><hr><p><a class="start" href="https://tinybase.org/guides/the-basics/getting-started/">Get started</a></p><p><a href="https://tinybase.org/demos/">Try the demos</a></p><p><a href="https://tinybase.org/api/store/interfaces/store/store/">Read the docs</a></p><hr><section><h3 id="proud-to-be-sponsored-by">Proud to be sponsored by:</h3><p><a href="https://github.com/expo" target="_blank"><img title="expo" src="https://github.com/expo.png?size=48" width="48" height="48"></a><a href="https://github.com/WonderPanda" target="_blank"><img title="WonderPanda" src="https://github.com/WonderPanda.png?size=48" width="48" height="48"></a><a href="https://github.com/arpitBhalla" target="_blank"><img title="arpitBhalla" src="https://github.com/arpitBhalla.png?size=48" width="48" height="48"></a></p></section><section><h3 id="excited-to-be-used-by">Excited to be used by:</h3><p><a href="https://github.com/Apocalypsor" target="_blank"><img title="Apocalypsor" src="https://github.com/Apocalypsor.png?size=48" width="48" height="48"></a><a href="https://github.com/brentvatne" target="_blank"><img title="brentvatne" src="https://github.com/brentvatne.png?size=48" width="48" height="48"></a><a href="https://github.com/circadian-risk" target="_blank"><img title="circadian-risk" src="https://github.com/circadian-risk.png?size=48" width="48" height="48"></a><a href="https://github.com/cubecull" target="_blank"><img title="cubecull" src="https://github.com/cubecull.png?size=48" width="48" height="48"></a><a href="https://github.com/erwinkn" target="_blank"><img title="erwinkn" src="https://github.com/erwinkn.png?size=48" width="48" height="48"></a><a href="https://github.com/flaming-codes" target="_blank"><img title="flaming-codes" src="https://github.com/flaming-codes.png?size=48" width="48" height="48"></a><a href="https://github.com/generates" target="_blank"><img title="generates" src="https://github.com/generates.png?size=48" width="48" height="48"></a><a href="https://github.com/Giulio987" target="_blank"><img title="Giulio987" src="https://github.com/Giulio987.png?size=48" width="48" height="48"></a><a href="https://github.com/jaysc" target="_blank"><img title="jaysc" src="https://github.com/jaysc.png?size=48" width="48" height="48"></a><a href="https://github.com/Kayoo-asso" target="_blank"><img title="Kayoo-asso" src="https://github.com/Kayoo-asso.png?size=48" width="48" height="48"></a><a href="https://github.com/kotofurumiya" target="_blank"><img title="kotofurumiya" src="https://github.com/kotofurumiya.png?size=48" width="48" height="48"></a><a href="https://github.com/learn-anything" target="_blank"><img title="learn-anything" src="https://github.com/learn-anything.png?size=48" width="48" height="48"></a><a href="https://github.com/miking-the-viking" target="_blank"><img title="miking-the-viking" src="https://github.com/miking-the-viking.png?size=48" width="48" height="48"></a><a href="https://github.com/shaneosullivan" target="_blank"><img title="shaneosullivan" src="https://github.com/shaneosullivan.png?size=48" width="48" height="48"></a><a href="https://github.com/SuperSonicHub1" target="_blank"><img title="SuperSonicHub1" src="https://github.com/SuperSonicHub1.png?size=48" width="48" height="48"></a><a href="https://github.com/threepointone" target="_blank"><img title="threepointone" src="https://github.com/threepointone.png?size=48" width="48" height="48"></a><a href="https://github.com/uptonking" target="_blank"><img title="uptonking" src="https://github.com/uptonking.png?size=48" width="48" height="48"></a><a href="https://github.com/WonderPanda" target="_blank"><img title="WonderPanda" src="https://github.com/WonderPanda.png?size=48" width="48" height="48"></a></p></section><hr><section><h2 id="start-with-a-simple-key-value-store">Start with a simple key-value store.</h2><p>Creating a <a href="https://tinybase.org/api/store/interfaces/store/store/"><code>Store</code></a> requires just a simple call to the <a href="https://tinybase.org/api/store/functions/creation/createstore/"><code>createStore</code></a> function. Once you have one, you can easily set <a href="https://tinybase.org/api/store/type-aliases/store/values/"><code>Values</code></a> in it by unique <a href="https://tinybase.org/api/common/type-aliases/identity/id/"><code>Id</code></a>. And of course you can easily get them back out again.</p><p>Read more about using keyed value data in <a href="https://tinybase.org/guides/the-basics/">The Basics</a> guide.</p></section>
1
+ <section id="hero"><h2 id="the-reactive-data-store-for-local-first-apps">The <em>reactive</em> data store for <span>local-first apps</span>.</h2><p>Modern apps deserve better. Why trade reactive user experiences to be able to use relational data? Why sacrifice features for bundle size? And why does the cloud do all the work <a href="https://localfirstweb.dev/" target="_blank">anyway</a>?</p><p><em>TinyBase is a smart new way to structure your local app data:</em></p><ul><li>Manage <a href="#start-with-a-simple-key-value-store">key-value data</a>, <a href="#level-up-to-use-tabular-data">tabular data</a> - or both - with optional <a href="#apply-schemas-to-tables-values">schematization</a> to model it.</li><li><a href="#register-listeners-at-any-granularity">Flexibly reactive</a> to reconciled updates, so you only spend cycles on things that change.</li><li><a href="#build-complex-queries-with-tinyql">Powerful query engine</a> to select, join, filter, group, sort and paginate data - reactively.</li><li><a href="#create-indexes-for-fast-lookups">Indexing</a>, <a href="#define-metrics-and-aggregations">metrics</a>, <a href="#model-relationships-between-tables">relationships</a> - and even an <a href="#use-checkpoints-for-an-easy-undo-stack">undo stack</a> for your app state.</li><li><a href="#type-definitions-orm-like-apis">Type definitions &amp; ORM-like APIs</a> (<em>new!</em>), based on a schema or inference.</li><li>Easily <a href="#persist-to-storage-sqlite-or-crdts">sync your data</a> to storage, (<em>new!</em>) SQLite, or (<em>new!</em>) CRDTs.</li><li>Use idiomatic, optional, <a href="#call-hooks-to-bind-to-data">bindings to React</a> for a fully reactive UI.</li></ul><p><em>Tiny by name, tiny by nature</em>, TinyBase only costs <a href="#did-we-say-tiny">4.7kB - 9.0kB</a> when compressed, and has zero dependencies. And of course it&#x27;s <a href="#well-tested-and-documented">well tested</a>, <a href="https://tinybase.org/guides/the-basics/getting-started/">fully documented</a>, and <a href="https://github.com/tinyplex/tinybase">open source</a>.</p></section><p><a id="new" href="https://tinybase.org/guides/releases/#v4-0"><em>NEW!</em> v4.0 release</a></p><hr><p><a class="start" href="https://tinybase.org/guides/the-basics/getting-started/">Get started</a></p><p><a href="https://tinybase.org/demos/">Try the demos</a></p><p><a href="https://tinybase.org/api/store/interfaces/store/store/">Read the docs</a></p><hr><section><h3 id="proud-to-be-sponsored-by">Proud to be sponsored by:</h3><p><a href="https://github.com/expo" target="_blank"><img title="expo" src="https://github.com/expo.png?size=48" width="48" height="48"></a><a href="https://github.com/WonderPanda" target="_blank"><img title="WonderPanda" src="https://github.com/WonderPanda.png?size=48" width="48" height="48"></a><a href="https://github.com/arpitBhalla" target="_blank"><img title="arpitBhalla" src="https://github.com/arpitBhalla.png?size=48" width="48" height="48"></a></p></section><section><h3 id="excited-to-be-used-by">Excited to be used by:</h3><p><a href="https://github.com/Apocalypsor" target="_blank"><img title="Apocalypsor" src="https://github.com/Apocalypsor.png?size=48" width="48" height="48"></a><a href="https://github.com/brentvatne" target="_blank"><img title="brentvatne" src="https://github.com/brentvatne.png?size=48" width="48" height="48"></a><a href="https://github.com/circadian-risk" target="_blank"><img title="circadian-risk" src="https://github.com/circadian-risk.png?size=48" width="48" height="48"></a><a href="https://github.com/cubecull" target="_blank"><img title="cubecull" src="https://github.com/cubecull.png?size=48" width="48" height="48"></a><a href="https://github.com/erwinkn" target="_blank"><img title="erwinkn" src="https://github.com/erwinkn.png?size=48" width="48" height="48"></a><a href="https://github.com/expo" target="_blank"><img title="expo" src="https://github.com/expo.png?size=48" width="48" height="48"></a><a href="https://github.com/ezra-en" target="_blank"><img title="ezra-en" src="https://github.com/ezra-en.png?size=48" width="48" height="48"></a><a href="https://github.com/fdfontes" target="_blank"><img title="fdfontes" src="https://github.com/fdfontes.png?size=48" width="48" height="48"></a><a href="https://github.com/flaming-codes" target="_blank"><img title="flaming-codes" src="https://github.com/flaming-codes.png?size=48" width="48" height="48"></a><a href="https://github.com/generates" target="_blank"><img title="generates" src="https://github.com/generates.png?size=48" width="48" height="48"></a><a href="https://github.com/Giulio987" target="_blank"><img title="Giulio987" src="https://github.com/Giulio987.png?size=48" width="48" height="48"></a><a href="https://github.com/jaysc" target="_blank"><img title="jaysc" src="https://github.com/jaysc.png?size=48" width="48" height="48"></a><a href="https://github.com/Kayoo-asso" target="_blank"><img title="Kayoo-asso" src="https://github.com/Kayoo-asso.png?size=48" width="48" height="48"></a><a href="https://github.com/kotofurumiya" target="_blank"><img title="kotofurumiya" src="https://github.com/kotofurumiya.png?size=48" width="48" height="48"></a><a href="https://github.com/learn-anything" target="_blank"><img title="learn-anything" src="https://github.com/learn-anything.png?size=48" width="48" height="48"></a><a href="https://github.com/marksteve" target="_blank"><img title="marksteve" src="https://github.com/marksteve.png?size=48" width="48" height="48"></a><a href="https://github.com/miking-the-viking" target="_blank"><img title="miking-the-viking" src="https://github.com/miking-the-viking.png?size=48" width="48" height="48"></a><a href="https://github.com/nikitavoloboev" target="_blank"><img title="nikitavoloboev" src="https://github.com/nikitavoloboev.png?size=48" width="48" height="48"></a><a href="https://github.com/shaneosullivan" target="_blank"><img title="shaneosullivan" src="https://github.com/shaneosullivan.png?size=48" width="48" height="48"></a><a href="https://github.com/SuperSonicHub1" target="_blank"><img title="SuperSonicHub1" src="https://github.com/SuperSonicHub1.png?size=48" width="48" height="48"></a><a href="https://github.com/threepointone" target="_blank"><img title="threepointone" src="https://github.com/threepointone.png?size=48" width="48" height="48"></a><a href="https://github.com/uptonking" target="_blank"><img title="uptonking" src="https://github.com/uptonking.png?size=48" width="48" height="48"></a><a href="https://github.com/WonderPanda" target="_blank"><img title="WonderPanda" src="https://github.com/WonderPanda.png?size=48" width="48" height="48"></a></p></section><hr><section><h2 id="start-with-a-simple-key-value-store">Start with a simple key-value store.</h2><p>Creating a <a href="https://tinybase.org/api/store/interfaces/store/store/"><code>Store</code></a> requires just a simple call to the <a href="https://tinybase.org/api/store/functions/creation/createstore/"><code>createStore</code></a> function. Once you have one, you can easily set <a href="https://tinybase.org/api/store/type-aliases/store/values/"><code>Values</code></a> in it by unique <a href="https://tinybase.org/api/common/type-aliases/identity/id/"><code>Id</code></a>. And of course you can easily get them back out again.</p><p>Read more about using keyed value data in <a href="https://tinybase.org/guides/the-basics/">The Basics</a> guide.</p></section>
2
2
 
3
3
  ```js
4
4
  const store = createStore()
@@ -266,4 +266,4 @@ export const createShop: typeof createShopDecl = () => {
266
266
  };
267
267
  ```
268
268
 
269
- <section><h2 id="did-we-say-tiny">Did we say tiny?</h2><p>If you use the basic <a href="https://tinybase.org/api/store/"><code>store</code></a> module alone, you&#x27;ll only add a gzipped <em>4.7kB</em> to your app. Incrementally add the other modules as you need more functionality, or get it all for <em>8.9kB</em>.</p><p>The optional <a href="https://tinybase.org/api/ui-react/"><code>ui-react</code></a> module is just another <em>3.4kB</em>, the auxiliary <a href="https://tinybase.org/api/tools/"><code>tools</code></a> module is <em>10.2kB</em>, and everything is super fast. Life&#x27;s easy when you have zero dependencies!</p><p>Read more about how TinyBase is structured and packaged in the <a href="https://tinybase.org/guides/how-tinybase-is-built/architecture/">Architecture</a> guide.</p></section><div class="table"><table class="fixed"><tbody><tr><th width="30%"> </th><th>.js.gz</th><th>.js</th><th>debug.js</th><th>.d.ts</th></tr><tr><th class="right"><a href="https://tinybase.org/api/store/">store</a></th><td>4.7kB</td><td>11.1kB</td><td>47.6kB</td><td>212.9kB</td></tr><tr><th class="right"><a href="https://tinybase.org/api/metrics/">metrics</a></th><td>1.8kB</td><td>3.6kB</td><td>14.9kB</td><td>29.2kB</td></tr><tr><th class="right"><a href="https://tinybase.org/api/indexes/">indexes</a></th><td>1.9kB</td><td>3.7kB</td><td>16.7kB</td><td>33.8kB</td></tr><tr><th class="right"><a href="https://tinybase.org/api/relationships/">relationships</a></th><td>1.8kB</td><td>3.7kB</td><td>16.8kB</td><td>42.1kB</td></tr><tr><th class="right"><a href="https://tinybase.org/api/queries/">queries</a></th><td>2.7kB</td><td>5.5kB</td><td>25.0kB</td><td>112.7kB</td></tr><tr><th class="right"><a href="https://tinybase.org/api/checkpoints/">checkpoints</a></th><td>1.5kB</td><td>3.1kB</td><td>12.5kB</td><td>33.3kB</td></tr><tr><th class="right"><a href="https://tinybase.org/api/persisters/">persisters</a></th><td>0.6kB</td><td>1.2kB</td><td>3.9kB</td><td>42.4kB</td></tr><tr><th class="right"><a href="https://tinybase.org/api/common/">common</a></th><td>0.1kB</td><td>0.1kB</td><td>0.1kB</td><td>3.5kB</td></tr><tr><th class="right">tinybase (all)</th><td>8.9kB</td><td>21.9kB</td><td>94.8kB</td><td>0.3kB</td></tr></tbody></table></div><section><h2 id="well-tested-and-documented">Well tested and documented.</h2><p>TinyBase has <em>100.0%</em> test coverage, including the code throughout the documentation - even on this page! The guides, demos, and API examples are designed to make it as easy as possible for you to get your TinyBase-powered app up and running.</p><p>Read more about how TinyBase is tested in the Unit <a href="https://tinybase.org/guides/how-tinybase-is-built/testing/">Testing</a> guide.</p></section><div class="table"><table class="fixed"><tbody><tr><th width="30%"> </th><th>Total</th><th>Tested</th><th>Coverage</th></tr><tr><th class="right">Lines</th><td>1,815</td><td>1,815</td><td>100.0%</td></tr><tr><th class="right">Statements</th><td>1,957</td><td>1,957</td><td>100.0%</td></tr><tr><th class="right">Functions</th><td>776</td><td>776</td><td>100.0%</td></tr><tr><th class="right">Branches</th><td>669</td><td>669</td><td>100.0%</td></tr><tr><th class="right">Tests</th><td colspan="3">3,138</td></tr><tr><th class="right">Assertions</th><td colspan="3">14,445</td></tr></tbody></table></div><hr><p><a class="start" href="https://tinybase.org/guides/the-basics/getting-started/">Get started</a></p><p><a href="https://tinybase.org/demos/">Try the demos</a></p><p><a href="https://tinybase.org/api/store/interfaces/store/store/">Read the docs</a></p><hr><section><h2 id="follow">Follow</h2><ul><li>News and updates on <a href="https://twitter.com/tinybasejs">Twitter</a>, <a href="https://discord.com/invite/mGz3mevwP8">Discord</a>, and <a href="https://facebook.com/tinybasejs">Facebook</a>.</li><li><a href="https://github.com/tinyplex/tinybase/discussions">Discussions</a> and <a href="https://github.com/tinyplex/tinybase/issues">issues</a> on <a href="https://github.com/tinyplex/tinybase">GitHub</a>.</li><li><a href="https://tinybase.org/guides/releases/">Release notes</a> for each version.</li><li>Packages on <a href="https://www.npmjs.com/package/tinybase/v/4.0.3">NPM</a>.</li></ul></section><section><h2 id="about">About</h2><p>Building TinyBase was originally an interesting exercise for <a rel="me" href="https://hachyderm.io/@jamesgpearce">me</a> in API design, minification, and documentation. It could not have been built without these great <a href="https://tinybase.org/guides/how-tinybase-is-built/credits/#giants">projects</a> and <a href="https://tinybase.org/guides/how-tinybase-is-built/credits/#and-friends">friends</a>, and I hope you enjoy using it!</p></section>
269
+ <section><h2 id="did-we-say-tiny">Did we say tiny?</h2><p>If you use the basic <a href="https://tinybase.org/api/store/"><code>store</code></a> module alone, you&#x27;ll only add a gzipped <em>4.7kB</em> to your app. Incrementally add the other modules as you need more functionality, or get it all for <em>9.0kB</em>.</p><p>The optional <a href="https://tinybase.org/api/ui-react/"><code>ui-react</code></a> module is just another <em>3.4kB</em>, the auxiliary <a href="https://tinybase.org/api/tools/"><code>tools</code></a> module is <em>10.2kB</em>, and everything is super fast. Life&#x27;s easy when you have zero dependencies!</p><p>Read more about how TinyBase is structured and packaged in the <a href="https://tinybase.org/guides/how-tinybase-is-built/architecture/">Architecture</a> guide.</p></section><div class="table"><table class="fixed"><tbody><tr><th width="30%"> </th><th>.js.gz</th><th>.js</th><th>debug.js</th><th>.d.ts</th></tr><tr><th class="right"><a href="https://tinybase.org/api/store/">store</a></th><td>4.7kB</td><td>11.1kB</td><td>47.6kB</td><td>212.9kB</td></tr><tr><th class="right"><a href="https://tinybase.org/api/metrics/">metrics</a></th><td>1.8kB</td><td>3.6kB</td><td>14.9kB</td><td>29.2kB</td></tr><tr><th class="right"><a href="https://tinybase.org/api/indexes/">indexes</a></th><td>1.9kB</td><td>3.7kB</td><td>16.7kB</td><td>33.8kB</td></tr><tr><th class="right"><a href="https://tinybase.org/api/relationships/">relationships</a></th><td>1.8kB</td><td>3.7kB</td><td>16.8kB</td><td>42.1kB</td></tr><tr><th class="right"><a href="https://tinybase.org/api/queries/">queries</a></th><td>2.7kB</td><td>5.5kB</td><td>25.0kB</td><td>112.7kB</td></tr><tr><th class="right"><a href="https://tinybase.org/api/checkpoints/">checkpoints</a></th><td>1.5kB</td><td>3.1kB</td><td>12.5kB</td><td>33.3kB</td></tr><tr><th class="right"><a href="https://tinybase.org/api/persisters/">persisters</a></th><td>0.7kB</td><td>1.5kB</td><td>5.1kB</td><td>43.4kB</td></tr><tr><th class="right"><a href="https://tinybase.org/api/common/">common</a></th><td>0.1kB</td><td>0.1kB</td><td>0.1kB</td><td>3.5kB</td></tr><tr><th class="right">tinybase (all)</th><td>9.0kB</td><td>22.0kB</td><td>95.5kB</td><td>0.3kB</td></tr></tbody></table></div><section><h2 id="well-tested-and-documented">Well tested and documented.</h2><p>TinyBase has <em>100.0%</em> test coverage, including the code throughout the documentation - even on this page! The guides, demos, and API examples are designed to make it as easy as possible for you to get your TinyBase-powered app up and running.</p><p>Read more about how TinyBase is tested in the Unit <a href="https://tinybase.org/guides/how-tinybase-is-built/testing/">Testing</a> guide.</p></section><div class="table"><table class="fixed"><tbody><tr><th width="30%"> </th><th>Total</th><th>Tested</th><th>Coverage</th></tr><tr><th class="right">Lines</th><td>1,820</td><td>1,820</td><td>100.0%</td></tr><tr><th class="right">Statements</th><td>1,964</td><td>1,964</td><td>100.0%</td></tr><tr><th class="right">Functions</th><td>779</td><td>779</td><td>100.0%</td></tr><tr><th class="right">Branches</th><td>670</td><td>670</td><td>100.0%</td></tr><tr><th class="right">Tests</th><td colspan="3">3,138</td></tr><tr><th class="right">Assertions</th><td colspan="3">14,445</td></tr></tbody></table></div><hr><p><a class="start" href="https://tinybase.org/guides/the-basics/getting-started/">Get started</a></p><p><a href="https://tinybase.org/demos/">Try the demos</a></p><p><a href="https://tinybase.org/api/store/interfaces/store/store/">Read the docs</a></p><hr><section><h2 id="follow">Follow</h2><ul><li>News and updates on <a href="https://twitter.com/tinybasejs">Twitter</a>, <a href="https://discord.com/invite/mGz3mevwP8">Discord</a>, and <a href="https://facebook.com/tinybasejs">Facebook</a>.</li><li><a href="https://github.com/tinyplex/tinybase/discussions">Discussions</a> and <a href="https://github.com/tinyplex/tinybase/issues">issues</a> on <a href="https://github.com/tinyplex/tinybase">GitHub</a>.</li><li><a href="https://tinybase.org/guides/releases/">Release notes</a> for each version.</li><li>Packages on <a href="https://www.npmjs.com/package/tinybase/v/4.0.4">NPM</a>.</li></ul></section><section><h2 id="about">About</h2><p>Building TinyBase was originally an interesting exercise for <a rel="me" href="https://hachyderm.io/@jamesgpearce">me</a> in API design, minification, and documentation. It could not have been built without these great <a href="https://tinybase.org/guides/how-tinybase-is-built/credits/#giants">projects</a> and <a href="https://tinybase.org/guides/how-tinybase-is-built/credits/#and-friends">friends</a>, and I hope you enjoy using it!</p></section>