tinybase 4.1.4 → 4.2.0-beta.1

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 (62) hide show
  1. package/lib/cjs/persisters/persister-indexed-db.cjs +1 -0
  2. package/lib/cjs/persisters/persister-indexed-db.cjs.gz +0 -0
  3. package/lib/cjs/persisters/persister-remote.cjs +1 -1
  4. package/lib/cjs/persisters/persister-remote.cjs.gz +0 -0
  5. package/lib/cjs/persisters/persister-yjs.cjs +1 -1
  6. package/lib/cjs/persisters/persister-yjs.cjs.gz +0 -0
  7. package/lib/cjs/tools.cjs +1 -1
  8. package/lib/cjs/tools.cjs.gz +0 -0
  9. package/lib/cjs-es6/persisters/persister-indexed-db.cjs +1 -0
  10. package/lib/cjs-es6/persisters/persister-indexed-db.cjs.gz +0 -0
  11. package/lib/cjs-es6/persisters/persister-remote.cjs +1 -1
  12. package/lib/cjs-es6/persisters/persister-remote.cjs.gz +0 -0
  13. package/lib/cjs-es6/persisters/persister-yjs.cjs +1 -1
  14. package/lib/cjs-es6/persisters/persister-yjs.cjs.gz +0 -0
  15. package/lib/cjs-es6/tools.cjs +1 -1
  16. package/lib/cjs-es6/tools.cjs.gz +0 -0
  17. package/lib/debug/persisters/persister-browser.js +13 -8
  18. package/lib/debug/persisters/persister-indexed-db.js +272 -0
  19. package/lib/debug/persisters/persister-remote.js +1 -1
  20. package/lib/debug/persisters/persister-yjs.js +10 -16
  21. package/lib/debug/tools.js +21 -5
  22. package/lib/debug/ui-react-dom.js +12 -7
  23. package/lib/es6/persisters/persister-indexed-db.js +1 -0
  24. package/lib/es6/persisters/persister-indexed-db.js.gz +0 -0
  25. package/lib/es6/persisters/persister-remote.js +1 -1
  26. package/lib/es6/persisters/persister-remote.js.gz +0 -0
  27. package/lib/es6/persisters/persister-yjs.js +1 -1
  28. package/lib/es6/persisters/persister-yjs.js.gz +0 -0
  29. package/lib/es6/tools.js +1 -1
  30. package/lib/es6/tools.js.gz +0 -0
  31. package/lib/persisters/persister-indexed-db.js +1 -0
  32. package/lib/persisters/persister-indexed-db.js.gz +0 -0
  33. package/lib/persisters/persister-remote.js +1 -1
  34. package/lib/persisters/persister-remote.js.gz +0 -0
  35. package/lib/persisters/persister-yjs.js +1 -1
  36. package/lib/persisters/persister-yjs.js.gz +0 -0
  37. package/lib/tools.js +1 -1
  38. package/lib/tools.js.gz +0 -0
  39. package/lib/types/persisters/persister-indexed-db.d.ts +75 -0
  40. package/lib/types/persisters/persister-remote.d.ts +2 -2
  41. package/lib/types/persisters.d.ts +1 -0
  42. package/lib/types/with-schemas/persisters/persister-indexed-db.d.ts +86 -0
  43. package/lib/types/with-schemas/persisters/persister-remote.d.ts +3 -3
  44. package/lib/types/with-schemas/persisters.d.ts +1 -0
  45. package/lib/umd/persisters/persister-indexed-db.js +1 -0
  46. package/lib/umd/persisters/persister-indexed-db.js.gz +0 -0
  47. package/lib/umd/persisters/persister-remote.js +1 -1
  48. package/lib/umd/persisters/persister-remote.js.gz +0 -0
  49. package/lib/umd/persisters/persister-yjs.js +1 -1
  50. package/lib/umd/persisters/persister-yjs.js.gz +0 -0
  51. package/lib/umd/tools.js +1 -1
  52. package/lib/umd/tools.js.gz +0 -0
  53. package/lib/umd-es6/persisters/persister-indexed-db.js +1 -0
  54. package/lib/umd-es6/persisters/persister-indexed-db.js.gz +0 -0
  55. package/lib/umd-es6/persisters/persister-remote.js +1 -1
  56. package/lib/umd-es6/persisters/persister-remote.js.gz +0 -0
  57. package/lib/umd-es6/persisters/persister-yjs.js +1 -1
  58. package/lib/umd-es6/persisters/persister-yjs.js.gz +0 -0
  59. package/lib/umd-es6/tools.js +1 -1
  60. package/lib/umd-es6/tools.js.gz +0 -0
  61. package/package.json +17 -15
  62. package/readme.md +13 -13
@@ -0,0 +1 @@
1
+ var t,e;t=this,e=function(t){"use strict";const e=(t,e)=>t.map(e),a=(t,...e)=>t.push(...e),s=Promise,n=setInterval,o=clearInterval,r=t=>null==t,c=(t,e,a)=>r(t)?a?.():e(t),i=t=>new s(t),d=async t=>s.all(t),y=Object,l=y.keys,u=y.freeze,w=t=>(t=>t instanceof y&&t.constructor==y)(t)&&0==(t=>l(t).length)(t),h=t=>new Map(t),p=(t,e)=>t?.get(e),f=(t,e,a)=>{return r(a)?(s=t,n=e,s?.delete(n),t):t?.set(e,a);var s,n},v=(t,e,a)=>{var s,n;return s=t,n=e,s?.has(n)||f(t,e,a()),p(t,e)},g=h(),b=h(),A=globalThis.window,S=["t","v"],x={keyPath:"k"},j=async(t,s)=>{const n=((a,s)=>e(y.entries(a),(([e,a])=>L(t,"put",{k:e,v:a}))))(s);e(await L(t,"getAllKeys"),(e=>((t,e)=>!r(((t,e)=>c(t,(t=>t[e])))(t,e)))(s,e)?0:a(n,L(t,"delete",e)))),await d(n)},L=async(t,e,a)=>i(((s,n)=>{const o=t[e](a);o.onsuccess=()=>s(o.result),o.onerror=()=>n(`objectStore.${e} error`)}));t.createIndexedDbPersister=(t,s,l=1,h)=>{const T=async(t,a=[],n=0)=>i(((o,r)=>{const c=A.indexedDB.open(s,1);c.onupgradeneeded=()=>n&&e(S,(t=>c.result.createObjectStore(t,x))),c.onsuccess=async()=>{try{const s=c.result.transaction(S,"readwrite"),n=await d(e(S,(async(e,n)=>await t(s.objectStore(e),a[n]))));c.result.close(),o(n)}catch(t){r(t)}},c.onerror=()=>r("indexedDB.open error")}));return((t,e,s,n,o,i,d=[])=>{let y,l,h,A=0,S=0;v(g,d,(()=>0)),v(b,d,(()=>[]));const x=async t=>(2!=A&&(A=1,await j.schedule((async()=>{await t(),A=0}))),j),j={load:async(a,s)=>await x((async()=>{try{t.setContent(await e())}catch{t.setContent([a,s])}})),startAutoLoad:async(a={},s={})=>(j.stopAutoLoad(),await j.load(a,s),S=1,h=n((async(a,s)=>{if(s){const e=s();await x((async()=>t.setTransactionChanges(e)))}else await x((async()=>{try{t.setContent(a?.()??await e())}catch(t){i?.(t)}}))})),j),stopAutoLoad:()=>(S&&(o(h),h=void 0,S=0),j),save:async e=>(1!=A&&(A=2,await j.schedule((async()=>{try{await s(t.getContent,e)}catch(t){i?.(t)}A=0}))),j),startAutoSave:async()=>(await j.stopAutoSave().save(),y=t.addDidFinishTransactionListener(((t,e)=>{const[a,s]=e();w(a)&&w(s)||j.save((()=>[a,s]))})),j),stopAutoSave:()=>(c(y,t.delListener),j),schedule:async(...t)=>(a(p(b,d),...t),await(async()=>{if(!p(g,d)){for(f(g,d,1);!r((t=p(b,d),l=t.shift()));)try{await l()}catch(t){i?.(t)}f(g,d,0)}var t})(),j),getStore:()=>t,destroy:()=>j.stopAutoLoad().stopAutoSave(),getStats:()=>({})};return u(j)})(t,(async()=>await T((async t=>((t=[])=>y.fromEntries(t))(e(await L(t,"getAll"),(({k:t,v:e})=>[t,e])))))),(async t=>await T((async(t,e)=>await j(t,e)),t(),1)),(t=>n(t,1e3*l)),(t=>o(t)),h)},t.objectStoreMatch=j},"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).TinyBasePersisterIndexedDb={});
@@ -1 +1 @@
1
- var t,e;t=this,e=function(t){"use strict";const e=setInterval,a=clearInterval,s=(t,e)=>t instanceof e,n=t=>null==t,o=Object,r=o.keys,c=o.freeze,i=t=>(t=>s(t,o)&&t.constructor==o)(t)&&0==(t=>r(t).length)(t),d=JSON.parse,y=t=>new Map(t),u=(t,e)=>t?.get(e),f=(t,e,a)=>{return n(a)?(s=t,o=e,s?.delete(o),t):t?.set(e,a);var s,o},h=(t,e,a)=>{var s,n;return s=t,n=e,s?.has(n)||f(t,e,a()),u(t,e)},l=y(),p=y(),w=t=>t.headers.get("ETag");t.createRemotePersister=(t,r,y,v,g)=>{let A;return((t,e,a,s,o,r,d=[])=>{let y,w,v,g=0,A=0;h(l,d,(()=>0)),h(p,d,(()=>[]));const S=async t=>(2!=g&&(g=1,await T.schedule((async()=>{await t(),g=0}))),T),T={load:async(a,s)=>await S((async()=>{try{t.setContent(await e())}catch{t.setContent([a,s])}})),startAutoLoad:async(a={},n={})=>(T.stopAutoLoad(),await T.load(a,n),A=1,v=s((async(a,s)=>{if(s){const e=s();await S((async()=>t.setTransactionChanges(e)))}else await S((async()=>{try{t.setContent(a?.()??await e())}catch(t){r?.(t)}}))})),T),stopAutoLoad:()=>(A&&(o(v),v=void 0,A=0),T),save:async e=>(1!=g&&(g=2,await T.schedule((async()=>{try{await a(t.getContent,e)}catch(t){r?.(t)}g=0}))),T),startAutoSave:async()=>(await T.stopAutoSave().save(),y=t.addDidFinishTransactionListener(((t,e)=>{const[a,s]=e();i(a)&&i(s)||T.save((()=>[a,s]))})),T),stopAutoSave:()=>{var e,a;return e=y,a=t.delListener,n(e)||a(e),T},schedule:async(...t)=>(((t,...e)=>{t.push(...e)})(u(p,d),...t),await(async()=>{if(!u(l,d)){for(f(l,d,1);!n((t=u(p,d),w=t.shift()));)try{await w()}catch(t){r?.(t)}f(l,d,0)}var t})(),T),getStore:()=>t,destroy:()=>T.stopAutoLoad().stopAutoSave(),getStats:()=>({})};return c(T)})(t,(async()=>{const t=await fetch(r);return A=w(t),d(await t.text())}),(async t=>{return await fetch(y,{method:"POST",headers:{"Content-Type":"application/json"},body:(e=t(),JSON.stringify(e,((t,e)=>s(e,Map)?o.fromEntries([...e]):e)))});var e}),(t=>e((async()=>{const e=await fetch(r,{method:"HEAD"}),a=w(e);n(A)||n(a)||a==A||(A=a,t())}),1e3*v)),(t=>a(t)),g)}},"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).TinyBasePersisterRemote={});
1
+ var t,e;t=this,e=function(t){"use strict";const e=setInterval,a=clearInterval,s=(t,e)=>t instanceof e,n=t=>null==t,o=Object,r=o.keys,c=o.freeze,i=t=>(t=>s(t,o)&&t.constructor==o)(t)&&0==(t=>r(t).length)(t),d=JSON.parse,y=t=>new Map(t),u=(t,e)=>t?.get(e),f=(t,e,a)=>{return n(a)?(s=t,o=e,s?.delete(o),t):t?.set(e,a);var s,o},h=(t,e,a)=>{var s,n;return s=t,n=e,s?.has(n)||f(t,e,a()),u(t,e)},l=y(),p=y(),w=t=>t.headers.get("ETag");t.createRemotePersister=(t,r,y,v=5,g)=>{let A;return((t,e,a,s,o,r,d=[])=>{let y,w,v,g=0,A=0;h(l,d,(()=>0)),h(p,d,(()=>[]));const S=async t=>(2!=g&&(g=1,await T.schedule((async()=>{await t(),g=0}))),T),T={load:async(a,s)=>await S((async()=>{try{t.setContent(await e())}catch{t.setContent([a,s])}})),startAutoLoad:async(a={},n={})=>(T.stopAutoLoad(),await T.load(a,n),A=1,v=s((async(a,s)=>{if(s){const e=s();await S((async()=>t.setTransactionChanges(e)))}else await S((async()=>{try{t.setContent(a?.()??await e())}catch(t){r?.(t)}}))})),T),stopAutoLoad:()=>(A&&(o(v),v=void 0,A=0),T),save:async e=>(1!=g&&(g=2,await T.schedule((async()=>{try{await a(t.getContent,e)}catch(t){r?.(t)}g=0}))),T),startAutoSave:async()=>(await T.stopAutoSave().save(),y=t.addDidFinishTransactionListener(((t,e)=>{const[a,s]=e();i(a)&&i(s)||T.save((()=>[a,s]))})),T),stopAutoSave:()=>{var e,a;return e=y,a=t.delListener,n(e)||a(e),T},schedule:async(...t)=>(((t,...e)=>{t.push(...e)})(u(p,d),...t),await(async()=>{if(!u(l,d)){for(f(l,d,1);!n((t=u(p,d),w=t.shift()));)try{await w()}catch(t){r?.(t)}f(l,d,0)}var t})(),T),getStore:()=>t,destroy:()=>T.stopAutoLoad().stopAutoSave(),getStats:()=>({})};return c(T)})(t,(async()=>{const t=await fetch(r);return A=w(t),d(await t.text())}),(async t=>{return await fetch(y,{method:"POST",headers:{"Content-Type":"application/json"},body:(e=t(),JSON.stringify(e,((t,e)=>s(e,Map)?o.fromEntries([...e]):e)))});var e}),(t=>e((async()=>{const e=await fetch(r,{method:"HEAD"}),a=w(e);n(A)||n(a)||a==A||(A=a,t())}),1e3*v)),(t=>a(t)),g)}},"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).TinyBasePersisterRemote={});
@@ -1 +1 @@
1
- var t,e;t=this,e=function(t,e){"use strict";const s=t=>t.length,a=t=>t.shift(),n=t=>null==t,o=(t,e,s)=>n(t)?s?.():e(t),c=Object,r=c.keys,i=c.freeze,d=(t=[])=>c.fromEntries(t),l=(t,e)=>!n(((t,e)=>o(t,(t=>t[e])))(t,e)),u=(t,e)=>((t,e)=>t.map(e))(c.entries(t),(([t,s])=>e(s,t))),y=t=>(t=>t instanceof c&&t.constructor==c)(t)&&0==(t=>s(r(t)))(t),g=(t,e,s)=>(l(t,e)||(t[e]=s()),t[e]),f=t=>new Map(t),p=(t,e)=>t?.get(e),h=(t,e)=>((t,e)=>t?.forEach(e))(t,((t,s)=>e(s,t))),v=(t,e,s)=>{return n(s)?(a=t,o=e,a?.delete(o),t):t?.set(e,s);var a,o},w=(t,e,s)=>{var a,n;return a=t,n=e,a?.has(n)||v(t,e,s()),p(t,e)},S=f(),A=f(),b="t",j="delete",O=t=>[t.get(b),t.get("v")],J=(t,s,a,o)=>{const c=n(s)?t:t.get(s)??t.set(s,new e.Map);let r;return u(a,((t,e)=>{o(c,e,t)&&(r=1)})),c.forEach(((t,e)=>{l(a,e)||(c.delete(e),r=1)})),n(s)||c.size||t.delete(s),r};t.createYjsPersister=(t,c,r="tinybase",l)=>{const f=c.getMap(r);return((t,e,s,c,r,d,l=[])=>{let u,g,f,h=0,b=0;w(S,l,(()=>0)),w(A,l,(()=>[]));const j=async t=>(2!=h&&(h=1,await O.schedule((async()=>{await t(),h=0}))),O),O={load:async(s,a)=>await j((async()=>{try{t.setContent(await e())}catch{t.setContent([s,a])}})),startAutoLoad:async(s={},a={})=>(O.stopAutoLoad(),await O.load(s,a),b=1,f=c((async(s,a)=>{if(a){const e=a();await j((async()=>t.setTransactionChanges(e)))}else await j((async()=>{try{t.setContent(s?.()??await e())}catch(t){d?.(t)}}))})),O),stopAutoLoad:()=>(b&&(r(f),f=void 0,b=0),O),save:async e=>(1!=h&&(h=2,await O.schedule((async()=>{try{await s(t.getContent,e)}catch(t){d?.(t)}h=0}))),O),startAutoSave:async()=>(await O.stopAutoSave().save(),u=t.addDidFinishTransactionListener(((t,e)=>{const[s,a]=e();y(s)&&y(a)||O.save((()=>[s,a]))})),O),stopAutoSave:()=>(o(u,t.delListener),O),schedule:async(...t)=>(((t,...e)=>{t.push(...e)})(p(A,l),...t),await(async()=>{if(!p(S,l)){for(v(S,l,1);!n(g=a(p(A,l)));)try{await g()}catch(t){d?.(t)}v(S,l,0)}})(),O),getStore:()=>t,destroy:()=>O.stopAutoLoad().stopAutoSave(),getStats:()=>({})};return i(O)})(t,(async()=>f.size?[f.get(b).toJSON(),f.get("v").toJSON()]:void 0),(async(t,s)=>c.transact((()=>((t,s,a)=>{(t=>{t.size||(t.set(b,new e.Map),t.set("v",new e.Map))})(t);const[c,r]=O(t),i=()=>{d=1};let d=1;if(o(a?.(),(([t,e])=>{d=0,u(t,((t,e)=>d?0:n(t)?c.delete(e):o(c.get(e),(e=>u(t,((t,s)=>d?0:n(t)?e.delete(s):o(e.get(s),(e=>u(t,((t,s)=>n(t)?e.delete(s):e.set(s,t)))),i)))),i))),u(e,((t,e)=>d?0:n(t)?r.delete(e):r.set(e,t)))})),d){const[t,e]=s();J(c,void 0,t,((t,e,s)=>J(c,e,s,((t,e,s)=>J(t,e,s,((t,e,s)=>{if(t.get(e)!==s)return t.set(e,s),1})))))),J(r,void 0,e,((t,e,s)=>{r.get(e)!==s&&r.set(e,s)}))}})(f,t,s)))),(t=>{const e=e=>t(void 0,(()=>((t,e)=>{if(1==s(e)&&(n=e[0].path,0==s(n)))return[t.get("t").toJSON(),t.get("v").toJSON()];var n;const[c,r]=O(t),i={},l={};return((t,e)=>{t.forEach((({path:t,changes:{keys:e}})=>a(t)==b?o(a(t),(s=>{const n=g(i,s,d),r=c.get(s);o(a(t),(t=>{const s=g(n,t,d),a=r.get(t);h(e,((t,{action:e})=>s[t]=e==j?null:a.get(t)))}),(()=>h(e,((t,{action:e})=>n[t]=e==j?null:r.get(t)?.toJSON()))))}),(()=>h(e,((t,{action:e})=>i[t]=e==j?null:c.get(t)?.toJSON())))):h(e,((t,{action:e})=>l[t]=e==j?null:r.get(t)))))})(e),[i,l]})(f,e)));return f.observeDeep(e),e}),(t=>{f.unobserveDeep(t)}),l)}},"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("yjs")):"function"==typeof define&&define.amd?define(["exports","yjs"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).TinyBasePersisterYjs={},t.yjs);
1
+ var t,e;t=this,e=function(t,e){"use strict";const s="t",a="v",n=t=>t.length,o=t=>t.shift(),c=t=>null==t,r=(t,e,s)=>c(t)?s?.():e(t),i=Object,d=i.keys,l=i.freeze,u=(t=[])=>i.fromEntries(t),y=(t,e)=>!c(((t,e)=>r(t,(t=>t[e])))(t,e)),g=(t,e)=>((t,e)=>t.map(e))(i.entries(t),(([t,s])=>e(s,t))),f=t=>(t=>t instanceof i&&t.constructor==i)(t)&&0==(t=>n(d(t)))(t),p=(t,e,s)=>(y(t,e)||(t[e]=s()),t[e]),h=t=>new Map(t),v=(t,e)=>t?.get(e),w=(t,e)=>((t,e)=>t?.forEach(e))(t,((t,s)=>e(s,t))),S=(t,e,s)=>{return c(s)?(a=t,n=e,a?.delete(n),t):t?.set(e,s);var a,n},A=(t,e,s)=>{var a,n;return a=t,n=e,a?.has(n)||S(t,e,s()),v(t,e)},b=h(),j=h(),O="delete",J=t=>[t.get(s),t.get(a)],L=(t,s,a,n)=>{const o=c(s)?t:t.get(s)??t.set(s,new e.Map);let r;return g(a,((t,e)=>{n(o,e,t)&&(r=1)})),o.forEach(((t,e)=>{y(a,e)||(o.delete(e),r=1)})),c(s)||o.size||t.delete(s),r};t.createYjsPersister=(t,i,d="tinybase",y)=>{const h=i.getMap(d);return((t,e,s,a,n,i,d=[])=>{let u,y,g,p=0,h=0;A(b,d,(()=>0)),A(j,d,(()=>[]));const w=async t=>(2!=p&&(p=1,await O.schedule((async()=>{await t(),p=0}))),O),O={load:async(s,a)=>await w((async()=>{try{t.setContent(await e())}catch{t.setContent([s,a])}})),startAutoLoad:async(s={},n={})=>(O.stopAutoLoad(),await O.load(s,n),h=1,g=a((async(s,a)=>{if(a){const e=a();await w((async()=>t.setTransactionChanges(e)))}else await w((async()=>{try{t.setContent(s?.()??await e())}catch(t){i?.(t)}}))})),O),stopAutoLoad:()=>(h&&(n(g),g=void 0,h=0),O),save:async e=>(1!=p&&(p=2,await O.schedule((async()=>{try{await s(t.getContent,e)}catch(t){i?.(t)}p=0}))),O),startAutoSave:async()=>(await O.stopAutoSave().save(),u=t.addDidFinishTransactionListener(((t,e)=>{const[s,a]=e();f(s)&&f(a)||O.save((()=>[s,a]))})),O),stopAutoSave:()=>(r(u,t.delListener),O),schedule:async(...t)=>(((t,...e)=>{t.push(...e)})(v(j,d),...t),await(async()=>{if(!v(b,d)){for(S(b,d,1);!c(y=o(v(j,d)));)try{await y()}catch(t){i?.(t)}S(b,d,0)}})(),O),getStore:()=>t,destroy:()=>O.stopAutoLoad().stopAutoSave(),getStats:()=>({})};return l(O)})(t,(async()=>h.size?[h.get(s).toJSON(),h.get(a).toJSON()]:void 0),(async(t,n)=>i.transact((()=>((t,n,o)=>{t.size||(t.set(s,new e.Map),t.set(a,new e.Map));const[i,d]=J(t),l=()=>{u=1};let u=1;if(r(o?.(),(([t,e])=>{u=0,g(t,((t,e)=>u?0:c(t)?i.delete(e):r(i.get(e),(e=>g(t,((t,s)=>u?0:c(t)?e.delete(s):r(e.get(s),(e=>g(t,((t,s)=>c(t)?e.delete(s):e.set(s,t)))),l)))),l))),g(e,((t,e)=>u?0:c(t)?d.delete(e):d.set(e,t)))})),u){const[t,e]=n();L(i,void 0,t,((t,e,s)=>L(i,e,s,((t,e,s)=>L(t,e,s,((t,e,s)=>{if(t.get(e)!==s)return t.set(e,s),1})))))),L(d,void 0,e,((t,e,s)=>{d.get(e)!==s&&d.set(e,s)}))}})(h,t,n)))),(t=>{const e=e=>t(void 0,(()=>((t,e)=>{if(1==n(e)&&(c=e[0].path,0==n(c)))return[t.get(s).toJSON(),t.get(a).toJSON()];var c;const[i,d]=J(t),l={},y={};return((t,e)=>{t.forEach((({path:t,changes:{keys:e}})=>o(t)==s?r(o(t),(s=>{const a=p(l,s,u),n=i.get(s);r(o(t),(t=>{const s=p(a,t,u),o=n.get(t);w(e,((t,{action:e})=>s[t]=e==O?null:o.get(t)))}),(()=>w(e,((t,{action:e})=>a[t]=e==O?null:n.get(t)?.toJSON()))))}),(()=>w(e,((t,{action:e})=>l[t]=e==O?null:i.get(t)?.toJSON())))):w(e,((t,{action:e})=>y[t]=e==O?null:d.get(t)))))})(e),[l,y]})(h,e)));return h.observeDeep(e),e}),(t=>{h.unobserveDeep(t)}),y)}},"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("yjs")):"function"==typeof define&&define.amd?define(["exports","yjs"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).TinyBasePersisterYjs={},t.yjs);
package/lib/umd/tools.js CHANGED
@@ -1 +1 @@
1
- var e,t;e=this,t=function(e){"use strict";const t=e=>typeof e,l="tinybase",a="",n=",",o=t(a),d=t(!0),s=t(0),r="type",I="default",c="Listener",$="get",u="add",i="Ids",p="Table",b=p+"s",C=p+i,h="Row",m=h+i,g="Sorted"+h+i,f="Cell",w=f+i,y="Value",T=y+"s",v=y+i,V=isFinite,x=(e,t)=>e instanceof t,R=e=>null==e,k=e=>e==o||e==d,S=e=>t(e)==o,A=e=>Array.isArray(e),P=e=>{const l=t(e);return k(l)||l==s&&V(e)?l:void 0},E=(e,t)=>e.every(t),D=(e,t)=>e.sort(t),O=(e,t)=>e.forEach(t),N=(e,t=a)=>e.join(t),G=(e,t)=>e.map(t),L=e=>e.length,j=(e,t)=>e.filter(t),M=(e,...t)=>e.push(...t),J=e=>e.pop(),z=(e,...t)=>e.unshift(...t),W=e=>e.shift(),B=Object,F=B.keys,U=B.freeze,_=e=>x(e,B)&&e.constructor==B,Z=(e,t)=>G(B.entries(e),(([e,l])=>t(l,e))),H=e=>L(F(e)),Q=e=>_(e)&&0==H(e),q=(e,t)=>e?.has(t)??!1,K=e=>[...e?.values()??[]],X=(e,t)=>e?.forEach(t),Y=(e,t)=>e?.delete(t),ee=e=>new Map(e),te=(e,t)=>e?.get(t),le=(e,t)=>X(e,((e,l)=>t(l,e))),ae=(e,t)=>G([...e?.entries()??[]],(([e,l])=>t(l,e))),ne=(e,t,l)=>R(l)?(Y(e,t),e):e?.set(t,l),oe=(e,t,l)=>(q(e,t)||ne(e,t,l()),te(e,t)),de=e=>e.toUpperCase(),se=e=>e.toLowerCase(),re="a ",Ie="A function for",ce=", and registers a listener so that any changes to that result will cause a re-render",$e="Callback",ue="Del",ie="Deps",pe=ie+"?: React.DependencyList",be="doRollback?: DoRollback",Ce="actions: () => Return, "+be,he="export",me="Id",ge="Invalid",fe="Json",we=se(c),ye="?: ",Te=" | undefined",ve="NonNullable",Ve="Partial",xe="Props",Re="Provider",ke=`Registers a ${we} that will be called`,Se="Represents",Ae="rowId: "+me,Pe="Schema",Ee="Set",De=", descending?: boolean, offset?: number, limit?: number",Oe="[]",Ne="the Store",Ge="Transaction",Le=Ge+"Changes",je=se(Ge),Me="Execute a "+je+" to make multiple mutations",Je="Explicitly starts a "+je,ze="Explicitly finishes a "+je,We="the end of the "+je,Be="void",Fe=" => "+Be,Ue="WhenSet",_e=" when setting it",Ze=re+"string serialization of",He=" ",Qe="Gets a callback that can ",qe="the ",Ke=" the schema for",Xe=(e=0,t=0)=>`the ${Ct[e]}content of`+(t?He+Ne:a),Ye=(e=0,t,l=0)=>it[t]+He+Xe(e,1)+(l?" when setting it":a),et=(e,t=0)=>Se+` a Row when ${t?"s":"g"}etting ${Xe()} the '${e}' `+p,tt=(e,t,l=0)=>`Gets ${l?"sorted, paginated":"the"} Ids of the ${e}s in `+t,lt=(e,t)=>`Calls a function for each ${e} in `+t,at=e=>"The props passed to a component that renders "+e,nt=e=>"A function that takes "+e,ot=(e,t=0)=>Ie+" listening to changes to "+bt[e]+" in "+bt[t],dt=(e,t,l=0)=>ke+" whenever "+bt[e]+" in "+bt[t]+" change"+(l?a:"s"),st=e=>`the '${e}' `+p,rt=e=>"the specified Row in "+st(e),It=(e,t=0)=>it[t]+` ${Xe()} `+st(e),ct=(e,t=0)=>it[t]+` ${Xe()} `+rt(e),$t=(e,t,l=0)=>it[l]+` the '${t}' Cell for `+rt(e),ut=(e,t=0)=>it[t]+` the '${e}' Value`,it=["Gets","Checks existence of","Sets","Deletes","Sets part of",Se,"Gets "+Ze,"Sets "+Ze,ke+" whenever",Qe+"set",Qe+"add",Qe+"set part of",Qe+"delete","Renders","Gets "+Ze+Ke,"Sets"+Ke,"Deletes"+Ke],pt=[$,"has","set","del","set","forEach",u,a],bt=[Ne,b,qe+p+He+i,re+p,qe+h+He+i,re+h,qe+f+He+i,re+f,"invalid Cell changes",T,qe+y+He+i,re+y,"invalid Value changes",qe+"sorted "+h+He+i,qe+f+He+i+" anywhere",qe+"number of Rows"],Ct=[a,"tabular ","keyed value "],ht=e=>new Set(A(e)||R(e)?e:[e]),mt=(e,t)=>e?.add(t),gt=/[^A-Za-z]+/,ft=/[^A-Za-z0-9]+/,wt=/^( *)\/\*\* *(.*?) *\*\/$/gm,yt=(e,t,l)=>e.substring(t,l),Tt=e=>e.includes(n),vt=(e,t,l,a=1)=>{const n=`${t}${1==a?"":a}`;return q(e,n)?vt(e,t,l,a+1):(ne(e,n,l),n)},Vt=e=>e.replace(wt,((e,t,l)=>{const a=77-xt(t);return`${t}/**\n${l.replace(RegExp(`([^\\n]{1,${a}})(\\s|$)`,"g"),t+" * $1\n")}${t} */`})),xt=e=>e.length,Rt=e=>e.flat(1e3),kt=(e,t=0)=>N(G(e.split(ft),((e,l)=>(l>0||t?de:se)(yt(e,0,1))+yt(e,1)))),St=e=>de(N((e&&!gt.test(e[0])?e:" "+e).split(ft),"_")),At=e=>`/** ${e}. */`,Pt=(...e)=>N(j(e,(e=>e)),", "),Et=(...e)=>"{"+N(e,"; ")+"}",Dt=(...e)=>Et(...G(e,(e=>"readonly "+e))),Ot=()=>{const e=[ee(),ee(),ee(),ee()],t=ee(),l=ee(),n=e=>{const t=e.indexOf(" as ");return-1!=t?e.substring(t+4):e};return[(...e)=>N(Rt(e),"\n"),(t,l,...a)=>O(a,(a=>O([0,1],(n=>(t??n)==n?mt(oe(e[n],l,ht),a):0)))),(e,l,n,o=a,d=1)=>vt(t,e,[l,n,o,d]),(e,t,a)=>vt(l,e,A(a)?[`(${t}) => {`,a,"}"]:[`(${t}) => ${a}`]),(e,t)=>te(l,e)===t?e:vt(l,e,t),(t=0)=>G([...D(ae(e[t],((e,t)=>`import {${N(D(K(e),((e,t)=>n(e)>n(t)?1:-1)),", ")}} from '${t}';`)),((e,t)=>Tt(e)!=Tt(t)?Tt(e)?-1:1:e>t?1:-1)),a],(e=>e.replace("{React}","React"))),()=>ae(t,(([e,t,l,n],o)=>[At(t),`${n?he+" ":a}type ${o}${l} = ${e};`,a])),()=>ae(l,((e,t)=>(e=A(e)?e:[e],M(e,J(e)+";"),[`const ${t} = ${W(e)}`,e,a])))]},Nt=e=>{const t=new WeakMap;return l=>(t.has(l)||t.set(l,e(l)),t.get(l))},Gt=(e,t,l)=>[t=>Z(e,((e,a)=>t(a,kt(a,1),l(St(a),`'${a}'`)))),(t,a)=>Z(e[t],((e,t)=>a(t,e[r],e[I],l(St(t),`'${t}'`),kt(t,1)))),e=>Z(t,((t,a)=>e(a,t[r],t[I],l(St(a),`'${a}'`),kt(a,1))))],Lt=(e,t,l,n)=>[(n,o)=>{const d=n+": "+o,s=e(b,Et(...t((e=>`'${e}'?: {[rowId: Id]: `+Et(...l(e,((e,t,l)=>`'${e}'${R(l)?"?":a}: ${t}`)))+"}"))),Ye(1,5)),r=e(b+Ue,Et(...t((e=>`'${e}'?: {[rowId: Id]: `+Et(...l(e,((e,t)=>`'${e}'?: ${t}`)))+"}"))),Ye(1,5,1)),I=e(p+me,"keyof "+s,"A "+p+" Id in "+Ne),$=`<TId extends ${I}>`,u=e(p,ve+`<${s}[TId]>`,"A "+p+" in "+Ne,$),i=e(p+Ue,ve+`<${r}[TId]>`,"A "+p+" in "+Ne+_e,$),y=e(h,u+"<TId>[Id]","A "+h+" in a "+p,$),T=e(h+Ue,i+"<TId>[Id]","A "+h+" in a "+p+_e,$),v=e(f+me,`Extract<keyof ${y}<TId>, Id>`,"A "+f+" Id in a "+h,$),V=e(f,ve+`<${s}[TId]>[Id][CId]`,"A "+f+" in a "+h,`<TId extends ${I}, CId extends ${v}<TId>>`),x=e("CellIdCellArray",`CId extends ${v}<TId> ? [cellId: CId, cell: ${V}<TId, CId>] : never`,f+" Ids and types in a "+h,`<TId extends ${I}, CId = ${v}<TId>>`,0),k=e(f+$e,`(...[cellId, cell]: ${x}<TId>)`+Fe,nt(re+f+" Id, and "+f),$),S=e(h+$e,"(rowId: Id, forEachCell: (cellCallback: CellCallback<TId>) "+Fe+") "+Fe,nt(re+h+" Id, and a "+f+" iterator"),$),A=e(p+f+$e,`(cellId: ${v}<TId>, count: number) `+Fe,nt(re+f+" Id, and count of how many times it appears"),$),P=e("TableIdForEachRowArray",`TId extends ${I} ? [tableId: TId, forEachRow: (rowCallback: ${S}<TId>)${Fe}] : never`,p+" Ids and callback types",`<TId = ${I}>`,0),E=e(p+$e,`(...[tableId, forEachRow]: ${P})`+Fe,nt(re+p+" Id, and a "+h+" iterator"),a),D=e("TableIdRowIdCellIdArray",`TId extends ${I} ? [tableId: TId, rowId: Id, cellId: ${v}<TId>] : never`,"Ids for GetCellChange",`<TId = ${I}>`,0),O=e("GetCellChange",`(...[tableId, rowId, cellId]: ${D}) => CellChange`,Ie+" returning information about any Cell's changes during a "+je),N=e(b+c,`(${d}, getCellChange: ${O}${Te})`+Fe,ot(1)),G=e(C+c,`(${d})`+Fe,ot(2)),L=e(p+c,`(${d}, tableId: ${I}, getCellChange: ${O}${Te})`+Fe,ot(3)),j=e(p+w+c,`(${d}, tableId: ${I})`+Fe,ot(14,3)),M=e(h+"Count"+c,`(${d}, tableId: ${I})`+Fe,ot(15,3)),J=e(m+c,`(${d}, tableId: ${I})`+Fe,ot(4,3)),z=e(g+c,"("+Pt(d,"tableId: "+I,"cellId: Id"+Te,"descending: boolean","offset: number","limit: number"+Te,"sortedRowIds: Ids")+")"+Fe,ot(13,3)),W=e(h+c,"("+Pt(""+d,"tableId: "+I,Ae,`getCellChange: ${O}${Te}`)+")"+Fe,ot(5,3)),B=e(w+c,"("+Pt(""+d,"tableId: "+I,Ae)+")"+Fe,ot(6,5)),F=e("CellListenerArgsArrayInner",`CId extends ${v}<TId> ? [${d}, tableId: TId, ${Ae}, cellId: CId, newCell: ${V}<TId, CId> ${Te}, oldCell: ${V}<TId, CId> ${Te}, getCellChange: ${O} ${Te}] : never`,"Cell args for CellListener",`<TId extends ${I}, CId = ${v}<TId>>`,0),U=e("CellListenerArgsArrayOuter",`TId extends ${I} ? `+F+"<TId> : never","Table args for CellListener",`<TId = ${I}>`,0);return[s,r,I,u,i,y,T,v,V,k,S,A,E,N,G,L,j,M,J,z,W,B,e(f+c,`(...[${n}, tableId, rowId, cellId, newCell, oldCell, getCellChange]: ${U})`+Fe,ot(7,5)),e(ge+f+c,`(${d}, tableId: Id, ${Ae}, cellId: Id, invalidCells: any[])`+Fe,ot(8))]},(t,l)=>{const o=t+": "+l,d=e(T,Et(...n(((e,t,l)=>`'${e}'${R(l)?"?":a}: ${t}`))),Ye(2,5)),s=e(T+Ue,Et(...n(((e,t)=>`'${e}'?: ${t}`))),Ye(2,5,1)),r=e(y+me,"keyof "+d,"A "+y+" Id in "+Ne),I=e(y,ve+`<${d}[VId]>`,"A "+y+" Id in "+Ne,`<VId extends ${r}>`),$=e("ValueIdValueArray",`VId extends ${r} ? [valueId: VId, value: ${I}<VId>] : never`,y+" Ids and types in "+Ne,`<VId = ${r}>`,0),u=e(y+$e,`(...[valueId, value]: ${$})`+Fe,nt(re+y+" Id, and "+y)),i=e("GetValueChange",`(valueId: ${r}) => ValueChange`,Ie+" returning information about any Value's changes during a "+je),p=e(T+c,`(${o}, getValueChange: ${i}${Te})`+Fe,ot(9)),b=e(v+c,`(${o})`+Fe,ot(10)),C=e("ValueListenerArgsArray",`VId extends ${r} ? [${o}, valueId: VId, newValue: ${I}<VId> ${Te}, oldValue: ${I}<VId> ${Te}, getValueChange: ${i} ${Te}] : never`,"Value args for ValueListener",`<VId = ${r}>`,0);return[d,s,r,I,u,p,b,e(y+c,`(...[${t}, valueId, newValue, oldValue, getValueChange]: `+C+")"+Fe,ot(11)),e(ge+y+c,`(${o}, valueId: Id, invalidValues: any[])`+Fe,ot(12))]},(t,l)=>e(Ge+c,`(${t}: ${l}, getTransactionChanges: GetTransactionChanges, getTransactionLog: GetTransactionLog)`+Fe,Ie+" listening to the completion of a "+je)],jt=(e,t=a,l=a)=>`store.${e}(${t})`+(l?" as "+l:a),Mt=(e,t=a)=>`fluent(() => ${jt(e,t)})`,Jt=(e,t=a,l=a)=>`store.${e}(${t?t+", ":a}proxy(listener)${l?", "+l:a})`,zt=(e,t,n)=>{const[o,s,$,V,x,k,A,P]=Ot(),[E,D,G]=Gt(e,t,x),[L,j,J]=Lt($,E,D,G),W=ee(),B=(e=0)=>ae(W,(([t,l,n,o,d],s)=>{const r=e?[s+`: ${d}(${t}): ${l} => ${n},`]:[s+d+`(${t}): ${l};`];return e||z(r,At(o)),M(r,a),r})),F=(e,t,l,n,o,d=a)=>vt(W,e,[t,l,n,o,d]),U=(e,t,l,n,o,d=a,s=a,r=a)=>F(pt[e]+t+(4==e?Ve:a)+l,d,n,(n==H?Mt:jt)(pt[e]+(4==e?Ve:a)+l,s,e?void 0:n),o,r),_=(e,t,l,n=a,o=a,d=1,s=a)=>F(u+e+c,(n?n+", ":a)+we+": "+t+(d?", mutator?: boolean":a),me,Jt(u+e+c,o,d?"mutator":a),l,s),Z=`./${kt(n)}.d`,H=kt(n,1),q=kt(H),X=[],Y=ee();let oe=[],de=[];if(s(1,Z,H,`create${H} as create${H}Decl`),Q(e))s(null,l,b);else{s(0,l,"CellChange"),s(null,l,i);const[e,t,n,o,c,u,y,T,v,V,k,A,P,G,j,J,z,W,B,F,Q,le,ae,de]=L(q,H),se=ee();E(((e,t)=>{const l=`<'${e}'>`,a=[$(t+p,o+l,Se+` the '${e}' `+p),$(t+p+Ue,c+l,Se+` the '${e}' `+p+_e),$(t+h,u+l,et(e)),$(t+h+Ue,y+l,et(e,1)),$(t+f+me,T+l,`A Cell Id for the '${e}' `+p),$(t+f+$e,V+l,nt(`a Cell Id and value from a Row in the '${e}' `+p)),$(t+h+$e,k+l,nt(`a Row Id from the '${e}' Table, and a Cell iterator`)),$(t+p+f+$e,A+l,nt(`a Cell Id from anywhere in the '${e}' Table, and a count of how many times it appears`))];ne(se,e,a),s(1,Z,...a)})),s(1,Z,e,t,n,T,P,G,j,J,z,W,B,F,Q,le,ae,de),oe=[e,t,n,T,G,j,J,z,W,B,F,Q,le,ae,se],O([[e],[d],[H,"tables: "+t,"tables"],[H]],(([e,t,l],n)=>U(n,a,b,e,Ye(1,n),t,l))),U(0,a,C,n+Oe,tt(p,Ne)),U(5,a,p,Be,lt(p,Ne),"tableCallback: "+P,"tableCallback as any"),E(((e,t,l)=>{const[n,o,s,r,I,c,$,u]=te(se,e);O([[n],[d],[H,"table: "+o,", table"],[H]],(([n,o,d=a],s)=>U(s,t,p,n,It(e,s),o,l+d))),U(0,t,p+w,i,tt(f,"the whole of "+st(e)),a,l),U(5,t,p+f,Be,lt(p+f,"the whole of "+st(e)),"tableCellCallback: "+u,l+", tableCellCallback as any"),U(0,t,h+"Count","number","Gets the number of Rows in the "+st(e),a,l),U(0,t,m,i,tt(h,st(e)),a,l),U(0,t,g,i,tt(h,st(e),1),"cellId?: "+I+De,l+", cellId, descending, offset, limit"),U(5,t,h,Be,lt(h,st(e)),"rowCallback: "+$,l+", rowCallback as any"),O([[s],[d],[H,", row: "+r,", row"],[H],[H,", partialRow: "+r,", partialRow"]],(([n,o=a,d=a],s)=>U(s,t,h,n,ct(e,s),Ae+o,l+", rowId"+d))),U(6,t,h,me+Te,"Add a new Row to "+st(e),"row: "+r+", reuseIds?: boolean",l+", row, reuseIds"),U(0,t,w,I+Oe,tt(f,rt(e)),Ae,l+", rowId"),U(5,t,f,Be,lt(f,rt(e)),Ae+", cellCallback: "+c,l+", rowId, cellCallback as any"),D(e,((n,o,s,r,I)=>{const c="Map"+kt(o,1);ne(Y,o,c);const $=o+(R(s)?Te:a);O([[$],[d],[H,`, cell: ${o} | `+c,", cell as any"],[H]],(([o,d=a,s=a],c)=>U(c,t+I,f,o,$t(e,n,c),Ae+d,l+", rowId, "+r+s))),U(1,t+I,p+f,d,it[1]+` the '${n}' Cell anywhere in `+st(e),a,l+", "+r)}))})),U(0,a,b+fe,fe,Ye(1,6)),U(2,a,b+fe,H,Ye(1,7),"tablesJson: "+fe,"tables"+fe),_(b,G,Ye(1,8)+" changes"),_(C,j,dt(2,0,1)),_(p,J,dt(3,0),`tableId: ${n} | null`,"tableId"),_(p+w,z,dt(14,3,1),`tableId: ${n} | null`,"tableId"),_(h+"Count",W,dt(15,3),`tableId: ${n} | null`,"tableId"),_(m,B,dt(4,3,1),`tableId: ${n} | null`,"tableId"),_(g,F,dt(13,3,1),Pt("tableId: TId",`cellId: ${T}<TId>`+Te,"descending: boolean","offset: number","limit: number"+Te),Pt("tableId","cellId","descending","offset","limit"),1,"<TId extends TableId>"),_(h,Q,dt(5,3),`tableId: ${n} | null, rowId: IdOrNull`,"tableId, rowId"),_(w,le,dt(6,5,1),`tableId: ${n} | null, rowId: IdOrNull`,"tableId, rowId"),_(f,ae,dt(7,5),`tableId: ${n} | null, rowId: IdOrNull, cellId: ${N(E((e=>te(se,e)?.[4]??a))," | ")} | null`,"tableId, rowId, cellId"),_(ge+f,de,ke+" whenever an invalid Cell change was attempted","tableId: IdOrNull, rowId: IdOrNull, cellId: IdOrNull","tableId, rowId, cellId"),s(1,Z,...K(Y)),M(X,".set"+b+Pe+"({",Rt(E(((e,t,l)=>[`[${l}]: {`,...D(e,((e,t,l,n)=>`[${n}]: {[${x(St(r),`'${r}'`)}]: ${x(St(t),`'${t}'`)}${R(l)?a:`, [${x(St(I),`'${I}'`)}]: `+(S(l)?x(St(l),`'${l}'`):l)}},`)),"},"]))),"})")}if(Q(t))s(null,l,T);else{const[e,t,n,o,c,$,u,i,p]=j(q,H);s(1,Z,e,t,n,c,$,u,i,p),de=[e,t,n,$,u,i],O([[e],[d],[H,"values: "+t,"values"],[H],[H,"partialValues: "+t,"partialValues"]],(([e,t,l],n)=>U(n,a,T,e,Ye(2,n),t,l))),U(0,a,v,n+Oe,tt(y,Ne)),U(5,a,y,"void",lt(y,Ne),"valueCallback: "+c,"valueCallback as any"),G(((e,t,l,n,o)=>{const s="Map"+kt(t,1);ne(Y,t,s),O([[t],[d],[H,`value: ${t} | `+s,", value as any"],[H]],(([t,l,d=a],s)=>U(s,o,y,t,ut(e,s),l,n+d)))})),U(0,a,T+fe,fe,Ye(2,6)),U(2,a,T+fe,H,Ye(2,7),"valuesJson: "+fe,"values"+fe),_(T,$,Ye(2,8)+" changes"),_(v,u,dt(10,0,1)),_(y,i,dt(11,0),`valueId: ${n} | null`,"valueId"),_(ge+y,p,ke+" whenever an invalid Value change was attempted","valueId: IdOrNull","valueId"),s(1,Z,...K(Y)),s(0,l,"ValueChange"),M(X,".set"+T+Pe+"({",G(((e,t,l,n)=>[`[${n}]: {[${x(St(r),`'${r}'`)}]: ${x(St(t),`'${t}'`)}${R(l)?a:`, [${x(St(I),`'${I}'`)}]: `+(S(l)?x(St(l),`'${l}'`):l)}},`])),"})")}U(0,a,"Content",`[${b}, ${T}]`,Ye(0,0)),U(2,a,"Content",H,Ye(0,2),`[tables, values]: [${b}, ${T}]`,"[tables, values]"),U(2,a,Le,H,`Applies a set of ${Le} to the Store`,"transactionChanges: "+Le,"transactionChanges"),le(Y,((e,t)=>$(t,`(cell: ${e}${Te}) => `+e,`Takes a ${e} Cell value and returns another`))),s(null,l,"DoRollback",me,"IdOrNull",fe,"Store",Le),s(0,l,"Get"+Le,"GetTransactionLog"),U(0,a,fe,fe,Ye(0,6)),U(2,a,fe,H,Ye(0,7),"tablesAndValuesJson: "+fe,"tablesAndValuesJson"),U(7,a,je,"Return",Me,Ce,"actions, doRollback","<Return>"),U(7,a,"start"+Ge,H,Je),U(7,a,"finish"+Ge,H,ze,be,"doRollback");const se=J(q,H);return _("Start"+Ge,se,ke+" just before the start of the "+je,a,a,0),_("WillFinish"+Ge,se,ke+" just before "+We,a,a,0),_("DidFinish"+Ge,se,ke+" just after "+We,a,a,0),U(7,a,"call"+c,H,"Manually provoke a listener to be called","listenerId: Id","listenerId"),U(3,a,c,H,"Remove a listener that was previously added to "+Ne,"listenerId: Id","listenerId"),F("getStore",a,"Store","store",it[0]+" the underlying Store object"),s(1,l,"createStore"),s(1,Z,H,`create${H} as create${H}Decl`,se),x("store",["createStore()",...X]),V("fluent","actions: () => Store",["actions();",`return ${q};`]),V("proxy","listener: any",`(_: Store, ...params: any[]) => listener(${q}, ...params)`),x(q,["{",...B(1),"}"]),[o(...k(0),...A(),he+" interface "+H+" {",...B(0),"}",a,At(`Creates a ${H} object`),he+" function create"+H+"(): "+H+";"),o(...k(1),he+" const create"+H+": typeof create"+H+"Decl = () => {",...P(),`return Object.freeze(${q});`,"};"),oe,de]},Wt=e=>$+e,Bt=e=>Pt(Wt(e),Wt(e)+ie),Ft="debugIds?: boolean",Ut="debugIds={debugIds}",_t="then"+pe,Zt="Parameter",Ht=": (parameter: "+Zt+", store: Store) => ",Qt="const contextValue = useContext(Context);",qt=", based on a parameter",Kt=": ",Xt="<"+Zt+",>",Yt=Zt+"ized"+$e+"<"+Zt+">",el="rowId",tl="rowId={rowId}",ll=", separator, debugIds",al="separator?: ReactElement | string",nl="then?: (store: Store",ol=Pt(nl+")"+Fe,_t),dl="then, then"+ie,sl=el+Kt+me,rl="View",Il=(e,...t)=>Pt(...t,we+": "+e,we+pe,"mutator?: boolean"),cl=(...e)=>Pt(...e,we,we+ie,"mutator"),$l=(e,t,n,o,d)=>{const[s,r,I,$,u,V,x,k]=Ot(),[S,A,P]=Gt(e,t,u),E=`./${kt(n)}.d`,D=`./${kt(n)}-ui-react.d`,O="tinybase/ui-react",G=kt(n,1),L=kt(G),j=G+"Or"+G+me,J=L+"Or"+G+me,W=L+`={${L}}`,B=ee(),F=(e,t,l,n,o,d=a)=>(r(1,D,e+" as "+e+"Decl"),vt(B,e,[t,l,n,o,d])),U=(e,t,l,n,o,d=a)=>F("use"+e,t,l,n,o,d),_=(e,t,l,n,o=a,d=a,s=a,I=a,c=a)=>(r(1,O,`use${t} as use${t}Core`),U(e,Pt(o,X,I),l,le+`(${J}, use${t}Core, [`+(d||a)+(c?"], ["+c:a)+"]);",n,s)),Z=(e,t,l,a)=>F(e,t,1,l,a),H=(e=0)=>ae(B,(([t,l,n,o,d],s)=>{const r=e?[he+` const ${s}: typeof ${s}Decl = ${d}(${t}): ${1==l?"any":l} =>`,n]:[he+` function ${s}${d}(${t}): ${1==l?"ComponentReturnType":l};`];return e||z(r,At(o)),M(r,a),r}));r(null,l,me,"Store",$e,Zt+"ized"+$e),r(0,O,"ComponentReturnType"),r(1,O,"useCellIds"),r(null,O,"ExtraProps"),r(0,E,G);const q=I(j,G+" | "+me,`Used when you need to refer to a ${G} in a React hook or component`),K=I(Re+xe,Dt(L+ye+G,L+`ById?: {[${L}Id: Id]: ${G}}`),`Used with the ${Re} component, so that a `+G+" can be passed into the context of an application");r(0,"react","ReactElement","ComponentType"),r(1,"react","React"),r(1,D,q,K);const X=J+ye+q;u("{createContext, useContext, useMemo}","React"),u("Context",`createContext<[${G}?, {[${L}Id: Id]: ${G}}?]>([])`),U("Create"+G,`create: () => ${G}, create`+pe,G,"\n// eslint-disable-next-line react-hooks/exhaustive-deps\nuseMemo(create, createDeps)",`Create a ${G} within a React application with convenient memoization`);const Y=U(G,"id?: Id",G+Te,["{",Qt,"return id == null ? contextValue[0] : contextValue[1]?.[id];","}"],`Get a reference to a ${G} from within a ${Re} component context`),le=$("useHook",J+`: ${q} | undefined, hook: (...params: any[]) => any, preParams: any[], postParams: any[] = []`,[`const ${L} = ${Y}(${J} as Id);`,`return hook(...preParams, ((${J} == null || typeof ${J} == 'string')`,`? ${L} : ${J})?.getStore(), ...postParams)`]),ne=$("getProps","getProps: ((id: any) => ExtraProps) | undefined, id: Id","(getProps == null) ? ({} as ExtraProps) : getProps(id)"),oe=$("wrap",Pt("children: any","separator?: any","encloseWithId?: boolean","id?: Id"),["const separated = separator==null || !Array.isArray(children)"," ? children"," : children.map((child, c) => (c > 0 ? [separator, child] : child));","return encloseWithId ? [id, ':{', separated, '}'] : separated;"]),de=$("useCustomOrDefaultCellIds",Pt("customCellIds: Ids | undefined","tableId: Id","rowId: Id",`${J}?: ${q} | undefined`),[`const defaultCellIds = ${le}(${J}, useCellIds, [tableId, rowId]);`,"return customCellIds ?? defaultCellIds;"]),se=u("NullComponent","() => null");if(!Q(e)){const[e,t,n,d,s,u,y,T,v,V,x,k,P,O,j]=o;r(null,E,e,t,n,s,u,y,T,v,V,x,k,P,O),r(0,E,d),r(1,E,G),r(null,l,i,"IdOrNull");const M=$("tableView",`{${L}, rowComponent, getRowComponentProps, customCellIds`+ll+"}: any, rowIds: Ids, tableId: Id, defaultRowComponent: React.ComponentType<any>",["const Row = rowComponent ?? defaultRowComponent;",`return ${oe}(rowIds.map((rowId) => (`,"<Row","{..."+ne+"(getRowComponentProps, rowId)}","key={rowId}","tableId={tableId}",tl,"customCellIds={customCellIds}",W,Ut,"/>","))",ll,", tableId,",");"]),J=$("getDefaultTableComponent","tableId: Id",N(S(((e,t,l)=>`tableId == ${l} ? ${t}TableView : `)))+se),z=$("getDefaultCellComponent","tableId: Id, cellId: Id",N(S(((e,t,l)=>`tableId == ${l} ? ${N(A(e,((e,l,a,n,o)=>`cellId == ${n} ? `+t+o+"CellView : ")))+se} : `)))+se);_(b,b,e,Ye(1,0)+ce);const B=_(C,C,n+Oe,tt(p,Ne)+ce);_(Ee+b+$e,Ee+b+$e,Yt,Ye(1,9)+qt,Pt(Wt(b)+Ht+t,Wt(b)+pe),Bt(b),Xt,Pt(nl,`tables: ${t})`+Fe,_t),dl),_(ue+b+$e,ue+b+$e,$e,Ye(1,12),a,a,a,ol,dl);const F=I(f+xe,Dt("tableId?: TId","rowId: Id","cellId?: CId",L+ye+G,Ft),at(re+f),`<TId extends ${n}, CId extends ${d}<TId>>`),U=I(h+xe,Dt("tableId?: TId","rowId: Id",L+ye+G,"cellComponents?: {readonly [CId in "+d+`<TId>]?: ComponentType<${F}<TId, CId>>;}`,`getCellComponentProps?: (cellId: ${d}<TId>) => ExtraProps`,`customCellIds?: ${d}<TId>[]`,al,Ft),at(re+h),`<TId extends ${n}>`),H=I(p+xe,Dt("tableId?: TId",L+ye+G,`rowComponent?: ComponentType<${U}<TId>>`,"getRowComponentProps?: (rowId: Id) => ExtraProps","customCellIds?: CellId<TId>[]",al,Ft),at(re+p),`<TId extends ${n}>`),Q=I("Sorted"+p+xe,Dt("tableId?: TId","cellId?: "+d+"<TId>","descending?: boolean","offset?: number","limit?: number",L+ye+G,`rowComponent?: ComponentType<${U}<TId>>`,"getRowComponentProps?: (rowId: Id) => ExtraProps","customCellIds?: CellId<TId>[]",al,Ft),at(re+"sorted "+p),`<TId extends ${n}>`),q=I(b+xe,Dt(L+ye+G,"tableComponents?: {readonly [TId in "+n+`]?: ComponentType<${H}<TId>>;}`,`getTableComponentProps?: (tableId: ${n}) => ExtraProps`,al,Ft),at(Xe(1,1)));r(1,D,q,H,Q,U,F),Z(b+rl,"{"+L+", tableComponents, getTableComponentProps"+ll+"}: "+q,[oe+`(${B}(${L}).map((tableId) => {`,"const Table = (tableComponents?.[tableId] ?? "+J+"(tableId)) as React.ComponentType<TableProps<typeof tableId>>;","return <Table",`{...${ne}(getTableComponentProps, tableId)}`,"tableId={tableId}","key={tableId}",W,Ut,"/>;","}), separator)"],Ye(1,13)+ce),S(((e,t,l)=>{const[n,o,d,s,I]=te(j,e);r(null,E,n,o,d,s,I),_(t+p,p,n,It(e)+ce,a,l),_(t+p+w,p+w,i,tt(f,"the whole of "+st(e))+ce,a,l);const c=_(t+m,m,i,tt(h,st(e))+ce,a,l),$=_(t+g,g,i,tt(h,st(e),1)+ce,"cellId?: "+I+", descending?: boolean, offset?: number, limit?: number",l+", cellId, descending, offset, limit");_(t+h,h,d,ct(e)+ce,sl,Pt(l,el)),_(t+w,w,I+Oe,tt(f,rt(e))+ce,sl,Pt(l,el)),_(Ee+t+p+$e,Ee+p+$e,Yt,It(e,9)+qt,Pt(Wt(p)+Ht+o,Wt(p)+pe),Pt(l,Bt(p)),Xt,Pt(nl,`table: ${o})`+Fe,_t),dl),_(ue+t+p+$e,ue+p+$e,$e,It(e,12),a,l,a,ol,dl),_(Ee+t+h+$e,Ee+h+$e,Yt,ct(e,9)+qt,Pt(sl,Wt(h)+Ht+s,Wt(h)+pe),Pt(l,el,Bt(h)),Xt,Pt(nl,`row: ${s})`+Fe,_t),dl),_("Add"+t+h+$e,"Add"+h+$e,Yt,ct(e,10)+qt,Pt(Wt(h)+Ht+s,Wt(h)+pe),Pt(l,Bt(h)),Xt,"then?: ("+Pt(sl+Te,"store: Store","row: "+s+")"+Fe,"then"+pe)+", reuseRowIds?: boolean",dl+", reuseRowIds"),_(Ee+t+Ve+h+$e,Ee+Ve+h+$e,Yt,ct(e,11)+qt,Pt(sl,Wt(Ve+h)+Ht+s,Wt(Ve+h)+pe),Pt(l,el,Bt(Ve+h)),Xt,Pt(nl,`partialRow: ${s})`+Fe,_t),dl),_(ue+t+h+$e,ue+h+$e,$e,ct(e,12),sl,Pt(l,el),a,ol,dl);const u=Z(t+h+rl,"{rowId, "+L+", cellComponents, getCellComponentProps, customCellIds"+ll+`}: ${U}<'${e}'>`,[oe+`(${de}(customCellIds, `+l+`, rowId, ${L}).map((cellId: ${I}) => {`,"const Cell = (cellComponents?.[cellId] ?? "+z+`(${l}, cellId)) as React.ComponentType<CellProps<typeof `+l+", typeof cellId>>;","return <Cell",`{...${ne}(getCellComponentProps, cellId)} `,"key={cellId}",`tableId={${l}}`,tl,"cellId={cellId}",W,Ut,"/>;","})"+ll+", rowId)"],ct(e,13)+ce);Z(t+"Sorted"+p+rl,"{cellId, descending, offset, limit, ...props}: "+Q+`<'${e}'>`,M+"(props, "+$+`(cellId, descending, offset, limit, props.${L}), ${l}, ${u});`,It(e,13)+", sorted"+ce),Z(t+p+rl,`props: ${H}<'${e}'>`,M+"(props, "+c+`(props.${L}), ${l}, ${u});`,It(e,13)+ce),A(e,((n,o,d,s,I)=>{const c="Map"+kt(o,1);r(0,E,c),r(1,E,c);const $=_(t+I+f,f,o+(R(d)?Te:a),$t(e,n)+ce,sl,Pt(l,el,s));_(Ee+t+I+f+$e,Ee+f+$e,Yt,$t(e,n,9)+qt,Pt(sl,Wt(f)+Ht+o+" | "+c,Wt(f)+pe),Pt(l,el,s,Bt(f)),Xt,Pt(nl,`cell: ${o} | ${c})`+Fe,_t),dl),_(ue+t+I+f+$e,ue+f+$e,$e,$t(e,n,12),Pt(sl,"forceDel?: boolean"),Pt(l,el,s,"forceDel"),a,ol,dl),Z(t+I+f+rl,`{rowId, ${L}, debugIds}: `+F+`<'${e}', '${n}'>`,[oe+`('' + ${$}(rowId, `+L+`) ?? '', undefined, debugIds, ${s})`],$t(e,n,13)+ce)}))}));const K=N(S((e=>te(j,e)?.[4]??a))," | ");_(b+c,b+c,Be,Ye(1,8)+" changes",Il(s),cl()),_(C+c,C+c,Be,dt(2,0,1),Il(u),cl()),_(p+c,p+c,Be,dt(3,0),Il(y,`tableId: ${n} | null`),cl("tableId")),_(p+w+c,p+w+c,Be,dt(14,3,1),Il(T,`tableId: ${n} | null`),cl("tableId")),_(m+c,m+c,Be,dt(4,3,1),Il(V,`tableId: ${n} | null`),cl("tableId")),_(g+c,g+c,Be,dt(13,3,1),Il(x,`tableId: ${n} | null`,"cellId: "+K+Te,"descending: boolean","offset: number","limit: number"+Te),cl("tableId","cellId","descending","offset","limit")),_(h+c,h+c,Be,dt(5,3),Il(k,`tableId: ${n} | null`,el+": IdOrNull"),cl("tableId",el)),_(w+c,w+c,Be,dt(6,5,1),Il(P,`tableId: ${n} | null`,el+": IdOrNull"),cl("tableId",el)),_(f+c,f+c,Be,dt(7,5),Il(O,`tableId: ${n} | null`,el+": IdOrNull",`cellId: ${K} | null`),cl("tableId",el,"cellId"))}if(!Q(t)){const[e,t,l,n,o,s]=d;r(null,E,...d),r(1,E,G);const u=$("getDefaultValueComponent","valueId: Id",N(P(((e,t,l,a,n)=>`valueId == ${a} ? `+n+"ValueView : ")))+se);_(T,T,e,Ye(2,0)+ce);const i=_(v,v,l+Oe,tt(y,Ne)+ce);_(Ee+T+$e,Ee+T+$e,Yt,Ye(2,9)+qt,Pt(Wt(T)+Ht+t,Wt(T)+pe),Bt(T),Xt,Pt(nl,`values: ${t})`+Fe,_t),dl),_(Ee+Ve+T+$e,Ee+Ve+T+$e,Yt,Ye(2,11)+qt,Pt(Wt(Ve+T)+Ht+t,Wt(Ve+T)+pe),Bt(Ve+T),Xt,Pt(nl,`partialValues: ${t})`+Fe,_t),dl),_(ue+T+$e,ue+T+$e,$e,Ye(2,12),a,a,a,ol,dl);const p=I(y+xe,Dt("valueId?: VId",L+ye+G,Ft),at("a Value"),`<VId extends ${l}>`),b=I(T+xe,Dt(L+ye+G,"valueComponents?: {readonly [VId in "+l+`]?: ComponentType<${p}<VId>>;}`,`getValueComponentProps?: (valueId: ${l}) => ExtraProps`,al,Ft),at(Xe(2,1)));r(1,D,b,p),Z(T+rl,"{"+L+", valueComponents, getValueComponentProps"+ll+"}: "+b,[oe+`(${i}(${L}).map((valueId) => {`,"const Value = valueComponents?.[valueId] ?? "+u+"(valueId);","return <Value",`{...${ne}(getValueComponentProps, valueId)}`,"key={valueId}",W,Ut,"/>;","}), separator)"],Ye(2,13)+ce),P(((e,t,l,n,o)=>{const d="Map"+kt(t,1);r(0,E,d),r(1,E,d);const s=_(o+y,y,t,ut(e)+ce,a,n);_(Ee+o+y+$e,Ee+y+$e,Yt,ut(e,9)+qt,Pt(Wt(y)+Ht+t+" | "+d,Wt(y)+pe),Pt(n,Bt(y)),Xt,Pt(nl,`value: ${t} | ${d})`+Fe,_t),dl),_(ue+o+y+$e,ue+y+$e,$e,ut(e,12),a,n,a,ol,dl),Z(o+y+rl,`{${L}, debugIds}: ${p}<'${e}'>`,[oe+`('' + ${s}(`+L+`) ?? '', undefined, debugIds, ${n})`],ut(e,13)+ce)})),_(T+c,T+c,Be,Ye(2,8)+" changes",Il(n),cl()),_(v+c,v+c,Be,dt(10,0,1),Il(o),cl()),_(y+c,y+c,Be,dt(11,0),Il(s,`valueId: ${l} | null`),cl("valueId"))}return Z(Re,`{${L}, ${L}ById, children}: `+K+" & {children: React.ReactNode}",["{",Qt,"return (","<Context."+Re,"value={useMemo(",`() => [${L} ?? contextValue[0], {...contextValue[1], ...${L}ById}],`,`[${L}, ${L}ById, contextValue],`,")}>","{children}",`</Context.${Re}>`,");","}"],"Wraps part of an application in a context that provides default objects to be used by hooks and components within"),[s(...V(0),...x(),...H(0)),s(...V(1),...k(),...H(1))]},ul=(e,t,l)=>{if(Q(e)&&Q(t))return[a,a,a,a];const[n,o,d,s]=zt(e,t,l);return[n,o,...$l(e,t,l,d,s)]},il=JSON.parse,pl={parser:"typescript",singleQuote:!0,trailingComma:"all",bracketSpacing:!1,jsdocSingleLineComment:!1},bl=Nt((e=>{const t=()=>{const t=il(e.getTablesSchemaJson());return!Q(t)||E(e.getTableIds(),(l=>{const a=e.getRowIds(l),n=ee();if(E(a,(t=>E(e.getCellIds(l,t),(a=>{const o=e.getCell(l,t,a),d=oe(n,a,(()=>[P(o),ee(),[0],0])),[s,r,[I]]=d,c=oe(r,o,(()=>0))+1;return c>I&&(d[2]=[c,o]),ne(r,o,c),d[3]++,s==P(o)})))))return t[l]={},X(n,(([e,,[,n],o],d)=>{t[l][d]={[r]:e,...o==L(a)?{[I]:n}:{}}})),1}))?t:{}},l=()=>{const t=il(e.getValuesSchemaJson());return Q(t)&&e.forEachValue(((e,l)=>{t[e]={[r]:P(l)}})),t},a=e=>ul(t(),l(),e),n=async e=>{const t=["d.ts","ts","d.ts","tsx"];let l;try{l=(await import("prettier")).format}catch(e){l=e=>e}return G(a(e),((e,a)=>Vt(l(e,{...pl,filepath:"_."+t[a]}))))};return U({getStoreStats:t=>{let l=0,a=0,n=0;const o={};return e.forEachTable(((e,d)=>{l++;let s=0,r=0;const I={};d(((e,l)=>{s++;let a=0;l((()=>a++)),r+=a,t&&(I[e]={rowCells:a})})),a+=s,n+=r,t&&(o[e]={tableRows:s,tableCells:r,rows:I})})),{totalTables:l,totalRows:a,totalCells:n,totalValues:L(e.getValueIds()),jsonLength:xt(e.getJson()),...t?{detail:{tables:o}}:{}}},getStoreTablesSchema:t,getStoreValuesSchema:l,getStoreApi:a,getPrettyStoreApi:n,getStore:()=>e})}));e.createTools=bl},"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).TinyBaseTools={});
1
+ var e,t;e=this,t=function(e){"use strict";const t=e=>typeof e,l="tinybase",a="",n=",",o=t(a),d=t(!0),s=t(0),r="type",I="default",c="Listener",$="get",i="add",u="Ids",p="Table",b=p+"s",C=p+u,h="Row",m=h+u,g="Sorted"+h+u,f="Cell",w=f+u,y="Value",T=y+"s",v=y+u,V=Promise,x=isFinite,R=(e,t)=>e instanceof t,k=e=>null==e,S=e=>e==o||e==d,P=e=>t(e)==o,A=e=>Array.isArray(e),E=async e=>V.all(e),D=e=>{const l=t(e);return S(l)||l==s&&x(e)?l:void 0},O=(e,t)=>e.every(t),N=(e,t)=>e.sort(t),G=(e,t)=>e.forEach(t),L=(e,t=a)=>e.join(t),j=(e,t)=>e.map(t),M=e=>e.length,J=(e,t)=>e.filter(t),z=(e,...t)=>e.push(...t),W=e=>e.pop(),B=(e,...t)=>e.unshift(...t),F=e=>e.shift(),U=Object,_=U.keys,Z=U.freeze,H=e=>R(e,U)&&e.constructor==U,Q=(e,t)=>j(U.entries(e),(([e,l])=>t(l,e))),q=e=>M(_(e)),K=e=>H(e)&&0==q(e),X=(e,t)=>e?.has(t)??!1,Y=e=>[...e?.values()??[]],ee=(e,t)=>e?.forEach(t),te=(e,t)=>e?.delete(t),le=e=>new Map(e),ae=(e,t)=>e?.get(t),ne=(e,t)=>ee(e,((e,l)=>t(l,e))),oe=(e,t)=>j([...e?.entries()??[]],(([e,l])=>t(l,e))),de=(e,t,l)=>k(l)?(te(e,t),e):e?.set(t,l),se=(e,t,l)=>(X(e,t)||de(e,t,l()),ae(e,t)),re=e=>e.toUpperCase(),Ie=e=>e.toLowerCase(),ce="a ",$e="A function for",ie=", and registers a listener so that any changes to that result will cause a re-render",ue="Callback",pe="Del",be="Deps",Ce=be+"?: React.DependencyList",he="doRollback?: DoRollback",me="actions: () => Return, "+he,ge="export",fe="Id",we="Invalid",ye="Json",Te=Ie(c),ve="?: ",Ve=" | undefined",xe="NonNullable",Re="Partial",ke="Props",Se="Provider",Pe=`Registers a ${Te} that will be called`,Ae="Represents",Ee="rowId: "+fe,De="Schema",Oe="Set",Ne=", descending?: boolean, offset?: number, limit?: number",Ge="[]",Le="the Store",je="Transaction",Me=je+"Changes",Je=Ie(je),ze="Execute a "+Je+" to make multiple mutations",We="Explicitly starts a "+Je,Be="Explicitly finishes a "+Je,Fe="the end of the "+Je,Ue="void",_e=" => "+Ue,Ze="WhenSet",He=" when setting it",Qe=ce+"string serialization of",qe=" ",Ke="Gets a callback that can ",Xe="the ",Ye=" the schema for",et=(e=0,t=0)=>`the ${mt[e]}content of`+(t?qe+Le:a),tt=(e=0,t,l=0)=>bt[t]+qe+et(e,1)+(l?" when setting it":a),lt=(e,t=0)=>Ae+` a Row when ${t?"s":"g"}etting ${et()} the '${e}' `+p,at=(e,t,l=0)=>`Gets ${l?"sorted, paginated":"the"} Ids of the ${e}s in `+t,nt=(e,t)=>`Calls a function for each ${e} in `+t,ot=e=>"The props passed to a component that renders "+e,dt=e=>"A function that takes "+e,st=(e,t=0)=>$e+" listening to changes to "+ht[e]+" in "+ht[t],rt=(e,t,l=0)=>Pe+" whenever "+ht[e]+" in "+ht[t]+" change"+(l?a:"s"),It=e=>`the '${e}' `+p,ct=e=>"the specified Row in "+It(e),$t=(e,t=0)=>bt[t]+` ${et()} `+It(e),it=(e,t=0)=>bt[t]+` ${et()} `+ct(e),ut=(e,t,l=0)=>bt[l]+` the '${t}' Cell for `+ct(e),pt=(e,t=0)=>bt[t]+` the '${e}' Value`,bt=["Gets","Checks existence of","Sets","Deletes","Sets part of",Ae,"Gets "+Qe,"Sets "+Qe,Pe+" whenever",Ke+"set",Ke+"add",Ke+"set part of",Ke+"delete","Renders","Gets "+Qe+Ye,"Sets"+Ye,"Deletes"+Ye],Ct=[$,"has","set","del","set","forEach",i,a],ht=[Le,b,Xe+p+qe+u,ce+p,Xe+h+qe+u,ce+h,Xe+f+qe+u,ce+f,"invalid Cell changes",T,Xe+y+qe+u,ce+y,"invalid Value changes",Xe+"sorted "+h+qe+u,Xe+f+qe+u+" anywhere",Xe+"number of Rows"],mt=[a,"tabular ","keyed value "],gt=e=>new Set(A(e)||k(e)?e:[e]),ft=(e,t)=>e?.add(t),wt=/[^A-Za-z]+/,yt=/[^A-Za-z0-9]+/,Tt=/^( *)\/\*\* *(.*?) *\*\/$/gm,vt=(e,t,l)=>e.substring(t,l),Vt=e=>e.includes(n),xt=(e,t,l,a=1)=>{const n=`${t}${1==a?"":a}`;return X(e,n)?xt(e,t,l,a+1):(de(e,n,l),n)},Rt=e=>e.replace(Tt,((e,t,l)=>{const a=77-kt(t);return`${t}/**\n${l.replace(RegExp(`([^\\n]{1,${a}})(\\s|$)`,"g"),t+" * $1\n")}${t} */`})),kt=e=>e.length,St=e=>e.flat(1e3),Pt=(e,t=0)=>L(j(e.split(yt),((e,l)=>(l>0||t?re:Ie)(vt(e,0,1))+vt(e,1)))),At=e=>re(L((e&&!wt.test(e[0])?e:" "+e).split(yt),"_")),Et=e=>`/** ${e}. */`,Dt=(...e)=>L(J(e,(e=>e)),", "),Ot=(...e)=>"{"+L(e,"; ")+"}",Nt=(...e)=>Ot(...j(e,(e=>"readonly "+e))),Gt=()=>{const e=[le(),le(),le(),le()],t=le(),l=le(),n=e=>{const t=e.indexOf(" as ");return-1!=t?e.substring(t+4):e};return[(...e)=>L(St(e),"\n"),(t,l,...a)=>G(a,(a=>G([0,1],(n=>(t??n)==n?ft(se(e[n],l,gt),a):0)))),(e,l,n,o=a,d=1)=>xt(t,e,[l,n,o,d]),(e,t,a)=>xt(l,e,A(a)?[`(${t}) => {`,a,"}"]:[`(${t}) => ${a}`]),(e,t)=>ae(l,e)===t?e:xt(l,e,t),(t=0)=>j([...N(oe(e[t],((e,t)=>`import {${L(N(Y(e),((e,t)=>n(e)>n(t)?1:-1)),", ")}} from '${t}';`)),((e,t)=>Vt(e)!=Vt(t)?Vt(e)?-1:1:e>t?1:-1)),a],(e=>e.replace("{React}","React"))),()=>oe(t,(([e,t,l,n],o)=>[Et(t),`${n?ge+" ":a}type ${o}${l} = ${e};`,a])),()=>oe(l,((e,t)=>(e=A(e)?e:[e],z(e,W(e)+";"),[`const ${t} = ${F(e)}`,e,a])))]},Lt=e=>{const t=new WeakMap;return l=>(t.has(l)||t.set(l,e(l)),t.get(l))},jt=(e,t,l)=>[t=>Q(e,((e,a)=>t(a,Pt(a,1),l(At(a),`'${a}'`)))),(t,a)=>Q(e[t],((e,t)=>a(t,e[r],e[I],l(At(t),`'${t}'`),Pt(t,1)))),e=>Q(t,((t,a)=>e(a,t[r],t[I],l(At(a),`'${a}'`),Pt(a,1))))],Mt=(e,t,l,n)=>[(n,o)=>{const d=n+": "+o,s=e(b,Ot(...t((e=>`'${e}'?: {[rowId: Id]: `+Ot(...l(e,((e,t,l)=>`'${e}'${k(l)?"?":a}: ${t}`)))+"}"))),tt(1,5)),r=e(b+Ze,Ot(...t((e=>`'${e}'?: {[rowId: Id]: `+Ot(...l(e,((e,t)=>`'${e}'?: ${t}`)))+"}"))),tt(1,5,1)),I=e(p+fe,"keyof "+s,"A "+p+" Id in "+Le),$=`<TId extends ${I}>`,i=e(p,xe+`<${s}[TId]>`,"A "+p+" in "+Le,$),u=e(p+Ze,xe+`<${r}[TId]>`,"A "+p+" in "+Le+He,$),y=e(h,i+"<TId>[Id]","A "+h+" in a "+p,$),T=e(h+Ze,u+"<TId>[Id]","A "+h+" in a "+p+He,$),v=e(f+fe,`Extract<keyof ${y}<TId>, Id>`,"A "+f+" Id in a "+h,$),V=e(f,xe+`<${s}[TId]>[Id][CId]`,"A "+f+" in a "+h,`<TId extends ${I}, CId extends ${v}<TId>>`),x=e("CellIdCellArray",`CId extends ${v}<TId> ? [cellId: CId, cell: ${V}<TId, CId>] : never`,f+" Ids and types in a "+h,`<TId extends ${I}, CId = ${v}<TId>>`,0),R=e(f+ue,`(...[cellId, cell]: ${x}<TId>)`+_e,dt(ce+f+" Id, and "+f),$),S=e(h+ue,"(rowId: Id, forEachCell: (cellCallback: CellCallback<TId>) "+_e+") "+_e,dt(ce+h+" Id, and a "+f+" iterator"),$),P=e(p+f+ue,`(cellId: ${v}<TId>, count: number) `+_e,dt(ce+f+" Id, and count of how many times it appears"),$),A=e("TableIdForEachRowArray",`TId extends ${I} ? [tableId: TId, forEachRow: (rowCallback: ${S}<TId>)${_e}] : never`,p+" Ids and callback types",`<TId = ${I}>`,0),E=e(p+ue,`(...[tableId, forEachRow]: ${A})`+_e,dt(ce+p+" Id, and a "+h+" iterator"),a),D=e("TableIdRowIdCellIdArray",`TId extends ${I} ? [tableId: TId, rowId: Id, cellId: ${v}<TId>] : never`,"Ids for GetCellChange",`<TId = ${I}>`,0),O=e("GetCellChange",`(...[tableId, rowId, cellId]: ${D}) => CellChange`,$e+" returning information about any Cell's changes during a "+Je),N=e(b+c,`(${d}, getCellChange: ${O}${Ve})`+_e,st(1)),G=e(C+c,`(${d})`+_e,st(2)),L=e(p+c,`(${d}, tableId: ${I}, getCellChange: ${O}${Ve})`+_e,st(3)),j=e(p+w+c,`(${d}, tableId: ${I})`+_e,st(14,3)),M=e(h+"Count"+c,`(${d}, tableId: ${I})`+_e,st(15,3)),J=e(m+c,`(${d}, tableId: ${I})`+_e,st(4,3)),z=e(g+c,"("+Dt(d,"tableId: "+I,"cellId: Id"+Ve,"descending: boolean","offset: number","limit: number"+Ve,"sortedRowIds: Ids")+")"+_e,st(13,3)),W=e(h+c,"("+Dt(""+d,"tableId: "+I,Ee,`getCellChange: ${O}${Ve}`)+")"+_e,st(5,3)),B=e(w+c,"("+Dt(""+d,"tableId: "+I,Ee)+")"+_e,st(6,5)),F=e("CellListenerArgsArrayInner",`CId extends ${v}<TId> ? [${d}, tableId: TId, ${Ee}, cellId: CId, newCell: ${V}<TId, CId> ${Ve}, oldCell: ${V}<TId, CId> ${Ve}, getCellChange: ${O} ${Ve}] : never`,"Cell args for CellListener",`<TId extends ${I}, CId = ${v}<TId>>`,0),U=e("CellListenerArgsArrayOuter",`TId extends ${I} ? `+F+"<TId> : never","Table args for CellListener",`<TId = ${I}>`,0);return[s,r,I,i,u,y,T,v,V,R,S,P,E,N,G,L,j,M,J,z,W,B,e(f+c,`(...[${n}, tableId, rowId, cellId, newCell, oldCell, getCellChange]: ${U})`+_e,st(7,5)),e(we+f+c,`(${d}, tableId: Id, ${Ee}, cellId: Id, invalidCells: any[])`+_e,st(8))]},(t,l)=>{const o=t+": "+l,d=e(T,Ot(...n(((e,t,l)=>`'${e}'${k(l)?"?":a}: ${t}`))),tt(2,5)),s=e(T+Ze,Ot(...n(((e,t)=>`'${e}'?: ${t}`))),tt(2,5,1)),r=e(y+fe,"keyof "+d,"A "+y+" Id in "+Le),I=e(y,xe+`<${d}[VId]>`,"A "+y+" Id in "+Le,`<VId extends ${r}>`),$=e("ValueIdValueArray",`VId extends ${r} ? [valueId: VId, value: ${I}<VId>] : never`,y+" Ids and types in "+Le,`<VId = ${r}>`,0),i=e(y+ue,`(...[valueId, value]: ${$})`+_e,dt(ce+y+" Id, and "+y)),u=e("GetValueChange",`(valueId: ${r}) => ValueChange`,$e+" returning information about any Value's changes during a "+Je),p=e(T+c,`(${o}, getValueChange: ${u}${Ve})`+_e,st(9)),b=e(v+c,`(${o})`+_e,st(10)),C=e("ValueListenerArgsArray",`VId extends ${r} ? [${o}, valueId: VId, newValue: ${I}<VId> ${Ve}, oldValue: ${I}<VId> ${Ve}, getValueChange: ${u} ${Ve}] : never`,"Value args for ValueListener",`<VId = ${r}>`,0);return[d,s,r,I,i,p,b,e(y+c,`(...[${t}, valueId, newValue, oldValue, getValueChange]: `+C+")"+_e,st(11)),e(we+y+c,`(${o}, valueId: Id, invalidValues: any[])`+_e,st(12))]},(t,l)=>e(je+c,`(${t}: ${l}, getTransactionChanges: GetTransactionChanges, getTransactionLog: GetTransactionLog)`+_e,$e+" listening to the completion of a "+Je)],Jt=(e,t=a,l=a)=>`store.${e}(${t})`+(l?" as "+l:a),zt=(e,t=a)=>`fluent(() => ${Jt(e,t)})`,Wt=(e,t=a,l=a)=>`store.${e}(${t?t+", ":a}proxy(listener)${l?", "+l:a})`,Bt=(e,t,n)=>{const[o,s,$,V,x,R,S,A]=Gt(),[E,D,O]=jt(e,t,x),[N,j,M]=Mt($,E,D,O),J=le(),W=(e=0)=>oe(J,(([t,l,n,o,d],s)=>{const r=e?[s+`: ${d}(${t}): ${l} => ${n},`]:[s+d+`(${t}): ${l};`];return e||B(r,Et(o)),z(r,a),r})),F=(e,t,l,n,o,d=a)=>xt(J,e,[t,l,n,o,d]),U=(e,t,l,n,o,d=a,s=a,r=a)=>F(Ct[e]+t+(4==e?Re:a)+l,d,n,(n==H?zt:Jt)(Ct[e]+(4==e?Re:a)+l,s,e?void 0:n),o,r),_=(e,t,l,n=a,o=a,d=1,s=a)=>F(i+e+c,(n?n+", ":a)+Te+": "+t+(d?", mutator?: boolean":a),fe,Wt(i+e+c,o,d?"mutator":a),l,s),Z=`./${Pt(n)}.d`,H=Pt(n,1),Q=Pt(H),q=[],X=le();let ee=[],te=[];if(s(1,Z,H,`create${H} as create${H}Decl`),K(e))s(null,l,b);else{s(0,l,"CellChange"),s(null,l,u);const[e,t,n,o,c,i,y,T,v,V,R,S,A,O,j,M,J,W,B,F,K,te,ne,oe]=N(Q,H),se=le();E(((e,t)=>{const l=`<'${e}'>`,a=[$(t+p,o+l,Ae+` the '${e}' `+p),$(t+p+Ze,c+l,Ae+` the '${e}' `+p+He),$(t+h,i+l,lt(e)),$(t+h+Ze,y+l,lt(e,1)),$(t+f+fe,T+l,`A Cell Id for the '${e}' `+p),$(t+f+ue,V+l,dt(`a Cell Id and value from a Row in the '${e}' `+p)),$(t+h+ue,R+l,dt(`a Row Id from the '${e}' Table, and a Cell iterator`)),$(t+p+f+ue,S+l,dt(`a Cell Id from anywhere in the '${e}' Table, and a count of how many times it appears`))];de(se,e,a),s(1,Z,...a)})),s(1,Z,e,t,n,T,A,O,j,M,J,W,B,F,K,te,ne,oe),ee=[e,t,n,T,O,j,M,J,W,B,F,K,te,ne,se],G([[e],[d],[H,"tables: "+t,"tables"],[H]],(([e,t,l],n)=>U(n,a,b,e,tt(1,n),t,l))),U(0,a,C,n+Ge,at(p,Le)),U(5,a,p,Ue,nt(p,Le),"tableCallback: "+A,"tableCallback as any"),E(((e,t,l)=>{const[n,o,s,r,I,c,$,i]=ae(se,e);G([[n],[d],[H,"table: "+o,", table"],[H]],(([n,o,d=a],s)=>U(s,t,p,n,$t(e,s),o,l+d))),U(0,t,p+w,u,at(f,"the whole of "+It(e)),a,l),U(5,t,p+f,Ue,nt(p+f,"the whole of "+It(e)),"tableCellCallback: "+i,l+", tableCellCallback as any"),U(0,t,h+"Count","number","Gets the number of Rows in the "+It(e),a,l),U(0,t,m,u,at(h,It(e)),a,l),U(0,t,g,u,at(h,It(e),1),"cellId?: "+I+Ne,l+", cellId, descending, offset, limit"),U(5,t,h,Ue,nt(h,It(e)),"rowCallback: "+$,l+", rowCallback as any"),G([[s],[d],[H,", row: "+r,", row"],[H],[H,", partialRow: "+r,", partialRow"]],(([n,o=a,d=a],s)=>U(s,t,h,n,it(e,s),Ee+o,l+", rowId"+d))),U(6,t,h,fe+Ve,"Add a new Row to "+It(e),"row: "+r+", reuseIds?: boolean",l+", row, reuseIds"),U(0,t,w,I+Ge,at(f,ct(e)),Ee,l+", rowId"),U(5,t,f,Ue,nt(f,ct(e)),Ee+", cellCallback: "+c,l+", rowId, cellCallback as any"),D(e,((n,o,s,r,I)=>{const c="Map"+Pt(o,1);de(X,o,c);const $=o+(k(s)?Ve:a);G([[$],[d],[H,`, cell: ${o} | `+c,", cell as any"],[H]],(([o,d=a,s=a],c)=>U(c,t+I,f,o,ut(e,n,c),Ee+d,l+", rowId, "+r+s))),U(1,t+I,p+f,d,bt[1]+` the '${n}' Cell anywhere in `+It(e),a,l+", "+r)}))})),U(0,a,b+ye,ye,tt(1,6)),U(2,a,b+ye,H,tt(1,7),"tablesJson: "+ye,"tables"+ye),_(b,O,tt(1,8)+" changes"),_(C,j,rt(2,0,1)),_(p,M,rt(3,0),`tableId: ${n} | null`,"tableId"),_(p+w,J,rt(14,3,1),`tableId: ${n} | null`,"tableId"),_(h+"Count",W,rt(15,3),`tableId: ${n} | null`,"tableId"),_(m,B,rt(4,3,1),`tableId: ${n} | null`,"tableId"),_(g,F,rt(13,3,1),Dt("tableId: TId",`cellId: ${T}<TId>`+Ve,"descending: boolean","offset: number","limit: number"+Ve),Dt("tableId","cellId","descending","offset","limit"),1,"<TId extends TableId>"),_(h,K,rt(5,3),`tableId: ${n} | null, rowId: IdOrNull`,"tableId, rowId"),_(w,te,rt(6,5,1),`tableId: ${n} | null, rowId: IdOrNull`,"tableId, rowId"),_(f,ne,rt(7,5),`tableId: ${n} | null, rowId: IdOrNull, cellId: ${L(E((e=>ae(se,e)?.[4]??a))," | ")} | null`,"tableId, rowId, cellId"),_(we+f,oe,Pe+" whenever an invalid Cell change was attempted","tableId: IdOrNull, rowId: IdOrNull, cellId: IdOrNull","tableId, rowId, cellId"),s(1,Z,...Y(X)),z(q,".set"+b+De+"({",St(E(((e,t,l)=>[`[${l}]: {`,...D(e,((e,t,l,n)=>`[${n}]: {[${x(At(r),`'${r}'`)}]: ${x(At(t),`'${t}'`)}${k(l)?a:`, [${x(At(I),`'${I}'`)}]: `+(P(l)?x(At(l),`'${l}'`):l)}},`)),"},"]))),"})")}if(K(t))s(null,l,T);else{const[e,t,n,o,c,$,i,u,p]=j(Q,H);s(1,Z,e,t,n,c,$,i,u,p),te=[e,t,n,$,i,u],G([[e],[d],[H,"values: "+t,"values"],[H],[H,"partialValues: "+t,"partialValues"]],(([e,t,l],n)=>U(n,a,T,e,tt(2,n),t,l))),U(0,a,v,n+Ge,at(y,Le)),U(5,a,y,"void",nt(y,Le),"valueCallback: "+c,"valueCallback as any"),O(((e,t,l,n,o)=>{const s="Map"+Pt(t,1);de(X,t,s),G([[t],[d],[H,`value: ${t} | `+s,", value as any"],[H]],(([t,l,d=a],s)=>U(s,o,y,t,pt(e,s),l,n+d)))})),U(0,a,T+ye,ye,tt(2,6)),U(2,a,T+ye,H,tt(2,7),"valuesJson: "+ye,"values"+ye),_(T,$,tt(2,8)+" changes"),_(v,i,rt(10,0,1)),_(y,u,rt(11,0),`valueId: ${n} | null`,"valueId"),_(we+y,p,Pe+" whenever an invalid Value change was attempted","valueId: IdOrNull","valueId"),s(1,Z,...Y(X)),s(0,l,"ValueChange"),z(q,".set"+T+De+"({",O(((e,t,l,n)=>[`[${n}]: {[${x(At(r),`'${r}'`)}]: ${x(At(t),`'${t}'`)}${k(l)?a:`, [${x(At(I),`'${I}'`)}]: `+(P(l)?x(At(l),`'${l}'`):l)}},`])),"})")}U(0,a,"Content",`[${b}, ${T}]`,tt(0,0)),U(2,a,"Content",H,tt(0,2),`[tables, values]: [${b}, ${T}]`,"[tables, values]"),U(2,a,Me,H,`Applies a set of ${Me} to the Store`,"transactionChanges: "+Me,"transactionChanges"),ne(X,((e,t)=>$(t,`(cell: ${e}${Ve}) => `+e,`Takes a ${e} Cell value and returns another`))),s(null,l,"DoRollback",fe,"IdOrNull",ye,"Store",Me),s(0,l,"Get"+Me,"GetTransactionLog"),U(0,a,ye,ye,tt(0,6)),U(2,a,ye,H,tt(0,7),"tablesAndValuesJson: "+ye,"tablesAndValuesJson"),U(7,a,Je,"Return",ze,me,"actions, doRollback","<Return>"),U(7,a,"start"+je,H,We),U(7,a,"finish"+je,H,Be,he,"doRollback");const se=M(Q,H);return _("Start"+je,se,Pe+" just before the start of the "+Je,a,a,0),_("WillFinish"+je,se,Pe+" just before "+Fe,a,a,0),_("DidFinish"+je,se,Pe+" just after "+Fe,a,a,0),U(7,a,"call"+c,H,"Manually provoke a listener to be called","listenerId: Id","listenerId"),U(3,a,c,H,"Remove a listener that was previously added to "+Le,"listenerId: Id","listenerId"),F("getStore",a,"Store","store",bt[0]+" the underlying Store object"),s(1,l,"createStore"),s(1,Z,H,`create${H} as create${H}Decl`,se),x("store",["createStore()",...q]),V("fluent","actions: () => Store",["actions();",`return ${Q};`]),V("proxy","listener: any",`(_: Store, ...params: any[]) => listener(${Q}, ...params)`),x(Q,["{",...W(1),"}"]),[o(...R(0),...S(),ge+" interface "+H+" {",...W(0),"}",a,Et(`Creates a ${H} object`),ge+" function create"+H+"(): "+H+";"),o(...R(1),ge+" const create"+H+": typeof create"+H+"Decl = () => {",...A(),`return Object.freeze(${Q});`,"};"),ee,te]},Ft=e=>$+e,Ut=e=>Dt(Ft(e),Ft(e)+be),_t="debugIds?: boolean",Zt="debugIds={debugIds}",Ht="then"+Ce,Qt="Parameter",qt=": (parameter: "+Qt+", store: Store) => ",Kt="const contextValue = useContext(Context);",Xt=", based on a parameter",Yt=": ",el="<"+Qt+",>",tl=Qt+"ized"+ue+"<"+Qt+">",ll="rowId",al="rowId={rowId}",nl=", separator, debugIds",ol="separator?: ReactElement | string",dl="then?: (store: Store",sl=Dt(dl+")"+_e,Ht),rl="then, then"+be,Il=ll+Yt+fe,cl="View",$l=(e,...t)=>Dt(...t,Te+": "+e,Te+Ce,"mutator?: boolean"),il=(...e)=>Dt(...e,Te,Te+be,"mutator"),ul=(e,t,n,o,d)=>{const[s,r,I,$,i,V,x,R]=Gt(),[S,P,A]=jt(e,t,i),E=`./${Pt(n)}.d`,D=`./${Pt(n)}-ui-react.d`,O="tinybase/ui-react",N=Pt(n,1),G=Pt(N),j=N+"Or"+N+fe,M=G+"Or"+N+fe,J=G+`={${G}}`,W=le(),F=(e,t,l,n,o,d=a)=>(r(1,D,e+" as "+e+"Decl"),xt(W,e,[t,l,n,o,d])),U=(e,t,l,n,o,d=a)=>F("use"+e,t,l,n,o,d),_=(e,t,l,n,o=a,d=a,s=a,I=a,c=a)=>(r(1,O,`use${t} as use${t}Core`),U(e,Dt(o,X,I),l,ee+`(${M}, use${t}Core, [`+(d||a)+(c?"], ["+c:a)+"]);",n,s)),Z=(e,t,l,a)=>F(e,t,1,l,a),H=(e=0)=>oe(W,(([t,l,n,o,d],s)=>{const r=e?[ge+` const ${s}: typeof ${s}Decl = ${d}(${t}): ${1==l?"any":l} =>`,n]:[ge+` function ${s}${d}(${t}): ${1==l?"ComponentReturnType":l};`];return e||B(r,Et(o)),z(r,a),r}));r(null,l,fe,"Store",ue,Qt+"ized"+ue),r(0,O,"ComponentReturnType"),r(1,O,"useCellIds"),r(null,O,"ExtraProps"),r(0,E,N);const Q=I(j,N+" | "+fe,`Used when you need to refer to a ${N} in a React hook or component`),q=I(Se+ke,Nt(G+ve+N,G+`ById?: {[${G}Id: Id]: ${N}}`),`Used with the ${Se} component, so that a `+N+" can be passed into the context of an application");r(0,"react","ReactElement","ComponentType"),r(1,"react","React"),r(1,D,Q,q);const X=M+ve+Q;i("{createContext, useContext, useMemo}","React"),i("Context",`createContext<[${N}?, {[${G}Id: Id]: ${N}}?]>([])`),U("Create"+N,`create: () => ${N}, create`+Ce,N,"\n// eslint-disable-next-line react-hooks/exhaustive-deps\nuseMemo(create, createDeps)",`Create a ${N} within a React application with convenient memoization`);const Y=U(N,"id?: Id",N+Ve,["{",Kt,"return id == null ? contextValue[0] : contextValue[1]?.[id];","}"],`Get a reference to a ${N} from within a ${Se} component context`),ee=$("useHook",M+`: ${Q} | undefined, hook: (...params: any[]) => any, preParams: any[], postParams: any[] = []`,[`const ${G} = ${Y}(${M} as Id);`,`return hook(...preParams, ((${M} == null || typeof ${M} == 'string')`,`? ${G} : ${M})?.getStore(), ...postParams)`]),te=$("getProps","getProps: ((id: any) => ExtraProps) | undefined, id: Id","(getProps == null) ? ({} as ExtraProps) : getProps(id)"),ne=$("wrap",Dt("children: any","separator?: any","encloseWithId?: boolean","id?: Id"),["const separated = separator==null || !Array.isArray(children)"," ? children"," : children.map((child, c) => (c > 0 ? [separator, child] : child));","return encloseWithId ? [id, ':{', separated, '}'] : separated;"]),de=$("useCustomOrDefaultCellIds",Dt("customCellIds: Ids | undefined","tableId: Id","rowId: Id",`${M}?: ${Q} | undefined`),[`const defaultCellIds = ${ee}(${M}, useCellIds, [tableId, rowId]);`,"return customCellIds ?? defaultCellIds;"]),se=i("NullComponent","() => null");if(!K(e)){const[e,t,n,d,s,i,y,T,v,V,x,R,A,O,j]=o;r(null,E,e,t,n,s,i,y,T,v,V,x,R,A,O),r(0,E,d),r(1,E,N),r(null,l,u,"IdOrNull");const M=$("tableView",`{${G}, rowComponent, getRowComponentProps, customCellIds`+nl+"}: any, rowIds: Ids, tableId: Id, defaultRowComponent: React.ComponentType<any>",["const Row = rowComponent ?? defaultRowComponent;",`return ${ne}(rowIds.map((rowId) => (`,"<Row","{..."+te+"(getRowComponentProps, rowId)}","key={rowId}","tableId={tableId}",al,"customCellIds={customCellIds}",J,Zt,"/>","))",nl,", tableId,",");"]),z=$("getDefaultTableComponent","tableId: Id",L(S(((e,t,l)=>`tableId == ${l} ? ${t}TableView : `)))+se),W=$("getDefaultCellComponent","tableId: Id, cellId: Id",L(S(((e,t,l)=>`tableId == ${l} ? ${L(P(e,((e,l,a,n,o)=>`cellId == ${n} ? `+t+o+"CellView : ")))+se} : `)))+se);_(b,b,e,tt(1,0)+ie);const B=_(C,C,n+Ge,at(p,Le)+ie);_(Oe+b+ue,Oe+b+ue,tl,tt(1,9)+Xt,Dt(Ft(b)+qt+t,Ft(b)+Ce),Ut(b),el,Dt(dl,`tables: ${t})`+_e,Ht),rl),_(pe+b+ue,pe+b+ue,ue,tt(1,12),a,a,a,sl,rl);const F=I(f+ke,Nt("tableId?: TId","rowId: Id","cellId?: CId",G+ve+N,_t),ot(ce+f),`<TId extends ${n}, CId extends ${d}<TId>>`),U=I(h+ke,Nt("tableId?: TId","rowId: Id",G+ve+N,"cellComponents?: {readonly [CId in "+d+`<TId>]?: ComponentType<${F}<TId, CId>>;}`,`getCellComponentProps?: (cellId: ${d}<TId>) => ExtraProps`,`customCellIds?: ${d}<TId>[]`,ol,_t),ot(ce+h),`<TId extends ${n}>`),H=I(p+ke,Nt("tableId?: TId",G+ve+N,`rowComponent?: ComponentType<${U}<TId>>`,"getRowComponentProps?: (rowId: Id) => ExtraProps","customCellIds?: CellId<TId>[]",ol,_t),ot(ce+p),`<TId extends ${n}>`),Q=I("Sorted"+p+ke,Nt("tableId?: TId","cellId?: "+d+"<TId>","descending?: boolean","offset?: number","limit?: number",G+ve+N,`rowComponent?: ComponentType<${U}<TId>>`,"getRowComponentProps?: (rowId: Id) => ExtraProps","customCellIds?: CellId<TId>[]",ol,_t),ot(ce+"sorted "+p),`<TId extends ${n}>`),q=I(b+ke,Nt(G+ve+N,"tableComponents?: {readonly [TId in "+n+`]?: ComponentType<${H}<TId>>;}`,`getTableComponentProps?: (tableId: ${n}) => ExtraProps`,ol,_t),ot(et(1,1)));r(1,D,q,H,Q,U,F),Z(b+cl,"{"+G+", tableComponents, getTableComponentProps"+nl+"}: "+q,[ne+`(${B}(${G}).map((tableId) => {`,"const Table = (tableComponents?.[tableId] ?? "+z+"(tableId)) as React.ComponentType<TableProps<typeof tableId>>;","return <Table",`{...${te}(getTableComponentProps, tableId)}`,"tableId={tableId}","key={tableId}",J,Zt,"/>;","}), separator)"],tt(1,13)+ie),S(((e,t,l)=>{const[n,o,d,s,I]=ae(j,e);r(null,E,n,o,d,s,I),_(t+p,p,n,$t(e)+ie,a,l),_(t+p+w,p+w,u,at(f,"the whole of "+It(e))+ie,a,l);const c=_(t+m,m,u,at(h,It(e))+ie,a,l),$=_(t+g,g,u,at(h,It(e),1)+ie,"cellId?: "+I+", descending?: boolean, offset?: number, limit?: number",l+", cellId, descending, offset, limit");_(t+h,h,d,it(e)+ie,Il,Dt(l,ll)),_(t+w,w,I+Ge,at(f,ct(e))+ie,Il,Dt(l,ll)),_(Oe+t+p+ue,Oe+p+ue,tl,$t(e,9)+Xt,Dt(Ft(p)+qt+o,Ft(p)+Ce),Dt(l,Ut(p)),el,Dt(dl,`table: ${o})`+_e,Ht),rl),_(pe+t+p+ue,pe+p+ue,ue,$t(e,12),a,l,a,sl,rl),_(Oe+t+h+ue,Oe+h+ue,tl,it(e,9)+Xt,Dt(Il,Ft(h)+qt+s,Ft(h)+Ce),Dt(l,ll,Ut(h)),el,Dt(dl,`row: ${s})`+_e,Ht),rl),_("Add"+t+h+ue,"Add"+h+ue,tl,it(e,10)+Xt,Dt(Ft(h)+qt+s,Ft(h)+Ce),Dt(l,Ut(h)),el,"then?: ("+Dt(Il+Ve,"store: Store","row: "+s+")"+_e,"then"+Ce)+", reuseRowIds?: boolean",rl+", reuseRowIds"),_(Oe+t+Re+h+ue,Oe+Re+h+ue,tl,it(e,11)+Xt,Dt(Il,Ft(Re+h)+qt+s,Ft(Re+h)+Ce),Dt(l,ll,Ut(Re+h)),el,Dt(dl,`partialRow: ${s})`+_e,Ht),rl),_(pe+t+h+ue,pe+h+ue,ue,it(e,12),Il,Dt(l,ll),a,sl,rl);const i=Z(t+h+cl,"{rowId, "+G+", cellComponents, getCellComponentProps, customCellIds"+nl+`}: ${U}<'${e}'>`,[ne+`(${de}(customCellIds, `+l+`, rowId, ${G}).map((cellId: ${I}) => {`,"const Cell = (cellComponents?.[cellId] ?? "+W+`(${l}, cellId)) as React.ComponentType<CellProps<typeof `+l+", typeof cellId>>;","return <Cell",`{...${te}(getCellComponentProps, cellId)} `,"key={cellId}",`tableId={${l}}`,al,"cellId={cellId}",J,Zt,"/>;","})"+nl+", rowId)"],it(e,13)+ie);Z(t+"Sorted"+p+cl,"{cellId, descending, offset, limit, ...props}: "+Q+`<'${e}'>`,M+"(props, "+$+`(cellId, descending, offset, limit, props.${G}), ${l}, ${i});`,$t(e,13)+", sorted"+ie),Z(t+p+cl,`props: ${H}<'${e}'>`,M+"(props, "+c+`(props.${G}), ${l}, ${i});`,$t(e,13)+ie),P(e,((n,o,d,s,I)=>{const c="Map"+Pt(o,1);r(0,E,c),r(1,E,c);const $=_(t+I+f,f,o+(k(d)?Ve:a),ut(e,n)+ie,Il,Dt(l,ll,s));_(Oe+t+I+f+ue,Oe+f+ue,tl,ut(e,n,9)+Xt,Dt(Il,Ft(f)+qt+o+" | "+c,Ft(f)+Ce),Dt(l,ll,s,Ut(f)),el,Dt(dl,`cell: ${o} | ${c})`+_e,Ht),rl),_(pe+t+I+f+ue,pe+f+ue,ue,ut(e,n,12),Dt(Il,"forceDel?: boolean"),Dt(l,ll,s,"forceDel"),a,sl,rl),Z(t+I+f+cl,`{rowId, ${G}, debugIds}: `+F+`<'${e}', '${n}'>`,[ne+`('' + ${$}(rowId, `+G+`) ?? '', undefined, debugIds, ${s})`],ut(e,n,13)+ie)}))}));const K=L(S((e=>ae(j,e)?.[4]??a))," | ");_(b+c,b+c,Ue,tt(1,8)+" changes",$l(s),il()),_(C+c,C+c,Ue,rt(2,0,1),$l(i),il()),_(p+c,p+c,Ue,rt(3,0),$l(y,`tableId: ${n} | null`),il("tableId")),_(p+w+c,p+w+c,Ue,rt(14,3,1),$l(T,`tableId: ${n} | null`),il("tableId")),_(m+c,m+c,Ue,rt(4,3,1),$l(V,`tableId: ${n} | null`),il("tableId")),_(g+c,g+c,Ue,rt(13,3,1),$l(x,`tableId: ${n} | null`,"cellId: "+K+Ve,"descending: boolean","offset: number","limit: number"+Ve),il("tableId","cellId","descending","offset","limit")),_(h+c,h+c,Ue,rt(5,3),$l(R,`tableId: ${n} | null`,ll+": IdOrNull"),il("tableId",ll)),_(w+c,w+c,Ue,rt(6,5,1),$l(A,`tableId: ${n} | null`,ll+": IdOrNull"),il("tableId",ll)),_(f+c,f+c,Ue,rt(7,5),$l(O,`tableId: ${n} | null`,ll+": IdOrNull",`cellId: ${K} | null`),il("tableId",ll,"cellId"))}if(!K(t)){const[e,t,l,n,o,s]=d;r(null,E,...d),r(1,E,N);const i=$("getDefaultValueComponent","valueId: Id",L(A(((e,t,l,a,n)=>`valueId == ${a} ? `+n+"ValueView : ")))+se);_(T,T,e,tt(2,0)+ie);const u=_(v,v,l+Ge,at(y,Le)+ie);_(Oe+T+ue,Oe+T+ue,tl,tt(2,9)+Xt,Dt(Ft(T)+qt+t,Ft(T)+Ce),Ut(T),el,Dt(dl,`values: ${t})`+_e,Ht),rl),_(Oe+Re+T+ue,Oe+Re+T+ue,tl,tt(2,11)+Xt,Dt(Ft(Re+T)+qt+t,Ft(Re+T)+Ce),Ut(Re+T),el,Dt(dl,`partialValues: ${t})`+_e,Ht),rl),_(pe+T+ue,pe+T+ue,ue,tt(2,12),a,a,a,sl,rl);const p=I(y+ke,Nt("valueId?: VId",G+ve+N,_t),ot("a Value"),`<VId extends ${l}>`),b=I(T+ke,Nt(G+ve+N,"valueComponents?: {readonly [VId in "+l+`]?: ComponentType<${p}<VId>>;}`,`getValueComponentProps?: (valueId: ${l}) => ExtraProps`,ol,_t),ot(et(2,1)));r(1,D,b,p),Z(T+cl,"{"+G+", valueComponents, getValueComponentProps"+nl+"}: "+b,[ne+`(${u}(${G}).map((valueId) => {`,"const Value = valueComponents?.[valueId] ?? "+i+"(valueId);","return <Value",`{...${te}(getValueComponentProps, valueId)}`,"key={valueId}",J,Zt,"/>;","}), separator)"],tt(2,13)+ie),A(((e,t,l,n,o)=>{const d="Map"+Pt(t,1);r(0,E,d),r(1,E,d);const s=_(o+y,y,t,pt(e)+ie,a,n);_(Oe+o+y+ue,Oe+y+ue,tl,pt(e,9)+Xt,Dt(Ft(y)+qt+t+" | "+d,Ft(y)+Ce),Dt(n,Ut(y)),el,Dt(dl,`value: ${t} | ${d})`+_e,Ht),rl),_(pe+o+y+ue,pe+y+ue,ue,pt(e,12),a,n,a,sl,rl),Z(o+y+cl,`{${G}, debugIds}: ${p}<'${e}'>`,[ne+`('' + ${s}(`+G+`) ?? '', undefined, debugIds, ${n})`],pt(e,13)+ie)})),_(T+c,T+c,Ue,tt(2,8)+" changes",$l(n),il()),_(v+c,v+c,Ue,rt(10,0,1),$l(o),il()),_(y+c,y+c,Ue,rt(11,0),$l(s,`valueId: ${l} | null`),il("valueId"))}return Z(Se,`{${G}, ${G}ById, children}: `+q+" & {children: React.ReactNode}",["{",Kt,"return (","<Context."+Se,"value={useMemo(",`() => [${G} ?? contextValue[0], {...contextValue[1], ...${G}ById}],`,`[${G}, ${G}ById, contextValue],`,")}>","{children}",`</Context.${Se}>`,");","}"],"Wraps part of an application in a context that provides default objects to be used by hooks and components within"),[s(...V(0),...x(),...H(0)),s(...V(1),...R(),...H(1))]},pl=(e,t,l)=>{if(K(e)&&K(t))return[a,a,a,a];const[n,o,d,s]=Bt(e,t,l);return[n,o,...ul(e,t,l,d,s)]},bl=JSON.parse,Cl="prettier/",hl=Cl+"plugins/",ml={parser:"typescript",singleQuote:!0,trailingComma:"all",bracketSpacing:!1,jsdocSingleLineComment:!1},gl=Lt((e=>{const t=()=>{const t=bl(e.getTablesSchemaJson());return!K(t)||O(e.getTableIds(),(l=>{const a=e.getRowIds(l),n=le();if(O(a,(t=>O(e.getCellIds(l,t),(a=>{const o=e.getCell(l,t,a),d=se(n,a,(()=>[D(o),le(),[0],0])),[s,r,[I]]=d,c=se(r,o,(()=>0))+1;return c>I&&(d[2]=[c,o]),de(r,o,c),d[3]++,s==D(o)})))))return t[l]={},ee(n,(([e,,[,n],o],d)=>{t[l][d]={[r]:e,...o==M(a)?{[I]:n}:{}}})),1}))?t:{}},l=()=>{const t=bl(e.getValuesSchemaJson());return K(t)&&e.forEachValue(((e,l)=>{t[e]={[r]:D(l)}})),t},a=e=>pl(t(),l(),e),n=async e=>{const t=["d.ts","ts","d.ts","tsx"],l=[];let n;try{n=(await import(Cl+"standalone")).format,z(l,await import(hl+"estree"),await import(hl+"typescript"))}catch(e){n=async e=>e}return await E(j(a(e),(async(e,a)=>Rt(await n(e,{...ml,plugins:l,filepath:"_."+t[a]})))))};return Z({getStoreStats:t=>{let l=0,a=0,n=0;const o={};return e.forEachTable(((e,d)=>{l++;let s=0,r=0;const I={};d(((e,l)=>{s++;let a=0;l((()=>a++)),r+=a,t&&(I[e]={rowCells:a})})),a+=s,n+=r,t&&(o[e]={tableRows:s,tableCells:r,rows:I})})),{totalTables:l,totalRows:a,totalCells:n,totalValues:M(e.getValueIds()),jsonLength:kt(e.getJson()),...t?{detail:{tables:o}}:{}}},getStoreTablesSchema:t,getStoreValuesSchema:l,getStoreApi:a,getPrettyStoreApi:n,getStore:()=>e})}));e.createTools=gl},"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).TinyBaseTools={});
Binary file
@@ -0,0 +1 @@
1
+ var e,t;e=this,t=function(e){"use strict";const t=(e,t)=>e.map(t),n=(e,...t)=>e.push(...t),o=Promise,l=setInterval,r=clearInterval,i=e=>null==e,u=(e,t,n)=>i(e)?null==n?void 0:n():t(e),d=e=>new o(e),s=e=>{return t=function*(){return o.all(e)},new Promise(((e,n)=>{var o=e=>{try{r(t.next(e))}catch(e){n(e)}},l=e=>{try{r(t.throw(e))}catch(e){n(e)}},r=t=>t.done?e(t.value):Promise.resolve(t.value).then(o,l);r((t=t.apply(void 0,null)).next())}));var t},c=Object,a=c.keys,v=c.freeze,y=e=>(e=>e instanceof c&&e.constructor==c)(e)&&0==(e=>a(e).length)(e),f=e=>new Map(e),h=(e,t)=>null==e?void 0:e.get(t),p=(e,t,n)=>{return i(n)?(l=t,null==(o=e)||o.delete(l),e):null==e?void 0:e.set(t,n);var o,l},x=(e,t,n)=>{var o,l,r;return l=t,null!=(r=null==(o=e)?void 0:o.has(l))&&r||p(e,t,n()),h(e,t)};var g=(e,t,n)=>new Promise(((o,l)=>{var r=e=>{try{u(n.next(e))}catch(e){l(e)}},i=e=>{try{u(n.throw(e))}catch(e){l(e)}},u=e=>e.done?o(e.value):Promise.resolve(e.value).then(r,i);u((n=n.apply(e,t)).next())}));const b=f(),m=f();var w=(e,t,n)=>new Promise(((o,l)=>{var r=e=>{try{u(n.next(e))}catch(e){l(e)}},i=e=>{try{u(n.throw(e))}catch(e){l(e)}},u=e=>e.done?o(e.value):Promise.resolve(e.value).then(r,i);u((n=n.apply(e,t)).next())}));const A=globalThis.window,P=["t","v"],S={keyPath:"k"},j=(e,o)=>w(void 0,null,(function*(){const l=((n,o)=>t(c.entries(n),(([t,n])=>L(e,"put",{k:t,v:n}))))(o);t(yield L(e,"getAllKeys"),(t=>((e,t)=>!i(((e,t)=>u(e,(e=>e[t])))(e,t)))(o,t)?0:n(l,L(e,"delete",t)))),yield s(l)})),L=(e,t,n)=>w(void 0,null,(function*(){return d(((o,l)=>{const r=e[t](n);r.onsuccess=()=>o(r.result),r.onerror=()=>l(`objectStore.${t} error`)}))}));e.createIndexedDbPersister=(e,o,a=1,f)=>{const T=(e,...n)=>w(void 0,[e,...n],(function*(e,n=[],l=0){return d(((r,i)=>{const u=A.indexedDB.open(o,1);u.onupgradeneeded=()=>l&&t(P,(e=>u.result.createObjectStore(e,S))),u.onsuccess=()=>w(void 0,null,(function*(){try{const o=u.result.transaction(P,"readwrite"),l=yield s(t(P,((t,l)=>w(void 0,null,(function*(){return yield e(o.objectStore(t),n[l])})))));u.result.close(),r(l)}catch(e){i(e)}})),u.onerror=()=>i("indexedDB.open error")}))}));return((e,t,o,l,r,d,s=[])=>{let c,a,f,w=0,A=0;x(b,s,(()=>0)),x(m,s,(()=>[]));const P=e=>g(void 0,null,(function*(){return 2!=w&&(w=1,yield S.schedule((()=>g(void 0,null,(function*(){yield e(),w=0}))))),S})),S={load:(n,o)=>g(void 0,null,(function*(){return yield P((()=>g(void 0,null,(function*(){try{e.setContent(yield t())}catch(t){e.setContent([n,o])}}))))})),startAutoLoad:(...n)=>g(void 0,[...n],(function*(n={},o={}){return S.stopAutoLoad(),yield S.load(n,o),A=1,f=l(((n,o)=>g(void 0,null,(function*(){if(o){const t=o();yield P((()=>g(void 0,null,(function*(){return e.setTransactionChanges(t)}))))}else yield P((()=>g(void 0,null,(function*(){var o;try{e.setContent(null!=(o=null==n?void 0:n())?o:yield t())}catch(e){null==d||d(e)}}))))})))),S})),stopAutoLoad:()=>(A&&(r(f),f=void 0,A=0),S),save:t=>g(void 0,null,(function*(){return 1!=w&&(w=2,yield S.schedule((()=>g(void 0,null,(function*(){try{yield o(e.getContent,t)}catch(e){null==d||d(e)}w=0}))))),S})),startAutoSave:()=>g(void 0,null,(function*(){return yield S.stopAutoSave().save(),c=e.addDidFinishTransactionListener(((e,t)=>{const[n,o]=t();y(n)&&y(o)||S.save((()=>[n,o]))})),S})),stopAutoSave:()=>(u(c,e.delListener),S),schedule:(...e)=>g(void 0,null,(function*(){return n(h(m,s),...e),yield g(void 0,null,(function*(){if(!h(b,s)){for(p(b,s,1);!i((e=h(m,s),a=e.shift()));)try{yield a()}catch(e){null==d||d(e)}p(b,s,0)}var e})),S})),getStore:()=>e,destroy:()=>S.stopAutoLoad().stopAutoSave(),getStats:()=>({})};return v(S)})(e,(()=>w(void 0,null,(function*(){return yield T((e=>w(void 0,null,(function*(){return((e=[])=>c.fromEntries(e))(t(yield L(e,"getAll"),(({k:e,v:t})=>[e,t])))}))))}))),(e=>w(void 0,null,(function*(){return yield T(((e,t)=>w(void 0,null,(function*(){return yield j(e,t)}))),e(),1)}))),(e=>l(e,1e3*a)),(e=>r(e)),f)},e.objectStoreMatch=j},"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).TinyBasePersisterIndexedDb={});
@@ -1 +1 @@
1
- var e,t;e=this,t=function(e){"use strict";const t=setInterval,n=clearInterval,o=(e,t)=>e instanceof t,l=e=>null==e,i=Object,r=i.keys,u=i.freeze,d=e=>(e=>o(e,i)&&e.constructor==i)(e)&&0==(e=>r(e).length)(e),s=JSON.parse,a=e=>new Map(e),c=(e,t)=>null==e?void 0:e.get(t),v=(e,t,n)=>{return l(n)?(i=t,null==(o=e)||o.delete(i),e):null==e?void 0:e.set(t,n);var o,i},f=(e,t,n)=>{var o,l,i;return l=t,null!=(i=null==(o=e)?void 0:o.has(l))&&i||v(e,t,n()),c(e,t)};var y=(e,t,n)=>new Promise(((o,l)=>{var i=e=>{try{u(n.next(e))}catch(e){l(e)}},r=e=>{try{u(n.throw(e))}catch(e){l(e)}},u=e=>e.done?o(e.value):Promise.resolve(e.value).then(i,r);u((n=n.apply(e,t)).next())}));const h=a(),p=a();var g=(e,t,n)=>new Promise(((o,l)=>{var i=e=>{try{u(n.next(e))}catch(e){l(e)}},r=e=>{try{u(n.throw(e))}catch(e){l(e)}},u=e=>e.done?o(e.value):Promise.resolve(e.value).then(i,r);u((n=n.apply(e,t)).next())}));const m=e=>e.headers.get("ETag");e.createRemotePersister=(e,r,a,A,S)=>{let x;return((e,t,n,o,i,r,s=[])=>{let a,g,m,A=0,S=0;f(h,s,(()=>0)),f(p,s,(()=>[]));const x=e=>y(void 0,null,(function*(){return 2!=A&&(A=1,yield T.schedule((()=>y(void 0,null,(function*(){yield e(),A=0}))))),T})),T={load:(n,o)=>y(void 0,null,(function*(){return yield x((()=>y(void 0,null,(function*(){try{e.setContent(yield t())}catch(t){e.setContent([n,o])}}))))})),startAutoLoad:(...n)=>y(void 0,[...n],(function*(n={},l={}){return T.stopAutoLoad(),yield T.load(n,l),S=1,m=o(((n,o)=>y(void 0,null,(function*(){if(o){const t=o();yield x((()=>y(void 0,null,(function*(){return e.setTransactionChanges(t)}))))}else yield x((()=>y(void 0,null,(function*(){var o;try{e.setContent(null!=(o=null==n?void 0:n())?o:yield t())}catch(e){null==r||r(e)}}))))})))),T})),stopAutoLoad:()=>(S&&(i(m),m=void 0,S=0),T),save:t=>y(void 0,null,(function*(){return 1!=A&&(A=2,yield T.schedule((()=>y(void 0,null,(function*(){try{yield n(e.getContent,t)}catch(e){null==r||r(e)}A=0}))))),T})),startAutoSave:()=>y(void 0,null,(function*(){return yield T.stopAutoSave().save(),a=e.addDidFinishTransactionListener(((e,t)=>{const[n,o]=t();d(n)&&d(o)||T.save((()=>[n,o]))})),T})),stopAutoSave:()=>{var t,n;return t=a,n=e.delListener,!!l(t)||n(t),T},schedule:(...e)=>y(void 0,null,(function*(){return((e,...t)=>{e.push(...t)})(c(p,s),...e),yield y(void 0,null,(function*(){if(!c(h,s)){for(v(h,s,1);!l((e=c(p,s),g=e.shift()));)try{yield g()}catch(e){null==r||r(e)}v(h,s,0)}var e})),T})),getStore:()=>e,destroy:()=>T.stopAutoLoad().stopAutoSave(),getStats:()=>({})};return u(T)})(e,(()=>g(void 0,null,(function*(){const e=yield fetch(r);return x=m(e),s(yield e.text())}))),(e=>g(void 0,null,(function*(){return yield fetch(a,{method:"POST",headers:{"Content-Type":"application/json"},body:(t=e(),JSON.stringify(t,((e,t)=>o(t,Map)?i.fromEntries([...t]):t)))});var t}))),(e=>t((()=>g(void 0,null,(function*(){const t=yield fetch(r,{method:"HEAD"}),n=m(t);l(x)||l(n)||n==x||(x=n,e())}))),1e3*A)),(e=>n(e)),S)}},"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).TinyBasePersisterRemote={});
1
+ var e,t;e=this,t=function(e){"use strict";const t=setInterval,n=clearInterval,o=(e,t)=>e instanceof t,l=e=>null==e,i=Object,r=i.keys,u=i.freeze,d=e=>(e=>o(e,i)&&e.constructor==i)(e)&&0==(e=>r(e).length)(e),s=JSON.parse,a=e=>new Map(e),c=(e,t)=>null==e?void 0:e.get(t),v=(e,t,n)=>{return l(n)?(i=t,null==(o=e)||o.delete(i),e):null==e?void 0:e.set(t,n);var o,i},f=(e,t,n)=>{var o,l,i;return l=t,null!=(i=null==(o=e)?void 0:o.has(l))&&i||v(e,t,n()),c(e,t)};var y=(e,t,n)=>new Promise(((o,l)=>{var i=e=>{try{u(n.next(e))}catch(e){l(e)}},r=e=>{try{u(n.throw(e))}catch(e){l(e)}},u=e=>e.done?o(e.value):Promise.resolve(e.value).then(i,r);u((n=n.apply(e,t)).next())}));const h=a(),p=a();var g=(e,t,n)=>new Promise(((o,l)=>{var i=e=>{try{u(n.next(e))}catch(e){l(e)}},r=e=>{try{u(n.throw(e))}catch(e){l(e)}},u=e=>e.done?o(e.value):Promise.resolve(e.value).then(i,r);u((n=n.apply(e,t)).next())}));const m=e=>e.headers.get("ETag");e.createRemotePersister=(e,r,a,A=5,S)=>{let x;return((e,t,n,o,i,r,s=[])=>{let a,g,m,A=0,S=0;f(h,s,(()=>0)),f(p,s,(()=>[]));const x=e=>y(void 0,null,(function*(){return 2!=A&&(A=1,yield T.schedule((()=>y(void 0,null,(function*(){yield e(),A=0}))))),T})),T={load:(n,o)=>y(void 0,null,(function*(){return yield x((()=>y(void 0,null,(function*(){try{e.setContent(yield t())}catch(t){e.setContent([n,o])}}))))})),startAutoLoad:(...n)=>y(void 0,[...n],(function*(n={},l={}){return T.stopAutoLoad(),yield T.load(n,l),S=1,m=o(((n,o)=>y(void 0,null,(function*(){if(o){const t=o();yield x((()=>y(void 0,null,(function*(){return e.setTransactionChanges(t)}))))}else yield x((()=>y(void 0,null,(function*(){var o;try{e.setContent(null!=(o=null==n?void 0:n())?o:yield t())}catch(e){null==r||r(e)}}))))})))),T})),stopAutoLoad:()=>(S&&(i(m),m=void 0,S=0),T),save:t=>y(void 0,null,(function*(){return 1!=A&&(A=2,yield T.schedule((()=>y(void 0,null,(function*(){try{yield n(e.getContent,t)}catch(e){null==r||r(e)}A=0}))))),T})),startAutoSave:()=>y(void 0,null,(function*(){return yield T.stopAutoSave().save(),a=e.addDidFinishTransactionListener(((e,t)=>{const[n,o]=t();d(n)&&d(o)||T.save((()=>[n,o]))})),T})),stopAutoSave:()=>{var t,n;return t=a,n=e.delListener,!!l(t)||n(t),T},schedule:(...e)=>y(void 0,null,(function*(){return((e,...t)=>{e.push(...t)})(c(p,s),...e),yield y(void 0,null,(function*(){if(!c(h,s)){for(v(h,s,1);!l((e=c(p,s),g=e.shift()));)try{yield g()}catch(e){null==r||r(e)}v(h,s,0)}var e})),T})),getStore:()=>e,destroy:()=>T.stopAutoLoad().stopAutoSave(),getStats:()=>({})};return u(T)})(e,(()=>g(void 0,null,(function*(){const e=yield fetch(r);return x=m(e),s(yield e.text())}))),(e=>g(void 0,null,(function*(){return yield fetch(a,{method:"POST",headers:{"Content-Type":"application/json"},body:(t=e(),JSON.stringify(t,((e,t)=>o(t,Map)?i.fromEntries([...t]):t)))});var t}))),(e=>t((()=>g(void 0,null,(function*(){const t=yield fetch(r,{method:"HEAD"}),n=m(t);l(x)||l(n)||n==x||(x=n,e())}))),1e3*A)),(e=>n(e)),S)}},"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).TinyBasePersisterRemote={});
@@ -1 +1 @@
1
- var e,t;e=this,t=function(e,t){"use strict";const n=e=>e.length,o=e=>e.shift(),l=e=>null==e,i=(e,t,n)=>l(e)?null==n?void 0:n():t(e),r=Object,u=r.keys,s=r.freeze,d=(e=[])=>r.fromEntries(e),a=(e,t)=>!l(((e,t)=>i(e,(e=>e[t])))(e,t)),c=(e,t)=>((e,t)=>e.map(t))(r.entries(e),(([e,n])=>t(n,e))),v=e=>(e=>e instanceof r&&e.constructor==r)(e)&&0==(e=>n(u(e)))(e),f=(e,t,n)=>(a(e,t)||(e[t]=n()),e[t]),y=e=>new Map(e),h=(e,t)=>null==e?void 0:e.get(t),p=(e,t)=>((e,t)=>null==e?void 0:e.forEach(t))(e,((e,n)=>t(n,e))),g=(e,t,n)=>{return l(n)?(i=t,null==(o=e)||o.delete(i),e):null==e?void 0:e.set(t,n);var o,i},S=(e,t,n)=>{var o,l,i;return l=t,null!=(i=null==(o=e)?void 0:o.has(l))&&i||g(e,t,n()),h(e,t)};var m=(e,t,n)=>new Promise(((o,l)=>{var i=e=>{try{u(n.next(e))}catch(e){l(e)}},r=e=>{try{u(n.throw(e))}catch(e){l(e)}},u=e=>e.done?o(e.value):Promise.resolve(e.value).then(i,r);u((n=n.apply(e,t)).next())}));const w=y(),A=y();var b=(e,t,n)=>new Promise(((o,l)=>{var i=e=>{try{u(n.next(e))}catch(e){l(e)}},r=e=>{try{u(n.throw(e))}catch(e){l(e)}},u=e=>e.done?o(e.value):Promise.resolve(e.value).then(i,r);u((n=n.apply(e,t)).next())}));const j="t",x="delete",O=e=>[e.get(j),e.get("v")],J=(e,n,o,i)=>{var r;const u=l(n)?e:null!=(r=e.get(n))?r:e.set(n,new t.Map);let s;return c(o,((e,t)=>{i(u,t,e)&&(s=1)})),u.forEach(((e,t)=>{a(o,t)||(u.delete(t),s=1)})),l(n)||u.size||e.delete(n),s};e.createYjsPersister=(e,r,u="tinybase",a)=>{const y=r.getMap(u);return((e,t,n,r,u,d,a=[])=>{let c,f,y,p=0,b=0;S(w,a,(()=>0)),S(A,a,(()=>[]));const j=e=>m(void 0,null,(function*(){return 2!=p&&(p=1,yield x.schedule((()=>m(void 0,null,(function*(){yield e(),p=0}))))),x})),x={load:(n,o)=>m(void 0,null,(function*(){return yield j((()=>m(void 0,null,(function*(){try{e.setContent(yield t())}catch(t){e.setContent([n,o])}}))))})),startAutoLoad:(...n)=>m(void 0,[...n],(function*(n={},o={}){return x.stopAutoLoad(),yield x.load(n,o),b=1,y=r(((n,o)=>m(void 0,null,(function*(){if(o){const t=o();yield j((()=>m(void 0,null,(function*(){return e.setTransactionChanges(t)}))))}else yield j((()=>m(void 0,null,(function*(){var o;try{e.setContent(null!=(o=null==n?void 0:n())?o:yield t())}catch(e){null==d||d(e)}}))))})))),x})),stopAutoLoad:()=>(b&&(u(y),y=void 0,b=0),x),save:t=>m(void 0,null,(function*(){return 1!=p&&(p=2,yield x.schedule((()=>m(void 0,null,(function*(){try{yield n(e.getContent,t)}catch(e){null==d||d(e)}p=0}))))),x})),startAutoSave:()=>m(void 0,null,(function*(){return yield x.stopAutoSave().save(),c=e.addDidFinishTransactionListener(((e,t)=>{const[n,o]=t();v(n)&&v(o)||x.save((()=>[n,o]))})),x})),stopAutoSave:()=>(i(c,e.delListener),x),schedule:(...e)=>m(void 0,null,(function*(){return((e,...t)=>{e.push(...t)})(h(A,a),...e),yield m(void 0,null,(function*(){if(!h(w,a)){for(g(w,a,1);!l(f=o(h(A,a)));)try{yield f()}catch(e){null==d||d(e)}g(w,a,0)}})),x})),getStore:()=>e,destroy:()=>x.stopAutoLoad().stopAutoSave(),getStats:()=>({})};return s(x)})(e,(()=>b(void 0,null,(function*(){return y.size?[y.get(j).toJSON(),y.get("v").toJSON()]:void 0}))),((e,n)=>b(void 0,null,(function*(){return r.transact((()=>((e,n,o)=>{(e=>{e.size||(e.set(j,new t.Map),e.set("v",new t.Map))})(e);const[r,u]=O(e),s=()=>{d=1};let d=1;if(i(null==o?void 0:o(),(([e,t])=>{d=0,c(e,((e,t)=>d?0:l(e)?r.delete(t):i(r.get(t),(t=>c(e,((e,n)=>d?0:l(e)?t.delete(n):i(t.get(n),(t=>c(e,((e,n)=>l(e)?t.delete(n):t.set(n,e)))),s)))),s))),c(t,((e,t)=>d?0:l(e)?u.delete(t):u.set(t,e)))})),d){const[e,t]=n();J(r,void 0,e,((e,t,n)=>J(r,t,n,((e,t,n)=>J(e,t,n,((e,t,n)=>{if(e.get(t)!==n)return e.set(t,n),1})))))),J(u,void 0,t,((e,t,n)=>{u.get(t)!==n&&u.set(t,n)}))}})(y,e,n)))}))),(e=>{const t=t=>e(void 0,(()=>((e,t)=>{if(1==n(t)&&(l=t[0].path,0==n(l)))return[e.get("t").toJSON(),e.get("v").toJSON()];var l;const[r,u]=O(e),s={},a={};return((e,t)=>{e.forEach((({path:e,changes:{keys:t}})=>o(e)==j?i(o(e),(n=>{const l=f(s,n,d),u=r.get(n);i(o(e),(e=>{const n=f(l,e,d),o=u.get(e);p(t,((e,{action:t})=>n[e]=t==x?null:o.get(e)))}),(()=>p(t,((e,{action:t})=>{var n;return l[e]=t==x?null:null==(n=u.get(e))?void 0:n.toJSON()}))))}),(()=>p(t,((e,{action:t})=>{var n;return s[e]=t==x?null:null==(n=r.get(e))?void 0:n.toJSON()})))):p(t,((e,{action:t})=>a[e]=t==x?null:u.get(e)))))})(t),[s,a]})(y,t)));return y.observeDeep(t),t}),(e=>{y.unobserveDeep(e)}),a)}},"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("yjs")):"function"==typeof define&&define.amd?define(["exports","yjs"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).TinyBasePersisterYjs={},e.yjs);
1
+ var e,t;e=this,t=function(e,t){"use strict";const n="t",o="v",l=e=>e.length,i=e=>e.shift(),r=e=>null==e,u=(e,t,n)=>r(e)?null==n?void 0:n():t(e),s=Object,d=s.keys,a=s.freeze,c=(e=[])=>s.fromEntries(e),v=(e,t)=>!r(((e,t)=>u(e,(e=>e[t])))(e,t)),f=(e,t)=>((e,t)=>e.map(t))(s.entries(e),(([e,n])=>t(n,e))),y=e=>(e=>e instanceof s&&e.constructor==s)(e)&&0==(e=>l(d(e)))(e),h=(e,t,n)=>(v(e,t)||(e[t]=n()),e[t]),p=e=>new Map(e),g=(e,t)=>null==e?void 0:e.get(t),S=(e,t)=>((e,t)=>null==e?void 0:e.forEach(t))(e,((e,n)=>t(n,e))),m=(e,t,n)=>{return r(n)?(l=t,null==(o=e)||o.delete(l),e):null==e?void 0:e.set(t,n);var o,l},w=(e,t,n)=>{var o,l,i;return l=t,null!=(i=null==(o=e)?void 0:o.has(l))&&i||m(e,t,n()),g(e,t)};var A=(e,t,n)=>new Promise(((o,l)=>{var i=e=>{try{u(n.next(e))}catch(e){l(e)}},r=e=>{try{u(n.throw(e))}catch(e){l(e)}},u=e=>e.done?o(e.value):Promise.resolve(e.value).then(i,r);u((n=n.apply(e,t)).next())}));const b=p(),j=p();var x=(e,t,n)=>new Promise(((o,l)=>{var i=e=>{try{u(n.next(e))}catch(e){l(e)}},r=e=>{try{u(n.throw(e))}catch(e){l(e)}},u=e=>e.done?o(e.value):Promise.resolve(e.value).then(i,r);u((n=n.apply(e,t)).next())}));const O="delete",J=e=>[e.get(n),e.get(o)],L=(e,n,o,l)=>{var i;const u=r(n)?e:null!=(i=e.get(n))?i:e.set(n,new t.Map);let s;return f(o,((e,t)=>{l(u,t,e)&&(s=1)})),u.forEach(((e,t)=>{v(o,t)||(u.delete(t),s=1)})),r(n)||u.size||e.delete(n),s};e.createYjsPersister=(e,s,d="tinybase",v)=>{const p=s.getMap(d);return((e,t,n,o,l,s,d=[])=>{let c,v,f,h=0,p=0;w(b,d,(()=>0)),w(j,d,(()=>[]));const S=e=>A(void 0,null,(function*(){return 2!=h&&(h=1,yield x.schedule((()=>A(void 0,null,(function*(){yield e(),h=0}))))),x})),x={load:(n,o)=>A(void 0,null,(function*(){return yield S((()=>A(void 0,null,(function*(){try{e.setContent(yield t())}catch(t){e.setContent([n,o])}}))))})),startAutoLoad:(...n)=>A(void 0,[...n],(function*(n={},l={}){return x.stopAutoLoad(),yield x.load(n,l),p=1,f=o(((n,o)=>A(void 0,null,(function*(){if(o){const t=o();yield S((()=>A(void 0,null,(function*(){return e.setTransactionChanges(t)}))))}else yield S((()=>A(void 0,null,(function*(){var o;try{e.setContent(null!=(o=null==n?void 0:n())?o:yield t())}catch(e){null==s||s(e)}}))))})))),x})),stopAutoLoad:()=>(p&&(l(f),f=void 0,p=0),x),save:t=>A(void 0,null,(function*(){return 1!=h&&(h=2,yield x.schedule((()=>A(void 0,null,(function*(){try{yield n(e.getContent,t)}catch(e){null==s||s(e)}h=0}))))),x})),startAutoSave:()=>A(void 0,null,(function*(){return yield x.stopAutoSave().save(),c=e.addDidFinishTransactionListener(((e,t)=>{const[n,o]=t();y(n)&&y(o)||x.save((()=>[n,o]))})),x})),stopAutoSave:()=>(u(c,e.delListener),x),schedule:(...e)=>A(void 0,null,(function*(){return((e,...t)=>{e.push(...t)})(g(j,d),...e),yield A(void 0,null,(function*(){if(!g(b,d)){for(m(b,d,1);!r(v=i(g(j,d)));)try{yield v()}catch(e){null==s||s(e)}m(b,d,0)}})),x})),getStore:()=>e,destroy:()=>x.stopAutoLoad().stopAutoSave(),getStats:()=>({})};return a(x)})(e,(()=>x(void 0,null,(function*(){return p.size?[p.get(n).toJSON(),p.get(o).toJSON()]:void 0}))),((e,l)=>x(void 0,null,(function*(){return s.transact((()=>((e,l,i)=>{e.size||(e.set(n,new t.Map),e.set(o,new t.Map));const[s,d]=J(e),a=()=>{c=1};let c=1;if(u(null==i?void 0:i(),(([e,t])=>{c=0,f(e,((e,t)=>c?0:r(e)?s.delete(t):u(s.get(t),(t=>f(e,((e,n)=>c?0:r(e)?t.delete(n):u(t.get(n),(t=>f(e,((e,n)=>r(e)?t.delete(n):t.set(n,e)))),a)))),a))),f(t,((e,t)=>c?0:r(e)?d.delete(t):d.set(t,e)))})),c){const[e,t]=l();L(s,void 0,e,((e,t,n)=>L(s,t,n,((e,t,n)=>L(e,t,n,((e,t,n)=>{if(e.get(t)!==n)return e.set(t,n),1})))))),L(d,void 0,t,((e,t,n)=>{d.get(t)!==n&&d.set(t,n)}))}})(p,e,l)))}))),(e=>{const t=t=>e(void 0,(()=>((e,t)=>{if(1==l(t)&&(r=t[0].path,0==l(r)))return[e.get(n).toJSON(),e.get(o).toJSON()];var r;const[s,d]=J(e),a={},v={};return((e,t)=>{e.forEach((({path:e,changes:{keys:t}})=>i(e)==n?u(i(e),(n=>{const o=h(a,n,c),l=s.get(n);u(i(e),(e=>{const n=h(o,e,c),i=l.get(e);S(t,((e,{action:t})=>n[e]=t==O?null:i.get(e)))}),(()=>S(t,((e,{action:t})=>{var n;return o[e]=t==O?null:null==(n=l.get(e))?void 0:n.toJSON()}))))}),(()=>S(t,((e,{action:t})=>{var n;return a[e]=t==O?null:null==(n=s.get(e))?void 0:n.toJSON()})))):S(t,((e,{action:t})=>v[e]=t==O?null:d.get(e)))))})(t),[a,v]})(p,t)));return p.observeDeep(t),t}),(e=>{p.unobserveDeep(e)}),v)}},"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("yjs")):"function"==typeof define&&define.amd?define(["exports","yjs"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).TinyBasePersisterYjs={},e.yjs);
@@ -1 +1 @@
1
- var e,t;e=this,t=function(e){"use strict";const t=e=>typeof e,l="tinybase",a="",n=",",o=t(a),d=t(!0),r=t(0),s="type",I="default",c="Listener",u="get",$="add",i="Ids",p="Table",b=p+"s",C=p+i,h="Row",m=h+i,f="Sorted"+h+i,g="Cell",w=g+i,y="Value",T=y+"s",v=y+i,V=isFinite,x=(e,t)=>e instanceof t,R=e=>null==e,k=e=>e==o||e==d,P=e=>t(e)==o,S=e=>Array.isArray(e),A=e=>{const l=t(e);return k(l)||l==r&&V(e)?l:void 0},O=(e,t)=>e.every(t),E=(e,t)=>e.sort(t),D=(e,t)=>e.forEach(t),j=(e,t=a)=>e.join(t),N=(e,t)=>e.map(t),G=e=>e.length,L=(e,t)=>e.filter(t),M=(e,...t)=>e.push(...t),J=e=>e.pop(),z=(e,...t)=>e.unshift(...t),W=e=>e.shift(),B=Object,F=B.keys,U=B.freeze,_=e=>x(e,B)&&e.constructor==B,Z=(e,t)=>N(B.entries(e),(([e,l])=>t(l,e))),H=e=>G(F(e)),Q=e=>_(e)&&0==H(e),q=(e,t)=>{var l;return null!=(l=null==e?void 0:e.has(t))&&l},K=e=>{var t;return[...null!=(t=null==e?void 0:e.values())?t:[]]},X=(e,t)=>null==e?void 0:e.forEach(t),Y=(e,t)=>null==e?void 0:e.delete(t),ee=e=>new Map(e),te=(e,t)=>null==e?void 0:e.get(t),le=(e,t)=>X(e,((e,l)=>t(l,e))),ae=(e,t)=>{var l;return N([...null!=(l=null==e?void 0:e.entries())?l:[]],(([e,l])=>t(l,e)))},ne=(e,t,l)=>R(l)?(Y(e,t),e):null==e?void 0:e.set(t,l),oe=(e,t,l)=>(q(e,t)||ne(e,t,l()),te(e,t)),de=e=>e.toUpperCase(),re=e=>e.toLowerCase(),se="a ",Ie="A function for",ce=", and registers a listener so that any changes to that result will cause a re-render",ue="Callback",$e="Del",ie="Deps",pe=ie+"?: React.DependencyList",be="doRollback?: DoRollback",Ce="actions: () => Return, "+be,he="export",me="Id",fe="Invalid",ge="Json",we=re(c),ye="?: ",Te=" | undefined",ve="NonNullable",Ve="Partial",xe="Props",Re="Provider",ke=`Registers a ${we} that will be called`,Pe="Represents",Se="rowId: "+me,Ae="Schema",Oe="Set",Ee=", descending?: boolean, offset?: number, limit?: number",De="[]",je="the Store",Ne="Transaction",Ge=Ne+"Changes",Le=re(Ne),Me="Execute a "+Le+" to make multiple mutations",Je="Explicitly starts a "+Le,ze="Explicitly finishes a "+Le,We="the end of the "+Le,Be="void",Fe=" => "+Be,Ue="WhenSet",_e=" when setting it",Ze=se+"string serialization of",He=" ",Qe="Gets a callback that can ",qe="the ",Ke=" the schema for",Xe=(e=0,t=0)=>`the ${Ct[e]}content of`+(t?He+je:a),Ye=(e=0,t,l=0)=>it[t]+He+Xe(e,1)+(l?" when setting it":a),et=(e,t=0)=>Pe+` a Row when ${t?"s":"g"}etting ${Xe()} the '${e}' `+p,tt=(e,t,l=0)=>`Gets ${l?"sorted, paginated":"the"} Ids of the ${e}s in `+t,lt=(e,t)=>`Calls a function for each ${e} in `+t,at=e=>"The props passed to a component that renders "+e,nt=e=>"A function that takes "+e,ot=(e,t=0)=>Ie+" listening to changes to "+bt[e]+" in "+bt[t],dt=(e,t,l=0)=>ke+" whenever "+bt[e]+" in "+bt[t]+" change"+(l?a:"s"),rt=e=>`the '${e}' `+p,st=e=>"the specified Row in "+rt(e),It=(e,t=0)=>it[t]+` ${Xe()} `+rt(e),ct=(e,t=0)=>it[t]+` ${Xe()} `+st(e),ut=(e,t,l=0)=>it[l]+` the '${t}' Cell for `+st(e),$t=(e,t=0)=>it[t]+` the '${e}' Value`,it=["Gets","Checks existence of","Sets","Deletes","Sets part of",Pe,"Gets "+Ze,"Sets "+Ze,ke+" whenever",Qe+"set",Qe+"add",Qe+"set part of",Qe+"delete","Renders","Gets "+Ze+Ke,"Sets"+Ke,"Deletes"+Ke],pt=[u,"has","set","del","set","forEach",$,a],bt=[je,b,qe+p+He+i,se+p,qe+h+He+i,se+h,qe+g+He+i,se+g,"invalid Cell changes",T,qe+y+He+i,se+y,"invalid Value changes",qe+"sorted "+h+He+i,qe+g+He+i+" anywhere",qe+"number of Rows"],Ct=[a,"tabular ","keyed value "],ht=e=>new Set(S(e)||R(e)?e:[e]),mt=(e,t)=>null==e?void 0:e.add(t),ft=/[^A-Za-z]+/,gt=/[^A-Za-z0-9]+/,wt=/^( *)\/\*\* *(.*?) *\*\/$/gm,yt=(e,t,l)=>e.substring(t,l),Tt=e=>e.includes(n),vt=(e,t,l,a=1)=>{const n=`${t}${1==a?"":a}`;return q(e,n)?vt(e,t,l,a+1):(ne(e,n,l),n)},Vt=e=>e.replace(wt,((e,t,l)=>{const a=77-xt(t);return`${t}/**\n${l.replace(RegExp(`([^\\n]{1,${a}})(\\s|$)`,"g"),t+" * $1\n")}${t} */`})),xt=e=>e.length,Rt=e=>e.flat(1e3),kt=(e,t=0)=>j(N(e.split(gt),((e,l)=>(l>0||t?de:re)(yt(e,0,1))+yt(e,1)))),Pt=e=>de(j((e&&!ft.test(e[0])?e:" "+e).split(gt),"_")),St=e=>`/** ${e}. */`,At=(...e)=>j(L(e,(e=>e)),", "),Ot=(...e)=>"{"+j(e,"; ")+"}",Et=(...e)=>Ot(...N(e,(e=>"readonly "+e))),Dt=()=>{const e=[ee(),ee(),ee(),ee()],t=ee(),l=ee(),n=e=>{const t=e.indexOf(" as ");return-1!=t?e.substring(t+4):e};return[(...e)=>j(Rt(e),"\n"),(t,l,...a)=>D(a,(a=>D([0,1],(n=>(null!=t?t:n)==n?mt(oe(e[n],l,ht),a):0)))),(e,l,n,o=a,d=1)=>vt(t,e,[l,n,o,d]),(e,t,a)=>vt(l,e,S(a)?[`(${t}) => {`,a,"}"]:[`(${t}) => ${a}`]),(e,t)=>te(l,e)===t?e:vt(l,e,t),(t=0)=>N([...E(ae(e[t],((e,t)=>`import {${j(E(K(e),((e,t)=>n(e)>n(t)?1:-1)),", ")}} from '${t}';`)),((e,t)=>Tt(e)!=Tt(t)?Tt(e)?-1:1:e>t?1:-1)),a],(e=>e.replace("{React}","React"))),()=>ae(t,(([e,t,l,n],o)=>[St(t),`${n?he+" ":a}type ${o}${l} = ${e};`,a])),()=>ae(l,((e,t)=>(e=S(e)?e:[e],M(e,J(e)+";"),[`const ${t} = ${W(e)}`,e,a])))]},jt=e=>{const t=new WeakMap;return l=>(t.has(l)||t.set(l,e(l)),t.get(l))},Nt=(e,t,l)=>[t=>Z(e,((e,a)=>t(a,kt(a,1),l(Pt(a),`'${a}'`)))),(t,a)=>Z(e[t],((e,t)=>a(t,e[s],e[I],l(Pt(t),`'${t}'`),kt(t,1)))),e=>Z(t,((t,a)=>e(a,t[s],t[I],l(Pt(a),`'${a}'`),kt(a,1))))],Gt=(e,t,l,n)=>[(n,o)=>{const d=n+": "+o,r=e(b,Ot(...t((e=>`'${e}'?: {[rowId: Id]: `+Ot(...l(e,((e,t,l)=>`'${e}'${R(l)?"?":a}: ${t}`)))+"}"))),Ye(1,5)),s=e(b+Ue,Ot(...t((e=>`'${e}'?: {[rowId: Id]: `+Ot(...l(e,((e,t)=>`'${e}'?: ${t}`)))+"}"))),Ye(1,5,1)),I=e(p+me,"keyof "+r,"A "+p+" Id in "+je),u=`<TId extends ${I}>`,$=e(p,ve+`<${r}[TId]>`,"A "+p+" in "+je,u),i=e(p+Ue,ve+`<${s}[TId]>`,"A "+p+" in "+je+_e,u),y=e(h,$+"<TId>[Id]","A "+h+" in a "+p,u),T=e(h+Ue,i+"<TId>[Id]","A "+h+" in a "+p+_e,u),v=e(g+me,`Extract<keyof ${y}<TId>, Id>`,"A "+g+" Id in a "+h,u),V=e(g,ve+`<${r}[TId]>[Id][CId]`,"A "+g+" in a "+h,`<TId extends ${I}, CId extends ${v}<TId>>`),x=e("CellIdCellArray",`CId extends ${v}<TId> ? [cellId: CId, cell: ${V}<TId, CId>] : never`,g+" Ids and types in a "+h,`<TId extends ${I}, CId = ${v}<TId>>`,0),k=e(g+ue,`(...[cellId, cell]: ${x}<TId>)`+Fe,nt(se+g+" Id, and "+g),u),P=e(h+ue,"(rowId: Id, forEachCell: (cellCallback: CellCallback<TId>) "+Fe+") "+Fe,nt(se+h+" Id, and a "+g+" iterator"),u),S=e(p+g+ue,`(cellId: ${v}<TId>, count: number) `+Fe,nt(se+g+" Id, and count of how many times it appears"),u),A=e("TableIdForEachRowArray",`TId extends ${I} ? [tableId: TId, forEachRow: (rowCallback: ${P}<TId>)${Fe}] : never`,p+" Ids and callback types",`<TId = ${I}>`,0),O=e(p+ue,`(...[tableId, forEachRow]: ${A})`+Fe,nt(se+p+" Id, and a "+h+" iterator"),a),E=e("TableIdRowIdCellIdArray",`TId extends ${I} ? [tableId: TId, rowId: Id, cellId: ${v}<TId>] : never`,"Ids for GetCellChange",`<TId = ${I}>`,0),D=e("GetCellChange",`(...[tableId, rowId, cellId]: ${E}) => CellChange`,Ie+" returning information about any Cell's changes during a "+Le),j=e(b+c,`(${d}, getCellChange: ${D}${Te})`+Fe,ot(1)),N=e(C+c,`(${d})`+Fe,ot(2)),G=e(p+c,`(${d}, tableId: ${I}, getCellChange: ${D}${Te})`+Fe,ot(3)),L=e(p+w+c,`(${d}, tableId: ${I})`+Fe,ot(14,3)),M=e(h+"Count"+c,`(${d}, tableId: ${I})`+Fe,ot(15,3)),J=e(m+c,`(${d}, tableId: ${I})`+Fe,ot(4,3)),z=e(f+c,"("+At(d,"tableId: "+I,"cellId: Id"+Te,"descending: boolean","offset: number","limit: number"+Te,"sortedRowIds: Ids")+")"+Fe,ot(13,3)),W=e(h+c,"("+At(""+d,"tableId: "+I,Se,`getCellChange: ${D}${Te}`)+")"+Fe,ot(5,3)),B=e(w+c,"("+At(""+d,"tableId: "+I,Se)+")"+Fe,ot(6,5)),F=e("CellListenerArgsArrayInner",`CId extends ${v}<TId> ? [${d}, tableId: TId, ${Se}, cellId: CId, newCell: ${V}<TId, CId> ${Te}, oldCell: ${V}<TId, CId> ${Te}, getCellChange: ${D} ${Te}] : never`,"Cell args for CellListener",`<TId extends ${I}, CId = ${v}<TId>>`,0),U=e("CellListenerArgsArrayOuter",`TId extends ${I} ? `+F+"<TId> : never","Table args for CellListener",`<TId = ${I}>`,0);return[r,s,I,$,i,y,T,v,V,k,P,S,O,j,N,G,L,M,J,z,W,B,e(g+c,`(...[${n}, tableId, rowId, cellId, newCell, oldCell, getCellChange]: ${U})`+Fe,ot(7,5)),e(fe+g+c,`(${d}, tableId: Id, ${Se}, cellId: Id, invalidCells: any[])`+Fe,ot(8))]},(t,l)=>{const o=t+": "+l,d=e(T,Ot(...n(((e,t,l)=>`'${e}'${R(l)?"?":a}: ${t}`))),Ye(2,5)),r=e(T+Ue,Ot(...n(((e,t)=>`'${e}'?: ${t}`))),Ye(2,5,1)),s=e(y+me,"keyof "+d,"A "+y+" Id in "+je),I=e(y,ve+`<${d}[VId]>`,"A "+y+" Id in "+je,`<VId extends ${s}>`),u=e("ValueIdValueArray",`VId extends ${s} ? [valueId: VId, value: ${I}<VId>] : never`,y+" Ids and types in "+je,`<VId = ${s}>`,0),$=e(y+ue,`(...[valueId, value]: ${u})`+Fe,nt(se+y+" Id, and "+y)),i=e("GetValueChange",`(valueId: ${s}) => ValueChange`,Ie+" returning information about any Value's changes during a "+Le),p=e(T+c,`(${o}, getValueChange: ${i}${Te})`+Fe,ot(9)),b=e(v+c,`(${o})`+Fe,ot(10)),C=e("ValueListenerArgsArray",`VId extends ${s} ? [${o}, valueId: VId, newValue: ${I}<VId> ${Te}, oldValue: ${I}<VId> ${Te}, getValueChange: ${i} ${Te}] : never`,"Value args for ValueListener",`<VId = ${s}>`,0);return[d,r,s,I,$,p,b,e(y+c,`(...[${t}, valueId, newValue, oldValue, getValueChange]: `+C+")"+Fe,ot(11)),e(fe+y+c,`(${o}, valueId: Id, invalidValues: any[])`+Fe,ot(12))]},(t,l)=>e(Ne+c,`(${t}: ${l}, getTransactionChanges: GetTransactionChanges, getTransactionLog: GetTransactionLog)`+Fe,Ie+" listening to the completion of a "+Le)],Lt=(e,t=a,l=a)=>`store.${e}(${t})`+(l?" as "+l:a),Mt=(e,t=a)=>`fluent(() => ${Lt(e,t)})`,Jt=(e,t=a,l=a)=>`store.${e}(${t?t+", ":a}proxy(listener)${l?", "+l:a})`,zt=(e,t,n)=>{const[o,r,u,V,x,k,S,A]=Dt(),[O,E,N]=Nt(e,t,x),[G,L,J]=Gt(u,O,E,N),W=ee(),B=(e=0)=>ae(W,(([t,l,n,o,d],r)=>{const s=e?[r+`: ${d}(${t}): ${l} => ${n},`]:[r+d+`(${t}): ${l};`];return e||z(s,St(o)),M(s,a),s})),F=(e,t,l,n,o,d=a)=>vt(W,e,[t,l,n,o,d]),U=(e,t,l,n,o,d=a,r=a,s=a)=>F(pt[e]+t+(4==e?Ve:a)+l,d,n,(n==H?Mt:Lt)(pt[e]+(4==e?Ve:a)+l,r,e?void 0:n),o,s),_=(e,t,l,n=a,o=a,d=1,r=a)=>F($+e+c,(n?n+", ":a)+we+": "+t+(d?", mutator?: boolean":a),me,Jt($+e+c,o,d?"mutator":a),l,r),Z=`./${kt(n)}.d`,H=kt(n,1),q=kt(H),X=[],Y=ee();let oe=[],de=[];if(r(1,Z,H,`create${H} as create${H}Decl`),Q(e))r(null,l,b);else{r(0,l,"CellChange"),r(null,l,i);const[e,t,n,o,c,$,y,T,v,V,k,S,A,N,L,J,z,W,B,F,Q,le,ae,de]=G(q,H),re=ee();O(((e,t)=>{const l=`<'${e}'>`,a=[u(t+p,o+l,Pe+` the '${e}' `+p),u(t+p+Ue,c+l,Pe+` the '${e}' `+p+_e),u(t+h,$+l,et(e)),u(t+h+Ue,y+l,et(e,1)),u(t+g+me,T+l,`A Cell Id for the '${e}' `+p),u(t+g+ue,V+l,nt(`a Cell Id and value from a Row in the '${e}' `+p)),u(t+h+ue,k+l,nt(`a Row Id from the '${e}' Table, and a Cell iterator`)),u(t+p+g+ue,S+l,nt(`a Cell Id from anywhere in the '${e}' Table, and a count of how many times it appears`))];ne(re,e,a),r(1,Z,...a)})),r(1,Z,e,t,n,T,A,N,L,J,z,W,B,F,Q,le,ae,de),oe=[e,t,n,T,N,L,J,z,W,B,F,Q,le,ae,re],D([[e],[d],[H,"tables: "+t,"tables"],[H]],(([e,t,l],n)=>U(n,a,b,e,Ye(1,n),t,l))),U(0,a,C,n+De,tt(p,je)),U(5,a,p,Be,lt(p,je),"tableCallback: "+A,"tableCallback as any"),O(((e,t,l)=>{const[n,o,r,s,I,c,u,$]=te(re,e);D([[n],[d],[H,"table: "+o,", table"],[H]],(([n,o,d=a],r)=>U(r,t,p,n,It(e,r),o,l+d))),U(0,t,p+w,i,tt(g,"the whole of "+rt(e)),a,l),U(5,t,p+g,Be,lt(p+g,"the whole of "+rt(e)),"tableCellCallback: "+$,l+", tableCellCallback as any"),U(0,t,h+"Count","number","Gets the number of Rows in the "+rt(e),a,l),U(0,t,m,i,tt(h,rt(e)),a,l),U(0,t,f,i,tt(h,rt(e),1),"cellId?: "+I+Ee,l+", cellId, descending, offset, limit"),U(5,t,h,Be,lt(h,rt(e)),"rowCallback: "+u,l+", rowCallback as any"),D([[r],[d],[H,", row: "+s,", row"],[H],[H,", partialRow: "+s,", partialRow"]],(([n,o=a,d=a],r)=>U(r,t,h,n,ct(e,r),Se+o,l+", rowId"+d))),U(6,t,h,me+Te,"Add a new Row to "+rt(e),"row: "+s+", reuseIds?: boolean",l+", row, reuseIds"),U(0,t,w,I+De,tt(g,st(e)),Se,l+", rowId"),U(5,t,g,Be,lt(g,st(e)),Se+", cellCallback: "+c,l+", rowId, cellCallback as any"),E(e,((n,o,r,s,I)=>{const c="Map"+kt(o,1);ne(Y,o,c);const u=o+(R(r)?Te:a);D([[u],[d],[H,`, cell: ${o} | `+c,", cell as any"],[H]],(([o,d=a,r=a],c)=>U(c,t+I,g,o,ut(e,n,c),Se+d,l+", rowId, "+s+r))),U(1,t+I,p+g,d,it[1]+` the '${n}' Cell anywhere in `+rt(e),a,l+", "+s)}))})),U(0,a,b+ge,ge,Ye(1,6)),U(2,a,b+ge,H,Ye(1,7),"tablesJson: "+ge,"tables"+ge),_(b,N,Ye(1,8)+" changes"),_(C,L,dt(2,0,1)),_(p,J,dt(3,0),`tableId: ${n} | null`,"tableId"),_(p+w,z,dt(14,3,1),`tableId: ${n} | null`,"tableId"),_(h+"Count",W,dt(15,3),`tableId: ${n} | null`,"tableId"),_(m,B,dt(4,3,1),`tableId: ${n} | null`,"tableId"),_(f,F,dt(13,3,1),At("tableId: TId",`cellId: ${T}<TId>`+Te,"descending: boolean","offset: number","limit: number"+Te),At("tableId","cellId","descending","offset","limit"),1,"<TId extends TableId>"),_(h,Q,dt(5,3),`tableId: ${n} | null, rowId: IdOrNull`,"tableId, rowId"),_(w,le,dt(6,5,1),`tableId: ${n} | null, rowId: IdOrNull`,"tableId, rowId"),_(g,ae,dt(7,5),`tableId: ${n} | null, rowId: IdOrNull, cellId: ${j(O((e=>{var t,l;return null!=(l=null==(t=te(re,e))?void 0:t[4])?l:a}))," | ")} | null`,"tableId, rowId, cellId"),_(fe+g,de,ke+" whenever an invalid Cell change was attempted","tableId: IdOrNull, rowId: IdOrNull, cellId: IdOrNull","tableId, rowId, cellId"),r(1,Z,...K(Y)),M(X,".set"+b+Ae+"({",Rt(O(((e,t,l)=>[`[${l}]: {`,...E(e,((e,t,l,n)=>`[${n}]: {[${x(Pt(s),`'${s}'`)}]: ${x(Pt(t),`'${t}'`)}${R(l)?a:`, [${x(Pt(I),`'${I}'`)}]: `+(P(l)?x(Pt(l),`'${l}'`):l)}},`)),"},"]))),"})")}if(Q(t))r(null,l,T);else{const[e,t,n,o,c,u,$,i,p]=L(q,H);r(1,Z,e,t,n,c,u,$,i,p),de=[e,t,n,u,$,i],D([[e],[d],[H,"values: "+t,"values"],[H],[H,"partialValues: "+t,"partialValues"]],(([e,t,l],n)=>U(n,a,T,e,Ye(2,n),t,l))),U(0,a,v,n+De,tt(y,je)),U(5,a,y,"void",lt(y,je),"valueCallback: "+c,"valueCallback as any"),N(((e,t,l,n,o)=>{const r="Map"+kt(t,1);ne(Y,t,r),D([[t],[d],[H,`value: ${t} | `+r,", value as any"],[H]],(([t,l,d=a],r)=>U(r,o,y,t,$t(e,r),l,n+d)))})),U(0,a,T+ge,ge,Ye(2,6)),U(2,a,T+ge,H,Ye(2,7),"valuesJson: "+ge,"values"+ge),_(T,u,Ye(2,8)+" changes"),_(v,$,dt(10,0,1)),_(y,i,dt(11,0),`valueId: ${n} | null`,"valueId"),_(fe+y,p,ke+" whenever an invalid Value change was attempted","valueId: IdOrNull","valueId"),r(1,Z,...K(Y)),r(0,l,"ValueChange"),M(X,".set"+T+Ae+"({",N(((e,t,l,n)=>[`[${n}]: {[${x(Pt(s),`'${s}'`)}]: ${x(Pt(t),`'${t}'`)}${R(l)?a:`, [${x(Pt(I),`'${I}'`)}]: `+(P(l)?x(Pt(l),`'${l}'`):l)}},`])),"})")}U(0,a,"Content",`[${b}, ${T}]`,Ye(0,0)),U(2,a,"Content",H,Ye(0,2),`[tables, values]: [${b}, ${T}]`,"[tables, values]"),U(2,a,Ge,H,`Applies a set of ${Ge} to the Store`,"transactionChanges: "+Ge,"transactionChanges"),le(Y,((e,t)=>u(t,`(cell: ${e}${Te}) => `+e,`Takes a ${e} Cell value and returns another`))),r(null,l,"DoRollback",me,"IdOrNull",ge,"Store",Ge),r(0,l,"Get"+Ge,"GetTransactionLog"),U(0,a,ge,ge,Ye(0,6)),U(2,a,ge,H,Ye(0,7),"tablesAndValuesJson: "+ge,"tablesAndValuesJson"),U(7,a,Le,"Return",Me,Ce,"actions, doRollback","<Return>"),U(7,a,"start"+Ne,H,Je),U(7,a,"finish"+Ne,H,ze,be,"doRollback");const re=J(q,H);return _("Start"+Ne,re,ke+" just before the start of the "+Le,a,a,0),_("WillFinish"+Ne,re,ke+" just before "+We,a,a,0),_("DidFinish"+Ne,re,ke+" just after "+We,a,a,0),U(7,a,"call"+c,H,"Manually provoke a listener to be called","listenerId: Id","listenerId"),U(3,a,c,H,"Remove a listener that was previously added to "+je,"listenerId: Id","listenerId"),F("getStore",a,"Store","store",it[0]+" the underlying Store object"),r(1,l,"createStore"),r(1,Z,H,`create${H} as create${H}Decl`,re),x("store",["createStore()",...X]),V("fluent","actions: () => Store",["actions();",`return ${q};`]),V("proxy","listener: any",`(_: Store, ...params: any[]) => listener(${q}, ...params)`),x(q,["{",...B(1),"}"]),[o(...k(0),...S(),he+" interface "+H+" {",...B(0),"}",a,St(`Creates a ${H} object`),he+" function create"+H+"(): "+H+";"),o(...k(1),he+" const create"+H+": typeof create"+H+"Decl = () => {",...A(),`return Object.freeze(${q});`,"};"),oe,de]},Wt=e=>u+e,Bt=e=>At(Wt(e),Wt(e)+ie),Ft="debugIds?: boolean",Ut="debugIds={debugIds}",_t="then"+pe,Zt="Parameter",Ht=": (parameter: "+Zt+", store: Store) => ",Qt="const contextValue = useContext(Context);",qt=", based on a parameter",Kt=": ",Xt="<"+Zt+",>",Yt=Zt+"ized"+ue+"<"+Zt+">",el="rowId",tl="rowId={rowId}",ll=", separator, debugIds",al="separator?: ReactElement | string",nl="then?: (store: Store",ol=At(nl+")"+Fe,_t),dl="then, then"+ie,rl=el+Kt+me,sl="View",Il=(e,...t)=>At(...t,we+": "+e,we+pe,"mutator?: boolean"),cl=(...e)=>At(...e,we,we+ie,"mutator"),ul=(e,t,n,o,d)=>{const[r,s,I,u,$,V,x,k]=Dt(),[P,S,A]=Nt(e,t,$),O=`./${kt(n)}.d`,E=`./${kt(n)}-ui-react.d`,D="tinybase/ui-react",N=kt(n,1),G=kt(N),L=N+"Or"+N+me,J=G+"Or"+N+me,W=G+`={${G}}`,B=ee(),F=(e,t,l,n,o,d=a)=>(s(1,E,e+" as "+e+"Decl"),vt(B,e,[t,l,n,o,d])),U=(e,t,l,n,o,d=a)=>F("use"+e,t,l,n,o,d),_=(e,t,l,n,o=a,d=a,r=a,I=a,c=a)=>(s(1,D,`use${t} as use${t}Core`),U(e,At(o,X,I),l,le+`(${J}, use${t}Core, [`+(d||a)+(c?"], ["+c:a)+"]);",n,r)),Z=(e,t,l,a)=>F(e,t,1,l,a),H=(e=0)=>ae(B,(([t,l,n,o,d],r)=>{const s=e?[he+` const ${r}: typeof ${r}Decl = ${d}(${t}): ${1==l?"any":l} =>`,n]:[he+` function ${r}${d}(${t}): ${1==l?"ComponentReturnType":l};`];return e||z(s,St(o)),M(s,a),s}));s(null,l,me,"Store",ue,Zt+"ized"+ue),s(0,D,"ComponentReturnType"),s(1,D,"useCellIds"),s(null,D,"ExtraProps"),s(0,O,N);const q=I(L,N+" | "+me,`Used when you need to refer to a ${N} in a React hook or component`),K=I(Re+xe,Et(G+ye+N,G+`ById?: {[${G}Id: Id]: ${N}}`),`Used with the ${Re} component, so that a `+N+" can be passed into the context of an application");s(0,"react","ReactElement","ComponentType"),s(1,"react","React"),s(1,E,q,K);const X=J+ye+q;$("{createContext, useContext, useMemo}","React"),$("Context",`createContext<[${N}?, {[${G}Id: Id]: ${N}}?]>([])`),U("Create"+N,`create: () => ${N}, create`+pe,N,"\n// eslint-disable-next-line react-hooks/exhaustive-deps\nuseMemo(create, createDeps)",`Create a ${N} within a React application with convenient memoization`);const Y=U(N,"id?: Id",N+Te,["{",Qt,"return id == null ? contextValue[0] : contextValue[1]?.[id];","}"],`Get a reference to a ${N} from within a ${Re} component context`),le=u("useHook",J+`: ${q} | undefined, hook: (...params: any[]) => any, preParams: any[], postParams: any[] = []`,[`const ${G} = ${Y}(${J} as Id);`,`return hook(...preParams, ((${J} == null || typeof ${J} == 'string')`,`? ${G} : ${J})?.getStore(), ...postParams)`]),ne=u("getProps","getProps: ((id: any) => ExtraProps) | undefined, id: Id","(getProps == null) ? ({} as ExtraProps) : getProps(id)"),oe=u("wrap",At("children: any","separator?: any","encloseWithId?: boolean","id?: Id"),["const separated = separator==null || !Array.isArray(children)"," ? children"," : children.map((child, c) => (c > 0 ? [separator, child] : child));","return encloseWithId ? [id, ':{', separated, '}'] : separated;"]),de=u("useCustomOrDefaultCellIds",At("customCellIds: Ids | undefined","tableId: Id","rowId: Id",`${J}?: ${q} | undefined`),[`const defaultCellIds = ${le}(${J}, useCellIds, [tableId, rowId]);`,"return customCellIds ?? defaultCellIds;"]),re=$("NullComponent","() => null");if(!Q(e)){const[e,t,n,d,r,$,y,T,v,V,x,k,A,D,L]=o;s(null,O,e,t,n,r,$,y,T,v,V,x,k,A,D),s(0,O,d),s(1,O,N),s(null,l,i,"IdOrNull");const M=u("tableView",`{${G}, rowComponent, getRowComponentProps, customCellIds`+ll+"}: any, rowIds: Ids, tableId: Id, defaultRowComponent: React.ComponentType<any>",["const Row = rowComponent ?? defaultRowComponent;",`return ${oe}(rowIds.map((rowId) => (`,"<Row","{..."+ne+"(getRowComponentProps, rowId)}","key={rowId}","tableId={tableId}",tl,"customCellIds={customCellIds}",W,Ut,"/>","))",ll,", tableId,",");"]),J=u("getDefaultTableComponent","tableId: Id",j(P(((e,t,l)=>`tableId == ${l} ? ${t}TableView : `)))+re),z=u("getDefaultCellComponent","tableId: Id, cellId: Id",j(P(((e,t,l)=>`tableId == ${l} ? ${j(S(e,((e,l,a,n,o)=>`cellId == ${n} ? `+t+o+"CellView : ")))+re} : `)))+re);_(b,b,e,Ye(1,0)+ce);const B=_(C,C,n+De,tt(p,je)+ce);_(Oe+b+ue,Oe+b+ue,Yt,Ye(1,9)+qt,At(Wt(b)+Ht+t,Wt(b)+pe),Bt(b),Xt,At(nl,`tables: ${t})`+Fe,_t),dl),_($e+b+ue,$e+b+ue,ue,Ye(1,12),a,a,a,ol,dl);const F=I(g+xe,Et("tableId?: TId","rowId: Id","cellId?: CId",G+ye+N,Ft),at(se+g),`<TId extends ${n}, CId extends ${d}<TId>>`),U=I(h+xe,Et("tableId?: TId","rowId: Id",G+ye+N,"cellComponents?: {readonly [CId in "+d+`<TId>]?: ComponentType<${F}<TId, CId>>;}`,`getCellComponentProps?: (cellId: ${d}<TId>) => ExtraProps`,`customCellIds?: ${d}<TId>[]`,al,Ft),at(se+h),`<TId extends ${n}>`),H=I(p+xe,Et("tableId?: TId",G+ye+N,`rowComponent?: ComponentType<${U}<TId>>`,"getRowComponentProps?: (rowId: Id) => ExtraProps","customCellIds?: CellId<TId>[]",al,Ft),at(se+p),`<TId extends ${n}>`),Q=I("Sorted"+p+xe,Et("tableId?: TId","cellId?: "+d+"<TId>","descending?: boolean","offset?: number","limit?: number",G+ye+N,`rowComponent?: ComponentType<${U}<TId>>`,"getRowComponentProps?: (rowId: Id) => ExtraProps","customCellIds?: CellId<TId>[]",al,Ft),at(se+"sorted "+p),`<TId extends ${n}>`),q=I(b+xe,Et(G+ye+N,"tableComponents?: {readonly [TId in "+n+`]?: ComponentType<${H}<TId>>;}`,`getTableComponentProps?: (tableId: ${n}) => ExtraProps`,al,Ft),at(Xe(1,1)));s(1,E,q,H,Q,U,F),Z(b+sl,"{"+G+", tableComponents, getTableComponentProps"+ll+"}: "+q,[oe+`(${B}(${G}).map((tableId) => {`,"const Table = (tableComponents?.[tableId] ?? "+J+"(tableId)) as React.ComponentType<TableProps<typeof tableId>>;","return <Table",`{...${ne}(getTableComponentProps, tableId)}`,"tableId={tableId}","key={tableId}",W,Ut,"/>;","}), separator)"],Ye(1,13)+ce),P(((e,t,l)=>{const[n,o,d,r,I]=te(L,e);s(null,O,n,o,d,r,I),_(t+p,p,n,It(e)+ce,a,l),_(t+p+w,p+w,i,tt(g,"the whole of "+rt(e))+ce,a,l);const c=_(t+m,m,i,tt(h,rt(e))+ce,a,l),u=_(t+f,f,i,tt(h,rt(e),1)+ce,"cellId?: "+I+", descending?: boolean, offset?: number, limit?: number",l+", cellId, descending, offset, limit");_(t+h,h,d,ct(e)+ce,rl,At(l,el)),_(t+w,w,I+De,tt(g,st(e))+ce,rl,At(l,el)),_(Oe+t+p+ue,Oe+p+ue,Yt,It(e,9)+qt,At(Wt(p)+Ht+o,Wt(p)+pe),At(l,Bt(p)),Xt,At(nl,`table: ${o})`+Fe,_t),dl),_($e+t+p+ue,$e+p+ue,ue,It(e,12),a,l,a,ol,dl),_(Oe+t+h+ue,Oe+h+ue,Yt,ct(e,9)+qt,At(rl,Wt(h)+Ht+r,Wt(h)+pe),At(l,el,Bt(h)),Xt,At(nl,`row: ${r})`+Fe,_t),dl),_("Add"+t+h+ue,"Add"+h+ue,Yt,ct(e,10)+qt,At(Wt(h)+Ht+r,Wt(h)+pe),At(l,Bt(h)),Xt,"then?: ("+At(rl+Te,"store: Store","row: "+r+")"+Fe,"then"+pe)+", reuseRowIds?: boolean",dl+", reuseRowIds"),_(Oe+t+Ve+h+ue,Oe+Ve+h+ue,Yt,ct(e,11)+qt,At(rl,Wt(Ve+h)+Ht+r,Wt(Ve+h)+pe),At(l,el,Bt(Ve+h)),Xt,At(nl,`partialRow: ${r})`+Fe,_t),dl),_($e+t+h+ue,$e+h+ue,ue,ct(e,12),rl,At(l,el),a,ol,dl);const $=Z(t+h+sl,"{rowId, "+G+", cellComponents, getCellComponentProps, customCellIds"+ll+`}: ${U}<'${e}'>`,[oe+`(${de}(customCellIds, `+l+`, rowId, ${G}).map((cellId: ${I}) => {`,"const Cell = (cellComponents?.[cellId] ?? "+z+`(${l}, cellId)) as React.ComponentType<CellProps<typeof `+l+", typeof cellId>>;","return <Cell",`{...${ne}(getCellComponentProps, cellId)} `,"key={cellId}",`tableId={${l}}`,tl,"cellId={cellId}",W,Ut,"/>;","})"+ll+", rowId)"],ct(e,13)+ce);Z(t+"Sorted"+p+sl,"{cellId, descending, offset, limit, ...props}: "+Q+`<'${e}'>`,M+"(props, "+u+`(cellId, descending, offset, limit, props.${G}), ${l}, ${$});`,It(e,13)+", sorted"+ce),Z(t+p+sl,`props: ${H}<'${e}'>`,M+"(props, "+c+`(props.${G}), ${l}, ${$});`,It(e,13)+ce),S(e,((n,o,d,r,I)=>{const c="Map"+kt(o,1);s(0,O,c),s(1,O,c);const u=_(t+I+g,g,o+(R(d)?Te:a),ut(e,n)+ce,rl,At(l,el,r));_(Oe+t+I+g+ue,Oe+g+ue,Yt,ut(e,n,9)+qt,At(rl,Wt(g)+Ht+o+" | "+c,Wt(g)+pe),At(l,el,r,Bt(g)),Xt,At(nl,`cell: ${o} | ${c})`+Fe,_t),dl),_($e+t+I+g+ue,$e+g+ue,ue,ut(e,n,12),At(rl,"forceDel?: boolean"),At(l,el,r,"forceDel"),a,ol,dl),Z(t+I+g+sl,`{rowId, ${G}, debugIds}: `+F+`<'${e}', '${n}'>`,[oe+`('' + ${u}(rowId, `+G+`) ?? '', undefined, debugIds, ${r})`],ut(e,n,13)+ce)}))}));const K=j(P((e=>{var t,l;return null!=(l=null==(t=te(L,e))?void 0:t[4])?l:a}))," | ");_(b+c,b+c,Be,Ye(1,8)+" changes",Il(r),cl()),_(C+c,C+c,Be,dt(2,0,1),Il($),cl()),_(p+c,p+c,Be,dt(3,0),Il(y,`tableId: ${n} | null`),cl("tableId")),_(p+w+c,p+w+c,Be,dt(14,3,1),Il(T,`tableId: ${n} | null`),cl("tableId")),_(m+c,m+c,Be,dt(4,3,1),Il(V,`tableId: ${n} | null`),cl("tableId")),_(f+c,f+c,Be,dt(13,3,1),Il(x,`tableId: ${n} | null`,"cellId: "+K+Te,"descending: boolean","offset: number","limit: number"+Te),cl("tableId","cellId","descending","offset","limit")),_(h+c,h+c,Be,dt(5,3),Il(k,`tableId: ${n} | null`,el+": IdOrNull"),cl("tableId",el)),_(w+c,w+c,Be,dt(6,5,1),Il(A,`tableId: ${n} | null`,el+": IdOrNull"),cl("tableId",el)),_(g+c,g+c,Be,dt(7,5),Il(D,`tableId: ${n} | null`,el+": IdOrNull",`cellId: ${K} | null`),cl("tableId",el,"cellId"))}if(!Q(t)){const[e,t,l,n,o,r]=d;s(null,O,...d),s(1,O,N);const $=u("getDefaultValueComponent","valueId: Id",j(A(((e,t,l,a,n)=>`valueId == ${a} ? `+n+"ValueView : ")))+re);_(T,T,e,Ye(2,0)+ce);const i=_(v,v,l+De,tt(y,je)+ce);_(Oe+T+ue,Oe+T+ue,Yt,Ye(2,9)+qt,At(Wt(T)+Ht+t,Wt(T)+pe),Bt(T),Xt,At(nl,`values: ${t})`+Fe,_t),dl),_(Oe+Ve+T+ue,Oe+Ve+T+ue,Yt,Ye(2,11)+qt,At(Wt(Ve+T)+Ht+t,Wt(Ve+T)+pe),Bt(Ve+T),Xt,At(nl,`partialValues: ${t})`+Fe,_t),dl),_($e+T+ue,$e+T+ue,ue,Ye(2,12),a,a,a,ol,dl);const p=I(y+xe,Et("valueId?: VId",G+ye+N,Ft),at("a Value"),`<VId extends ${l}>`),b=I(T+xe,Et(G+ye+N,"valueComponents?: {readonly [VId in "+l+`]?: ComponentType<${p}<VId>>;}`,`getValueComponentProps?: (valueId: ${l}) => ExtraProps`,al,Ft),at(Xe(2,1)));s(1,E,b,p),Z(T+sl,"{"+G+", valueComponents, getValueComponentProps"+ll+"}: "+b,[oe+`(${i}(${G}).map((valueId) => {`,"const Value = valueComponents?.[valueId] ?? "+$+"(valueId);","return <Value",`{...${ne}(getValueComponentProps, valueId)}`,"key={valueId}",W,Ut,"/>;","}), separator)"],Ye(2,13)+ce),A(((e,t,l,n,o)=>{const d="Map"+kt(t,1);s(0,O,d),s(1,O,d);const r=_(o+y,y,t,$t(e)+ce,a,n);_(Oe+o+y+ue,Oe+y+ue,Yt,$t(e,9)+qt,At(Wt(y)+Ht+t+" | "+d,Wt(y)+pe),At(n,Bt(y)),Xt,At(nl,`value: ${t} | ${d})`+Fe,_t),dl),_($e+o+y+ue,$e+y+ue,ue,$t(e,12),a,n,a,ol,dl),Z(o+y+sl,`{${G}, debugIds}: ${p}<'${e}'>`,[oe+`('' + ${r}(`+G+`) ?? '', undefined, debugIds, ${n})`],$t(e,13)+ce)})),_(T+c,T+c,Be,Ye(2,8)+" changes",Il(n),cl()),_(v+c,v+c,Be,dt(10,0,1),Il(o),cl()),_(y+c,y+c,Be,dt(11,0),Il(r,`valueId: ${l} | null`),cl("valueId"))}return Z(Re,`{${G}, ${G}ById, children}: `+K+" & {children: React.ReactNode}",["{",Qt,"return (","<Context."+Re,"value={useMemo(",`() => [${G} ?? contextValue[0], {...contextValue[1], ...${G}ById}],`,`[${G}, ${G}ById, contextValue],`,")}>","{children}",`</Context.${Re}>`,");","}"],"Wraps part of an application in a context that provides default objects to be used by hooks and components within"),[r(...V(0),...x(),...H(0)),r(...V(1),...k(),...H(1))]},$l=(e,t,l)=>{if(Q(e)&&Q(t))return[a,a,a,a];const[n,o,d,r]=zt(e,t,l);return[n,o,...ul(e,t,l,d,r)]},il=JSON.parse;var pl=Object.defineProperty,bl=Object.defineProperties,Cl=Object.getOwnPropertyDescriptors,hl=Object.getOwnPropertySymbols,ml=Object.prototype.hasOwnProperty,fl=Object.prototype.propertyIsEnumerable,gl=(e,t,l)=>t in e?pl(e,t,{enumerable:!0,configurable:!0,writable:!0,value:l}):e[t]=l,wl=(e,t)=>{for(var l in t||(t={}))ml.call(t,l)&&gl(e,l,t[l]);if(hl)for(var l of hl(t))fl.call(t,l)&&gl(e,l,t[l]);return e},yl=(e,t)=>bl(e,Cl(t)),Tl=(e,t,l)=>new Promise(((a,n)=>{var o=e=>{try{r(l.next(e))}catch(e){n(e)}},d=e=>{try{r(l.throw(e))}catch(e){n(e)}},r=e=>e.done?a(e.value):Promise.resolve(e.value).then(o,d);r((l=l.apply(e,t)).next())}));const vl={parser:"typescript",singleQuote:!0,trailingComma:"all",bracketSpacing:!1,jsdocSingleLineComment:!1},Vl=jt((e=>{const t=()=>{const t=il(e.getTablesSchemaJson());return!Q(t)||O(e.getTableIds(),(l=>{const a=e.getRowIds(l),n=ee();if(O(a,(t=>O(e.getCellIds(l,t),(a=>{const o=e.getCell(l,t,a),d=oe(n,a,(()=>[A(o),ee(),[0],0])),[r,s,[I]]=d,c=oe(s,o,(()=>0))+1;return c>I&&(d[2]=[c,o]),ne(s,o,c),d[3]++,r==A(o)})))))return t[l]={},X(n,(([e,,[,n],o],d)=>{t[l][d]=wl({[s]:e},o==G(a)?{[I]:n}:{})})),1}))?t:{}},l=()=>{const t=il(e.getValuesSchemaJson());return Q(t)&&e.forEachValue(((e,l)=>{t[e]={[s]:A(l)}})),t},a=e=>$l(t(),l(),e),n=e=>Tl(void 0,null,(function*(){const t=["d.ts","ts","d.ts","tsx"];let l;try{l=(yield import("prettier")).format}catch(e){l=e=>e}return N(a(e),((e,a)=>Vt(l(e,yl(wl({},vl),{filepath:"_."+t[a]})))))}));return U({getStoreStats:t=>{let l=0,a=0,n=0;const o={};return e.forEachTable(((e,d)=>{l++;let r=0,s=0;const I={};d(((e,l)=>{r++;let a=0;l((()=>a++)),s+=a,t&&(I[e]={rowCells:a})})),a+=r,n+=s,t&&(o[e]={tableRows:r,tableCells:s,rows:I})})),wl({totalTables:l,totalRows:a,totalCells:n,totalValues:G(e.getValueIds()),jsonLength:xt(e.getJson())},t?{detail:{tables:o}}:{})},getStoreTablesSchema:t,getStoreValuesSchema:l,getStoreApi:a,getPrettyStoreApi:n,getStore:()=>e})}));e.createTools=Vl},"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).TinyBaseTools={});
1
+ var e,t;e=this,t=function(e){"use strict";const t=e=>typeof e,l="tinybase",n="",a=",",o=t(n),d=t(!0),r=t(0),s="type",I="default",c="Listener",u="get",i="add",$="Ids",p="Table",b=p+"s",C=p+$,h="Row",m=h+$,f="Sorted"+h+$,g="Cell",w=g+$,y="Value",v=y+"s",T=y+$;var x=(e,t,l)=>new Promise(((n,a)=>{var o=e=>{try{r(l.next(e))}catch(e){a(e)}},d=e=>{try{r(l.throw(e))}catch(e){a(e)}},r=e=>e.done?n(e.value):Promise.resolve(e.value).then(o,d);r((l=l.apply(e,t)).next())}));const V=Promise,R=isFinite,P=(e,t)=>e instanceof t,k=e=>null==e,S=e=>e==o||e==d,A=e=>t(e)==o,O=e=>Array.isArray(e),E=e=>x(void 0,null,(function*(){return V.all(e)})),D=e=>{const l=t(e);return S(l)||l==r&&R(e)?l:void 0},j=(e,t)=>e.every(t),N=(e,t)=>e.sort(t),G=(e,t)=>e.forEach(t),L=(e,t=n)=>e.join(t),M=(e,t)=>e.map(t),J=e=>e.length,z=(e,t)=>e.filter(t),W=(e,...t)=>e.push(...t),B=e=>e.pop(),F=(e,...t)=>e.unshift(...t),U=e=>e.shift(),_=Object,Z=_.keys,H=_.freeze,Q=e=>P(e,_)&&e.constructor==_,q=(e,t)=>M(_.entries(e),(([e,l])=>t(l,e))),K=e=>J(Z(e)),X=e=>Q(e)&&0==K(e),Y=(e,t)=>{var l;return null!=(l=null==e?void 0:e.has(t))&&l},ee=e=>{var t;return[...null!=(t=null==e?void 0:e.values())?t:[]]},te=(e,t)=>null==e?void 0:e.forEach(t),le=(e,t)=>null==e?void 0:e.delete(t),ne=e=>new Map(e),ae=(e,t)=>null==e?void 0:e.get(t),oe=(e,t)=>te(e,((e,l)=>t(l,e))),de=(e,t)=>{var l;return M([...null!=(l=null==e?void 0:e.entries())?l:[]],(([e,l])=>t(l,e)))},re=(e,t,l)=>k(l)?(le(e,t),e):null==e?void 0:e.set(t,l),se=(e,t,l)=>(Y(e,t)||re(e,t,l()),ae(e,t)),Ie=e=>e.toUpperCase(),ce=e=>e.toLowerCase(),ue="a ",ie="A function for",$e=", and registers a listener so that any changes to that result will cause a re-render",pe="Callback",be="Del",Ce="Deps",he=Ce+"?: React.DependencyList",me="doRollback?: DoRollback",fe="actions: () => Return, "+me,ge="export",we="Id",ye="Invalid",ve="Json",Te=ce(c),xe="?: ",Ve=" | undefined",Re="NonNullable",Pe="Partial",ke="Props",Se="Provider",Ae=`Registers a ${Te} that will be called`,Oe="Represents",Ee="rowId: "+we,De="Schema",je="Set",Ne=", descending?: boolean, offset?: number, limit?: number",Ge="[]",Le="the Store",Me="Transaction",Je=Me+"Changes",ze=ce(Me),We="Execute a "+ze+" to make multiple mutations",Be="Explicitly starts a "+ze,Fe="Explicitly finishes a "+ze,Ue="the end of the "+ze,_e="void",Ze=" => "+_e,He="WhenSet",Qe=" when setting it",qe=ue+"string serialization of",Ke=" ",Xe="Gets a callback that can ",Ye="the ",et=" the schema for",tt=(e=0,t=0)=>`the ${ft[e]}content of`+(t?Ke+Le:n),lt=(e=0,t,l=0)=>Ct[t]+Ke+tt(e,1)+(l?" when setting it":n),nt=(e,t=0)=>Oe+` a Row when ${t?"s":"g"}etting ${tt()} the '${e}' `+p,at=(e,t,l=0)=>`Gets ${l?"sorted, paginated":"the"} Ids of the ${e}s in `+t,ot=(e,t)=>`Calls a function for each ${e} in `+t,dt=e=>"The props passed to a component that renders "+e,rt=e=>"A function that takes "+e,st=(e,t=0)=>ie+" listening to changes to "+mt[e]+" in "+mt[t],It=(e,t,l=0)=>Ae+" whenever "+mt[e]+" in "+mt[t]+" change"+(l?n:"s"),ct=e=>`the '${e}' `+p,ut=e=>"the specified Row in "+ct(e),it=(e,t=0)=>Ct[t]+` ${tt()} `+ct(e),$t=(e,t=0)=>Ct[t]+` ${tt()} `+ut(e),pt=(e,t,l=0)=>Ct[l]+` the '${t}' Cell for `+ut(e),bt=(e,t=0)=>Ct[t]+` the '${e}' Value`,Ct=["Gets","Checks existence of","Sets","Deletes","Sets part of",Oe,"Gets "+qe,"Sets "+qe,Ae+" whenever",Xe+"set",Xe+"add",Xe+"set part of",Xe+"delete","Renders","Gets "+qe+et,"Sets"+et,"Deletes"+et],ht=[u,"has","set","del","set","forEach",i,n],mt=[Le,b,Ye+p+Ke+$,ue+p,Ye+h+Ke+$,ue+h,Ye+g+Ke+$,ue+g,"invalid Cell changes",v,Ye+y+Ke+$,ue+y,"invalid Value changes",Ye+"sorted "+h+Ke+$,Ye+g+Ke+$+" anywhere",Ye+"number of Rows"],ft=[n,"tabular ","keyed value "],gt=e=>new Set(O(e)||k(e)?e:[e]),wt=(e,t)=>null==e?void 0:e.add(t),yt=/[^A-Za-z]+/,vt=/[^A-Za-z0-9]+/,Tt=/^( *)\/\*\* *(.*?) *\*\/$/gm,xt=(e,t,l)=>e.substring(t,l),Vt=e=>e.includes(a),Rt=(e,t,l,n=1)=>{const a=`${t}${1==n?"":n}`;return Y(e,a)?Rt(e,t,l,n+1):(re(e,a,l),a)},Pt=e=>e.replace(Tt,((e,t,l)=>{const n=77-kt(t);return`${t}/**\n${l.replace(RegExp(`([^\\n]{1,${n}})(\\s|$)`,"g"),t+" * $1\n")}${t} */`})),kt=e=>e.length,St=e=>e.flat(1e3),At=(e,t=0)=>L(M(e.split(vt),((e,l)=>(l>0||t?Ie:ce)(xt(e,0,1))+xt(e,1)))),Ot=e=>Ie(L((e&&!yt.test(e[0])?e:" "+e).split(vt),"_")),Et=e=>`/** ${e}. */`,Dt=(...e)=>L(z(e,(e=>e)),", "),jt=(...e)=>"{"+L(e,"; ")+"}",Nt=(...e)=>jt(...M(e,(e=>"readonly "+e))),Gt=()=>{const e=[ne(),ne(),ne(),ne()],t=ne(),l=ne(),a=e=>{const t=e.indexOf(" as ");return-1!=t?e.substring(t+4):e};return[(...e)=>L(St(e),"\n"),(t,l,...n)=>G(n,(n=>G([0,1],(a=>(null!=t?t:a)==a?wt(se(e[a],l,gt),n):0)))),(e,l,a,o=n,d=1)=>Rt(t,e,[l,a,o,d]),(e,t,n)=>Rt(l,e,O(n)?[`(${t}) => {`,n,"}"]:[`(${t}) => ${n}`]),(e,t)=>ae(l,e)===t?e:Rt(l,e,t),(t=0)=>M([...N(de(e[t],((e,t)=>`import {${L(N(ee(e),((e,t)=>a(e)>a(t)?1:-1)),", ")}} from '${t}';`)),((e,t)=>Vt(e)!=Vt(t)?Vt(e)?-1:1:e>t?1:-1)),n],(e=>e.replace("{React}","React"))),()=>de(t,(([e,t,l,a],o)=>[Et(t),`${a?ge+" ":n}type ${o}${l} = ${e};`,n])),()=>de(l,((e,t)=>(e=O(e)?e:[e],W(e,B(e)+";"),[`const ${t} = ${U(e)}`,e,n])))]},Lt=e=>{const t=new WeakMap;return l=>(t.has(l)||t.set(l,e(l)),t.get(l))},Mt=(e,t,l)=>[t=>q(e,((e,n)=>t(n,At(n,1),l(Ot(n),`'${n}'`)))),(t,n)=>q(e[t],((e,t)=>n(t,e[s],e[I],l(Ot(t),`'${t}'`),At(t,1)))),e=>q(t,((t,n)=>e(n,t[s],t[I],l(Ot(n),`'${n}'`),At(n,1))))],Jt=(e,t,l,a)=>[(a,o)=>{const d=a+": "+o,r=e(b,jt(...t((e=>`'${e}'?: {[rowId: Id]: `+jt(...l(e,((e,t,l)=>`'${e}'${k(l)?"?":n}: ${t}`)))+"}"))),lt(1,5)),s=e(b+He,jt(...t((e=>`'${e}'?: {[rowId: Id]: `+jt(...l(e,((e,t)=>`'${e}'?: ${t}`)))+"}"))),lt(1,5,1)),I=e(p+we,"keyof "+r,"A "+p+" Id in "+Le),u=`<TId extends ${I}>`,i=e(p,Re+`<${r}[TId]>`,"A "+p+" in "+Le,u),$=e(p+He,Re+`<${s}[TId]>`,"A "+p+" in "+Le+Qe,u),y=e(h,i+"<TId>[Id]","A "+h+" in a "+p,u),v=e(h+He,$+"<TId>[Id]","A "+h+" in a "+p+Qe,u),T=e(g+we,`Extract<keyof ${y}<TId>, Id>`,"A "+g+" Id in a "+h,u),x=e(g,Re+`<${r}[TId]>[Id][CId]`,"A "+g+" in a "+h,`<TId extends ${I}, CId extends ${T}<TId>>`),V=e("CellIdCellArray",`CId extends ${T}<TId> ? [cellId: CId, cell: ${x}<TId, CId>] : never`,g+" Ids and types in a "+h,`<TId extends ${I}, CId = ${T}<TId>>`,0),R=e(g+pe,`(...[cellId, cell]: ${V}<TId>)`+Ze,rt(ue+g+" Id, and "+g),u),P=e(h+pe,"(rowId: Id, forEachCell: (cellCallback: CellCallback<TId>) "+Ze+") "+Ze,rt(ue+h+" Id, and a "+g+" iterator"),u),S=e(p+g+pe,`(cellId: ${T}<TId>, count: number) `+Ze,rt(ue+g+" Id, and count of how many times it appears"),u),A=e("TableIdForEachRowArray",`TId extends ${I} ? [tableId: TId, forEachRow: (rowCallback: ${P}<TId>)${Ze}] : never`,p+" Ids and callback types",`<TId = ${I}>`,0),O=e(p+pe,`(...[tableId, forEachRow]: ${A})`+Ze,rt(ue+p+" Id, and a "+h+" iterator"),n),E=e("TableIdRowIdCellIdArray",`TId extends ${I} ? [tableId: TId, rowId: Id, cellId: ${T}<TId>] : never`,"Ids for GetCellChange",`<TId = ${I}>`,0),D=e("GetCellChange",`(...[tableId, rowId, cellId]: ${E}) => CellChange`,ie+" returning information about any Cell's changes during a "+ze),j=e(b+c,`(${d}, getCellChange: ${D}${Ve})`+Ze,st(1)),N=e(C+c,`(${d})`+Ze,st(2)),G=e(p+c,`(${d}, tableId: ${I}, getCellChange: ${D}${Ve})`+Ze,st(3)),L=e(p+w+c,`(${d}, tableId: ${I})`+Ze,st(14,3)),M=e(h+"Count"+c,`(${d}, tableId: ${I})`+Ze,st(15,3)),J=e(m+c,`(${d}, tableId: ${I})`+Ze,st(4,3)),z=e(f+c,"("+Dt(d,"tableId: "+I,"cellId: Id"+Ve,"descending: boolean","offset: number","limit: number"+Ve,"sortedRowIds: Ids")+")"+Ze,st(13,3)),W=e(h+c,"("+Dt(""+d,"tableId: "+I,Ee,`getCellChange: ${D}${Ve}`)+")"+Ze,st(5,3)),B=e(w+c,"("+Dt(""+d,"tableId: "+I,Ee)+")"+Ze,st(6,5)),F=e("CellListenerArgsArrayInner",`CId extends ${T}<TId> ? [${d}, tableId: TId, ${Ee}, cellId: CId, newCell: ${x}<TId, CId> ${Ve}, oldCell: ${x}<TId, CId> ${Ve}, getCellChange: ${D} ${Ve}] : never`,"Cell args for CellListener",`<TId extends ${I}, CId = ${T}<TId>>`,0),U=e("CellListenerArgsArrayOuter",`TId extends ${I} ? `+F+"<TId> : never","Table args for CellListener",`<TId = ${I}>`,0);return[r,s,I,i,$,y,v,T,x,R,P,S,O,j,N,G,L,M,J,z,W,B,e(g+c,`(...[${a}, tableId, rowId, cellId, newCell, oldCell, getCellChange]: ${U})`+Ze,st(7,5)),e(ye+g+c,`(${d}, tableId: Id, ${Ee}, cellId: Id, invalidCells: any[])`+Ze,st(8))]},(t,l)=>{const o=t+": "+l,d=e(v,jt(...a(((e,t,l)=>`'${e}'${k(l)?"?":n}: ${t}`))),lt(2,5)),r=e(v+He,jt(...a(((e,t)=>`'${e}'?: ${t}`))),lt(2,5,1)),s=e(y+we,"keyof "+d,"A "+y+" Id in "+Le),I=e(y,Re+`<${d}[VId]>`,"A "+y+" Id in "+Le,`<VId extends ${s}>`),u=e("ValueIdValueArray",`VId extends ${s} ? [valueId: VId, value: ${I}<VId>] : never`,y+" Ids and types in "+Le,`<VId = ${s}>`,0),i=e(y+pe,`(...[valueId, value]: ${u})`+Ze,rt(ue+y+" Id, and "+y)),$=e("GetValueChange",`(valueId: ${s}) => ValueChange`,ie+" returning information about any Value's changes during a "+ze),p=e(v+c,`(${o}, getValueChange: ${$}${Ve})`+Ze,st(9)),b=e(T+c,`(${o})`+Ze,st(10)),C=e("ValueListenerArgsArray",`VId extends ${s} ? [${o}, valueId: VId, newValue: ${I}<VId> ${Ve}, oldValue: ${I}<VId> ${Ve}, getValueChange: ${$} ${Ve}] : never`,"Value args for ValueListener",`<VId = ${s}>`,0);return[d,r,s,I,i,p,b,e(y+c,`(...[${t}, valueId, newValue, oldValue, getValueChange]: `+C+")"+Ze,st(11)),e(ye+y+c,`(${o}, valueId: Id, invalidValues: any[])`+Ze,st(12))]},(t,l)=>e(Me+c,`(${t}: ${l}, getTransactionChanges: GetTransactionChanges, getTransactionLog: GetTransactionLog)`+Ze,ie+" listening to the completion of a "+ze)],zt=(e,t=n,l=n)=>`store.${e}(${t})`+(l?" as "+l:n),Wt=(e,t=n)=>`fluent(() => ${zt(e,t)})`,Bt=(e,t=n,l=n)=>`store.${e}(${t?t+", ":n}proxy(listener)${l?", "+l:n})`,Ft=(e,t,a)=>{const[o,r,u,x,V,R,P,S]=Gt(),[O,E,D]=Mt(e,t,V),[j,N,M]=Jt(u,O,E,D),J=ne(),z=(e=0)=>de(J,(([t,l,a,o,d],r)=>{const s=e?[r+`: ${d}(${t}): ${l} => ${a},`]:[r+d+`(${t}): ${l};`];return e||F(s,Et(o)),W(s,n),s})),B=(e,t,l,a,o,d=n)=>Rt(J,e,[t,l,a,o,d]),U=(e,t,l,a,o,d=n,r=n,s=n)=>B(ht[e]+t+(4==e?Pe:n)+l,d,a,(a==H?Wt:zt)(ht[e]+(4==e?Pe:n)+l,r,e?void 0:a),o,s),_=(e,t,l,a=n,o=n,d=1,r=n)=>B(i+e+c,(a?a+", ":n)+Te+": "+t+(d?", mutator?: boolean":n),we,Bt(i+e+c,o,d?"mutator":n),l,r),Z=`./${At(a)}.d`,H=At(a,1),Q=At(H),q=[],K=ne();let Y=[],te=[];if(r(1,Z,H,`create${H} as create${H}Decl`),X(e))r(null,l,b);else{r(0,l,"CellChange"),r(null,l,$);const[e,t,a,o,c,i,y,v,T,x,R,P,S,D,N,M,J,z,B,F,X,te,le,oe]=j(Q,H),de=ne();O(((e,t)=>{const l=`<'${e}'>`,n=[u(t+p,o+l,Oe+` the '${e}' `+p),u(t+p+He,c+l,Oe+` the '${e}' `+p+Qe),u(t+h,i+l,nt(e)),u(t+h+He,y+l,nt(e,1)),u(t+g+we,v+l,`A Cell Id for the '${e}' `+p),u(t+g+pe,x+l,rt(`a Cell Id and value from a Row in the '${e}' `+p)),u(t+h+pe,R+l,rt(`a Row Id from the '${e}' Table, and a Cell iterator`)),u(t+p+g+pe,P+l,rt(`a Cell Id from anywhere in the '${e}' Table, and a count of how many times it appears`))];re(de,e,n),r(1,Z,...n)})),r(1,Z,e,t,a,v,S,D,N,M,J,z,B,F,X,te,le,oe),Y=[e,t,a,v,D,N,M,J,z,B,F,X,te,le,de],G([[e],[d],[H,"tables: "+t,"tables"],[H]],(([e,t,l],a)=>U(a,n,b,e,lt(1,a),t,l))),U(0,n,C,a+Ge,at(p,Le)),U(5,n,p,_e,ot(p,Le),"tableCallback: "+S,"tableCallback as any"),O(((e,t,l)=>{const[a,o,r,s,I,c,u,i]=ae(de,e);G([[a],[d],[H,"table: "+o,", table"],[H]],(([a,o,d=n],r)=>U(r,t,p,a,it(e,r),o,l+d))),U(0,t,p+w,$,at(g,"the whole of "+ct(e)),n,l),U(5,t,p+g,_e,ot(p+g,"the whole of "+ct(e)),"tableCellCallback: "+i,l+", tableCellCallback as any"),U(0,t,h+"Count","number","Gets the number of Rows in the "+ct(e),n,l),U(0,t,m,$,at(h,ct(e)),n,l),U(0,t,f,$,at(h,ct(e),1),"cellId?: "+I+Ne,l+", cellId, descending, offset, limit"),U(5,t,h,_e,ot(h,ct(e)),"rowCallback: "+u,l+", rowCallback as any"),G([[r],[d],[H,", row: "+s,", row"],[H],[H,", partialRow: "+s,", partialRow"]],(([a,o=n,d=n],r)=>U(r,t,h,a,$t(e,r),Ee+o,l+", rowId"+d))),U(6,t,h,we+Ve,"Add a new Row to "+ct(e),"row: "+s+", reuseIds?: boolean",l+", row, reuseIds"),U(0,t,w,I+Ge,at(g,ut(e)),Ee,l+", rowId"),U(5,t,g,_e,ot(g,ut(e)),Ee+", cellCallback: "+c,l+", rowId, cellCallback as any"),E(e,((a,o,r,s,I)=>{const c="Map"+At(o,1);re(K,o,c);const u=o+(k(r)?Ve:n);G([[u],[d],[H,`, cell: ${o} | `+c,", cell as any"],[H]],(([o,d=n,r=n],c)=>U(c,t+I,g,o,pt(e,a,c),Ee+d,l+", rowId, "+s+r))),U(1,t+I,p+g,d,Ct[1]+` the '${a}' Cell anywhere in `+ct(e),n,l+", "+s)}))})),U(0,n,b+ve,ve,lt(1,6)),U(2,n,b+ve,H,lt(1,7),"tablesJson: "+ve,"tables"+ve),_(b,D,lt(1,8)+" changes"),_(C,N,It(2,0,1)),_(p,M,It(3,0),`tableId: ${a} | null`,"tableId"),_(p+w,J,It(14,3,1),`tableId: ${a} | null`,"tableId"),_(h+"Count",z,It(15,3),`tableId: ${a} | null`,"tableId"),_(m,B,It(4,3,1),`tableId: ${a} | null`,"tableId"),_(f,F,It(13,3,1),Dt("tableId: TId",`cellId: ${v}<TId>`+Ve,"descending: boolean","offset: number","limit: number"+Ve),Dt("tableId","cellId","descending","offset","limit"),1,"<TId extends TableId>"),_(h,X,It(5,3),`tableId: ${a} | null, rowId: IdOrNull`,"tableId, rowId"),_(w,te,It(6,5,1),`tableId: ${a} | null, rowId: IdOrNull`,"tableId, rowId"),_(g,le,It(7,5),`tableId: ${a} | null, rowId: IdOrNull, cellId: ${L(O((e=>{var t,l;return null!=(l=null==(t=ae(de,e))?void 0:t[4])?l:n}))," | ")} | null`,"tableId, rowId, cellId"),_(ye+g,oe,Ae+" whenever an invalid Cell change was attempted","tableId: IdOrNull, rowId: IdOrNull, cellId: IdOrNull","tableId, rowId, cellId"),r(1,Z,...ee(K)),W(q,".set"+b+De+"({",St(O(((e,t,l)=>[`[${l}]: {`,...E(e,((e,t,l,a)=>`[${a}]: {[${V(Ot(s),`'${s}'`)}]: ${V(Ot(t),`'${t}'`)}${k(l)?n:`, [${V(Ot(I),`'${I}'`)}]: `+(A(l)?V(Ot(l),`'${l}'`):l)}},`)),"},"]))),"})")}if(X(t))r(null,l,v);else{const[e,t,a,o,c,u,i,$,p]=N(Q,H);r(1,Z,e,t,a,c,u,i,$,p),te=[e,t,a,u,i,$],G([[e],[d],[H,"values: "+t,"values"],[H],[H,"partialValues: "+t,"partialValues"]],(([e,t,l],a)=>U(a,n,v,e,lt(2,a),t,l))),U(0,n,T,a+Ge,at(y,Le)),U(5,n,y,"void",ot(y,Le),"valueCallback: "+c,"valueCallback as any"),D(((e,t,l,a,o)=>{const r="Map"+At(t,1);re(K,t,r),G([[t],[d],[H,`value: ${t} | `+r,", value as any"],[H]],(([t,l,d=n],r)=>U(r,o,y,t,bt(e,r),l,a+d)))})),U(0,n,v+ve,ve,lt(2,6)),U(2,n,v+ve,H,lt(2,7),"valuesJson: "+ve,"values"+ve),_(v,u,lt(2,8)+" changes"),_(T,i,It(10,0,1)),_(y,$,It(11,0),`valueId: ${a} | null`,"valueId"),_(ye+y,p,Ae+" whenever an invalid Value change was attempted","valueId: IdOrNull","valueId"),r(1,Z,...ee(K)),r(0,l,"ValueChange"),W(q,".set"+v+De+"({",D(((e,t,l,a)=>[`[${a}]: {[${V(Ot(s),`'${s}'`)}]: ${V(Ot(t),`'${t}'`)}${k(l)?n:`, [${V(Ot(I),`'${I}'`)}]: `+(A(l)?V(Ot(l),`'${l}'`):l)}},`])),"})")}U(0,n,"Content",`[${b}, ${v}]`,lt(0,0)),U(2,n,"Content",H,lt(0,2),`[tables, values]: [${b}, ${v}]`,"[tables, values]"),U(2,n,Je,H,`Applies a set of ${Je} to the Store`,"transactionChanges: "+Je,"transactionChanges"),oe(K,((e,t)=>u(t,`(cell: ${e}${Ve}) => `+e,`Takes a ${e} Cell value and returns another`))),r(null,l,"DoRollback",we,"IdOrNull",ve,"Store",Je),r(0,l,"Get"+Je,"GetTransactionLog"),U(0,n,ve,ve,lt(0,6)),U(2,n,ve,H,lt(0,7),"tablesAndValuesJson: "+ve,"tablesAndValuesJson"),U(7,n,ze,"Return",We,fe,"actions, doRollback","<Return>"),U(7,n,"start"+Me,H,Be),U(7,n,"finish"+Me,H,Fe,me,"doRollback");const le=M(Q,H);return _("Start"+Me,le,Ae+" just before the start of the "+ze,n,n,0),_("WillFinish"+Me,le,Ae+" just before "+Ue,n,n,0),_("DidFinish"+Me,le,Ae+" just after "+Ue,n,n,0),U(7,n,"call"+c,H,"Manually provoke a listener to be called","listenerId: Id","listenerId"),U(3,n,c,H,"Remove a listener that was previously added to "+Le,"listenerId: Id","listenerId"),B("getStore",n,"Store","store",Ct[0]+" the underlying Store object"),r(1,l,"createStore"),r(1,Z,H,`create${H} as create${H}Decl`,le),V("store",["createStore()",...q]),x("fluent","actions: () => Store",["actions();",`return ${Q};`]),x("proxy","listener: any",`(_: Store, ...params: any[]) => listener(${Q}, ...params)`),V(Q,["{",...z(1),"}"]),[o(...R(0),...P(),ge+" interface "+H+" {",...z(0),"}",n,Et(`Creates a ${H} object`),ge+" function create"+H+"(): "+H+";"),o(...R(1),ge+" const create"+H+": typeof create"+H+"Decl = () => {",...S(),`return Object.freeze(${Q});`,"};"),Y,te]},Ut=e=>u+e,_t=e=>Dt(Ut(e),Ut(e)+Ce),Zt="debugIds?: boolean",Ht="debugIds={debugIds}",Qt="then"+he,qt="Parameter",Kt=": (parameter: "+qt+", store: Store) => ",Xt="const contextValue = useContext(Context);",Yt=", based on a parameter",el=": ",tl="<"+qt+",>",ll=qt+"ized"+pe+"<"+qt+">",nl="rowId",al="rowId={rowId}",ol=", separator, debugIds",dl="separator?: ReactElement | string",rl="then?: (store: Store",sl=Dt(rl+")"+Ze,Qt),Il="then, then"+Ce,cl=nl+el+we,ul="View",il=(e,...t)=>Dt(...t,Te+": "+e,Te+he,"mutator?: boolean"),$l=(...e)=>Dt(...e,Te,Te+Ce,"mutator"),pl=(e,t,a,o,d)=>{const[r,s,I,u,i,x,V,R]=Gt(),[P,S,A]=Mt(e,t,i),O=`./${At(a)}.d`,E=`./${At(a)}-ui-react.d`,D="tinybase/ui-react",j=At(a,1),N=At(j),G=j+"Or"+j+we,M=N+"Or"+j+we,J=N+`={${N}}`,z=ne(),B=(e,t,l,a,o,d=n)=>(s(1,E,e+" as "+e+"Decl"),Rt(z,e,[t,l,a,o,d])),U=(e,t,l,a,o,d=n)=>B("use"+e,t,l,a,o,d),_=(e,t,l,a,o=n,d=n,r=n,I=n,c=n)=>(s(1,D,`use${t} as use${t}Core`),U(e,Dt(o,K,I),l,ee+`(${M}, use${t}Core, [`+(d||n)+(c?"], ["+c:n)+"]);",a,r)),Z=(e,t,l,n)=>B(e,t,1,l,n),H=(e=0)=>de(z,(([t,l,a,o,d],r)=>{const s=e?[ge+` const ${r}: typeof ${r}Decl = ${d}(${t}): ${1==l?"any":l} =>`,a]:[ge+` function ${r}${d}(${t}): ${1==l?"ComponentReturnType":l};`];return e||F(s,Et(o)),W(s,n),s}));s(null,l,we,"Store",pe,qt+"ized"+pe),s(0,D,"ComponentReturnType"),s(1,D,"useCellIds"),s(null,D,"ExtraProps"),s(0,O,j);const Q=I(G,j+" | "+we,`Used when you need to refer to a ${j} in a React hook or component`),q=I(Se+ke,Nt(N+xe+j,N+`ById?: {[${N}Id: Id]: ${j}}`),`Used with the ${Se} component, so that a `+j+" can be passed into the context of an application");s(0,"react","ReactElement","ComponentType"),s(1,"react","React"),s(1,E,Q,q);const K=M+xe+Q;i("{createContext, useContext, useMemo}","React"),i("Context",`createContext<[${j}?, {[${N}Id: Id]: ${j}}?]>([])`),U("Create"+j,`create: () => ${j}, create`+he,j,"\n// eslint-disable-next-line react-hooks/exhaustive-deps\nuseMemo(create, createDeps)",`Create a ${j} within a React application with convenient memoization`);const Y=U(j,"id?: Id",j+Ve,["{",Xt,"return id == null ? contextValue[0] : contextValue[1]?.[id];","}"],`Get a reference to a ${j} from within a ${Se} component context`),ee=u("useHook",M+`: ${Q} | undefined, hook: (...params: any[]) => any, preParams: any[], postParams: any[] = []`,[`const ${N} = ${Y}(${M} as Id);`,`return hook(...preParams, ((${M} == null || typeof ${M} == 'string')`,`? ${N} : ${M})?.getStore(), ...postParams)`]),te=u("getProps","getProps: ((id: any) => ExtraProps) | undefined, id: Id","(getProps == null) ? ({} as ExtraProps) : getProps(id)"),le=u("wrap",Dt("children: any","separator?: any","encloseWithId?: boolean","id?: Id"),["const separated = separator==null || !Array.isArray(children)"," ? children"," : children.map((child, c) => (c > 0 ? [separator, child] : child));","return encloseWithId ? [id, ':{', separated, '}'] : separated;"]),oe=u("useCustomOrDefaultCellIds",Dt("customCellIds: Ids | undefined","tableId: Id","rowId: Id",`${M}?: ${Q} | undefined`),[`const defaultCellIds = ${ee}(${M}, useCellIds, [tableId, rowId]);`,"return customCellIds ?? defaultCellIds;"]),re=i("NullComponent","() => null");if(!X(e)){const[e,t,a,d,r,i,y,v,T,x,V,R,A,D,G]=o;s(null,O,e,t,a,r,i,y,v,T,x,V,R,A,D),s(0,O,d),s(1,O,j),s(null,l,$,"IdOrNull");const M=u("tableView",`{${N}, rowComponent, getRowComponentProps, customCellIds`+ol+"}: any, rowIds: Ids, tableId: Id, defaultRowComponent: React.ComponentType<any>",["const Row = rowComponent ?? defaultRowComponent;",`return ${le}(rowIds.map((rowId) => (`,"<Row","{..."+te+"(getRowComponentProps, rowId)}","key={rowId}","tableId={tableId}",al,"customCellIds={customCellIds}",J,Ht,"/>","))",ol,", tableId,",");"]),z=u("getDefaultTableComponent","tableId: Id",L(P(((e,t,l)=>`tableId == ${l} ? ${t}TableView : `)))+re),W=u("getDefaultCellComponent","tableId: Id, cellId: Id",L(P(((e,t,l)=>`tableId == ${l} ? ${L(S(e,((e,l,n,a,o)=>`cellId == ${a} ? `+t+o+"CellView : ")))+re} : `)))+re);_(b,b,e,lt(1,0)+$e);const B=_(C,C,a+Ge,at(p,Le)+$e);_(je+b+pe,je+b+pe,ll,lt(1,9)+Yt,Dt(Ut(b)+Kt+t,Ut(b)+he),_t(b),tl,Dt(rl,`tables: ${t})`+Ze,Qt),Il),_(be+b+pe,be+b+pe,pe,lt(1,12),n,n,n,sl,Il);const F=I(g+ke,Nt("tableId?: TId","rowId: Id","cellId?: CId",N+xe+j,Zt),dt(ue+g),`<TId extends ${a}, CId extends ${d}<TId>>`),U=I(h+ke,Nt("tableId?: TId","rowId: Id",N+xe+j,"cellComponents?: {readonly [CId in "+d+`<TId>]?: ComponentType<${F}<TId, CId>>;}`,`getCellComponentProps?: (cellId: ${d}<TId>) => ExtraProps`,`customCellIds?: ${d}<TId>[]`,dl,Zt),dt(ue+h),`<TId extends ${a}>`),H=I(p+ke,Nt("tableId?: TId",N+xe+j,`rowComponent?: ComponentType<${U}<TId>>`,"getRowComponentProps?: (rowId: Id) => ExtraProps","customCellIds?: CellId<TId>[]",dl,Zt),dt(ue+p),`<TId extends ${a}>`),Q=I("Sorted"+p+ke,Nt("tableId?: TId","cellId?: "+d+"<TId>","descending?: boolean","offset?: number","limit?: number",N+xe+j,`rowComponent?: ComponentType<${U}<TId>>`,"getRowComponentProps?: (rowId: Id) => ExtraProps","customCellIds?: CellId<TId>[]",dl,Zt),dt(ue+"sorted "+p),`<TId extends ${a}>`),q=I(b+ke,Nt(N+xe+j,"tableComponents?: {readonly [TId in "+a+`]?: ComponentType<${H}<TId>>;}`,`getTableComponentProps?: (tableId: ${a}) => ExtraProps`,dl,Zt),dt(tt(1,1)));s(1,E,q,H,Q,U,F),Z(b+ul,"{"+N+", tableComponents, getTableComponentProps"+ol+"}: "+q,[le+`(${B}(${N}).map((tableId) => {`,"const Table = (tableComponents?.[tableId] ?? "+z+"(tableId)) as React.ComponentType<TableProps<typeof tableId>>;","return <Table",`{...${te}(getTableComponentProps, tableId)}`,"tableId={tableId}","key={tableId}",J,Ht,"/>;","}), separator)"],lt(1,13)+$e),P(((e,t,l)=>{const[a,o,d,r,I]=ae(G,e);s(null,O,a,o,d,r,I),_(t+p,p,a,it(e)+$e,n,l),_(t+p+w,p+w,$,at(g,"the whole of "+ct(e))+$e,n,l);const c=_(t+m,m,$,at(h,ct(e))+$e,n,l),u=_(t+f,f,$,at(h,ct(e),1)+$e,"cellId?: "+I+", descending?: boolean, offset?: number, limit?: number",l+", cellId, descending, offset, limit");_(t+h,h,d,$t(e)+$e,cl,Dt(l,nl)),_(t+w,w,I+Ge,at(g,ut(e))+$e,cl,Dt(l,nl)),_(je+t+p+pe,je+p+pe,ll,it(e,9)+Yt,Dt(Ut(p)+Kt+o,Ut(p)+he),Dt(l,_t(p)),tl,Dt(rl,`table: ${o})`+Ze,Qt),Il),_(be+t+p+pe,be+p+pe,pe,it(e,12),n,l,n,sl,Il),_(je+t+h+pe,je+h+pe,ll,$t(e,9)+Yt,Dt(cl,Ut(h)+Kt+r,Ut(h)+he),Dt(l,nl,_t(h)),tl,Dt(rl,`row: ${r})`+Ze,Qt),Il),_("Add"+t+h+pe,"Add"+h+pe,ll,$t(e,10)+Yt,Dt(Ut(h)+Kt+r,Ut(h)+he),Dt(l,_t(h)),tl,"then?: ("+Dt(cl+Ve,"store: Store","row: "+r+")"+Ze,"then"+he)+", reuseRowIds?: boolean",Il+", reuseRowIds"),_(je+t+Pe+h+pe,je+Pe+h+pe,ll,$t(e,11)+Yt,Dt(cl,Ut(Pe+h)+Kt+r,Ut(Pe+h)+he),Dt(l,nl,_t(Pe+h)),tl,Dt(rl,`partialRow: ${r})`+Ze,Qt),Il),_(be+t+h+pe,be+h+pe,pe,$t(e,12),cl,Dt(l,nl),n,sl,Il);const i=Z(t+h+ul,"{rowId, "+N+", cellComponents, getCellComponentProps, customCellIds"+ol+`}: ${U}<'${e}'>`,[le+`(${oe}(customCellIds, `+l+`, rowId, ${N}).map((cellId: ${I}) => {`,"const Cell = (cellComponents?.[cellId] ?? "+W+`(${l}, cellId)) as React.ComponentType<CellProps<typeof `+l+", typeof cellId>>;","return <Cell",`{...${te}(getCellComponentProps, cellId)} `,"key={cellId}",`tableId={${l}}`,al,"cellId={cellId}",J,Ht,"/>;","})"+ol+", rowId)"],$t(e,13)+$e);Z(t+"Sorted"+p+ul,"{cellId, descending, offset, limit, ...props}: "+Q+`<'${e}'>`,M+"(props, "+u+`(cellId, descending, offset, limit, props.${N}), ${l}, ${i});`,it(e,13)+", sorted"+$e),Z(t+p+ul,`props: ${H}<'${e}'>`,M+"(props, "+c+`(props.${N}), ${l}, ${i});`,it(e,13)+$e),S(e,((a,o,d,r,I)=>{const c="Map"+At(o,1);s(0,O,c),s(1,O,c);const u=_(t+I+g,g,o+(k(d)?Ve:n),pt(e,a)+$e,cl,Dt(l,nl,r));_(je+t+I+g+pe,je+g+pe,ll,pt(e,a,9)+Yt,Dt(cl,Ut(g)+Kt+o+" | "+c,Ut(g)+he),Dt(l,nl,r,_t(g)),tl,Dt(rl,`cell: ${o} | ${c})`+Ze,Qt),Il),_(be+t+I+g+pe,be+g+pe,pe,pt(e,a,12),Dt(cl,"forceDel?: boolean"),Dt(l,nl,r,"forceDel"),n,sl,Il),Z(t+I+g+ul,`{rowId, ${N}, debugIds}: `+F+`<'${e}', '${a}'>`,[le+`('' + ${u}(rowId, `+N+`) ?? '', undefined, debugIds, ${r})`],pt(e,a,13)+$e)}))}));const K=L(P((e=>{var t,l;return null!=(l=null==(t=ae(G,e))?void 0:t[4])?l:n}))," | ");_(b+c,b+c,_e,lt(1,8)+" changes",il(r),$l()),_(C+c,C+c,_e,It(2,0,1),il(i),$l()),_(p+c,p+c,_e,It(3,0),il(y,`tableId: ${a} | null`),$l("tableId")),_(p+w+c,p+w+c,_e,It(14,3,1),il(v,`tableId: ${a} | null`),$l("tableId")),_(m+c,m+c,_e,It(4,3,1),il(x,`tableId: ${a} | null`),$l("tableId")),_(f+c,f+c,_e,It(13,3,1),il(V,`tableId: ${a} | null`,"cellId: "+K+Ve,"descending: boolean","offset: number","limit: number"+Ve),$l("tableId","cellId","descending","offset","limit")),_(h+c,h+c,_e,It(5,3),il(R,`tableId: ${a} | null`,nl+": IdOrNull"),$l("tableId",nl)),_(w+c,w+c,_e,It(6,5,1),il(A,`tableId: ${a} | null`,nl+": IdOrNull"),$l("tableId",nl)),_(g+c,g+c,_e,It(7,5),il(D,`tableId: ${a} | null`,nl+": IdOrNull",`cellId: ${K} | null`),$l("tableId",nl,"cellId"))}if(!X(t)){const[e,t,l,a,o,r]=d;s(null,O,...d),s(1,O,j);const i=u("getDefaultValueComponent","valueId: Id",L(A(((e,t,l,n,a)=>`valueId == ${n} ? `+a+"ValueView : ")))+re);_(v,v,e,lt(2,0)+$e);const $=_(T,T,l+Ge,at(y,Le)+$e);_(je+v+pe,je+v+pe,ll,lt(2,9)+Yt,Dt(Ut(v)+Kt+t,Ut(v)+he),_t(v),tl,Dt(rl,`values: ${t})`+Ze,Qt),Il),_(je+Pe+v+pe,je+Pe+v+pe,ll,lt(2,11)+Yt,Dt(Ut(Pe+v)+Kt+t,Ut(Pe+v)+he),_t(Pe+v),tl,Dt(rl,`partialValues: ${t})`+Ze,Qt),Il),_(be+v+pe,be+v+pe,pe,lt(2,12),n,n,n,sl,Il);const p=I(y+ke,Nt("valueId?: VId",N+xe+j,Zt),dt("a Value"),`<VId extends ${l}>`),b=I(v+ke,Nt(N+xe+j,"valueComponents?: {readonly [VId in "+l+`]?: ComponentType<${p}<VId>>;}`,`getValueComponentProps?: (valueId: ${l}) => ExtraProps`,dl,Zt),dt(tt(2,1)));s(1,E,b,p),Z(v+ul,"{"+N+", valueComponents, getValueComponentProps"+ol+"}: "+b,[le+`(${$}(${N}).map((valueId) => {`,"const Value = valueComponents?.[valueId] ?? "+i+"(valueId);","return <Value",`{...${te}(getValueComponentProps, valueId)}`,"key={valueId}",J,Ht,"/>;","}), separator)"],lt(2,13)+$e),A(((e,t,l,a,o)=>{const d="Map"+At(t,1);s(0,O,d),s(1,O,d);const r=_(o+y,y,t,bt(e)+$e,n,a);_(je+o+y+pe,je+y+pe,ll,bt(e,9)+Yt,Dt(Ut(y)+Kt+t+" | "+d,Ut(y)+he),Dt(a,_t(y)),tl,Dt(rl,`value: ${t} | ${d})`+Ze,Qt),Il),_(be+o+y+pe,be+y+pe,pe,bt(e,12),n,a,n,sl,Il),Z(o+y+ul,`{${N}, debugIds}: ${p}<'${e}'>`,[le+`('' + ${r}(`+N+`) ?? '', undefined, debugIds, ${a})`],bt(e,13)+$e)})),_(v+c,v+c,_e,lt(2,8)+" changes",il(a),$l()),_(T+c,T+c,_e,It(10,0,1),il(o),$l()),_(y+c,y+c,_e,It(11,0),il(r,`valueId: ${l} | null`),$l("valueId"))}return Z(Se,`{${N}, ${N}ById, children}: `+q+" & {children: React.ReactNode}",["{",Xt,"return (","<Context."+Se,"value={useMemo(",`() => [${N} ?? contextValue[0], {...contextValue[1], ...${N}ById}],`,`[${N}, ${N}ById, contextValue],`,")}>","{children}",`</Context.${Se}>`,");","}"],"Wraps part of an application in a context that provides default objects to be used by hooks and components within"),[r(...x(0),...V(),...H(0)),r(...x(1),...R(),...H(1))]},bl=(e,t,l)=>{if(X(e)&&X(t))return[n,n,n,n];const[a,o,d,r]=Ft(e,t,l);return[a,o,...pl(e,t,l,d,r)]},Cl=JSON.parse;var hl=Object.defineProperty,ml=Object.defineProperties,fl=Object.getOwnPropertyDescriptors,gl=Object.getOwnPropertySymbols,wl=Object.prototype.hasOwnProperty,yl=Object.prototype.propertyIsEnumerable,vl=(e,t,l)=>t in e?hl(e,t,{enumerable:!0,configurable:!0,writable:!0,value:l}):e[t]=l,Tl=(e,t)=>{for(var l in t||(t={}))wl.call(t,l)&&vl(e,l,t[l]);if(gl)for(var l of gl(t))yl.call(t,l)&&vl(e,l,t[l]);return e},xl=(e,t)=>ml(e,fl(t)),Vl=(e,t,l)=>new Promise(((n,a)=>{var o=e=>{try{r(l.next(e))}catch(e){a(e)}},d=e=>{try{r(l.throw(e))}catch(e){a(e)}},r=e=>e.done?n(e.value):Promise.resolve(e.value).then(o,d);r((l=l.apply(e,t)).next())}));const Rl="prettier/",Pl=Rl+"plugins/",kl={parser:"typescript",singleQuote:!0,trailingComma:"all",bracketSpacing:!1,jsdocSingleLineComment:!1},Sl=Lt((e=>{const t=()=>{const t=Cl(e.getTablesSchemaJson());return!X(t)||j(e.getTableIds(),(l=>{const n=e.getRowIds(l),a=ne();if(j(n,(t=>j(e.getCellIds(l,t),(n=>{const o=e.getCell(l,t,n),d=se(a,n,(()=>[D(o),ne(),[0],0])),[r,s,[I]]=d,c=se(s,o,(()=>0))+1;return c>I&&(d[2]=[c,o]),re(s,o,c),d[3]++,r==D(o)})))))return t[l]={},te(a,(([e,,[,a],o],d)=>{t[l][d]=Tl({[s]:e},o==J(n)?{[I]:a}:{})})),1}))?t:{}},l=()=>{const t=Cl(e.getValuesSchemaJson());return X(t)&&e.forEachValue(((e,l)=>{t[e]={[s]:D(l)}})),t},n=e=>bl(t(),l(),e),a=e=>Vl(void 0,null,(function*(){const t=["d.ts","ts","d.ts","tsx"],l=[];let a;try{a=(yield import(Rl+"standalone")).format,W(l,yield import(Pl+"estree"),yield import(Pl+"typescript"))}catch(e){a=e=>Vl(void 0,null,(function*(){return e}))}return yield E(M(n(e),((e,n)=>Vl(void 0,null,(function*(){return Pt(yield a(e,xl(Tl({},kl),{plugins:l,filepath:"_."+t[n]})))})))))}));return H({getStoreStats:t=>{let l=0,n=0,a=0;const o={};return e.forEachTable(((e,d)=>{l++;let r=0,s=0;const I={};d(((e,l)=>{r++;let n=0;l((()=>n++)),s+=n,t&&(I[e]={rowCells:n})})),n+=r,a+=s,t&&(o[e]={tableRows:r,tableCells:s,rows:I})})),Tl({totalTables:l,totalRows:n,totalCells:a,totalValues:J(e.getValueIds()),jsonLength:kt(e.getJson())},t?{detail:{tables:o}}:{})},getStoreTablesSchema:t,getStoreValuesSchema:l,getStoreApi:n,getPrettyStoreApi:a,getStore:()=>e})}));e.createTools=Sl},"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).TinyBaseTools={});
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tinybase",
3
- "version": "4.1.4",
3
+ "version": "4.2.0-beta.1",
4
4
  "author": "jamesgpearce",
5
5
  "repository": "github:tinyplex/tinybase",
6
6
  "license": "MIT",
@@ -212,11 +212,12 @@
212
212
  },
213
213
  "devDependencies": {
214
214
  "@automerge/automerge": "^2.1.0-alpha.6",
215
- "@babel/cli": "^7.22.10",
216
- "@babel/core": "^7.22.11",
217
- "@babel/preset-env": "^7.22.14",
218
- "@babel/preset-react": "^7.22.5",
219
- "@babel/preset-typescript": "^7.22.11",
215
+ "@babel/cli": "^7.22.15",
216
+ "@babel/core": "^7.22.15",
217
+ "@babel/preset-env": "^7.22.15",
218
+ "@babel/preset-react": "^7.22.15",
219
+ "@babel/preset-typescript": "^7.22.15",
220
+ "@prettier/sync": "^0.3.0",
220
221
  "@rollup/plugin-image": "^3.0.2",
221
222
  "@rollup/plugin-replace": "^5.0.2",
222
223
  "@rollup/plugin-terser": "^0.4.3",
@@ -227,14 +228,14 @@
227
228
  "@types/jest": "^29.5.4",
228
229
  "@types/jest-environment-puppeteer": "^5.0.3",
229
230
  "@types/less": "^3.0.4",
230
- "@types/node": "^20.5.7",
231
+ "@types/node": "^20.5.9",
231
232
  "@types/puppeteer": "^5.4.7",
232
233
  "@types/react": "^18.2.21",
233
234
  "@types/react-dom": "^18.2.7",
234
- "@types/react-test-renderer": "^18.0.0",
235
+ "@types/react-test-renderer": "^18.0.1",
235
236
  "@types/tmp": "^0.2.3",
236
- "@typescript-eslint/eslint-plugin": "^6.5.0",
237
- "@typescript-eslint/parser": "^6.5.0",
237
+ "@typescript-eslint/eslint-plugin": "^6.6.0",
238
+ "@typescript-eslint/parser": "^6.6.0",
238
239
  "@vlcn.io/crsqlite-wasm": "^0.14.0",
239
240
  "asciichart": "^1.5.25",
240
241
  "automerge-repo": "^0.1.0",
@@ -244,7 +245,7 @@
244
245
  "babel-preset-minify": "^0.5.2",
245
246
  "buffer-replace": "^1.0.0",
246
247
  "country-flag-emoji-json": "^2.0.0",
247
- "cspell": "^7.2.0",
248
+ "cspell": "^7.3.2",
248
249
  "esbuild": "^0.19.2",
249
250
  "eslint": "^8.48.0",
250
251
  "eslint-config-prettier": "^9.0.0",
@@ -257,12 +258,13 @@
257
258
  "gulp": "^4.0.2",
258
259
  "gulp-gzip": "^1.4.2",
259
260
  "http-server": "^14.1.1",
261
+ "idb": "^7.1.1",
260
262
  "jest": "^29.6.4",
261
263
  "jest-environment-jsdom": "^29.6.4",
262
264
  "jest-fetch-mock": "^3.0.3",
263
265
  "jest-puppeteer": "^9.0.0",
264
266
  "less": "^4.2.0",
265
- "prettier": "^2.8.8",
267
+ "prettier": "^3.0.3",
266
268
  "puppeteer": "^21.1.1",
267
269
  "react": "^18.2.0",
268
270
  "react-dom": "^18.2.0",
@@ -271,12 +273,12 @@
271
273
  "rollup-plugin-esbuild": "^5.0.0",
272
274
  "rollup-plugin-gzip": "^3.1.0",
273
275
  "rollup-plugin-preserve-shebang": "^1.0.1",
274
- "rollup-plugin-prettier": "^3.0.0",
276
+ "rollup-plugin-prettier": "^4.0.0",
275
277
  "sqlite3": "^5.1.6",
276
278
  "tinybase": "file:./",
277
279
  "tinydocs": "^0.1.32",
278
280
  "tmp": "^0.2.1",
279
- "ts-unused-exports": "^10.0.0",
281
+ "ts-unused-exports": "^10.0.1",
280
282
  "typescript": "5.2.2",
281
283
  "yjs": "^13.6.7"
282
284
  },
@@ -284,7 +286,7 @@
284
286
  "@sqlite.org/sqlite-wasm": "^3.42.0-build4",
285
287
  "@vlcn.io/crsqlite-wasm": "^0.14.0",
286
288
  "automerge-repo": "^0.1.0",
287
- "prettier": ">2.8.8",
289
+ "prettier": "^3.0.3",
288
290
  "react": "^18.2.0",
289
291
  "react-dom": "^18.2.0",
290
292
  "sqlite3": "^5.1.6",