tinybase 8.1.0-beta.3 → 8.1.0-beta.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/@types/ui-svelte/index.d.ts +556 -581
- package/@types/ui-svelte/with-schemas/index.d.ts +560 -597
- package/min/omni/index.js +1 -1
- package/min/omni/index.js.gz +0 -0
- package/min/omni/with-schemas/index.js +1 -1
- package/min/omni/with-schemas/index.js.gz +0 -0
- package/min/persisters/persister-remote/index.js +1 -1
- package/min/persisters/persister-remote/index.js.gz +0 -0
- package/min/persisters/persister-remote/with-schemas/index.js +1 -1
- package/min/persisters/persister-remote/with-schemas/index.js.gz +0 -0
- package/min/ui-svelte/index.js +1 -1
- package/min/ui-svelte/index.js.gz +0 -0
- package/min/ui-svelte/with-schemas/index.js +1 -1
- package/min/ui-svelte/with-schemas/index.js.gz +0 -0
- package/omni/index.js +7 -9
- package/omni/with-schemas/index.js +7 -9
- package/package.json +17 -17
- package/persisters/persister-remote/index.js +7 -9
- package/persisters/persister-remote/with-schemas/index.js +7 -9
- package/readme.md +1 -1
- package/ui-svelte/index.js +550 -598
- package/ui-svelte/with-schemas/index.js +550 -598
|
@@ -1 +1 @@
|
|
|
1
|
-
import"svelte/internal/disclose-version";import*as e from"svelte/internal/client";import{getContext as t,setContext as r,untrack as n}from"svelte";const d=e=>typeof e,s=d(""),u=d(d),o="Listener",i="Result",g="Has",c="Ids",p="Table",a=p+"s",l=p+c,I="Row",f=I+"Count",b=I+c,h="Sorted"+I+c,m="Cell",v=m+c,w="Value",y=w+"s",x=w+c,_="Transaction",$="Finish",k="Status",q="Metric",C="Slice",R="RemoteRowId",L="Local",T="Linked",V="Checkpoint",B=e=>void 0===e,S=(z=B,(e,t,r)=>z(e)?r?.():t(e));var z;const F=Object.keys,P="tinybase_uisc",j=[],A={},D=[j,void 0,j],H=e=>(e=>d(e)==u)(e)?e():e,M=()=>t(P)??[],O=(e,t,r)=>{return B(t)?e[2*r]:d(t)==s?(n=e[2*r+1],u=t,S(n,e=>e[u])):t;var n,u},Q=(e,t)=>O(M(),e,t),W=(e,t)=>{const r=M();return()=>O(r,H(e),t)},E=(e,t)=>F(e[2*t+1]??A),G=e=>W(e,0),J=e=>W(e,1),K=e=>W(e,2),N=e=>W(e,3),U=e=>W(e,4),X=e=>W(e,5),Y=e=>W(e,6),Z=e=>W(e,7),ee=(t,r,n,d=()=>j,s)=>{const u=(s?"has":"get")+r,i="add"+(s?g:"")+r+o;let c=e.state(e.proxy(t()?.[u]?.(...d())??n));return"undefined"!=typeof window&&e.user_effect(()=>{const r=t(),s=d();e.set(c,r?.[u]?.(...s)??n,!0);const o=r?.[i]?.(...s,()=>{e.set(c,r[u](...d())??n,!0)});return()=>r?.delListener?.(o)}),{get current(){return e.get(c)}}},te=(t,r,n,d=()=>j,s)=>{"undefined"!=typeof window&&e.user_effect(()=>{const e=t(),u=d(),i=e?.["add"+r+o]?.(...u,n,...void 0!==s?[s]:j);return()=>e?.delListener?.(i)})},re=e=>ee(G(e),a,!1,()=>j,1),ne=e=>ee(G(e),a,A),de=e=>ee(G(e),l,j),se=(e,t)=>ee(G(t),p,!1,()=>[H(e)],1),ue=(e,t)=>ee(G(t),p,A,()=>[H(e)]),oe=(e,t)=>ee(G(t),p+v,j,()=>[H(e)]),ie=(e,t,r)=>ee(G(r),p+m,!1,()=>[H(e),H(t)],1),ge=(e,t)=>ee(G(t),f,0,()=>[H(e)]),ce=(e,t)=>ee(G(t),b,j,()=>[H(e)]),pe=(e,t,r=!1,n=0,d,s)=>ee(G(s),h,j,()=>[H(e),H(t),H(r),H(n),H(d)]),ae=(e,t,r)=>ee(G(r),I,!1,()=>[H(e),H(t)],1),le=(e,t,r)=>ee(G(r),I,A,()=>[H(e),H(t)]),Ie=(e,t,r)=>ee(G(r),v,j,()=>[H(e),H(t)]),fe=(e,t,r,n)=>ee(G(n),m,!1,()=>[H(e),H(t),H(r)],1),be=(e,t,r,n)=>ee(G(n),m,void 0,()=>[H(e),H(t),H(r)]),he=(t,r,n,d)=>{const s=G(d);let u=e.state(e.proxy(s()?.getCell(H(t),H(r),H(n))));return"undefined"!=typeof window&&e.user_effect(()=>{const d=s(),o=H(t),i=H(r),g=H(n);e.set(u,d?.getCell(o,i,g),!0);const c=d?.addCellListener(o,i,g,d=>{e.set(u,d.getCell(H(t),H(r),H(n)),!0)});return()=>d?.delListener?.(c)}),{get current(){return e.get(u)},set current(e){s()?.setCell(H(t),H(r),H(n),e)}}},me=e=>ee(G(e),y,!1,()=>j,1),ve=e=>ee(G(e),y,A),we=e=>ee(G(e),x,j),ye=(e,t)=>ee(G(t),w,!1,()=>[H(e)],1),xe=(e,t)=>ee(G(t),w,void 0,()=>[H(e)]),_e=(t,r)=>{const n=G(r);let d=e.state(e.proxy(n()?.getValue(H(t))));return"undefined"!=typeof window&&e.user_effect(()=>{const r=n(),s=H(t);e.set(d,r?.getValue(s),!0);const u=r?.addValueListener(s,r=>{e.set(d,r.getValue(H(t)),!0)});return()=>r?.delListener?.(u)}),{get current(){return e.get(d)},set current(e){n()?.setValue(H(t),e)}}},$e=e=>Q(e,0),ke=()=>{const t=M();let r=e.state(e.proxy(E(t,0)));return"undefined"!=typeof window&&e.user_effect(()=>{e.set(r,E(t,0),!0)}),{get current(){return e.get(r)}}},qe=e=>Q(e,1),Ce=()=>{const t=M();let r=e.state(e.proxy(E(t,1)));return"undefined"!=typeof window&&e.user_effect(()=>{e.set(r,E(t,1),!0)}),{get current(){return e.get(r)}}},Re=e=>ee(J(e),q+c,j),Le=(e,t)=>ee(J(t),q,void 0,()=>[H(e)]),Te=e=>Q(e,2),Ve=()=>{const t=M();let r=e.state(e.proxy(E(t,2)));return"undefined"!=typeof window&&e.user_effect(()=>{e.set(r,E(t,2),!0)}),{get current(){return e.get(r)}}},Be=e=>ee(K(e),"Index"+c,j),Se=(e,t)=>ee(K(t),C+c,j,()=>[H(e)]),ze=(e,t,r)=>ee(K(r),C+b,j,()=>[H(e),H(t)]),Fe=(e,t)=>{const r=K(e);return{get store(){return r()?.getStore()},get tableId(){return r()?.getTableId(H(t))}}},Pe=e=>Q(e,4),je=()=>{const t=M();let r=e.state(e.proxy(E(t,4)));return"undefined"!=typeof window&&e.user_effect(()=>{e.set(r,E(t,4),!0)}),{get current(){return e.get(r)}}},Ae=e=>ee(U(e),"Query"+c,j),De=(e,t)=>ee(U(t),i+p,A,()=>[H(e)]),He=(e,t)=>ee(U(t),i+p+v,j,()=>[H(e)]),Me=(e,t)=>ee(U(t),i+f,0,()=>[H(e)]),Oe=(e,t)=>ee(U(t),i+b,j,()=>[H(e)]),Qe=(e,t,r=!1,n=0,d,s)=>ee(U(s),i+h,j,()=>[H(e),H(t),H(r),H(n),H(d)]),We=(e,t,r)=>ee(U(r),i+I,A,()=>[H(e),H(t)]),Ee=(e,t,r)=>ee(U(r),i+v,j,()=>[H(e),H(t)]),Ge=(e,t,r,n)=>ee(U(n),i+m,void 0,()=>[H(e),H(t),H(r)]),Je=e=>Q(e,3),Ke=()=>{const t=M();let r=e.state(e.proxy(E(t,3)));return"undefined"!=typeof window&&e.user_effect(()=>{e.set(r,E(t,3),!0)}),{get current(){return e.get(r)}}},Ne=e=>ee(N(e),"Relationship"+c,j),Ue=(e,t,r)=>ee(N(r),R,void 0,()=>[H(e),H(t)]),Xe=(e,t,r)=>ee(N(r),L+b,j,()=>[H(e),H(t)]),Ye=(e,t,r)=>ee(N(r),T+b,j,()=>[H(e),H(t)]),Ze=(e,t)=>{const r=N(e);return{get store(){return r()?.getStore()},get localTableId(){return r()?.getLocalTableId(H(t))},get remoteTableId(){return r()?.getRemoteTableId(H(t))}}},et=e=>Q(e,5),tt=()=>{const t=M();let r=e.state(e.proxy(E(t,5)));return"undefined"!=typeof window&&e.user_effect(()=>{e.set(r,E(t,5),!0)}),{get current(){return e.get(r)}}},rt=e=>ee(X(e),V+c,D),nt=(e,t)=>ee(X(t),V,void 0,()=>[H(e)]),dt=e=>{const t=X(e);return()=>t()?.goBackward()},st=e=>{const t=X(e);return()=>t()?.goForward()},ut=e=>Q(e,6),ot=()=>{const t=M();let r=e.state(e.proxy(E(t,6)));return"undefined"!=typeof window&&e.user_effect(()=>{e.set(r,E(t,6),!0)}),{get current(){return e.get(r)}}},it=e=>ee(Y(e),k,0),gt=e=>Q(e,7),ct=()=>{const t=M();let r=e.state(e.proxy(E(t,7)));return"undefined"!=typeof window&&e.user_effect(()=>{e.set(r,E(t,7),!0)}),{get current(){return e.get(r)}}},pt=e=>ee(Z(e),k,0),at=(e,t,r)=>te(G(r),g+a,e,()=>j,t),lt=(e,t,r)=>te(G(r),a,e,()=>j,t),It=(e,t,r)=>te(G(r),l,e,()=>j,t),ft=(e,t,r,n)=>te(G(n),g+p,t,()=>[H(e)],r),bt=(e,t,r,n)=>te(G(n),p,t,()=>[H(e)],r),ht=(e,t,r,n)=>te(G(n),p+v,t,()=>[H(e)],r),mt=(e,t,r,n,d)=>te(G(d),g+p+m,r,()=>[H(e),H(t)],n),vt=(e,t,r,n)=>te(G(n),f,t,()=>[H(e)],r),wt=(e,t,r,n)=>te(G(n),b,t,()=>[H(e)],r),yt=(e,t,r,n,d,s,u,o)=>te(G(o),h,s,()=>[H(e),H(t),H(r),H(n),H(d)],u),xt=(e,t,r,n,d)=>te(G(d),g+I,r,()=>[H(e),H(t)],n),_t=(e,t,r,n,d)=>te(G(d),I,r,()=>[H(e),H(t)],n),$t=(e,t,r,n,d)=>te(G(d),v,r,()=>[H(e),H(t)],n),kt=(e,t,r,n,d,s)=>te(G(s),g+m,n,()=>[H(e),H(t),H(r)],d),qt=(e,t,r,n,d,s)=>te(G(s),m,n,()=>[H(e),H(t),H(r)],d),Ct=(e,t,r)=>te(G(r),g+y,e,()=>j,t),Rt=(e,t,r)=>te(G(r),y,e,()=>j,t),Lt=(e,t,r)=>te(G(r),x,e,()=>j,t),Tt=(e,t,r,n)=>te(G(n),g+w,t,()=>[H(e)],r),Vt=(e,t,r,n)=>te(G(n),w,t,()=>[H(e)],r),Bt=(e,t)=>te(G(t),"Start"+_,e),St=(e,t)=>te(G(t),"Will"+$+_,e),zt=(e,t)=>te(G(t),"Did"+$+_,e),Ft=(e,t,r)=>te(J(r),q,t,()=>[H(e)]),Pt=(e,t,r)=>te(K(r),C+c,t,()=>[H(e)]),jt=(e,t,r,n)=>te(K(n),C+b,r,()=>[H(e),H(t)]),At=(e,t,r,n)=>te(N(n),R,r,()=>[H(e),H(t)]),Dt=(e,t,r,n)=>te(N(n),L+b,r,()=>[H(e),H(t)]),Ht=(e,t,r,n)=>te(N(n),T+b,r,()=>[H(e),H(t)]),Mt=(e,t,r)=>te(U(r),i+p,t,()=>[H(e)]),Ot=(e,t,r)=>te(U(r),i+p+v,t,()=>[H(e)]),Qt=(e,t,r)=>te(U(r),i+f,t,()=>[H(e)]),Wt=(e,t,r)=>te(U(r),i+b,t,()=>[H(e)]),Et=(e,t,r,n,d,s,u)=>te(U(u),i+h,s,()=>[H(e),H(t),H(r),H(n),H(d)]),Gt=(e,t,r,n)=>te(U(n),i+I,r,()=>[H(e),H(t)]),Jt=(e,t,r,n)=>te(U(n),i+v,r,()=>[H(e),H(t)]),Kt=(e,t,r,n,d)=>te(U(d),i+m,n,()=>[H(e),H(t),H(r)]),Nt=(e,t,r)=>te(U(r),"ParamValues",t,()=>[H(e)]),Ut=(e,t,r,n)=>te(U(n),"ParamValue",r,()=>[H(e),H(t)]),Xt=(e,t)=>te(X(t),V+c,e),Yt=(e,t,r)=>te(X(r),V,t,()=>[H(e)]),Zt=(e,t)=>te(Y(t),k,e),er=(e,t)=>te(Z(t),k,e),tr=(t,r,n)=>{const d=M();"undefined"!=typeof window&&e.user_effect(()=>(d[16]?.(n,t,r),()=>d[17]?.(n,t)))},rr=(e,t)=>tr(e,t,0),nr=(e,t)=>tr(e,t,1),dr=(e,t)=>tr(e,t,2),sr=(e,t)=>tr(e,t,3),ur=(e,t)=>tr(e,t,4),or=(e,t)=>tr(e,t,5),ir=(e,t)=>tr(e,t,6),gr=(e,t)=>tr(e,t,7);function cr(t,r){e.push(r,!0);const n=nt(()=>r.checkpointId,()=>r.checkpoints),d=e.derived(()=>""+(n.current??"")),s=e.derived(()=>r.debugIds?`${r.checkpointId}:{${e.get(d)}}`:e.get(d));e.next();var u=e.text();e.template_effect(()=>e.set_text(u,e.get(s))),e.append(t,u),e.pop()}var pr=e.from_html("<!><!>",1),ar=e.from_html("<!><!><!>",1);function lr(t,r){e.push(r,!0);var n=ar(),d=e.first_child(n),s=t=>{var n=e.text();e.template_effect(()=>e.set_text(n,(r.id??"")+":{")),e.append(t,n)},u=e.derived(()=>r.debugIds&&!B(r.id));e.if(d,t=>{e.get(u)&&t(s)});var o=e.sibling(d);e.each(o,18,()=>r.ids,e=>e,(t,n,d)=>{var s=pr(),u=e.first_child(s),o=t=>{var n=e.comment(),d=e.first_child(n);e.snippet(d,()=>r.separator),e.append(t,n)};e.if(u,t=>{e.get(d)>0&&r.separator&&t(o)});var i=e.sibling(u),g=t=>{var d=e.comment(),s=e.first_child(d);e.snippet(s,()=>r.custom,()=>n),e.append(t,d)},c=t=>{var d=e.comment(),s=e.first_child(d);e.snippet(s,()=>r.children,()=>n),e.append(t,d)};e.if(i,e=>{r.custom?e(g):e(c,-1)}),e.append(t,s)});var i=e.sibling(o),g=t=>{var r=e.text();r.nodeValue="}",e.append(t,r)},c=e.derived(()=>r.debugIds&&!B(r.id));e.if(i,t=>{e.get(c)&&t(g)}),e.append(t,n),e.pop()}function Ir(t,r){e.push(r,!0);const n=rt(()=>r.checkpoints),d=e.derived(()=>n.current[0]);{const n=(t,n=e.noop)=>{cr(t,{get checkpointId(){return n()},get checkpoints(){return r.checkpoints},get debugIds(){return r.debugIds}})};lr(t,{get ids(){return e.get(d)},get separator(){return r.separator},get debugIds(){return r.debugIds},get custom(){return r.checkpoint},children:n,$$slots:{default:!0}})}e.pop()}function fr(t,r){e.push(r,!0);const n=be(()=>r.tableId,()=>r.rowId,()=>r.cellId,()=>r.store),d=e.derived(()=>""+(n.current??"")),s=e.derived(()=>r.debugIds?`${r.cellId}:{${e.get(d)}}`:e.get(d));e.next();var u=e.text();e.template_effect(()=>e.set_text(u,e.get(s))),e.append(t,u),e.pop()}function br(t,r){e.push(r,!0);const n=rt(()=>r.checkpoints),d=e.derived(()=>n.current[1]);var s=e.comment(),u=e.first_child(s),o=t=>{var n=e.comment(),s=e.first_child(n),u=t=>{var n=e.comment(),s=e.first_child(n);e.snippet(s,()=>r.checkpoint,()=>e.get(d)),e.append(t,n)},o=t=>{cr(t,{get checkpointId(){return e.get(d)},get checkpoints(){return r.checkpoints},get debugIds(){return r.debugIds}})};e.if(s,e=>{r.checkpoint?e(u):e(o,-1)}),e.append(t,n)},i=e.derived(()=>!B(e.get(d)));e.if(u,t=>{e.get(i)&&t(o)}),e.append(t,s),e.pop()}function hr(t,r){e.push(r,!0);const n=rt(()=>r.checkpoints),d=e.derived(()=>n.current[2]);{const n=(t,n=e.noop)=>{cr(t,{get checkpointId(){return n()},get checkpoints(){return r.checkpoints},get debugIds(){return r.debugIds}})};lr(t,{get ids(){return e.get(d)},get separator(){return r.separator},get debugIds(){return r.debugIds},get custom(){return r.checkpoint},children:n,$$slots:{default:!0}})}e.pop()}function mr(t,r){e.push(r,!0);const n=Ie(()=>r.tableId,()=>r.rowId,()=>r.store),d=e.derived(()=>r.customCellIds??n.current);{const n=(t,n=e.noop)=>{fr(t,{get tableId(){return r.tableId},get rowId(){return r.rowId},get cellId(){return n()},get store(){return r.store},get debugIds(){return r.debugIds}})};lr(t,{get ids(){return e.get(d)},get separator(){return r.separator},get debugIds(){return r.debugIds},get id(){return r.rowId},get custom(){return r.cell},children:n,$$slots:{default:!0}})}e.pop()}function vr(t,r){e.push(r,!0);const{store:n,tableId:d}=Fe(()=>r.indexes,()=>r.indexId),s=ze(()=>r.indexId,()=>r.sliceId,()=>r.indexes);{const u=(t,s=e.noop)=>{var u=e.comment(),o=e.first_child(u),i=e=>{mr(e,{get tableId(){return d},get rowId(){return s()},get store(){return n},get debugIds(){return r.debugIds}})};e.if(o,e=>{d&&e(i)}),e.append(t,u)};lr(t,{get ids(){return s.current},get separator(){return r.separator},get debugIds(){return r.debugIds},get id(){return r.sliceId},get custom(){return r.row},children:u,$$slots:{default:!0}})}e.pop()}function wr(t,r){e.push(r,!0);const n=Se(()=>r.indexId,()=>r.indexes);{const d=(t,n=e.noop)=>{vr(t,{get indexId(){return r.indexId},get sliceId(){return n()},get indexes(){return r.indexes},get debugIds(){return r.debugIds}})};lr(t,{get ids(){return n.current},get separator(){return r.separator},get debugIds(){return r.debugIds},get id(){return r.indexId},get custom(){return r.slice},children:d,$$slots:{default:!0}})}e.pop()}function yr(t,r){e.push(r,!0);const{store:n,localTableId:d}=Ze(()=>r.relationships,()=>r.relationshipId),s=Ye(()=>r.relationshipId,()=>r.firstRowId,()=>r.relationships);{const u=(t,s=e.noop)=>{var u=e.comment(),o=e.first_child(u),i=e=>{mr(e,{get tableId(){return d},get rowId(){return s()},get store(){return n},get debugIds(){return r.debugIds}})};e.if(o,e=>{d&&e(i)}),e.append(t,u)};lr(t,{get ids(){return s.current},get separator(){return r.separator},get debugIds(){return r.debugIds},get id(){return r.firstRowId},get custom(){return r.row},children:u,$$slots:{default:!0}})}e.pop()}function xr(t,r){e.push(r,!0);const{store:n,localTableId:d}=Ze(()=>r.relationships,()=>r.relationshipId),s=Xe(()=>r.relationshipId,()=>r.remoteRowId,()=>r.relationships);{const u=(t,s=e.noop)=>{var u=e.comment(),o=e.first_child(u),i=e=>{mr(e,{get tableId(){return d},get rowId(){return s()},get store(){return n},get debugIds(){return r.debugIds}})};e.if(o,e=>{d&&e(i)}),e.append(t,u)};lr(t,{get ids(){return s.current},get separator(){return r.separator},get debugIds(){return r.debugIds},get id(){return r.remoteRowId},get custom(){return r.row},children:u,$$slots:{default:!0}})}e.pop()}function _r(t,r){e.push(r,!0);const n=Le(()=>r.metricId,()=>r.metrics),d=e.derived(()=>""+(n.current??"")),s=e.derived(()=>r.debugIds?`${r.metricId}:{${e.get(d)}}`:e.get(d));e.next();var u=e.text();e.template_effect(()=>e.set_text(u,e.get(s))),e.append(t,u),e.pop()}function $r(d,s){e.push(s,!0);const u=t(P)??[];let o=e.proxy(Array.from({length:8},()=>({})));const i=(e,t,r)=>{o[e]={...n(()=>o[e]),[t]:r}},g=(e,t)=>{const{[t]:r,...d}=n(()=>o[e]);o[e]=d};r(P,{get 0(){return s.store??u[0]},get 1(){return{...u[1]??{},...s.storesById,...o[0]}},get 2(){return s.metrics??u[2]},get 3(){return{...u[3]??{},...s.metricsById,...o[1]}},get 4(){return s.indexes??u[4]},get 5(){return{...u[5]??{},...s.indexesById,...o[2]}},get 6(){return s.relationships??u[6]},get 7(){return{...u[7]??{},...s.relationshipsById,...o[3]}},get 8(){return s.queries??u[8]},get 9(){return{...u[9]??{},...s.queriesById,...o[4]}},get 10(){return s.checkpoints??u[10]},get 11(){return{...u[11]??{},...s.checkpointsById,...o[5]}},get 12(){return s.persister??u[12]},get 13(){return{...u[13]??{},...s.persistersById,...o[6]}},get 14(){return s.synchronizer??u[14]},get 15(){return{...u[15]??{},...s.synchronizersById,...o[7]}},get 16(){return i},get 17(){return g}});var c=e.comment(),p=e.first_child(c);e.snippet(p,()=>s.children),e.append(d,c),e.pop()}var kr=e.from_html("<!><!><!>",1);function qr(t,r){e.push(r,!0);const{store:n,remoteTableId:d}=Ze(()=>r.relationships,()=>r.relationshipId),s=Ue(()=>r.relationshipId,()=>r.localRowId,()=>r.relationships);var u=kr(),o=e.first_child(u),i=t=>{var n=e.text();e.template_effect(()=>e.set_text(n,(r.localRowId??"")+":{")),e.append(t,n)};e.if(o,e=>{r.debugIds&&e(i)});var g=e.sibling(o),c=t=>{var u=e.comment(),o=e.first_child(u),i=t=>{var n=e.comment(),d=e.first_child(n);e.snippet(d,()=>r.row,()=>s.current),e.append(t,n)},g=e=>{mr(e,{get tableId(){return d},get rowId(){return s.current},get store(){return n},get debugIds(){return r.debugIds}})};e.if(o,e=>{r.row?e(i):d&&e(g,1)}),e.append(t,u)},p=e.derived(()=>!B(s.current));e.if(g,t=>{e.get(p)&&t(c)});var a=e.sibling(g),l=t=>{var r=e.text();r.nodeValue="}",e.append(t,r)};e.if(a,e=>{r.debugIds&&e(l)}),e.append(t,u),e.pop()}function Cr(t,r){e.push(r,!0);const n=Ge(()=>r.queryId,()=>r.rowId,()=>r.cellId,()=>r.queries),d=e.derived(()=>""+(n.current??"")),s=e.derived(()=>r.debugIds?`${r.cellId}:{${e.get(d)}}`:e.get(d));e.next();var u=e.text();e.template_effect(()=>e.set_text(u,e.get(s))),e.append(t,u),e.pop()}function Rr(t,r){e.push(r,!0);const n=Ee(()=>r.queryId,()=>r.rowId,()=>r.queries);{const d=(t,n=e.noop)=>{Cr(t,{get queryId(){return r.queryId},get rowId(){return r.rowId},get cellId(){return n()},get queries(){return r.queries},get debugIds(){return r.debugIds}})};lr(t,{get ids(){return n.current},get separator(){return r.separator},get debugIds(){return r.debugIds},get id(){return r.rowId},get custom(){return r.cell},children:d,$$slots:{default:!0}})}e.pop()}function Lr(t,r){e.push(r,!0);const n=Qe(()=>r.queryId,()=>r.cellId,()=>r.descending??!1,()=>r.offset??0,()=>r.limit,()=>r.queries);{const d=(t,n=e.noop)=>{Rr(t,{get queryId(){return r.queryId},get rowId(){return n()},get queries(){return r.queries},get debugIds(){return r.debugIds}})};lr(t,{get ids(){return n.current},get separator(){return r.separator},get debugIds(){return r.debugIds},get id(){return r.queryId},get custom(){return r.row},children:d,$$slots:{default:!0}})}e.pop()}function Tr(t,r){e.push(r,!0);const n=Oe(()=>r.queryId,()=>r.queries);{const d=(t,n=e.noop)=>{Rr(t,{get queryId(){return r.queryId},get rowId(){return n()},get queries(){return r.queries},get debugIds(){return r.debugIds}})};lr(t,{get ids(){return n.current},get separator(){return r.separator},get debugIds(){return r.debugIds},get id(){return r.queryId},get custom(){return r.row},children:d,$$slots:{default:!0}})}e.pop()}function Vr(t,r){e.push(r,!0);const n=pe(()=>r.tableId,()=>r.cellId,()=>r.descending??!1,()=>r.offset??0,()=>r.limit,()=>r.store);{const d=(t,n=e.noop)=>{mr(t,{get tableId(){return r.tableId},get rowId(){return n()},get store(){return r.store},get customCellIds(){return r.customCellIds},get debugIds(){return r.debugIds}})};lr(t,{get ids(){return n.current},get separator(){return r.separator},get debugIds(){return r.debugIds},get id(){return r.tableId},get custom(){return r.row},children:d,$$slots:{default:!0}})}e.pop()}function Br(t,r){e.push(r,!0);const n=ce(()=>r.tableId,()=>r.store);{const d=(t,n=e.noop)=>{mr(t,{get tableId(){return r.tableId},get rowId(){return n()},get store(){return r.store},get customCellIds(){return r.customCellIds},get debugIds(){return r.debugIds}})};lr(t,{get ids(){return n.current},get separator(){return r.separator},get debugIds(){return r.debugIds},get id(){return r.tableId},get custom(){return r.row},children:d,$$slots:{default:!0}})}e.pop()}function Sr(t,r){e.push(r,!0);const n=de(()=>r.store);{const d=(t,n=e.noop)=>{Br(t,{get tableId(){return n()},get store(){return r.store},get debugIds(){return r.debugIds}})};lr(t,{get ids(){return n.current},get separator(){return r.separator},get debugIds(){return r.debugIds},get custom(){return r.table},children:d,$$slots:{default:!0}})}e.pop()}function zr(t,r){e.push(r,!0);const n=xe(()=>r.valueId,()=>r.store),d=e.derived(()=>""+(n.current??"")),s=e.derived(()=>r.debugIds?`${r.valueId}:{${e.get(d)}}`:e.get(d));e.next();var u=e.text();e.template_effect(()=>e.set_text(u,e.get(s))),e.append(t,u),e.pop()}function Fr(t,r){e.push(r,!0);const n=we(()=>r.store);{const d=(t,n=e.noop)=>{zr(t,{get valueId(){return n()},get store(){return r.store},get debugIds(){return r.debugIds}})};lr(t,{get ids(){return n.current},get separator(){return r.separator},get debugIds(){return r.debugIds},get custom(){return r.value},children:d,$$slots:{default:!0}})}e.pop()}export{Ir as BackwardCheckpointsView,fr as CellView,cr as CheckpointView,br as CurrentCheckpointView,hr as ForwardCheckpointsView,wr as IndexView,yr as LinkedRowsView,xr as LocalRowsView,_r as MetricView,$r as Provider,qr as RemoteRowView,Cr as ResultCellView,Rr as ResultRowView,Lr as ResultSortedTableView,Tr as ResultTableView,mr as RowView,vr as SliceView,Vr as SortedTableView,Br as TableView,Sr as TablesView,zr as ValueView,Fr as ValuesView,or as provideCheckpoints,dr as provideIndexes,nr as provideMetrics,ir as providePersister,ur as provideQueries,sr as provideRelationships,rr as provideStore,gr as provideSynchronizer,he as useBindableCell,_e as useBindableValue,be as useCell,Ie as useCellIds,$t as useCellIdsListener,qt as useCellListener,nt as useCheckpoint,rt as useCheckpointIds,Xt as useCheckpointIdsListener,Yt as useCheckpointListener,et as useCheckpoints,tt as useCheckpointsIds,X as useCheckpointsOrCheckpointsById,zt as useDidFinishTransactionListener,dt as useGoBackwardCallback,st as useGoForwardCallback,fe as useHasCell,kt as useHasCellListener,ae as useHasRow,xt as useHasRowListener,se as useHasTable,ie as useHasTableCell,mt as useHasTableCellListener,ft as useHasTableListener,re as useHasTables,at as useHasTablesListener,ye as useHasValue,Tt as useHasValueListener,me as useHasValues,Ct as useHasValuesListener,Be as useIndexIds,Fe as useIndexStoreTableId,Te as useIndexes,Ve as useIndexesIds,K as useIndexesOrIndexesById,Ye as useLinkedRowIds,Ht as useLinkedRowIdsListener,Xe as useLocalRowIds,Dt as useLocalRowIdsListener,Le as useMetric,Re as useMetricIds,Ft as useMetricListener,qe as useMetrics,Ce as useMetricsIds,J as useMetricsOrMetricsById,Ut as useParamValueListener,Nt as useParamValuesListener,ut as usePersister,ot as usePersisterIds,Y as usePersisterOrPersisterById,it as usePersisterStatus,Zt as usePersisterStatusListener,Pe as useQueries,je as useQueriesIds,U as useQueriesOrQueriesById,Ae as useQueryIds,Ne as useRelationshipIds,Je as useRelationships,Ke as useRelationshipsIds,N as useRelationshipsOrRelationshipsById,Ze as useRelationshipsStoreTableIds,Ue as useRemoteRowId,At as useRemoteRowIdListener,Ge as useResultCell,Ee as useResultCellIds,Jt as useResultCellIdsListener,Kt as useResultCellListener,We as useResultRow,Me as useResultRowCount,Qt as useResultRowCountListener,Oe as useResultRowIds,Wt as useResultRowIdsListener,Gt as useResultRowListener,Qe as useResultSortedRowIds,Et as useResultSortedRowIdsListener,De as useResultTable,He as useResultTableCellIds,Ot as useResultTableCellIdsListener,Mt as useResultTableListener,le as useRow,ge as useRowCount,vt as useRowCountListener,ce as useRowIds,wt as useRowIdsListener,_t as useRowListener,Se as useSliceIds,Pt as useSliceIdsListener,ze as useSliceRowIds,jt as useSliceRowIdsListener,pe as useSortedRowIds,yt as useSortedRowIdsListener,Bt as useStartTransactionListener,$e as useStore,ke as useStoreIds,G as useStoreOrStoreById,gt as useSynchronizer,ct as useSynchronizerIds,Z as useSynchronizerOrSynchronizerById,pt as useSynchronizerStatus,er as useSynchronizerStatusListener,ue as useTable,oe as useTableCellIds,ht as useTableCellIdsListener,de as useTableIds,It as useTableIdsListener,bt as useTableListener,ne as useTables,lt as useTablesListener,xe as useValue,we as useValueIds,Lt as useValueIdsListener,Vt as useValueListener,ve as useValues,Rt as useValuesListener,St as useWillFinishTransactionListener};
|
|
1
|
+
import"svelte/internal/disclose-version";import*as e from"svelte/internal/client";import{getContext as t,setContext as r,untrack as n}from"svelte";import{createSubscriber as s}from"svelte/reactivity";const d=e=>typeof e,u=d(""),o=d(d),c="Listener",g="Result",i="Has",a="Ids",p="Table",l=p+"s",I=p+a,f="Row",b=f+"Count",h=f+a,m="Sorted"+f+a,v="Cell",x=v+a,_="Value",w=_+"s",y=_+a,$="Transaction",k="Finish",q="Status",R="Metric",C="Slice",T="RemoteRowId",L="Local",B="Linked",V="Checkpoint",S=globalThis,z=e=>void 0===e,F=()=>!z(S.window),P=(j=z,(e,t,r)=>j(e)?r?.():t(e));var j;const A=()=>{},D=Object.keys,H="tinybase_uisc";class M{#e;#t;constructor(e,t){this.#e=e,this.#t=t}get current(){return this.#t(),this.#e()}}class O extends M{#r;constructor(e,t,r){super(e,r),this.#r=t}get current(){return super.current}set current(e){this.#r(e)}}const Q=[],W={},E=[Q,void 0,Q],G=e=>(e=>d(e)==o)(e)?e():e,J=()=>t(H)??[],K=(e,t,r)=>{return z(t)?e[2*r]:d(t)==u?(n=e[2*r+1],s=t,P(n,e=>e[s])):t;var n,s},N=(e,t)=>K(J(),e,t),U=(e,t)=>{const r=J();return()=>K(r,G(e),t)},X=(e,t)=>D(e[2*t+1]??W),Y=e=>U(e,0),Z=e=>U(e,1),ee=e=>U(e,2),te=e=>U(e,3),re=e=>U(e,4),ne=e=>U(e,5),se=e=>U(e,6),de=e=>U(e,7),ue=(t,r,n,d=()=>Q,u)=>{const o=(u?"has":"get")+r,g="add"+(u?i:"")+r+c;let a=e.state(e.proxy(A));return F()&&e.user_effect(()=>{const r=t(),n=d();e.set(a,s(e=>{const t=r?.[g]?.(...n,e);return()=>r?.delListener?.(t)}),!0)}),new M(()=>t()?.[o]?.(...d())??n,()=>e.get(a)())},oe=(t,r,n,s=()=>Q,d)=>{F()&&e.user_effect(()=>{const e=t(),u=s(),o=e?.["add"+r+c]?.(...u,n,...void 0!==d?[d]:Q);return()=>e?.delListener?.(o)})},ce=e=>ue(Y(e),l,!1,()=>Q,1),ge=e=>ue(Y(e),l,W),ie=e=>ue(Y(e),I,Q),ae=(e,t)=>ue(Y(t),p,!1,()=>[G(e)],1),pe=(e,t)=>ue(Y(t),p,W,()=>[G(e)]),le=(e,t)=>ue(Y(t),p+x,Q,()=>[G(e)]),Ie=(e,t,r)=>ue(Y(r),p+v,!1,()=>[G(e),G(t)],1),fe=(e,t)=>ue(Y(t),b,0,()=>[G(e)]),be=(e,t)=>ue(Y(t),h,Q,()=>[G(e)]),he=(e,t,r=!1,n=0,s,d)=>ue(Y(d),m,Q,()=>[G(e),G(t),G(r),G(n),G(s)]),me=(e,t,r)=>ue(Y(r),f,!1,()=>[G(e),G(t)],1),ve=(e,t,r)=>ue(Y(r),f,W,()=>[G(e),G(t)]),xe=(e,t,r)=>ue(Y(r),x,Q,()=>[G(e),G(t)]),_e=(e,t,r,n)=>ue(Y(n),v,!1,()=>[G(e),G(t),G(r)],1),we=(t,r,n,d)=>{const u=Y(d);let o=e.state(e.proxy(A));return F()&&e.user_effect(()=>{const d=u(),c=G(t),g=G(r),i=G(n);e.set(o,s(e=>{const t=d?.addCellListener(c,g,i,e);return()=>d?.delListener?.(t)}),!0)}),new O(()=>u()?.getCell(G(t),G(r),G(n)),e=>u()?.setCell(G(t),G(r),G(n),e),()=>e.get(o)())},ye=e=>ue(Y(e),w,!1,()=>Q,1),$e=e=>ue(Y(e),w,W),ke=e=>ue(Y(e),y,Q),qe=(e,t)=>ue(Y(t),_,!1,()=>[G(e)],1),Re=(t,r)=>{const n=Y(r);let d=e.state(e.proxy(A));return F()&&e.user_effect(()=>{const r=n(),u=G(t);e.set(d,s(e=>{const t=r?.addValueListener(u,e);return()=>r?.delListener?.(t)}),!0)}),new O(()=>n()?.getValue(G(t)),e=>n()?.setValue(G(t),e),()=>e.get(d)())},Ce=e=>N(e,0),Te=()=>{const t=J();let r=e.state(e.proxy(X(t,0)));return F()&&e.user_effect(()=>{e.set(r,X(t,0),!0)}),{get current(){return e.get(r)}}},Le=e=>N(e,1),Be=()=>{const t=J();let r=e.state(e.proxy(X(t,1)));return F()&&e.user_effect(()=>{e.set(r,X(t,1),!0)}),{get current(){return e.get(r)}}},Ve=e=>ue(Z(e),R+a,Q),Se=(e,t)=>ue(Z(t),R,void 0,()=>[G(e)]),ze=e=>N(e,2),Fe=()=>{const t=J();let r=e.state(e.proxy(X(t,2)));return F()&&e.user_effect(()=>{e.set(r,X(t,2),!0)}),{get current(){return e.get(r)}}},Pe=e=>ue(ee(e),"Index"+a,Q),je=(e,t)=>ue(ee(t),C+a,Q,()=>[G(e)]),Ae=(e,t,r)=>ue(ee(r),C+h,Q,()=>[G(e),G(t)]),De=(e,t)=>{const r=ee(e);return{get store(){return r()?.getStore()},get tableId(){return r()?.getTableId(G(t))}}},He=e=>N(e,4),Me=()=>{const t=J();let r=e.state(e.proxy(X(t,4)));return F()&&e.user_effect(()=>{e.set(r,X(t,4),!0)}),{get current(){return e.get(r)}}},Oe=e=>ue(re(e),"Query"+a,Q),Qe=(e,t)=>ue(re(t),g+p,W,()=>[G(e)]),We=(e,t)=>ue(re(t),g+p+x,Q,()=>[G(e)]),Ee=(e,t)=>ue(re(t),g+b,0,()=>[G(e)]),Ge=(e,t)=>ue(re(t),g+h,Q,()=>[G(e)]),Je=(e,t,r=!1,n=0,s,d)=>ue(re(d),g+m,Q,()=>[G(e),G(t),G(r),G(n),G(s)]),Ke=(e,t,r)=>ue(re(r),g+f,W,()=>[G(e),G(t)]),Ne=(e,t,r)=>ue(re(r),g+x,Q,()=>[G(e),G(t)]),Ue=(e,t,r,n)=>ue(re(n),g+v,void 0,()=>[G(e),G(t),G(r)]),Xe=e=>N(e,3),Ye=()=>{const t=J();let r=e.state(e.proxy(X(t,3)));return F()&&e.user_effect(()=>{e.set(r,X(t,3),!0)}),{get current(){return e.get(r)}}},Ze=e=>ue(te(e),"Relationship"+a,Q),et=(e,t,r)=>ue(te(r),T,void 0,()=>[G(e),G(t)]),tt=(e,t,r)=>ue(te(r),L+h,Q,()=>[G(e),G(t)]),rt=(e,t,r)=>ue(te(r),B+h,Q,()=>[G(e),G(t)]),nt=(e,t)=>{const r=te(e);return{get store(){return r()?.getStore()},get localTableId(){return r()?.getLocalTableId(G(t))},get remoteTableId(){return r()?.getRemoteTableId(G(t))}}},st=e=>N(e,5),dt=()=>{const t=J();let r=e.state(e.proxy(X(t,5)));return F()&&e.user_effect(()=>{e.set(r,X(t,5),!0)}),{get current(){return e.get(r)}}},ut=e=>ue(ne(e),V+a,E),ot=(e,t)=>ue(ne(t),V,void 0,()=>[G(e)]),ct=e=>{const t=ne(e);return()=>t()?.goBackward()},gt=e=>{const t=ne(e);return()=>t()?.goForward()},it=e=>N(e,6),at=()=>{const t=J();let r=e.state(e.proxy(X(t,6)));return F()&&e.user_effect(()=>{e.set(r,X(t,6),!0)}),{get current(){return e.get(r)}}},pt=e=>ue(se(e),q,0),lt=e=>N(e,7),It=()=>{const t=J();let r=e.state(e.proxy(X(t,7)));return F()&&e.user_effect(()=>{e.set(r,X(t,7),!0)}),{get current(){return e.get(r)}}},ft=e=>ue(de(e),q,0),bt=(e,t,r)=>oe(Y(r),i+l,e,()=>Q,t),ht=(e,t,r)=>oe(Y(r),l,e,()=>Q,t),mt=(e,t,r)=>oe(Y(r),I,e,()=>Q,t),vt=(e,t,r,n)=>oe(Y(n),i+p,t,()=>[G(e)],r),xt=(e,t,r,n)=>oe(Y(n),p,t,()=>[G(e)],r),_t=(e,t,r,n)=>oe(Y(n),p+x,t,()=>[G(e)],r),wt=(e,t,r,n,s)=>oe(Y(s),i+p+v,r,()=>[G(e),G(t)],n),yt=(e,t,r,n)=>oe(Y(n),b,t,()=>[G(e)],r),$t=(e,t,r,n)=>oe(Y(n),h,t,()=>[G(e)],r),kt=(e,t,r,n,s,d,u,o)=>oe(Y(o),m,d,()=>[G(e),G(t),G(r),G(n),G(s)],u),qt=(e,t,r,n,s)=>oe(Y(s),i+f,r,()=>[G(e),G(t)],n),Rt=(e,t,r,n,s)=>oe(Y(s),f,r,()=>[G(e),G(t)],n),Ct=(e,t,r,n,s)=>oe(Y(s),x,r,()=>[G(e),G(t)],n),Tt=(e,t,r,n,s,d)=>oe(Y(d),i+v,n,()=>[G(e),G(t),G(r)],s),Lt=(e,t,r,n,s,d)=>oe(Y(d),v,n,()=>[G(e),G(t),G(r)],s),Bt=(e,t,r)=>oe(Y(r),i+w,e,()=>Q,t),Vt=(e,t,r)=>oe(Y(r),w,e,()=>Q,t),St=(e,t,r)=>oe(Y(r),y,e,()=>Q,t),zt=(e,t,r,n)=>oe(Y(n),i+_,t,()=>[G(e)],r),Ft=(e,t,r,n)=>oe(Y(n),_,t,()=>[G(e)],r),Pt=(e,t)=>oe(Y(t),"Start"+$,e),jt=(e,t)=>oe(Y(t),"Will"+k+$,e),At=(e,t)=>oe(Y(t),"Did"+k+$,e),Dt=(e,t,r)=>oe(Z(r),R,t,()=>[G(e)]),Ht=(e,t,r)=>oe(ee(r),C+a,t,()=>[G(e)]),Mt=(e,t,r,n)=>oe(ee(n),C+h,r,()=>[G(e),G(t)]),Ot=(e,t,r,n)=>oe(te(n),T,r,()=>[G(e),G(t)]),Qt=(e,t,r,n)=>oe(te(n),L+h,r,()=>[G(e),G(t)]),Wt=(e,t,r,n)=>oe(te(n),B+h,r,()=>[G(e),G(t)]),Et=(e,t,r)=>oe(re(r),g+p,t,()=>[G(e)]),Gt=(e,t,r)=>oe(re(r),g+p+x,t,()=>[G(e)]),Jt=(e,t,r)=>oe(re(r),g+b,t,()=>[G(e)]),Kt=(e,t,r)=>oe(re(r),g+h,t,()=>[G(e)]),Nt=(e,t,r,n,s,d,u)=>oe(re(u),g+m,d,()=>[G(e),G(t),G(r),G(n),G(s)]),Ut=(e,t,r,n)=>oe(re(n),g+f,r,()=>[G(e),G(t)]),Xt=(e,t,r,n)=>oe(re(n),g+x,r,()=>[G(e),G(t)]),Yt=(e,t,r,n,s)=>oe(re(s),g+v,n,()=>[G(e),G(t),G(r)]),Zt=(e,t,r)=>oe(re(r),"ParamValues",t,()=>[G(e)]),er=(e,t,r,n)=>oe(re(n),"ParamValue",r,()=>[G(e),G(t)]),tr=(e,t)=>oe(ne(t),V+a,e),rr=(e,t,r)=>oe(ne(r),V,t,()=>[G(e)]),nr=(e,t)=>oe(se(t),q,e),sr=(e,t)=>oe(de(t),q,e),dr=(t,r,n)=>{const s=J();F()&&e.user_effect(()=>(s[16]?.(n,t,r),()=>s[17]?.(n,t)))},ur=(e,t)=>dr(e,t,0),or=(e,t)=>dr(e,t,1),cr=(e,t)=>dr(e,t,2),gr=(e,t)=>dr(e,t,3),ir=(e,t)=>dr(e,t,4),ar=(e,t)=>dr(e,t,5),pr=(e,t)=>dr(e,t,6),lr=(e,t)=>dr(e,t,7);function Ir(t,r){e.push(r,!0);const n=ot(()=>r.checkpointId,()=>r.checkpoints),s=e.derived(()=>""+(n.current??"")),d=e.derived(()=>r.debugIds?`${r.checkpointId}:{${e.get(s)}}`:e.get(s));e.next();var u=e.text();e.template_effect(()=>e.set_text(u,e.get(d))),e.append(t,u),e.pop()}var fr=e.from_html("<!><!>",1),br=e.from_html("<!><!><!>",1);function hr(t,r){e.push(r,!0);var n=br(),s=e.first_child(n),d=t=>{var n=e.text();e.template_effect(()=>e.set_text(n,(r.id??"")+":{")),e.append(t,n)},u=e.derived(()=>r.debugIds&&!z(r.id));e.if(s,t=>{e.get(u)&&t(d)});var o=e.sibling(s);e.each(o,18,()=>r.ids,e=>e,(t,n,s)=>{var d=fr(),u=e.first_child(d),o=t=>{var n=e.comment(),s=e.first_child(n);e.snippet(s,()=>r.separator),e.append(t,n)};e.if(u,t=>{e.get(s)>0&&r.separator&&t(o)});var c=e.sibling(u),g=t=>{var s=e.comment(),d=e.first_child(s);e.snippet(d,()=>r.custom,()=>n),e.append(t,s)},i=t=>{var s=e.comment(),d=e.first_child(s);e.snippet(d,()=>r.children,()=>n),e.append(t,s)};e.if(c,e=>{r.custom?e(g):e(i,-1)}),e.append(t,d)});var c=e.sibling(o),g=t=>{var r=e.text();r.nodeValue="}",e.append(t,r)},i=e.derived(()=>r.debugIds&&!z(r.id));e.if(c,t=>{e.get(i)&&t(g)}),e.append(t,n),e.pop()}function mr(t,r){e.push(r,!0);const n=ut(()=>r.checkpoints),s=e.derived(()=>n.current[0]);{const n=(t,n=e.noop)=>{Ir(t,{get checkpointId(){return n()},get checkpoints(){return r.checkpoints},get debugIds(){return r.debugIds}})};hr(t,{get ids(){return e.get(s)},get separator(){return r.separator},get debugIds(){return r.debugIds},get custom(){return r.checkpoint},children:n,$$slots:{default:!0}})}e.pop()}function vr(t,r){e.push(r,!0);const n=we(()=>r.tableId,()=>r.rowId,()=>r.cellId,()=>r.store),s=e.derived(()=>""+(n.current??"")),d=e.derived(()=>r.debugIds?`${r.cellId}:{${e.get(s)}}`:e.get(s));e.next();var u=e.text();e.template_effect(()=>e.set_text(u,e.get(d))),e.append(t,u),e.pop()}function xr(t,r){e.push(r,!0);const n=ut(()=>r.checkpoints),s=e.derived(()=>n.current[1]);var d=e.comment(),u=e.first_child(d),o=t=>{var n=e.comment(),d=e.first_child(n),u=t=>{var n=e.comment(),d=e.first_child(n);e.snippet(d,()=>r.checkpoint,()=>e.get(s)),e.append(t,n)},o=t=>{Ir(t,{get checkpointId(){return e.get(s)},get checkpoints(){return r.checkpoints},get debugIds(){return r.debugIds}})};e.if(d,e=>{r.checkpoint?e(u):e(o,-1)}),e.append(t,n)},c=e.derived(()=>!z(e.get(s)));e.if(u,t=>{e.get(c)&&t(o)}),e.append(t,d),e.pop()}function _r(t,r){e.push(r,!0);const n=ut(()=>r.checkpoints),s=e.derived(()=>n.current[2]);{const n=(t,n=e.noop)=>{Ir(t,{get checkpointId(){return n()},get checkpoints(){return r.checkpoints},get debugIds(){return r.debugIds}})};hr(t,{get ids(){return e.get(s)},get separator(){return r.separator},get debugIds(){return r.debugIds},get custom(){return r.checkpoint},children:n,$$slots:{default:!0}})}e.pop()}function wr(t,r){e.push(r,!0);const n=xe(()=>r.tableId,()=>r.rowId,()=>r.store),s=e.derived(()=>r.customCellIds??n.current);{const n=(t,n=e.noop)=>{vr(t,{get tableId(){return r.tableId},get rowId(){return r.rowId},get cellId(){return n()},get store(){return r.store},get debugIds(){return r.debugIds}})};hr(t,{get ids(){return e.get(s)},get separator(){return r.separator},get debugIds(){return r.debugIds},get id(){return r.rowId},get custom(){return r.cell},children:n,$$slots:{default:!0}})}e.pop()}function yr(t,r){e.push(r,!0);const{store:n,tableId:s}=De(()=>r.indexes,()=>r.indexId),d=Ae(()=>r.indexId,()=>r.sliceId,()=>r.indexes);{const u=(t,d=e.noop)=>{var u=e.comment(),o=e.first_child(u),c=e=>{wr(e,{get tableId(){return s},get rowId(){return d()},get store(){return n},get debugIds(){return r.debugIds}})};e.if(o,e=>{s&&e(c)}),e.append(t,u)};hr(t,{get ids(){return d.current},get separator(){return r.separator},get debugIds(){return r.debugIds},get id(){return r.sliceId},get custom(){return r.row},children:u,$$slots:{default:!0}})}e.pop()}function $r(t,r){e.push(r,!0);const n=je(()=>r.indexId,()=>r.indexes);{const s=(t,n=e.noop)=>{yr(t,{get indexId(){return r.indexId},get sliceId(){return n()},get indexes(){return r.indexes},get debugIds(){return r.debugIds}})};hr(t,{get ids(){return n.current},get separator(){return r.separator},get debugIds(){return r.debugIds},get id(){return r.indexId},get custom(){return r.slice},children:s,$$slots:{default:!0}})}e.pop()}function kr(t,r){e.push(r,!0);const{store:n,localTableId:s}=nt(()=>r.relationships,()=>r.relationshipId),d=rt(()=>r.relationshipId,()=>r.firstRowId,()=>r.relationships);{const u=(t,d=e.noop)=>{var u=e.comment(),o=e.first_child(u),c=e=>{wr(e,{get tableId(){return s},get rowId(){return d()},get store(){return n},get debugIds(){return r.debugIds}})};e.if(o,e=>{s&&e(c)}),e.append(t,u)};hr(t,{get ids(){return d.current},get separator(){return r.separator},get debugIds(){return r.debugIds},get id(){return r.firstRowId},get custom(){return r.row},children:u,$$slots:{default:!0}})}e.pop()}function qr(t,r){e.push(r,!0);const{store:n,localTableId:s}=nt(()=>r.relationships,()=>r.relationshipId),d=tt(()=>r.relationshipId,()=>r.remoteRowId,()=>r.relationships);{const u=(t,d=e.noop)=>{var u=e.comment(),o=e.first_child(u),c=e=>{wr(e,{get tableId(){return s},get rowId(){return d()},get store(){return n},get debugIds(){return r.debugIds}})};e.if(o,e=>{s&&e(c)}),e.append(t,u)};hr(t,{get ids(){return d.current},get separator(){return r.separator},get debugIds(){return r.debugIds},get id(){return r.remoteRowId},get custom(){return r.row},children:u,$$slots:{default:!0}})}e.pop()}function Rr(t,r){e.push(r,!0);const n=Se(()=>r.metricId,()=>r.metrics),s=e.derived(()=>""+(n.current??"")),d=e.derived(()=>r.debugIds?`${r.metricId}:{${e.get(s)}}`:e.get(s));e.next();var u=e.text();e.template_effect(()=>e.set_text(u,e.get(d))),e.append(t,u),e.pop()}function Cr(s,d){e.push(d,!0);const u=t(H)??[];let o=e.proxy(Array.from({length:8},()=>({})));const c=(e,t,r)=>{o[e]={...n(()=>o[e]),[t]:r}},g=(e,t)=>{const{[t]:r,...s}=n(()=>o[e]);o[e]=s};r(H,{get 0(){return d.store??u[0]},get 1(){return{...u[1]??{},...d.storesById,...o[0]}},get 2(){return d.metrics??u[2]},get 3(){return{...u[3]??{},...d.metricsById,...o[1]}},get 4(){return d.indexes??u[4]},get 5(){return{...u[5]??{},...d.indexesById,...o[2]}},get 6(){return d.relationships??u[6]},get 7(){return{...u[7]??{},...d.relationshipsById,...o[3]}},get 8(){return d.queries??u[8]},get 9(){return{...u[9]??{},...d.queriesById,...o[4]}},get 10(){return d.checkpoints??u[10]},get 11(){return{...u[11]??{},...d.checkpointsById,...o[5]}},get 12(){return d.persister??u[12]},get 13(){return{...u[13]??{},...d.persistersById,...o[6]}},get 14(){return d.synchronizer??u[14]},get 15(){return{...u[15]??{},...d.synchronizersById,...o[7]}},get 16(){return c},get 17(){return g}});var i=e.comment(),a=e.first_child(i);e.snippet(a,()=>d.children),e.append(s,i),e.pop()}var Tr=e.from_html("<!><!><!>",1);function Lr(t,r){e.push(r,!0);const{store:n,remoteTableId:s}=nt(()=>r.relationships,()=>r.relationshipId),d=et(()=>r.relationshipId,()=>r.localRowId,()=>r.relationships);var u=Tr(),o=e.first_child(u),c=t=>{var n=e.text();e.template_effect(()=>e.set_text(n,(r.localRowId??"")+":{")),e.append(t,n)};e.if(o,e=>{r.debugIds&&e(c)});var g=e.sibling(o),i=t=>{var u=e.comment(),o=e.first_child(u),c=t=>{var n=e.comment(),s=e.first_child(n);e.snippet(s,()=>r.row,()=>d.current),e.append(t,n)},g=e=>{wr(e,{get tableId(){return s},get rowId(){return d.current},get store(){return n},get debugIds(){return r.debugIds}})};e.if(o,e=>{r.row?e(c):s&&e(g,1)}),e.append(t,u)},a=e.derived(()=>!z(d.current));e.if(g,t=>{e.get(a)&&t(i)});var p=e.sibling(g),l=t=>{var r=e.text();r.nodeValue="}",e.append(t,r)};e.if(p,e=>{r.debugIds&&e(l)}),e.append(t,u),e.pop()}function Br(t,r){e.push(r,!0);const n=Ue(()=>r.queryId,()=>r.rowId,()=>r.cellId,()=>r.queries),s=e.derived(()=>""+(n.current??"")),d=e.derived(()=>r.debugIds?`${r.cellId}:{${e.get(s)}}`:e.get(s));e.next();var u=e.text();e.template_effect(()=>e.set_text(u,e.get(d))),e.append(t,u),e.pop()}function Vr(t,r){e.push(r,!0);const n=Ne(()=>r.queryId,()=>r.rowId,()=>r.queries);{const s=(t,n=e.noop)=>{Br(t,{get queryId(){return r.queryId},get rowId(){return r.rowId},get cellId(){return n()},get queries(){return r.queries},get debugIds(){return r.debugIds}})};hr(t,{get ids(){return n.current},get separator(){return r.separator},get debugIds(){return r.debugIds},get id(){return r.rowId},get custom(){return r.cell},children:s,$$slots:{default:!0}})}e.pop()}function Sr(t,r){e.push(r,!0);const n=Je(()=>r.queryId,()=>r.cellId,()=>r.descending??!1,()=>r.offset??0,()=>r.limit,()=>r.queries);{const s=(t,n=e.noop)=>{Vr(t,{get queryId(){return r.queryId},get rowId(){return n()},get queries(){return r.queries},get debugIds(){return r.debugIds}})};hr(t,{get ids(){return n.current},get separator(){return r.separator},get debugIds(){return r.debugIds},get id(){return r.queryId},get custom(){return r.row},children:s,$$slots:{default:!0}})}e.pop()}function zr(t,r){e.push(r,!0);const n=Ge(()=>r.queryId,()=>r.queries);{const s=(t,n=e.noop)=>{Vr(t,{get queryId(){return r.queryId},get rowId(){return n()},get queries(){return r.queries},get debugIds(){return r.debugIds}})};hr(t,{get ids(){return n.current},get separator(){return r.separator},get debugIds(){return r.debugIds},get id(){return r.queryId},get custom(){return r.row},children:s,$$slots:{default:!0}})}e.pop()}function Fr(t,r){e.push(r,!0);const n=he(()=>r.tableId,()=>r.cellId,()=>r.descending??!1,()=>r.offset??0,()=>r.limit,()=>r.store);{const s=(t,n=e.noop)=>{wr(t,{get tableId(){return r.tableId},get rowId(){return n()},get store(){return r.store},get customCellIds(){return r.customCellIds},get debugIds(){return r.debugIds}})};hr(t,{get ids(){return n.current},get separator(){return r.separator},get debugIds(){return r.debugIds},get id(){return r.tableId},get custom(){return r.row},children:s,$$slots:{default:!0}})}e.pop()}function Pr(t,r){e.push(r,!0);const n=be(()=>r.tableId,()=>r.store);{const s=(t,n=e.noop)=>{wr(t,{get tableId(){return r.tableId},get rowId(){return n()},get store(){return r.store},get customCellIds(){return r.customCellIds},get debugIds(){return r.debugIds}})};hr(t,{get ids(){return n.current},get separator(){return r.separator},get debugIds(){return r.debugIds},get id(){return r.tableId},get custom(){return r.row},children:s,$$slots:{default:!0}})}e.pop()}function jr(t,r){e.push(r,!0);const n=ie(()=>r.store);{const s=(t,n=e.noop)=>{Pr(t,{get tableId(){return n()},get store(){return r.store},get debugIds(){return r.debugIds}})};hr(t,{get ids(){return n.current},get separator(){return r.separator},get debugIds(){return r.debugIds},get custom(){return r.table},children:s,$$slots:{default:!0}})}e.pop()}function Ar(t,r){e.push(r,!0);const n=Re(()=>r.valueId,()=>r.store),s=e.derived(()=>""+(n.current??"")),d=e.derived(()=>r.debugIds?`${r.valueId}:{${e.get(s)}}`:e.get(s));e.next();var u=e.text();e.template_effect(()=>e.set_text(u,e.get(d))),e.append(t,u),e.pop()}function Dr(t,r){e.push(r,!0);const n=ke(()=>r.store);{const s=(t,n=e.noop)=>{Ar(t,{get valueId(){return n()},get store(){return r.store},get debugIds(){return r.debugIds}})};hr(t,{get ids(){return n.current},get separator(){return r.separator},get debugIds(){return r.debugIds},get custom(){return r.value},children:s,$$slots:{default:!0}})}e.pop()}export{mr as BackwardCheckpointsView,vr as CellView,Ir as CheckpointView,xr as CurrentCheckpointView,_r as ForwardCheckpointsView,$r as IndexView,kr as LinkedRowsView,qr as LocalRowsView,Rr as MetricView,Cr as Provider,Lr as RemoteRowView,Br as ResultCellView,Vr as ResultRowView,Sr as ResultSortedTableView,zr as ResultTableView,wr as RowView,yr as SliceView,Fr as SortedTableView,Pr as TableView,jr as TablesView,Ar as ValueView,Dr as ValuesView,we as createCell,xe as createCellIds,ot as createCheckpoint,ut as createCheckpointIds,dt as createCheckpointsIds,ct as createGoBackwardCallback,gt as createGoForwardCallback,_e as createHasCell,me as createHasRow,ae as createHasTable,Ie as createHasTableCell,ce as createHasTables,qe as createHasValue,ye as createHasValues,Pe as createIndexIds,Fe as createIndexesIds,rt as createLinkedRowIds,tt as createLocalRowIds,Se as createMetric,Ve as createMetricIds,Be as createMetricsIds,at as createPersisterIds,pt as createPersisterStatus,Me as createQueriesIds,Oe as createQueryIds,Ze as createRelationshipIds,Ye as createRelationshipsIds,et as createRemoteRowId,Ue as createResultCell,Ne as createResultCellIds,Ke as createResultRow,Ee as createResultRowCount,Ge as createResultRowIds,Je as createResultSortedRowIds,Qe as createResultTable,We as createResultTableCellIds,ve as createRow,fe as createRowCount,be as createRowIds,je as createSliceIds,Ae as createSliceRowIds,he as createSortedRowIds,Te as createStoreIds,It as createSynchronizerIds,ft as createSynchronizerStatus,pe as createTable,le as createTableCellIds,ie as createTableIds,ge as createTables,Re as createValue,ke as createValueIds,$e as createValues,st as getCheckpoints,De as getIndexStoreTableId,ze as getIndexes,Le as getMetrics,it as getPersister,He as getQueries,Xe as getRelationships,nt as getRelationshipsStoreTableIds,Ce as getStore,lt as getSynchronizer,Lt as onCell,Ct as onCellIds,rr as onCheckpoint,tr as onCheckpointIds,At as onDidFinishTransaction,Tt as onHasCell,qt as onHasRow,vt as onHasTable,wt as onHasTableCell,bt as onHasTables,zt as onHasValue,Bt as onHasValues,Wt as onLinkedRowIds,Qt as onLocalRowIds,Dt as onMetric,er as onParamValue,Zt as onParamValues,nr as onPersisterStatus,Ot as onRemoteRowId,Yt as onResultCell,Xt as onResultCellIds,Ut as onResultRow,Jt as onResultRowCount,Kt as onResultRowIds,Nt as onResultSortedRowIds,Et as onResultTable,Gt as onResultTableCellIds,Rt as onRow,yt as onRowCount,$t as onRowIds,Ht as onSliceIds,Mt as onSliceRowIds,kt as onSortedRowIds,Pt as onStartTransaction,sr as onSynchronizerStatus,xt as onTable,_t as onTableCellIds,mt as onTableIds,ht as onTables,Ft as onValue,St as onValueIds,Vt as onValues,jt as onWillFinishTransaction,ar as provideCheckpoints,cr as provideIndexes,or as provideMetrics,pr as providePersister,ir as provideQueries,gr as provideRelationships,ur as provideStore,lr as provideSynchronizer,ne as resolveCheckpoints,ee as resolveIndexes,Z as resolveMetrics,se as resolvePersister,re as resolveQueries,te as resolveRelationships,Y as resolveStore,de as resolveSynchronizer};
|
|
Binary file
|
package/omni/index.js
CHANGED
|
@@ -6016,7 +6016,7 @@ const createReactNativeSqlitePersister = (
|
|
|
6016
6016
|
db,
|
|
6017
6017
|
);
|
|
6018
6018
|
|
|
6019
|
-
const getETag = (response) => response.headers.get('ETag');
|
|
6019
|
+
const getETag = (response) => response.headers.get('ETag') ?? '';
|
|
6020
6020
|
const createRemotePersister = (
|
|
6021
6021
|
store,
|
|
6022
6022
|
loadUrl,
|
|
@@ -6024,9 +6024,11 @@ const createRemotePersister = (
|
|
|
6024
6024
|
autoLoadIntervalSeconds = 5,
|
|
6025
6025
|
onIgnoredError,
|
|
6026
6026
|
) => {
|
|
6027
|
-
let lastEtag;
|
|
6027
|
+
let lastEtag = '';
|
|
6028
6028
|
const getPersisted = async () => {
|
|
6029
|
-
const response = await fetch(loadUrl
|
|
6029
|
+
const response = await fetch(loadUrl, {
|
|
6030
|
+
headers: {'If-None-Match': lastEtag},
|
|
6031
|
+
});
|
|
6030
6032
|
lastEtag = getETag(response);
|
|
6031
6033
|
return jsonParse(await response.text());
|
|
6032
6034
|
};
|
|
@@ -6040,14 +6042,10 @@ const createRemotePersister = (
|
|
|
6040
6042
|
startInterval(async () => {
|
|
6041
6043
|
const response = await fetch(loadUrl, {
|
|
6042
6044
|
method: 'HEAD',
|
|
6043
|
-
headers: {'If-None-Match': lastEtag
|
|
6045
|
+
headers: {'If-None-Match': lastEtag},
|
|
6044
6046
|
});
|
|
6045
6047
|
const currentEtag = getETag(response);
|
|
6046
|
-
if (
|
|
6047
|
-
!isNull(lastEtag) &&
|
|
6048
|
-
!isNull(currentEtag) &&
|
|
6049
|
-
currentEtag != lastEtag
|
|
6050
|
-
) {
|
|
6048
|
+
if (currentEtag != lastEtag) {
|
|
6051
6049
|
lastEtag = currentEtag;
|
|
6052
6050
|
listener();
|
|
6053
6051
|
}
|
|
@@ -6016,7 +6016,7 @@ const createReactNativeSqlitePersister = (
|
|
|
6016
6016
|
db,
|
|
6017
6017
|
);
|
|
6018
6018
|
|
|
6019
|
-
const getETag = (response) => response.headers.get('ETag');
|
|
6019
|
+
const getETag = (response) => response.headers.get('ETag') ?? '';
|
|
6020
6020
|
const createRemotePersister = (
|
|
6021
6021
|
store,
|
|
6022
6022
|
loadUrl,
|
|
@@ -6024,9 +6024,11 @@ const createRemotePersister = (
|
|
|
6024
6024
|
autoLoadIntervalSeconds = 5,
|
|
6025
6025
|
onIgnoredError,
|
|
6026
6026
|
) => {
|
|
6027
|
-
let lastEtag;
|
|
6027
|
+
let lastEtag = '';
|
|
6028
6028
|
const getPersisted = async () => {
|
|
6029
|
-
const response = await fetch(loadUrl
|
|
6029
|
+
const response = await fetch(loadUrl, {
|
|
6030
|
+
headers: {'If-None-Match': lastEtag},
|
|
6031
|
+
});
|
|
6030
6032
|
lastEtag = getETag(response);
|
|
6031
6033
|
return jsonParse(await response.text());
|
|
6032
6034
|
};
|
|
@@ -6040,14 +6042,10 @@ const createRemotePersister = (
|
|
|
6040
6042
|
startInterval(async () => {
|
|
6041
6043
|
const response = await fetch(loadUrl, {
|
|
6042
6044
|
method: 'HEAD',
|
|
6043
|
-
headers: {'If-None-Match': lastEtag
|
|
6045
|
+
headers: {'If-None-Match': lastEtag},
|
|
6044
6046
|
});
|
|
6045
6047
|
const currentEtag = getETag(response);
|
|
6046
|
-
if (
|
|
6047
|
-
!isNull(lastEtag) &&
|
|
6048
|
-
!isNull(currentEtag) &&
|
|
6049
|
-
currentEtag != lastEtag
|
|
6050
|
-
) {
|
|
6048
|
+
if (currentEtag != lastEtag) {
|
|
6051
6049
|
lastEtag = currentEtag;
|
|
6052
6050
|
listener();
|
|
6053
6051
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tinybase",
|
|
3
|
-
"version": "8.1.0-beta.
|
|
3
|
+
"version": "8.1.0-beta.4",
|
|
4
4
|
"author": "jamesgpearce",
|
|
5
5
|
"repository": "github:tinyplex/tinybase",
|
|
6
6
|
"license": "MIT",
|
|
@@ -21,32 +21,32 @@
|
|
|
21
21
|
},
|
|
22
22
|
"sideEffects": false,
|
|
23
23
|
"peerDependencies": {
|
|
24
|
-
"@automerge/automerge-repo": "^2.5.
|
|
25
|
-
"@cloudflare/workers-types": "^4.
|
|
26
|
-
"@electric-sql/pglite": "^0.
|
|
27
|
-
"@libsql/client": "^0.17.
|
|
28
|
-
"@powersync/common": "^1.
|
|
29
|
-
"@sinclair/typebox": "^0.34.
|
|
30
|
-
"@sqlite.org/sqlite-wasm": "^3.51.2-
|
|
24
|
+
"@automerge/automerge-repo": "^2.5.4",
|
|
25
|
+
"@cloudflare/workers-types": "^4.20260329.1",
|
|
26
|
+
"@electric-sql/pglite": "^0.4.2",
|
|
27
|
+
"@libsql/client": "^0.17.2",
|
|
28
|
+
"@powersync/common": "^1.51.0",
|
|
29
|
+
"@sinclair/typebox": "^0.34.49",
|
|
30
|
+
"@sqlite.org/sqlite-wasm": "^3.51.2-build8",
|
|
31
31
|
"@vlcn.io/crsqlite-wasm": "^0.16.0",
|
|
32
32
|
"arktype": "^2.2.0",
|
|
33
|
-
"bun": "^1.3.
|
|
34
|
-
"effect": "^3.
|
|
33
|
+
"bun": "^1.3.11",
|
|
34
|
+
"effect": "^3.21.0",
|
|
35
35
|
"electric-sql": "^0.12.1",
|
|
36
|
-
"expo": "^55.0.
|
|
37
|
-
"expo-sqlite": "^55.0.
|
|
36
|
+
"expo": "^55.0.9",
|
|
37
|
+
"expo-sqlite": "^55.0.11",
|
|
38
38
|
"partykit": "^0.0.115",
|
|
39
39
|
"partysocket": "^1.1.16",
|
|
40
40
|
"postgres": "^3.4.8",
|
|
41
41
|
"react": "^19.2.4",
|
|
42
42
|
"react-dom": "^19.2.4",
|
|
43
|
-
"react-native-mmkv": "4.
|
|
43
|
+
"react-native-mmkv": "4.3.0",
|
|
44
44
|
"react-native-sqlite-storage": "^6.0.1",
|
|
45
45
|
"sqlite3": "^6.0.1",
|
|
46
|
-
"svelte": "^5.
|
|
47
|
-
"valibot": "^1.
|
|
48
|
-
"ws": "^8.
|
|
49
|
-
"yjs": "^13.6.
|
|
46
|
+
"svelte": "^5.55.1",
|
|
47
|
+
"valibot": "^1.3.1",
|
|
48
|
+
"ws": "^8.20.0",
|
|
49
|
+
"yjs": "^13.6.30",
|
|
50
50
|
"zod": "^4.3.6"
|
|
51
51
|
},
|
|
52
52
|
"peerDependenciesMeta": {
|
|
@@ -441,7 +441,7 @@ const createCustomPersister = (
|
|
|
441
441
|
return objFreeze(persister);
|
|
442
442
|
};
|
|
443
443
|
|
|
444
|
-
const getETag = (response) => response.headers.get('ETag');
|
|
444
|
+
const getETag = (response) => response.headers.get('ETag') ?? '';
|
|
445
445
|
const createRemotePersister = (
|
|
446
446
|
store,
|
|
447
447
|
loadUrl,
|
|
@@ -449,9 +449,11 @@ const createRemotePersister = (
|
|
|
449
449
|
autoLoadIntervalSeconds = 5,
|
|
450
450
|
onIgnoredError,
|
|
451
451
|
) => {
|
|
452
|
-
let lastEtag;
|
|
452
|
+
let lastEtag = '';
|
|
453
453
|
const getPersisted = async () => {
|
|
454
|
-
const response = await fetch(loadUrl
|
|
454
|
+
const response = await fetch(loadUrl, {
|
|
455
|
+
headers: {'If-None-Match': lastEtag},
|
|
456
|
+
});
|
|
455
457
|
lastEtag = getETag(response);
|
|
456
458
|
return jsonParse(await response.text());
|
|
457
459
|
};
|
|
@@ -465,14 +467,10 @@ const createRemotePersister = (
|
|
|
465
467
|
startInterval(async () => {
|
|
466
468
|
const response = await fetch(loadUrl, {
|
|
467
469
|
method: 'HEAD',
|
|
468
|
-
headers: {'If-None-Match': lastEtag
|
|
470
|
+
headers: {'If-None-Match': lastEtag},
|
|
469
471
|
});
|
|
470
472
|
const currentEtag = getETag(response);
|
|
471
|
-
if (
|
|
472
|
-
!isNull(lastEtag) &&
|
|
473
|
-
!isNull(currentEtag) &&
|
|
474
|
-
currentEtag != lastEtag
|
|
475
|
-
) {
|
|
473
|
+
if (currentEtag != lastEtag) {
|
|
476
474
|
lastEtag = currentEtag;
|
|
477
475
|
listener();
|
|
478
476
|
}
|
|
@@ -441,7 +441,7 @@ const createCustomPersister = (
|
|
|
441
441
|
return objFreeze(persister);
|
|
442
442
|
};
|
|
443
443
|
|
|
444
|
-
const getETag = (response) => response.headers.get('ETag');
|
|
444
|
+
const getETag = (response) => response.headers.get('ETag') ?? '';
|
|
445
445
|
const createRemotePersister = (
|
|
446
446
|
store,
|
|
447
447
|
loadUrl,
|
|
@@ -449,9 +449,11 @@ const createRemotePersister = (
|
|
|
449
449
|
autoLoadIntervalSeconds = 5,
|
|
450
450
|
onIgnoredError,
|
|
451
451
|
) => {
|
|
452
|
-
let lastEtag;
|
|
452
|
+
let lastEtag = '';
|
|
453
453
|
const getPersisted = async () => {
|
|
454
|
-
const response = await fetch(loadUrl
|
|
454
|
+
const response = await fetch(loadUrl, {
|
|
455
|
+
headers: {'If-None-Match': lastEtag},
|
|
456
|
+
});
|
|
455
457
|
lastEtag = getETag(response);
|
|
456
458
|
return jsonParse(await response.text());
|
|
457
459
|
};
|
|
@@ -465,14 +467,10 @@ const createRemotePersister = (
|
|
|
465
467
|
startInterval(async () => {
|
|
466
468
|
const response = await fetch(loadUrl, {
|
|
467
469
|
method: 'HEAD',
|
|
468
|
-
headers: {'If-None-Match': lastEtag
|
|
470
|
+
headers: {'If-None-Match': lastEtag},
|
|
469
471
|
});
|
|
470
472
|
const currentEtag = getETag(response);
|
|
471
|
-
if (
|
|
472
|
-
!isNull(lastEtag) &&
|
|
473
|
-
!isNull(currentEtag) &&
|
|
474
|
-
currentEtag != lastEtag
|
|
475
|
-
) {
|
|
473
|
+
if (currentEtag != lastEtag) {
|
|
476
474
|
lastEtag = currentEtag;
|
|
477
475
|
listener();
|
|
478
476
|
}
|
package/readme.md
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
📦 Creating your project...
|
|
7
7
|
```
|
|
8
8
|
|
|
9
|
-
<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">6.2kB - 13.2kB</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 src="https://beta.tinybase.org/react.svg?asImg" width="48"> React</a></div><div><a href="https://beta.tinybase.org/api/persister-indexed-db/functions/creation/createindexeddbpersister"><img src="https://beta.tinybase.org/indexeddb.svg?asImg" width="48"> IndexedDB</a></div><div><a href="https://beta.tinybase.org/api/persister-browser"><img src="https://beta.tinybase.org/browser.svg?asImg" width="48"> OPFS</a></div><div><a href="https://beta.tinybase.org/guides/integrations/cloudflare-durable-objects"><img src="https://beta.tinybase.org/cloudflare.svg?asImg" width="48"> Cloudflare</a></div><div><a href="https://beta.tinybase.org/guides/schemas-and-persistence/database-persistence"><img src="https://beta.tinybase.org/postgresql.svg?asImg" width="48"> PostgreSQL</a></div><div><a href="https://beta.tinybase.org/guides/schemas-and-persistence/database-persistence"><img src="https://beta.tinybase.org/pglite.svg?asImg" width="48"> PGlite</a></div><div><a href="https://beta.tinybase.org/guides/schemas-and-persistence/database-persistence"><img src="https://beta.tinybase.org/sqlite.svg?asImg" width="48"> SQLite</a></div><div><a href="https://beta.tinybase.org/guides/schemas-and-persistence/database-persistence"><img src="https://beta.tinybase.org/bun.svg?asImg" width="48"> Bun SQLite</a></div><div><a href="https://beta.tinybase.org/guides/schemas-and-persistence/database-persistence"><img src="https://beta.tinybase.org/expo.svg?asImg" width="48"> Expo SQLite</a></div><div><a href="https://beta.tinybase.org/guides/schemas-and-persistence/database-persistence"><img src="https://beta.tinybase.org/electric.svg?asImg" width="48"> ElectricSQL</a></div><div><a href="https://beta.tinybase.org/guides/schemas-and-persistence/database-persistence"><img src="https://beta.tinybase.org/turso.svg?asImg" width="48"> Turso</a></div><div><a href="https://beta.tinybase.org/guides/schemas-and-persistence/database-persistence"><img src="https://beta.tinybase.org/powersync.svg?asImg" width="48"> PowerSync</a></div><div><a href="https://beta.tinybase.org/api/persister-partykit-client"><img src="https://beta.tinybase.org/partykit.svg?asImg" width="48"> PartyKit</a></div><div><a href="https://beta.tinybase.org/api/persister-yjs/functions/creation/createyjspersister"><img src="https://beta.tinybase.org/yjs.svg?asImg" width="48"> YJS</a></div><div><a href="https://beta.tinybase.org/api/persister-cr-sqlite-wasm"><img src="https://beta.tinybase.org/crsqlite.png" width="48"> CR-SQLite</a></div><div><a href="https://beta.tinybase.org/api/persister-automerge"><img src="https://beta.tinybase.org/automerge.svg?asImg" width="48"> Automerge</a></div><div><a href="https://beta.tinybase.org/api/schematizer-zod/functions/creation/createzodschematizer"><img src="https://beta.tinybase.org/zod.svg?asImg" width="48"> Zod</a></div><div><a href="https://beta.tinybase.org/api/schematizer-typebox/functions/creation/createtypeboxschematizer"><img src="https://beta.tinybase.org/typebox.svg?asImg" width="48"> TypeBox</a></div><div><a href="https://beta.tinybase.org/api/schematizer-valibot/functions/creation/createvalibotschematizer"><img src="https://beta.tinybase.org/valibot.svg?asImg" width="48"> Valibot</a></div><div><a href="https://beta.tinybase.org/api/schematizer-arktype/functions/creation/createarktypeschematizer"><img src="https://beta.tinybase.org/arktype.svg?asImg" width="48"> ArkType</a></div><div><a href="https://beta.tinybase.org/api/schematizer-yup/functions/creation/createyupschematizer"><img src="https://beta.tinybase.org/yup.svg?asImg" width="48"> Yup</a></div><div><a href="https://beta.tinybase.org/api/schematizer-effect/functions/creation/createeffectschematizer"><img src="https://beta.tinybase.org/effect.svg?asImg" width="48"> Effect</a></div><p>(Baffled by all these logos? Check out our <a href="https://beta.tinybase.org/guides/the-basics/architectural-options">architectural options</a> guide to make sense of it all!)</p></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://bsky.app/profile/tinybase.bsky.social"><img src="https://img.shields.io/badge/Bluesky-Follow-blue?style=for-the-badge&logo=bluesky&logoColor=%23fff&color=%23333&labelColor=%230285FF"> </a><a href="https://x.com/tinybasejs" target="_blank"><img src="https://img.shields.io/badge/%2F%20Twitter-Follow-blue?style=for-the-badge&logo=x&logoColor=%23fff&color=%23333&labelColor=%23000"> </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><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=Vitest&logoColor=%23fff&color=%23333&labelColor=%2387c305"> </a><a href="https://www.npmjs.com/package/tinybase/v/8.1.0-beta.
|
|
9
|
+
<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">6.2kB - 13.2kB</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 src="https://beta.tinybase.org/react.svg?asImg" width="48"> React</a></div><div><a href="https://beta.tinybase.org/api/persister-indexed-db/functions/creation/createindexeddbpersister"><img src="https://beta.tinybase.org/indexeddb.svg?asImg" width="48"> IndexedDB</a></div><div><a href="https://beta.tinybase.org/api/persister-browser"><img src="https://beta.tinybase.org/browser.svg?asImg" width="48"> OPFS</a></div><div><a href="https://beta.tinybase.org/guides/integrations/cloudflare-durable-objects"><img src="https://beta.tinybase.org/cloudflare.svg?asImg" width="48"> Cloudflare</a></div><div><a href="https://beta.tinybase.org/guides/schemas-and-persistence/database-persistence"><img src="https://beta.tinybase.org/postgresql.svg?asImg" width="48"> PostgreSQL</a></div><div><a href="https://beta.tinybase.org/guides/schemas-and-persistence/database-persistence"><img src="https://beta.tinybase.org/pglite.svg?asImg" width="48"> PGlite</a></div><div><a href="https://beta.tinybase.org/guides/schemas-and-persistence/database-persistence"><img src="https://beta.tinybase.org/sqlite.svg?asImg" width="48"> SQLite</a></div><div><a href="https://beta.tinybase.org/guides/schemas-and-persistence/database-persistence"><img src="https://beta.tinybase.org/bun.svg?asImg" width="48"> Bun SQLite</a></div><div><a href="https://beta.tinybase.org/guides/schemas-and-persistence/database-persistence"><img src="https://beta.tinybase.org/expo.svg?asImg" width="48"> Expo SQLite</a></div><div><a href="https://beta.tinybase.org/guides/schemas-and-persistence/database-persistence"><img src="https://beta.tinybase.org/electric.svg?asImg" width="48"> ElectricSQL</a></div><div><a href="https://beta.tinybase.org/guides/schemas-and-persistence/database-persistence"><img src="https://beta.tinybase.org/turso.svg?asImg" width="48"> Turso</a></div><div><a href="https://beta.tinybase.org/guides/schemas-and-persistence/database-persistence"><img src="https://beta.tinybase.org/powersync.svg?asImg" width="48"> PowerSync</a></div><div><a href="https://beta.tinybase.org/api/persister-partykit-client"><img src="https://beta.tinybase.org/partykit.svg?asImg" width="48"> PartyKit</a></div><div><a href="https://beta.tinybase.org/api/persister-yjs/functions/creation/createyjspersister"><img src="https://beta.tinybase.org/yjs.svg?asImg" width="48"> YJS</a></div><div><a href="https://beta.tinybase.org/api/persister-cr-sqlite-wasm"><img src="https://beta.tinybase.org/crsqlite.png" width="48"> CR-SQLite</a></div><div><a href="https://beta.tinybase.org/api/persister-automerge"><img src="https://beta.tinybase.org/automerge.svg?asImg" width="48"> Automerge</a></div><div><a href="https://beta.tinybase.org/api/schematizer-zod/functions/creation/createzodschematizer"><img src="https://beta.tinybase.org/zod.svg?asImg" width="48"> Zod</a></div><div><a href="https://beta.tinybase.org/api/schematizer-typebox/functions/creation/createtypeboxschematizer"><img src="https://beta.tinybase.org/typebox.svg?asImg" width="48"> TypeBox</a></div><div><a href="https://beta.tinybase.org/api/schematizer-valibot/functions/creation/createvalibotschematizer"><img src="https://beta.tinybase.org/valibot.svg?asImg" width="48"> Valibot</a></div><div><a href="https://beta.tinybase.org/api/schematizer-arktype/functions/creation/createarktypeschematizer"><img src="https://beta.tinybase.org/arktype.svg?asImg" width="48"> ArkType</a></div><div><a href="https://beta.tinybase.org/api/schematizer-yup/functions/creation/createyupschematizer"><img src="https://beta.tinybase.org/yup.svg?asImg" width="48"> Yup</a></div><div><a href="https://beta.tinybase.org/api/schematizer-effect/functions/creation/createeffectschematizer"><img src="https://beta.tinybase.org/effect.svg?asImg" width="48"> Effect</a></div><p>(Baffled by all these logos? Check out our <a href="https://beta.tinybase.org/guides/the-basics/architectural-options">architectural options</a> guide to make sense of it all!)</p></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://bsky.app/profile/tinybase.bsky.social"><img src="https://img.shields.io/badge/Bluesky-Follow-blue?style=for-the-badge&logo=bluesky&logoColor=%23fff&color=%23333&labelColor=%230285FF"> </a><a href="https://x.com/tinybasejs" target="_blank"><img src="https://img.shields.io/badge/%2F%20Twitter-Follow-blue?style=for-the-badge&logo=x&logoColor=%23fff&color=%23333&labelColor=%23000"> </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><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=Vitest&logoColor=%23fff&color=%23333&labelColor=%2387c305"> </a><a href="https://www.npmjs.com/package/tinybase/v/8.1.0-beta.3" 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/the-essentials/creating-stores/store/"><code>Store</code></a> requires just a simple call to the <a href="https://beta.tinybase.org/api/the-essentials/creating-stores/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>
|
|
10
10
|
|
|
11
11
|
```js
|
|
12
12
|
import {createStore} from 'tinybase';
|