tinybase 5.4.0-beta.3 → 5.4.0-beta.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/@types/mergeable-store/index.d.cts +5 -4
- package/@types/mergeable-store/index.d.ts +5 -4
- package/@types/mergeable-store/with-schemas/index.d.cts +5 -4
- package/@types/mergeable-store/with-schemas/index.d.ts +5 -4
- package/@types/persisters/index.d.cts +1 -0
- package/@types/persisters/index.d.ts +1 -0
- package/@types/persisters/persister-durable-object-storage/index.d.cts +25 -17
- package/@types/persisters/persister-durable-object-storage/index.d.ts +25 -17
- package/@types/persisters/persister-durable-object-storage/with-schemas/index.d.cts +26 -18
- package/@types/persisters/persister-durable-object-storage/with-schemas/index.d.ts +26 -18
- package/@types/persisters/persister-partykit-server/index.d.cts +12 -0
- package/@types/persisters/persister-partykit-server/index.d.ts +12 -0
- package/@types/persisters/persister-partykit-server/with-schemas/index.d.cts +15 -0
- package/@types/persisters/persister-partykit-server/with-schemas/index.d.ts +15 -0
- package/@types/persisters/with-schemas/index.d.cts +1 -0
- package/@types/persisters/with-schemas/index.d.ts +1 -0
- package/@types/store/index.d.cts +10 -8
- package/@types/store/index.d.ts +10 -8
- package/@types/store/with-schemas/index.d.cts +10 -8
- package/@types/store/with-schemas/index.d.ts +10 -8
- package/@types/synchronizers/synchronizer-ws-server-durable-object/index.d.cts +206 -28
- package/@types/synchronizers/synchronizer-ws-server-durable-object/index.d.ts +206 -28
- package/@types/synchronizers/synchronizer-ws-server-durable-object/with-schemas/index.d.cts +219 -28
- package/@types/synchronizers/synchronizer-ws-server-durable-object/with-schemas/index.d.ts +219 -28
- package/cjs/es6/index.cjs +0 -1
- package/cjs/es6/indexes/index.cjs +1 -1
- package/cjs/es6/indexes/with-schemas/index.cjs +1 -1
- package/cjs/es6/metrics/index.cjs +1 -1
- package/cjs/es6/metrics/with-schemas/index.cjs +1 -1
- package/cjs/es6/min/index.cjs +1 -1
- package/cjs/es6/min/index.cjs.gz +0 -0
- package/cjs/es6/min/indexes/index.cjs +1 -1
- package/cjs/es6/min/indexes/index.cjs.gz +0 -0
- package/cjs/es6/min/indexes/with-schemas/index.cjs +1 -1
- package/cjs/es6/min/indexes/with-schemas/index.cjs.gz +0 -0
- package/cjs/es6/min/metrics/index.cjs +1 -1
- package/cjs/es6/min/metrics/index.cjs.gz +0 -0
- package/cjs/es6/min/metrics/with-schemas/index.cjs +1 -1
- package/cjs/es6/min/metrics/with-schemas/index.cjs.gz +0 -0
- package/cjs/es6/min/persisters/persister-durable-object-storage/index.cjs +1 -1
- package/cjs/es6/min/persisters/persister-durable-object-storage/index.cjs.gz +0 -0
- package/cjs/es6/min/persisters/persister-durable-object-storage/with-schemas/index.cjs +1 -1
- package/cjs/es6/min/persisters/persister-durable-object-storage/with-schemas/index.cjs.gz +0 -0
- package/cjs/es6/min/queries/index.cjs +1 -1
- package/cjs/es6/min/queries/index.cjs.gz +0 -0
- package/cjs/es6/min/queries/with-schemas/index.cjs +1 -1
- package/cjs/es6/min/queries/with-schemas/index.cjs.gz +0 -0
- package/cjs/es6/min/relationships/index.cjs +1 -1
- package/cjs/es6/min/relationships/index.cjs.gz +0 -0
- package/cjs/es6/min/relationships/with-schemas/index.cjs +1 -1
- package/cjs/es6/min/relationships/with-schemas/index.cjs.gz +0 -0
- package/cjs/es6/min/synchronizers/synchronizer-ws-server-durable-object/index.cjs +1 -1
- package/cjs/es6/min/synchronizers/synchronizer-ws-server-durable-object/index.cjs.gz +0 -0
- package/cjs/es6/min/synchronizers/synchronizer-ws-server-durable-object/with-schemas/index.cjs +1 -1
- package/cjs/es6/min/synchronizers/synchronizer-ws-server-durable-object/with-schemas/index.cjs.gz +0 -0
- package/cjs/es6/min/with-schemas/index.cjs +1 -1
- package/cjs/es6/min/with-schemas/index.cjs.gz +0 -0
- package/cjs/es6/persisters/persister-durable-object-storage/index.cjs +1 -1
- package/cjs/es6/persisters/persister-durable-object-storage/with-schemas/index.cjs +1 -1
- package/cjs/es6/persisters/persister-partykit-client/index.cjs +2 -5
- package/cjs/es6/persisters/persister-partykit-client/with-schemas/index.cjs +2 -5
- package/cjs/es6/queries/index.cjs +0 -1
- package/cjs/es6/queries/with-schemas/index.cjs +0 -1
- package/cjs/es6/relationships/index.cjs +1 -1
- package/cjs/es6/relationships/with-schemas/index.cjs +1 -1
- package/cjs/es6/synchronizers/synchronizer-ws-server-durable-object/index.cjs +10 -6
- package/cjs/es6/synchronizers/synchronizer-ws-server-durable-object/with-schemas/index.cjs +10 -6
- package/cjs/es6/with-schemas/index.cjs +0 -1
- package/cjs/min/persisters/persister-durable-object-storage/index.cjs +1 -1
- package/cjs/min/persisters/persister-durable-object-storage/index.cjs.gz +0 -0
- package/cjs/min/persisters/persister-durable-object-storage/with-schemas/index.cjs +1 -1
- package/cjs/min/persisters/persister-durable-object-storage/with-schemas/index.cjs.gz +0 -0
- package/cjs/min/synchronizers/synchronizer-ws-server-durable-object/index.cjs +1 -1
- package/cjs/min/synchronizers/synchronizer-ws-server-durable-object/index.cjs.gz +0 -0
- package/cjs/min/synchronizers/synchronizer-ws-server-durable-object/with-schemas/index.cjs +1 -1
- package/cjs/min/synchronizers/synchronizer-ws-server-durable-object/with-schemas/index.cjs.gz +0 -0
- package/cjs/persisters/persister-durable-object-storage/index.cjs +1 -1
- package/cjs/persisters/persister-durable-object-storage/with-schemas/index.cjs +1 -1
- package/cjs/persisters/persister-partykit-client/index.cjs +2 -5
- package/cjs/persisters/persister-partykit-client/with-schemas/index.cjs +2 -5
- package/cjs/synchronizers/synchronizer-ws-server-durable-object/index.cjs +3 -3
- package/cjs/synchronizers/synchronizer-ws-server-durable-object/with-schemas/index.cjs +3 -3
- package/es6/index.js +0 -1
- package/es6/indexes/index.js +1 -1
- package/es6/indexes/with-schemas/index.js +1 -1
- package/es6/metrics/index.js +1 -1
- package/es6/metrics/with-schemas/index.js +1 -1
- package/es6/min/index.js +1 -1
- package/es6/min/index.js.gz +0 -0
- package/es6/min/indexes/index.js +1 -1
- package/es6/min/indexes/index.js.gz +0 -0
- package/es6/min/indexes/with-schemas/index.js +1 -1
- package/es6/min/indexes/with-schemas/index.js.gz +0 -0
- package/es6/min/metrics/index.js +1 -1
- package/es6/min/metrics/index.js.gz +0 -0
- package/es6/min/metrics/with-schemas/index.js +1 -1
- package/es6/min/metrics/with-schemas/index.js.gz +0 -0
- package/es6/min/persisters/persister-durable-object-storage/index.js +1 -1
- package/es6/min/persisters/persister-durable-object-storage/index.js.gz +0 -0
- package/es6/min/persisters/persister-durable-object-storage/with-schemas/index.js +1 -1
- package/es6/min/persisters/persister-durable-object-storage/with-schemas/index.js.gz +0 -0
- package/es6/min/persisters/persister-file/index.js +1 -1
- package/es6/min/persisters/persister-file/index.js.gz +0 -0
- package/es6/min/persisters/persister-file/with-schemas/index.js +1 -1
- package/es6/min/persisters/persister-file/with-schemas/index.js.gz +0 -0
- package/es6/min/queries/index.js +1 -1
- package/es6/min/queries/index.js.gz +0 -0
- package/es6/min/queries/with-schemas/index.js +1 -1
- package/es6/min/queries/with-schemas/index.js.gz +0 -0
- package/es6/min/relationships/index.js +1 -1
- package/es6/min/relationships/index.js.gz +0 -0
- package/es6/min/relationships/with-schemas/index.js +1 -1
- package/es6/min/relationships/with-schemas/index.js.gz +0 -0
- package/es6/min/synchronizers/synchronizer-ws-server-durable-object/index.js +1 -1
- package/es6/min/synchronizers/synchronizer-ws-server-durable-object/index.js.gz +0 -0
- package/es6/min/synchronizers/synchronizer-ws-server-durable-object/with-schemas/index.js +1 -1
- package/es6/min/synchronizers/synchronizer-ws-server-durable-object/with-schemas/index.js.gz +0 -0
- package/es6/min/ui-react-dom/index.js +1 -1
- package/es6/min/ui-react-dom/index.js.gz +0 -0
- package/es6/min/ui-react-dom/with-schemas/index.js +1 -1
- package/es6/min/ui-react-dom/with-schemas/index.js.gz +0 -0
- package/es6/min/ui-react-inspector/index.js +1 -1
- package/es6/min/ui-react-inspector/index.js.gz +0 -0
- package/es6/min/ui-react-inspector/with-schemas/index.js +1 -1
- package/es6/min/ui-react-inspector/with-schemas/index.js.gz +0 -0
- package/es6/min/with-schemas/index.js +1 -1
- package/es6/min/with-schemas/index.js.gz +0 -0
- package/es6/persisters/persister-durable-object-storage/index.js +1 -1
- package/es6/persisters/persister-durable-object-storage/with-schemas/index.js +1 -1
- package/es6/persisters/persister-file/index.js +1 -1
- package/es6/persisters/persister-file/with-schemas/index.js +1 -1
- package/es6/persisters/persister-partykit-client/index.js +2 -5
- package/es6/persisters/persister-partykit-client/with-schemas/index.js +2 -5
- package/es6/queries/index.js +0 -1
- package/es6/queries/with-schemas/index.js +0 -1
- package/es6/relationships/index.js +1 -1
- package/es6/relationships/with-schemas/index.js +1 -1
- package/es6/synchronizers/synchronizer-ws-server-durable-object/index.js +10 -6
- package/es6/synchronizers/synchronizer-ws-server-durable-object/with-schemas/index.js +10 -6
- package/es6/ui-react-dom/index.js +8 -8
- package/es6/ui-react-dom/with-schemas/index.js +8 -8
- package/es6/ui-react-inspector/index.js +4 -4
- package/es6/ui-react-inspector/with-schemas/index.js +4 -4
- package/es6/with-schemas/index.js +0 -1
- package/min/persisters/persister-durable-object-storage/index.js +1 -1
- package/min/persisters/persister-durable-object-storage/index.js.gz +0 -0
- package/min/persisters/persister-durable-object-storage/with-schemas/index.js +1 -1
- package/min/persisters/persister-durable-object-storage/with-schemas/index.js.gz +0 -0
- package/min/persisters/persister-file/index.js +1 -1
- package/min/persisters/persister-file/index.js.gz +0 -0
- package/min/persisters/persister-file/with-schemas/index.js +1 -1
- package/min/persisters/persister-file/with-schemas/index.js.gz +0 -0
- package/min/synchronizers/synchronizer-ws-server-durable-object/index.js +1 -1
- package/min/synchronizers/synchronizer-ws-server-durable-object/index.js.gz +0 -0
- package/min/synchronizers/synchronizer-ws-server-durable-object/with-schemas/index.js +1 -1
- package/min/synchronizers/synchronizer-ws-server-durable-object/with-schemas/index.js.gz +0 -0
- package/min/ui-react-dom/index.js +1 -1
- package/min/ui-react-dom/index.js.gz +0 -0
- package/min/ui-react-dom/with-schemas/index.js +1 -1
- package/min/ui-react-dom/with-schemas/index.js.gz +0 -0
- package/min/ui-react-inspector/index.js +1 -1
- package/min/ui-react-inspector/index.js.gz +0 -0
- package/min/ui-react-inspector/with-schemas/index.js +1 -1
- package/min/ui-react-inspector/with-schemas/index.js.gz +0 -0
- package/package.json +1 -1
- package/persisters/persister-durable-object-storage/index.js +1 -1
- package/persisters/persister-durable-object-storage/with-schemas/index.js +1 -1
- package/persisters/persister-file/index.js +1 -1
- package/persisters/persister-file/with-schemas/index.js +1 -1
- package/persisters/persister-partykit-client/index.js +2 -5
- package/persisters/persister-partykit-client/with-schemas/index.js +2 -5
- package/readme.md +2 -2
- package/releases.md +17 -5
- package/synchronizers/synchronizer-ws-server-durable-object/index.js +3 -3
- package/synchronizers/synchronizer-ws-server-durable-object/with-schemas/index.js +3 -3
- package/ui-react-dom/index.js +8 -8
- package/ui-react-dom/with-schemas/index.js +8 -8
- package/ui-react-inspector/index.js +4 -4
- package/ui-react-inspector/with-schemas/index.js +4 -4
- package/umd/es6/index.js +0 -1
- package/umd/es6/indexes/index.js +1 -5
- package/umd/es6/indexes/with-schemas/index.js +1 -5
- package/umd/es6/metrics/index.js +1 -5
- package/umd/es6/metrics/with-schemas/index.js +1 -5
- package/umd/es6/min/index.js +1 -1
- package/umd/es6/min/index.js.gz +0 -0
- package/umd/es6/min/indexes/index.js +1 -1
- package/umd/es6/min/indexes/index.js.gz +0 -0
- package/umd/es6/min/indexes/with-schemas/index.js +1 -1
- package/umd/es6/min/indexes/with-schemas/index.js.gz +0 -0
- package/umd/es6/min/metrics/index.js +1 -1
- package/umd/es6/min/metrics/index.js.gz +0 -0
- package/umd/es6/min/metrics/with-schemas/index.js +1 -1
- package/umd/es6/min/metrics/with-schemas/index.js.gz +0 -0
- package/umd/es6/min/persisters/persister-durable-object-storage/index.js +1 -1
- package/umd/es6/min/persisters/persister-durable-object-storage/index.js.gz +0 -0
- package/umd/es6/min/persisters/persister-durable-object-storage/with-schemas/index.js +1 -1
- package/umd/es6/min/persisters/persister-durable-object-storage/with-schemas/index.js.gz +0 -0
- package/umd/es6/min/queries/index.js +1 -1
- package/umd/es6/min/queries/index.js.gz +0 -0
- package/umd/es6/min/queries/with-schemas/index.js +1 -1
- package/umd/es6/min/queries/with-schemas/index.js.gz +0 -0
- package/umd/es6/min/relationships/index.js +1 -1
- package/umd/es6/min/relationships/index.js.gz +0 -0
- package/umd/es6/min/relationships/with-schemas/index.js +1 -1
- package/umd/es6/min/relationships/with-schemas/index.js.gz +0 -0
- package/umd/es6/min/synchronizers/synchronizer-ws-server-durable-object/index.js +1 -1
- package/umd/es6/min/synchronizers/synchronizer-ws-server-durable-object/index.js.gz +0 -0
- package/umd/es6/min/synchronizers/synchronizer-ws-server-durable-object/with-schemas/index.js +1 -1
- package/umd/es6/min/synchronizers/synchronizer-ws-server-durable-object/with-schemas/index.js.gz +0 -0
- package/umd/es6/min/with-schemas/index.js +1 -1
- package/umd/es6/min/with-schemas/index.js.gz +0 -0
- package/umd/es6/persisters/persister-durable-object-storage/index.js +1 -1
- package/umd/es6/persisters/persister-durable-object-storage/with-schemas/index.js +1 -1
- package/umd/es6/persisters/persister-partykit-client/index.js +2 -5
- package/umd/es6/persisters/persister-partykit-client/with-schemas/index.js +2 -5
- package/umd/es6/queries/index.js +0 -1
- package/umd/es6/queries/with-schemas/index.js +0 -1
- package/umd/es6/relationships/index.js +1 -5
- package/umd/es6/relationships/with-schemas/index.js +1 -5
- package/umd/es6/synchronizers/synchronizer-ws-server-durable-object/index.js +10 -6
- package/umd/es6/synchronizers/synchronizer-ws-server-durable-object/with-schemas/index.js +10 -6
- package/umd/es6/with-schemas/index.js +0 -1
- package/umd/min/persisters/persister-durable-object-storage/index.js +1 -1
- package/umd/min/persisters/persister-durable-object-storage/index.js.gz +0 -0
- package/umd/min/persisters/persister-durable-object-storage/with-schemas/index.js +1 -1
- package/umd/min/persisters/persister-durable-object-storage/with-schemas/index.js.gz +0 -0
- package/umd/min/synchronizers/synchronizer-ws-server-durable-object/index.js +1 -1
- package/umd/min/synchronizers/synchronizer-ws-server-durable-object/index.js.gz +0 -0
- package/umd/min/synchronizers/synchronizer-ws-server-durable-object/with-schemas/index.js +1 -1
- package/umd/min/synchronizers/synchronizer-ws-server-durable-object/with-schemas/index.js.gz +0 -0
- package/umd/persisters/persister-durable-object-storage/index.js +1 -1
- package/umd/persisters/persister-durable-object-storage/with-schemas/index.js +1 -1
- package/umd/persisters/persister-partykit-client/index.js +2 -5
- package/umd/persisters/persister-partykit-client/with-schemas/index.js +2 -5
- package/umd/synchronizers/synchronizer-ws-server-durable-object/index.js +3 -3
- package/umd/synchronizers/synchronizer-ws-server-durable-object/with-schemas/index.js +3 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
import e from"react";import{useCell as t,useValue as n,useSetValueCallback as s,useSetCellCallback as l,useValueIds as a,useStoreOrStoreById as r,ValueView as o,useRowCount as i,useSortedRowIds as d,CellView as c,useTableCellIds as u,useIndexesOrIndexesById as h,useSliceRowIds as m,useRelationshipsOrRelationshipsById as g,useRemoteRowId as p,useRowIds as b,useResultRowCount as f,useResultSortedRowIds as y,ResultCellView as I,useResultTableCellIds as w,useIndexes as v,useIndexIds as C,useSliceIds as k,useMetrics as x,useMetricIds as T,useMetric as S,useQueries as q,useQueryIds as N,useRelationships as V,useRelationshipIds as L,useStore as M,useTableIds as R,useValues as E,useStoreIds as z,useMetricsIds as $,useIndexesIds as A,useRelationshipsIds as J,useQueriesIds as O,useCreateStore as P,useCreatePersister as D}from"../../ui-react/with-schemas/index.js";const F=e=>typeof e,j="",B=F(j),H=F(!0),W=F(0),Q=F(F),G="type",K="default",U="Has",X="Ids",Y="Table",Z=Y+"s",_=Y+X,ee="Row",te=ee+"Count",ne=ee+X,se="Cell",le=se+X,ae="Value",re=ae+"s",oe=ae+X,ie="currentTarget",de="value",ce=e=>j+e,ue=globalThis.window,he=Math,me=he.min,ge=he.floor,pe=isFinite,be=e=>null==e,fe=(e,t,n)=>be(e)?n?.():t(e),ye=e=>e==B||e==H,Ie=e=>F(e)==Q,we=e=>Array.isArray(e),ve=(e,t,n)=>e.slice(t,n),Ce=e=>e.length,ke=e=>{throw Error(e)},{PureComponent:xe,Fragment:Te,createContext:Se,createElement:qe,useCallback:Ne,useContext:Ve,useEffect:Le,useLayoutEffect:Me,useMemo:Re,useRef:Ee,useState:ze,useSyncExternalStore:$e}=e,Ae=(e,...t)=>be(e)?{}:e(...t),Je=(e,t)=>e.sort(t),Oe=(e,t)=>e.forEach(t),Pe=(e,t)=>e.map(t),De=e=>0==Ce(e),Fe=(e,...t)=>e.push(...t),je=e=>e.shift(),Be=Object,He=e=>Be.getPrototypeOf(e),We=Be.entries,Qe=Be.isFrozen,Ge=e=>!be(e)&&fe(He(e),(e=>e==Be.prototype||be(He(e))),(()=>!0)),Ke=Be.keys,Ue=Be.freeze,Xe=(e=[])=>Be.fromEntries(e),Ye=(e,t)=>t in e,Ze=(e,t)=>(delete e[t],e),_e=(e,t)=>Pe(We(e),(([e,n])=>t(n,e))),et=e=>Ge(e)&&0==(e=>Ce(Ke(e)))(e),tt=(e,t,n,s=0)=>be(e)||!Ge(e)||!s&&et(e)||Qe(e)?(n?.(),!1):(_e(e,((n,s)=>{t(n,s)||Ze(e,s)})),!!s||!et(e)),nt=JSON.stringify,st=JSON.parse,lt=e=>nt(e,((e,t)=>t instanceof Map?Be.fromEntries([...t]):t)),at="tinybaseInspector",rt="TinyBase Inspector",ot=["left","top","bottom","right","full"],it="state",dt="sort",ct="open",ut="position",ht=ct,mt="editable",gt=(...e)=>lt(e),pt=(e,t)=>Pe(Je([...e]),t),bt=(e,n)=>[!!t(it,e,mt,n),Ne((t=>{n.setCell(it,e,mt,(e=>!e)),t.preventDefault()}),[n,e])],ft="M20 80l5-15l40-40l10 10l-40 40l-15 5m5-15l10 10",yt='content:url("',It=yt+"data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100' stroke-width='4' stroke='white' fill='none'>",wt='</svg>")',vt=yt+"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\")",Ct=Pe([[20,20,20,60],[20,20,60,20],[20,60,60,20],[60,20,20,60],[30,30,40,40]],(([e,t,n,s])=>It+`<rect x='20' y='20' width='60' height='60' fill='grey'/><rect x='${e}' y='${t}' width='${n}' height='${s}' fill='white'/>`+wt)),kt=It+"<path d='M20 20l60 60M20 80l60-60' />"+wt,xt=It+`<path d='${ft}' />`+wt,Tt=It+`<path d='${ft}M20 20l60 60' />`+wt,St="*::-webkit-scrollbar",qt=((e,t="")=>e.join(t))(_e({"":"all:initial;font-family:sans-serif;font-size:0.75rem;position:fixed;z-index:999999","*":"all:revert","*::before":"all:revert","*::after":"all:revert",[St]:"width:0.5rem;height:0.5rem;",[St+"-track"]:"background:#111",[St+"-thumb"]:"background:#999;border:1px solid #111",[St+"-thumb:hover"]:"background:#fff",[St+"-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;"+vt,...Xe(Pe(["bottom:0;left:0","top:0;right:0"],((e,t)=>[`>img[data-position='${t}']`,e]))),main:"display:flex;flex-direction:column;background:#111d;color:#fff;position:fixed;",...Xe(Pe(["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,t)=>[`main[data-position='${t}']`,e]))),header:"display:flex;padding:0.25rem;background:#000;align-items:center","header>img:nth-of-type(1)":vt,"header>img:nth-of-type(6)":kt,...Xe(Pe(Ct,((e,t)=>[`header>img[data-id='${t}']`,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":xt,"details[open]>summary img.done":Tt,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,#${at} 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,t)=>e?`#${at} ${t}{${e}}`:""))),Nt=({s:e})=>{const t=n(ut,e)??1,l=s(ht,(()=>!0),[],e);return n(ht,e)?null:qe("img",{onClick:l,title:rt,"data-position":t})},Vt=({uniqueId:e,summary:n,editable:s,handleEditable:a,children:r,s:o})=>{const i=!!t(it,e,ct,o),d=l(it,e,ct,(e=>e[ie].open),[],o);return qe("details",{open:i,onToggle:d},qe("summary",null,n,a?qe("img",{onClick:a,className:s?"done":"edit"}):null),r)},Lt=e=>{const t=F(e);return ye(t)||t==W&&pe(e)?t:void 0},Mt=(e,t,n,s,l)=>be(l)?e.delCell(t,n,s,!0):e.setCell(t,n,s,l),Rt=(e,t,n)=>be(n)?e.delValue(t):e.setValue(t,n),Et=(e,t,n,s)=>e==B?t:e==W?n:s,zt="editable",$t=(e,t)=>Pe(u(e,t),(t=>e+"."+t)),At=(e,t,n)=>{const s=Ne(e,t);return n?s:void 0},Jt=(...e)=>Re((()=>e),e),Ot=(e,t)=>Re((()=>({store:e,tableId:t})),[e,t]),Pt=(e,t)=>Re((()=>({queries:e,queryId:t})),[e,t]),Dt=(e,t=!1,n,s=0,l,a,r,o)=>{const[[i,d,c],u]=ze([e,t,s]),h=Ne((e=>{u(e),o?.(e)}),[o]),m=At((e=>h([e,e==i&&!d,c])),[h,i,d,c],n),g=Ne((e=>h([i,d,e])),[h,i,d]),p=!0===r?_t:r;return[[i,d,c],m,Re((()=>!1===r?null:qe(p,{offset:c,limit:l,total:a,onChange:g})),[r,p,c,l,a,g])]},Ft=(e,t,n)=>Re((()=>{const s=t??e;return l=we(s)?Xe(Pe(s,(e=>[e,e]))):s,a=(e,t)=>{return{label:t,component:n,...(s=e,F(s)==B?{label:e}:e)};var s},Xe(_e(l,((e,t)=>[t,a(e,t)])));var l,a}),[t,n,e]),jt=({className:e,headerRow:t,idColumn:n,params:[s,l,a,r,o,i]})=>qe("table",{className:e},i?qe("caption",null,i):null,!1===t?null:qe("thead",null,qe("tr",null,!1===n?null:qe(Bt,{sort:r??[],label:"Id",onClick:o}),_e(s,(({label:e},t)=>qe(Bt,{key:t,cellId:t,label:e,sort:r??[],onClick:o}))))),qe("tbody",null,Pe(a,(e=>qe("tr",{key:e},!1===n?null:qe("th",null,e),_e(s,(({component:t,getComponentProps:n},s)=>qe("td",{key:s},qe(t,{...Ae(n,e,s),...l,rowId:e,cellId:s}))))))))),Bt=({cellId:e,sort:[t,n],label:s=e??j,onClick:l})=>qe("th",{onClick:At((()=>l?.(e)),[l,e],l),className:be(n)||t!=e?void 0:`sorted ${n?"de":"a"}scending`},be(n)||t!=e?null:(n?"↓":"↑")+" ",s),Ht=({localRowId:e,params:[t,n,s,l,a,r,o]})=>{const i=p(a,e,r);return qe("tr",null,!1===t?null:qe(Te,null,qe("th",null,e),qe("th",null,i)),_e(n,(({component:t,getComponentProps:n},a)=>{const[r,d]=((e,t="",n)=>e.split(t,n))(a,".",2),c=r===s?e:r===l?i:null;return be(c)?null:qe("td",{key:a},qe(t,{...Ae(n,c,d),store:o,tableId:r,rowId:c,cellId:d}))})))},Wt=({thing:e,onThingChange:t,className:n,hasSchema:s,showType:l=!0})=>{const[a,r]=ze(),[o,i]=ze(),[d,c]=ze(),[u,h]=ze(),[m,g]=ze();o!==e&&(r(Lt(e)),i(e),c(e+""),h(Number(e)||0),g(!!e));const p=Ne(((e,n)=>{n(e),i(e),t(e)}),[t]),b=Ne((()=>{if(!s?.()){const e=Et(a,W,H,B),n=Et(e,d,u,m);r(e),i(n),t(n)}}),[s,t,d,u,m,a]);return qe("div",{className:n},l?qe("button",{className:a,onClick:b},a):null,Et(a,qe("input",{key:a,value:d,onChange:Ne((e=>p(e[ie][de]+"",c)),[p])}),qe("input",{key:a,type:"number",value:u,onChange:Ne((e=>p(Number(e[ie][de]||0),h)),[p])}),qe("input",{key:a,type:"checkbox",checked:m,onChange:Ne((e=>p(!!e[ie].checked,g)),[p])})))},Qt=({tableId:e,cellId:t,descending:n,offset:s,limit:l,store:a,editable:r,sortOnClick:o,paginator:h=!1,onChange:m,customCells:g,...p})=>{const[b,f,y]=Dt(t,n,o,s,l,i(e,a),h,m);return qe(jt,{...p,params:Jt(Ft(u(e,a),g,r?Yt:c),Ot(a,e),d(e,...b,l,a),b,f,y)})},Gt=({store:e,editable:t=!1,valueComponent:n=(t?Zt:o),getValueComponentProps:s,className:l,headerRow:r,idColumn:i})=>qe("table",{className:l},!1===r?null:qe("thead",null,qe("tr",null,!1===i?null:qe("th",null,"Id"),qe("th",null,ae))),qe("tbody",null,Pe(a(e),(t=>qe("tr",{key:t},!1===i?null:qe("th",null,t),qe("td",null,qe(n,{...Ae(s,t),valueId:t,store:e}))))))),Kt=({indexId:e,sliceId:t,indexes:n,editable:s,customCells:l,...a})=>{const[r,o,i]=((e,t)=>[e,e?.getStore(),e?.getTableId(t)])(h(n),e);return qe(jt,{...a,params:Jt(Ft(u(i,o),l,s?Yt:c),Ot(o,i),m(e,t,r))})},Ut=({relationshipId:e,relationships:t,editable:n,customCells:s,className:l,headerRow:a,idColumn:r=!0})=>{const[o,i,d,u]=((e,t)=>[e,e?.getStore(),e?.getLocalTableId(t),e?.getRemoteTableId(t)])(g(t),e),h=Ft([...$t(d,i),...$t(u,i)],s,n?Yt:c),m=Jt(r,h,d,u,e,o,i);return qe("table",{className:l},!1===a?null:qe("thead",null,qe("tr",null,!1===r?null:qe(Te,null,qe("th",null,d,".Id"),qe("th",null,u,".Id")),_e(h,(({label:e},t)=>qe("th",{key:t},e))))),qe("tbody",null,Pe(b(d,i),(e=>qe(Ht,{key:e,localRowId:e,params:m})))))},Xt=({queryId:e,cellId:t,descending:n,offset:s,limit:l,queries:a,sortOnClick:r,paginator:o=!1,customCells:i,onChange:d,...c})=>{const[u,h,m]=Dt(t,n,r,s,l,f(e,a),o,d);return qe(jt,{...c,params:Jt(Ft(w(e,a),i,I),Pt(a,e),y(e,...u,l,a),u,h,m)})},Yt=({tableId:e,rowId:n,cellId:s,store:a,className:o,showType:i})=>qe(Wt,{thing:t(e,n,s,a),onThingChange:l(e,n,s,(e=>e),[],a),className:o??zt+se,showType:i,hasSchema:r(a)?.hasTablesSchema}),Zt=({valueId:e,store:t,className:l,showType:a})=>qe(Wt,{thing:n(e,t),onThingChange:s(e,(e=>e),[],t),className:l??zt+ae,showType:a,hasSchema:r(t)?.hasValuesSchema}),_t=({onChange:e,total:t,offset:n=0,limit:s=t,singular:l="row",plural:a=l+"s"})=>{(n>t||n<0)&&(n=0,e(0));const r=At((()=>e(n-s)),[e,n,s],n>0),o=At((()=>e(n+s)),[e,n,s],n+s<t);return qe(Te,null,t>s&&qe(Te,null,qe("button",{className:"previous",disabled:0==n,onClick:r},"←"),qe("button",{className:"next",disabled:n+s>=t,onClick:o},"→"),n+1," to ",me(t,n+s)," of "),t," ",1!=t?a:l)},en=({indexes:e,indexesId:t,indexId:n,s:s})=>qe(Vt,{uniqueId:gt("i",t,n),summary:"Index: "+n,s:s},Pe(k(n,e),(l=>qe(tn,{indexes:e,indexesId:t,indexId:n,sliceId:l,s:s,key:l})))),tn=({indexes:e,indexesId:t,indexId:n,sliceId:s,s:l})=>{const a=gt("i",t,n,s),[r,o]=bt(a,l);return qe(Vt,{uniqueId:a,summary:"Slice: "+s,editable:r,handleEditable:o,s:l},qe(Kt,{sliceId:s,indexId:n,indexes:e,editable:r}))},nn=({indexesId:e,s:t})=>{const n=v(e),s=C(n);return be(n)?null:qe(Vt,{uniqueId:gt("i",e),summary:"Indexes: "+(e??K),s:t},De(s)?"No indexes defined":pt(s,(s=>qe(en,{indexes:n,indexesId:e,indexId:s,s:t,key:s}))))},sn=({metrics:e,metricId:t})=>qe("tr",null,qe("th",null,t),qe("td",null,e?.getTableId(t)),qe("td",null,S(t,e))),ln=({metricsId:e,s:t})=>{const n=x(e),s=T(n);return be(n)?null:qe(Vt,{uniqueId:gt("m",e),summary:"Metrics: "+(e??K),s:t},De(s)?"No metrics defined":qe("table",null,qe("thead",null,qe("th",null,"Metric Id"),qe("th",null,"Table Id"),qe("th",null,"Metric")),qe("tbody",null,Pe(s,(e=>qe(sn,{metrics:n,metricId:e,key:e}))))))},an=({queries:e,queriesId:n,queryId:s,s:a})=>{const r=gt("q",n,s),[o,i,d]=st(t(it,r,dt,a)??"[]"),c=l(it,r,dt,lt,[],a);return qe(Vt,{uniqueId:r,summary:"Query: "+s,s:a},qe(Xt,{queryId:s,queries:e,cellId:o,descending:i,offset:d,limit:10,paginator:!0,sortOnClick:!0,onChange:c}))},rn=({queriesId:e,s:t})=>{const n=q(e),s=N(n);return be(n)?null:qe(Vt,{uniqueId:gt("q",e),summary:"Queries: "+(e??K),s:t},De(s)?"No queries defined":pt(s,(s=>qe(an,{queries:n,queriesId:e,queryId:s,s:t,key:s}))))},on=({relationships:e,relationshipsId:t,relationshipId:n,s:s})=>{const l=gt("r",t,n),[a,r]=bt(l,s);return qe(Vt,{uniqueId:l,summary:"Relationship: "+n,editable:a,handleEditable:r,s:s},qe(Ut,{relationshipId:n,relationships:e,editable:a}))},dn=({relationshipsId:e,s:t})=>{const n=V(e),s=L(n);return be(n)?null:qe(Vt,{uniqueId:gt("r",e),summary:"Relationships: "+(e??K),s:t},De(s)?"No relationships defined":pt(s,(s=>qe(on,{relationships:n,relationshipsId:e,relationshipId:s,s:t,key:s}))))},cn=({tableId:e,store:n,storeId:s,s:a})=>{const r=gt("t",s,e),[o,i,d]=st(t(it,r,dt,a)??"[]"),c=l(it,r,dt,lt,[],a),[u,h]=bt(r,a);return qe(Vt,{uniqueId:r,summary:Y+": "+e,editable:u,handleEditable:h,s:a},qe(Qt,{tableId:e,store:n,cellId:o,descending:i,offset:d,limit:10,paginator:!0,sortOnClick:!0,onChange:c,editable:u}))},un=({store:e,storeId:t,s:n})=>{const s=gt("v",t),[l,r]=bt(s,n);return De(a(e))?null:qe(Vt,{uniqueId:s,summary:re,editable:l,handleEditable:r,s:n},qe(Gt,{store:e,editable:l}))},hn=({storeId:e,s:t})=>{const n=M(e),s=R(n);return be(n)?null:qe(Vt,{uniqueId:gt("s",e),summary:(n.isMergeable()?"Mergeable":"")+"Store: "+(e??K),s:t},qe(un,{storeId:e,store:n,s:t}),pt(s,(s=>qe(cn,{store:n,storeId:e,tableId:s,s:t,key:s}))))},mn=({s:e})=>{const t=Ee(null),n=Ee(0),[s,l]=ze(!1),{scrollLeft:a,scrollTop:r}=E(e);Me((()=>{const e=t.current;if(e&&!s){const t=new MutationObserver((()=>{e.scrollWidth>=ge(a)+e.clientWidth&&e.scrollHeight>=ge(r)+e.clientHeight&&e.scrollTo(a,r)}));return t.observe(e,{childList:!0,subtree:!0}),()=>t.disconnect()}}),[s,a,r]);const o=Ne((t=>{const{scrollLeft:s,scrollTop:a}=t[ie];cancelIdleCallback(n.current),n.current=requestIdleCallback((()=>{l(!0),e.setPartialValues({scrollLeft:s,scrollTop:a})}))}),[e]),i=M(),d=z(),c=x(),u=$(),h=v(),m=A(),g=V(),p=J(),b=q(),f=O();return be(i)&&De(d)&&be(c)&&De(u)&&be(h)&&De(m)&&be(g)&&De(p)&&be(b)&&De(f)?qe("span",{className:"warn"},"There are no Stores or other objects to inspect. Make sure you placed the Inspector inside a Provider component."):qe("article",{ref:t,onScroll:o},qe(hn,{s:e}),Pe(d,(t=>qe(hn,{storeId:t,s:e,key:t}))),qe(ln,{s:e}),Pe(u,(t=>qe(ln,{metricsId:t,s:e,key:t}))),qe(nn,{s:e}),Pe(m,(t=>qe(nn,{indexesId:t,s:e,key:t}))),qe(dn,{s:e}),Pe(p,(t=>qe(dn,{relationshipsId:t,s:e,key:t}))),qe(rn,{s:e}),Pe(f,(t=>qe(rn,{queriesId:t,s:e,key:t}))))};class gn extends xe{constructor(e){super(e),this.state={e:0}}static getDerivedStateFromError(){return{e:1}}componentDidCatch=(e,t)=>console.error(e,t.componentStack);render(){return this.state.e?qe("span",{className:"warn"},"Inspector error: please see console for details."):this.props.children}}const pn=({s:e})=>{const t=n(ut,e)??1,l=s(ht,(()=>!1),[],e),a=s(ut,(e=>Number(e[ie].dataset.id)),[],e);return qe("header",null,qe("img",{title:rt}),qe("span",null,rt),Pe(ot,((e,n)=>n==t?null:qe("img",{onClick:a,"data-id":n,title:"Dock to "+e,key:n}))),qe("img",{onClick:l,title:"Close"}))},bn=({s:e})=>{const t=n(ut,e)??1;return n(ht,e)?qe("main",{"data-position":t},qe(pn,{s:e}),qe(gn,null,qe(mn,{s:e}))):null},fn=e=>t=>{return n=(t,n)=>t+e(n),xn(t).reduce(n,0);var n},yn=e=>e?.size??0,In=fn(yn),wn=fn(In),vn=fn(wn),Cn=(e,t)=>e?.has(t)??!1,kn=e=>be(e)||0==yn(e),xn=e=>[...e?.values()??[]],Tn=e=>e.clear(),Sn=(e,t)=>e?.forEach(t),qn=(e,t)=>e?.delete(t),Nn=e=>new Map(e),Vn=e=>[...e?.keys()??[]],Ln=(e,t)=>e?.get(t),Mn=(e,t)=>Sn(e,((e,n)=>t(n,e))),Rn=(e,t,n)=>be(n)?(qn(e,t),e):e?.set(t,n),En=(e,t,n,s)=>(Cn(e,t)?s?.(Ln(e,t)):Rn(e,t,n()),Ln(e,t)),zn=(e,t,n,s=Rn)=>(_e(t,((t,s)=>n(e,s,t))),Mn(e,(n=>Ye(t,n)?0:s(e,n))),e),$n=(e,t,n,s)=>{const l={};return Sn(e,((e,a)=>{if(!n?.(e,a)){const n=t?t(e,a):e;s?.(n)||(l[a]=n)}})),l},An=(e,t,n)=>$n(e,(e=>$n(e,t,n)),kn,et),Jn=(e,t,n)=>$n(e,(e=>An(e,t,n)),kn,et),On=(e,t)=>{const n=Nn();return Sn(e,((e,s)=>n.set(s,t?.(e)??e))),n},Pn=e=>On(e,On),Dn=e=>On(e,Pn),Fn=(e,t,n,s,l=0)=>fe((n?En:Ln)(e,t[l],l>Ce(t)-2?n:Nn),(a=>{if(l>Ce(t)-2)return s?.(a)&&Rn(e,t[l]),a;const r=Fn(a,t,n,s,l+1);return kn(a)&&Rn(e,t[l]),r})),jn=e=>new Set(we(e)||be(e)?e:[e]),Bn=(e,t)=>e?.add(t),Hn=/^\d+$/,Wn=()=>{const e=[];let t=0;return[n=>(n?je(e):null)??j+t++,t=>{Hn.test(t)&&Ce(e)<1e3&&Fe(e,t)}]},Qn=e=>{let t;const[n,s]=Wn(),l=Nn();return[(s,a,r,o=[],i=()=>[])=>{t??=e();const d=n(1);return Rn(l,d,[s,a,r,o,i]),Bn(Fn(a,r??[j],jn),d),d},(e,n,...s)=>Oe(((e,t=[j])=>{const n=[],s=(e,l)=>l==Ce(t)?Fe(n,e):null===t[l]?Sn(e,(e=>s(e,l+1))):Oe([t[l],null],(t=>s(Ln(e,t),l+1)));return s(e,0),n})(e,n),(e=>Sn(e,(e=>Ln(l,e)[0](t,...n??[],...s))))),e=>fe(Ln(l,e),(([,t,n])=>(Fn(t,n??[j],void 0,(t=>(qn(t,e),kn(t)?1:0))),Rn(l,e),s(e),n))),e=>fe(Ln(l,e),(([e,,n=[],s,l])=>{const a=(...r)=>{const o=Ce(r);o==Ce(n)?e(t,...r,...l(r)):be(n[o])?Oe(s[o]?.(...r)??[],(e=>a(...r,e))):a(...r,n[o])};a()}))]},Gn=Nn(),Kn=Nn(),Un="storage",Xn=e=>[e,e],Yn=(e,t=In)=>t(e[0])+t(e[1]),Zn=()=>[Nn(),Nn()],_n=e=>[...e],es=([e,t])=>e===t,ts=(e,t,n)=>Rn(e,t,Ln(e,t)==-n?void 0:n),ns=()=>{let e,t,n=!1,s=!1,l=0,a=[];const r=Nn(),o=Nn(),i=Nn(),d=Nn(),c=Nn(),u=Nn(),h=Nn(),m=Nn(),g=Nn(),p=Nn(),b=Nn(),f=Nn(),y=Nn(),I=Nn(),w=jn(),v=Nn(),C=Nn(),k=Nn(),x=Nn(),T=Zn(),S=Zn(),q=Zn(),N=Zn(),V=Zn(),L=Zn(),M=Zn(),R=Zn(),E=Zn(),z=Zn(),$=Zn(),A=Zn(),J=Zn(),O=Zn(),P=Zn(),D=Zn(),F=Zn(),j=Zn(),B=Zn(),H=Zn(),Q=Zn(),X=Zn(),ie=Nn(),de=Zn(),[ue,he,me,ge]=Qn((()=>nn)),pe=e=>{if(!tt(e,((e,t)=>[G,K].includes(t))))return!1;const t=e[G];return!(!ye(t)&&t!=W||(Lt(e[K])!=t&&Ze(e,K),0))},ke=we,xe=(t,n)=>(!e||Cn(b,n)||ut(n))&&tt(t,((e,t)=>Te(n,t,e)),(()=>ut(n))),Te=(e,t,n,s)=>tt(s?n:Ve(n,e,t),((s,l)=>fe(Se(e,t,l,s),(e=>(n[l]=e,!0)),(()=>!1))),(()=>ut(e,t))),Se=(t,n,s,l)=>e?fe(Ln(Ln(b,t),s),(e=>Lt(l)!=e[G]?ut(t,n,s,l,e[K]):l),(()=>ut(t,n,s,l))):be(Lt(l))?ut(t,n,s,l):l,qe=(e,t)=>tt(t?e:Le(e),((t,n)=>fe(Ne(n,t),(t=>(e[n]=t,!0)),(()=>!1))),(()=>ht())),Ne=(e,n)=>t?fe(Ln(y,e),(t=>Lt(n)!=t[G]?ht(e,n,t[K]):n),(()=>ht(e,n))):be(Lt(n))?ht(e,n):n,Ve=(e,t,n)=>(fe(Ln(f,t),(([s,l])=>{Sn(s,((t,n)=>{Ye(e,n)||(e[n]=t)})),Sn(l,(s=>{Ye(e,s)||ut(t,n,s)}))})),e),Le=e=>(t&&(Sn(I,((t,n)=>{Ye(e,n)||(e[n]=t)})),Sn(w,(t=>{Ye(e,t)||ht(t)}))),e),Me=e=>zn(b,e,((e,t,n)=>{const s=Nn(),l=jn();zn(En(b,t,Nn),n,((e,t,n)=>{Rn(e,t,n),fe(n[K],(e=>Rn(s,t,e)),(()=>Bn(l,t)))})),Rn(f,t,[s,l])}),((e,t)=>{Rn(b,t),Rn(f,t)})),Re=e=>zn(y,e,((e,t,n)=>{Rn(y,t,n),fe(n[K],(e=>Rn(I,t,e)),(()=>Bn(w,t)))}),((e,t)=>{Rn(y,t),Rn(I,t),qn(w,t)})),Ee=e=>et(e)?Gt():jt(e),ze=e=>zn(k,e,((e,t,n)=>$e(t,n)),((e,t)=>Ge(t))),$e=(e,t)=>zn(En(k,e,(()=>(at(e,1),Rn(v,e,Wn()),Rn(C,e,Nn()),Nn()))),t,((t,n,s)=>Ae(e,t,n,s)),((t,n)=>Ke(e,t,n))),Ae=(e,t,n,s,l)=>zn(En(t,n,(()=>(rt(e,n,1),Nn()))),s,((t,s,l)=>De(e,n,t,s,l)),((s,a)=>Xe(e,t,n,s,a,l))),De=(e,t,n,s,l)=>{Cn(n,s)||ot(e,t,s,1);const a=Ln(n,s);l!==a&&(it(e,t,s,a,l),Rn(n,s,l))},je=(e,t,n,s,l)=>fe(Ln(t,n),(t=>De(e,n,t,s,l)),(()=>Ae(e,t,n,Ve({[s]:l},e,n)))),Be=e=>et(e)?Xt():Bt(e),He=e=>zn(x,e,((e,t,n)=>We(t,n)),((e,t)=>nt(t))),We=(e,t)=>{Cn(x,e)||dt(e,1);const n=Ln(x,e);t!==n&&(ct(e,n,t),Rn(x,e,t))},Qe=e=>Ln(k,e)??$e(e,{}),Ge=e=>$e(e,{}),Ke=(e,t,n)=>{const[,s]=Ln(v,e);s(n),Ae(e,t,n,{},!0)},Xe=(e,t,n,s,l,a)=>{const r=Ln(Ln(f,e)?.[0],l);if(!be(r)&&!a)return De(e,n,s,l,r);const o=t=>{it(e,n,t,Ln(s,t)),ot(e,n,t,-1),Rn(s,t)};be(r)?o(l):Mn(s,o),kn(s)&&(rt(e,n,-1),kn(Rn(t,n))&&(at(e,-1),Rn(k,e),Rn(v,e),Rn(C,e)))},nt=e=>{const t=Ln(I,e);if(!be(t))return We(e,t);ct(e,Ln(x,e)),dt(e,-1),Rn(x,e)},at=(e,t)=>ts(r,e,t),rt=(e,t,n)=>ts(En(d,e,Nn),t,n)&&Rn(i,e,En(i,e,(()=>0))+n),ot=(e,t,n,s)=>{const l=Ln(C,e),a=Ln(l,n)??0;(0==a&&1==s||1==a&&-1==s)&&ts(En(o,e,Nn),n,s),Rn(l,n,a!=-s?a+s:null),ts(En(En(c,e,Nn),t,Nn),n,s)},it=(e,t,n,s,l)=>{En(En(En(u,e,Nn),t,Nn),n,(()=>[s,0]))[1]=l,a[3]?.(e,t,n,l)},dt=(e,t)=>ts(h,e,t),ct=(e,t,n)=>{En(m,e,(()=>[t,0]))[1]=n,a[4]?.(e,n)},ut=(e,t,n,s,l)=>(Fe(En(En(En(g,e,Nn),t,Nn),n,(()=>[])),s),l),ht=(e,t,n)=>(Fe(En(p,e,(()=>[])),t),n),mt=(e,t,n)=>fe(Ln(Ln(Ln(u,e),t),n),(([e,t])=>[!0,e,t]),(()=>[!1,...Xn(Nt(e,t,n))])),gt=e=>fe(Ln(m,e),(([e,t])=>[!0,e,t]),(()=>[!1,...Xn(zt(e))])),pt=e=>kn(g)||kn(D[e])?0:Sn(e?Dn(g):g,((t,n)=>Sn(t,((t,s)=>Sn(t,((t,l)=>he(D[e],[n,s,l],t))))))),bt=e=>kn(p)||kn(F[e])?0:Sn(e?On(p):p,((t,n)=>he(F[e],[n],t))),ft=(e,t,n,s)=>{if(!kn(e))return he(t,s,(()=>$n(e))),Mn(e,((e,t)=>he(n,[...s??[],e],1==t))),1},yt=e=>{const t=$t();t!=n&&he(T[e],void 0,t);const s=kn(z[e]),l=kn(J[e])&&kn(O[e])&&kn(E[e])&&kn($[e])&&kn(L[e])&&kn(M[e])&&kn(R[e])&&s&&kn(q[e])&&kn(N[e]),a=kn(P[e])&&kn(A[e])&&kn(V[e])&&kn(S[e]);if(!l||!a){const t=e?[On(r),Pn(o),On(i),Pn(d),Dn(c),Dn(u)]:[r,o,i,d,c,u];if(!l){ft(t[0],q[e],N[e]),Sn(t[1],((t,n)=>ft(t,L[e],M[e],[n]))),Sn(t[2],((t,n)=>{0!=t&&he(R[e],[n],xt(n))}));const n=jn();Sn(t[3],((t,l)=>{ft(t,E[e],$[e],[l])&&!s&&(he(z[e],[l,null]),Bn(n,l))})),s||Sn(t[5],((t,s)=>{if(!Cn(n,s)){const n=jn();Sn(t,(e=>Sn(e,(([t,s],l)=>s!==t?Bn(n,l):qn(e,l))))),Sn(n,(t=>he(z[e],[s,t])))}})),Sn(t[4],((t,n)=>Sn(t,((t,s)=>ft(t,J[e],O[e],[n,s])))))}if(!a){let n;Sn(t[5],((t,s)=>{let l;Sn(t,((t,a)=>{let r;Sn(t,(([t,o],i)=>{o!==t&&(he(P[e],[s,a,i],o,t,mt),n=l=r=1)})),r&&he(A[e],[s,a],mt)})),l&&he(V[e],[s],mt)})),n&&he(S[e],void 0,mt)}}},It=e=>{const t=Dt();t!=s&&he(j[e],void 0,t);const n=kn(H[e])&&kn(Q[e]),l=kn(X[e])&&kn(B[e]);if(!n||!l){const t=e?[On(h),On(m)]:[h,m];if(n||ft(t[0],H[e],Q[e]),!l){let n;Sn(t[1],(([t,s],l)=>{s!==t&&(he(X[e],[l],s,t,gt),n=1)})),n&&he(B[e],void 0,gt)}}},wt=(e,...t)=>(_t((()=>e(...Pe(t,ce)))),nn),vt=()=>Jn(k),Ct=()=>Vn(k),kt=e=>Vn(Ln(C,ce(e))),xt=e=>yn(Ln(k,ce(e))),Tt=e=>Vn(Ln(k,ce(e))),St=(e,t,n,s=0,l)=>{return Pe(ve(Je((a=Ln(k,ce(e)),r=(e,n)=>[be(t)?n:Ln(e,ce(t)),n],Pe([...a?.entries()??[]],(([e,t])=>r(t,e)))),(([e],[t])=>((e??0)<(t??0)?-1:1)*(n?-1:1))),s,be(l)?l:s+l),(([,e])=>e));var a,r},qt=(e,t)=>Vn(Ln(Ln(k,ce(e)),ce(t))),Nt=(e,t,n)=>Ln(Ln(Ln(k,ce(e)),ce(t)),ce(n)),Vt=()=>$n(x),Et=()=>Vn(x),zt=e=>Ln(x,ce(e)),$t=()=>!kn(k),At=e=>Cn(k,ce(e)),Jt=(e,t)=>Cn(Ln(C,ce(e)),ce(t)),Ot=(e,t)=>Cn(Ln(k,ce(e)),ce(t)),Pt=(e,t,n)=>Cn(Ln(Ln(k,ce(e)),ce(t)),ce(n)),Dt=()=>!kn(x),Ft=e=>Cn(x,ce(e)),jt=e=>wt((()=>(e=>tt(e,xe,ut))(e)?ze(e):0)),Bt=e=>wt((()=>qe(e)?He(e):0)),Ht=e=>{try{Ee(st(e))}catch{}return nn},Wt=t=>wt((()=>{if((e=tt(t,(e=>tt(e,pe))))&&(Me(t),!kn(k))){const e=vt();Gt(),jt(e)}})),Qt=e=>wt((()=>{if(t=(e=>tt(e,pe))(e)){const n=Vt();Zt(),Xt(),t=!0,Re(e),Bt(n)}})),Gt=()=>wt((()=>ze({}))),Kt=e=>wt((e=>Cn(k,e)?Ge(e):0),e),Ut=(e,t)=>wt(((e,t)=>fe(Ln(k,e),(n=>Cn(n,t)?Ke(e,n,t):0))),e,t),Xt=()=>wt((()=>He({}))),Yt=()=>wt((()=>{Me({}),e=!1})),Zt=()=>wt((()=>{Re({}),t=!1})),_t=(e,t)=>{if(-1!=l){en();const n=e();return tn(t),n}},en=()=>(-1!=l&&l++,1==l&&(a[0]?.(),he(ie)),nn),tn=e=>(l>0&&(l--,0==l&&(l=1,pt(1),kn(u)||yt(1),bt(1),kn(m)||It(1),e?.(nn)&&(Sn(u,((e,t)=>Sn(e,((e,n)=>Sn(e,(([e],s)=>Mt(nn,t,n,s,e))))))),Tn(u),Sn(m,(([e],t)=>Rt(nn,t,e))),Tn(m)),he(de[0],void 0),l=-1,pt(0),kn(u)||yt(0),bt(0),kn(m)||It(0),a[1]?.(),he(de[1],void 0),a[2]?.(),l=0,n=$t(),s=Dt(),Oe([r,o,i,d,c,u,g,h,m,p],Tn))),nn),nn={getContent:()=>[vt(),Vt()],getTables:vt,getTableIds:Ct,getTable:e=>An(Ln(k,ce(e))),getTableCellIds:kt,getRowCount:xt,getRowIds:Tt,getSortedRowIds:St,getRow:(e,t)=>$n(Ln(Ln(k,ce(e)),ce(t))),getCellIds:qt,getCell:Nt,getValues:Vt,getValueIds:Et,getValue:zt,hasTables:$t,hasTable:At,hasTableCell:Jt,hasRow:Ot,hasCell:Pt,hasValues:Dt,hasValue:Ft,getTablesJson:()=>lt(k),getValuesJson:()=>lt(x),getJson:()=>lt([k,x]),getTablesSchemaJson:()=>lt(b),getValuesSchemaJson:()=>lt(y),getSchemaJson:()=>lt([b,y]),hasTablesSchema:()=>e,hasValuesSchema:()=>t,setContent:e=>wt((()=>ke(e)?(([e,t])=>{(et(e)?Gt:jt)(e),(et(t)?Xt:Bt)(t)})(e):0)),setTables:jt,setTable:(e,t)=>wt((e=>xe(t,e)?$e(e,t):0),e),setRow:(e,t,n)=>wt(((e,t)=>Te(e,t,n)?Ae(e,Qe(e),t,n):0),e,t),addRow:(e,t,n=!0)=>_t((()=>{let s;return Te(e,s,t)&&(e=ce(e),Ae(e,Qe(e),s=((e,t)=>{const[n]=Ln(v,e);let s;do{s=n(t)}while(Cn(Ln(k,e),s));return s})(e,n?1:0),t)),s})),setPartialRow:(e,t,n)=>wt(((e,t)=>{if(Te(e,t,n,1)){const s=Qe(e);_e(n,((n,l)=>je(e,s,t,l,n)))}}),e,t),setCell:(e,t,n,s)=>wt(((e,t,n)=>fe(Se(e,t,n,Ie(s)?s(Nt(e,t,n)):s),(s=>je(e,Qe(e),t,n,s)))),e,t,n),setValues:Bt,setPartialValues:e=>wt((()=>qe(e,1)?_e(e,((e,t)=>We(t,e))):0)),setValue:(e,t)=>wt((e=>fe(Ne(e,Ie(t)?t(zt(e)):t),(t=>We(e,t)))),e),applyChanges:e=>wt((()=>{_e(e[0],((e,t)=>be(e)?Kt(t):_e(e,((e,n)=>be(e)?Ut(t,n):_e(e,((e,s)=>Mt(nn,t,n,s,e))))))),_e(e[1],((e,t)=>Rt(nn,t,e)))})),setTablesJson:Ht,setValuesJson:e=>{try{Be(st(e))}catch{}return nn},setJson:e=>wt((()=>{try{const[t,n]=st(e);Ee(t),Be(n)}catch{Ht(e)}})),setTablesSchema:Wt,setValuesSchema:Qt,setSchema:(e,t)=>wt((()=>{Wt(e),Qt(t)})),delTables:Gt,delTable:Kt,delRow:Ut,delCell:(e,t,n,s)=>wt(((e,t,n)=>fe(Ln(k,e),(l=>fe(Ln(l,t),(a=>Cn(a,n)?Xe(e,l,t,a,n,s):0))))),e,t,n),delValues:Xt,delValue:e=>wt((e=>Cn(x,e)?nt(e):0),e),delTablesSchema:Yt,delValuesSchema:Zt,delSchema:()=>wt((()=>{Yt(),Zt()})),transaction:_t,startTransaction:en,getTransactionChanges:()=>[$n(u,((e,t)=>-1===Ln(r,t)?void 0:$n(e,((e,n)=>-1===Ln(Ln(d,t),n)?void 0:$n(e,(([,e])=>e),(e=>es(e)))),kn,et)),kn,et),$n(m,(([,e])=>e),(e=>es(e))),1],getTransactionLog:()=>[!kn(u),!kn(m),Jn(u,_n,es),Jn(g),$n(m,_n,es),$n(p),$n(r),An(d),Jn(c),$n(h)],finishTransaction:tn,forEachTable:e=>Sn(k,((t,n)=>e(n,(e=>Sn(t,((t,n)=>e(n,(e=>Mn(t,e))))))))),forEachTableCell:(e,t)=>Mn(Ln(C,ce(e)),t),forEachRow:(e,t)=>Sn(Ln(k,ce(e)),((e,n)=>t(n,(t=>Mn(e,t))))),forEachCell:(e,t,n)=>Mn(Ln(Ln(k,ce(e)),ce(t)),n),forEachValue:e=>Mn(x,e),addSortedRowIdsListener:(e,t,n,s,l,a,r)=>{let o=St(e,t,n,s,l);return ue((()=>{const r=St(e,t,n,s,l);var i,d,c;d=o,Ce(i=r)===Ce(d)&&(c=(e,t)=>d[t]===e,i.every(c))||(o=r,a(nn,e,t,n,s,l,o))}),z[r?1:0],[e,t],[Ct])},addStartTransactionListener:e=>ue(e,ie),addWillFinishTransactionListener:e=>ue(e,de[0]),addDidFinishTransactionListener:e=>ue(e,de[1]),callListener:e=>(ge(e),nn),delListener:e=>(me(e),nn),getListenerStats:()=>({hasTables:Yn(T),tables:Yn(S),tableIds:Yn(q),hasTable:Yn(N),table:Yn(V),tableCellIds:Yn(L),hasTableCell:Yn(M,wn),rowCount:Yn(R),rowIds:Yn(E),sortedRowIds:Yn(z),hasRow:Yn($,wn),row:Yn(A,wn),cellIds:Yn(J,wn),hasCell:Yn(O,vn),cell:Yn(P,vn),invalidCell:Yn(D,vn),hasValues:Yn(j),values:Yn(B),valueIds:Yn(H),hasValue:Yn(Q),value:Yn(X),invalidValue:Yn(F),transaction:In(ie)+Yn(de)}),isMergeable:()=>!1,createStore:ns,addListener:ue,callListeners:he,setInternalListeners:(e,t,n,s,l)=>a=[e,t,n,s,l]};return _e({[U+Z]:[0,T,[],()=>[$t()]],[Z]:[0,S],[_]:[0,q],[U+Y]:[1,N,[Ct],e=>[At(...e)]],[Y]:[1,V,[Ct]],[Y+le]:[1,L,[Ct]],[U+Y+se]:[2,M,[Ct,kt],e=>[Jt(...e)]],[te]:[1,R,[Ct]],[ne]:[1,E,[Ct]],[U+ee]:[2,$,[Ct,Tt],e=>[Ot(...e)]],[ee]:[2,A,[Ct,Tt]],[le]:[2,J,[Ct,Tt]],[U+se]:[3,O,[Ct,Tt,qt],e=>[Pt(...e)]],[se]:[3,P,[Ct,Tt,qt],e=>Xn(Nt(...e))],InvalidCell:[3,D],[U+re]:[0,j,[],()=>[Dt()]],[re]:[0,B],[oe]:[0,H],[U+ae]:[1,Q,[Et],e=>[Ft(...e)]],[ae]:[1,X,[Et],e=>Xn(zt(e[0]))],InvalidValue:[1,F]},(([e,t,n,s],l)=>{nn["add"+l+"Listener"]=(...l)=>ue(l[e],t[l[e+1]?1:0],e>0?ve(l,0,e):void 0,n,s)})),Ue(nn)},ss=({position:e="right",open:t=!1})=>{const n=P(ns),s=ot.indexOf(e);return D(n,(e=>{return t=at,n=sessionStorage,((e,t,n,s,l,a,r,o={},i=0,d=[])=>{let c,u,h,m=0,g=0,p=0;En(Gn,d,(()=>0)),En(Kn,d,(()=>[]));const b=Nn(),[f,y,I,w,v]=((e=1,t,n)=>1!=e&&t.isMergeable()?[1,t.getMergeableContent,()=>t.getTransactionMergeableChanges(!n),([[e],[t]])=>!et(e)||!et(t),t.setDefaultContent]:2!=e?[0,t.getContent,t.getTransactionChanges,([e,t])=>!et(e)||!et(t),t.setContent]:ke("Store type not supported by this Persister"))(r,e,i),[C,k,x]=Qn((()=>R)),T=e=>{e!=m&&(m=e,k(b,void 0,m))},S=t=>{(f&&we(t?.[0])?1===t?.[2]?e.applyMergeableChanges:e.setMergeableContent:1===t?.[2]?e.applyChanges:e.setContent)(t)},q=async e=>(2!=m&&(T(1),g++,await M((async()=>{try{const n=await t();we(n)?S(n):e?v(e):ke("Content is not an array: "+n)}catch(t){e&&v(e)}T(0)}))),R),N=()=>(u&&(l(u),u=void 0),R),V=async e=>(1!=m&&(T(2),p++,await M((async()=>{try{await n(y,e)}catch(e){}T(0)}))),R),L=()=>(h&&(e.delListener(h),h=void 0),R),M=async(...e)=>(Fe(Ln(Kn,d),...e),await(async()=>{if(!Ln(Gn,d)){for(Rn(Gn,d,1);!be(c=je(Ln(Kn,d)));)try{await c()}catch(e){}Rn(Gn,d,0)}})(),R),R={load:q,startAutoLoad:async e=>{N(),await q(e);try{u=await s((async(e,t)=>{t||e?2!=m&&(T(1),g++,S(t??e),T(0)):await q()}))}catch(e){}return R},stopAutoLoad:N,isAutoLoading:()=>!be(u),save:V,startAutoSave:async()=>(L(),await V(),h=e.addDidFinishTransactionListener((()=>{const e=I();w(e)&&V(e)})),R),stopAutoSave:L,isAutoSaving:()=>!be(h),getStatus:()=>m,addStatusListener:e=>C(e,b),delListener:t=>(x(t),e),schedule:M,getStore:()=>e,destroy:()=>(Ln(Kn,d).splice(0,void 0),N().stopAutoSave()),getStats:()=>({loads:g,saves:p}),...o};return Ue(R)})(e,(async()=>{return e=n.getItem(t),st(e,((e,t)=>""===t?void 0:t));var e}),(async e=>{return n.setItem(t,(s=e(),nt(s,((e,t)=>void 0===t?"":t))));var s}),(e=>{const s=s=>{if(s.storageArea===n&&s.key===t)try{e(st(s.newValue))}catch{e()}};return ue.addEventListener(Un,s),s}),(e=>ue.removeEventListener(Un,e)),0,3,{getStorageName:()=>t});var t,n}),void 0,(async e=>{await e.load([{},{position:-1==s?1:s,open:!!t}]),await e.startAutoSave()})),qe(Te,null,qe("aside",{id:at},qe(Nt,{s:n}),qe(bn,{s:n})),qe("style",null,qt))};export{ss as Inspector};
|
|
1
|
+
import e from"react";import{useCell as t,useValue as n,useSetValueCallback as s,useSetCellCallback as l,useValueIds as a,ValueView as r,useStoreOrStoreById as o,useRowCount as i,useSortedRowIds as d,useTableCellIds as c,useIndexesOrIndexesById as u,useSliceRowIds as h,useRelationshipsOrRelationshipsById as m,useRowIds as g,useResultRowCount as p,useResultSortedRowIds as b,useResultTableCellIds as f,useRemoteRowId as y,CellView as I,ResultCellView as w,useIndexes as v,useIndexIds as C,useSliceIds as k,useMetrics as x,useMetricIds as T,useMetric as S,useQueries as q,useQueryIds as N,useRelationships as V,useRelationshipIds as L,useStore as M,useTableIds as R,useValues as E,useStoreIds as z,useMetricsIds as $,useIndexesIds as A,useRelationshipsIds as J,useQueriesIds as O,useCreateStore as P,useCreatePersister as D}from"../../ui-react/with-schemas/index.js";const F=e=>typeof e,j="",B=F(j),H=F(!0),W=F(0),Q=F(F),G="type",K="default",U="Has",X="Ids",Y="Table",Z=Y+"s",_=Y+X,ee="Row",te=ee+"Count",ne=ee+X,se="Cell",le=se+X,ae="Value",re=ae+"s",oe=ae+X,ie="currentTarget",de="value",ce=e=>j+e,ue=globalThis.window,he=Math,me=he.min,ge=he.floor,pe=isFinite,be=e=>null==e,fe=(e,t,n)=>be(e)?n?.():t(e),ye=e=>e==B||e==H,Ie=e=>F(e)==Q,we=e=>Array.isArray(e),ve=(e,t,n)=>e.slice(t,n),Ce=e=>e.length,ke=e=>{throw Error(e)},{PureComponent:xe,Fragment:Te,createContext:Se,createElement:qe,useCallback:Ne,useContext:Ve,useEffect:Le,useLayoutEffect:Me,useMemo:Re,useRef:Ee,useState:ze,useSyncExternalStore:$e}=e,Ae=(e,...t)=>be(e)?{}:e(...t),Je=(e,t)=>e.sort(t),Oe=(e,t)=>e.forEach(t),Pe=(e,t)=>e.map(t),De=e=>0==Ce(e),Fe=(e,...t)=>e.push(...t),je=e=>e.shift(),Be=Object,He=e=>Be.getPrototypeOf(e),We=Be.entries,Qe=Be.isFrozen,Ge=e=>!be(e)&&fe(He(e),(e=>e==Be.prototype||be(He(e))),(()=>!0)),Ke=Be.keys,Ue=Be.freeze,Xe=(e=[])=>Be.fromEntries(e),Ye=(e,t)=>t in e,Ze=(e,t)=>(delete e[t],e),_e=(e,t)=>Pe(We(e),(([e,n])=>t(n,e))),et=e=>Ge(e)&&0==(e=>Ce(Ke(e)))(e),tt=(e,t,n,s=0)=>be(e)||!Ge(e)||!s&&et(e)||Qe(e)?(n?.(),!1):(_e(e,((n,s)=>{t(n,s)||Ze(e,s)})),!!s||!et(e)),nt=JSON.stringify,st=JSON.parse,lt=e=>nt(e,((e,t)=>t instanceof Map?Be.fromEntries([...t]):t)),at="tinybaseInspector",rt="TinyBase Inspector",ot=["left","top","bottom","right","full"],it="state",dt="sort",ct="open",ut="position",ht=ct,mt="editable",gt=(...e)=>lt(e),pt=(e,t)=>Pe(Je([...e]),t),bt=(e,n)=>[!!t(it,e,mt,n),Ne((t=>{n.setCell(it,e,mt,(e=>!e)),t.preventDefault()}),[n,e])],ft="M20 80l5-15l40-40l10 10l-40 40l-15 5m5-15l10 10",yt='content:url("',It=yt+"data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100' stroke-width='4' stroke='white' fill='none'>",wt='</svg>")',vt=yt+"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\")",Ct=Pe([[20,20,20,60],[20,20,60,20],[20,60,60,20],[60,20,20,60],[30,30,40,40]],(([e,t,n,s])=>It+`<rect x='20' y='20' width='60' height='60' fill='grey'/><rect x='${e}' y='${t}' width='${n}' height='${s}' fill='white'/>`+wt)),kt=It+"<path d='M20 20l60 60M20 80l60-60' />"+wt,xt=It+`<path d='${ft}' />`+wt,Tt=It+`<path d='${ft}M20 20l60 60' />`+wt,St="*::-webkit-scrollbar",qt=((e,t="")=>e.join(t))(_e({"":"all:initial;font-family:sans-serif;font-size:0.75rem;position:fixed;z-index:999999","*":"all:revert","*::before":"all:revert","*::after":"all:revert",[St]:"width:0.5rem;height:0.5rem;",[St+"-track"]:"background:#111",[St+"-thumb"]:"background:#999;border:1px solid #111",[St+"-thumb:hover"]:"background:#fff",[St+"-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;"+vt,...Xe(Pe(["bottom:0;left:0","top:0;right:0"],((e,t)=>[`>img[data-position='${t}']`,e]))),main:"display:flex;flex-direction:column;background:#111d;color:#fff;position:fixed;",...Xe(Pe(["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,t)=>[`main[data-position='${t}']`,e]))),header:"display:flex;padding:0.25rem;background:#000;align-items:center","header>img:nth-of-type(1)":vt,"header>img:nth-of-type(6)":kt,...Xe(Pe(Ct,((e,t)=>[`header>img[data-id='${t}']`,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":xt,"details[open]>summary img.done":Tt,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,#${at} 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,t)=>e?`#${at} ${t}{${e}}`:""))),Nt=({s:e})=>{const t=n(ut,e)??1,l=s(ht,(()=>!0),[],e);return n(ht,e)?null:qe("img",{onClick:l,title:rt,"data-position":t})},Vt=({uniqueId:e,summary:n,editable:s,handleEditable:a,children:r,s:o})=>{const i=!!t(it,e,ct,o),d=l(it,e,ct,(e=>e[ie].open),[],o);return qe("details",{open:i,onToggle:d},qe("summary",null,n,a?qe("img",{onClick:a,className:s?"done":"edit"}):null),r)},Lt=e=>{const t=F(e);return ye(t)||t==W&&pe(e)?t:void 0},Mt=(e,t,n,s,l)=>be(l)?e.delCell(t,n,s,!0):e.setCell(t,n,s,l),Rt=(e,t,n)=>be(n)?e.delValue(t):e.setValue(t,n),Et=(e,t,n,s)=>e==B?t:e==W?n:s,zt="editable",$t=(e,t)=>Pe(c(e,t),(t=>e+"."+t)),At=(e,t,n)=>{const s=Ne(e,t);return n?s:void 0},Jt=(...e)=>Re((()=>e),e),Ot=(e,t)=>Re((()=>({store:e,tableId:t})),[e,t]),Pt=(e,t)=>Re((()=>({queries:e,queryId:t})),[e,t]),Dt=(e,t=!1,n,s=0,l,a,r,o)=>{const[[i,d,c],u]=ze([e,t,s]),h=Ne((e=>{u(e),o?.(e)}),[o]),m=At((e=>h([e,e==i&&!d,c])),[h,i,d,c],n),g=Ne((e=>h([i,d,e])),[h,i,d]),p=!0===r?_t:r;return[[i,d,c],m,Re((()=>!1===r?null:qe(p,{offset:c,limit:l,total:a,onChange:g})),[r,p,c,l,a,g])]},Ft=(e,t,n)=>Re((()=>{const s=t??e;return l=we(s)?Xe(Pe(s,(e=>[e,e]))):s,a=(e,t)=>{return{label:t,component:n,...(s=e,F(s)==B?{label:e}:e)};var s},Xe(_e(l,((e,t)=>[t,a(e,t)])));var l,a}),[t,n,e]),jt=({className:e,headerRow:t,idColumn:n,params:[s,l,a,r,o,i]})=>qe("table",{className:e},i?qe("caption",null,i):null,!1===t?null:qe("thead",null,qe("tr",null,!1===n?null:qe(Bt,{sort:r??[],label:"Id",onClick:o}),_e(s,(({label:e},t)=>qe(Bt,{key:t,cellId:t,label:e,sort:r??[],onClick:o}))))),qe("tbody",null,Pe(a,(e=>qe("tr",{key:e},!1===n?null:qe("th",null,e),_e(s,(({component:t,getComponentProps:n},s)=>qe("td",{key:s},qe(t,{...Ae(n,e,s),...l,rowId:e,cellId:s}))))))))),Bt=({cellId:e,sort:[t,n],label:s=e??j,onClick:l})=>qe("th",{onClick:At((()=>l?.(e)),[l,e],l),className:be(n)||t!=e?void 0:`sorted ${n?"de":"a"}scending`},be(n)||t!=e?null:(n?"↓":"↑")+" ",s),Ht=({localRowId:e,params:[t,n,s,l,a,r,o]})=>{const i=y(a,e,r);return qe("tr",null,!1===t?null:qe(Te,null,qe("th",null,e),qe("th",null,i)),_e(n,(({component:t,getComponentProps:n},a)=>{const[r,d]=((e,t="",n)=>e.split(t,n))(a,".",2),c=r===s?e:r===l?i:null;return be(c)?null:qe("td",{key:a},qe(t,{...Ae(n,c,d),store:o,tableId:r,rowId:c,cellId:d}))})))},Wt=({thing:e,onThingChange:t,className:n,hasSchema:s,showType:l=!0})=>{const[a,r]=ze(),[o,i]=ze(),[d,c]=ze(),[u,h]=ze(),[m,g]=ze();o!==e&&(r(Lt(e)),i(e),c(e+""),h(Number(e)||0),g(!!e));const p=Ne(((e,n)=>{n(e),i(e),t(e)}),[t]),b=Ne((()=>{if(!s?.()){const e=Et(a,W,H,B),n=Et(e,d,u,m);r(e),i(n),t(n)}}),[s,t,d,u,m,a]);return qe("div",{className:n},l?qe("button",{className:a,onClick:b},a):null,Et(a,qe("input",{key:a,value:d,onChange:Ne((e=>p(e[ie][de]+"",c)),[p])}),qe("input",{key:a,type:"number",value:u,onChange:Ne((e=>p(Number(e[ie][de]||0),h)),[p])}),qe("input",{key:a,type:"checkbox",checked:m,onChange:Ne((e=>p(!!e[ie].checked,g)),[p])})))},Qt=({tableId:e,cellId:t,descending:n,offset:s,limit:l,store:a,editable:r,sortOnClick:o,paginator:u=!1,onChange:h,customCells:m,...g})=>{const[p,b,f]=Dt(t,n,o,s,l,i(e,a),u,h);return qe(jt,{...g,params:Jt(Ft(c(e,a),m,r?Yt:I),Ot(a,e),d(e,...p,l,a),p,b,f)})},Gt=({store:e,editable:t=!1,valueComponent:n=(t?Zt:r),getValueComponentProps:s,className:l,headerRow:o,idColumn:i})=>qe("table",{className:l},!1===o?null:qe("thead",null,qe("tr",null,!1===i?null:qe("th",null,"Id"),qe("th",null,ae))),qe("tbody",null,Pe(a(e),(t=>qe("tr",{key:t},!1===i?null:qe("th",null,t),qe("td",null,qe(n,{...Ae(s,t),valueId:t,store:e}))))))),Kt=({indexId:e,sliceId:t,indexes:n,editable:s,customCells:l,...a})=>{const[r,o,i]=((e,t)=>[e,e?.getStore(),e?.getTableId(t)])(u(n),e);return qe(jt,{...a,params:Jt(Ft(c(i,o),l,s?Yt:I),Ot(o,i),h(e,t,r))})},Ut=({relationshipId:e,relationships:t,editable:n,customCells:s,className:l,headerRow:a,idColumn:r=!0})=>{const[o,i,d,c]=((e,t)=>[e,e?.getStore(),e?.getLocalTableId(t),e?.getRemoteTableId(t)])(m(t),e),u=Ft([...$t(d,i),...$t(c,i)],s,n?Yt:I),h=Jt(r,u,d,c,e,o,i);return qe("table",{className:l},!1===a?null:qe("thead",null,qe("tr",null,!1===r?null:qe(Te,null,qe("th",null,d,".Id"),qe("th",null,c,".Id")),_e(u,(({label:e},t)=>qe("th",{key:t},e))))),qe("tbody",null,Pe(g(d,i),(e=>qe(Ht,{key:e,localRowId:e,params:h})))))},Xt=({queryId:e,cellId:t,descending:n,offset:s,limit:l,queries:a,sortOnClick:r,paginator:o=!1,customCells:i,onChange:d,...c})=>{const[u,h,m]=Dt(t,n,r,s,l,p(e,a),o,d);return qe(jt,{...c,params:Jt(Ft(f(e,a),i,w),Pt(a,e),b(e,...u,l,a),u,h,m)})},Yt=({tableId:e,rowId:n,cellId:s,store:a,className:r,showType:i})=>qe(Wt,{thing:t(e,n,s,a),onThingChange:l(e,n,s,(e=>e),[],a),className:r??zt+se,showType:i,hasSchema:o(a)?.hasTablesSchema}),Zt=({valueId:e,store:t,className:l,showType:a})=>qe(Wt,{thing:n(e,t),onThingChange:s(e,(e=>e),[],t),className:l??zt+ae,showType:a,hasSchema:o(t)?.hasValuesSchema}),_t=({onChange:e,total:t,offset:n=0,limit:s=t,singular:l="row",plural:a=l+"s"})=>{(n>t||n<0)&&(n=0,e(0));const r=At((()=>e(n-s)),[e,n,s],n>0),o=At((()=>e(n+s)),[e,n,s],n+s<t);return qe(Te,null,t>s&&qe(Te,null,qe("button",{className:"previous",disabled:0==n,onClick:r},"←"),qe("button",{className:"next",disabled:n+s>=t,onClick:o},"→"),n+1," to ",me(t,n+s)," of "),t," ",1!=t?a:l)},en=({indexes:e,indexesId:t,indexId:n,s:s})=>qe(Vt,{uniqueId:gt("i",t,n),summary:"Index: "+n,s:s},Pe(k(n,e),(l=>qe(tn,{indexes:e,indexesId:t,indexId:n,sliceId:l,s:s,key:l})))),tn=({indexes:e,indexesId:t,indexId:n,sliceId:s,s:l})=>{const a=gt("i",t,n,s),[r,o]=bt(a,l);return qe(Vt,{uniqueId:a,summary:"Slice: "+s,editable:r,handleEditable:o,s:l},qe(Kt,{sliceId:s,indexId:n,indexes:e,editable:r}))},nn=({indexesId:e,s:t})=>{const n=v(e),s=C(n);return be(n)?null:qe(Vt,{uniqueId:gt("i",e),summary:"Indexes: "+(e??K),s:t},De(s)?"No indexes defined":pt(s,(s=>qe(en,{indexes:n,indexesId:e,indexId:s,s:t,key:s}))))},sn=({metrics:e,metricId:t})=>qe("tr",null,qe("th",null,t),qe("td",null,e?.getTableId(t)),qe("td",null,S(t,e))),ln=({metricsId:e,s:t})=>{const n=x(e),s=T(n);return be(n)?null:qe(Vt,{uniqueId:gt("m",e),summary:"Metrics: "+(e??K),s:t},De(s)?"No metrics defined":qe("table",null,qe("thead",null,qe("th",null,"Metric Id"),qe("th",null,"Table Id"),qe("th",null,"Metric")),qe("tbody",null,Pe(s,(e=>qe(sn,{metrics:n,metricId:e,key:e}))))))},an=({queries:e,queriesId:n,queryId:s,s:a})=>{const r=gt("q",n,s),[o,i,d]=st(t(it,r,dt,a)??"[]"),c=l(it,r,dt,lt,[],a);return qe(Vt,{uniqueId:r,summary:"Query: "+s,s:a},qe(Xt,{queryId:s,queries:e,cellId:o,descending:i,offset:d,limit:10,paginator:!0,sortOnClick:!0,onChange:c}))},rn=({queriesId:e,s:t})=>{const n=q(e),s=N(n);return be(n)?null:qe(Vt,{uniqueId:gt("q",e),summary:"Queries: "+(e??K),s:t},De(s)?"No queries defined":pt(s,(s=>qe(an,{queries:n,queriesId:e,queryId:s,s:t,key:s}))))},on=({relationships:e,relationshipsId:t,relationshipId:n,s:s})=>{const l=gt("r",t,n),[a,r]=bt(l,s);return qe(Vt,{uniqueId:l,summary:"Relationship: "+n,editable:a,handleEditable:r,s:s},qe(Ut,{relationshipId:n,relationships:e,editable:a}))},dn=({relationshipsId:e,s:t})=>{const n=V(e),s=L(n);return be(n)?null:qe(Vt,{uniqueId:gt("r",e),summary:"Relationships: "+(e??K),s:t},De(s)?"No relationships defined":pt(s,(s=>qe(on,{relationships:n,relationshipsId:e,relationshipId:s,s:t,key:s}))))},cn=({tableId:e,store:n,storeId:s,s:a})=>{const r=gt("t",s,e),[o,i,d]=st(t(it,r,dt,a)??"[]"),c=l(it,r,dt,lt,[],a),[u,h]=bt(r,a);return qe(Vt,{uniqueId:r,summary:Y+": "+e,editable:u,handleEditable:h,s:a},qe(Qt,{tableId:e,store:n,cellId:o,descending:i,offset:d,limit:10,paginator:!0,sortOnClick:!0,onChange:c,editable:u}))},un=({store:e,storeId:t,s:n})=>{const s=gt("v",t),[l,r]=bt(s,n);return De(a(e))?null:qe(Vt,{uniqueId:s,summary:re,editable:l,handleEditable:r,s:n},qe(Gt,{store:e,editable:l}))},hn=({storeId:e,s:t})=>{const n=M(e),s=R(n);return be(n)?null:qe(Vt,{uniqueId:gt("s",e),summary:(n.isMergeable()?"Mergeable":"")+"Store: "+(e??K),s:t},qe(un,{storeId:e,store:n,s:t}),pt(s,(s=>qe(cn,{store:n,storeId:e,tableId:s,s:t,key:s}))))},mn=({s:e})=>{const t=Ee(null),n=Ee(0),[s,l]=ze(!1),{scrollLeft:a,scrollTop:r}=E(e);Me((()=>{const e=t.current;if(e&&!s){const t=new MutationObserver((()=>{e.scrollWidth>=ge(a)+e.clientWidth&&e.scrollHeight>=ge(r)+e.clientHeight&&e.scrollTo(a,r)}));return t.observe(e,{childList:!0,subtree:!0}),()=>t.disconnect()}}),[s,a,r]);const o=Ne((t=>{const{scrollLeft:s,scrollTop:a}=t[ie];cancelIdleCallback(n.current),n.current=requestIdleCallback((()=>{l(!0),e.setPartialValues({scrollLeft:s,scrollTop:a})}))}),[e]),i=M(),d=z(),c=x(),u=$(),h=v(),m=A(),g=V(),p=J(),b=q(),f=O();return be(i)&&De(d)&&be(c)&&De(u)&&be(h)&&De(m)&&be(g)&&De(p)&&be(b)&&De(f)?qe("span",{className:"warn"},"There are no Stores or other objects to inspect. Make sure you placed the Inspector inside a Provider component."):qe("article",{ref:t,onScroll:o},qe(hn,{s:e}),Pe(d,(t=>qe(hn,{storeId:t,s:e,key:t}))),qe(ln,{s:e}),Pe(u,(t=>qe(ln,{metricsId:t,s:e,key:t}))),qe(nn,{s:e}),Pe(m,(t=>qe(nn,{indexesId:t,s:e,key:t}))),qe(dn,{s:e}),Pe(p,(t=>qe(dn,{relationshipsId:t,s:e,key:t}))),qe(rn,{s:e}),Pe(f,(t=>qe(rn,{queriesId:t,s:e,key:t}))))};class gn extends xe{constructor(e){super(e),this.state={e:0}}static getDerivedStateFromError(){return{e:1}}componentDidCatch=(e,t)=>console.error(e,t.componentStack);render(){return this.state.e?qe("span",{className:"warn"},"Inspector error: please see console for details."):this.props.children}}const pn=({s:e})=>{const t=n(ut,e)??1,l=s(ht,(()=>!1),[],e),a=s(ut,(e=>Number(e[ie].dataset.id)),[],e);return qe("header",null,qe("img",{title:rt}),qe("span",null,rt),Pe(ot,((e,n)=>n==t?null:qe("img",{onClick:a,"data-id":n,title:"Dock to "+e,key:n}))),qe("img",{onClick:l,title:"Close"}))},bn=({s:e})=>{const t=n(ut,e)??1;return n(ht,e)?qe("main",{"data-position":t},qe(pn,{s:e}),qe(gn,null,qe(mn,{s:e}))):null},fn=e=>t=>{return n=(t,n)=>t+e(n),xn(t).reduce(n,0);var n},yn=e=>e?.size??0,In=fn(yn),wn=fn(In),vn=fn(wn),Cn=(e,t)=>e?.has(t)??!1,kn=e=>be(e)||0==yn(e),xn=e=>[...e?.values()??[]],Tn=e=>e.clear(),Sn=(e,t)=>e?.forEach(t),qn=(e,t)=>e?.delete(t),Nn=e=>new Map(e),Vn=e=>[...e?.keys()??[]],Ln=(e,t)=>e?.get(t),Mn=(e,t)=>Sn(e,((e,n)=>t(n,e))),Rn=(e,t,n)=>be(n)?(qn(e,t),e):e?.set(t,n),En=(e,t,n,s)=>(Cn(e,t)?s?.(Ln(e,t)):Rn(e,t,n()),Ln(e,t)),zn=(e,t,n,s=Rn)=>(_e(t,((t,s)=>n(e,s,t))),Mn(e,(n=>Ye(t,n)?0:s(e,n))),e),$n=(e,t,n,s)=>{const l={};return Sn(e,((e,a)=>{if(!n?.(e,a)){const n=t?t(e,a):e;s?.(n)||(l[a]=n)}})),l},An=(e,t,n)=>$n(e,(e=>$n(e,t,n)),kn,et),Jn=(e,t,n)=>$n(e,(e=>An(e,t,n)),kn,et),On=(e,t)=>{const n=Nn();return Sn(e,((e,s)=>n.set(s,t?.(e)??e))),n},Pn=e=>On(e,On),Dn=e=>On(e,Pn),Fn=(e,t,n,s,l=0)=>fe((n?En:Ln)(e,t[l],l>Ce(t)-2?n:Nn),(a=>{if(l>Ce(t)-2)return s?.(a)&&Rn(e,t[l]),a;const r=Fn(a,t,n,s,l+1);return kn(a)&&Rn(e,t[l]),r})),jn=e=>new Set(we(e)||be(e)?e:[e]),Bn=(e,t)=>e?.add(t),Hn=/^\d+$/,Wn=()=>{const e=[];let t=0;return[n=>(n?je(e):null)??j+t++,t=>{Hn.test(t)&&Ce(e)<1e3&&Fe(e,t)}]},Qn=e=>{let t;const[n,s]=Wn(),l=Nn();return[(s,a,r,o=[],i=()=>[])=>{t??=e();const d=n(1);return Rn(l,d,[s,a,r,o,i]),Bn(Fn(a,r??[j],jn),d),d},(e,n,...s)=>Oe(((e,t=[j])=>{const n=[],s=(e,l)=>l==Ce(t)?Fe(n,e):null===t[l]?Sn(e,(e=>s(e,l+1))):Oe([t[l],null],(t=>s(Ln(e,t),l+1)));return s(e,0),n})(e,n),(e=>Sn(e,(e=>Ln(l,e)[0](t,...n??[],...s))))),e=>fe(Ln(l,e),(([,t,n])=>(Fn(t,n??[j],void 0,(t=>(qn(t,e),kn(t)?1:0))),Rn(l,e),s(e),n))),e=>fe(Ln(l,e),(([e,,n=[],s,l])=>{const a=(...r)=>{const o=Ce(r);o==Ce(n)?e(t,...r,...l(r)):be(n[o])?Oe(s[o]?.(...r)??[],(e=>a(...r,e))):a(...r,n[o])};a()}))]},Gn=Nn(),Kn=Nn(),Un="storage",Xn=e=>[e,e],Yn=(e,t=In)=>t(e[0])+t(e[1]),Zn=()=>[Nn(),Nn()],_n=e=>[...e],es=([e,t])=>e===t,ts=(e,t,n)=>Rn(e,t,Ln(e,t)==-n?void 0:n),ns=()=>{let e,t,n=!1,s=!1,l=0,a=[];const r=Nn(),o=Nn(),i=Nn(),d=Nn(),c=Nn(),u=Nn(),h=Nn(),m=Nn(),g=Nn(),p=Nn(),b=Nn(),f=Nn(),y=Nn(),I=Nn(),w=jn(),v=Nn(),C=Nn(),k=Nn(),x=Nn(),T=Zn(),S=Zn(),q=Zn(),N=Zn(),V=Zn(),L=Zn(),M=Zn(),R=Zn(),E=Zn(),z=Zn(),$=Zn(),A=Zn(),J=Zn(),O=Zn(),P=Zn(),D=Zn(),F=Zn(),j=Zn(),B=Zn(),H=Zn(),Q=Zn(),X=Zn(),ie=Nn(),de=Zn(),[ue,he,me,ge]=Qn((()=>nn)),pe=e=>{if(!tt(e,((e,t)=>[G,K].includes(t))))return!1;const t=e[G];return!(!ye(t)&&t!=W||(Lt(e[K])!=t&&Ze(e,K),0))},ke=we,xe=(t,n)=>(!e||Cn(b,n)||ut(n))&&tt(t,((e,t)=>Te(n,t,e)),(()=>ut(n))),Te=(e,t,n,s)=>tt(s?n:Ve(n,e,t),((s,l)=>fe(Se(e,t,l,s),(e=>(n[l]=e,!0)),(()=>!1))),(()=>ut(e,t))),Se=(t,n,s,l)=>e?fe(Ln(Ln(b,t),s),(e=>Lt(l)!=e[G]?ut(t,n,s,l,e[K]):l),(()=>ut(t,n,s,l))):be(Lt(l))?ut(t,n,s,l):l,qe=(e,t)=>tt(t?e:Le(e),((t,n)=>fe(Ne(n,t),(t=>(e[n]=t,!0)),(()=>!1))),(()=>ht())),Ne=(e,n)=>t?fe(Ln(y,e),(t=>Lt(n)!=t[G]?ht(e,n,t[K]):n),(()=>ht(e,n))):be(Lt(n))?ht(e,n):n,Ve=(e,t,n)=>(fe(Ln(f,t),(([s,l])=>{Sn(s,((t,n)=>{Ye(e,n)||(e[n]=t)})),Sn(l,(s=>{Ye(e,s)||ut(t,n,s)}))})),e),Le=e=>(t&&(Sn(I,((t,n)=>{Ye(e,n)||(e[n]=t)})),Sn(w,(t=>{Ye(e,t)||ht(t)}))),e),Me=e=>zn(b,e,((e,t,n)=>{const s=Nn(),l=jn();zn(En(b,t,Nn),n,((e,t,n)=>{Rn(e,t,n),fe(n[K],(e=>Rn(s,t,e)),(()=>Bn(l,t)))})),Rn(f,t,[s,l])}),((e,t)=>{Rn(b,t),Rn(f,t)})),Re=e=>zn(y,e,((e,t,n)=>{Rn(y,t,n),fe(n[K],(e=>Rn(I,t,e)),(()=>Bn(w,t)))}),((e,t)=>{Rn(y,t),Rn(I,t),qn(w,t)})),Ee=e=>et(e)?Gt():jt(e),ze=e=>zn(k,e,((e,t,n)=>$e(t,n)),((e,t)=>Ge(t))),$e=(e,t)=>zn(En(k,e,(()=>(at(e,1),Rn(v,e,Wn()),Rn(C,e,Nn()),Nn()))),t,((t,n,s)=>Ae(e,t,n,s)),((t,n)=>Ke(e,t,n))),Ae=(e,t,n,s,l)=>zn(En(t,n,(()=>(rt(e,n,1),Nn()))),s,((t,s,l)=>De(e,n,t,s,l)),((s,a)=>Xe(e,t,n,s,a,l))),De=(e,t,n,s,l)=>{Cn(n,s)||ot(e,t,s,1);const a=Ln(n,s);l!==a&&(it(e,t,s,a,l),Rn(n,s,l))},je=(e,t,n,s,l)=>fe(Ln(t,n),(t=>De(e,n,t,s,l)),(()=>Ae(e,t,n,Ve({[s]:l},e,n)))),Be=e=>et(e)?Xt():Bt(e),He=e=>zn(x,e,((e,t,n)=>We(t,n)),((e,t)=>nt(t))),We=(e,t)=>{Cn(x,e)||dt(e,1);const n=Ln(x,e);t!==n&&(ct(e,n,t),Rn(x,e,t))},Qe=e=>Ln(k,e)??$e(e,{}),Ge=e=>$e(e,{}),Ke=(e,t,n)=>{const[,s]=Ln(v,e);s(n),Ae(e,t,n,{},!0)},Xe=(e,t,n,s,l,a)=>{const r=Ln(Ln(f,e)?.[0],l);if(!be(r)&&!a)return De(e,n,s,l,r);const o=t=>{it(e,n,t,Ln(s,t)),ot(e,n,t,-1),Rn(s,t)};be(r)?o(l):Mn(s,o),kn(s)&&(rt(e,n,-1),kn(Rn(t,n))&&(at(e,-1),Rn(k,e),Rn(v,e),Rn(C,e)))},nt=e=>{const t=Ln(I,e);if(!be(t))return We(e,t);ct(e,Ln(x,e)),dt(e,-1),Rn(x,e)},at=(e,t)=>ts(r,e,t),rt=(e,t,n)=>ts(En(d,e,Nn),t,n)&&Rn(i,e,En(i,e,(()=>0))+n),ot=(e,t,n,s)=>{const l=Ln(C,e),a=Ln(l,n)??0;(0==a&&1==s||1==a&&-1==s)&&ts(En(o,e,Nn),n,s),Rn(l,n,a!=-s?a+s:null),ts(En(En(c,e,Nn),t,Nn),n,s)},it=(e,t,n,s,l)=>{En(En(En(u,e,Nn),t,Nn),n,(()=>[s,0]))[1]=l,a[3]?.(e,t,n,l)},dt=(e,t)=>ts(h,e,t),ct=(e,t,n)=>{En(m,e,(()=>[t,0]))[1]=n,a[4]?.(e,n)},ut=(e,t,n,s,l)=>(Fe(En(En(En(g,e,Nn),t,Nn),n,(()=>[])),s),l),ht=(e,t,n)=>(Fe(En(p,e,(()=>[])),t),n),mt=(e,t,n)=>fe(Ln(Ln(Ln(u,e),t),n),(([e,t])=>[!0,e,t]),(()=>[!1,...Xn(Nt(e,t,n))])),gt=e=>fe(Ln(m,e),(([e,t])=>[!0,e,t]),(()=>[!1,...Xn(zt(e))])),pt=e=>kn(g)||kn(D[e])?0:Sn(e?Dn(g):g,((t,n)=>Sn(t,((t,s)=>Sn(t,((t,l)=>he(D[e],[n,s,l],t))))))),bt=e=>kn(p)||kn(F[e])?0:Sn(e?On(p):p,((t,n)=>he(F[e],[n],t))),ft=(e,t,n,s)=>{if(!kn(e))return he(t,s,(()=>$n(e))),Mn(e,((e,t)=>he(n,[...s??[],e],1==t))),1},yt=e=>{const t=$t();t!=n&&he(T[e],void 0,t);const s=kn(z[e]),l=kn(J[e])&&kn(O[e])&&kn(E[e])&&kn($[e])&&kn(L[e])&&kn(M[e])&&kn(R[e])&&s&&kn(q[e])&&kn(N[e]),a=kn(P[e])&&kn(A[e])&&kn(V[e])&&kn(S[e]);if(!l||!a){const t=e?[On(r),Pn(o),On(i),Pn(d),Dn(c),Dn(u)]:[r,o,i,d,c,u];if(!l){ft(t[0],q[e],N[e]),Sn(t[1],((t,n)=>ft(t,L[e],M[e],[n]))),Sn(t[2],((t,n)=>{0!=t&&he(R[e],[n],xt(n))}));const n=jn();Sn(t[3],((t,l)=>{ft(t,E[e],$[e],[l])&&!s&&(he(z[e],[l,null]),Bn(n,l))})),s||Sn(t[5],((t,s)=>{if(!Cn(n,s)){const n=jn();Sn(t,(e=>Sn(e,(([t,s],l)=>s!==t?Bn(n,l):qn(e,l))))),Sn(n,(t=>he(z[e],[s,t])))}})),Sn(t[4],((t,n)=>Sn(t,((t,s)=>ft(t,J[e],O[e],[n,s])))))}if(!a){let n;Sn(t[5],((t,s)=>{let l;Sn(t,((t,a)=>{let r;Sn(t,(([t,o],i)=>{o!==t&&(he(P[e],[s,a,i],o,t,mt),n=l=r=1)})),r&&he(A[e],[s,a],mt)})),l&&he(V[e],[s],mt)})),n&&he(S[e],void 0,mt)}}},It=e=>{const t=Dt();t!=s&&he(j[e],void 0,t);const n=kn(H[e])&&kn(Q[e]),l=kn(X[e])&&kn(B[e]);if(!n||!l){const t=e?[On(h),On(m)]:[h,m];if(n||ft(t[0],H[e],Q[e]),!l){let n;Sn(t[1],(([t,s],l)=>{s!==t&&(he(X[e],[l],s,t,gt),n=1)})),n&&he(B[e],void 0,gt)}}},wt=(e,...t)=>(_t((()=>e(...Pe(t,ce)))),nn),vt=()=>Jn(k),Ct=()=>Vn(k),kt=e=>Vn(Ln(C,ce(e))),xt=e=>yn(Ln(k,ce(e))),Tt=e=>Vn(Ln(k,ce(e))),St=(e,t,n,s=0,l)=>{return Pe(ve(Je((a=Ln(k,ce(e)),r=(e,n)=>[be(t)?n:Ln(e,ce(t)),n],Pe([...a?.entries()??[]],(([e,t])=>r(t,e)))),(([e],[t])=>((e??0)<(t??0)?-1:1)*(n?-1:1))),s,be(l)?l:s+l),(([,e])=>e));var a,r},qt=(e,t)=>Vn(Ln(Ln(k,ce(e)),ce(t))),Nt=(e,t,n)=>Ln(Ln(Ln(k,ce(e)),ce(t)),ce(n)),Vt=()=>$n(x),Et=()=>Vn(x),zt=e=>Ln(x,ce(e)),$t=()=>!kn(k),At=e=>Cn(k,ce(e)),Jt=(e,t)=>Cn(Ln(C,ce(e)),ce(t)),Ot=(e,t)=>Cn(Ln(k,ce(e)),ce(t)),Pt=(e,t,n)=>Cn(Ln(Ln(k,ce(e)),ce(t)),ce(n)),Dt=()=>!kn(x),Ft=e=>Cn(x,ce(e)),jt=e=>wt((()=>(e=>tt(e,xe,ut))(e)?ze(e):0)),Bt=e=>wt((()=>qe(e)?He(e):0)),Ht=e=>{try{Ee(st(e))}catch{}return nn},Wt=t=>wt((()=>{if((e=tt(t,(e=>tt(e,pe))))&&(Me(t),!kn(k))){const e=vt();Gt(),jt(e)}})),Qt=e=>wt((()=>{if(t=(e=>tt(e,pe))(e)){const n=Vt();Zt(),Xt(),t=!0,Re(e),Bt(n)}})),Gt=()=>wt((()=>ze({}))),Kt=e=>wt((e=>Cn(k,e)?Ge(e):0),e),Ut=(e,t)=>wt(((e,t)=>fe(Ln(k,e),(n=>Cn(n,t)?Ke(e,n,t):0))),e,t),Xt=()=>wt((()=>He({}))),Yt=()=>wt((()=>{Me({}),e=!1})),Zt=()=>wt((()=>{Re({}),t=!1})),_t=(e,t)=>{if(-1!=l){en();const n=e();return tn(t),n}},en=()=>(-1!=l&&l++,1==l&&(a[0]?.(),he(ie)),nn),tn=e=>(l>0&&(l--,0==l&&(l=1,pt(1),kn(u)||yt(1),bt(1),kn(m)||It(1),e?.(nn)&&(Sn(u,((e,t)=>Sn(e,((e,n)=>Sn(e,(([e],s)=>Mt(nn,t,n,s,e))))))),Tn(u),Sn(m,(([e],t)=>Rt(nn,t,e))),Tn(m)),he(de[0],void 0),l=-1,pt(0),kn(u)||yt(0),bt(0),kn(m)||It(0),a[1]?.(),he(de[1],void 0),a[2]?.(),l=0,n=$t(),s=Dt(),Oe([r,o,i,d,c,u,g,h,m,p],Tn))),nn),nn={getContent:()=>[vt(),Vt()],getTables:vt,getTableIds:Ct,getTable:e=>An(Ln(k,ce(e))),getTableCellIds:kt,getRowCount:xt,getRowIds:Tt,getSortedRowIds:St,getRow:(e,t)=>$n(Ln(Ln(k,ce(e)),ce(t))),getCellIds:qt,getCell:Nt,getValues:Vt,getValueIds:Et,getValue:zt,hasTables:$t,hasTable:At,hasTableCell:Jt,hasRow:Ot,hasCell:Pt,hasValues:Dt,hasValue:Ft,getTablesJson:()=>lt(k),getValuesJson:()=>lt(x),getJson:()=>lt([k,x]),getTablesSchemaJson:()=>lt(b),getValuesSchemaJson:()=>lt(y),getSchemaJson:()=>lt([b,y]),hasTablesSchema:()=>e,hasValuesSchema:()=>t,setContent:e=>wt((()=>ke(e)?(([e,t])=>{(et(e)?Gt:jt)(e),(et(t)?Xt:Bt)(t)})(e):0)),setTables:jt,setTable:(e,t)=>wt((e=>xe(t,e)?$e(e,t):0),e),setRow:(e,t,n)=>wt(((e,t)=>Te(e,t,n)?Ae(e,Qe(e),t,n):0),e,t),addRow:(e,t,n=!0)=>_t((()=>{let s;return Te(e,s,t)&&(e=ce(e),Ae(e,Qe(e),s=((e,t)=>{const[n]=Ln(v,e);let s;do{s=n(t)}while(Cn(Ln(k,e),s));return s})(e,n?1:0),t)),s})),setPartialRow:(e,t,n)=>wt(((e,t)=>{if(Te(e,t,n,1)){const s=Qe(e);_e(n,((n,l)=>je(e,s,t,l,n)))}}),e,t),setCell:(e,t,n,s)=>wt(((e,t,n)=>fe(Se(e,t,n,Ie(s)?s(Nt(e,t,n)):s),(s=>je(e,Qe(e),t,n,s)))),e,t,n),setValues:Bt,setPartialValues:e=>wt((()=>qe(e,1)?_e(e,((e,t)=>We(t,e))):0)),setValue:(e,t)=>wt((e=>fe(Ne(e,Ie(t)?t(zt(e)):t),(t=>We(e,t)))),e),applyChanges:e=>wt((()=>{_e(e[0],((e,t)=>be(e)?Kt(t):_e(e,((e,n)=>be(e)?Ut(t,n):_e(e,((e,s)=>Mt(nn,t,n,s,e))))))),_e(e[1],((e,t)=>Rt(nn,t,e)))})),setTablesJson:Ht,setValuesJson:e=>{try{Be(st(e))}catch{}return nn},setJson:e=>wt((()=>{try{const[t,n]=st(e);Ee(t),Be(n)}catch{Ht(e)}})),setTablesSchema:Wt,setValuesSchema:Qt,setSchema:(e,t)=>wt((()=>{Wt(e),Qt(t)})),delTables:Gt,delTable:Kt,delRow:Ut,delCell:(e,t,n,s)=>wt(((e,t,n)=>fe(Ln(k,e),(l=>fe(Ln(l,t),(a=>Cn(a,n)?Xe(e,l,t,a,n,s):0))))),e,t,n),delValues:Xt,delValue:e=>wt((e=>Cn(x,e)?nt(e):0),e),delTablesSchema:Yt,delValuesSchema:Zt,delSchema:()=>wt((()=>{Yt(),Zt()})),transaction:_t,startTransaction:en,getTransactionChanges:()=>[$n(u,((e,t)=>-1===Ln(r,t)?void 0:$n(e,((e,n)=>-1===Ln(Ln(d,t),n)?void 0:$n(e,(([,e])=>e),(e=>es(e)))),kn,et)),kn,et),$n(m,(([,e])=>e),(e=>es(e))),1],getTransactionLog:()=>[!kn(u),!kn(m),Jn(u,_n,es),Jn(g),$n(m,_n,es),$n(p),$n(r),An(d),Jn(c),$n(h)],finishTransaction:tn,forEachTable:e=>Sn(k,((t,n)=>e(n,(e=>Sn(t,((t,n)=>e(n,(e=>Mn(t,e))))))))),forEachTableCell:(e,t)=>Mn(Ln(C,ce(e)),t),forEachRow:(e,t)=>Sn(Ln(k,ce(e)),((e,n)=>t(n,(t=>Mn(e,t))))),forEachCell:(e,t,n)=>Mn(Ln(Ln(k,ce(e)),ce(t)),n),forEachValue:e=>Mn(x,e),addSortedRowIdsListener:(e,t,n,s,l,a,r)=>{let o=St(e,t,n,s,l);return ue((()=>{const r=St(e,t,n,s,l);var i,d,c;d=o,Ce(i=r)===Ce(d)&&(c=(e,t)=>d[t]===e,i.every(c))||(o=r,a(nn,e,t,n,s,l,o))}),z[r?1:0],[e,t],[Ct])},addStartTransactionListener:e=>ue(e,ie),addWillFinishTransactionListener:e=>ue(e,de[0]),addDidFinishTransactionListener:e=>ue(e,de[1]),callListener:e=>(ge(e),nn),delListener:e=>(me(e),nn),getListenerStats:()=>({hasTables:Yn(T),tables:Yn(S),tableIds:Yn(q),hasTable:Yn(N),table:Yn(V),tableCellIds:Yn(L),hasTableCell:Yn(M,wn),rowCount:Yn(R),rowIds:Yn(E),sortedRowIds:Yn(z),hasRow:Yn($,wn),row:Yn(A,wn),cellIds:Yn(J,wn),hasCell:Yn(O,vn),cell:Yn(P,vn),invalidCell:Yn(D,vn),hasValues:Yn(j),values:Yn(B),valueIds:Yn(H),hasValue:Yn(Q),value:Yn(X),invalidValue:Yn(F),transaction:In(ie)+Yn(de)}),isMergeable:()=>!1,createStore:ns,addListener:ue,callListeners:he,setInternalListeners:(e,t,n,s,l)=>a=[e,t,n,s,l]};return _e({[U+Z]:[0,T,[],()=>[$t()]],[Z]:[0,S],[_]:[0,q],[U+Y]:[1,N,[Ct],e=>[At(...e)]],[Y]:[1,V,[Ct]],[Y+le]:[1,L,[Ct]],[U+Y+se]:[2,M,[Ct,kt],e=>[Jt(...e)]],[te]:[1,R,[Ct]],[ne]:[1,E,[Ct]],[U+ee]:[2,$,[Ct,Tt],e=>[Ot(...e)]],[ee]:[2,A,[Ct,Tt]],[le]:[2,J,[Ct,Tt]],[U+se]:[3,O,[Ct,Tt,qt],e=>[Pt(...e)]],[se]:[3,P,[Ct,Tt,qt],e=>Xn(Nt(...e))],InvalidCell:[3,D],[U+re]:[0,j,[],()=>[Dt()]],[re]:[0,B],[oe]:[0,H],[U+ae]:[1,Q,[Et],e=>[Ft(...e)]],[ae]:[1,X,[Et],e=>Xn(zt(e[0]))],InvalidValue:[1,F]},(([e,t,n,s],l)=>{nn["add"+l+"Listener"]=(...l)=>ue(l[e],t[l[e+1]?1:0],e>0?ve(l,0,e):void 0,n,s)})),Ue(nn)},ss=({position:e="right",open:t=!1})=>{const n=P(ns),s=ot.indexOf(e);return D(n,(e=>{return t=at,n=sessionStorage,((e,t,n,s,l,a,r,o={},i=0,d=[])=>{let c,u,h,m=0,g=0,p=0;En(Gn,d,(()=>0)),En(Kn,d,(()=>[]));const b=Nn(),[f,y,I,w,v]=((e=1,t,n)=>1!=e&&t.isMergeable()?[1,t.getMergeableContent,()=>t.getTransactionMergeableChanges(!n),([[e],[t]])=>!et(e)||!et(t),t.setDefaultContent]:2!=e?[0,t.getContent,t.getTransactionChanges,([e,t])=>!et(e)||!et(t),t.setContent]:ke("Store type not supported by this Persister"))(r,e,i),[C,k,x]=Qn((()=>R)),T=e=>{e!=m&&(m=e,k(b,void 0,m))},S=t=>{(f&&we(t?.[0])?1===t?.[2]?e.applyMergeableChanges:e.setMergeableContent:1===t?.[2]?e.applyChanges:e.setContent)(t)},q=async e=>(2!=m&&(T(1),g++,await M((async()=>{try{const n=await t();we(n)?S(n):e?v(e):ke("Content is not an array: "+n)}catch(t){e&&v(e)}T(0)}))),R),N=()=>(u&&(l(u),u=void 0),R),V=async e=>(1!=m&&(T(2),p++,await M((async()=>{try{await n(y,e)}catch(e){}T(0)}))),R),L=()=>(h&&(e.delListener(h),h=void 0),R),M=async(...e)=>(Fe(Ln(Kn,d),...e),await(async()=>{if(!Ln(Gn,d)){for(Rn(Gn,d,1);!be(c=je(Ln(Kn,d)));)try{await c()}catch(e){}Rn(Gn,d,0)}})(),R),R={load:q,startAutoLoad:async e=>{N(),await q(e);try{u=await s((async(e,t)=>{t||e?2!=m&&(T(1),g++,S(t??e),T(0)):await q()}))}catch(e){}return R},stopAutoLoad:N,isAutoLoading:()=>!be(u),save:V,startAutoSave:async()=>(L(),await V(),h=e.addDidFinishTransactionListener((()=>{const e=I();w(e)&&V(e)})),R),stopAutoSave:L,isAutoSaving:()=>!be(h),getStatus:()=>m,addStatusListener:e=>C(e,b),delListener:t=>(x(t),e),schedule:M,getStore:()=>e,destroy:()=>(Ln(Kn,d).splice(0,void 0),N().stopAutoSave()),getStats:()=>({loads:g,saves:p}),...o};return Ue(R)})(e,(async()=>{return e=n.getItem(t),st(e,((e,t)=>""===t?void 0:t));var e}),(async e=>{return n.setItem(t,(s=e(),nt(s,((e,t)=>void 0===t?"":t))));var s}),(e=>{const s=s=>{if(s.storageArea===n&&s.key===t)try{e(st(s.newValue))}catch{e()}};return ue.addEventListener(Un,s),s}),(e=>ue.removeEventListener(Un,e)),0,3,{getStorageName:()=>t});var t,n}),void 0,(async e=>{await e.load([{},{position:-1==s?1:s,open:!!t}]),await e.startAutoSave()})),qe(Te,null,qe("aside",{id:at},qe(Nt,{s:n}),qe(bn,{s:n})),qe("style",null,qt))};export{ss as Inspector};
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -55,10 +55,7 @@ const construct = (prefix, type, payload) =>
|
|
|
55
55
|
const deconstruct = (prefix, message, stringified) => {
|
|
56
56
|
const prefixSize = size(prefix);
|
|
57
57
|
return strStartsWith(message, prefix)
|
|
58
|
-
? [
|
|
59
|
-
message[prefixSize],
|
|
60
|
-
(stringified ? jsonParse : String)(slice(message, prefixSize + 1)),
|
|
61
|
-
]
|
|
58
|
+
? [message[prefixSize], jsonParse(slice(message, prefixSize + 1))]
|
|
62
59
|
: void 0;
|
|
63
60
|
};
|
|
64
61
|
|
|
@@ -461,7 +458,7 @@ const createPartyKitPersister = (
|
|
|
461
458
|
const addPersisterListener = (listener) => {
|
|
462
459
|
const messageListener = (event) =>
|
|
463
460
|
ifNotUndefined(
|
|
464
|
-
deconstruct(messagePrefix, event.data
|
|
461
|
+
deconstruct(messagePrefix, event.data),
|
|
465
462
|
([type, payload]) => {
|
|
466
463
|
if (type == SET_CHANGES) {
|
|
467
464
|
listener(void 0, payload);
|
|
@@ -55,10 +55,7 @@ const construct = (prefix, type, payload) =>
|
|
|
55
55
|
const deconstruct = (prefix, message, stringified) => {
|
|
56
56
|
const prefixSize = size(prefix);
|
|
57
57
|
return strStartsWith(message, prefix)
|
|
58
|
-
? [
|
|
59
|
-
message[prefixSize],
|
|
60
|
-
(stringified ? jsonParse : String)(slice(message, prefixSize + 1)),
|
|
61
|
-
]
|
|
58
|
+
? [message[prefixSize], jsonParse(slice(message, prefixSize + 1))]
|
|
62
59
|
: void 0;
|
|
63
60
|
};
|
|
64
61
|
|
|
@@ -461,7 +458,7 @@ const createPartyKitPersister = (
|
|
|
461
458
|
const addPersisterListener = (listener) => {
|
|
462
459
|
const messageListener = (event) =>
|
|
463
460
|
ifNotUndefined(
|
|
464
|
-
deconstruct(messagePrefix, event.data
|
|
461
|
+
deconstruct(messagePrefix, event.data),
|
|
465
462
|
([type, payload]) => {
|
|
466
463
|
if (type == SET_CHANGES) {
|
|
467
464
|
listener(void 0, payload);
|
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></section><p><a href="https://beta.tinybase.org/guides/releases/#v5-4"><em>NEW!</em> v5.4 release</a></p><p><span id="one-with">"The One With Durable Objects!"</span></p><p><a class="start" href="https://beta.tinybase.org/guides/the-basics/getting-started/">Get started</a></p><p><a href="https://beta.tinybase.org/demos/">Try the demos</a></p><p><a href="https://beta.tinybase.org/api/store/interfaces/store/store/">Read the docs</a></p><hr><section><h2 id="it-s-reactive">It's <em>Reactive</em></h2><p>TinyBase lets you <a href="#register-granular-listeners">listen to changes</a> made to any part of your data. This means your app will be fast, since you only spend rendering cycles on things that change. The optional <a href="#call-hooks-to-bind-to-data">bindings to React</a> and <a href="#pre-built-reactive-components">pre-built components</a> let you easily build fully reactive UIs on top of TinyBase. You even get a built-in <a href="#set-checkpoints-for-an-undo-stack">undo stack</a>, and <a href="#an-inspector-for-your-data">developer tools</a>!</p></section><section><h2 id="it-s-database-like">It's <em>Database-Like</em></h2><p>Consumer app? Enterprise app? Or even a game? Model <a href="#start-with-a-simple-key-value-store">key-value data</a> and <a href="#level-up-to-use-tabular-data">tabular data</a> with optional typed <a href="#apply-schemas-to-tables-values">schematization</a>, whatever its data structures. There are built-in <a href="#create-indexes-for-fast-lookups">indexing</a>, <a href="#define-metrics-and-aggregations">metric aggregation</a>, and tabular <a href="#model-table-relationships">relationships</a> APIs - and a powerful <a href="#build-complex-queries-with-tinyql">query engine</a> to select, join, filter, and group data (reactively!) without SQL.</p></section><section><h2 id="it-synchronizes">It <em>Synchronizes</em></h2><p>TinyBase has <a href="#synchronize-between-devices">native CRDT</a> support, meaning that you can deterministically <a href="https://beta.tinybase.org/guides/synchronization/">synchronize</a> and merge data across multiple sources, clients, and servers. And although TinyBase is an in-memory data store, you can easily <a href="#persist-to-storage-databases-more">persist</a> your data to file, <a href="https://beta.tinybase.org/api/persister-browser">browser storage</a>, <a href="https://beta.tinybase.org/api/persister-indexed-db">IndexedDB</a>, <a href="https://beta.tinybase.org/guides/persistence/database-persistence/">SQLite or PostgreSQL databases</a>, and <a href="https://beta.tinybase.org/guides/persistence/third-party-crdt-persistence/">more</a>.</p></section><section><h2 id="it-s-built-for-a-local-first-world">It's Built For A <em>Local-First</em> World</h2><p>TinyBase works anywhere that JavaScript does, but it's especially great for local-first apps: where data is stored locally on the user's device and that can be run offline. It's tiny by name, tiny by nature: just <a href="#did-we-say-tiny">5.3kB - 11.4kB</a> and with no dependencies - yet <a href="#well-tested-and-documented">100% tested</a>, <a href="https://beta.tinybase.org/guides/the-basics/getting-started/">fully documented</a>, and of course, <a href="https://github.com/tinyplex/tinybase">open source</a>!</p></section><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://beta.tinybase.org/guides/building-uis/getting-started-with-ui-react"><img width="48" src="https://beta.tinybase.org/react.svg"> React</a></div><div><a href="https://beta.tinybase.org/api/persister-indexed-db/functions/creation/createindexeddbpersister"><img width="48" src="https://beta.tinybase.org/indexeddb.svg"> IndexedDB</a></div><div><a href="https://beta.tinybase.org/guides/schemas-and-persistence/database-persistence"><img width="48" src="https://beta.tinybase.org/postgresql.svg"> PostgreSQL</a></div><div><a href="https://beta.tinybase.org/guides/schemas-and-persistence/database-persistence"><img width="48" src="https://beta.tinybase.org/pglite.svg"> PGlite</a></div><div><a href="https://beta.tinybase.org/guides/schemas-and-persistence/database-persistence"><img width="48" src="https://beta.tinybase.org/sqlite.svg"> SQLite</a></div><div><a href="https://beta.tinybase.org/guides/schemas-and-persistence/database-persistence"><img width="48" src="https://beta.tinybase.org/expo.svg"> Expo SQLite</a></div><div><a href="https://beta.tinybase.org/guides/synchronization/using-a-synchronizer/#synchronizing-with-websockets"><img width="48" src="https://beta.tinybase.org/cloudflare.svg"> Cloudflare</a></div><div><a href="https://beta.tinybase.org/guides/schemas-and-persistence/database-persistence"><img width="48" src="https://beta.tinybase.org/electric.svg"> ElectricSQL</a></div><div><a href="https://beta.tinybase.org/guides/schemas-and-persistence/database-persistence"><img width="48" src="https://beta.tinybase.org/turso.svg"> Turso</a></div><div><a href="https://beta.tinybase.org/guides/schemas-and-persistence/database-persistence"><img width="48" src="https://beta.tinybase.org/powersync.svg"> PowerSync</a></div><div><a href="https://beta.tinybase.org/api/persister-partykit-client"><img width="48" src="https://beta.tinybase.org/partykit.svg"> PartyKit</a></div><div><a href="https://beta.tinybase.org/api/persister-yjs/functions/creation/createyjspersister"><img width="48" src="https://beta.tinybase.org/yjs.svg"> YJS</a></div><div><a href="https://beta.tinybase.org/api/persister-cr-sqlite-wasm"><img width="48" src="https://beta.tinybase.org/crsqlite.png"> CR-SQLite</a></div><div><a href="https://beta.tinybase.org/api/persister-automerge"><img width="48" src="https://beta.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/5.4.0-beta.
|
|
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></section><p><a href="https://beta.tinybase.org/guides/releases/#v5-4"><em>NEW!</em> v5.4 release</a></p><p><span id="one-with">"The One With Durable Objects!"</span></p><p><a class="start" href="https://beta.tinybase.org/guides/the-basics/getting-started/">Get started</a></p><p><a href="https://beta.tinybase.org/demos/">Try the demos</a></p><p><a href="https://beta.tinybase.org/api/store/interfaces/store/store/">Read the docs</a></p><hr><section><h2 id="it-s-reactive">It's <em>Reactive</em></h2><p>TinyBase lets you <a href="#register-granular-listeners">listen to changes</a> made to any part of your data. This means your app will be fast, since you only spend rendering cycles on things that change. The optional <a href="#call-hooks-to-bind-to-data">bindings to React</a> and <a href="#pre-built-reactive-components">pre-built components</a> let you easily build fully reactive UIs on top of TinyBase. You even get a built-in <a href="#set-checkpoints-for-an-undo-stack">undo stack</a>, and <a href="#an-inspector-for-your-data">developer tools</a>!</p></section><section><h2 id="it-s-database-like">It's <em>Database-Like</em></h2><p>Consumer app? Enterprise app? Or even a game? Model <a href="#start-with-a-simple-key-value-store">key-value data</a> and <a href="#level-up-to-use-tabular-data">tabular data</a> with optional typed <a href="#apply-schemas-to-tables-values">schematization</a>, whatever its data structures. There are built-in <a href="#create-indexes-for-fast-lookups">indexing</a>, <a href="#define-metrics-and-aggregations">metric aggregation</a>, and tabular <a href="#model-table-relationships">relationships</a> APIs - and a powerful <a href="#build-complex-queries-with-tinyql">query engine</a> to select, join, filter, and group data (reactively!) without SQL.</p></section><section><h2 id="it-synchronizes">It <em>Synchronizes</em></h2><p>TinyBase has <a href="#synchronize-between-devices">native CRDT</a> support, meaning that you can deterministically <a href="https://beta.tinybase.org/guides/synchronization/">synchronize</a> and merge data across multiple sources, clients, and servers. And although TinyBase is an in-memory data store, you can easily <a href="#persist-to-storage-databases-more">persist</a> your data to file, <a href="https://beta.tinybase.org/api/persister-browser">browser storage</a>, <a href="https://beta.tinybase.org/api/persister-indexed-db">IndexedDB</a>, <a href="https://beta.tinybase.org/guides/persistence/database-persistence/">SQLite or PostgreSQL databases</a>, and <a href="https://beta.tinybase.org/guides/persistence/third-party-crdt-persistence/">more</a>.</p></section><section><h2 id="it-s-built-for-a-local-first-world">It's Built For A <em>Local-First</em> World</h2><p>TinyBase works anywhere that JavaScript does, but it's especially great for local-first apps: where data is stored locally on the user's device and that can be run offline. It's tiny by name, tiny by nature: just <a href="#did-we-say-tiny">5.3kB - 11.4kB</a> and with no dependencies - yet <a href="#well-tested-and-documented">100% tested</a>, <a href="https://beta.tinybase.org/guides/the-basics/getting-started/">fully documented</a>, and of course, <a href="https://github.com/tinyplex/tinybase">open source</a>!</p></section><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://beta.tinybase.org/guides/building-uis/getting-started-with-ui-react"><img width="48" src="https://beta.tinybase.org/react.svg"> React</a></div><div><a href="https://beta.tinybase.org/api/persister-indexed-db/functions/creation/createindexeddbpersister"><img width="48" src="https://beta.tinybase.org/indexeddb.svg"> IndexedDB</a></div><div><a href="https://beta.tinybase.org/guides/schemas-and-persistence/database-persistence"><img width="48" src="https://beta.tinybase.org/postgresql.svg"> PostgreSQL</a></div><div><a href="https://beta.tinybase.org/guides/schemas-and-persistence/database-persistence"><img width="48" src="https://beta.tinybase.org/pglite.svg"> PGlite</a></div><div><a href="https://beta.tinybase.org/guides/schemas-and-persistence/database-persistence"><img width="48" src="https://beta.tinybase.org/sqlite.svg"> SQLite</a></div><div><a href="https://beta.tinybase.org/guides/schemas-and-persistence/database-persistence"><img width="48" src="https://beta.tinybase.org/expo.svg"> Expo SQLite</a></div><div><a href="https://beta.tinybase.org/guides/synchronization/using-a-synchronizer/#synchronizing-with-websockets"><img width="48" src="https://beta.tinybase.org/cloudflare.svg"> Cloudflare</a></div><div><a href="https://beta.tinybase.org/guides/schemas-and-persistence/database-persistence"><img width="48" src="https://beta.tinybase.org/electric.svg"> ElectricSQL</a></div><div><a href="https://beta.tinybase.org/guides/schemas-and-persistence/database-persistence"><img width="48" src="https://beta.tinybase.org/turso.svg"> Turso</a></div><div><a href="https://beta.tinybase.org/guides/schemas-and-persistence/database-persistence"><img width="48" src="https://beta.tinybase.org/powersync.svg"> PowerSync</a></div><div><a href="https://beta.tinybase.org/api/persister-partykit-client"><img width="48" src="https://beta.tinybase.org/partykit.svg"> PartyKit</a></div><div><a href="https://beta.tinybase.org/api/persister-yjs/functions/creation/createyjspersister"><img width="48" src="https://beta.tinybase.org/yjs.svg"> YJS</a></div><div><a href="https://beta.tinybase.org/api/persister-cr-sqlite-wasm"><img width="48" src="https://beta.tinybase.org/crsqlite.png"> CR-SQLite</a></div><div><a href="https://beta.tinybase.org/api/persister-automerge"><img width="48" src="https://beta.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/5.4.0-beta.4" 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://beta.tinybase.org/api/store/interfaces/store/store/"><code>Store</code></a> requires just a simple call to the <a href="https://beta.tinybase.org/api/store/functions/creation/createstore/"><code>createStore</code></a> function. Once you have one, you can easily set <a href="https://beta.tinybase.org/api/store/type-aliases/store/values/"><code>Values</code></a> in it by unique <a href="https://beta.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://beta.tinybase.org/guides/the-basics/">The Basics</a> guide.</p></section>
|
|
2
2
|
|
|
3
3
|
```js
|
|
4
4
|
import {createStore} from 'tinybase';
|
|
@@ -294,4 +294,4 @@ export const createShop: typeof createShopDecl = () => {
|
|
|
294
294
|
};
|
|
295
295
|
```
|
|
296
296
|
|
|
297
|
-
<section><h2 id="did-we-say-tiny">Did we say tiny?</h2><p>If you use the basic <a href="https://beta.tinybase.org/api/store/"><code>store</code></a> module alone, you'll only add a gzipped <em>5.3kB</em> to your app. Incrementally add the other modules as you need more functionality, or get it all for <em>11.4kB</em>.</p><p>The optional <a href="https://beta.tinybase.org/api/ui-react/"><code>ui-react</code></a> module is just <em>4.9kB</em>, the ui-react-dom components are another <em>2.6kB</em>, and everything is super fast. Life's easy when you have zero dependencies!</p><p>Read more about how TinyBase is structured and packaged in the <a href="https://beta.tinybase.org/guides/how-tinybase-is-built/architecture/">Architecture</a> guide.</p></section><div class="table"><table class="fixed"><tbody><tr><th> </th><th>Minified .js.gz</th><th>Source .js</th></tr><tr><th class="right"><a href="https://beta.tinybase.org/api/store/">tinybase/store</a> (minimal)</th><td>5.3kB</td><td>52.4kB</td></tr><tr><th class="right">tinybase (complete)</th><td>11.4kB</td><td>119.0kB</td></tr><tr><th class="right"><a href="https://beta.tinybase.org/api/ui-react/">ui-react</a></th><td>4.9kB</td><td>53.5kB</td></tr><tr><th class="right"><a href="https://beta.tinybase.org/api/ui-react-dom/">ui-react-dom</a></th><td>2.6kB</td><td>20.4kB</td></tr></tbody></table></div><section><h2 id="well-tested-and-documented">Well tested and documented.</h2><p>TinyBase has <em>100.0%</em> test coverage, including the code throughout the documentation - even on this page! The guides, demos, and API examples are designed to make it as easy as possible for you to get your TinyBase-powered app up and running.</p><p>Read more about how TinyBase is tested in the Unit <a href="https://beta.tinybase.org/guides/how-tinybase-is-built/testing/">Testing</a> guide.</p></section><div class="table"><table class="fixed"><tbody><tr><th width="30%"> </th><th>Total</th><th>Tested</th><th>Coverage</th></tr><tr><th class="right">Lines</th><td>2,284</td><td>2,284</td><td>100.0%</td></tr><tr><th class="right">Statements</th><td>2,465</td><td>2,465</td><td>100.0%</td></tr><tr><th class="right">Functions</th><td>985</td><td>985</td><td>100.0%</td></tr><tr><th class="right">Branches</th><td>851</td><td>851</td><td>100.0%</td></tr><tr><th class="right">Tests</th><td colspan="3">7,461</td></tr><tr><th class="right">Assertions</th><td colspan="3">33,187</td></tr></tbody></table></div><hr><section id="sponsors"><h2 id="proud-to-be-sponsored-by">Proud to be sponsored by:</h2><a href="https://github.com/cpojer" target="_blank"><img title="cpojer" src="https://github.com/cpojer.png?size=48" width="48" height="48"></a><a href="https://github.com/expo" target="_blank"><img title="expo" src="https://github.com/expo.png?size=48" width="48" height="48"></a><a href="https://github.com/beekeeb" target="_blank"><img title="beekeeb" src="https://github.com/beekeeb.png?size=48" width="48" height="48"></a><a href="https://github.com/cancelself" target="_blank"><img title="cancelself" src="https://github.com/cancelself.png?size=48" width="48" height="48"></a><a href="https://github.com/WonderPanda" target="_blank"><img title="WonderPanda" src="https://github.com/WonderPanda.png?size=48" width="48" height="48"></a><a href="https://github.com/arpitBhalla" target="_blank"><img title="arpitBhalla" src="https://github.com/arpitBhalla.png?size=48" width="48" height="48"></a></section><section id="users"><h2 id="excited-to-be-used-by">Excited to be used by:</h2><a href="https://github.com/Apocalypsor" target="_blank"><img title="Apocalypsor" src="https://github.com/Apocalypsor.png?size=48" width="48" height="48"></a><a href="https://github.com/brentvatne" target="_blank"><img title="brentvatne" src="https://github.com/brentvatne.png?size=48" width="48" height="48"></a><a href="https://github.com/byCedric" target="_blank"><img title="byCedric" src="https://github.com/byCedric.png?size=48" width="48" height="48"></a><a href="https://github.com/circadian-risk" target="_blank"><img title="circadian-risk" src="https://github.com/circadian-risk.png?size=48" width="48" height="48"></a><a href="https://github.com/cpojer" target="_blank"><img title="cpojer" src="https://github.com/cpojer.png?size=48" width="48" height="48"></a><a href="https://github.com/cubecull" target="_blank"><img title="cubecull" src="https://github.com/cubecull.png?size=48" width="48" height="48"></a><a href="https://github.com/erwinkn" target="_blank"><img title="erwinkn" src="https://github.com/erwinkn.png?size=48" width="48" height="48"></a><a href="https://github.com/expo" target="_blank"><img title="expo" src="https://github.com/expo.png?size=48" width="48" height="48"></a><a href="https://github.com/ezra-en" target="_blank"><img title="ezra-en" src="https://github.com/ezra-en.png?size=48" width="48" height="48"></a><a href="https://github.com/fdfontes" target="_blank"><img title="fdfontes" src="https://github.com/fdfontes.png?size=48" width="48" height="48"></a><a href="https://github.com/feychenie" target="_blank"><img title="feychenie" src="https://github.com/feychenie.png?size=48" width="48" height="48"></a><a href="https://github.com/flaming-codes" target="_blank"><img title="flaming-codes" src="https://github.com/flaming-codes.png?size=48" width="48" height="48"></a><a href="https://github.com/fostertheweb" target="_blank"><img title="fostertheweb" src="https://github.com/fostertheweb.png?size=48" width="48" height="48"></a><a href="https://github.com/generates" target="_blank"><img title="generates" src="https://github.com/generates.png?size=48" width="48" height="48"></a><a href="https://github.com/Giulio987" target="_blank"><img title="Giulio987" src="https://github.com/Giulio987.png?size=48" width="48" height="48"></a><a href="https://github.com/itsdevcoffee" target="_blank"><img title="itsdevcoffee" src="https://github.com/itsdevcoffee.png?size=48" width="48" height="48"></a><a href="https://github.com/jaysc" target="_blank"><img title="jaysc" src="https://github.com/jaysc.png?size=48" width="48" height="48"></a><a href="https://github.com/jbolda" target="_blank"><img title="jbolda" src="https://github.com/jbolda.png?size=48" width="48" height="48"></a><a href="https://github.com/Kayoo-asso" target="_blank"><img title="Kayoo-asso" src="https://github.com/Kayoo-asso.png?size=48" width="48" height="48"></a><a href="https://github.com/kotofurumiya" target="_blank"><img title="kotofurumiya" src="https://github.com/kotofurumiya.png?size=48" width="48" height="48"></a><a href="https://github.com/Kudo" target="_blank"><img title="Kudo" src="https://github.com/Kudo.png?size=48" width="48" height="48"></a><a href="https://github.com/learn-anything" target="_blank"><img title="learn-anything" src="https://github.com/learn-anything.png?size=48" width="48" height="48"></a><a href="https://github.com/lluc" target="_blank"><img title="lluc" src="https://github.com/lluc.png?size=48" width="48" height="48"></a><a href="https://github.com/marksteve" target="_blank"><img title="marksteve" src="https://github.com/marksteve.png?size=48" width="48" height="48"></a><a href="https://github.com/miking-the-viking" target="_blank"><img title="miking-the-viking" src="https://github.com/miking-the-viking.png?size=48" width="48" height="48"></a><a href="https://github.com/mjamesderocher" target="_blank"><img title="mjamesderocher" src="https://github.com/mjamesderocher.png?size=48" width="48" height="48"></a><a href="https://github.com/mouktardev" target="_blank"><img title="mouktardev" src="https://github.com/mouktardev.png?size=48" width="48" height="48"></a><a href="https://github.com/nickmessing" target="_blank"><img title="nickmessing" src="https://github.com/nickmessing.png?size=48" width="48" height="48"></a><a href="https://github.com/nikitavoloboev" target="_blank"><img title="nikitavoloboev" src="https://github.com/nikitavoloboev.png?size=48" width="48" height="48"></a><a href="https://github.com/nkzw-tech" target="_blank"><img title="nkzw-tech" src="https://github.com/nkzw-tech.png?size=48" width="48" height="48"></a><a href="https://github.com/palerdot" target="_blank"><img title="palerdot" src="https://github.com/palerdot.png?size=48" width="48" height="48"></a><a href="https://github.com/PorcoRosso85" target="_blank"><img title="PorcoRosso85" src="https://github.com/PorcoRosso85.png?size=48" width="48" height="48"></a><a href="https://github.com/primodiumxyz" target="_blank"><img title="primodiumxyz" src="https://github.com/primodiumxyz.png?size=48" width="48" height="48"></a><a href="https://github.com/shaneosullivan" target="_blank"><img title="shaneosullivan" src="https://github.com/shaneosullivan.png?size=48" width="48" height="48"></a><a href="https://github.com/sudo-self" target="_blank"><img title="sudo-self" src="https://github.com/sudo-self.png?size=48" width="48" height="48"></a><a href="https://github.com/SuperSonicHub1" target="_blank"><img title="SuperSonicHub1" src="https://github.com/SuperSonicHub1.png?size=48" width="48" height="48"></a><a href="https://github.com/threepointone" target="_blank"><img title="threepointone" src="https://github.com/threepointone.png?size=48" width="48" height="48"></a><a href="https://github.com/uptonking" target="_blank"><img title="uptonking" src="https://github.com/uptonking.png?size=48" width="48" height="48"></a><a href="https://github.com/ViktorZhurbin" target="_blank"><img title="ViktorZhurbin" src="https://github.com/ViktorZhurbin.png?size=48" width="48" height="48"></a><a href="https://github.com/WonderPanda" target="_blank"><img title="WonderPanda" src="https://github.com/WonderPanda.png?size=48" width="48" height="48"></a></section><hr><p><a class="start" href="https://beta.tinybase.org/guides/the-basics/getting-started/">Get started</a></p><p><a href="https://beta.tinybase.org/demos/">Try the demos</a></p><p><a href="https://beta.tinybase.org/api/store/interfaces/store/store/">Read the docs</a></p><hr><section id="about"><h2 id="about">About</h2><p>Modern apps deserve better. Why trade reactive user experiences to be able to use relational data? Or sacrifice features for bundle size? And why does the cloud do all the work <a href="https://localfirstweb.dev/" target="_blank">anyway</a>?</p><p>Building TinyBase was originally an interesting exercise for <a rel="me" href="https://tripleodeon.com">me</a> in API design, minification, and documentation. But now it has taken on a life of its own, and has grown beyond my wildest expectations.</p><p>It could not have been built without these great <a href="https://beta.tinybase.org/guides/how-tinybase-is-built/credits/#giants">projects</a> and <a href="https://beta.tinybase.org/guides/how-tinybase-is-built/credits/#and-friends">friends</a>, and I hope you enjoy using it as much as I do building it!</p></section><section id="story"><h2 id="the-story">The story</h2><a href="https://youtu.be/hXL7OkW-Prk?t=1232" target="_blank"><img src="https://beta.tinybase.org/youtube.webp"></a></section>
|
|
297
|
+
<section><h2 id="did-we-say-tiny">Did we say tiny?</h2><p>If you use the basic <a href="https://beta.tinybase.org/api/store/"><code>store</code></a> module alone, you'll only add a gzipped <em>5.3kB</em> to your app. Incrementally add the other modules as you need more functionality, or get it all for <em>11.4kB</em>.</p><p>The optional <a href="https://beta.tinybase.org/api/ui-react/"><code>ui-react</code></a> module is just <em>4.9kB</em>, the ui-react-dom components are another <em>2.6kB</em>, and everything is super fast. Life's easy when you have zero dependencies!</p><p>Read more about how TinyBase is structured and packaged in the <a href="https://beta.tinybase.org/guides/how-tinybase-is-built/architecture/">Architecture</a> guide.</p></section><div class="table"><table class="fixed"><tbody><tr><th> </th><th>Minified .js.gz</th><th>Source .js</th></tr><tr><th class="right"><a href="https://beta.tinybase.org/api/store/">tinybase/store</a> (minimal)</th><td>5.3kB</td><td>52.4kB</td></tr><tr><th class="right">tinybase (complete)</th><td>11.4kB</td><td>119.3kB</td></tr><tr><th class="right"><a href="https://beta.tinybase.org/api/ui-react/">ui-react</a></th><td>4.9kB</td><td>53.5kB</td></tr><tr><th class="right"><a href="https://beta.tinybase.org/api/ui-react-dom/">ui-react-dom</a></th><td>2.6kB</td><td>20.4kB</td></tr></tbody></table></div><section><h2 id="well-tested-and-documented">Well tested and documented.</h2><p>TinyBase has <em>100.0%</em> test coverage, including the code throughout the documentation - even on this page! The guides, demos, and API examples are designed to make it as easy as possible for you to get your TinyBase-powered app up and running.</p><p>Read more about how TinyBase is tested in the Unit <a href="https://beta.tinybase.org/guides/how-tinybase-is-built/testing/">Testing</a> guide.</p></section><div class="table"><table class="fixed"><tbody><tr><th width="30%"> </th><th>Total</th><th>Tested</th><th>Coverage</th></tr><tr><th class="right">Lines</th><td>2,286</td><td>2,286</td><td>100.0%</td></tr><tr><th class="right">Statements</th><td>2,468</td><td>2,468</td><td>100.0%</td></tr><tr><th class="right">Functions</th><td>986</td><td>986</td><td>100.0%</td></tr><tr><th class="right">Branches</th><td>854</td><td>854</td><td>100.0%</td></tr><tr><th class="right">Tests</th><td colspan="3">7,461</td></tr><tr><th class="right">Assertions</th><td colspan="3">33,189</td></tr></tbody></table></div><hr><section id="sponsors"><h2 id="proud-to-be-sponsored-by">Proud to be sponsored by:</h2><a href="https://github.com/cpojer" target="_blank"><img title="cpojer" src="https://github.com/cpojer.png?size=48" width="48" height="48"></a><a href="https://github.com/expo" target="_blank"><img title="expo" src="https://github.com/expo.png?size=48" width="48" height="48"></a><a href="https://github.com/beekeeb" target="_blank"><img title="beekeeb" src="https://github.com/beekeeb.png?size=48" width="48" height="48"></a><a href="https://github.com/cancelself" target="_blank"><img title="cancelself" src="https://github.com/cancelself.png?size=48" width="48" height="48"></a><a href="https://github.com/WonderPanda" target="_blank"><img title="WonderPanda" src="https://github.com/WonderPanda.png?size=48" width="48" height="48"></a><a href="https://github.com/arpitBhalla" target="_blank"><img title="arpitBhalla" src="https://github.com/arpitBhalla.png?size=48" width="48" height="48"></a></section><section id="users"><h2 id="excited-to-be-used-by">Excited to be used by:</h2><a href="https://github.com/Apocalypsor" target="_blank"><img title="Apocalypsor" src="https://github.com/Apocalypsor.png?size=48" width="48" height="48"></a><a href="https://github.com/brentvatne" target="_blank"><img title="brentvatne" src="https://github.com/brentvatne.png?size=48" width="48" height="48"></a><a href="https://github.com/byCedric" target="_blank"><img title="byCedric" src="https://github.com/byCedric.png?size=48" width="48" height="48"></a><a href="https://github.com/circadian-risk" target="_blank"><img title="circadian-risk" src="https://github.com/circadian-risk.png?size=48" width="48" height="48"></a><a href="https://github.com/cpojer" target="_blank"><img title="cpojer" src="https://github.com/cpojer.png?size=48" width="48" height="48"></a><a href="https://github.com/cubecull" target="_blank"><img title="cubecull" src="https://github.com/cubecull.png?size=48" width="48" height="48"></a><a href="https://github.com/erwinkn" target="_blank"><img title="erwinkn" src="https://github.com/erwinkn.png?size=48" width="48" height="48"></a><a href="https://github.com/expo" target="_blank"><img title="expo" src="https://github.com/expo.png?size=48" width="48" height="48"></a><a href="https://github.com/ezra-en" target="_blank"><img title="ezra-en" src="https://github.com/ezra-en.png?size=48" width="48" height="48"></a><a href="https://github.com/fdfontes" target="_blank"><img title="fdfontes" src="https://github.com/fdfontes.png?size=48" width="48" height="48"></a><a href="https://github.com/feychenie" target="_blank"><img title="feychenie" src="https://github.com/feychenie.png?size=48" width="48" height="48"></a><a href="https://github.com/flaming-codes" target="_blank"><img title="flaming-codes" src="https://github.com/flaming-codes.png?size=48" width="48" height="48"></a><a href="https://github.com/fostertheweb" target="_blank"><img title="fostertheweb" src="https://github.com/fostertheweb.png?size=48" width="48" height="48"></a><a href="https://github.com/generates" target="_blank"><img title="generates" src="https://github.com/generates.png?size=48" width="48" height="48"></a><a href="https://github.com/Giulio987" target="_blank"><img title="Giulio987" src="https://github.com/Giulio987.png?size=48" width="48" height="48"></a><a href="https://github.com/itsdevcoffee" target="_blank"><img title="itsdevcoffee" src="https://github.com/itsdevcoffee.png?size=48" width="48" height="48"></a><a href="https://github.com/jaysc" target="_blank"><img title="jaysc" src="https://github.com/jaysc.png?size=48" width="48" height="48"></a><a href="https://github.com/jbolda" target="_blank"><img title="jbolda" src="https://github.com/jbolda.png?size=48" width="48" height="48"></a><a href="https://github.com/Kayoo-asso" target="_blank"><img title="Kayoo-asso" src="https://github.com/Kayoo-asso.png?size=48" width="48" height="48"></a><a href="https://github.com/kotofurumiya" target="_blank"><img title="kotofurumiya" src="https://github.com/kotofurumiya.png?size=48" width="48" height="48"></a><a href="https://github.com/Kudo" target="_blank"><img title="Kudo" src="https://github.com/Kudo.png?size=48" width="48" height="48"></a><a href="https://github.com/learn-anything" target="_blank"><img title="learn-anything" src="https://github.com/learn-anything.png?size=48" width="48" height="48"></a><a href="https://github.com/lluc" target="_blank"><img title="lluc" src="https://github.com/lluc.png?size=48" width="48" height="48"></a><a href="https://github.com/marksteve" target="_blank"><img title="marksteve" src="https://github.com/marksteve.png?size=48" width="48" height="48"></a><a href="https://github.com/miking-the-viking" target="_blank"><img title="miking-the-viking" src="https://github.com/miking-the-viking.png?size=48" width="48" height="48"></a><a href="https://github.com/mjamesderocher" target="_blank"><img title="mjamesderocher" src="https://github.com/mjamesderocher.png?size=48" width="48" height="48"></a><a href="https://github.com/mouktardev" target="_blank"><img title="mouktardev" src="https://github.com/mouktardev.png?size=48" width="48" height="48"></a><a href="https://github.com/nickmessing" target="_blank"><img title="nickmessing" src="https://github.com/nickmessing.png?size=48" width="48" height="48"></a><a href="https://github.com/nikitavoloboev" target="_blank"><img title="nikitavoloboev" src="https://github.com/nikitavoloboev.png?size=48" width="48" height="48"></a><a href="https://github.com/nkzw-tech" target="_blank"><img title="nkzw-tech" src="https://github.com/nkzw-tech.png?size=48" width="48" height="48"></a><a href="https://github.com/palerdot" target="_blank"><img title="palerdot" src="https://github.com/palerdot.png?size=48" width="48" height="48"></a><a href="https://github.com/PorcoRosso85" target="_blank"><img title="PorcoRosso85" src="https://github.com/PorcoRosso85.png?size=48" width="48" height="48"></a><a href="https://github.com/primodiumxyz" target="_blank"><img title="primodiumxyz" src="https://github.com/primodiumxyz.png?size=48" width="48" height="48"></a><a href="https://github.com/shaneosullivan" target="_blank"><img title="shaneosullivan" src="https://github.com/shaneosullivan.png?size=48" width="48" height="48"></a><a href="https://github.com/sudo-self" target="_blank"><img title="sudo-self" src="https://github.com/sudo-self.png?size=48" width="48" height="48"></a><a href="https://github.com/SuperSonicHub1" target="_blank"><img title="SuperSonicHub1" src="https://github.com/SuperSonicHub1.png?size=48" width="48" height="48"></a><a href="https://github.com/threepointone" target="_blank"><img title="threepointone" src="https://github.com/threepointone.png?size=48" width="48" height="48"></a><a href="https://github.com/uptonking" target="_blank"><img title="uptonking" src="https://github.com/uptonking.png?size=48" width="48" height="48"></a><a href="https://github.com/ViktorZhurbin" target="_blank"><img title="ViktorZhurbin" src="https://github.com/ViktorZhurbin.png?size=48" width="48" height="48"></a><a href="https://github.com/WonderPanda" target="_blank"><img title="WonderPanda" src="https://github.com/WonderPanda.png?size=48" width="48" height="48"></a></section><hr><p><a class="start" href="https://beta.tinybase.org/guides/the-basics/getting-started/">Get started</a></p><p><a href="https://beta.tinybase.org/demos/">Try the demos</a></p><p><a href="https://beta.tinybase.org/api/store/interfaces/store/store/">Read the docs</a></p><hr><section id="about"><h2 id="about">About</h2><p>Modern apps deserve better. Why trade reactive user experiences to be able to use relational data? Or sacrifice features for bundle size? And why does the cloud do all the work <a href="https://localfirstweb.dev/" target="_blank">anyway</a>?</p><p>Building TinyBase was originally an interesting exercise for <a rel="me" href="https://tripleodeon.com">me</a> in API design, minification, and documentation. But now it has taken on a life of its own, and has grown beyond my wildest expectations.</p><p>It could not have been built without these great <a href="https://beta.tinybase.org/guides/how-tinybase-is-built/credits/#giants">projects</a> and <a href="https://beta.tinybase.org/guides/how-tinybase-is-built/credits/#and-friends">friends</a>, and I hope you enjoy using it as much as I do building it!</p></section><section id="story"><h2 id="the-story">The story</h2><a href="https://youtu.be/hXL7OkW-Prk?t=1232" target="_blank"><img src="https://beta.tinybase.org/youtube.webp"></a></section>
|
package/releases.md
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
<p>This is a reverse chronological list of the major <a href="https://beta.tinybase.org/">TinyBase</a> releases, with highlighted features.</p><h1 id="v5-4">v5.4</h1><p>This release contains
|
|
1
|
+
<p>This is a reverse chronological list of the major <a href="https://beta.tinybase.org/">TinyBase</a> releases, with highlighted features.</p><h1 id="v5-4">v5.4</h1><h2 id="durable-objects-synchronization">Durable Objects synchronization</h2><p>This release contains a new WebSocket synchronization server that runs on Cloudflare as a Durable Object. It's in the new <a href="https://beta.tinybase.org/api/synchronizer-ws-server-durable-object/"><code>synchronizer-ws-server-durable-object</code></a> module, and you use it by extending the <a href="https://beta.tinybase.org/api/synchronizer-ws-server-durable-object/classes/creation/wsserverdurableobject/"><code>WsServerDurableObject</code></a> class. Use the <a href="https://beta.tinybase.org/api/synchronizer-ws-server-durable-object/functions/creation/getwsserverdurableobjectfetch/"><code>getWsServerDurableObjectFetch</code></a> function for conveniently binding your Cloudflare Worker to your Durable Object:</p>
|
|
2
2
|
|
|
3
|
-
```
|
|
4
|
-
import {Id, IdAddedOrRemoved} from 'tinybase';
|
|
3
|
+
```js yolo
|
|
5
4
|
import {
|
|
6
|
-
getWsServerDurableObjectFetch,
|
|
7
5
|
WsServerDurableObject,
|
|
6
|
+
getWsServerDurableObjectFetch,
|
|
8
7
|
} from 'tinybase/synchronizers/synchronizer-ws-server-durable-object';
|
|
9
8
|
|
|
10
9
|
export class MyDurableObject extends WsServerDurableObject {}
|
|
@@ -20,7 +19,20 @@ name = "MyDurableObjects"
|
|
|
20
19
|
class_name = "MyDurableObject"
|
|
21
20
|
```
|
|
22
21
|
|
|
23
|
-
<p>With this you can now easily connect and synchronize clients using the <a href="https://beta.tinybase.org/api/synchronizer-ws-client/interfaces/synchronizer/wssynchronizer/"><code>WsSynchronizer</code></a> synchronizer. This implementation does not currently store the data between clients, but will soon!</p><p>This release also includes the new <a href="https://beta.tinybase.org/api/synchronizer-ws-server-simple/"><code>synchronizer-ws-server-simple</code></a> module that contains a simple server implementation called <a href="https://beta.tinybase.org/api/synchronizer-ws-server-simple/interfaces/server/wsserversimple/"><code>WsServerSimple</code></a>. Without the complications of listeners, persistence, or statistics, this is more suitable to be used as a reference implementation for other server environments.</p><h1 id="v5-3">v5.3</h1><p>This release is focussed on a few API improvements and quality-of-life changes. These include:</p><h2 id="react-ssr-support">React SSR support</h2><p>Thanks to contributor <a href="https://github.com/muhajirdev">Muhammad Muhajir</a> for ensuring that <a href="https://beta.tinybase.org/">TinyBase</a> runs in server-side rendering environments!</p><h2 id="in-the-persisters-module">In the <a href="https://beta.tinybase.org/api/persisters/"><code>persisters</code></a> module...</h2><p>All <a href="https://beta.tinybase.org/api/persisters/interfaces/persister/persister/"><code>Persister</code></a> objects now expose information about whether they are loading or saving. To access this <a href="https://beta.tinybase.org/api/persisters/enumerations/lifecycle/status/"><code>Status</code></a>, use:</p><ul><li>The <a href="https://beta.tinybase.org/api/persisters/interfaces/persister/persister/methods/lifecycle/getstatus/"><code>getStatus</code></a> method, which will return 0 when it is idle, 1 when it is loading, and 2 when it is saving.</li><li>The <a href="https://beta.tinybase.org/api/persisters/interfaces/persister/persister/methods/listener/addstatuslistener/"><code>addStatusListener</code></a> method, which lets you add a <a href="https://beta.tinybase.org/api/persisters/type-aliases/listener/statuslistener/"><code>StatusListener</code></a> function and which is called whenever the status changes.</li></ul><p>These make it possible to track background load and save activities, so that, for example, you can show a status-bar spinner of asynchronous persistence activity.</p><h2 id="in-the-synchronizers-module">In the <a href="https://beta.tinybase.org/api/synchronizers/"><code>synchronizers</code></a> module...</h2><p>Synchronizers are a sub-class of <a href="https://beta.tinybase.org/api/persisters/interfaces/persister/persister/"><code>Persister</code></a>, so all <a href="https://beta.tinybase.org/api/synchronizers/interfaces/synchronizer/synchronizer/"><code>Synchronizer</code></a> objects now also have:</p><ul><li>The <a href="https://beta.tinybase.org/api/persisters/interfaces/persister/persister/methods/lifecycle/getstatus/"><code>getStatus</code></a> method, which will return 0 when it is idle, 1 when it is 'loading' (ie inbound syncing), and 2 when it is 'saving' (ie outbound syncing).</li><li>The <a href="https://beta.tinybase.org/api/persisters/interfaces/persister/persister/methods/listener/addstatuslistener/"><code>addStatusListener</code></a> method, which lets you add a <a href="https://beta.tinybase.org/api/persisters/type-aliases/listener/statuslistener/"><code>StatusListener</code></a> function and which is called whenever the status changes.</li></ul><h2 id="in-the-ui-react-module">In the <a href="https://beta.tinybase.org/api/ui-react/"><code>ui-react</code></a> module...</h2><p>There are corresponding hooks so that you can build these status changes into a React UI easily:</p><ul><li>The <a href="https://beta.tinybase.org/api/ui-react/functions/persister-hooks/usepersisterstatus/"><code>usePersisterStatus</code></a> hook, which will return the status for an explicitly provided, or context-derived <a href="https://beta.tinybase.org/api/persisters/interfaces/persister/persister/"><code>Persister</code></a>.</li><li>The <a href="https://beta.tinybase.org/api/ui-react/functions/persister-hooks/usepersisterstatuslistener/"><code>usePersisterStatusListener</code></a> hook, which lets you add your own <a href="https://beta.tinybase.org/api/persisters/type-aliases/listener/statuslistener/"><code>StatusListener</code></a> function to a <a href="https://beta.tinybase.org/api/persisters/interfaces/persister/persister/"><code>Persister</code></a>.</li><li>The <a href="https://beta.tinybase.org/api/ui-react/functions/persister-hooks/usepersister/"><code>usePersister</code></a> hook, which lets you get direct access to a <a href="https://beta.tinybase.org/api/persisters/interfaces/persister/persister/"><code>Persister</code></a> from within your UI.</li></ul><p>And correspondingly for Synchronizers:</p><ul><li>The <a href="https://beta.tinybase.org/api/ui-react/functions/synchronizer-hooks/usesynchronizerstatus/"><code>useSynchronizerStatus</code></a> hook, which will return the status for an explicitly provided, or context-derived <a href="https://beta.tinybase.org/api/synchronizers/interfaces/synchronizer/synchronizer/"><code>Synchronizer</code></a>.</li><li>The <a href="https://beta.tinybase.org/api/ui-react/functions/synchronizer-hooks/usesynchronizerstatuslistener/"><code>useSynchronizerStatusListener</code></a> hook, which lets you add your own <a href="https://beta.tinybase.org/api/persisters/type-aliases/listener/statuslistener/"><code>StatusListener</code></a> function to a <a href="https://beta.tinybase.org/api/synchronizers/interfaces/synchronizer/synchronizer/"><code>Synchronizer</code></a>.</li><li>The <a href="https://beta.tinybase.org/api/ui-react/functions/synchronizer-hooks/usesynchronizer/"><code>useSynchronizer</code></a> hook, which lets you get direct access to a <a href="https://beta.tinybase.org/api/synchronizers/interfaces/synchronizer/synchronizer/"><code>Synchronizer</code></a> from within your UI.</li></ul><p>In addition, this module also now includes hooks for injecting objects into the Provider context scope imperatively, much like the existing <a href="https://beta.tinybase.org/api/ui-react/functions/store-hooks/useprovidestore/"><code>useProvideStore</code></a> hook:</p><ul><li>The <a href="https://beta.tinybase.org/api/ui-react/functions/metrics-hooks/useprovidemetrics/"><code>useProvideMetrics</code></a> hook, which lets you imperatively register <a href="https://beta.tinybase.org/api/metrics/interfaces/metrics/metrics/"><code>Metrics</code></a> objects.</li><li>The <a href="https://beta.tinybase.org/api/ui-react/functions/other/useprovideindexes/"><code>useProvideIndexes</code></a> hook, which lets you register <a href="https://beta.tinybase.org/api/indexes/interfaces/indexes/indexes/"><code>Indexes</code></a> objects.</li><li>The <a href="https://beta.tinybase.org/api/ui-react/functions/other/useproviderelationships/"><code>useProvideRelationships</code></a> hook, which lets you register <a href="https://beta.tinybase.org/api/relationships/interfaces/relationships/relationships/"><code>Relationships</code></a> objects.</li><li>The <a href="https://beta.tinybase.org/api/ui-react/functions/other/useprovidequeries/"><code>useProvideQueries</code></a> hook, which lets you register <a href="https://beta.tinybase.org/api/queries/interfaces/queries/queries/"><code>Queries</code></a> objects.</li><li>The <a href="https://beta.tinybase.org/api/ui-react/functions/other/useprovidecheckpoints/"><code>useProvideCheckpoints</code></a> hook, which lets you register <a href="https://beta.tinybase.org/api/checkpoints/interfaces/checkpoints/checkpoints/"><code>Checkpoints</code></a> objects.</li><li>The <a href="https://beta.tinybase.org/api/ui-react/functions/other/useprovidepersister/"><code>useProvidePersister</code></a> hook, which lets you register <a href="https://beta.tinybase.org/api/persisters/interfaces/persister/persister/"><code>Persister</code></a> objects.</li><li>The <a href="https://beta.tinybase.org/api/ui-react/functions/other/useprovidesynchronizer/"><code>useProvideSynchronizer</code></a> hook, which lets you register <a href="https://beta.tinybase.org/api/synchronizers/interfaces/synchronizer/synchronizer/"><code>Synchronizer</code></a> objects.</li></ul><p>All of these new methods have extensive documentation, each with examples to show how to use them.</p><p>Please provide feedback on this new release on GitHub!</p><h1 id="v5-2">v5.2</h1><p>This release introduces new Persisters for... PostgreSQL! <a href="https://beta.tinybase.org/">TinyBase</a> now has two new <a href="https://beta.tinybase.org/api/persisters/interfaces/persister/persister/"><code>Persister</code></a> modules:</p><ul><li>The <a href="https://beta.tinybase.org/api/persister-postgres/"><code>persister-postgres</code></a> module provides the <a href="https://beta.tinybase.org/api/persister-postgres/interfaces/persister/postgrespersister/"><code>PostgresPersister</code></a>, which uses the excellent <a href="https://github.com/porsager/postgres"><code>postgres</code></a> module to bind to regular PostgreSQL databases, generally on a server.</li><li>The <a href="https://beta.tinybase.org/api/persister-pglite/"><code>persister-pglite</code></a> module provides the <a href="https://beta.tinybase.org/api/persister-pglite/interfaces/persister/pglitepersister/"><code>PglitePersister</code></a>, which uses the new and exciting <a href="https://github.com/electric-sql/pglite"><code>pglite</code></a> module for running PostgreSQL... in a browser!</li></ul><p>Conceptually, things behave in the same way as they do for the various SQLite persisters. Simply use the <a href="https://beta.tinybase.org/api/persister-postgres/functions/creation/createpostgrespersister/"><code>createPostgresPersister</code></a> function (or the similar <a href="https://beta.tinybase.org/api/persister-pglite/functions/creation/createpglitepersister/"><code>createPglitePersister</code></a> function) to persist your <a href="https://beta.tinybase.org/">TinyBase</a> data:</p>
|
|
22
|
+
<p>With this you can now easily connect and synchronize clients that are using the <a href="https://beta.tinybase.org/api/synchronizer-ws-client/interfaces/synchronizer/wssynchronizer/"><code>WsSynchronizer</code></a> synchronizer.</p><h2 id="durable-objects-persistence">Durable Objects persistence</h2><p>But wait! there's more. Durable Objects also provide a storage mechanism, and sometimes you want <a href="https://beta.tinybase.org/">TinyBase</a> data to also be stored on the server (in case all the current clients disconnect and a new one joins, for example). So this release of <a href="https://beta.tinybase.org/">TinyBase</a> also includes a dedicated persister, the <a href="https://beta.tinybase.org/api/persister-durable-object-storage/interfaces/persister/durableobjectstoragepersister/"><code>DurableObjectStoragePersister</code></a>, that also synchronizes the data to the Durable Object storage layer.</p><p>You create it with the <a href="https://beta.tinybase.org/api/persister-durable-object-storage/functions/creation/createdurableobjectstoragepersister/"><code>createDurableObjectStoragePersister</code></a> function, and hook it into the Durable Object by returning it from the <a href="https://beta.tinybase.org/api/synchronizer-ws-server-durable-object/classes/creation/wsserverdurableobject/methods/creation/createpersister/"><code>createPersister</code></a> method of your <a href="https://beta.tinybase.org/api/synchronizer-ws-server-durable-object/classes/creation/wsserverdurableobject/"><code>WsServerDurableObject</code></a>:</p>
|
|
23
|
+
|
|
24
|
+
```js yolo
|
|
25
|
+
export class MyDurableObject extends WsServerDurableObject {
|
|
26
|
+
createPersister() {
|
|
27
|
+
return createDurableObjectStoragePersister(
|
|
28
|
+
createMergeableStore(),
|
|
29
|
+
this.ctx.storage,
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
<p>You can get started quickly with this architecture using the <a href="https://github.com/tinyplex/vite-tinybase-ts-react-sync-durable-object">new Vite template</a> that accompanies this release.</p><h2 id="server-reference-implementation">Server reference implementation</h2><p>Unrelated to Durable Objects, this release also includes the new <a href="https://beta.tinybase.org/api/synchronizer-ws-server-simple/"><code>synchronizer-ws-server-simple</code></a> module that contains a simple server implementation called <a href="https://beta.tinybase.org/api/synchronizer-ws-server-simple/interfaces/server/wsserversimple/"><code>WsServerSimple</code></a>. Without the complications of listeners, persistence, or statistics, this is more suitable to be used as a reference implementation for other server environments.</p><h1 id="v5-3">v5.3</h1><p>This release is focussed on a few API improvements and quality-of-life changes. These include:</p><h2 id="react-ssr-support">React SSR support</h2><p>Thanks to contributor <a href="https://github.com/muhajirdev">Muhammad Muhajir</a> for ensuring that <a href="https://beta.tinybase.org/">TinyBase</a> runs in server-side rendering environments!</p><h2 id="in-the-persisters-module">In the <a href="https://beta.tinybase.org/api/persisters/"><code>persisters</code></a> module...</h2><p>All <a href="https://beta.tinybase.org/api/persisters/interfaces/persister/persister/"><code>Persister</code></a> objects now expose information about whether they are loading or saving. To access this <a href="https://beta.tinybase.org/api/persisters/enumerations/lifecycle/status/"><code>Status</code></a>, use:</p><ul><li>The <a href="https://beta.tinybase.org/api/persisters/interfaces/persister/persister/methods/lifecycle/getstatus/"><code>getStatus</code></a> method, which will return 0 when it is idle, 1 when it is loading, and 2 when it is saving.</li><li>The <a href="https://beta.tinybase.org/api/persisters/interfaces/persister/persister/methods/listener/addstatuslistener/"><code>addStatusListener</code></a> method, which lets you add a <a href="https://beta.tinybase.org/api/persisters/type-aliases/listener/statuslistener/"><code>StatusListener</code></a> function and which is called whenever the status changes.</li></ul><p>These make it possible to track background load and save activities, so that, for example, you can show a status-bar spinner of asynchronous persistence activity.</p><h2 id="in-the-synchronizers-module">In the <a href="https://beta.tinybase.org/api/synchronizers/"><code>synchronizers</code></a> module...</h2><p>Synchronizers are a sub-class of <a href="https://beta.tinybase.org/api/persisters/interfaces/persister/persister/"><code>Persister</code></a>, so all <a href="https://beta.tinybase.org/api/synchronizers/interfaces/synchronizer/synchronizer/"><code>Synchronizer</code></a> objects now also have:</p><ul><li>The <a href="https://beta.tinybase.org/api/persisters/interfaces/persister/persister/methods/lifecycle/getstatus/"><code>getStatus</code></a> method, which will return 0 when it is idle, 1 when it is 'loading' (ie inbound syncing), and 2 when it is 'saving' (ie outbound syncing).</li><li>The <a href="https://beta.tinybase.org/api/persisters/interfaces/persister/persister/methods/listener/addstatuslistener/"><code>addStatusListener</code></a> method, which lets you add a <a href="https://beta.tinybase.org/api/persisters/type-aliases/listener/statuslistener/"><code>StatusListener</code></a> function and which is called whenever the status changes.</li></ul><h2 id="in-the-ui-react-module">In the <a href="https://beta.tinybase.org/api/ui-react/"><code>ui-react</code></a> module...</h2><p>There are corresponding hooks so that you can build these status changes into a React UI easily:</p><ul><li>The <a href="https://beta.tinybase.org/api/ui-react/functions/persister-hooks/usepersisterstatus/"><code>usePersisterStatus</code></a> hook, which will return the status for an explicitly provided, or context-derived <a href="https://beta.tinybase.org/api/persisters/interfaces/persister/persister/"><code>Persister</code></a>.</li><li>The <a href="https://beta.tinybase.org/api/ui-react/functions/persister-hooks/usepersisterstatuslistener/"><code>usePersisterStatusListener</code></a> hook, which lets you add your own <a href="https://beta.tinybase.org/api/persisters/type-aliases/listener/statuslistener/"><code>StatusListener</code></a> function to a <a href="https://beta.tinybase.org/api/persisters/interfaces/persister/persister/"><code>Persister</code></a>.</li><li>The <a href="https://beta.tinybase.org/api/ui-react/functions/persister-hooks/usepersister/"><code>usePersister</code></a> hook, which lets you get direct access to a <a href="https://beta.tinybase.org/api/persisters/interfaces/persister/persister/"><code>Persister</code></a> from within your UI.</li></ul><p>And correspondingly for Synchronizers:</p><ul><li>The <a href="https://beta.tinybase.org/api/ui-react/functions/synchronizer-hooks/usesynchronizerstatus/"><code>useSynchronizerStatus</code></a> hook, which will return the status for an explicitly provided, or context-derived <a href="https://beta.tinybase.org/api/synchronizers/interfaces/synchronizer/synchronizer/"><code>Synchronizer</code></a>.</li><li>The <a href="https://beta.tinybase.org/api/ui-react/functions/synchronizer-hooks/usesynchronizerstatuslistener/"><code>useSynchronizerStatusListener</code></a> hook, which lets you add your own <a href="https://beta.tinybase.org/api/persisters/type-aliases/listener/statuslistener/"><code>StatusListener</code></a> function to a <a href="https://beta.tinybase.org/api/synchronizers/interfaces/synchronizer/synchronizer/"><code>Synchronizer</code></a>.</li><li>The <a href="https://beta.tinybase.org/api/ui-react/functions/synchronizer-hooks/usesynchronizer/"><code>useSynchronizer</code></a> hook, which lets you get direct access to a <a href="https://beta.tinybase.org/api/synchronizers/interfaces/synchronizer/synchronizer/"><code>Synchronizer</code></a> from within your UI.</li></ul><p>In addition, this module also now includes hooks for injecting objects into the Provider context scope imperatively, much like the existing <a href="https://beta.tinybase.org/api/ui-react/functions/store-hooks/useprovidestore/"><code>useProvideStore</code></a> hook:</p><ul><li>The <a href="https://beta.tinybase.org/api/ui-react/functions/metrics-hooks/useprovidemetrics/"><code>useProvideMetrics</code></a> hook, which lets you imperatively register <a href="https://beta.tinybase.org/api/metrics/interfaces/metrics/metrics/"><code>Metrics</code></a> objects.</li><li>The <a href="https://beta.tinybase.org/api/ui-react/functions/other/useprovideindexes/"><code>useProvideIndexes</code></a> hook, which lets you register <a href="https://beta.tinybase.org/api/indexes/interfaces/indexes/indexes/"><code>Indexes</code></a> objects.</li><li>The <a href="https://beta.tinybase.org/api/ui-react/functions/other/useproviderelationships/"><code>useProvideRelationships</code></a> hook, which lets you register <a href="https://beta.tinybase.org/api/relationships/interfaces/relationships/relationships/"><code>Relationships</code></a> objects.</li><li>The <a href="https://beta.tinybase.org/api/ui-react/functions/other/useprovidequeries/"><code>useProvideQueries</code></a> hook, which lets you register <a href="https://beta.tinybase.org/api/queries/interfaces/queries/queries/"><code>Queries</code></a> objects.</li><li>The <a href="https://beta.tinybase.org/api/ui-react/functions/other/useprovidecheckpoints/"><code>useProvideCheckpoints</code></a> hook, which lets you register <a href="https://beta.tinybase.org/api/checkpoints/interfaces/checkpoints/checkpoints/"><code>Checkpoints</code></a> objects.</li><li>The <a href="https://beta.tinybase.org/api/ui-react/functions/other/useprovidepersister/"><code>useProvidePersister</code></a> hook, which lets you register <a href="https://beta.tinybase.org/api/persisters/interfaces/persister/persister/"><code>Persister</code></a> objects.</li><li>The <a href="https://beta.tinybase.org/api/ui-react/functions/other/useprovidesynchronizer/"><code>useProvideSynchronizer</code></a> hook, which lets you register <a href="https://beta.tinybase.org/api/synchronizers/interfaces/synchronizer/synchronizer/"><code>Synchronizer</code></a> objects.</li></ul><p>All of these new methods have extensive documentation, each with examples to show how to use them.</p><p>Please provide feedback on this new release on GitHub!</p><h1 id="v5-2">v5.2</h1><p>This release introduces new Persisters for... PostgreSQL! <a href="https://beta.tinybase.org/">TinyBase</a> now has two new <a href="https://beta.tinybase.org/api/persisters/interfaces/persister/persister/"><code>Persister</code></a> modules:</p><ul><li>The <a href="https://beta.tinybase.org/api/persister-postgres/"><code>persister-postgres</code></a> module provides the <a href="https://beta.tinybase.org/api/persister-postgres/interfaces/persister/postgrespersister/"><code>PostgresPersister</code></a>, which uses the excellent <a href="https://github.com/porsager/postgres"><code>postgres</code></a> module to bind to regular PostgreSQL databases, generally on a server.</li><li>The <a href="https://beta.tinybase.org/api/persister-pglite/"><code>persister-pglite</code></a> module provides the <a href="https://beta.tinybase.org/api/persister-pglite/interfaces/persister/pglitepersister/"><code>PglitePersister</code></a>, which uses the new and exciting <a href="https://github.com/electric-sql/pglite"><code>pglite</code></a> module for running PostgreSQL... in a browser!</li></ul><p>Conceptually, things behave in the same way as they do for the various SQLite persisters. Simply use the <a href="https://beta.tinybase.org/api/persister-postgres/functions/creation/createpostgrespersister/"><code>createPostgresPersister</code></a> function (or the similar <a href="https://beta.tinybase.org/api/persister-pglite/functions/creation/createpglitepersister/"><code>createPglitePersister</code></a> function) to persist your <a href="https://beta.tinybase.org/">TinyBase</a> data:</p>
|
|
24
36
|
|
|
25
37
|
```js
|
|
26
38
|
import postgres from 'postgres';
|
|
@@ -750,7 +750,7 @@ class WsServerDurableObject extends DurableObject {
|
|
|
750
750
|
this.onMessage(fromClientId, toClientId, remainder);
|
|
751
751
|
if (toClientId == EMPTY_STRING) {
|
|
752
752
|
if (fromClientId != SERVER_CLIENT_ID) {
|
|
753
|
-
this.#serverClientSend(forwardedPayload);
|
|
753
|
+
this.#serverClientSend?.(forwardedPayload);
|
|
754
754
|
}
|
|
755
755
|
arrayForEach(this.#getClients(), (otherClient) => {
|
|
756
756
|
if (otherClient != fromClient) {
|
|
@@ -758,7 +758,7 @@ class WsServerDurableObject extends DurableObject {
|
|
|
758
758
|
}
|
|
759
759
|
});
|
|
760
760
|
} else if (toClientId == SERVER_CLIENT_ID) {
|
|
761
|
-
this.#serverClientSend(forwardedPayload);
|
|
761
|
+
this.#serverClientSend?.(forwardedPayload);
|
|
762
762
|
} else if (toClientId != fromClientId) {
|
|
763
763
|
this.#getClients(toClientId)[0]?.send(forwardedPayload);
|
|
764
764
|
}
|
|
@@ -774,7 +774,7 @@ class WsServerDurableObject extends DurableObject {
|
|
|
774
774
|
getPathId() {
|
|
775
775
|
return this.ctx.getTags(this.#getClients()[0])?.[1];
|
|
776
776
|
}
|
|
777
|
-
getClientIds(
|
|
777
|
+
getClientIds() {
|
|
778
778
|
return arrayMap(
|
|
779
779
|
this.#getClients(),
|
|
780
780
|
(client) => this.ctx.getTags(client)[0],
|
|
@@ -750,7 +750,7 @@ class WsServerDurableObject extends DurableObject {
|
|
|
750
750
|
this.onMessage(fromClientId, toClientId, remainder);
|
|
751
751
|
if (toClientId == EMPTY_STRING) {
|
|
752
752
|
if (fromClientId != SERVER_CLIENT_ID) {
|
|
753
|
-
this.#serverClientSend(forwardedPayload);
|
|
753
|
+
this.#serverClientSend?.(forwardedPayload);
|
|
754
754
|
}
|
|
755
755
|
arrayForEach(this.#getClients(), (otherClient) => {
|
|
756
756
|
if (otherClient != fromClient) {
|
|
@@ -758,7 +758,7 @@ class WsServerDurableObject extends DurableObject {
|
|
|
758
758
|
}
|
|
759
759
|
});
|
|
760
760
|
} else if (toClientId == SERVER_CLIENT_ID) {
|
|
761
|
-
this.#serverClientSend(forwardedPayload);
|
|
761
|
+
this.#serverClientSend?.(forwardedPayload);
|
|
762
762
|
} else if (toClientId != fromClientId) {
|
|
763
763
|
this.#getClients(toClientId)[0]?.send(forwardedPayload);
|
|
764
764
|
}
|
|
@@ -774,7 +774,7 @@ class WsServerDurableObject extends DurableObject {
|
|
|
774
774
|
getPathId() {
|
|
775
775
|
return this.ctx.getTags(this.#getClients()[0])?.[1];
|
|
776
776
|
}
|
|
777
|
-
getClientIds(
|
|
777
|
+
getClientIds() {
|
|
778
778
|
return arrayMap(
|
|
779
779
|
this.#getClients(),
|
|
780
780
|
(client) => this.ctx.getTags(client)[0],
|