tinybase 4.8.4 → 4.8.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/ui-react-dom-debug.cjs +1 -1
- package/lib/cjs/ui-react-dom-debug.cjs.gz +0 -0
- package/lib/cjs-es6/checkpoints.cjs +1 -1
- package/lib/cjs-es6/checkpoints.cjs.gz +0 -0
- package/lib/cjs-es6/indexes.cjs +1 -1
- package/lib/cjs-es6/indexes.cjs.gz +0 -0
- package/lib/cjs-es6/metrics.cjs +1 -1
- package/lib/cjs-es6/metrics.cjs.gz +0 -0
- package/lib/cjs-es6/queries.cjs +1 -1
- package/lib/cjs-es6/queries.cjs.gz +0 -0
- package/lib/cjs-es6/relationships.cjs +1 -1
- package/lib/cjs-es6/relationships.cjs.gz +0 -0
- package/lib/cjs-es6/ui-react-dom-debug.cjs +1 -1
- package/lib/cjs-es6/ui-react-dom-debug.cjs.gz +0 -0
- package/lib/debug/persisters/persister-cr-sqlite-wasm.js +23 -27
- package/lib/debug/persisters/persister-electric-sql.js +23 -27
- package/lib/debug/persisters/persister-expo-sqlite-next.js +23 -27
- package/lib/debug/persisters/persister-expo-sqlite.js +23 -27
- package/lib/debug/persisters/persister-indexed-db.js +0 -1
- package/lib/debug/persisters/persister-libsql.js +23 -27
- package/lib/debug/persisters/persister-powersync.js +23 -27
- package/lib/debug/persisters/persister-remote.js +0 -1
- package/lib/debug/persisters/persister-sqlite-wasm.js +23 -27
- package/lib/debug/persisters/persister-sqlite3.js +23 -27
- package/lib/debug/ui-react-dom.js +3 -11
- package/lib/es6/checkpoints.js +1 -1
- package/lib/es6/checkpoints.js.gz +0 -0
- package/lib/es6/indexes.js +1 -1
- package/lib/es6/indexes.js.gz +0 -0
- package/lib/es6/metrics.js +1 -1
- package/lib/es6/metrics.js.gz +0 -0
- package/lib/es6/queries.js +1 -1
- package/lib/es6/queries.js.gz +0 -0
- package/lib/es6/relationships.js +1 -1
- package/lib/es6/relationships.js.gz +0 -0
- package/lib/es6/ui-react-dom-debug.js +1 -1
- package/lib/es6/ui-react-dom-debug.js.gz +0 -0
- package/lib/types/persisters/persister-automerge.d.ts +2 -2
- package/lib/types/persisters/persister-browser.d.ts +2 -2
- package/lib/types/persisters/persister-cr-sqlite-wasm.d.ts +2 -2
- package/lib/types/persisters/persister-electric-sql.d.ts +2 -2
- package/lib/types/persisters/persister-expo-sqlite-next.d.ts +2 -2
- package/lib/types/persisters/persister-expo-sqlite.d.ts +2 -2
- package/lib/types/persisters/persister-file.d.ts +2 -2
- package/lib/types/persisters/persister-indexed-db.d.ts +2 -2
- package/lib/types/persisters/persister-libsql.d.ts +2 -2
- package/lib/types/persisters/persister-partykit-client.d.ts +2 -2
- package/lib/types/persisters/persister-partykit-server.d.ts +2 -2
- package/lib/types/persisters/persister-powersync.d.ts +2 -2
- package/lib/types/persisters/persister-remote.d.ts +2 -2
- package/lib/types/persisters/persister-sqlite-wasm.d.ts +2 -2
- package/lib/types/persisters/persister-sqlite3.d.ts +2 -2
- package/lib/types/ui-react-dom.d.ts +2 -2
- package/lib/types/with-schemas/indexes.d.ts +1 -1
- package/lib/types/with-schemas/internal/queries.d.ts +4 -4
- package/lib/types/with-schemas/internal/store.d.ts +2 -2
- package/lib/types/with-schemas/internal/ui-react.d.ts +12 -8
- package/lib/types/with-schemas/metrics.d.ts +1 -1
- package/lib/types/with-schemas/persisters/persister-automerge.d.ts +2 -2
- package/lib/types/with-schemas/persisters/persister-browser.d.ts +2 -2
- package/lib/types/with-schemas/persisters/persister-cr-sqlite-wasm.d.ts +2 -2
- package/lib/types/with-schemas/persisters/persister-electric-sql.d.ts +2 -2
- package/lib/types/with-schemas/persisters/persister-expo-sqlite-next.d.ts +2 -2
- package/lib/types/with-schemas/persisters/persister-expo-sqlite.d.ts +2 -2
- package/lib/types/with-schemas/persisters/persister-file.d.ts +2 -2
- package/lib/types/with-schemas/persisters/persister-indexed-db.d.ts +2 -2
- package/lib/types/with-schemas/persisters/persister-libsql.d.ts +2 -2
- package/lib/types/with-schemas/persisters/persister-partykit-client.d.ts +2 -2
- package/lib/types/with-schemas/persisters/persister-partykit-server.d.ts +2 -2
- package/lib/types/with-schemas/persisters/persister-powersync.d.ts +2 -2
- package/lib/types/with-schemas/persisters/persister-remote.d.ts +2 -2
- package/lib/types/with-schemas/persisters/persister-sqlite-wasm.d.ts +2 -2
- package/lib/types/with-schemas/persisters/persister-sqlite3.d.ts +2 -2
- package/lib/types/with-schemas/persisters.d.ts +1 -1
- package/lib/types/with-schemas/queries.d.ts +2 -2
- package/lib/types/with-schemas/relationships.d.ts +1 -1
- package/lib/types/with-schemas/store.d.ts +1 -1
- package/lib/types/with-schemas/ui-react-dom.d.ts +5 -5
- package/lib/types/with-schemas/ui-react.d.ts +2 -2
- package/lib/umd/ui-react-dom-debug.js +1 -1
- package/lib/umd/ui-react-dom-debug.js.gz +0 -0
- package/lib/umd-es6/checkpoints.js +1 -1
- package/lib/umd-es6/checkpoints.js.gz +0 -0
- package/lib/umd-es6/indexes.js +1 -1
- package/lib/umd-es6/indexes.js.gz +0 -0
- package/lib/umd-es6/metrics.js +1 -1
- package/lib/umd-es6/metrics.js.gz +0 -0
- package/lib/umd-es6/queries.js +1 -1
- package/lib/umd-es6/queries.js.gz +0 -0
- package/lib/umd-es6/relationships.js +1 -1
- package/lib/umd-es6/relationships.js.gz +0 -0
- package/lib/umd-es6/ui-react-dom-debug.js +1 -1
- package/lib/umd-es6/ui-react-dom-debug.js.gz +0 -0
- package/package.json +15 -15
- package/readme.md +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
var e,l;e=this,l=function(e,l,t){"use strict";const n=e=>typeof e,s="",r=n(s),a=n(!0),o=n(0),i=n(n),u="type",d="default",c="Has",h="Ids",m="Table",b=m+"s",p=m+h,g="Row",v=g+"Count",f=g+h,I="Cell",y=I+h,w="Value",C=w+"s",T=w+h,k="currentTarget",S="value",x=e=>s+e,V=Math.floor,R=isFinite,O=e=>null==e,q=(e,l,t)=>O(e)?null==t?void 0:t():l(e),P=e=>e==r||e==a,N=e=>n(e)==i,E=e=>Array.isArray(e),L=(e,l,t)=>e.slice(l,t),M=e=>e.length,{PureComponent:j,Fragment:z,createElement:$,useCallback:A,useLayoutEffect:F,useRef:J,useState:D}=l,H=(e,...l)=>O(e)?{}:e(...l),B=(e,l)=>e.sort(l),Q=(e,l)=>e.forEach(l),W=(e,l)=>e.map(l),U=e=>0==M(e),G=(e,...l)=>e.push(...l),K=e=>e.shift(),X=Object,Y=e=>X.getPrototypeOf(e),Z=X.keys,_=X.isFrozen,ee=X.freeze,le=e=>!O(e)&&q(Y(e),(e=>e==X.prototype||O(Y(e))),(()=>!0)),te=(e=[])=>X.fromEntries(e),ne=(e,l)=>!O(((e,l)=>q(e,(e=>e[l])))(e,l)),se=(e,l)=>(delete e[l],e),re=(e,l)=>W(X.entries(e),(([e,t])=>l(t,e))),ae=e=>le(e)&&0==(e=>M(Z(e)))(e),oe=e=>JSON.stringify(e,((e,l)=>l instanceof Map?X.fromEntries([...l]):l)),ie=JSON.parse,ue="tinybaseStoreInspector",de="TinyBase Store Inspector",ce=["left","top","bottom","right","full"],he="state",me="sort",be="open",pe="position",ge=be,ve="editable",fe=(...e)=>oe(e),Ie=(e,l)=>W(B(e),l),ye=(e,l)=>[!!t.useCell(he,e,ve,l),A((t=>{l.setCell(he,e,ve,(e=>!e)),t.preventDefault()}),[l,e])],we="M20 80l5-15l40-40l10 10l-40 40l-15 5m5-15l10 10",Ce='content:url("',Te=Ce+"data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100' stroke-width='4' stroke='white' fill='none'>",ke='</svg>")',Se=Ce+"data:image/svg+xml,%3csvg viewBox='0 0 680 680' xmlns='http://www.w3.org/2000/svg' style='width:680px%3bheight:680px'%3e %3cpath stroke='white' stroke-width='80' fill='none' d='M340 617a84 241 90 11.01 0zM131 475a94 254 70 10428-124 114 286 70 01-428 124zm0-140a94 254 70 10428-124 114 286 70 01-428 124zm-12-127a94 254 70 00306 38 90 260 90 01-306-38zm221 3a74 241 90 11.01 0z' /%3e %3cpath fill='%23d81b60' d='M131 475a94 254 70 10428-124 114 286 70 01-428 124zm0-140a94 254 70 10428-124 114 286 70 01-428 124z' /%3e %3cpath d='M249 619a94 240 90 00308-128 114 289 70 01-308 128zM119 208a94 254 70 00306 38 90 260 90 01-306-38zm221 3a74 241 90 11.01 0z' /%3e%3c/svg%3e\")",xe=W([[20,20,20,60],[20,20,60,20],[20,60,60,20],[60,20,20,60],[30,30,40,40]],(([e,l,t,n])=>Te+`<rect x='20' y='20' width='60' height='60' fill='grey'/><rect x='${e}' y='${l}' width='${t}' height='${n}' fill='white'/>`+ke)),Ve=Te+"<path d='M20 20l60 60M20 80l60-60' />"+ke,Re=Te+`<path d='${we}' />`+ke,Oe=Te+`<path d='${we}M20 20l60 60' />`+ke;var qe=Object.defineProperty,Pe=Object.defineProperties,Ne=Object.getOwnPropertyDescriptors,Ee=Object.getOwnPropertySymbols,Le=Object.prototype.hasOwnProperty,Me=Object.prototype.propertyIsEnumerable,je=(e,l,t)=>l in e?qe(e,l,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[l]=t,ze=(e,l)=>{for(var t in l||(l={}))Le.call(l,t)&&je(e,t,l[t]);if(Ee)for(var t of Ee(l))Me.call(l,t)&&je(e,t,l[t]);return e},$e=(e,l)=>Pe(e,Ne(l));const Ae="*::-webkit-scrollbar",Fe=((e,l="")=>e.join(l))(re($e(ze($e(ze($e(ze({"":"all:initial;font-family:sans-serif;font-size:0.75rem;position:fixed;z-index:999999","*":"all:revert","*::before":"all:revert","*::after":"all:revert",[Ae]:"width:0.5rem;height:0.5rem;",[Ae+"-track"]:"background:#111",[Ae+"-thumb"]:"background:#999;border:1px solid #111",[Ae+"-thumb:hover"]:"background:#fff",[Ae+"-corner"]:"background:#111",img:"width:1rem;height:1rem;background:#111;border:0;vertical-align:text-bottom",">img":"padding:0.25rem;bottom:0;right:0;position:fixed;"+Se},te(W(["bottom:0;left:0","top:0;right:0"],((e,l)=>[`>img[data-position='${l}']`,e])))),{main:"display:flex;flex-direction:column;background:#111d;color:#fff;position:fixed;"}),te(W(["bottom:0;left:0;width:35vw;height:100vh","top:0;right:0;width:100vw;height:30vh","bottom:0;left:0;width:100vw;height:30vh","top:0;right:0;width:35vw;height:100vh","top:0;right:0;width:100vw;height:100vh"],((e,l)=>[`main[data-position='${l}']`,e])))),{header:"display:flex;padding:0.25rem;background:#000;align-items:center","header>img:nth-of-type(1)":Se,"header>img:nth-of-type(6)":Ve}),te(W(xe,((e,l)=>[`header>img[data-id='${l}']`,e])))),{"header>span":"flex:1;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;margin-left:0.25rem",article:"padding:0.25rem 0.25rem 0.25rem 0.5rem;overflow:auto;flex:1",details:"margin-left:0.75rem;width:fit-content;","details img":"display:none","details[open]>summary img":"display:unset;background:none;margin-left:0.25rem","details[open]>summary img.edit":Re,"details[open]>summary img.done":Oe,summary:"margin-left:-0.75rem;line-height:1.25rem;user-select:none;width:fit-content",table:"border-collapse:collapse;table-layout:fixed;margin-bottom:0.5rem","table input":"background:#111;color:unset;padding:0 0.25rem;border:0;font-size:unset;vertical-align:top;margin:0",'table input[type="number"]':"width:4rem","table tbody button":"font-size:0;background:#fff;border-radius:50%;margin:0 0.125rem 0 0;width:0.85rem;color:#111","table button:first-letter":"font-size:0.75rem",thead:"background:#222","th:nth-of-type(1)":"min-width:2rem;","th.sorted":"background:#000","table caption":"text-align:left;white-space:nowrap;line-height:1.25rem",button:"width:1.5rem;border:none;background:none;color:#fff;padding:0","button[disabled]":"color:#777","button.next":"margin-right:0.5rem",[`th,#${ue} td`]:"overflow:hidden;text-overflow:ellipsis;padding:0.25rem 0.5rem;max-width:12rem;white-space:nowrap;border-width:1px 0;border-style:solid;border-color:#777;text-align:left","span.warn":"margin:0.25rem;color:#d81b60"}),((e,l)=>e?`#${ue} ${l}{${e}}`:""))),Je=({s:e})=>{var l;const n=null!=(l=t.useValue(pe,e))?l:1,s=t.useSetValueCallback(ge,(()=>!0),[],e);return t.useValue(ge,e)?null:$("img",{onClick:s,title:de,"data-position":n})},De=({uniqueId:e,summary:l,editable:n,handleEditable:s,children:r,s:a})=>{const o=!!t.useCell(he,e,be,a),i=t.useSetCellCallback(he,e,be,(e=>e[k].open),[],a);return $("details",{open:o,onToggle:i},$("summary",null,l,s?$("img",{onClick:s,className:n?"done":"edit"}):null),r)},He=e=>{const l=n(e);return P(l)||l==o&&R(e)?l:void 0},Be=(e,l,t,n,s)=>O(s)?e.delCell(l,t,n,!0):e.setCell(l,t,n,s),Qe=(e,l,t)=>O(t)?e.delValue(l):e.setValue(l,t),We=(e,l,t,n)=>e==r?l:e==o?t:n;var Ue=Object.defineProperty,Ge=Object.defineProperties,Ke=Object.getOwnPropertyDescriptors,Xe=Object.getOwnPropertySymbols,Ye=Object.prototype.hasOwnProperty,Ze=Object.prototype.propertyIsEnumerable,_e=(e,l,t)=>l in e?Ue(e,l,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[l]=t,el=(e,l)=>{for(var t in l||(l={}))Ye.call(l,t)&&_e(e,t,l[t]);if(Xe)for(var t of Xe(l))Ze.call(l,t)&&_e(e,t,l[t]);return e},ll=(e,l)=>Ge(e,Ke(l)),tl=(e,l)=>{var t={};for(var n in e)Ye.call(e,n)&&l.indexOf(n)<0&&(t[n]=e[n]);if(null!=e&&Xe)for(var n of Xe(e))l.indexOf(n)<0&&Ze.call(e,n)&&(t[n]=e[n]);return t};const{useCallback:nl,useMemo:sl,useState:rl}=l,al="editable",ol=(e,l)=>W(t.useTableCellIds(e,l),(l=>e+"."+l)),il=(e,l,t)=>{const n=nl(e,l);return t?n:void 0},ul=(...e)=>sl((()=>e),e),dl=(e,l)=>sl((()=>({store:e,tableId:l})),[e,l]),cl=(e,l)=>sl((()=>({queries:e,queryId:l})),[e,l]),hl=(e,l=!1,t,n=0,s,r,a,o)=>{const[[i,u,d],c]=rl([e,l,n]),h=nl((e=>{c(e),null==o||o(e)}),[o]),m=il((e=>h([e,e==i&&!u,d])),[h,i,u,d],t),b=nl((e=>h([i,u,e])),[h,i,u]),p=!0===a?Sl:a;return[[i,u,d],m,sl((()=>!1===a?null:$(p,{offset:d,limit:s,total:r,onChange:b})),[a,p,d,s,r,b])]},ml=(e,l,t)=>sl((()=>{const s=null!=l?l:e;return te(re(E(s)?te(W(s,(e=>[e,e]))):s,((e,l)=>{return[l,el(el({},{label:l,component:t}),(s=e,n(s)==r?{label:e}:e))];var s})))}),[l,t,e]),bl=({className:e,headerRow:l,idColumn:t,params:[n,s,r,a,o,i]})=>$("table",{className:e},i?$("caption",null,i):null,!1===l?null:$("thead",null,$("tr",null,!1===t?null:$(pl,{sort:null!=a?a:[],label:"Id",onClick:o}),re(n,(({label:e},l)=>$(pl,{key:l,cellId:l,label:e,sort:null!=a?a:[],onClick:o}))))),$("tbody",null,W(r,(e=>$("tr",{key:e},!1===t?null:$("th",null,e),re(n,(({component:l,getComponentProps:t},n)=>$("td",{key:n},$(l,ll(el(el({},H(t,e,n)),s),{rowId:e,cellId:n})))))))))),pl=({cellId:e,sort:[l,t],label:n=(null!=e?e:s),onClick:r})=>$("th",{onClick:il((()=>null==r?void 0:r(e)),[r,e],r),className:O(t)||l!=e?void 0:`sorted ${t?"de":"a"}scending`},O(t)||l!=e?null:(t?"↓":"↑")+" ",n),gl=({localRowId:e,params:[n,s,r,a,o,i,u]})=>{const d=t.useRemoteRowId(o,e,i);return $("tr",null,!1===n?null:$(l.Fragment,null,$("th",null,e),$("th",null,d)),re(s,(({component:l,getComponentProps:t},n)=>{const[s,o]=n.split(".",2),i=s===r?e:s===a?d:null;return O(i)?null:$("td",{key:n},$(l,ll(el({},H(t,i,o)),{store:u,tableId:s,rowId:i,cellId:o})))})))},vl=({thing:e,onThingChange:l,className:t,hasSchema:n,showType:s=!0})=>{const[i,u]=rl(),[d,c]=rl(),[h,m]=rl(),[b,p]=rl(),[g,v]=rl();d!==e&&(u(He(e)),c(e),m(e+""),p(Number(e)||0),v(!!e));const f=nl(((e,t)=>{t(e),c(e),l(e)}),[l]),I=nl((()=>{if(!(null==n?void 0:n())){const e=We(i,o,a,r),t=We(e,h,b,g);u(e),c(t),l(t)}}),[n,l,h,b,g,i]);return $("div",{className:t},s?$("button",{className:i,onClick:I},i):null,We(i,$("input",{key:i,value:h,onChange:nl((e=>f(e[k][S]+"",m)),[f])}),$("input",{key:i,type:"number",value:b,onChange:nl((e=>f(Number(e[k][S]||0),p)),[f])}),$("input",{key:i,type:"checkbox",checked:g,onChange:nl((e=>f(!!e[k].checked,v)),[f])})))},fl=e=>{var l=e,{tableId:n,cellId:s,descending:r,offset:a,limit:o,store:i,editable:u,sortOnClick:d,paginator:c=!1,onChange:h,customCells:m}=l,b=tl(l,["tableId","cellId","descending","offset","limit","store","editable","sortOnClick","paginator","onChange","customCells"]);const[p,g,v]=hl(s,r,d,a,o,t.useRowCount(n,i),c,h);return $(bl,ll(el({},b),{params:ul(ml(t.useTableCellIds(n,i),m,u?Tl:t.CellView),dl(i,n),t.useSortedRowIds(n,...p,o,i),p,g,v)}))},Il=({store:e,editable:l=!1,valueComponent:n=(l?kl:t.ValueView),getValueComponentProps:s,className:r,headerRow:a,idColumn:o})=>$("table",{className:r},!1===a?null:$("thead",null,$("tr",null,!1===o?null:$("th",null,"Id"),$("th",null,w))),$("tbody",null,W(t.useValueIds(e),(l=>$("tr",{key:l},!1===o?null:$("th",null,l),$("td",null,$(n,ll(el({},H(s,l)),{valueId:l,store:e})))))))),yl=e=>{var l=e,{indexId:n,sliceId:s,indexes:r,editable:a,customCells:o}=l,i=tl(l,["indexId","sliceId","indexes","editable","customCells"]);const[u,d,c]=((e,l)=>[e,null==e?void 0:e.getStore(),null==e?void 0:e.getTableId(l)])(t.useIndexesOrIndexesById(r),n);return $(bl,ll(el({},i),{params:ul(ml(t.useTableCellIds(c,d),o,a?Tl:t.CellView),dl(d,c),t.useSliceRowIds(n,s,u))}))},wl=({relationshipId:e,relationships:n,editable:s,customCells:r,className:a,headerRow:o,idColumn:i=!0})=>{const[u,d,c,h]=((e,l)=>[e,null==e?void 0:e.getStore(),null==e?void 0:e.getLocalTableId(l),null==e?void 0:e.getRemoteTableId(l)])(t.useRelationshipsOrRelationshipsById(n),e),m=ml([...ol(c,d),...ol(h,d)],r,s?Tl:t.CellView),b=ul(i,m,c,h,e,u,d);return $("table",{className:a},!1===o?null:$("thead",null,$("tr",null,!1===i?null:$(l.Fragment,null,$("th",null,c,".Id"),$("th",null,h,".Id")),re(m,(({label:e},l)=>$("th",{key:l},e))))),$("tbody",null,W(t.useRowIds(c,d),(e=>$(gl,{key:e,localRowId:e,params:b})))))},Cl=e=>{var l=e,{queryId:n,cellId:s,descending:r,offset:a,limit:o,queries:i,sortOnClick:u,paginator:d=!1,customCells:c,onChange:h}=l,m=tl(l,["queryId","cellId","descending","offset","limit","queries","sortOnClick","paginator","customCells","onChange"]);const[b,p,g]=hl(s,r,u,a,o,t.useResultRowCount(n,i),d,h);return $(bl,ll(el({},m),{params:ul(ml(t.useResultTableCellIds(n,i),c,t.ResultCellView),cl(i,n),t.useResultSortedRowIds(n,...b,o,i),b,p,g)}))},Tl=({tableId:e,rowId:l,cellId:n,store:s,className:r,showType:a})=>{var o;return $(vl,{thing:t.useCell(e,l,n,s),onThingChange:t.useSetCellCallback(e,l,n,(e=>e),[],s),className:null!=r?r:al+I,showType:a,hasSchema:null==(o=t.useStoreOrStoreById(s))?void 0:o.hasTablesSchema})},kl=({valueId:e,store:l,className:n,showType:s})=>{var r;return $(vl,{thing:t.useValue(e,l),onThingChange:t.useSetValueCallback(e,(e=>e),[],l),className:null!=n?n:al+w,showType:s,hasSchema:null==(r=t.useStoreOrStoreById(l))?void 0:r.hasValuesSchema})},Sl=({onChange:e,total:t,offset:n=0,limit:s=t,singular:r="row",plural:a=r+"s"})=>{(n>t||n<0)&&(n=0,e(0));const o=il((()=>e(n-s)),[e,n,s],n>0),i=il((()=>e(n+s)),[e,n,s],n+s<t);return $(l.Fragment,null,t>s&&$(l.Fragment,null,$("button",{className:"previous",disabled:0==n,onClick:o},"←"),$("button",{className:"next",disabled:n+s>=t,onClick:i},"→"),n+1," to ",Math.min(t,n+s)," of "),t," ",1!=t?a:r)},xl=({indexes:e,indexesId:l,indexId:n,s:s})=>$(De,{uniqueId:fe("i",l,n),summary:"Index: "+n,s:s},W(t.useSliceIds(n,e),(t=>$(Vl,{indexes:e,indexesId:l,indexId:n,sliceId:t,s:s,key:t})))),Vl=({indexes:e,indexesId:l,indexId:t,sliceId:n,s:s})=>{const r=fe("i",l,t,n),[a,o]=ye(r,s);return $(De,{uniqueId:r,summary:"Slice: "+n,editable:a,handleEditable:o,s:s},$(yl,{sliceId:n,indexId:t,indexes:e,editable:a}))},Rl=({indexesId:e,s:l})=>{const n=t.useIndexes(e),s=t.useIndexIds(n);return O(n)?null:$(De,{uniqueId:fe("i",e),summary:"Indexes: "+(null!=e?e:d),s:l},U(s)?"No indexes defined":Ie(s,(t=>$(xl,{indexes:n,indexesId:e,indexId:t,s:l,key:t}))))},Ol=({metrics:e,metricId:l})=>$("tr",null,$("th",null,l),$("td",null,null==e?void 0:e.getTableId(l)),$("td",null,t.useMetric(l,e))),ql=({metricsId:e,s:l})=>{const n=t.useMetrics(e),s=t.useMetricIds(n);return O(n)?null:$(De,{uniqueId:fe("m",e),summary:"Metrics: "+(null!=e?e:d),s:l},U(s)?"No metrics defined":$("table",null,$("thead",null,$("th",null,"Metric Id"),$("th",null,"Table Id"),$("th",null,"Metric")),$("tbody",null,W(s,(e=>$(Ol,{metrics:n,metricId:e,key:e}))))))},Pl=({queries:e,queriesId:l,queryId:n,s:s})=>{var r;const a=fe("q",l,n),[o,i,u]=ie(null!=(r=t.useCell(he,a,me,s))?r:"[]"),d=t.useSetCellCallback(he,a,me,oe,[],s);return $(De,{uniqueId:a,summary:"Query: "+n,s:s},$(Cl,{queryId:n,queries:e,cellId:o,descending:i,offset:u,limit:10,paginator:!0,sortOnClick:!0,onChange:d}))},Nl=({queriesId:e,s:l})=>{const n=t.useQueries(e),s=t.useQueryIds(n);return O(n)?null:$(De,{uniqueId:fe("q",e),summary:"Queries: "+(null!=e?e:d),s:l},U(s)?"No queries defined":Ie(s,(t=>$(Pl,{queries:n,queriesId:e,queryId:t,s:l,key:t}))))},El=({relationships:e,relationshipsId:l,relationshipId:t,s:n})=>{const s=fe("r",l,t),[r,a]=ye(s,n);return $(De,{uniqueId:s,summary:"Relationship: "+t,editable:r,handleEditable:a,s:n},$(wl,{relationshipId:t,relationships:e,editable:r}))},Ll=({relationshipsId:e,s:l})=>{const n=t.useRelationships(e),s=t.useRelationshipIds(n);return O(n)?null:$(De,{uniqueId:fe("r",e),summary:"Relationships: "+(null!=e?e:d),s:l},U(s)?"No relationships defined":Ie(s,(t=>$(El,{relationships:n,relationshipsId:e,relationshipId:t,s:l,key:t}))))},Ml=({tableId:e,store:l,storeId:n,s:s})=>{var r;const a=fe("t",n,e),[o,i,u]=ie(null!=(r=t.useCell(he,a,me,s))?r:"[]"),d=t.useSetCellCallback(he,a,me,oe,[],s),[c,h]=ye(a,s);return $(De,{uniqueId:a,summary:m+": "+e,editable:c,handleEditable:h,s:s},$(fl,{tableId:e,store:l,cellId:o,descending:i,offset:u,limit:10,paginator:!0,sortOnClick:!0,onChange:d,editable:c}))},jl=({store:e,storeId:l,s:n})=>{const s=fe("v",l),[r,a]=ye(s,n);return U(t.useValueIds(e))?null:$(De,{uniqueId:s,summary:C,editable:r,handleEditable:a,s:n},$(Il,{store:e,editable:r}))},zl=({storeId:e,s:l})=>{const n=t.useStore(e),s=t.useTableIds(n);return O(n)?null:$(De,{uniqueId:fe("s",e),summary:"Store: "+(null!=e?e:d),s:l},$(jl,{storeId:e,store:n,s:l}),Ie(s,(t=>$(Ml,{store:n,storeId:e,tableId:t,s:l,key:t}))))},$l=({s:e})=>{const l=J(null),n=J(0),[s,r]=D(!1),{scrollLeft:a,scrollTop:o}=t.useValues(e);F((()=>{const e=l.current;if(e&&!s){const l=new MutationObserver((()=>{e.scrollWidth>=V(a)+e.clientWidth&&e.scrollHeight>=V(o)+e.clientHeight&&e.scrollTo(a,o)}));return l.observe(e,{childList:!0,subtree:!0}),()=>l.disconnect()}}),[s,a,o]);const i=A((l=>{const{scrollLeft:t,scrollTop:s}=l[k];cancelIdleCallback(n.current),n.current=requestIdleCallback((()=>{r(!0),e.setPartialValues({scrollLeft:t,scrollTop:s})}))}),[e]),u=t.useStore(),d=t.useStoreIds(),c=t.useMetrics(),h=t.useMetricsIds(),m=t.useIndexes(),b=t.useIndexesIds(),p=t.useRelationships(),g=t.useRelationshipsIds(),v=t.useQueries(),f=t.useQueriesIds();return O(u)&&U(d)&&O(c)&&U(h)&&O(m)&&U(b)&&O(p)&&U(g)&&O(v)&&U(f)?$("span",{className:"warn"},"There are no Stores or other objects to inspect. Make sure you placed the StoreInspector inside a Provider component."):$("article",{ref:l,onScroll:i},$(zl,{s:e}),W(d,(l=>$(zl,{storeId:l,s:e,key:l}))),$(ql,{s:e}),W(h,(l=>$(ql,{metricsId:l,s:e,key:l}))),$(Rl,{s:e}),W(b,(l=>$(Rl,{indexesId:l,s:e,key:l}))),$(Ll,{s:e}),W(g,(l=>$(Ll,{relationshipsId:l,s:e,key:l}))),$(Nl,{s:e}),W(f,(l=>$(Nl,{queriesId:l,s:e,key:l}))))};class Al extends j{constructor(e){super(e),this.componentDidCatch=(e,l)=>console.error(e,l.componentStack),this.state={e:0}}static getDerivedStateFromError(){return{e:1}}render(){return this.state.e?$("span",{className:"warn"},"Inspector error: please see console for details."):this.props.children}}const Fl=({s:e})=>{var l;const n=null!=(l=t.useValue(pe,e))?l:1,s=t.useSetValueCallback(ge,(()=>!1),[],e),r=t.useSetValueCallback(pe,(e=>Number(e[k].dataset.id)),[],e);return $("header",null,$("img",{title:de}),$("span",null,de),W(ce,((e,l)=>l==n?null:$("img",{onClick:r,"data-id":l,title:"Dock to "+e,key:l}))),$("img",{onClick:s,title:"Close"}))},Jl=({s:e})=>{var l;const n=null!=(l=t.useValue(pe,e))?l:1;return t.useValue(ge,e)?$("main",{"data-position":n},$(Fl,{s:e}),$(Al,null,$($l,{s:e}))):null},Dl=e=>l=>{return t=(l,t)=>l+e(t),Kl(l).reduce(t,0);var t},Hl=e=>{var l;return null!=(l=null==e?void 0:e.size)?l:0},Bl=Dl(Hl),Ql=Dl(Bl),Wl=Dl(Ql),Ul=(e,l)=>{var t;return null!=(t=null==e?void 0:e.has(l))&&t},Gl=e=>O(e)||0==Hl(e),Kl=e=>{var l;return[...null!=(l=null==e?void 0:e.values())?l:[]]},Xl=e=>e.clear(),Yl=(e,l)=>null==e?void 0:e.forEach(l),Zl=(e,l)=>null==e?void 0:e.delete(l),_l=e=>new Map(e),et=e=>{var l;return[...null!=(l=null==e?void 0:e.keys())?l:[]]},lt=(e,l)=>null==e?void 0:e.get(l),tt=(e,l)=>Yl(e,((e,t)=>l(t,e))),nt=(e,l,t)=>O(t)?(Zl(e,l),e):null==e?void 0:e.set(l,t),st=(e,l,t)=>(Ul(e,l)||nt(e,l,t()),lt(e,l)),rt=(e,l,t,n=nt)=>(re(l,((l,n)=>t(e,n,l))),tt(e,(t=>ne(l,t)?0:n(e,t))),e),at=(e,l,t)=>{const n={};return Yl(e,((e,s)=>{const r=l?l(e,s):e;!(null==t?void 0:t(r,e))&&(n[s]=r)})),n},ot=(e,l,t)=>at(e,(e=>at(e,l,t)),ae),it=(e,l,t)=>at(e,(e=>ot(e,l,t)),ae),ut=(e,l)=>{const t=_l();return Yl(e,((e,n)=>{var s;return t.set(n,null!=(s=null==l?void 0:l(e))?s:e)})),t},dt=e=>ut(e,ut),ct=e=>ut(e,dt),ht=(e,l,t,n,s=0)=>q((t?st:lt)(e,l[s],s>M(l)-2?t:_l),(r=>{if(s>M(l)-2)return(null==n?void 0:n(r))&&nt(e,l[s]),r;const a=ht(r,l,t,n,s+1);return Gl(r)&&nt(e,l[s]),a}));var mt=(e,l,t)=>new Promise(((n,s)=>{var r=e=>{try{o(t.next(e))}catch(e){s(e)}},a=e=>{try{o(t.throw(e))}catch(e){s(e)}},o=e=>e.done?n(e.value):Promise.resolve(e.value).then(r,a);o((t=t.apply(e,l)).next())}));const bt=_l(),pt=_l();var gt=(e,l,t)=>new Promise(((n,s)=>{var r=e=>{try{o(t.next(e))}catch(e){s(e)}},a=e=>{try{o(t.throw(e))}catch(e){s(e)}},o=e=>e.done?n(e.value):Promise.resolve(e.value).then(r,a);o((t=t.apply(e,l)).next())}));const vt="storage",ft=globalThis.window,It=e=>new Set(E(e)||O(e)?e:[e]),yt=(e,l)=>null==e?void 0:e.add(l),wt=/^\d+$/,Ct=()=>{const e=[];let l=0;return[t=>{var n;return null!=(n=t?K(e):null)?n:s+l++},l=>{wt.test(l)&&M(e)<1e3&&G(e,l)}]},Tt=e=>[e,e],kt=(e,l=Bl)=>l(e[0])+l(e[1]),St=()=>[_l(),_l()],xt=e=>[...e],Vt=([e,l])=>e===l,Rt=(e,l,t)=>O(e)||!le(e)||ae(e)||_(e)?(null==t||t(),!1):(re(e,((t,n)=>{l(t,n)||se(e,n)})),!ae(e)),Ot=(e,l,t)=>nt(e,l,lt(e,l)==-t?void 0:t),qt=()=>{let e,l,t=!1,n=!1,r=!1,a=!1,i=0;const h=_l(),k=_l(),S=_l(),V=_l(),R=_l(),E=_l(),j=_l(),z=_l(),$=_l(),A=_l(),F=_l(),J=_l(),D=_l(),H=_l(),U=It(),K=_l(),X=_l(),Y=_l(),Z=_l(),_=St(),le=St(),te=St(),ue=St(),de=St(),ce=St(),he=St(),me=St(),be=St(),pe=St(),ge=St(),ve=St(),fe=St(),Ie=St(),ye=St(),we=St(),Ce=St(),Te=St(),ke=St(),Se=St(),xe=St(),Ve=St(),Re=_l(),Oe=St(),[qe,Pe,Ne,Ee]=(e=>{let l;const[t,n]=Ct(),r=_l();return[(e,n,a,o=[],i=(()=>[]))=>{null!=l||(l=$t);const u=t(1);return nt(r,u,[e,n,a,o,i]),yt(ht(n,null!=a?a:[s],It),u),u},(e,t,...n)=>Q(((e,l=[s])=>{const t=[],n=(e,s)=>s==M(l)?G(t,e):null===l[s]?Yl(e,(e=>n(e,s+1))):Q([l[s],null],(l=>n(lt(e,l),s+1)));return n(e,0),t})(e,t),(e=>Yl(e,(e=>lt(r,e)[0](l,...null!=t?t:[],...n))))),e=>q(lt(r,e),(([,l,t])=>(ht(l,null!=t?t:[s],void 0,(l=>(Zl(l,e),Gl(l)?1:0))),nt(r,e),n(e),t))),e=>q(lt(r,e),(([e,,t=[],n,s])=>{const r=(...a)=>{var o,i;const u=M(a);u==M(t)?e(l,...a,...s(a)):O(t[u])?Q(null!=(i=null==(o=n[u])?void 0:o.call(n,...a))?i:[],(e=>r(...a,e))):r(...a,t[u])};r()}))]})(),Le=e=>{if(!Rt(e,((e,l)=>[u,d].includes(l))))return!1;const l=e[u];return!(!P(l)&&l!=o||(He(e[d])!=l&&se(e,d),0))},Me=(l,t)=>(!e||Ul(F,t)||bl(t))&&Rt(l,((e,l)=>je(t,l,e)),(()=>bl(t))),je=(e,l,t,n)=>Rt(n?t:Fe(t,e,l),((n,s)=>q(ze(e,l,s,n),(e=>(t[s]=e,!0)),(()=>!1))),(()=>bl(e,l))),ze=(l,t,n,s)=>e?q(lt(lt(F,l),n),(e=>He(s)!=e[u]?bl(l,t,n,s,e[d]):s),(()=>bl(l,t,n,s))):O(He(s))?bl(l,t,n,s):s,$e=(e,l)=>Rt(l?e:Je(e),((l,t)=>q(Ae(t,l),(l=>(e[t]=l,!0)),(()=>!1))),(()=>pl())),Ae=(e,t)=>l?q(lt(D,e),(l=>He(t)!=l[u]?pl(e,t,l[d]):t),(()=>pl(e,t))):O(He(t))?pl(e,t):t,Fe=(e,l,t)=>(q(lt(J,l),(([n,s])=>{Yl(n,((l,t)=>{ne(e,t)||(e[t]=l)})),Yl(s,(n=>{ne(e,n)||bl(l,t,n)}))})),e),Je=e=>(l&&(Yl(H,((l,t)=>{ne(e,t)||(e[t]=l)})),Yl(U,(l=>{ne(e,l)||pl(l)}))),e),De=e=>rt(F,e,((e,l,t)=>{const n=_l(),s=It();rt(st(F,l,_l),t,((e,l,t)=>{nt(e,l,t),q(t[d],(e=>nt(n,l,e)),(()=>yt(s,l)))})),nt(J,l,[n,s])}),((e,l)=>{nt(F,l),nt(J,l)})),We=e=>rt(D,e,((e,l,t)=>{nt(D,l,t),q(t[d],(e=>nt(H,l,e)),(()=>yt(U,l)))}),((e,l)=>{nt(D,l),nt(H,l),Zl(U,l)})),Ue=e=>ae(e)?ft():mt(e),Ge=e=>rt(Y,e,((e,l,t)=>Ke(l,t)),((e,l)=>sl(l))),Ke=(e,l)=>rt(st(Y,e,(()=>(il(e,1),nt(K,e,Ct()),nt(X,e,_l()),_l()))),l,((l,t,n)=>Xe(e,l,t,n)),((l,t)=>rl(e,l,t))),Xe=(e,l,t,n,s)=>rt(st(l,t,(()=>(ul(e,t,1),_l()))),n,((l,n,s)=>Ye(e,t,l,n,s)),((n,r)=>al(e,l,t,n,r,s))),Ye=(e,l,t,n,s)=>{Ul(t,n)||dl(e,l,n,1);const r=lt(t,n);s!==r&&(cl(e,l,n,r,s),nt(t,n,s))},Ze=(e,l,t,n,s)=>q(lt(l,t),(l=>Ye(e,t,l,n,s)),(()=>Xe(e,l,t,Fe({[n]:s},e,t)))),_e=e=>ae(e)?Nt():bt(e),el=e=>rt(Z,e,((e,l,t)=>ll(l,t)),((e,l)=>ol(l))),ll=(e,l)=>{Ul(Z,e)||hl(e,1);const t=lt(Z,e);l!==t&&(ml(e,t,l),nt(Z,e,l))},tl=(e,l)=>{const[t]=lt(K,e),n=t(l);return Ul(lt(Y,e),n)?tl(e,l):n},nl=e=>{var l;return null!=(l=lt(Y,e))?l:Ke(e,{})},sl=e=>Ke(e,{}),rl=(e,l,t)=>{const[,n]=lt(K,e);n(t),Xe(e,l,t,{},!0)},al=(e,l,t,n,s,r)=>{var a;const o=lt(null==(a=lt(J,e))?void 0:a[0],s);if(!O(o)&&!r)return Ye(e,t,n,s,o);const i=l=>{cl(e,t,l,lt(n,l)),dl(e,t,l,-1),nt(n,l)};O(o)?i(s):tt(n,i),Gl(n)&&(ul(e,t,-1),Gl(nt(l,t))&&(il(e,-1),nt(Y,e),nt(K,e),nt(X,e)))},ol=e=>{const l=lt(H,e);if(!O(l))return ll(e,l);ml(e,lt(Z,e)),hl(e,-1),nt(Z,e)},il=(e,l)=>Ot(h,e,l),ul=(e,l,t)=>Ot(st(V,e,_l),l,t)&&nt(S,e,st(S,e,(()=>0))+t),dl=(e,l,t,n)=>{var s;const r=lt(X,e),a=null!=(s=lt(r,t))?s:0;(0==a&&1==n||1==a&&-1==n)&&Ot(st(k,e,_l),t,n),nt(r,t,a!=-n?a+n:null),Ot(st(st(R,e,_l),l,_l),t,n)},cl=(e,l,t,n,s)=>st(st(st(E,e,_l),l,_l),t,(()=>[n,0]))[1]=s,hl=(e,l)=>Ot(j,e,l),ml=(e,l,t)=>st(z,e,(()=>[l,0]))[1]=t,bl=(e,l,t,n,s)=>(G(st(st(st($,e,_l),l,_l),t,(()=>[])),n),s),pl=(e,l,t)=>(G(st(A,e,(()=>[])),l),t),gl=(e,l,t)=>q(lt(lt(lt(E,e),l),t),(([e,l])=>[!0,e,l]),(()=>[!1,...Tt(El(e,l,t))])),vl=e=>q(lt(z,e),(([e,l])=>[!0,e,l]),(()=>[!1,...Tt(jl(e))])),fl=e=>Gl($)||Gl(we[e])?0:Yl(e?ct($):$,((l,t)=>Yl(l,((l,n)=>Yl(l,((l,s)=>Pe(we[e],[t,n,s],l))))))),Il=e=>Gl(A)||Gl(Ce[e])?0:Yl(e?ut(A):A,((l,t)=>Pe(Ce[e],[t],l))),yl=(e,l,t,n)=>{if(!Gl(e))return Pe(l,n,(()=>at(e))),tt(e,((e,l)=>Pe(t,[...null!=n?n:[],e],1==l))),1},wl=e=>{const l=zl();l!=r&&Pe(_[e],void 0,l);const t=Gl(pe[e]),n=Gl(fe[e])&&Gl(Ie[e])&&Gl(be[e])&&Gl(ge[e])&&Gl(ce[e])&&Gl(he[e])&&Gl(me[e])&&t&&Gl(te[e])&&Gl(ue[e]),s=Gl(ye[e])&&Gl(ve[e])&&Gl(de[e])&&Gl(le[e]);if(!n||!s){const l=e?[ut(h),dt(k),ut(S),dt(V),ct(R),ct(E)]:[h,k,S,V,R,E];if(!n){yl(l[0],te[e],ue[e]),Yl(l[1],((l,t)=>yl(l,ce[e],he[e],[t]))),Yl(l[2],((l,t)=>{0!=l&&Pe(me[e],[t],Ol(t))}));const n=It();Yl(l[3],((l,s)=>{yl(l,be[e],ge[e],[s])&&!t&&(Pe(pe[e],[s,null]),yt(n,s))})),t||Yl(l[5],((l,t)=>{if(!Ul(n,t)){const n=It();Yl(l,(e=>Yl(e,(([l,t],s)=>t!==l?yt(n,s):Zl(e,s))))),Yl(n,(l=>Pe(pe[e],[t,l])))}})),Yl(l[4],((l,t)=>Yl(l,((l,n)=>yl(l,fe[e],Ie[e],[t,n])))))}if(!s){let t;Yl(l[5],((l,n)=>{let s;Yl(l,((l,r)=>{let a;Yl(l,(([l,o],i)=>{o!==l&&(Pe(ye[e],[n,r,i],o,l,gl),t=s=a=1)})),a&&Pe(ve[e],[n,r],gl)})),s&&Pe(de[e],[n],gl)})),t&&Pe(le[e],void 0,gl)}}},Cl=e=>{const l=Dl();l!=a&&Pe(Te[e],void 0,l);const t=Gl(Se[e])&&Gl(xe[e]),n=Gl(Ve[e])&&Gl(ke[e]);if(!t||!n){const l=e?[ut(j),ut(z)]:[j,z];if(t||yl(l[0],Se[e],xe[e]),!n){let t;Yl(l[1],(([l,n],s)=>{n!==l&&(Pe(Ve[e],[s],n,l,vl),t=1)})),t&&Pe(ke[e],void 0,vl)}}},Tl=(e,...l)=>(Mt((()=>e(...W(l,x)))),$t),kl=()=>[at(E,((e,l)=>-1===lt(h,l)?null:at(e,((e,t)=>-1===lt(lt(V,l),t)?null:at(e,(([,e])=>null!=e?e:null),((e,l)=>Vt(l)))),ae)),ae),at(z,(([,e])=>null!=e?e:null),((e,l)=>Vt(l)))],Sl=()=>({cellsTouched:t,valuesTouched:n,changedCells:it(E,xt,Vt),invalidCells:it($),changedValues:at(z,xt,Vt),invalidValues:at(A),changedTableIds:at(h),changedRowIds:ot(V),changedCellIds:it(R),changedValueIds:at(j)}),xl=()=>it(Y),Vl=()=>et(Y),Rl=e=>et(lt(X,x(e))),Ol=e=>Hl(lt(Y,x(e))),ql=e=>et(lt(Y,x(e))),Pl=(e,l,t,n=0,s)=>{return W(L(B((r=lt(Y,x(e)),a=(e,t)=>[O(l)?t:lt(e,x(l)),t],W([...null!=(o=null==r?void 0:r.entries())?o:[]],(([e,l])=>a(l,e)))),(([e],[l])=>{return((null!=(n=e)?n:0)<(null!=(s=l)?s:0)?-1:1)*(t?-1:1);var n,s})),n,O(s)?s:n+s),(([,e])=>e));var r,a,o},Nl=(e,l)=>et(lt(lt(Y,x(e)),x(l))),El=(e,l,t)=>lt(lt(lt(Y,x(e)),x(l)),x(t)),Ll=()=>at(Z),Ml=()=>et(Z),jl=e=>lt(Z,x(e)),zl=()=>!Gl(Y),$l=e=>Ul(Y,x(e)),Al=(e,l)=>Ul(lt(X,x(e)),x(l)),Fl=(e,l)=>Ul(lt(Y,x(e)),x(l)),Jl=(e,l,t)=>Ul(lt(lt(Y,x(e)),x(l)),x(t)),Dl=()=>!Gl(Z),Kl=e=>Ul(Z,x(e)),mt=e=>Tl((()=>(e=>Rt(e,Me,bl))(e)?Ge(e):0)),bt=e=>Tl((()=>$e(e)?el(e):0)),pt=e=>{try{Ue(ie(e))}catch(e){}return $t},gt=l=>Tl((()=>{if((e=Rt(l,(e=>Rt(e,Le))))&&(De(l),!Gl(Y))){const e=xl();ft(),mt(e)}})),vt=e=>Tl((()=>{if(l=(e=>Rt(e,Le))(e)){const t=Ll();Lt(),Nt(),l=!0,We(e),bt(t)}})),ft=()=>Tl((()=>Ge({}))),wt=e=>Tl((e=>Ul(Y,e)?sl(e):0),e),Pt=(e,l)=>Tl(((e,l)=>q(lt(Y,e),(t=>Ul(t,l)?rl(e,t,l):0))),e,l),Nt=()=>Tl((()=>el({}))),Et=()=>Tl((()=>{De({}),e=!1})),Lt=()=>Tl((()=>{We({}),l=!1})),Mt=(e,l)=>{if(-1!=i){jt();const t=e();return zt(l),t}},jt=()=>(-1!=i&&i++,1==i&&Pe(Re,void 0,kl,Sl),$t),zt=e=>(i>0&&(i--,0==i&&(t=!Gl(E),n=!Gl(z),i=1,fl(1),t&&wl(1),Il(1),n&&Cl(1),(null==e?void 0:e(kl,Sl))&&(Yl(E,((e,l)=>Yl(e,((e,t)=>Yl(e,(([e],n)=>Be($t,l,t,n,e))))))),Yl(z,(([e],l)=>Qe($t,l,e))),t=n=!1),Pe(Oe[0],void 0,kl,Sl),i=-1,fl(0),t&&wl(0),Il(0),n&&Cl(0),Pe(Oe[1],void 0,kl,Sl),i=0,t=n=!1,r=zl(),a=Dl(),Q([h,k,S,V,R,E,$,j,z,A],Xl))),$t),$t={getContent:()=>[xl(),Ll()],getTables:xl,getTableIds:Vl,getTable:e=>ot(lt(Y,x(e))),getTableCellIds:Rl,getRowCount:Ol,getRowIds:ql,getSortedRowIds:Pl,getRow:(e,l)=>at(lt(lt(Y,x(e)),x(l))),getCellIds:Nl,getCell:El,getValues:Ll,getValueIds:Ml,getValue:jl,hasTables:zl,hasTable:$l,hasTableCell:Al,hasRow:Fl,hasCell:Jl,hasValues:Dl,hasValue:Kl,getTablesJson:()=>oe(Y),getValuesJson:()=>oe(Z),getJson:()=>oe([Y,Z]),getTablesSchemaJson:()=>oe(F),getValuesSchemaJson:()=>oe(D),getSchemaJson:()=>oe([F,D]),hasTablesSchema:()=>e,hasValuesSchema:()=>l,setContent:([e,l])=>Tl((()=>{(ae(e)?ft:mt)(e),(ae(l)?Nt:bt)(l)})),setTables:mt,setTable:(e,l)=>Tl((e=>Me(l,e)?Ke(e,l):0),e),setRow:(e,l,t)=>Tl(((e,l)=>je(e,l,t)?Xe(e,nl(e),l,t):0),e,l),addRow:(e,l,t=!0)=>Mt((()=>{let n;return je(e,n,l)&&(e=x(e),Xe(e,nl(e),n=tl(e,t?1:0),l)),n})),setPartialRow:(e,l,t)=>Tl(((e,l)=>{if(je(e,l,t,1)){const n=nl(e);re(t,((t,s)=>Ze(e,n,l,s,t)))}}),e,l),setCell:(e,l,t,n)=>Tl(((e,l,t)=>q(ze(e,l,t,N(n)?n(El(e,l,t)):n),(n=>Ze(e,nl(e),l,t,n)))),e,l,t),setValues:bt,setPartialValues:e=>Tl((()=>$e(e,1)?re(e,((e,l)=>ll(l,e))):0)),setValue:(e,l)=>Tl((e=>q(Ae(e,N(l)?l(jl(e)):l),(l=>ll(e,l)))),e),setTransactionChanges:e=>Tl((()=>{re(e[0],((e,l)=>O(e)?wt(l):re(e,((e,t)=>O(e)?Pt(l,t):re(e,((e,n)=>Be($t,l,t,n,e))))))),re(e[1],((e,l)=>Qe($t,l,e)))})),setTablesJson:pt,setValuesJson:e=>{try{_e(ie(e))}catch(e){}return $t},setJson:e=>Tl((()=>{try{const[l,t]=ie(e);Ue(l),_e(t)}catch(l){pt(e)}})),setTablesSchema:gt,setValuesSchema:vt,setSchema:(e,l)=>Tl((()=>{gt(e),vt(l)})),delTables:ft,delTable:wt,delRow:Pt,delCell:(e,l,t,n)=>Tl(((e,l,t)=>q(lt(Y,e),(s=>q(lt(s,l),(r=>Ul(r,t)?al(e,s,l,r,t,n):0))))),e,l,t),delValues:Nt,delValue:e=>Tl((e=>Ul(Z,e)?ol(e):0),e),delTablesSchema:Et,delValuesSchema:Lt,delSchema:()=>Tl((()=>{Et(),Lt()})),transaction:Mt,startTransaction:jt,finishTransaction:zt,forEachTable:e=>Yl(Y,((l,t)=>e(t,(e=>Yl(l,((l,t)=>e(t,(e=>tt(l,e))))))))),forEachTableCell:(e,l)=>tt(lt(X,x(e)),l),forEachRow:(e,l)=>Yl(lt(Y,x(e)),((e,t)=>l(t,(l=>tt(e,l))))),forEachCell:(e,l,t)=>tt(lt(lt(Y,x(e)),x(l)),t),forEachValue:e=>tt(Z,e),addSortedRowIdsListener:(e,l,t,n,s,r,a)=>{let o=Pl(e,l,t,n,s);return qe((()=>{const a=Pl(e,l,t,n,s);var i,u,d;u=o,M(i=a)===M(u)&&(d=(e,l)=>u[l]===e,i.every(d))||(o=a,r($t,e,l,t,n,s,o))}),pe[a?1:0],[e,l],[Vl])},addStartTransactionListener:e=>qe(e,Re),addWillFinishTransactionListener:e=>qe(e,Oe[0]),addDidFinishTransactionListener:e=>qe(e,Oe[1]),callListener:e=>(Ee(e),$t),delListener:e=>(Ne(e),$t),getListenerStats:()=>({hasTables:kt(_),tables:kt(le),tableIds:kt(te),hasTable:kt(ue),table:kt(de),tableCellIds:kt(ce),hasTableCell:kt(he,Ql),rowCount:kt(me),rowIds:kt(be),sortedRowIds:kt(pe),hasRow:kt(ge,Ql),row:kt(ve,Ql),cellIds:kt(fe,Ql),hasCell:kt(Ie,Wl),cell:kt(ye,Wl),invalidCell:kt(we,Wl),hasValues:kt(Te),values:kt(ke),valueIds:kt(Se),hasValue:kt(xe),value:kt(Ve),invalidValue:kt(Ce),transaction:Bl(Re)+kt(Oe)}),createStore:qt,addListener:qe,callListeners:Pe};return re({[c+b]:[0,_,[],()=>[zl()]],[b]:[0,le],[p]:[0,te],[c+m]:[1,ue,[Vl],e=>[$l(...e)]],[m]:[1,de,[Vl]],[m+y]:[1,ce,[Vl]],[c+m+I]:[2,he,[Vl,Rl],e=>[Al(...e)]],[v]:[1,me,[Vl]],[f]:[1,be,[Vl]],[c+g]:[2,ge,[Vl,ql],e=>[Fl(...e)]],[g]:[2,ve,[Vl,ql]],[y]:[2,fe,[Vl,ql]],[c+I]:[3,Ie,[Vl,ql,Nl],e=>[Jl(...e)]],[I]:[3,ye,[Vl,ql,Nl],e=>Tt(El(...e))],InvalidCell:[3,we],[c+C]:[0,Te,[],()=>[Dl()]],[C]:[0,ke],[T]:[0,Se],[c+w]:[1,xe,[Ml],e=>[Kl(...e)]],[w]:[1,Ve,[Ml],e=>Tt(jl(e[0]))],InvalidValue:[1,Ce]},(([e,l,t,n],s)=>{$t["add"+s+"Listener"]=(...s)=>qe(s[e],l[s[e+1]?1:0],e>0?L(s,0,e):void 0,t,n)})),ee($t)},Pt=({position:e="right",open:l=!1})=>{const n=t.useCreateStore(qt),s=ce.indexOf(e);return t.useCreatePersister(n,(e=>{return((e,l,t,n)=>((e,l,t,n,s,r,[a,o]=[],i=[])=>{let u,d,c,h=0,m=0,b=0,p=0;st(bt,i,(()=>0)),st(pt,i,(()=>[]));const g=e=>mt(void 0,null,(function*(){return 2!=h&&(h=1,m++,yield v.schedule((()=>mt(void 0,null,(function*(){yield e(),h=0}))))),v})),v={load:(t,n)=>mt(void 0,null,(function*(){return yield g((()=>mt(void 0,null,(function*(){try{e.setContent(yield l())}catch(l){e.setContent([t,n])}}))))})),startAutoLoad:(...t)=>mt(void 0,[...t],(function*(t={},s={}){return v.stopAutoLoad(),yield v.load(t,s),p=1,c=n(((t,n)=>mt(void 0,null,(function*(){if(n){const l=n();yield g((()=>mt(void 0,null,(function*(){return e.setTransactionChanges(l)}))))}else yield g((()=>mt(void 0,null,(function*(){var n;try{e.setContent(null!=(n=null==t?void 0:t())?n:yield l())}catch(e){null==r||r(e)}}))))})))),v})),stopAutoLoad:()=>(p&&(s(c),c=void 0,p=0),v),save:l=>mt(void 0,null,(function*(){return 1!=h&&(h=2,b++,yield v.schedule((()=>mt(void 0,null,(function*(){try{yield t(e.getContent,l)}catch(e){null==r||r(e)}h=0}))))),v})),startAutoSave:()=>mt(void 0,null,(function*(){return yield v.stopAutoSave().save(),u=e.addDidFinishTransactionListener(((e,l)=>{const[t,n]=l();ae(t)&&ae(n)||v.save((()=>[t,n]))})),v})),stopAutoSave:()=>(q(u,e.delListener),u=void 0,v),schedule:(...e)=>mt(void 0,null,(function*(){return G(lt(pt,i),...e),yield mt(void 0,null,(function*(){if(!lt(bt,i)){for(nt(bt,i,1);!O(d=K(lt(pt,i)));)try{yield d()}catch(e){null==r||r(e)}nt(bt,i,0)}})),v})),getStore:()=>e,destroy:()=>v.stopAutoLoad().stopAutoSave(),getStats:()=>({loads:m,saves:b})};return a&&(v[a]=()=>o),ee(v)})(e,(()=>gt(void 0,null,(function*(){return ie(t.getItem(l))}))),(e=>gt(void 0,null,(function*(){return t.setItem(l,oe(e()))}))),(e=>{const n=n=>{n.storageArea===t&&n.key===l&&e((()=>ie(n.newValue)))};return ft.addEventListener(vt,n),n}),(e=>ft.removeEventListener(vt,e)),n,["getStorageName",l]))(e,ue,sessionStorage,l);var l}),void 0,(e=>{return t=function*(){yield e.load(void 0,{position:-1==s?1:s,open:!!l}),yield e.startAutoSave()},new Promise(((e,l)=>{var n=e=>{try{r(t.next(e))}catch(e){l(e)}},s=e=>{try{r(t.throw(e))}catch(e){l(e)}},r=l=>l.done?e(l.value):Promise.resolve(l.value).then(n,s);r((t=t.apply(void 0,null)).next())}));var t})),$(z,null,$("aside",{id:ue},$(Je,{s:n}),$(Jl,{s:n})),$("style",null,Fe))};var Nt=Object.defineProperty,Et=Object.getOwnPropertySymbols,Lt=Object.prototype.hasOwnProperty,Mt=Object.prototype.propertyIsEnumerable,jt=(e,l,t)=>l in e?Nt(e,l,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[l]=t;e.EditableCellView=Tl,e.EditableValueView=kl,e.RelationshipInHtmlTable=wl,e.ResultSortedTableInHtmlTable=Cl,e.ResultTableInHtmlTable=e=>{var l=e,{queryId:n,queries:s,customCells:r}=l,a=tl(l,["queryId","queries","customCells"]);return $(bl,ll(el({},a),{params:ul(ml(t.useResultTableCellIds(n,s),r,t.ResultCellView),cl(s,n),t.useResultRowIds(n,s))}))},e.SliceInHtmlTable=yl,e.SortedTableInHtmlTable=fl,e.SortedTablePaginator=Sl,e.StoreInspector=e=>$(Pt,((e,l)=>{for(var t in l||(l={}))Lt.call(l,t)&&jt(e,t,l[t]);if(Et)for(var t of Et(l))Mt.call(l,t)&&jt(e,t,l[t]);return e})({},e)),e.TableInHtmlTable=e=>{var l=e,{tableId:n,store:s,editable:r,customCells:a}=l,o=tl(l,["tableId","store","editable","customCells"]);return $(bl,ll(el({},o),{params:ul(ml(t.useTableCellIds(n,s),a,r?Tl:t.CellView),dl(s,n),t.useRowIds(n,s))}))},e.ValuesInHtmlTable=Il},"object"==typeof exports&&"undefined"!=typeof module?l(exports,require("react"),require("./ui-react")):"function"==typeof define&&define.amd?define(["exports","react","./ui-react"],l):l((e="undefined"!=typeof globalThis?globalThis:e||self).TinyBaseUiReactDomDebug={},e.React,e.TinyBaseUiReact);
|
|
1
|
+
var e,l;e=this,l=function(e,l,t){"use strict";const n=e=>typeof e,s="",r=n(s),a=n(!0),o=n(0),i=n(n),u="type",d="default",c="Has",h="Ids",m="Table",b=m+"s",p=m+h,g="Row",v=g+"Count",f=g+h,I="Cell",y=I+h,w="Value",C=w+"s",T=w+h,k="currentTarget",S="value",x=e=>s+e,V=Math.floor,R=isFinite,O=e=>null==e,q=(e,l,t)=>O(e)?null==t?void 0:t():l(e),P=e=>e==r||e==a,N=e=>n(e)==i,E=e=>Array.isArray(e),L=(e,l,t)=>e.slice(l,t),M=e=>e.length,{PureComponent:j,Fragment:z,createElement:$,useCallback:A,useLayoutEffect:F,useRef:J,useState:D}=l,H=(e,...l)=>O(e)?{}:e(...l),B=(e,l)=>e.sort(l),Q=(e,l)=>e.forEach(l),W=(e,l)=>e.map(l),U=e=>0==M(e),G=(e,...l)=>e.push(...l),K=e=>e.shift(),X=Object,Y=e=>X.getPrototypeOf(e),Z=X.keys,_=X.isFrozen,ee=X.freeze,le=e=>!O(e)&&q(Y(e),(e=>e==X.prototype||O(Y(e))),(()=>!0)),te=(e=[])=>X.fromEntries(e),ne=(e,l)=>!O(((e,l)=>q(e,(e=>e[l])))(e,l)),se=(e,l)=>(delete e[l],e),re=(e,l)=>W(X.entries(e),(([e,t])=>l(t,e))),ae=e=>le(e)&&0==(e=>M(Z(e)))(e),oe=e=>JSON.stringify(e,((e,l)=>l instanceof Map?X.fromEntries([...l]):l)),ie=JSON.parse,ue="tinybaseStoreInspector",de="TinyBase Store Inspector",ce=["left","top","bottom","right","full"],he="state",me="sort",be="open",pe="position",ge=be,ve="editable",fe=(...e)=>oe(e),Ie=(e,l)=>W(B(e),l),ye=(e,l)=>[!!t.useCell(he,e,ve,l),A((t=>{l.setCell(he,e,ve,(e=>!e)),t.preventDefault()}),[l,e])],we="M20 80l5-15l40-40l10 10l-40 40l-15 5m5-15l10 10",Ce='content:url("',Te=Ce+"data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100' stroke-width='4' stroke='white' fill='none'>",ke='</svg>")',Se=Ce+"data:image/svg+xml,%3csvg viewBox='0 0 680 680' xmlns='http://www.w3.org/2000/svg' style='width:680px%3bheight:680px'%3e %3cpath stroke='white' stroke-width='80' fill='none' d='M340 617a84 241 90 11.01 0zM131 475a94 254 70 10428-124 114 286 70 01-428 124zm0-140a94 254 70 10428-124 114 286 70 01-428 124zm-12-127a94 254 70 00306 38 90 260 90 01-306-38zm221 3a74 241 90 11.01 0z' /%3e %3cpath fill='%23d81b60' d='M131 475a94 254 70 10428-124 114 286 70 01-428 124zm0-140a94 254 70 10428-124 114 286 70 01-428 124z' /%3e %3cpath d='M249 619a94 240 90 00308-128 114 289 70 01-308 128zM119 208a94 254 70 00306 38 90 260 90 01-306-38zm221 3a74 241 90 11.01 0z' /%3e%3c/svg%3e\")",xe=W([[20,20,20,60],[20,20,60,20],[20,60,60,20],[60,20,20,60],[30,30,40,40]],(([e,l,t,n])=>Te+`<rect x='20' y='20' width='60' height='60' fill='grey'/><rect x='${e}' y='${l}' width='${t}' height='${n}' fill='white'/>`+ke)),Ve=Te+"<path d='M20 20l60 60M20 80l60-60' />"+ke,Re=Te+`<path d='${we}' />`+ke,Oe=Te+`<path d='${we}M20 20l60 60' />`+ke;var qe=Object.defineProperty,Pe=Object.defineProperties,Ne=Object.getOwnPropertyDescriptors,Ee=Object.getOwnPropertySymbols,Le=Object.prototype.hasOwnProperty,Me=Object.prototype.propertyIsEnumerable,je=(e,l,t)=>l in e?qe(e,l,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[l]=t,ze=(e,l)=>{for(var t in l||(l={}))Le.call(l,t)&&je(e,t,l[t]);if(Ee)for(var t of Ee(l))Me.call(l,t)&&je(e,t,l[t]);return e},$e=(e,l)=>Pe(e,Ne(l));const Ae="*::-webkit-scrollbar",Fe=((e,l="")=>e.join(l))(re($e(ze($e(ze($e(ze({"":"all:initial;font-family:sans-serif;font-size:0.75rem;position:fixed;z-index:999999","*":"all:revert","*::before":"all:revert","*::after":"all:revert",[Ae]:"width:0.5rem;height:0.5rem;",[Ae+"-track"]:"background:#111",[Ae+"-thumb"]:"background:#999;border:1px solid #111",[Ae+"-thumb:hover"]:"background:#fff",[Ae+"-corner"]:"background:#111",img:"width:1rem;height:1rem;background:#111;border:0;vertical-align:text-bottom",">img":"padding:0.25rem;bottom:0;right:0;position:fixed;"+Se},te(W(["bottom:0;left:0","top:0;right:0"],((e,l)=>[`>img[data-position='${l}']`,e])))),{main:"display:flex;flex-direction:column;background:#111d;color:#fff;position:fixed;"}),te(W(["bottom:0;left:0;width:35vw;height:100vh","top:0;right:0;width:100vw;height:30vh","bottom:0;left:0;width:100vw;height:30vh","top:0;right:0;width:35vw;height:100vh","top:0;right:0;width:100vw;height:100vh"],((e,l)=>[`main[data-position='${l}']`,e])))),{header:"display:flex;padding:0.25rem;background:#000;align-items:center","header>img:nth-of-type(1)":Se,"header>img:nth-of-type(6)":Ve}),te(W(xe,((e,l)=>[`header>img[data-id='${l}']`,e])))),{"header>span":"flex:1;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;margin-left:0.25rem",article:"padding:0.25rem 0.25rem 0.25rem 0.5rem;overflow:auto;flex:1",details:"margin-left:0.75rem;width:fit-content;","details img":"display:none","details[open]>summary img":"display:unset;background:none;margin-left:0.25rem","details[open]>summary img.edit":Re,"details[open]>summary img.done":Oe,summary:"margin-left:-0.75rem;line-height:1.25rem;user-select:none;width:fit-content",table:"border-collapse:collapse;table-layout:fixed;margin-bottom:0.5rem","table input":"background:#111;color:unset;padding:0 0.25rem;border:0;font-size:unset;vertical-align:top;margin:0",'table input[type="number"]':"width:4rem","table tbody button":"font-size:0;background:#fff;border-radius:50%;margin:0 0.125rem 0 0;width:0.85rem;color:#111","table button:first-letter":"font-size:0.75rem",thead:"background:#222","th:nth-of-type(1)":"min-width:2rem;","th.sorted":"background:#000","table caption":"text-align:left;white-space:nowrap;line-height:1.25rem",button:"width:1.5rem;border:none;background:none;color:#fff;padding:0","button[disabled]":"color:#777","button.next":"margin-right:0.5rem",[`th,#${ue} td`]:"overflow:hidden;text-overflow:ellipsis;padding:0.25rem 0.5rem;max-width:12rem;white-space:nowrap;border-width:1px 0;border-style:solid;border-color:#777;text-align:left","span.warn":"margin:0.25rem;color:#d81b60"}),((e,l)=>e?`#${ue} ${l}{${e}}`:""))),Je=({s:e})=>{var l;const n=null!=(l=t.useValue(pe,e))?l:1,s=t.useSetValueCallback(ge,(()=>!0),[],e);return t.useValue(ge,e)?null:$("img",{onClick:s,title:de,"data-position":n})},De=({uniqueId:e,summary:l,editable:n,handleEditable:s,children:r,s:a})=>{const o=!!t.useCell(he,e,be,a),i=t.useSetCellCallback(he,e,be,(e=>e[k].open),[],a);return $("details",{open:o,onToggle:i},$("summary",null,l,s?$("img",{onClick:s,className:n?"done":"edit"}):null),r)},He=e=>{const l=n(e);return P(l)||l==o&&R(e)?l:void 0},Be=(e,l,t,n,s)=>O(s)?e.delCell(l,t,n,!0):e.setCell(l,t,n,s),Qe=(e,l,t)=>O(t)?e.delValue(l):e.setValue(l,t),We=(e,l,t,n)=>e==r?l:e==o?t:n;var Ue=Object.defineProperty,Ge=Object.defineProperties,Ke=Object.getOwnPropertyDescriptors,Xe=Object.getOwnPropertySymbols,Ye=Object.prototype.hasOwnProperty,Ze=Object.prototype.propertyIsEnumerable,_e=(e,l,t)=>l in e?Ue(e,l,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[l]=t,el=(e,l)=>{for(var t in l||(l={}))Ye.call(l,t)&&_e(e,t,l[t]);if(Xe)for(var t of Xe(l))Ze.call(l,t)&&_e(e,t,l[t]);return e},ll=(e,l)=>Ge(e,Ke(l)),tl=(e,l)=>{var t={};for(var n in e)Ye.call(e,n)&&l.indexOf(n)<0&&(t[n]=e[n]);if(null!=e&&Xe)for(var n of Xe(e))l.indexOf(n)<0&&Ze.call(e,n)&&(t[n]=e[n]);return t};const{useCallback:nl,useMemo:sl,useState:rl}=l,al="editable",ol=(e,l)=>W(t.useTableCellIds(e,l),(l=>e+"."+l)),il=(e,l,t)=>{const n=nl(e,l);return t?n:void 0},ul=(...e)=>sl((()=>e),e),dl=(e,l)=>sl((()=>({store:e,tableId:l})),[e,l]),cl=(e,l)=>sl((()=>({queries:e,queryId:l})),[e,l]),hl=(e,l=!1,t,n=0,s,r,a,o)=>{const[[i,u,d],c]=rl([e,l,n]),h=nl((e=>{c(e),null==o||o(e)}),[o]),m=il((e=>h([e,e==i&&!u,d])),[h,i,u,d],t),b=nl((e=>h([i,u,e])),[h,i,u]),p=!0===a?Sl:a;return[[i,u,d],m,sl((()=>!1===a?null:$(p,{offset:d,limit:s,total:r,onChange:b})),[a,p,d,s,r,b])]},ml=(e,l,t)=>sl((()=>{const s=null!=l?l:e;return te(re(E(s)?te(W(s,(e=>[e,e]))):s,((e,l)=>{return[l,el(el({},{label:l,component:t}),(s=e,n(s)==r?{label:e}:e))];var s})))}),[l,t,e]),bl=({className:e,headerRow:l,idColumn:t,params:[n,s,r,a,o,i]})=>$("table",{className:e},i?$("caption",null,i):null,!1===l?null:$("thead",null,$("tr",null,!1===t?null:$(pl,{sort:null!=a?a:[],label:"Id",onClick:o}),re(n,(({label:e},l)=>$(pl,{key:l,cellId:l,label:e,sort:null!=a?a:[],onClick:o}))))),$("tbody",null,W(r,(e=>$("tr",{key:e},!1===t?null:$("th",null,e),re(n,(({component:l,getComponentProps:t},n)=>$("td",{key:n},$(l,ll(el(el({},H(t,e,n)),s),{rowId:e,cellId:n})))))))))),pl=({cellId:e,sort:[l,t],label:n=(null!=e?e:s),onClick:r})=>$("th",{onClick:il((()=>null==r?void 0:r(e)),[r,e],r),className:O(t)||l!=e?void 0:`sorted ${t?"de":"a"}scending`},O(t)||l!=e?null:(t?"↓":"↑")+" ",n),gl=({localRowId:e,params:[n,s,r,a,o,i,u]})=>{const d=t.useRemoteRowId(o,e,i);return $("tr",null,!1===n?null:$(l.Fragment,null,$("th",null,e),$("th",null,d)),re(s,(({component:l,getComponentProps:t},n)=>{const[s,o]=n.split(".",2),i=s===r?e:s===a?d:null;return O(i)?null:$("td",{key:n},$(l,ll(el({},H(t,i,o)),{store:u,tableId:s,rowId:i,cellId:o})))})))},vl=({thing:e,onThingChange:l,className:t,hasSchema:n,showType:s=!0})=>{const[i,u]=rl(),[d,c]=rl(),[h,m]=rl(),[b,p]=rl(),[g,v]=rl();d!==e&&(u(He(e)),c(e),m(e+""),p(Number(e)||0),v(!!e));const f=nl(((e,t)=>{t(e),c(e),l(e)}),[l]),I=nl((()=>{if(!(null==n?void 0:n())){const e=We(i,o,a,r),t=We(e,h,b,g);u(e),c(t),l(t)}}),[n,l,h,b,g,i]);return $("div",{className:t},s?$("button",{className:i,onClick:I},i):null,We(i,$("input",{key:i,value:h,onChange:nl((e=>f(e[k][S]+"",m)),[f])}),$("input",{key:i,type:"number",value:b,onChange:nl((e=>f(Number(e[k][S]||0),p)),[f])}),$("input",{key:i,type:"checkbox",checked:g,onChange:nl((e=>f(!!e[k].checked,v)),[f])})))},fl=e=>{var l=e,{tableId:n,cellId:s,descending:r,offset:a,limit:o,store:i,editable:u,sortOnClick:d,paginator:c=!1,onChange:h,customCells:m}=l,b=tl(l,["tableId","cellId","descending","offset","limit","store","editable","sortOnClick","paginator","onChange","customCells"]);const[p,g,v]=hl(s,r,d,a,o,t.useRowCount(n,i),c,h);return $(bl,ll(el({},b),{params:ul(ml(t.useTableCellIds(n,i),m,u?Tl:t.CellView),dl(i,n),t.useSortedRowIds(n,...p,o,i),p,g,v)}))},Il=({store:e,editable:l=!1,valueComponent:n=(l?kl:t.ValueView),getValueComponentProps:s,className:r,headerRow:a,idColumn:o})=>$("table",{className:r},!1===a?null:$("thead",null,$("tr",null,!1===o?null:$("th",null,"Id"),$("th",null,w))),$("tbody",null,W(t.useValueIds(e),(l=>$("tr",{key:l},!1===o?null:$("th",null,l),$("td",null,$(n,ll(el({},H(s,l)),{valueId:l,store:e})))))))),yl=e=>{var l=e,{indexId:n,sliceId:s,indexes:r,editable:a,customCells:o}=l,i=tl(l,["indexId","sliceId","indexes","editable","customCells"]);const[u,d,c]=((e,l)=>[e,null==e?void 0:e.getStore(),null==e?void 0:e.getTableId(l)])(t.useIndexesOrIndexesById(r),n);return $(bl,ll(el({},i),{params:ul(ml(t.useTableCellIds(c,d),o,a?Tl:t.CellView),dl(d,c),t.useSliceRowIds(n,s,u))}))},wl=({relationshipId:e,relationships:n,editable:s,customCells:r,className:a,headerRow:o,idColumn:i=!0})=>{const[u,d,c,h]=((e,l)=>[e,null==e?void 0:e.getStore(),null==e?void 0:e.getLocalTableId(l),null==e?void 0:e.getRemoteTableId(l)])(t.useRelationshipsOrRelationshipsById(n),e),m=ml([...ol(c,d),...ol(h,d)],r,s?Tl:t.CellView),b=ul(i,m,c,h,e,u,d);return $("table",{className:a},!1===o?null:$("thead",null,$("tr",null,!1===i?null:$(l.Fragment,null,$("th",null,c,".Id"),$("th",null,h,".Id")),re(m,(({label:e},l)=>$("th",{key:l},e))))),$("tbody",null,W(t.useRowIds(c,d),(e=>$(gl,{key:e,localRowId:e,params:b})))))},Cl=e=>{var l=e,{queryId:n,cellId:s,descending:r,offset:a,limit:o,queries:i,sortOnClick:u,paginator:d=!1,customCells:c,onChange:h}=l,m=tl(l,["queryId","cellId","descending","offset","limit","queries","sortOnClick","paginator","customCells","onChange"]);const[b,p,g]=hl(s,r,u,a,o,t.useResultRowCount(n,i),d,h);return $(bl,ll(el({},m),{params:ul(ml(t.useResultTableCellIds(n,i),c,t.ResultCellView),cl(i,n),t.useResultSortedRowIds(n,...b,o,i),b,p,g)}))},Tl=({tableId:e,rowId:l,cellId:n,store:s,className:r,showType:a})=>{var o;return $(vl,{thing:t.useCell(e,l,n,s),onThingChange:t.useSetCellCallback(e,l,n,(e=>e),[],s),className:null!=r?r:al+I,showType:a,hasSchema:null==(o=t.useStoreOrStoreById(s))?void 0:o.hasTablesSchema})},kl=({valueId:e,store:l,className:n,showType:s})=>{var r;return $(vl,{thing:t.useValue(e,l),onThingChange:t.useSetValueCallback(e,(e=>e),[],l),className:null!=n?n:al+w,showType:s,hasSchema:null==(r=t.useStoreOrStoreById(l))?void 0:r.hasValuesSchema})},Sl=({onChange:e,total:t,offset:n=0,limit:s=t,singular:r="row",plural:a=r+"s"})=>{(n>t||n<0)&&(n=0,e(0));const o=il((()=>e(n-s)),[e,n,s],n>0),i=il((()=>e(n+s)),[e,n,s],n+s<t);return $(l.Fragment,null,t>s&&$(l.Fragment,null,$("button",{className:"previous",disabled:0==n,onClick:o},"←"),$("button",{className:"next",disabled:n+s>=t,onClick:i},"→"),n+1," to ",Math.min(t,n+s)," of "),t," ",1!=t?a:r)},xl=({indexes:e,indexesId:l,indexId:n,s:s})=>$(De,{uniqueId:fe("i",l,n),summary:"Index: "+n,s:s},W(t.useSliceIds(n,e),(t=>$(Vl,{indexes:e,indexesId:l,indexId:n,sliceId:t,s:s,key:t})))),Vl=({indexes:e,indexesId:l,indexId:t,sliceId:n,s:s})=>{const r=fe("i",l,t,n),[a,o]=ye(r,s);return $(De,{uniqueId:r,summary:"Slice: "+n,editable:a,handleEditable:o,s:s},$(yl,{sliceId:n,indexId:t,indexes:e,editable:a}))},Rl=({indexesId:e,s:l})=>{const n=t.useIndexes(e),s=t.useIndexIds(n);return O(n)?null:$(De,{uniqueId:fe("i",e),summary:"Indexes: "+(null!=e?e:d),s:l},U(s)?"No indexes defined":Ie(s,(t=>$(xl,{indexes:n,indexesId:e,indexId:t,s:l,key:t}))))},Ol=({metrics:e,metricId:l})=>$("tr",null,$("th",null,l),$("td",null,null==e?void 0:e.getTableId(l)),$("td",null,t.useMetric(l,e))),ql=({metricsId:e,s:l})=>{const n=t.useMetrics(e),s=t.useMetricIds(n);return O(n)?null:$(De,{uniqueId:fe("m",e),summary:"Metrics: "+(null!=e?e:d),s:l},U(s)?"No metrics defined":$("table",null,$("thead",null,$("th",null,"Metric Id"),$("th",null,"Table Id"),$("th",null,"Metric")),$("tbody",null,W(s,(e=>$(Ol,{metrics:n,metricId:e,key:e}))))))},Pl=({queries:e,queriesId:l,queryId:n,s:s})=>{var r;const a=fe("q",l,n),[o,i,u]=ie(null!=(r=t.useCell(he,a,me,s))?r:"[]"),d=t.useSetCellCallback(he,a,me,oe,[],s);return $(De,{uniqueId:a,summary:"Query: "+n,s:s},$(Cl,{queryId:n,queries:e,cellId:o,descending:i,offset:u,limit:10,paginator:!0,sortOnClick:!0,onChange:d}))},Nl=({queriesId:e,s:l})=>{const n=t.useQueries(e),s=t.useQueryIds(n);return O(n)?null:$(De,{uniqueId:fe("q",e),summary:"Queries: "+(null!=e?e:d),s:l},U(s)?"No queries defined":Ie(s,(t=>$(Pl,{queries:n,queriesId:e,queryId:t,s:l,key:t}))))},El=({relationships:e,relationshipsId:l,relationshipId:t,s:n})=>{const s=fe("r",l,t),[r,a]=ye(s,n);return $(De,{uniqueId:s,summary:"Relationship: "+t,editable:r,handleEditable:a,s:n},$(wl,{relationshipId:t,relationships:e,editable:r}))},Ll=({relationshipsId:e,s:l})=>{const n=t.useRelationships(e),s=t.useRelationshipIds(n);return O(n)?null:$(De,{uniqueId:fe("r",e),summary:"Relationships: "+(null!=e?e:d),s:l},U(s)?"No relationships defined":Ie(s,(t=>$(El,{relationships:n,relationshipsId:e,relationshipId:t,s:l,key:t}))))},Ml=({tableId:e,store:l,storeId:n,s:s})=>{var r;const a=fe("t",n,e),[o,i,u]=ie(null!=(r=t.useCell(he,a,me,s))?r:"[]"),d=t.useSetCellCallback(he,a,me,oe,[],s),[c,h]=ye(a,s);return $(De,{uniqueId:a,summary:m+": "+e,editable:c,handleEditable:h,s:s},$(fl,{tableId:e,store:l,cellId:o,descending:i,offset:u,limit:10,paginator:!0,sortOnClick:!0,onChange:d,editable:c}))},jl=({store:e,storeId:l,s:n})=>{const s=fe("v",l),[r,a]=ye(s,n);return U(t.useValueIds(e))?null:$(De,{uniqueId:s,summary:C,editable:r,handleEditable:a,s:n},$(Il,{store:e,editable:r}))},zl=({storeId:e,s:l})=>{const n=t.useStore(e),s=t.useTableIds(n);return O(n)?null:$(De,{uniqueId:fe("s",e),summary:"Store: "+(null!=e?e:d),s:l},$(jl,{storeId:e,store:n,s:l}),Ie(s,(t=>$(Ml,{store:n,storeId:e,tableId:t,s:l,key:t}))))},$l=({s:e})=>{const l=J(null),n=J(0),[s,r]=D(!1),{scrollLeft:a,scrollTop:o}=t.useValues(e);F((()=>{const e=l.current;if(e&&!s){const l=new MutationObserver((()=>{e.scrollWidth>=V(a)+e.clientWidth&&e.scrollHeight>=V(o)+e.clientHeight&&e.scrollTo(a,o)}));return l.observe(e,{childList:!0,subtree:!0}),()=>l.disconnect()}}),[s,a,o]);const i=A((l=>{const{scrollLeft:t,scrollTop:s}=l[k];cancelIdleCallback(n.current),n.current=requestIdleCallback((()=>{r(!0),e.setPartialValues({scrollLeft:t,scrollTop:s})}))}),[e]),u=t.useStore(),d=t.useStoreIds(),c=t.useMetrics(),h=t.useMetricsIds(),m=t.useIndexes(),b=t.useIndexesIds(),p=t.useRelationships(),g=t.useRelationshipsIds(),v=t.useQueries(),f=t.useQueriesIds();return O(u)&&U(d)&&O(c)&&U(h)&&O(m)&&U(b)&&O(p)&&U(g)&&O(v)&&U(f)?$("span",{className:"warn"},"There are no Stores or other objects to inspect. Make sure you placed the StoreInspector inside a Provider component."):$("article",{ref:l,onScroll:i},$(zl,{s:e}),W(d,(l=>$(zl,{storeId:l,s:e,key:l}))),$(ql,{s:e}),W(h,(l=>$(ql,{metricsId:l,s:e,key:l}))),$(Rl,{s:e}),W(b,(l=>$(Rl,{indexesId:l,s:e,key:l}))),$(Ll,{s:e}),W(g,(l=>$(Ll,{relationshipsId:l,s:e,key:l}))),$(Nl,{s:e}),W(f,(l=>$(Nl,{queriesId:l,s:e,key:l}))))};class Al extends j{constructor(e){super(e),this.componentDidCatch=(e,l)=>console.error(e,l.componentStack),this.state={e:0}}static getDerivedStateFromError(){return{e:1}}render(){return this.state.e?$("span",{className:"warn"},"Inspector error: please see console for details."):this.props.children}}const Fl=({s:e})=>{var l;const n=null!=(l=t.useValue(pe,e))?l:1,s=t.useSetValueCallback(ge,(()=>!1),[],e),r=t.useSetValueCallback(pe,(e=>Number(e[k].dataset.id)),[],e);return $("header",null,$("img",{title:de}),$("span",null,de),W(ce,((e,l)=>l==n?null:$("img",{onClick:r,"data-id":l,title:"Dock to "+e,key:l}))),$("img",{onClick:s,title:"Close"}))},Jl=({s:e})=>{var l;const n=null!=(l=t.useValue(pe,e))?l:1;return t.useValue(ge,e)?$("main",{"data-position":n},$(Fl,{s:e}),$(Al,null,$($l,{s:e}))):null},Dl=e=>l=>{return t=(l,t)=>l+e(t),Kl(l).reduce(t,0);var t},Hl=e=>{var l;return null!=(l=null==e?void 0:e.size)?l:0},Bl=Dl(Hl),Ql=Dl(Bl),Wl=Dl(Ql),Ul=(e,l)=>{var t;return null!=(t=null==e?void 0:e.has(l))&&t},Gl=e=>O(e)||0==Hl(e),Kl=e=>{var l;return[...null!=(l=null==e?void 0:e.values())?l:[]]},Xl=e=>e.clear(),Yl=(e,l)=>null==e?void 0:e.forEach(l),Zl=(e,l)=>null==e?void 0:e.delete(l),_l=e=>new Map(e),et=e=>{var l;return[...null!=(l=null==e?void 0:e.keys())?l:[]]},lt=(e,l)=>null==e?void 0:e.get(l),tt=(e,l)=>Yl(e,((e,t)=>l(t,e))),nt=(e,l,t)=>O(t)?(Zl(e,l),e):null==e?void 0:e.set(l,t),st=(e,l,t)=>(Ul(e,l)||nt(e,l,t()),lt(e,l)),rt=(e,l,t,n=nt)=>(re(l,((l,n)=>t(e,n,l))),tt(e,(t=>ne(l,t)?0:n(e,t))),e),at=(e,l,t)=>{const n={};return Yl(e,((e,s)=>{const r=l?l(e,s):e;!(null==t?void 0:t(r,e))&&(n[s]=r)})),n},ot=(e,l,t)=>at(e,(e=>at(e,l,t)),ae),it=(e,l,t)=>at(e,(e=>ot(e,l,t)),ae),ut=(e,l)=>{const t=_l();return Yl(e,((e,n)=>{var s;return t.set(n,null!=(s=null==l?void 0:l(e))?s:e)})),t},dt=e=>ut(e,ut),ct=e=>ut(e,dt),ht=(e,l,t,n,s=0)=>q((t?st:lt)(e,l[s],s>M(l)-2?t:_l),(r=>{if(s>M(l)-2)return(null==n?void 0:n(r))&&nt(e,l[s]),r;const a=ht(r,l,t,n,s+1);return Gl(r)&&nt(e,l[s]),a}));var mt=(e,l,t)=>new Promise(((n,s)=>{var r=e=>{try{o(t.next(e))}catch(e){s(e)}},a=e=>{try{o(t.throw(e))}catch(e){s(e)}},o=e=>e.done?n(e.value):Promise.resolve(e.value).then(r,a);o((t=t.apply(e,l)).next())}));const bt=_l(),pt=_l();var gt=(e,l,t)=>new Promise(((n,s)=>{var r=e=>{try{o(t.next(e))}catch(e){s(e)}},a=e=>{try{o(t.throw(e))}catch(e){s(e)}},o=e=>e.done?n(e.value):Promise.resolve(e.value).then(r,a);o((t=t.apply(e,l)).next())}));const vt="storage",ft=globalThis.window,It=e=>new Set(E(e)||O(e)?e:[e]),yt=(e,l)=>null==e?void 0:e.add(l),wt=/^\d+$/,Ct=()=>{const e=[];let l=0;return[t=>{var n;return null!=(n=t?K(e):null)?n:s+l++},l=>{wt.test(l)&&M(e)<1e3&&G(e,l)}]},Tt=e=>[e,e],kt=(e,l=Bl)=>l(e[0])+l(e[1]),St=()=>[_l(),_l()],xt=e=>[...e],Vt=([e,l])=>e===l,Rt=(e,l,t)=>O(e)||!le(e)||ae(e)||_(e)?(null==t||t(),!1):(re(e,((t,n)=>{l(t,n)||se(e,n)})),!ae(e)),Ot=(e,l,t)=>nt(e,l,lt(e,l)==-t?void 0:t),qt=()=>{let e,l,t=!1,n=!1,r=!1,a=!1,i=0;const h=_l(),k=_l(),S=_l(),V=_l(),R=_l(),E=_l(),j=_l(),z=_l(),$=_l(),A=_l(),F=_l(),J=_l(),D=_l(),H=_l(),U=It(),K=_l(),X=_l(),Y=_l(),Z=_l(),_=St(),le=St(),te=St(),ue=St(),de=St(),ce=St(),he=St(),me=St(),be=St(),pe=St(),ge=St(),ve=St(),fe=St(),Ie=St(),ye=St(),we=St(),Ce=St(),Te=St(),ke=St(),Se=St(),xe=St(),Ve=St(),Re=_l(),Oe=St(),[qe,Pe,Ne,Ee]=(e=>{let l;const[t,n]=Ct(),r=_l();return[(e,n,a,o=[],i=(()=>[]))=>{null!=l||(l=$t);const u=t(1);return nt(r,u,[e,n,a,o,i]),yt(ht(n,null!=a?a:[s],It),u),u},(e,t,...n)=>Q(((e,l=[s])=>{const t=[],n=(e,s)=>s==M(l)?G(t,e):null===l[s]?Yl(e,(e=>n(e,s+1))):Q([l[s],null],(l=>n(lt(e,l),s+1)));return n(e,0),t})(e,t),(e=>Yl(e,(e=>lt(r,e)[0](l,...null!=t?t:[],...n))))),e=>q(lt(r,e),(([,l,t])=>(ht(l,null!=t?t:[s],void 0,(l=>(Zl(l,e),Gl(l)?1:0))),nt(r,e),n(e),t))),e=>q(lt(r,e),(([e,,t=[],n,s])=>{const r=(...a)=>{var o,i;const u=M(a);u==M(t)?e(l,...a,...s(a)):O(t[u])?Q(null!=(i=null==(o=n[u])?void 0:o.call(n,...a))?i:[],(e=>r(...a,e))):r(...a,t[u])};r()}))]})(),Le=e=>{if(!Rt(e,((e,l)=>[u,d].includes(l))))return!1;const l=e[u];return!(!P(l)&&l!=o||(He(e[d])!=l&&se(e,d),0))},Me=(l,t)=>(!e||Ul(F,t)||bl(t))&&Rt(l,((e,l)=>je(t,l,e)),(()=>bl(t))),je=(e,l,t,n)=>Rt(n?t:Fe(t,e,l),((n,s)=>q(ze(e,l,s,n),(e=>(t[s]=e,!0)),(()=>!1))),(()=>bl(e,l))),ze=(l,t,n,s)=>e?q(lt(lt(F,l),n),(e=>He(s)!=e[u]?bl(l,t,n,s,e[d]):s),(()=>bl(l,t,n,s))):O(He(s))?bl(l,t,n,s):s,$e=(e,l)=>Rt(l?e:Je(e),((l,t)=>q(Ae(t,l),(l=>(e[t]=l,!0)),(()=>!1))),(()=>pl())),Ae=(e,t)=>l?q(lt(D,e),(l=>He(t)!=l[u]?pl(e,t,l[d]):t),(()=>pl(e,t))):O(He(t))?pl(e,t):t,Fe=(e,l,t)=>(q(lt(J,l),(([n,s])=>{Yl(n,((l,t)=>{ne(e,t)||(e[t]=l)})),Yl(s,(n=>{ne(e,n)||bl(l,t,n)}))})),e),Je=e=>(l&&(Yl(H,((l,t)=>{ne(e,t)||(e[t]=l)})),Yl(U,(l=>{ne(e,l)||pl(l)}))),e),De=e=>rt(F,e,((e,l,t)=>{const n=_l(),s=It();rt(st(F,l,_l),t,((e,l,t)=>{nt(e,l,t),q(t[d],(e=>nt(n,l,e)),(()=>yt(s,l)))})),nt(J,l,[n,s])}),((e,l)=>{nt(F,l),nt(J,l)})),We=e=>rt(D,e,((e,l,t)=>{nt(D,l,t),q(t[d],(e=>nt(H,l,e)),(()=>yt(U,l)))}),((e,l)=>{nt(D,l),nt(H,l),Zl(U,l)})),Ue=e=>ae(e)?ft():mt(e),Ge=e=>rt(Y,e,((e,l,t)=>Ke(l,t)),((e,l)=>sl(l))),Ke=(e,l)=>rt(st(Y,e,(()=>(il(e,1),nt(K,e,Ct()),nt(X,e,_l()),_l()))),l,((l,t,n)=>Xe(e,l,t,n)),((l,t)=>rl(e,l,t))),Xe=(e,l,t,n,s)=>rt(st(l,t,(()=>(ul(e,t,1),_l()))),n,((l,n,s)=>Ye(e,t,l,n,s)),((n,r)=>al(e,l,t,n,r,s))),Ye=(e,l,t,n,s)=>{Ul(t,n)||dl(e,l,n,1);const r=lt(t,n);s!==r&&(cl(e,l,n,r,s),nt(t,n,s))},Ze=(e,l,t,n,s)=>q(lt(l,t),(l=>Ye(e,t,l,n,s)),(()=>Xe(e,l,t,Fe({[n]:s},e,t)))),_e=e=>ae(e)?Nt():bt(e),el=e=>rt(Z,e,((e,l,t)=>ll(l,t)),((e,l)=>ol(l))),ll=(e,l)=>{Ul(Z,e)||hl(e,1);const t=lt(Z,e);l!==t&&(ml(e,t,l),nt(Z,e,l))},tl=(e,l)=>{const[t]=lt(K,e),n=t(l);return Ul(lt(Y,e),n)?tl(e,l):n},nl=e=>{var l;return null!=(l=lt(Y,e))?l:Ke(e,{})},sl=e=>Ke(e,{}),rl=(e,l,t)=>{const[,n]=lt(K,e);n(t),Xe(e,l,t,{},!0)},al=(e,l,t,n,s,r)=>{var a;const o=lt(null==(a=lt(J,e))?void 0:a[0],s);if(!O(o)&&!r)return Ye(e,t,n,s,o);const i=l=>{cl(e,t,l,lt(n,l)),dl(e,t,l,-1),nt(n,l)};O(o)?i(s):tt(n,i),Gl(n)&&(ul(e,t,-1),Gl(nt(l,t))&&(il(e,-1),nt(Y,e),nt(K,e),nt(X,e)))},ol=e=>{const l=lt(H,e);if(!O(l))return ll(e,l);ml(e,lt(Z,e)),hl(e,-1),nt(Z,e)},il=(e,l)=>Ot(h,e,l),ul=(e,l,t)=>Ot(st(V,e,_l),l,t)&&nt(S,e,st(S,e,(()=>0))+t),dl=(e,l,t,n)=>{var s;const r=lt(X,e),a=null!=(s=lt(r,t))?s:0;(0==a&&1==n||1==a&&-1==n)&&Ot(st(k,e,_l),t,n),nt(r,t,a!=-n?a+n:null),Ot(st(st(R,e,_l),l,_l),t,n)},cl=(e,l,t,n,s)=>st(st(st(E,e,_l),l,_l),t,(()=>[n,0]))[1]=s,hl=(e,l)=>Ot(j,e,l),ml=(e,l,t)=>st(z,e,(()=>[l,0]))[1]=t,bl=(e,l,t,n,s)=>(G(st(st(st($,e,_l),l,_l),t,(()=>[])),n),s),pl=(e,l,t)=>(G(st(A,e,(()=>[])),l),t),gl=(e,l,t)=>q(lt(lt(lt(E,e),l),t),(([e,l])=>[!0,e,l]),(()=>[!1,...Tt(El(e,l,t))])),vl=e=>q(lt(z,e),(([e,l])=>[!0,e,l]),(()=>[!1,...Tt(jl(e))])),fl=e=>Gl($)||Gl(we[e])?0:Yl(e?ct($):$,((l,t)=>Yl(l,((l,n)=>Yl(l,((l,s)=>Pe(we[e],[t,n,s],l))))))),Il=e=>Gl(A)||Gl(Ce[e])?0:Yl(e?ut(A):A,((l,t)=>Pe(Ce[e],[t],l))),yl=(e,l,t,n)=>{if(!Gl(e))return Pe(l,n,(()=>at(e))),tt(e,((e,l)=>Pe(t,[...null!=n?n:[],e],1==l))),1},wl=e=>{const l=zl();l!=r&&Pe(_[e],void 0,l);const t=Gl(pe[e]),n=Gl(fe[e])&&Gl(Ie[e])&&Gl(be[e])&&Gl(ge[e])&&Gl(ce[e])&&Gl(he[e])&&Gl(me[e])&&t&&Gl(te[e])&&Gl(ue[e]),s=Gl(ye[e])&&Gl(ve[e])&&Gl(de[e])&&Gl(le[e]);if(!n||!s){const l=e?[ut(h),dt(k),ut(S),dt(V),ct(R),ct(E)]:[h,k,S,V,R,E];if(!n){yl(l[0],te[e],ue[e]),Yl(l[1],((l,t)=>yl(l,ce[e],he[e],[t]))),Yl(l[2],((l,t)=>{0!=l&&Pe(me[e],[t],Ol(t))}));const n=It();Yl(l[3],((l,s)=>{yl(l,be[e],ge[e],[s])&&!t&&(Pe(pe[e],[s,null]),yt(n,s))})),t||Yl(l[5],((l,t)=>{if(!Ul(n,t)){const n=It();Yl(l,(e=>Yl(e,(([l,t],s)=>t!==l?yt(n,s):Zl(e,s))))),Yl(n,(l=>Pe(pe[e],[t,l])))}})),Yl(l[4],((l,t)=>Yl(l,((l,n)=>yl(l,fe[e],Ie[e],[t,n])))))}if(!s){let t;Yl(l[5],((l,n)=>{let s;Yl(l,((l,r)=>{let a;Yl(l,(([l,o],i)=>{o!==l&&(Pe(ye[e],[n,r,i],o,l,gl),t=s=a=1)})),a&&Pe(ve[e],[n,r],gl)})),s&&Pe(de[e],[n],gl)})),t&&Pe(le[e],void 0,gl)}}},Cl=e=>{const l=Dl();l!=a&&Pe(Te[e],void 0,l);const t=Gl(Se[e])&&Gl(xe[e]),n=Gl(Ve[e])&&Gl(ke[e]);if(!t||!n){const l=e?[ut(j),ut(z)]:[j,z];if(t||yl(l[0],Se[e],xe[e]),!n){let t;Yl(l[1],(([l,n],s)=>{n!==l&&(Pe(Ve[e],[s],n,l,vl),t=1)})),t&&Pe(ke[e],void 0,vl)}}},Tl=(e,...l)=>(Mt((()=>e(...W(l,x)))),$t),kl=()=>[at(E,((e,l)=>-1===lt(h,l)?null:at(e,((e,t)=>-1===lt(lt(V,l),t)?null:at(e,(([,e])=>null!=e?e:null),((e,l)=>Vt(l)))),ae)),ae),at(z,(([,e])=>null!=e?e:null),((e,l)=>Vt(l)))],Sl=()=>({cellsTouched:t,valuesTouched:n,changedCells:it(E,xt,Vt),invalidCells:it($),changedValues:at(z,xt,Vt),invalidValues:at(A),changedTableIds:at(h),changedRowIds:ot(V),changedCellIds:it(R),changedValueIds:at(j)}),xl=()=>it(Y),Vl=()=>et(Y),Rl=e=>et(lt(X,x(e))),Ol=e=>Hl(lt(Y,x(e))),ql=e=>et(lt(Y,x(e))),Pl=(e,l,t,n=0,s)=>{return W(L(B((r=lt(Y,x(e)),a=(e,t)=>[O(l)?t:lt(e,x(l)),t],W([...null!=(o=null==r?void 0:r.entries())?o:[]],(([e,l])=>a(l,e)))),(([e],[l])=>{return((null!=(n=e)?n:0)<(null!=(s=l)?s:0)?-1:1)*(t?-1:1);var n,s})),n,O(s)?s:n+s),(([,e])=>e));var r,a,o},Nl=(e,l)=>et(lt(lt(Y,x(e)),x(l))),El=(e,l,t)=>lt(lt(lt(Y,x(e)),x(l)),x(t)),Ll=()=>at(Z),Ml=()=>et(Z),jl=e=>lt(Z,x(e)),zl=()=>!Gl(Y),$l=e=>Ul(Y,x(e)),Al=(e,l)=>Ul(lt(X,x(e)),x(l)),Fl=(e,l)=>Ul(lt(Y,x(e)),x(l)),Jl=(e,l,t)=>Ul(lt(lt(Y,x(e)),x(l)),x(t)),Dl=()=>!Gl(Z),Kl=e=>Ul(Z,x(e)),mt=e=>Tl((()=>(e=>Rt(e,Me,bl))(e)?Ge(e):0)),bt=e=>Tl((()=>$e(e)?el(e):0)),pt=e=>{try{Ue(ie(e))}catch(e){}return $t},gt=l=>Tl((()=>{if((e=Rt(l,(e=>Rt(e,Le))))&&(De(l),!Gl(Y))){const e=xl();ft(),mt(e)}})),vt=e=>Tl((()=>{if(l=(e=>Rt(e,Le))(e)){const t=Ll();Lt(),Nt(),l=!0,We(e),bt(t)}})),ft=()=>Tl((()=>Ge({}))),wt=e=>Tl((e=>Ul(Y,e)?sl(e):0),e),Pt=(e,l)=>Tl(((e,l)=>q(lt(Y,e),(t=>Ul(t,l)?rl(e,t,l):0))),e,l),Nt=()=>Tl((()=>el({}))),Et=()=>Tl((()=>{De({}),e=!1})),Lt=()=>Tl((()=>{We({}),l=!1})),Mt=(e,l)=>{if(-1!=i){jt();const t=e();return zt(l),t}},jt=()=>(-1!=i&&i++,1==i&&Pe(Re,void 0,kl,Sl),$t),zt=e=>(i>0&&(i--,0==i&&(t=!Gl(E),n=!Gl(z),i=1,fl(1),t&&wl(1),Il(1),n&&Cl(1),(null==e?void 0:e(kl,Sl))&&(Yl(E,((e,l)=>Yl(e,((e,t)=>Yl(e,(([e],n)=>Be($t,l,t,n,e))))))),Yl(z,(([e],l)=>Qe($t,l,e))),t=n=!1),Pe(Oe[0],void 0,kl,Sl),i=-1,fl(0),t&&wl(0),Il(0),n&&Cl(0),Pe(Oe[1],void 0,kl,Sl),i=0,t=n=!1,r=zl(),a=Dl(),Q([h,k,S,V,R,E,$,j,z,A],Xl))),$t),$t={getContent:()=>[xl(),Ll()],getTables:xl,getTableIds:Vl,getTable:e=>ot(lt(Y,x(e))),getTableCellIds:Rl,getRowCount:Ol,getRowIds:ql,getSortedRowIds:Pl,getRow:(e,l)=>at(lt(lt(Y,x(e)),x(l))),getCellIds:Nl,getCell:El,getValues:Ll,getValueIds:Ml,getValue:jl,hasTables:zl,hasTable:$l,hasTableCell:Al,hasRow:Fl,hasCell:Jl,hasValues:Dl,hasValue:Kl,getTablesJson:()=>oe(Y),getValuesJson:()=>oe(Z),getJson:()=>oe([Y,Z]),getTablesSchemaJson:()=>oe(F),getValuesSchemaJson:()=>oe(D),getSchemaJson:()=>oe([F,D]),hasTablesSchema:()=>e,hasValuesSchema:()=>l,setContent:([e,l])=>Tl((()=>{(ae(e)?ft:mt)(e),(ae(l)?Nt:bt)(l)})),setTables:mt,setTable:(e,l)=>Tl((e=>Me(l,e)?Ke(e,l):0),e),setRow:(e,l,t)=>Tl(((e,l)=>je(e,l,t)?Xe(e,nl(e),l,t):0),e,l),addRow:(e,l,t=!0)=>Mt((()=>{let n;return je(e,n,l)&&(e=x(e),Xe(e,nl(e),n=tl(e,t?1:0),l)),n})),setPartialRow:(e,l,t)=>Tl(((e,l)=>{if(je(e,l,t,1)){const n=nl(e);re(t,((t,s)=>Ze(e,n,l,s,t)))}}),e,l),setCell:(e,l,t,n)=>Tl(((e,l,t)=>q(ze(e,l,t,N(n)?n(El(e,l,t)):n),(n=>Ze(e,nl(e),l,t,n)))),e,l,t),setValues:bt,setPartialValues:e=>Tl((()=>$e(e,1)?re(e,((e,l)=>ll(l,e))):0)),setValue:(e,l)=>Tl((e=>q(Ae(e,N(l)?l(jl(e)):l),(l=>ll(e,l)))),e),setTransactionChanges:e=>Tl((()=>{re(e[0],((e,l)=>O(e)?wt(l):re(e,((e,t)=>O(e)?Pt(l,t):re(e,((e,n)=>Be($t,l,t,n,e))))))),re(e[1],((e,l)=>Qe($t,l,e)))})),setTablesJson:pt,setValuesJson:e=>{try{_e(ie(e))}catch(e){}return $t},setJson:e=>Tl((()=>{try{const[l,t]=ie(e);Ue(l),_e(t)}catch(l){pt(e)}})),setTablesSchema:gt,setValuesSchema:vt,setSchema:(e,l)=>Tl((()=>{gt(e),vt(l)})),delTables:ft,delTable:wt,delRow:Pt,delCell:(e,l,t,n)=>Tl(((e,l,t)=>q(lt(Y,e),(s=>q(lt(s,l),(r=>Ul(r,t)?al(e,s,l,r,t,n):0))))),e,l,t),delValues:Nt,delValue:e=>Tl((e=>Ul(Z,e)?ol(e):0),e),delTablesSchema:Et,delValuesSchema:Lt,delSchema:()=>Tl((()=>{Et(),Lt()})),transaction:Mt,startTransaction:jt,finishTransaction:zt,forEachTable:e=>Yl(Y,((l,t)=>e(t,(e=>Yl(l,((l,t)=>e(t,(e=>tt(l,e))))))))),forEachTableCell:(e,l)=>tt(lt(X,x(e)),l),forEachRow:(e,l)=>Yl(lt(Y,x(e)),((e,t)=>l(t,(l=>tt(e,l))))),forEachCell:(e,l,t)=>tt(lt(lt(Y,x(e)),x(l)),t),forEachValue:e=>tt(Z,e),addSortedRowIdsListener:(e,l,t,n,s,r,a)=>{let o=Pl(e,l,t,n,s);return qe((()=>{const a=Pl(e,l,t,n,s);var i,u,d;u=o,M(i=a)===M(u)&&(d=(e,l)=>u[l]===e,i.every(d))||(o=a,r($t,e,l,t,n,s,o))}),pe[a?1:0],[e,l],[Vl])},addStartTransactionListener:e=>qe(e,Re),addWillFinishTransactionListener:e=>qe(e,Oe[0]),addDidFinishTransactionListener:e=>qe(e,Oe[1]),callListener:e=>(Ee(e),$t),delListener:e=>(Ne(e),$t),getListenerStats:()=>({hasTables:kt(_),tables:kt(le),tableIds:kt(te),hasTable:kt(ue),table:kt(de),tableCellIds:kt(ce),hasTableCell:kt(he,Ql),rowCount:kt(me),rowIds:kt(be),sortedRowIds:kt(pe),hasRow:kt(ge,Ql),row:kt(ve,Ql),cellIds:kt(fe,Ql),hasCell:kt(Ie,Wl),cell:kt(ye,Wl),invalidCell:kt(we,Wl),hasValues:kt(Te),values:kt(ke),valueIds:kt(Se),hasValue:kt(xe),value:kt(Ve),invalidValue:kt(Ce),transaction:Bl(Re)+kt(Oe)}),createStore:qt,addListener:qe,callListeners:Pe};return re({[c+b]:[0,_,[],()=>[zl()]],[b]:[0,le],[p]:[0,te],[c+m]:[1,ue,[Vl],e=>[$l(...e)]],[m]:[1,de,[Vl]],[m+y]:[1,ce,[Vl]],[c+m+I]:[2,he,[Vl,Rl],e=>[Al(...e)]],[v]:[1,me,[Vl]],[f]:[1,be,[Vl]],[c+g]:[2,ge,[Vl,ql],e=>[Fl(...e)]],[g]:[2,ve,[Vl,ql]],[y]:[2,fe,[Vl,ql]],[c+I]:[3,Ie,[Vl,ql,Nl],e=>[Jl(...e)]],[I]:[3,ye,[Vl,ql,Nl],e=>Tt(El(...e))],InvalidCell:[3,we],[c+C]:[0,Te,[],()=>[Dl()]],[C]:[0,ke],[T]:[0,Se],[c+w]:[1,xe,[Ml],e=>[Kl(...e)]],[w]:[1,Ve,[Ml],e=>Tt(jl(e[0]))],InvalidValue:[1,Ce]},(([e,l,t,n],s)=>{$t["add"+s+"Listener"]=(...s)=>qe(s[e],l[s[e+1]?1:0],e>0?L(s,0,e):void 0,t,n)})),ee($t)},Pt=({position:e="right",open:l=!1})=>{const n=t.useCreateStore(qt),s=ce.indexOf(e);return t.useCreatePersister(n,(e=>((e,l,t,n)=>((e,l,t,n,s,r,[a,o]=[],i=[])=>{let u,d,c,h=0,m=0,b=0,p=0;st(bt,i,(()=>0)),st(pt,i,(()=>[]));const g=e=>mt(void 0,null,(function*(){return 2!=h&&(h=1,m++,yield v.schedule((()=>mt(void 0,null,(function*(){yield e(),h=0}))))),v})),v={load:(t,n)=>mt(void 0,null,(function*(){return yield g((()=>mt(void 0,null,(function*(){try{e.setContent(yield l())}catch(l){e.setContent([t,n])}}))))})),startAutoLoad:(...t)=>mt(void 0,[...t],(function*(t={},s={}){return v.stopAutoLoad(),yield v.load(t,s),p=1,c=n(((t,n)=>mt(void 0,null,(function*(){if(n){const l=n();yield g((()=>mt(void 0,null,(function*(){return e.setTransactionChanges(l)}))))}else yield g((()=>mt(void 0,null,(function*(){var n;try{e.setContent(null!=(n=null==t?void 0:t())?n:yield l())}catch(e){}}))))})))),v})),stopAutoLoad:()=>(p&&(s(c),c=void 0,p=0),v),save:l=>mt(void 0,null,(function*(){return 1!=h&&(h=2,b++,yield v.schedule((()=>mt(void 0,null,(function*(){try{yield t(e.getContent,l)}catch(e){}h=0}))))),v})),startAutoSave:()=>mt(void 0,null,(function*(){return yield v.stopAutoSave().save(),u=e.addDidFinishTransactionListener(((e,l)=>{const[t,n]=l();ae(t)&&ae(n)||v.save((()=>[t,n]))})),v})),stopAutoSave:()=>(q(u,e.delListener),u=void 0,v),schedule:(...e)=>mt(void 0,null,(function*(){return G(lt(pt,i),...e),yield mt(void 0,null,(function*(){if(!lt(bt,i)){for(nt(bt,i,1);!O(d=K(lt(pt,i)));)try{yield d()}catch(e){}nt(bt,i,0)}})),v})),getStore:()=>e,destroy:()=>v.stopAutoLoad().stopAutoSave(),getStats:()=>({loads:m,saves:b})};return a&&(v[a]=()=>o),ee(v)})(e,(()=>gt(void 0,null,(function*(){return ie(t.getItem(l))}))),(e=>gt(void 0,null,(function*(){return t.setItem(l,oe(e()))}))),(e=>{const n=n=>{n.storageArea===t&&n.key===l&&e((()=>ie(n.newValue)))};return ft.addEventListener(vt,n),n}),(e=>ft.removeEventListener(vt,e)),0,["getStorageName",l]))(e,ue,sessionStorage)),void 0,(e=>{return t=function*(){yield e.load(void 0,{position:-1==s?1:s,open:!!l}),yield e.startAutoSave()},new Promise(((e,l)=>{var n=e=>{try{r(t.next(e))}catch(e){l(e)}},s=e=>{try{r(t.throw(e))}catch(e){l(e)}},r=l=>l.done?e(l.value):Promise.resolve(l.value).then(n,s);r((t=t.apply(void 0,null)).next())}));var t})),$(z,null,$("aside",{id:ue},$(Je,{s:n}),$(Jl,{s:n})),$("style",null,Fe))};var Nt=Object.defineProperty,Et=Object.getOwnPropertySymbols,Lt=Object.prototype.hasOwnProperty,Mt=Object.prototype.propertyIsEnumerable,jt=(e,l,t)=>l in e?Nt(e,l,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[l]=t;e.EditableCellView=Tl,e.EditableValueView=kl,e.RelationshipInHtmlTable=wl,e.ResultSortedTableInHtmlTable=Cl,e.ResultTableInHtmlTable=e=>{var l=e,{queryId:n,queries:s,customCells:r}=l,a=tl(l,["queryId","queries","customCells"]);return $(bl,ll(el({},a),{params:ul(ml(t.useResultTableCellIds(n,s),r,t.ResultCellView),cl(s,n),t.useResultRowIds(n,s))}))},e.SliceInHtmlTable=yl,e.SortedTableInHtmlTable=fl,e.SortedTablePaginator=Sl,e.StoreInspector=e=>$(Pt,((e,l)=>{for(var t in l||(l={}))Lt.call(l,t)&&jt(e,t,l[t]);if(Et)for(var t of Et(l))Mt.call(l,t)&&jt(e,t,l[t]);return e})({},e)),e.TableInHtmlTable=e=>{var l=e,{tableId:n,store:s,editable:r,customCells:a}=l,o=tl(l,["tableId","store","editable","customCells"]);return $(bl,ll(el({},o),{params:ul(ml(t.useTableCellIds(n,s),a,r?Tl:t.CellView),dl(s,n),t.useRowIds(n,s))}))},e.ValuesInHtmlTable=Il},"object"==typeof exports&&"undefined"!=typeof module?l(exports,require("react"),require("./ui-react")):"function"==typeof define&&define.amd?define(["exports","react","./ui-react"],l):l((e="undefined"!=typeof globalThis?globalThis:e||self).TinyBaseUiReactDomDebug={},e.React,e.TinyBaseUiReact);
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tinybase",
|
|
3
|
-
"version": "4.8.
|
|
3
|
+
"version": "4.8.5",
|
|
4
4
|
"author": "jamesgpearce",
|
|
5
5
|
"repository": "github:tinyplex/tinybase",
|
|
6
6
|
"license": "MIT",
|
|
@@ -236,9 +236,9 @@
|
|
|
236
236
|
"@types/less": "^3.0.6",
|
|
237
237
|
"@types/node": "^20.12.7",
|
|
238
238
|
"@types/puppeteer": "^5.4.7",
|
|
239
|
-
"@types/react": "^18.
|
|
240
|
-
"@types/react-dom": "^18.
|
|
241
|
-
"@types/react-test-renderer": "^18.0
|
|
239
|
+
"@types/react": "^18.3.1",
|
|
240
|
+
"@types/react-dom": "^18.3.0",
|
|
241
|
+
"@types/react-test-renderer": "^18.3.0",
|
|
242
242
|
"@types/tmp": "^0.2.6",
|
|
243
243
|
"@typescript-eslint/eslint-plugin": "^7.7.1",
|
|
244
244
|
"@typescript-eslint/parser": "^7.7.1",
|
|
@@ -256,10 +256,10 @@
|
|
|
256
256
|
"esbuild": "^0.20.2",
|
|
257
257
|
"eslint": "^8.57.0",
|
|
258
258
|
"eslint-config-prettier": "^9.1.0",
|
|
259
|
-
"eslint-plugin-jest": "^28.
|
|
259
|
+
"eslint-plugin-jest": "^28.3.0",
|
|
260
260
|
"eslint-plugin-jsdoc": "^48.2.3",
|
|
261
261
|
"eslint-plugin-react": "7.34.1",
|
|
262
|
-
"eslint-plugin-react-hooks": "^4.6.
|
|
262
|
+
"eslint-plugin-react-hooks": "^4.6.2",
|
|
263
263
|
"expo-sqlite": "^13.2.1",
|
|
264
264
|
"fake-indexeddb": "^5.0.2",
|
|
265
265
|
"gulp": "^5.0.0",
|
|
@@ -274,11 +274,11 @@
|
|
|
274
274
|
"partykit": "^0.0.104",
|
|
275
275
|
"partysocket": "^1.0.1",
|
|
276
276
|
"prettier": "^3.2.5",
|
|
277
|
-
"puppeteer": "22.7.
|
|
278
|
-
"react": "^18.
|
|
279
|
-
"react-dom": "^18.
|
|
280
|
-
"react-test-renderer": "^18.
|
|
281
|
-
"rollup": "^4.
|
|
277
|
+
"puppeteer": "22.7.1",
|
|
278
|
+
"react": "^18.3.1",
|
|
279
|
+
"react-dom": "^18.3.1",
|
|
280
|
+
"react-test-renderer": "^18.3.1",
|
|
281
|
+
"rollup": "^4.17.0",
|
|
282
282
|
"rollup-plugin-esbuild": "^6.1.1",
|
|
283
283
|
"rollup-plugin-gzip": "^3.1.2",
|
|
284
284
|
"rollup-plugin-preserve-shebang": "^1.0.1",
|
|
@@ -290,7 +290,7 @@
|
|
|
290
290
|
"ts-unused-exports": "^10.0.1",
|
|
291
291
|
"typescript": "5.4.5",
|
|
292
292
|
"wa-sqlite": "github:rhashimoto/wa-sqlite",
|
|
293
|
-
"yjs": "^13.6.
|
|
293
|
+
"yjs": "^13.6.15"
|
|
294
294
|
},
|
|
295
295
|
"peerDependencies": {
|
|
296
296
|
"@automerge/automerge-repo": "^1.1.9",
|
|
@@ -303,10 +303,10 @@
|
|
|
303
303
|
"partykit": "^0.0.104",
|
|
304
304
|
"partysocket": "^1.0.1",
|
|
305
305
|
"prettier": "^3.2.5",
|
|
306
|
-
"react": "^18.
|
|
307
|
-
"react-dom": "^18.
|
|
306
|
+
"react": "^18.3.1",
|
|
307
|
+
"react-dom": "^18.3.1",
|
|
308
308
|
"sqlite3": "^5.1.7",
|
|
309
|
-
"yjs": "^13.6.
|
|
309
|
+
"yjs": "^13.6.15"
|
|
310
310
|
},
|
|
311
311
|
"peerDependenciesMeta": {
|
|
312
312
|
"@automerge/automerge-repo": {
|
package/readme.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
<section id="hero"><h2 id="the-reactive-data-store-for-local-first-apps">The <em>reactive</em> data store for <span>local-first apps</span>.</h2><p id="copy">Build blisteringly fast web apps that work both online and offline. Manage your state locally, synchronize it to the cloud when you need to, or even make it collaborative. But, most importantly... have fun building stuff again!</p></section><p><a href="https://tinybase.org/guides/releases/#v4-8"><em>NEW!</em> v4.8 release</a> <span id="one-with">"The One With PowerSync"</span></p><p><a class="start" href="https://tinybase.org/guides/the-basics/getting-started/">Get started</a></p><p><a href="https://tinybase.org/demos/">Try the demos</a></p><p><a href="https://tinybase.org/api/store/interfaces/store/store/">Read the docs</a></p><hr><ul><li>Manage <a href="#start-with-a-simple-key-value-store">key-value data</a>, <a href="#level-up-to-use-tabular-data">tabular data</a> - or both - with optional <a href="#apply-schemas-to-tables-values">schematization</a> to model your app's data structures.</li><li><a href="#register-granular-listeners">Flexibly reactive</a> to reconciled updates, so you only spend rendering cycles on things that change.</li><li><a href="#build-complex-queries-with-tinyql">Powerful query engine</a> to select, join, filter, group, sort and paginate data - reactively - and without SQL.</li><li>Built-in <a href="#create-indexes-for-fast-lookups">indexing</a>, <a href="#define-metrics-and-aggregations">metric aggregation</a>, <a href="#model-table-relationships">tabular relationships</a> - and even an <a href="#set-checkpoints-for-an-undo-stack">undo stack</a> for your app state.</li><li>Create <a href="#type-definitions-orm-like-apis">type definitions & ORM-like APIs</a>, from schema or inference. <a href="#an-inspector-for-your-data">Inspect your data</a> (<em>new!</em>) directly in the browser.</li><li>Easily <a href="#persist-to-storage-sqlite-crdts">sync your data</a> to browser <a href="https://tinybase.org/api/persister-browser">storage</a>, <a href="https://tinybase.org/api/persister-indexed-db/">IndexedDB</a>, <a href="https://tinybase.org/guides/schemas-and-persistence/database-persistence/">SQLite</a>, <a href="https://tinybase.org/guides/schemas-and-persistence/synchronizing-data/">CRDTs</a>; and (<em>new!</em>) <a href="https://tinybase.org/api/persister-partykit-client/">PartyKit</a> and <a href="https://electric-sql.com/">ElectricSQL</a>.</li><li>Optional <a href="#call-hooks-to-bind-to-data">bindings to React</a> and (<em>new!</em>) <a href="#pre-built-reactive-components">pre-built components</a> that let you easily build fully reactive user interfaces.</li><li>Tiny by name, tiny by nature: <a href="#did-we-say-tiny">5.0kB - 9.4kB</a>, no dependencies. <a href="#well-tested-and-documented">100% tested</a>, <a href="https://tinybase.org/guides/the-basics/getting-started/">fully documented</a>, and of course, <a href="https://github.com/tinyplex/tinybase">open source</a>!</li></ul><hr><section id="friends"><h2 id="tinybase-works-great-on-its-own-but-also-plays-well-with-friends">TinyBase works great on its own, but also plays well with friends!</h2><div><a href="https://tinybase.org/guides/building-uis/getting-started-with-ui-react"><img width="48" src="https://tinybase.org/react.svg"> React</a></div><div><a href="https://tinybase.org/api/persister-partykit-client"><img width="48" src="https://tinybase.org/partykit.svg"> PartyKit</a></div><div><a href="https://tinybase.org/guides/schemas-and-persistence/database-persistence"><img width="48" src="https://tinybase.org/expo.svg">Expo SQLite</a></div><div><a href="https://tinybase.org/guides/schemas-and-persistence/database-persistence"><img width="48" src="https://tinybase.org/electric.svg">ElectricSQL</a></div><div><a href="https://tinybase.org/guides/schemas-and-persistence/database-persistence"><img width="48" src="https://tinybase.org/sqlite.svg"> SQLite</a></div><div><a href="https://tinybase.org/guides/schemas-and-persistence/database-persistence"><img width="48" src="https://tinybase.org/turso.svg">Turso</a></div><div><a href="https://tinybase.org/guides/schemas-and-persistence/database-persistence"><img width="48" src="https://tinybase.org/powersync.svg">PowerSync</a></div><div><a href="https://tinybase.org/api/persister-indexed-db/functions/creation/createindexeddbpersister"><img width="48" src="https://tinybase.org/indexeddb.svg"> IndexedDB</a></div><div><a href="https://tinybase.org/api/persister-yjs/functions/creation/createyjspersister"><img width="48" src="https://tinybase.org/yjs.svg"> YJS</a></div><div><a href="https://tinybase.org/api/persister-cr-sqlite-wasm"><img width="48" src="https://tinybase.org/crsqlite.png"> CR-SQLite</a></div><div><a href="https://tinybase.org/api/persister-automerge"><img width="48" src="https://tinybase.org/automerge.svg"> Automerge</a></div></section><hr><section id="follow"><a href="https://github.com/tinyplex/tinybase" target="_blank"><img src="https://img.shields.io/github/stars/tinyplex/tinybase?style=for-the-badge&logo=GitHub&logoColor=%23fff&label=GitHub&labelColor=%23d81b60&color=%23333"> </a><a href="https://discord.com/invite/mGz3mevwP8" target="_blank"><img src="https://img.shields.io/discord/1027918215323590676?style=for-the-badge&logo=discord&logoColor=%23fff&label=Discord&labelColor=%233131e8&color=%23333"> </a><a href="https://twitter.com/tinybasejs" target="_blank"><img src="https://img.shields.io/twitter/follow/tinybasejs?style=for-the-badge&logo=x&logoColor=%23fff&label=Twitter&labelColor=%23333&color=%23333"></a><br><a href="https://github.com/tinyplex/tinybase/discussions" target="_blank"><img src="https://img.shields.io/github/discussions/tinyplex/tinybase?style=for-the-badge&logo=GitHub&logoColor=%23fff&label=Ideas&labelColor=%23d81b60&color=%23333"> </a><a href="https://github.com/tinyplex/tinybase/issues" target="_blank"><img src="https://img.shields.io/github/issues/tinyplex/tinybase?style=for-the-badge&logo=GitHub&logoColor=%23fff&label=Issues&labelColor=%23d81b60&color=%23333"> </a><a href="#well-tested-and-documented"><img src="https://img.shields.io/badge/Tests-100%25-green?style=for-the-badge&logo=jest&logoColor=%23fff&color=%23333&labelColor=%2387c305"> </a><a href="https://www.npmjs.com/package/tinybase/v/4.8.
|
|
1
|
+
<section id="hero"><h2 id="the-reactive-data-store-for-local-first-apps">The <em>reactive</em> data store for <span>local-first apps</span>.</h2><p id="copy">Build blisteringly fast web apps that work both online and offline. Manage your state locally, synchronize it to the cloud when you need to, or even make it collaborative. But, most importantly... have fun building stuff again!</p></section><p><a href="https://tinybase.org/guides/releases/#v4-8"><em>NEW!</em> v4.8 release</a> <span id="one-with">"The One With PowerSync"</span></p><p><a class="start" href="https://tinybase.org/guides/the-basics/getting-started/">Get started</a></p><p><a href="https://tinybase.org/demos/">Try the demos</a></p><p><a href="https://tinybase.org/api/store/interfaces/store/store/">Read the docs</a></p><hr><ul><li>Manage <a href="#start-with-a-simple-key-value-store">key-value data</a>, <a href="#level-up-to-use-tabular-data">tabular data</a> - or both - with optional <a href="#apply-schemas-to-tables-values">schematization</a> to model your app's data structures.</li><li><a href="#register-granular-listeners">Flexibly reactive</a> to reconciled updates, so you only spend rendering cycles on things that change.</li><li><a href="#build-complex-queries-with-tinyql">Powerful query engine</a> to select, join, filter, group, sort and paginate data - reactively - and without SQL.</li><li>Built-in <a href="#create-indexes-for-fast-lookups">indexing</a>, <a href="#define-metrics-and-aggregations">metric aggregation</a>, <a href="#model-table-relationships">tabular relationships</a> - and even an <a href="#set-checkpoints-for-an-undo-stack">undo stack</a> for your app state.</li><li>Create <a href="#type-definitions-orm-like-apis">type definitions & ORM-like APIs</a>, from schema or inference. <a href="#an-inspector-for-your-data">Inspect your data</a> (<em>new!</em>) directly in the browser.</li><li>Easily <a href="#persist-to-storage-sqlite-crdts">sync your data</a> to browser <a href="https://tinybase.org/api/persister-browser">storage</a>, <a href="https://tinybase.org/api/persister-indexed-db/">IndexedDB</a>, <a href="https://tinybase.org/guides/schemas-and-persistence/database-persistence/">SQLite</a>, <a href="https://tinybase.org/guides/schemas-and-persistence/synchronizing-data/">CRDTs</a>; and (<em>new!</em>) <a href="https://tinybase.org/api/persister-partykit-client/">PartyKit</a> and <a href="https://electric-sql.com/">ElectricSQL</a>.</li><li>Optional <a href="#call-hooks-to-bind-to-data">bindings to React</a> and (<em>new!</em>) <a href="#pre-built-reactive-components">pre-built components</a> that let you easily build fully reactive user interfaces.</li><li>Tiny by name, tiny by nature: <a href="#did-we-say-tiny">5.0kB - 9.4kB</a>, no dependencies. <a href="#well-tested-and-documented">100% tested</a>, <a href="https://tinybase.org/guides/the-basics/getting-started/">fully documented</a>, and of course, <a href="https://github.com/tinyplex/tinybase">open source</a>!</li></ul><hr><section id="friends"><h2 id="tinybase-works-great-on-its-own-but-also-plays-well-with-friends">TinyBase works great on its own, but also plays well with friends!</h2><div><a href="https://tinybase.org/guides/building-uis/getting-started-with-ui-react"><img width="48" src="https://tinybase.org/react.svg"> React</a></div><div><a href="https://tinybase.org/api/persister-partykit-client"><img width="48" src="https://tinybase.org/partykit.svg"> PartyKit</a></div><div><a href="https://tinybase.org/guides/schemas-and-persistence/database-persistence"><img width="48" src="https://tinybase.org/expo.svg">Expo SQLite</a></div><div><a href="https://tinybase.org/guides/schemas-and-persistence/database-persistence"><img width="48" src="https://tinybase.org/electric.svg">ElectricSQL</a></div><div><a href="https://tinybase.org/guides/schemas-and-persistence/database-persistence"><img width="48" src="https://tinybase.org/sqlite.svg"> SQLite</a></div><div><a href="https://tinybase.org/guides/schemas-and-persistence/database-persistence"><img width="48" src="https://tinybase.org/turso.svg">Turso</a></div><div><a href="https://tinybase.org/guides/schemas-and-persistence/database-persistence"><img width="48" src="https://tinybase.org/powersync.svg">PowerSync</a></div><div><a href="https://tinybase.org/api/persister-indexed-db/functions/creation/createindexeddbpersister"><img width="48" src="https://tinybase.org/indexeddb.svg"> IndexedDB</a></div><div><a href="https://tinybase.org/api/persister-yjs/functions/creation/createyjspersister"><img width="48" src="https://tinybase.org/yjs.svg"> YJS</a></div><div><a href="https://tinybase.org/api/persister-cr-sqlite-wasm"><img width="48" src="https://tinybase.org/crsqlite.png"> CR-SQLite</a></div><div><a href="https://tinybase.org/api/persister-automerge"><img width="48" src="https://tinybase.org/automerge.svg"> Automerge</a></div></section><hr><section id="follow"><a href="https://github.com/tinyplex/tinybase" target="_blank"><img src="https://img.shields.io/github/stars/tinyplex/tinybase?style=for-the-badge&logo=GitHub&logoColor=%23fff&label=GitHub&labelColor=%23d81b60&color=%23333"> </a><a href="https://discord.com/invite/mGz3mevwP8" target="_blank"><img src="https://img.shields.io/discord/1027918215323590676?style=for-the-badge&logo=discord&logoColor=%23fff&label=Discord&labelColor=%233131e8&color=%23333"> </a><a href="https://twitter.com/tinybasejs" target="_blank"><img src="https://img.shields.io/twitter/follow/tinybasejs?style=for-the-badge&logo=x&logoColor=%23fff&label=Twitter&labelColor=%23333&color=%23333"></a><br><a href="https://github.com/tinyplex/tinybase/discussions" target="_blank"><img src="https://img.shields.io/github/discussions/tinyplex/tinybase?style=for-the-badge&logo=GitHub&logoColor=%23fff&label=Ideas&labelColor=%23d81b60&color=%23333"> </a><a href="https://github.com/tinyplex/tinybase/issues" target="_blank"><img src="https://img.shields.io/github/issues/tinyplex/tinybase?style=for-the-badge&logo=GitHub&logoColor=%23fff&label=Issues&labelColor=%23d81b60&color=%23333"> </a><a href="#well-tested-and-documented"><img src="https://img.shields.io/badge/Tests-100%25-green?style=for-the-badge&logo=jest&logoColor=%23fff&color=%23333&labelColor=%2387c305"> </a><a href="https://www.npmjs.com/package/tinybase/v/4.8.5" target="_blank"><img src="https://img.shields.io/npm/v/tinybase?style=for-the-badge&logo=npm&logoColor=%23fff&labelColor=%23bd0005&color=%23333"></a></section><hr><section><h2 id="start-with-a-simple-key-value-store">Start with a simple key-value store.</h2><p>Creating a <a href="https://tinybase.org/api/store/interfaces/store/store/"><code>Store</code></a> requires just a simple call to the <a href="https://tinybase.org/api/store/functions/creation/createstore/"><code>createStore</code></a> function. Once you have one, you can easily set <a href="https://tinybase.org/api/store/type-aliases/store/values/"><code>Values</code></a> in it by unique <a href="https://tinybase.org/api/common/type-aliases/identity/id/"><code>Id</code></a>. And of course you can easily get them back out again.</p><p>Read more about using keyed value data in <a href="https://tinybase.org/guides/the-basics/">The Basics</a> guide.</p></section>
|
|
2
2
|
|
|
3
3
|
```js
|
|
4
4
|
const store = createStore()
|