tinybase 4.6.1 → 4.6.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/persisters/persister-expo-sqlite-next.cjs +1 -1
- package/lib/cjs/persisters/persister-expo-sqlite-next.cjs.gz +0 -0
- package/lib/cjs/ui-react.cjs +1 -1
- package/lib/cjs/ui-react.cjs.gz +0 -0
- package/lib/cjs-es6/persisters/persister-expo-sqlite-next.cjs +1 -1
- package/lib/cjs-es6/persisters/persister-expo-sqlite-next.cjs.gz +0 -0
- package/lib/cjs-es6/ui-react.cjs +1 -1
- package/lib/cjs-es6/ui-react.cjs.gz +0 -0
- package/lib/debug/persisters/persister-cr-sqlite-wasm.js +1 -3
- package/lib/debug/persisters/persister-electric-sql.js +1 -3
- package/lib/debug/persisters/persister-expo-sqlite-next.js +2 -4
- package/lib/debug/persisters/persister-expo-sqlite.js +1 -3
- package/lib/debug/persisters/persister-sqlite-wasm.js +1 -3
- package/lib/debug/persisters/persister-sqlite3.js +1 -3
- package/lib/debug/tools.js +9 -37
- package/lib/debug/ui-react.js +1 -1
- package/lib/es6/persisters/persister-expo-sqlite-next.js +1 -1
- package/lib/es6/persisters/persister-expo-sqlite-next.js.gz +0 -0
- package/lib/es6/ui-react.js +1 -1
- package/lib/es6/ui-react.js.gz +0 -0
- package/lib/persisters/persister-expo-sqlite-next.js +1 -1
- package/lib/persisters/persister-expo-sqlite-next.js.gz +0 -0
- package/lib/types/persisters/persister-expo-sqlite-next.d.ts +3 -3
- package/lib/types/with-schemas/internal/queries.d.ts +4 -3
- package/lib/types/with-schemas/internal/store.d.ts +4 -3
- package/lib/types/with-schemas/persisters/persister-expo-sqlite-next.d.ts +4 -4
- package/lib/ui-react.js +1 -1
- package/lib/ui-react.js.gz +0 -0
- package/lib/umd/persisters/persister-expo-sqlite-next.js +1 -1
- package/lib/umd/persisters/persister-expo-sqlite-next.js.gz +0 -0
- package/lib/umd/ui-react.js +1 -1
- package/lib/umd/ui-react.js.gz +0 -0
- package/lib/umd-es6/persisters/persister-expo-sqlite-next.js +1 -1
- package/lib/umd-es6/persisters/persister-expo-sqlite-next.js.gz +0 -0
- package/lib/umd-es6/ui-react.js +1 -1
- package/lib/umd-es6/ui-react.js.gz +0 -0
- package/package.json +12 -12
- package/readme.md +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{addDatabaseChangeListener as a}from"expo-sqlite/next";const t=a=>typeof a,e="tinybase",s=",",n=t(""),i=(a,t)=>a.repeat(t),c=Promise,o=clearInterval,r=a=>null==a,l=(a,t,e)=>r(a)?e?.():t(a),w=a=>t(a)==n,y=(a,t,e)=>a.slice(t,e),E=a=>a.length,u=async a=>c.all(a),d="_",m="_id",v=a=>`"${a.replace(/"/g,'""')}"`,
|
|
1
|
+
import{addDatabaseChangeListener as a}from"expo-sqlite/next";const t=a=>typeof a,e="tinybase",s=",",n=t(""),i=(a,t)=>a.repeat(t),c=Promise,o=clearInterval,r=a=>null==a,l=(a,t,e)=>r(a)?e?.():t(a),w=a=>t(a)==n,y=(a,t,e)=>a.slice(t,e),E=a=>a.length,u=async a=>c.all(a),d="_",m="_id",v=a=>`"${a.replace(/"/g,'""')}"`,A="SELECT",p=(a,t="")=>a.join(t),T=(a,t)=>a.map(t),L=a=>0==E(a),f=(a,t)=>a.filter(t),N=(a,...t)=>a.push(...t),O=(a,t)=>a?.has(t)??!1,R=a=>[...a?.values()??[]],h=(a,t)=>a?.delete(t),C=Object,D=a=>C.getPrototypeOf(a),S=C.keys,g=C.freeze,I=(a=[])=>C.fromEntries(a),b=(...a)=>C.assign({},...a),F=(a,t)=>T(C.entries(a),(([a,e])=>t(e,a))),M=a=>C.values(a),$=a=>E(S(a)),_=a=>(a=>!r(a)&&l(D(a),(a=>a==C.prototype||r(D(a))),(()=>!0)))(a)&&0==$(a),P=a=>new Map(a),B=a=>[...a?.keys()??[]],H=(a,t)=>a?.get(t),x=(a,t)=>T([...a?.entries()??[]],(([a,e])=>t(e,a))),W=(a,t,e)=>r(e)?(h(a,t),a):a?.set(t,e),j=(a,t,e)=>(O(a,t)||W(a,t,e()),H(a,t)),Y=(a,t,e,s=W)=>(F(t,((t,s)=>e(a,s,t))),((a,t)=>{((a,t)=>{a?.forEach(t)})(a,((a,e)=>t(e)))})(a,(e=>((a,t)=>!r(((a,t)=>l(a,(a=>a[t])))(a,t)))(t,e)?0:s(a,e))),a),k=a=>new Set(Array.isArray(a)||r(a)?a:[a]),G=(a,t)=>a?.add(t),J=A+"*FROM",U="FROM pragma_table_",q="WHERE",z=(a,t,e)=>{const n=P();return[async()=>Y(n,I(await u(T(await a("SELECT name "+U+"list WHERE schema='main'AND type='table'AND name IN("+V(t)+")ORDER BY name",t),(async({name:t})=>[t,I(T(await a(A+" name,type "+U+"info(?)",[t]),(({name:a,type:t})=>[a,t])))])))),((a,t,e)=>W(n,t,Y(j(n,t,P),e,((a,t,e)=>{e!=H(a,t)&&W(a,t,e)}),((a,t)=>W(a,t))))),((a,t)=>W(n,t))),async(t,e)=>((a,t)=>!r(H(H(n,a),t)))(t,e)?I(f(T(await a(J+v(t)),(a=>{return[a[e],(t={...a},s=e,delete t[s],t)];var t,s})),(([a,t])=>!r(a)&&!_(t)))):{},async(t,e,i,c,o,l=!1)=>{const w=k();F(i??{},(a=>T(S(a??{}),(a=>G(w,a)))));const y=R(w);if(!l&&o&&L(y)&&O(n,t))return await a("DROP TABLE"+v(t)),void W(n,t);if(L(y)||O(n,t)){const s=H(n,t),i=k(B(s));await u([...T(y,(async e=>{h(i,e)||(await a(`ALTER TABLE${v(t)}ADD${v(e)}`),W(s,e,""))})),...!l&&c?T(R(i),(async n=>{n!=e&&(await a(`ALTER TABLE${v(t)}DROP${v(n)}`),W(s,n))})):[]])}else await a(`CREATE TABLE${v(t)}(${v(e)} PRIMARY KEY ON CONFLICT REPLACE${p(T(y,(a=>s+v(a))))});`),W(n,t,P([[e,""],...T(y,(a=>[a,""]))]));if(l)r(i)?await a("DELETE FROM"+v(t)+"WHERE 1"):await u(F(i,(async(s,n)=>{r(s)?await a("DELETE FROM"+v(t)+q+v(e)+"=?",[n]):L(y)||await K(a,t,e,S(s),[n,...M(s)])})));else if(L(y))O(n,t)&&await a("DELETE FROM"+v(t)+"WHERE 1");else{const s=f(B(H(n,t)),(a=>a!=e)),c=[],o=[];F(i??{},((a,t)=>{N(c,t,...T(s,(t=>a?.[t]))),N(o,t)})),await K(a,t,e,s,c),await a("DELETE FROM"+v(t)+q+v(e)+"NOT IN("+V(o)+")",o)}},async t=>{let s;await a("BEGIN");try{s=await t()}catch(a){e?.(a)}return await a("END"),s}]},K=async(a,t,e,n,c)=>await a("INSERT INTO"+v(t)+"("+v(e)+p(T(n,(a=>s+v(a))))+")VALUES"+y(i(`,(?${i(",?",E(n))})`,E(c)/(E(n)+1)),1)+"ON CONFLICT("+v(e)+")DO UPDATE SET"+p(T(n,(a=>v(a)+"=excluded."+v(a))),s),c),V=a=>p(T(a,(()=>"?")),s),Q=JSON.parse,X=P(),Z=P(),aa=(a,t,e,s,n,i,[c,o]=[],w=[])=>{let y,E,u,d=0,m=0;j(X,w,(()=>0)),j(Z,w,(()=>[]));const v=async a=>(2!=d&&(d=1,await A.schedule((async()=>{await a(),d=0}))),A),A={load:async(e,s)=>await v((async()=>{try{a.setContent(await t())}catch{a.setContent([e,s])}})),startAutoLoad:async(e={},n={})=>(A.stopAutoLoad(),await A.load(e,n),m=1,u=s((async(e,s)=>{if(s){const t=s();await v((async()=>a.setTransactionChanges(t)))}else await v((async()=>{try{a.setContent(e?.()??await t())}catch(a){i?.(a)}}))})),A),stopAutoLoad:()=>(m&&(n(u),u=void 0,m=0),A),save:async t=>(1!=d&&(d=2,await A.schedule((async()=>{try{await e(a.getContent,t)}catch(a){i?.(a)}d=0}))),A),startAutoSave:async()=>(await A.stopAutoSave().save(),y=a.addDidFinishTransactionListener(((a,t)=>{const[e,s]=t();_(e)&&_(s)||A.save((()=>[e,s]))})),A),stopAutoSave:()=>(l(y,a.delListener),y=void 0,A),schedule:async(...a)=>(N(H(Z,w),...a),await(async()=>{if(!H(X,w)){for(W(X,w,1);!r((a=H(Z,w),E=a.shift()));)try{await E()}catch(a){i?.(a)}W(X,w,0)}var a})(),A),getStore:()=>a,destroy:()=>A.stopAutoLoad().stopAutoSave(),getStats:()=>({})};return c&&(A[c]=()=>o),g(A)},ta="store",ea=(a,t,e,s,n,[i],c,o,r)=>{const[l,w,y,E]=z(t,c,n);return aa(a,(async()=>await E((async()=>(await l(),Q((await w(i,m))[d]?.[ta]??"null"))))),(async a=>await E((async()=>{var t;await l(),await y(i,m,{[d]:{[ta]:(t=a()??null,JSON.stringify(t,((a,t)=>t instanceof Map?C.fromEntries([...t]):t)))}},!0,!0)}))),e,s,n,[r,o],o)},sa=(a,t,e,s,n,[i,c,[o,l,w]],y,E,v)=>{const[A,p,T,L]=z(t,y,n),N=async(a,t)=>await u(x(c,(async([e,s,n,i],c)=>{const o=a[c];t&&void 0===o||await T(e,s,o,n,i,t)}))),O=async(a,t)=>l?await T(w,m,{[d]:a},!0,!0,t):null;return aa(a,(async()=>await L((async()=>{await A();const a=await(async()=>I(f(await u(x(i,(async([a,t],e)=>[a,await p(e,t)]))),(a=>!_(a[1])))))(),t=await(async()=>o?(await p(w,m))[d]:{})();return _(a)&&r(t)?void 0:[a,t]}))),(async(a,t)=>await L((async()=>{if(await A(),r(t)){const[t,e]=a();await N(t),await O(e)}else{const[a,e]=t();await N(a,!0),await O(e,!0)}}))),e,s,n,[v,E],E)},na="json",ia="autoLoadIntervalSeconds",ca="rowIdColumnName",oa="tableId",ra="tableName",la={mode:na,[ia]:1},wa={load:0,save:0,[ra]:e+"_values"},ya=(a,t,e,s)=>{const n=P();return F(a,((a,i)=>{const c=y(M(b(t,w(a)?{[e]:a}:a)),0,$(t));r(c[0])||s(i,c[0])||W(n,i,c)})),n},Ea="pragma ",ua="data_version",da="schema_version",ma=(a,t,s,n,i,c,r,l,E="getDb")=>{let u,d,v;const[p,T,L,f]=(a=>{const t=(a=>b(la,w(a)?{storeTableName:a}:a??{}))(a),s=t[ia];if(t.mode==na){const{storeTableName:a=e}=t;return[1,s,[a],k(a)]}const{tables:{load:n={},save:i={}}={},values:c={}}=t,o=y(M(b(wa,c)),0,$(wa)),r=o[2],l=k(r);return[0,s,[ya(n,{[oa]:null,[ca]:m},oa,(a=>G(l,a)&&a==r)),ya(i,{[ra]:null,[ca]:m,deleteEmptyColumns:0,deleteEmptyTable:0},ra,((a,t)=>G(l,t)&&t==r)),o],l]})(t);return(p?ea:sa)(a,c?async(a,t)=>(c(a,t),await s(a,t)):s,(a=>{return[(t=async()=>{try{const t=(await s(Ea+ua))[0][ua],e=(await s(Ea+da))[0][da],n=(await s(A+" TOTAL_CHANGES() c"))[0].c;t==(u??=t)&&e==(d??=e)&&n==(v??=n)||(a(),u=t,d=e)}catch{}},e=T,t(),setInterval(t,1e3*e)),n((t=>f.has(t)?a():0))];var t,e}),(([a,t])=>{o(a),u=d=null,i(t)}),r,L,R(f),l,E)},va=(t,e,s,n,i)=>ma(t,s,(async(a,t=[])=>await e.getAllAsync(a,t)),(t=>a((({tableName:a})=>t(a)))),(a=>a.remove()),n,i,e);export{va as createExpoSqliteNextPersister};
|
|
Binary file
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
*/
|
|
22
22
|
|
|
23
23
|
import {DatabasePersisterConfig, Persister} from '../persisters';
|
|
24
|
-
import {
|
|
24
|
+
import {SQLiteDatabase} from 'expo-sqlite/next';
|
|
25
25
|
import {Store} from '../store';
|
|
26
26
|
|
|
27
27
|
/**
|
|
@@ -54,7 +54,7 @@ export interface ExpoSqliteNextPersister extends Persister {
|
|
|
54
54
|
* @category Getter
|
|
55
55
|
* @since v4.5.0
|
|
56
56
|
*/
|
|
57
|
-
getDb():
|
|
57
|
+
getDb(): SQLiteDatabase;
|
|
58
58
|
}
|
|
59
59
|
|
|
60
60
|
/**
|
|
@@ -161,7 +161,7 @@ export interface ExpoSqliteNextPersister extends Persister {
|
|
|
161
161
|
*/
|
|
162
162
|
export function createExpoSqliteNextPersister(
|
|
163
163
|
store: Store,
|
|
164
|
-
db:
|
|
164
|
+
db: SQLiteDatabase,
|
|
165
165
|
configOrStoreTableName?: DatabasePersisterConfig | string,
|
|
166
166
|
onSqlCommand?: (sql: string, args?: any[]) => void,
|
|
167
167
|
onIgnoredError?: (error: any) => void,
|
|
@@ -8,8 +8,9 @@ export type JoinedCellIdOrId<
|
|
|
8
8
|
JoinedTableId extends TableIdFromSchema<Schema> | Id =
|
|
9
9
|
| TableIdFromSchema<Schema>
|
|
10
10
|
| Id,
|
|
11
|
-
> =
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
> =
|
|
12
|
+
JoinedTableId extends TableIdFromSchema<Schema>
|
|
13
|
+
? CellIdFromSchema<Schema, JoinedTableId>
|
|
14
|
+
: Id;
|
|
14
15
|
|
|
15
16
|
export type GetResultCell = (cellId: Id) => ResultCell;
|
|
@@ -34,9 +34,10 @@ export type DefaultCellIdFromSchema<
|
|
|
34
34
|
export type AllCellIdFromSchema<
|
|
35
35
|
Schema extends OptionalTablesSchema,
|
|
36
36
|
TableId extends TableIdFromSchema<Schema> = TableIdFromSchema<Schema>,
|
|
37
|
-
> =
|
|
38
|
-
|
|
39
|
-
|
|
37
|
+
> =
|
|
38
|
+
TableId extends TableIdFromSchema<Schema>
|
|
39
|
+
? CellIdFromSchema<Schema, TableId>
|
|
40
|
+
: never;
|
|
40
41
|
|
|
41
42
|
export type CellIsDefaultedFromSchema<
|
|
42
43
|
Schema extends OptionalTablesSchema,
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
|
|
23
23
|
import {DatabasePersisterConfig, Persister} from '../persisters';
|
|
24
24
|
import {OptionalSchemas, Store} from '../store';
|
|
25
|
-
import {
|
|
25
|
+
import {SQLiteDatabase} from 'expo-sqlite/next';
|
|
26
26
|
|
|
27
27
|
/**
|
|
28
28
|
* The ExpoSqliteNextPersister interface is a minor extension to the Persister
|
|
@@ -55,7 +55,7 @@ export interface ExpoSqliteNextPersister<Schemas extends OptionalSchemas>
|
|
|
55
55
|
* @category Getter
|
|
56
56
|
* @since v4.5.0
|
|
57
57
|
*/
|
|
58
|
-
getDb: () =>
|
|
58
|
+
getDb: () => SQLiteDatabase;
|
|
59
59
|
}
|
|
60
60
|
|
|
61
61
|
/**
|
|
@@ -68,7 +68,7 @@ export interface ExpoSqliteNextPersister<Schemas extends OptionalSchemas>
|
|
|
68
68
|
* ```ts override
|
|
69
69
|
* createExpoSqliteNextPersister(
|
|
70
70
|
* store: Store,
|
|
71
|
-
* db:
|
|
71
|
+
* db: SQLiteDatabase,
|
|
72
72
|
* configOrStoreTableName?: DatabasePersisterConfig | string,
|
|
73
73
|
* onSqlCommand?: (sql: string, args?: any[]) => void,
|
|
74
74
|
* onIgnoredError?: (error: any) => void,
|
|
@@ -174,7 +174,7 @@ export interface ExpoSqliteNextPersister<Schemas extends OptionalSchemas>
|
|
|
174
174
|
*/
|
|
175
175
|
export function createExpoSqliteNextPersister<Schemas extends OptionalSchemas>(
|
|
176
176
|
store: Store<Schemas>,
|
|
177
|
-
db:
|
|
177
|
+
db: SQLiteDatabase,
|
|
178
178
|
configOrStoreTableName?: DatabasePersisterConfig<Schemas> | string,
|
|
179
179
|
onSqlCommand?: (sql: string, args?: any[]) => void,
|
|
180
180
|
onIgnoredError?: (error: any) => void,
|
package/lib/ui-react.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import e from"react";const t=e=>typeof e,o="",s=t(o),r=t(t),d="Listener",n="Result",u="Has",I="has",i="Ids",c="Table",l=c+"s",a=c+i,p="Row",g=p+"Count",b=p+i,C="Sorted"+p+i,m="Cell",k=m+i,y="Value",w=y+"s",h=y+i,R=e=>null==e,v=(e,t,o)=>R(e)?o?.():t(e),f=e=>t(e)==s,q=e=>t(e)==r,P=()=>{},x=(e,t)=>e.map(t),S=Object.keys,L=(e,t)=>v(e,(e=>e[t])),B=(e,t)=>(delete e[t],e),{createContext:T,useContext:E,useEffect:M}=e,F=T([]),V=(e,t)=>{const o=E(F);return R(e)?o[t]:f(e)?L(o[t+1]??{},e):e},A=(e,t)=>{const o=V(e,t);return R(e)||f(e)?o:e},j=e=>S(E(F)[e]??{}),D=e=>V(e,0),H=e=>A(e,0),O=(e,t)=>{const{12:o,13:s}=E(F);M((()=>(o?.(e,t),()=>s?.(e))),[o,e,t,s])},Q=e=>V(e,2),W=e=>A(e,2),z=e=>V(e,4),G=e=>A(e,4),J=e=>V(e,6),K=e=>A(e,6),N=e=>V(e,8),U=e=>A(e,8),X=e=>V(e,10),Y=e=>A(e,10),Z=e=>e.toLowerCase();Z(d);const $="Transaction";Z($);const{useCallback:_,useEffect:ee,useMemo:te,useLayoutEffect:oe,useRef:se,useState:re}=e,de=[],ne={},ue=[[],void 0,[]],Ie=(e,t,o=de)=>{const s=te((()=>t(e)),[e,...o]);return ee((()=>()=>s.destroy()),[s]),s},ie=(e,t,o,s=de,r,d="get",n="")=>{const[,u]=re(),I=_((()=>t?.[d+e]?.(...s)??o),[t,e,...s,o]),i=se();return te((()=>i.current=I()),[I]),ce(n+e,t,((...e)=>{i.current=R(r)?I():e[r],u([])}),[I,r],s),i.current},ce=(e,t,o,s=de,r=de,...n)=>oe((()=>{const s=t?.["add"+e+d]?.(...r,o,...n);return()=>t?.delListener(s)}),[t,e,...r,...s,...n]),le=(e,t,o,s=de,r=P,d=de,...n)=>{const u=H(e);return _((e=>v(u,(s=>v(o(e,s),(o=>r(s["set"+t](...x(n,(t=>q(t)?t(e,s):t)),o),o)))))),[u,t,...s,...d,...n])},ae=(e,t,o=P,s=de,...r)=>{const d=H(e);return _((()=>o(d?.["del"+t](...r))),[d,t,...s,...r])},pe=(e,t,o)=>{const s=Y(e);return _((()=>s?.[t](o)),[s,t,o])},ge=(e,t=de)=>te(e,t),be=()=>j(1),Ce=e=>ie(l,H(e),!1,[],1,I,u),me=e=>ie(l,H(e),ne),ke=e=>ie(a,H(e),de),ye=(e,t)=>ie(c,H(t),!1,[e],2,I,u),we=(e,t)=>ie(c,H(t),ne,[e]),he=(e,t)=>ie(c+k,H(t),de,[e]),Re=(e,t,o)=>ie(c+m,H(o),!1,[e,t],3,I,u),ve=(e,t)=>ie(g,H(t),0,[e]),fe=(e,t)=>ie(b,H(t),de,[e]),qe=(e,t,o,s=0,r,d)=>ie(C,H(d),de,[e,t,o,s,r],6),Pe=(e,t,o)=>ie(p,H(o),!1,[e,t],3,I,u),xe=(e,t,o)=>ie(p,H(o),ne,[e,t]),Se=(e,t,o)=>ie(k,H(o),de,[e,t]),Le=(e,t,o,s)=>ie(m,H(s),!1,[e,t,o],4,I,u),Be=(e,t,o,s)=>ie(m,H(s),void 0,[e,t,o],4),Te=e=>ie(w,H(e),!1,[],1,I,u),Ee=e=>ie(w,H(e),ne),Me=e=>ie(h,H(e),de),Fe=(e,t)=>ie(y,H(t),!1,[e],2,I,u),Ve=(e,t)=>ie(y,H(t),void 0,[e]),Ae=(e,t,o,s,r)=>le(o,l,e,t,s,r),je=(e,t,o,s,r,d)=>le(s,c,t,o,r,d,e),De=(e,t,o,s,r,d,n)=>le(r,p,o,s,d,n,e,t),He=(e,t,o=de,s,r=P,d=de,n=!0)=>{const u=H(s);return _((o=>v(u,(s=>v(t(o,s),(t=>r(s.addRow(q(e)?e(o,s):e,t,n),s,t)))))),[u,e,...o,...d,n])},Oe=(e,t,o,s,r,d,n)=>le(r,"PartialRow",o,s,d,n,e,t),Qe=(e,t,o,s,r,d,n,u)=>le(d,m,s,r,n,u,e,t,o),We=(e,t,o,s,r)=>le(o,w,e,t,s,r),ze=(e,t,o,s,r)=>le(o,"PartialValues",e,t,s,r),Ge=(e,t,o,s,r,d)=>le(s,y,t,o,r,d,e),Je=(e,t,o)=>ae(e,l,t,o),Ke=(e,t,o,s)=>ae(t,c,o,s,e),Ne=(e,t,o,s,r)=>ae(o,p,s,r,e,t),Ue=(e,t,o,s,r,d,n)=>ae(r,m,d,n,e,t,o,s),Xe=(e,t,o)=>ae(e,w,t,o),Ye=(e,t,o,s)=>ae(t,y,o,s,e),Ze=(e,t,o,s)=>ce(u+l,H(s),e,t,[],o),$e=(e,t,o,s)=>ce(l,H(s),e,t,de,o),_e=(e,t,o,s)=>ce(a,H(s),e,t,de,o),et=(e,t,o,s,r)=>ce(u+c,H(r),t,o,[e],s),tt=(e,t,o,s,r)=>ce(c,H(r),t,o,[e],s),ot=(e,t,o,s,r)=>ce(c+k,H(r),t,o,[e],s),st=(e,t,o,s,r,d)=>ce(u+c+m,H(d),o,s,[e,t],r),rt=(e,t,o,s,r)=>ce(g,H(r),t,o,[e],s),dt=(e,t,o,s,r)=>ce(b,H(r),t,o,[e],s),nt=(e,t,o,s,r,d,n,u,I)=>ce(C,H(I),d,n,[e,t,o,s,r],u),ut=(e,t,o,s,r,d)=>ce(u+p,H(d),o,s,[e,t],r),It=(e,t,o,s,r,d)=>ce(p,H(d),o,s,[e,t],r),it=(e,t,o,s,r,d)=>ce(k,H(d),o,s,[e,t],r),ct=(e,t,o,s,r,d,n)=>ce(u+m,H(n),s,r,[e,t,o],d),lt=(e,t,o,s,r,d,n)=>ce(m,H(n),s,r,[e,t,o],d),at=(e,t,o,s)=>ce(u+w,H(s),e,t,[],o),pt=(e,t,o,s)=>ce(w,H(s),e,t,de,o),gt=(e,t,o,s)=>ce(h,H(s),e,t,de,o),bt=(e,t,o,s,r)=>ce(u+y,H(r),t,o,[e],s),Ct=(e,t,o,s,r)=>ce(y,H(r),t,o,[e],s),mt=(e,t,o)=>ce("Start"+$,H(o),e,t),kt=(e,t,o)=>ce("WillFinish"+$,H(o),e,t),yt=(e,t,o)=>ce("DidFinish"+$,H(o),e,t),wt=(e,t,o)=>Ie(e,t,o),ht=()=>j(3),Rt=e=>ie("MetricIds",W(e),de),vt=(e,t)=>ie("Metric",W(t),void 0,[e]),ft=(e,t,o,s)=>ce("Metric",W(s),t,o,[e]),qt=(e,t,o)=>Ie(e,t,o),Pt=()=>j(5),xt=(e,t)=>ie("SliceIds",G(t),de,[e]),St=e=>ie("IndexIds",G(e),de),Lt=(e,t,o)=>ie("Slice"+b,G(o),de,[e,t]),Bt=(e,t,o,s)=>ce("SliceIds",G(s),t,o,[e]),Tt=(e,t,o,s,r)=>ce("Slice"+b,G(r),o,s,[e,t]),Et=(e,t,o)=>Ie(e,t,o),Mt=()=>j(7),Ft=e=>ie("RelationshipIds",K(e),de),Vt=(e,t,o)=>ie("RemoteRowId",K(o),void 0,[e,t]),At=(e,t,o)=>ie("Local"+b,K(o),de,[e,t]),jt=(e,t,o)=>ie("Linked"+b,K(o),de,[e,t]),Dt=(e,t,o,s,r)=>ce("RemoteRowId",K(r),o,s,[e,t]),Ht=(e,t,o,s,r)=>ce("Local"+b,K(r),o,s,[e,t]),Ot=(e,t,o,s,r)=>ce("Linked"+b,K(r),o,s,[e,t]),Qt=(e,t,o)=>Ie(e,t,o),Wt=()=>j(9),zt=e=>ie("QueryIds",U(e),de),Gt=(e,t)=>ie(n+c,U(t),ne,[e]),Jt=(e,t)=>ie(n+c+k,U(t),de,[e]),Kt=(e,t)=>ie(n+g,U(t),0,[e]),Nt=(e,t)=>ie(n+b,U(t),de,[e]),Ut=(e,t,o,s=0,r,d)=>ie(n+C,U(d),de,[e,t,o,s,r],6),Xt=(e,t,o)=>ie(n+p,U(o),ne,[e,t]),Yt=(e,t,o)=>ie(n+k,U(o),de,[e,t]),Zt=(e,t,o,s)=>ie(n+m,U(s),void 0,[e,t,o]),$t=(e,t,o,s)=>ce(n+c,U(s),t,o,[e]),_t=(e,t,o,s)=>ce(n+c+k,U(s),t,o,[e]),eo=(e,t,o,s)=>ce(n+g,U(s),t,o,[e]),to=(e,t,o,s)=>ce(n+b,U(s),t,o,[e]),oo=(e,t,o,s,r,d,u,I)=>ce(n+C,U(I),d,u,[e,t,o,s,r]),so=(e,t,o,s,r)=>ce(n+p,U(r),o,s,[e,t]),ro=(e,t,o,s,r)=>ce(n+k,U(r),o,s,[e,t]),no=(e,t,o,s,r,d)=>ce(n+m,U(d),s,r,[e,t,o]),uo=(e,t,o)=>Ie(e,t,o),Io=()=>j(11),io=e=>ie("CheckpointIds",Y(e),ue),co=(e,t)=>ie("Checkpoint",Y(t),void 0,[e]),lo=(e=P,t=de,o,s=P,r=de)=>{const d=Y(o);return _((t=>v(d,(o=>{const r=e(t);s(o.addCheckpoint(r),o,r)}))),[d,...t,...r])},ao=e=>pe(e,"goBackward"),po=e=>pe(e,"goForward"),go=(e,t=de,o,s=P,r=de)=>{const d=Y(o);return _((t=>v(d,(o=>v(e(t),(e=>s(o.goTo(e),e)))))),[d,...t,...r])},bo=e=>{const t=Y(e),[s,r]=io(t);return[(d=s,!(0==d.length)),ao(t),r,v(r,(e=>t?.getCheckpoint(e)))??o];var d},Co=e=>{const t=Y(e),[,,[s]]=io(t);return[!R(s),po(t),s,v(s,(e=>t?.getCheckpoint(e)))??o]},mo=(e,t,o)=>ce("CheckpointIds",Y(o),e,t),ko=(e,t,o,s)=>ce("Checkpoint",Y(s),t,o,[e]),yo=(e,t,o=de,s,r=de,d,n=de)=>{const[,u]=re(),I=te((()=>t(e)),[e,...o]);return ee((()=>((async()=>{s&&(await s(I),u([]))})(),()=>{I?.destroy(),d?.(I)})),[I,...r,...n]),I},{PureComponent:wo,Fragment:ho,createElement:Ro,useCallback:vo,useLayoutEffect:fo,useRef:qo,useState:Po}=e,xo=(e,...t)=>R(e)?{}:e(...t),So=(e,t)=>[e,e?.getStore(),e?.getLocalTableId(t),e?.getRemoteTableId(t)],{useCallback:Lo,useContext:Bo,useMemo:To,useState:Eo}=e,Mo=({tableId:e,store:t,rowComponent:o=Oo,getRowComponentProps:s,customCellIds:r,separator:d,debugIds:n},u)=>Do(x(u,(d=>Ro(o,{...xo(s,d),key:d,tableId:e,rowId:d,customCellIds:r,store:t,debugIds:n}))),d,n,e),Fo=({queryId:e,queries:t,resultRowComponent:o=_o,getResultRowComponentProps:s,separator:r,debugIds:d},n)=>Do(x(n,(r=>Ro(o,{...xo(s,r),key:r,queryId:e,rowId:r,queries:t,debugIds:d}))),r,d,e),Vo=({relationshipId:e,relationships:t,rowComponent:o=Oo,getRowComponentProps:s,separator:r,debugIds:d},n,u)=>{const[I,i,c]=So(K(t),e),l=n(e,u,I);return Do(x(l,(e=>Ro(o,{...xo(s,e),key:e,tableId:c,rowId:e,store:i,debugIds:d}))),r,d,u)},Ao=e=>({checkpoints:t,checkpointComponent:o=os,getCheckpointComponentProps:s,separator:r,debugIds:d})=>{const n=Y(t);return Do(x(e(io(n)),(e=>Ro(o,{...xo(s,e),key:e,checkpoints:n,checkpointId:e,debugIds:d}))),r)},jo=({store:e,storesById:t,metrics:o,metricsById:s,indexes:r,indexesById:d,relationships:n,relationshipsById:u,queries:I,queriesById:i,checkpoints:c,checkpointsById:l,children:a})=>{const p=Bo(F),[g,b]=Eo({}),C=Lo(((e,t)=>b((o=>L(o,e)==t?o:{...o,[e]:t}))),[]),m=Lo((e=>b((t=>({...B(t,e)})))),[]);return Ro(F.Provider,{value:To((()=>[e??p[0],{...p[1],...t,...g},o??p[2],{...p[3],...s},r??p[4],{...p[5],...d},n??p[6],{...p[7],...u},I??p[8],{...p[9],...i},c??p[10],{...p[11],...l},C,m]),[e,t,g,o,s,r,d,n,u,I,i,c,l,p,C,m])},a)},Do=(e,t,o,s)=>{const r=R(t)||!Array.isArray(e)?e:x(e,((e,o)=>o>0?[t,e]:e));return o?[s,":{",r,"}"]:r},Ho=({tableId:e,rowId:t,cellId:s,store:r,debugIds:d})=>Do(o+(Be(e,t,s,r)??o),void 0,d,s),Oo=({tableId:e,rowId:t,store:o,cellComponent:s=Ho,getCellComponentProps:r,customCellIds:d,separator:n,debugIds:u})=>Do(x(((e,t,o,s)=>{const r=Se(t,o,s);return e??r})(d,e,t,o),(d=>Ro(s,{...xo(r,d),key:d,tableId:e,rowId:t,cellId:d,store:o,debugIds:u}))),n,u,t),Qo=e=>Mo(e,fe(e.tableId,e.store)),Wo=({cellId:e,descending:t,offset:o,limit:s,...r})=>Mo(r,qe(r.tableId,e,t,o,s,r.store)),zo=({store:e,tableComponent:t=Qo,getTableComponentProps:o,separator:s,debugIds:r})=>Do(x(ke(e),(s=>Ro(t,{...xo(o,s),key:s,tableId:s,store:e,debugIds:r}))),s),Go=({valueId:e,store:t,debugIds:s})=>Do(o+(Ve(e,t)??o),void 0,s,e),Jo=({store:e,valueComponent:t=Go,getValueComponentProps:o,separator:s,debugIds:r})=>Do(x(Me(e),(s=>Ro(t,{...xo(o,s),key:s,valueId:s,store:e,debugIds:r}))),s),Ko=({metricId:e,metrics:t,debugIds:s})=>Do(vt(e,t)??o,void 0,s,e),No=({indexId:e,sliceId:t,indexes:o,rowComponent:s=Oo,getRowComponentProps:r,separator:d,debugIds:n})=>{const[u,I,i]=((e,t)=>[e,e?.getStore(),e?.getTableId(t)])(G(o),e),c=Lt(e,t,u);return Do(x(c,(e=>Ro(s,{...xo(r,e),key:e,tableId:i,rowId:e,store:I,debugIds:n}))),d,n,t)},Uo=({indexId:e,indexes:t,sliceComponent:o=No,getSliceComponentProps:s,separator:r,debugIds:d})=>Do(x(xt(e,t),(r=>Ro(o,{...xo(s,r),key:r,indexId:e,sliceId:r,indexes:t,debugIds:d}))),r,d,e),Xo=({relationshipId:e,localRowId:t,relationships:o,rowComponent:s=Oo,getRowComponentProps:r,debugIds:d})=>{const[n,u,,I]=So(K(o),e),i=Vt(e,t,n);return Do(R(I)||R(i)?null:Ro(s,{...xo(r,i),key:i,tableId:I,rowId:i,store:u,debugIds:d}),void 0,d,t)},Yo=e=>Vo(e,At,e.remoteRowId),Zo=e=>Vo(e,jt,e.firstRowId),$o=({queryId:e,rowId:t,cellId:s,queries:r,debugIds:d})=>Do(o+(Zt(e,t,s,r)??o),void 0,d,s),_o=({queryId:e,rowId:t,queries:o,resultCellComponent:s=$o,getResultCellComponentProps:r,separator:d,debugIds:n})=>Do(x(Yt(e,t,o),(d=>Ro(s,{...xo(r,d),key:d,queryId:e,rowId:t,cellId:d,queries:o,debugIds:n}))),d,n,t),es=e=>Fo(e,Nt(e.queryId,e.queries)),ts=({cellId:e,descending:t,offset:o,limit:s,...r})=>Fo(r,Ut(r.queryId,e,t,o,s,r.queries)),os=({checkpoints:e,checkpointId:t,debugIds:s})=>Do(co(t,e)??o,void 0,s,t),ss=Ao((e=>e[0])),rs=Ao((e=>R(e[1])?[]:[e[1]])),ds=Ao((e=>e[2]));export{ss as BackwardCheckpointsView,Ho as CellView,os as CheckpointView,rs as CurrentCheckpointView,ds as ForwardCheckpointsView,Uo as IndexView,Zo as LinkedRowsView,Yo as LocalRowsView,Ko as MetricView,jo as Provider,Xo as RemoteRowView,$o as ResultCellView,_o as ResultRowView,ts as ResultSortedTableView,es as ResultTableView,Oo as RowView,No as SliceView,Wo as SortedTableView,Qo as TableView,zo as TablesView,Go as ValueView,Jo as ValuesView,He as useAddRowCallback,Be as useCell,Se as useCellIds,it as useCellIdsListener,lt as useCellListener,co as useCheckpoint,io as useCheckpointIds,mo as useCheckpointIdsListener,ko as useCheckpointListener,X as useCheckpoints,Io as useCheckpointsIds,Y as useCheckpointsOrCheckpointsById,uo as useCreateCheckpoints,qt as useCreateIndexes,wt as useCreateMetrics,yo as useCreatePersister,Qt as useCreateQueries,Et as useCreateRelationships,ge as useCreateStore,Ue as useDelCellCallback,Ne as useDelRowCallback,Ke as useDelTableCallback,Je as useDelTablesCallback,Ye as useDelValueCallback,Xe as useDelValuesCallback,yt as useDidFinishTransactionListener,ao as useGoBackwardCallback,po as useGoForwardCallback,go as useGoToCallback,Le as useHasCell,ct as useHasCellListener,Pe as useHasRow,ut as useHasRowListener,ye as useHasTable,Re as useHasTableCell,st as useHasTableCellListener,et as useHasTableListener,Ce as useHasTables,Ze as useHasTablesListener,Fe as useHasValue,bt as useHasValueListener,Te as useHasValues,at as useHasValuesListener,St as useIndexIds,z as useIndexes,Pt as useIndexesIds,G as useIndexesOrIndexesById,jt as useLinkedRowIds,Ot as useLinkedRowIdsListener,At as useLocalRowIds,Ht as useLocalRowIdsListener,vt as useMetric,Rt as useMetricIds,ft as useMetricListener,Q as useMetrics,ht as useMetricsIds,W as useMetricsOrMetricsById,O as useProvideStore,N as useQueries,Wt as useQueriesIds,U as useQueriesOrQueriesById,zt as useQueryIds,Co as useRedoInformation,Ft as useRelationshipIds,J as useRelationships,Mt as useRelationshipsIds,K as useRelationshipsOrRelationshipsById,Vt as useRemoteRowId,Dt as useRemoteRowIdListener,Zt as useResultCell,Yt as useResultCellIds,ro as useResultCellIdsListener,no as useResultCellListener,Xt as useResultRow,Kt as useResultRowCount,eo as useResultRowCountListener,Nt as useResultRowIds,to as useResultRowIdsListener,so as useResultRowListener,Ut as useResultSortedRowIds,oo as useResultSortedRowIdsListener,Gt as useResultTable,Jt as useResultTableCellIds,_t as useResultTableCellIdsListener,$t as useResultTableListener,xe as useRow,ve as useRowCount,rt as useRowCountListener,fe as useRowIds,dt as useRowIdsListener,It as useRowListener,Qe as useSetCellCallback,lo as useSetCheckpointCallback,Oe as useSetPartialRowCallback,ze as useSetPartialValuesCallback,De as useSetRowCallback,je as useSetTableCallback,Ae as useSetTablesCallback,Ge as useSetValueCallback,We as useSetValuesCallback,xt as useSliceIds,Bt as useSliceIdsListener,Lt as useSliceRowIds,Tt as useSliceRowIdsListener,qe as useSortedRowIds,nt as useSortedRowIdsListener,mt as useStartTransactionListener,D as useStore,be as useStoreIds,H as useStoreOrStoreById,we as useTable,he as useTableCellIds,ot as useTableCellIdsListener,ke as useTableIds,_e as useTableIdsListener,tt as useTableListener,me as useTables,$e as useTablesListener,bo as useUndoInformation,Ve as useValue,Me as useValueIds,gt as useValueIdsListener,Ct as useValueListener,Ee as useValues,pt as useValuesListener,kt as useWillFinishTransactionListener};
|
|
1
|
+
import e from"react";const t=e=>typeof e,o="",s=t(o),r=t(t),d="Listener",n="Result",u="Has",I="has",i="Ids",c="Table",l=c+"s",a=c+i,p="Row",g=p+"Count",b=p+i,C="Sorted"+p+i,m="Cell",k=m+i,y="Value",w=y+"s",h=y+i,R=e=>null==e,v=(e,t,o)=>R(e)?o?.():t(e),f=e=>t(e)==s,q=e=>t(e)==r,P=()=>{},x=(e,t)=>e.map(t),S=Object.keys,L=(e,t)=>v(e,(e=>e[t])),B=(e,t)=>(delete e[t],e),{createContext:T,useContext:E,useEffect:M}=e,F=T([]),V=(e,t)=>{const o=E(F);return R(e)?o[t]:f(e)?L(o[t+1]??{},e):e},A=(e,t)=>{const o=V(e,t);return R(e)||f(e)?o:e},j=e=>S(E(F)[e]??{}),D=e=>V(e,0),H=e=>A(e,0),O=(e,t)=>{const{12:o,13:s}=E(F);M((()=>(o?.(e,t),()=>s?.(e))),[o,e,t,s])},Q=e=>V(e,2),W=e=>A(e,2),z=e=>V(e,4),G=e=>A(e,4),J=e=>V(e,6),K=e=>A(e,6),N=e=>V(e,8),U=e=>A(e,8),X=e=>V(e,10),Y=e=>A(e,10),Z=e=>e.toLowerCase();Z(d);const $="Transaction";Z($);const{useCallback:_,useEffect:ee,useMemo:te,useLayoutEffect:oe,useRef:se,useState:re}=e,de=[],ne={},ue=[[],void 0,[]],Ie=(e,t,o=de)=>{const s=te((()=>t(e)),[e,...o]);return ee((()=>()=>s.destroy()),[s]),s},ie=(e,t,o,s=de,r,d="get",n="")=>{const[,u]=re(),I=_((()=>t?.[d+e]?.(...s)??o),[t,d,e,...s,o]),i=se();return te((()=>i.current=I()),[I]),ce(n+e,t,((...e)=>{i.current=R(r)?I():e[r],u([])}),[I,r],s),i.current},ce=(e,t,o,s=de,r=de,...n)=>oe((()=>{const s=t?.["add"+e+d]?.(...r,o,...n);return()=>t?.delListener(s)}),[t,e,...r,...s,...n]),le=(e,t,o,s=de,r=P,d=de,...n)=>{const u=H(e);return _((e=>v(u,(s=>v(o(e,s),(o=>r(s["set"+t](...x(n,(t=>q(t)?t(e,s):t)),o),o)))))),[u,t,...s,...d,...n])},ae=(e,t,o=P,s=de,...r)=>{const d=H(e);return _((()=>o(d?.["del"+t](...r))),[d,t,...s,...r])},pe=(e,t,o)=>{const s=Y(e);return _((()=>s?.[t](o)),[s,t,o])},ge=(e,t=de)=>te(e,t),be=()=>j(1),Ce=e=>ie(l,H(e),!1,[],1,I,u),me=e=>ie(l,H(e),ne),ke=e=>ie(a,H(e),de),ye=(e,t)=>ie(c,H(t),!1,[e],2,I,u),we=(e,t)=>ie(c,H(t),ne,[e]),he=(e,t)=>ie(c+k,H(t),de,[e]),Re=(e,t,o)=>ie(c+m,H(o),!1,[e,t],3,I,u),ve=(e,t)=>ie(g,H(t),0,[e]),fe=(e,t)=>ie(b,H(t),de,[e]),qe=(e,t,o,s=0,r,d)=>ie(C,H(d),de,[e,t,o,s,r],6),Pe=(e,t,o)=>ie(p,H(o),!1,[e,t],3,I,u),xe=(e,t,o)=>ie(p,H(o),ne,[e,t]),Se=(e,t,o)=>ie(k,H(o),de,[e,t]),Le=(e,t,o,s)=>ie(m,H(s),!1,[e,t,o],4,I,u),Be=(e,t,o,s)=>ie(m,H(s),void 0,[e,t,o],4),Te=e=>ie(w,H(e),!1,[],1,I,u),Ee=e=>ie(w,H(e),ne),Me=e=>ie(h,H(e),de),Fe=(e,t)=>ie(y,H(t),!1,[e],2,I,u),Ve=(e,t)=>ie(y,H(t),void 0,[e]),Ae=(e,t,o,s,r)=>le(o,l,e,t,s,r),je=(e,t,o,s,r,d)=>le(s,c,t,o,r,d,e),De=(e,t,o,s,r,d,n)=>le(r,p,o,s,d,n,e,t),He=(e,t,o=de,s,r=P,d=de,n=!0)=>{const u=H(s);return _((o=>v(u,(s=>v(t(o,s),(t=>r(s.addRow(q(e)?e(o,s):e,t,n),s,t)))))),[u,e,...o,...d,n])},Oe=(e,t,o,s,r,d,n)=>le(r,"PartialRow",o,s,d,n,e,t),Qe=(e,t,o,s,r,d,n,u)=>le(d,m,s,r,n,u,e,t,o),We=(e,t,o,s,r)=>le(o,w,e,t,s,r),ze=(e,t,o,s,r)=>le(o,"PartialValues",e,t,s,r),Ge=(e,t,o,s,r,d)=>le(s,y,t,o,r,d,e),Je=(e,t,o)=>ae(e,l,t,o),Ke=(e,t,o,s)=>ae(t,c,o,s,e),Ne=(e,t,o,s,r)=>ae(o,p,s,r,e,t),Ue=(e,t,o,s,r,d,n)=>ae(r,m,d,n,e,t,o,s),Xe=(e,t,o)=>ae(e,w,t,o),Ye=(e,t,o,s)=>ae(t,y,o,s,e),Ze=(e,t,o,s)=>ce(u+l,H(s),e,t,[],o),$e=(e,t,o,s)=>ce(l,H(s),e,t,de,o),_e=(e,t,o,s)=>ce(a,H(s),e,t,de,o),et=(e,t,o,s,r)=>ce(u+c,H(r),t,o,[e],s),tt=(e,t,o,s,r)=>ce(c,H(r),t,o,[e],s),ot=(e,t,o,s,r)=>ce(c+k,H(r),t,o,[e],s),st=(e,t,o,s,r,d)=>ce(u+c+m,H(d),o,s,[e,t],r),rt=(e,t,o,s,r)=>ce(g,H(r),t,o,[e],s),dt=(e,t,o,s,r)=>ce(b,H(r),t,o,[e],s),nt=(e,t,o,s,r,d,n,u,I)=>ce(C,H(I),d,n,[e,t,o,s,r],u),ut=(e,t,o,s,r,d)=>ce(u+p,H(d),o,s,[e,t],r),It=(e,t,o,s,r,d)=>ce(p,H(d),o,s,[e,t],r),it=(e,t,o,s,r,d)=>ce(k,H(d),o,s,[e,t],r),ct=(e,t,o,s,r,d,n)=>ce(u+m,H(n),s,r,[e,t,o],d),lt=(e,t,o,s,r,d,n)=>ce(m,H(n),s,r,[e,t,o],d),at=(e,t,o,s)=>ce(u+w,H(s),e,t,[],o),pt=(e,t,o,s)=>ce(w,H(s),e,t,de,o),gt=(e,t,o,s)=>ce(h,H(s),e,t,de,o),bt=(e,t,o,s,r)=>ce(u+y,H(r),t,o,[e],s),Ct=(e,t,o,s,r)=>ce(y,H(r),t,o,[e],s),mt=(e,t,o)=>ce("Start"+$,H(o),e,t),kt=(e,t,o)=>ce("WillFinish"+$,H(o),e,t),yt=(e,t,o)=>ce("DidFinish"+$,H(o),e,t),wt=(e,t,o)=>Ie(e,t,o),ht=()=>j(3),Rt=e=>ie("MetricIds",W(e),de),vt=(e,t)=>ie("Metric",W(t),void 0,[e]),ft=(e,t,o,s)=>ce("Metric",W(s),t,o,[e]),qt=(e,t,o)=>Ie(e,t,o),Pt=()=>j(5),xt=(e,t)=>ie("SliceIds",G(t),de,[e]),St=e=>ie("IndexIds",G(e),de),Lt=(e,t,o)=>ie("Slice"+b,G(o),de,[e,t]),Bt=(e,t,o,s)=>ce("SliceIds",G(s),t,o,[e]),Tt=(e,t,o,s,r)=>ce("Slice"+b,G(r),o,s,[e,t]),Et=(e,t,o)=>Ie(e,t,o),Mt=()=>j(7),Ft=e=>ie("RelationshipIds",K(e),de),Vt=(e,t,o)=>ie("RemoteRowId",K(o),void 0,[e,t]),At=(e,t,o)=>ie("Local"+b,K(o),de,[e,t]),jt=(e,t,o)=>ie("Linked"+b,K(o),de,[e,t]),Dt=(e,t,o,s,r)=>ce("RemoteRowId",K(r),o,s,[e,t]),Ht=(e,t,o,s,r)=>ce("Local"+b,K(r),o,s,[e,t]),Ot=(e,t,o,s,r)=>ce("Linked"+b,K(r),o,s,[e,t]),Qt=(e,t,o)=>Ie(e,t,o),Wt=()=>j(9),zt=e=>ie("QueryIds",U(e),de),Gt=(e,t)=>ie(n+c,U(t),ne,[e]),Jt=(e,t)=>ie(n+c+k,U(t),de,[e]),Kt=(e,t)=>ie(n+g,U(t),0,[e]),Nt=(e,t)=>ie(n+b,U(t),de,[e]),Ut=(e,t,o,s=0,r,d)=>ie(n+C,U(d),de,[e,t,o,s,r],6),Xt=(e,t,o)=>ie(n+p,U(o),ne,[e,t]),Yt=(e,t,o)=>ie(n+k,U(o),de,[e,t]),Zt=(e,t,o,s)=>ie(n+m,U(s),void 0,[e,t,o]),$t=(e,t,o,s)=>ce(n+c,U(s),t,o,[e]),_t=(e,t,o,s)=>ce(n+c+k,U(s),t,o,[e]),eo=(e,t,o,s)=>ce(n+g,U(s),t,o,[e]),to=(e,t,o,s)=>ce(n+b,U(s),t,o,[e]),oo=(e,t,o,s,r,d,u,I)=>ce(n+C,U(I),d,u,[e,t,o,s,r]),so=(e,t,o,s,r)=>ce(n+p,U(r),o,s,[e,t]),ro=(e,t,o,s,r)=>ce(n+k,U(r),o,s,[e,t]),no=(e,t,o,s,r,d)=>ce(n+m,U(d),s,r,[e,t,o]),uo=(e,t,o)=>Ie(e,t,o),Io=()=>j(11),io=e=>ie("CheckpointIds",Y(e),ue),co=(e,t)=>ie("Checkpoint",Y(t),void 0,[e]),lo=(e=P,t=de,o,s=P,r=de)=>{const d=Y(o);return _((t=>v(d,(o=>{const r=e(t);s(o.addCheckpoint(r),o,r)}))),[d,...t,...r])},ao=e=>pe(e,"goBackward"),po=e=>pe(e,"goForward"),go=(e,t=de,o,s=P,r=de)=>{const d=Y(o);return _((t=>v(d,(o=>v(e(t),(e=>s(o.goTo(e),e)))))),[d,...t,...r])},bo=e=>{const t=Y(e),[s,r]=io(t);return[(d=s,!(0==d.length)),ao(t),r,v(r,(e=>t?.getCheckpoint(e)))??o];var d},Co=e=>{const t=Y(e),[,,[s]]=io(t);return[!R(s),po(t),s,v(s,(e=>t?.getCheckpoint(e)))??o]},mo=(e,t,o)=>ce("CheckpointIds",Y(o),e,t),ko=(e,t,o,s)=>ce("Checkpoint",Y(s),t,o,[e]),yo=(e,t,o=de,s,r=de,d,n=de)=>{const[,u]=re(),I=te((()=>t(e)),[e,...o]);return ee((()=>((async()=>{s&&(await s(I),u([]))})(),()=>{I?.destroy(),d?.(I)})),[I,...r,...n]),I},{PureComponent:wo,Fragment:ho,createElement:Ro,useCallback:vo,useLayoutEffect:fo,useRef:qo,useState:Po}=e,xo=(e,...t)=>R(e)?{}:e(...t),So=(e,t)=>[e,e?.getStore(),e?.getLocalTableId(t),e?.getRemoteTableId(t)],{useCallback:Lo,useContext:Bo,useMemo:To,useState:Eo}=e,Mo=({tableId:e,store:t,rowComponent:o=Oo,getRowComponentProps:s,customCellIds:r,separator:d,debugIds:n},u)=>Do(x(u,(d=>Ro(o,{...xo(s,d),key:d,tableId:e,rowId:d,customCellIds:r,store:t,debugIds:n}))),d,n,e),Fo=({queryId:e,queries:t,resultRowComponent:o=_o,getResultRowComponentProps:s,separator:r,debugIds:d},n)=>Do(x(n,(r=>Ro(o,{...xo(s,r),key:r,queryId:e,rowId:r,queries:t,debugIds:d}))),r,d,e),Vo=({relationshipId:e,relationships:t,rowComponent:o=Oo,getRowComponentProps:s,separator:r,debugIds:d},n,u)=>{const[I,i,c]=So(K(t),e),l=n(e,u,I);return Do(x(l,(e=>Ro(o,{...xo(s,e),key:e,tableId:c,rowId:e,store:i,debugIds:d}))),r,d,u)},Ao=e=>({checkpoints:t,checkpointComponent:o=os,getCheckpointComponentProps:s,separator:r,debugIds:d})=>{const n=Y(t);return Do(x(e(io(n)),(e=>Ro(o,{...xo(s,e),key:e,checkpoints:n,checkpointId:e,debugIds:d}))),r)},jo=({store:e,storesById:t,metrics:o,metricsById:s,indexes:r,indexesById:d,relationships:n,relationshipsById:u,queries:I,queriesById:i,checkpoints:c,checkpointsById:l,children:a})=>{const p=Bo(F),[g,b]=Eo({}),C=Lo(((e,t)=>b((o=>L(o,e)==t?o:{...o,[e]:t}))),[]),m=Lo((e=>b((t=>({...B(t,e)})))),[]);return Ro(F.Provider,{value:To((()=>[e??p[0],{...p[1],...t,...g},o??p[2],{...p[3],...s},r??p[4],{...p[5],...d},n??p[6],{...p[7],...u},I??p[8],{...p[9],...i},c??p[10],{...p[11],...l},C,m]),[e,t,g,o,s,r,d,n,u,I,i,c,l,p,C,m])},a)},Do=(e,t,o,s)=>{const r=R(t)||!Array.isArray(e)?e:x(e,((e,o)=>o>0?[t,e]:e));return o?[s,":{",r,"}"]:r},Ho=({tableId:e,rowId:t,cellId:s,store:r,debugIds:d})=>Do(o+(Be(e,t,s,r)??o),void 0,d,s),Oo=({tableId:e,rowId:t,store:o,cellComponent:s=Ho,getCellComponentProps:r,customCellIds:d,separator:n,debugIds:u})=>Do(x(((e,t,o,s)=>{const r=Se(t,o,s);return e??r})(d,e,t,o),(d=>Ro(s,{...xo(r,d),key:d,tableId:e,rowId:t,cellId:d,store:o,debugIds:u}))),n,u,t),Qo=e=>Mo(e,fe(e.tableId,e.store)),Wo=({cellId:e,descending:t,offset:o,limit:s,...r})=>Mo(r,qe(r.tableId,e,t,o,s,r.store)),zo=({store:e,tableComponent:t=Qo,getTableComponentProps:o,separator:s,debugIds:r})=>Do(x(ke(e),(s=>Ro(t,{...xo(o,s),key:s,tableId:s,store:e,debugIds:r}))),s),Go=({valueId:e,store:t,debugIds:s})=>Do(o+(Ve(e,t)??o),void 0,s,e),Jo=({store:e,valueComponent:t=Go,getValueComponentProps:o,separator:s,debugIds:r})=>Do(x(Me(e),(s=>Ro(t,{...xo(o,s),key:s,valueId:s,store:e,debugIds:r}))),s),Ko=({metricId:e,metrics:t,debugIds:s})=>Do(vt(e,t)??o,void 0,s,e),No=({indexId:e,sliceId:t,indexes:o,rowComponent:s=Oo,getRowComponentProps:r,separator:d,debugIds:n})=>{const[u,I,i]=((e,t)=>[e,e?.getStore(),e?.getTableId(t)])(G(o),e),c=Lt(e,t,u);return Do(x(c,(e=>Ro(s,{...xo(r,e),key:e,tableId:i,rowId:e,store:I,debugIds:n}))),d,n,t)},Uo=({indexId:e,indexes:t,sliceComponent:o=No,getSliceComponentProps:s,separator:r,debugIds:d})=>Do(x(xt(e,t),(r=>Ro(o,{...xo(s,r),key:r,indexId:e,sliceId:r,indexes:t,debugIds:d}))),r,d,e),Xo=({relationshipId:e,localRowId:t,relationships:o,rowComponent:s=Oo,getRowComponentProps:r,debugIds:d})=>{const[n,u,,I]=So(K(o),e),i=Vt(e,t,n);return Do(R(I)||R(i)?null:Ro(s,{...xo(r,i),key:i,tableId:I,rowId:i,store:u,debugIds:d}),void 0,d,t)},Yo=e=>Vo(e,At,e.remoteRowId),Zo=e=>Vo(e,jt,e.firstRowId),$o=({queryId:e,rowId:t,cellId:s,queries:r,debugIds:d})=>Do(o+(Zt(e,t,s,r)??o),void 0,d,s),_o=({queryId:e,rowId:t,queries:o,resultCellComponent:s=$o,getResultCellComponentProps:r,separator:d,debugIds:n})=>Do(x(Yt(e,t,o),(d=>Ro(s,{...xo(r,d),key:d,queryId:e,rowId:t,cellId:d,queries:o,debugIds:n}))),d,n,t),es=e=>Fo(e,Nt(e.queryId,e.queries)),ts=({cellId:e,descending:t,offset:o,limit:s,...r})=>Fo(r,Ut(r.queryId,e,t,o,s,r.queries)),os=({checkpoints:e,checkpointId:t,debugIds:s})=>Do(co(t,e)??o,void 0,s,t),ss=Ao((e=>e[0])),rs=Ao((e=>R(e[1])?[]:[e[1]])),ds=Ao((e=>e[2]));export{ss as BackwardCheckpointsView,Ho as CellView,os as CheckpointView,rs as CurrentCheckpointView,ds as ForwardCheckpointsView,Uo as IndexView,Zo as LinkedRowsView,Yo as LocalRowsView,Ko as MetricView,jo as Provider,Xo as RemoteRowView,$o as ResultCellView,_o as ResultRowView,ts as ResultSortedTableView,es as ResultTableView,Oo as RowView,No as SliceView,Wo as SortedTableView,Qo as TableView,zo as TablesView,Go as ValueView,Jo as ValuesView,He as useAddRowCallback,Be as useCell,Se as useCellIds,it as useCellIdsListener,lt as useCellListener,co as useCheckpoint,io as useCheckpointIds,mo as useCheckpointIdsListener,ko as useCheckpointListener,X as useCheckpoints,Io as useCheckpointsIds,Y as useCheckpointsOrCheckpointsById,uo as useCreateCheckpoints,qt as useCreateIndexes,wt as useCreateMetrics,yo as useCreatePersister,Qt as useCreateQueries,Et as useCreateRelationships,ge as useCreateStore,Ue as useDelCellCallback,Ne as useDelRowCallback,Ke as useDelTableCallback,Je as useDelTablesCallback,Ye as useDelValueCallback,Xe as useDelValuesCallback,yt as useDidFinishTransactionListener,ao as useGoBackwardCallback,po as useGoForwardCallback,go as useGoToCallback,Le as useHasCell,ct as useHasCellListener,Pe as useHasRow,ut as useHasRowListener,ye as useHasTable,Re as useHasTableCell,st as useHasTableCellListener,et as useHasTableListener,Ce as useHasTables,Ze as useHasTablesListener,Fe as useHasValue,bt as useHasValueListener,Te as useHasValues,at as useHasValuesListener,St as useIndexIds,z as useIndexes,Pt as useIndexesIds,G as useIndexesOrIndexesById,jt as useLinkedRowIds,Ot as useLinkedRowIdsListener,At as useLocalRowIds,Ht as useLocalRowIdsListener,vt as useMetric,Rt as useMetricIds,ft as useMetricListener,Q as useMetrics,ht as useMetricsIds,W as useMetricsOrMetricsById,O as useProvideStore,N as useQueries,Wt as useQueriesIds,U as useQueriesOrQueriesById,zt as useQueryIds,Co as useRedoInformation,Ft as useRelationshipIds,J as useRelationships,Mt as useRelationshipsIds,K as useRelationshipsOrRelationshipsById,Vt as useRemoteRowId,Dt as useRemoteRowIdListener,Zt as useResultCell,Yt as useResultCellIds,ro as useResultCellIdsListener,no as useResultCellListener,Xt as useResultRow,Kt as useResultRowCount,eo as useResultRowCountListener,Nt as useResultRowIds,to as useResultRowIdsListener,so as useResultRowListener,Ut as useResultSortedRowIds,oo as useResultSortedRowIdsListener,Gt as useResultTable,Jt as useResultTableCellIds,_t as useResultTableCellIdsListener,$t as useResultTableListener,xe as useRow,ve as useRowCount,rt as useRowCountListener,fe as useRowIds,dt as useRowIdsListener,It as useRowListener,Qe as useSetCellCallback,lo as useSetCheckpointCallback,Oe as useSetPartialRowCallback,ze as useSetPartialValuesCallback,De as useSetRowCallback,je as useSetTableCallback,Ae as useSetTablesCallback,Ge as useSetValueCallback,We as useSetValuesCallback,xt as useSliceIds,Bt as useSliceIdsListener,Lt as useSliceRowIds,Tt as useSliceRowIdsListener,qe as useSortedRowIds,nt as useSortedRowIdsListener,mt as useStartTransactionListener,D as useStore,be as useStoreIds,H as useStoreOrStoreById,we as useTable,he as useTableCellIds,ot as useTableCellIdsListener,ke as useTableIds,_e as useTableIdsListener,tt as useTableListener,me as useTables,$e as useTablesListener,bo as useUndoInformation,Ve as useValue,Me as useValueIds,gt as useValueIdsListener,Ct as useValueListener,Ee as useValues,pt as useValuesListener,kt as useWillFinishTransactionListener};
|
package/lib/ui-react.js.gz
CHANGED
|
Binary file
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var a,t;a=this,t=function(a,t){"use strict";const e=a=>typeof a,s="tinybase",n=",",i=e(""),o=(a,t)=>a.repeat(t),c=Promise,r=clearInterval,l=a=>null==a,y=(a,t,e)=>l(a)?e?.():t(a),w=a=>e(a)==i,E=(a,t,e)=>a.slice(t,e),d=a=>a.length,u=async a=>c.all(a),p="_",f="_id",T=a=>`"${a.replace(/"/g,'""')}"`,m="SELECT",v=(a,t="")=>a.join(t),A=(a,t)=>a.map(t),L=a=>0==d(a),h=(a,t)=>a.filter(t),N=(a,...t)=>a.push(...t),O=(a,t)=>a?.has(t)??!1,R=a=>[...a?.values()??[]],S=(a,t)=>a?.delete(t),
|
|
1
|
+
var a,t;a=this,t=function(a,t){"use strict";const e=a=>typeof a,s="tinybase",n=",",i=e(""),o=(a,t)=>a.repeat(t),c=Promise,r=clearInterval,l=a=>null==a,y=(a,t,e)=>l(a)?e?.():t(a),w=a=>e(a)==i,E=(a,t,e)=>a.slice(t,e),d=a=>a.length,u=async a=>c.all(a),p="_",f="_id",T=a=>`"${a.replace(/"/g,'""')}"`,m="SELECT",v=(a,t="")=>a.join(t),A=(a,t)=>a.map(t),L=a=>0==d(a),h=(a,t)=>a.filter(t),N=(a,...t)=>a.push(...t),O=(a,t)=>a?.has(t)??!1,R=a=>[...a?.values()??[]],S=(a,t)=>a?.delete(t),g=Object,C=a=>g.getPrototypeOf(a),D=g.keys,b=g.freeze,x=(a=[])=>g.fromEntries(a),I=(...a)=>g.assign({},...a),F=(a,t)=>A(g.entries(a),(([a,e])=>t(e,a))),M=a=>g.values(a),P=a=>d(D(a)),$=a=>(a=>!l(a)&&y(C(a),(a=>a==g.prototype||l(C(a))),(()=>!0)))(a)&&0==P(a),_=a=>new Map(a),B=a=>[...a?.keys()??[]],q=(a,t)=>a?.get(t),H=(a,t)=>A([...a?.entries()??[]],(([a,e])=>t(e,a))),j=(a,t,e)=>l(e)?(S(a,t),a):a?.set(t,e),W=(a,t,e)=>(O(a,t)||j(a,t,e()),q(a,t)),Y=(a,t,e,s=j)=>(F(t,((t,s)=>e(a,s,t))),((a,t)=>{((a,t)=>{a?.forEach(t)})(a,((a,e)=>t(e)))})(a,(e=>((a,t)=>!l(((a,t)=>y(a,(a=>a[t])))(a,t)))(t,e)?0:s(a,e))),a),k=a=>new Set(Array.isArray(a)||l(a)?a:[a]),G=(a,t)=>a?.add(t),J=m+"*FROM",U="FROM pragma_table_",z="WHERE",K=(a,t,e)=>{const s=_();return[async()=>Y(s,x(await u(A(await a("SELECT name "+U+"list WHERE schema='main'AND type='table'AND name IN("+Q(t)+")ORDER BY name",t),(async({name:t})=>[t,x(A(await a(m+" name,type "+U+"info(?)",[t]),(({name:a,type:t})=>[a,t])))])))),((a,t,e)=>j(s,t,Y(W(s,t,_),e,((a,t,e)=>{e!=q(a,t)&&j(a,t,e)}),((a,t)=>j(a,t))))),((a,t)=>j(s,t))),async(t,e)=>((a,t)=>!l(q(q(s,a),t)))(t,e)?x(h(A(await a(J+T(t)),(a=>{return[a[e],(t={...a},s=e,delete t[s],t)];var t,s})),(([a,t])=>!l(a)&&!$(t)))):{},async(t,e,i,o,c,r=!1)=>{const y=k();F(i??{},(a=>A(D(a??{}),(a=>G(y,a)))));const w=R(y);if(!r&&c&&L(w)&&O(s,t))return await a("DROP TABLE"+T(t)),void j(s,t);if(L(w)||O(s,t)){const n=q(s,t),i=k(B(n));await u([...A(w,(async e=>{S(i,e)||(await a(`ALTER TABLE${T(t)}ADD${T(e)}`),j(n,e,""))})),...!r&&o?A(R(i),(async s=>{s!=e&&(await a(`ALTER TABLE${T(t)}DROP${T(s)}`),j(n,s))})):[]])}else await a(`CREATE TABLE${T(t)}(${T(e)} PRIMARY KEY ON CONFLICT REPLACE${v(A(w,(a=>n+T(a))))});`),j(s,t,_([[e,""],...A(w,(a=>[a,""]))]));if(r)l(i)?await a("DELETE FROM"+T(t)+"WHERE 1"):await u(F(i,(async(s,n)=>{l(s)?await a("DELETE FROM"+T(t)+z+T(e)+"=?",[n]):L(w)||await V(a,t,e,D(s),[n,...M(s)])})));else if(L(w))O(s,t)&&await a("DELETE FROM"+T(t)+"WHERE 1");else{const n=h(B(q(s,t)),(a=>a!=e)),o=[],c=[];F(i??{},((a,t)=>{N(o,t,...A(n,(t=>a?.[t]))),N(c,t)})),await V(a,t,e,n,o),await a("DELETE FROM"+T(t)+z+T(e)+"NOT IN("+Q(c)+")",c)}},async t=>{let s;await a("BEGIN");try{s=await t()}catch(a){e?.(a)}return await a("END"),s}]},V=async(a,t,e,s,i)=>await a("INSERT INTO"+T(t)+"("+T(e)+v(A(s,(a=>n+T(a))))+")VALUES"+E(o(`,(?${o(",?",d(s))})`,d(i)/(d(s)+1)),1)+"ON CONFLICT("+T(e)+")DO UPDATE SET"+v(A(s,(a=>T(a)+"=excluded."+T(a))),n),i),Q=a=>v(A(a,(()=>"?")),n),X=JSON.parse,Z=_(),aa=_(),ta=(a,t,e,s,n,i,[o,c]=[],r=[])=>{let w,E,d,u=0,p=0;W(Z,r,(()=>0)),W(aa,r,(()=>[]));const f=async a=>(2!=u&&(u=1,await T.schedule((async()=>{await a(),u=0}))),T),T={load:async(e,s)=>await f((async()=>{try{a.setContent(await t())}catch{a.setContent([e,s])}})),startAutoLoad:async(e={},n={})=>(T.stopAutoLoad(),await T.load(e,n),p=1,d=s((async(e,s)=>{if(s){const t=s();await f((async()=>a.setTransactionChanges(t)))}else await f((async()=>{try{a.setContent(e?.()??await t())}catch(a){i?.(a)}}))})),T),stopAutoLoad:()=>(p&&(n(d),d=void 0,p=0),T),save:async t=>(1!=u&&(u=2,await T.schedule((async()=>{try{await e(a.getContent,t)}catch(a){i?.(a)}u=0}))),T),startAutoSave:async()=>(await T.stopAutoSave().save(),w=a.addDidFinishTransactionListener(((a,t)=>{const[e,s]=t();$(e)&&$(s)||T.save((()=>[e,s]))})),T),stopAutoSave:()=>(y(w,a.delListener),w=void 0,T),schedule:async(...a)=>(N(q(aa,r),...a),await(async()=>{if(!q(Z,r)){for(j(Z,r,1);!l((a=q(aa,r),E=a.shift()));)try{await E()}catch(a){i?.(a)}j(Z,r,0)}var a})(),T),getStore:()=>a,destroy:()=>T.stopAutoLoad().stopAutoSave(),getStats:()=>({})};return o&&(T[o]=()=>c),b(T)},ea="store",sa=(a,t,e,s,n,[i],o,c,r)=>{const[l,y,w,E]=K(t,o,n);return ta(a,(async()=>await E((async()=>(await l(),X((await y(i,f))[p]?.[ea]??"null"))))),(async a=>await E((async()=>{var t;await l(),await w(i,f,{[p]:{[ea]:(t=a()??null,JSON.stringify(t,((a,t)=>t instanceof Map?g.fromEntries([...t]):t)))}},!0,!0)}))),e,s,n,[r,c],c)},na=(a,t,e,s,n,[i,o,[c,r,y]],w,E,d)=>{const[T,m,v,A]=K(t,w,n),L=async(a,t)=>await u(H(o,(async([e,s,n,i],o)=>{const c=a[o];t&&void 0===c||await v(e,s,c,n,i,t)}))),N=async(a,t)=>r?await v(y,f,{[p]:a},!0,!0,t):null;return ta(a,(async()=>await A((async()=>{await T();const a=await(async()=>x(h(await u(H(i,(async([a,t],e)=>[a,await m(e,t)]))),(a=>!$(a[1])))))(),t=await(async()=>c?(await m(y,f))[p]:{})();return $(a)&&l(t)?void 0:[a,t]}))),(async(a,t)=>await A((async()=>{if(await T(),l(t)){const[t,e]=a();await L(t),await N(e)}else{const[a,e]=t();await L(a,!0),await N(e,!0)}}))),e,s,n,[d,E],E)},ia="json",oa="autoLoadIntervalSeconds",ca="rowIdColumnName",ra="tableId",la="tableName",ya={mode:ia,[oa]:1},wa={load:0,save:0,[la]:s+"_values"},Ea=(a,t,e,s)=>{const n=_();return F(a,((a,i)=>{const o=E(M(I(t,w(a)?{[e]:a}:a)),0,P(t));l(o[0])||s(i,o[0])||j(n,i,o)})),n},da="pragma ",ua="data_version",pa="schema_version",fa=(a,t,e,n,i,o,c,l,y="getDb")=>{let d,u,p;const[T,v,A,L]=(a=>{const t=(a=>I(ya,w(a)?{storeTableName:a}:a??{}))(a),e=t[oa];if(t.mode==ia){const{storeTableName:a=s}=t;return[1,e,[a],k(a)]}const{tables:{load:n={},save:i={}}={},values:o={}}=t,c=E(M(I(wa,o)),0,P(wa)),r=c[2],l=k(r);return[0,e,[Ea(n,{[ra]:null,[ca]:f},ra,(a=>G(l,a)&&a==r)),Ea(i,{[la]:null,[ca]:f,deleteEmptyColumns:0,deleteEmptyTable:0},la,((a,t)=>G(l,t)&&t==r)),c],l]})(t);return(T?sa:na)(a,o?async(a,t)=>(o(a,t),await e(a,t)):e,(a=>{return[(t=async()=>{try{const t=(await e(da+ua))[0][ua],s=(await e(da+pa))[0][pa],n=(await e(m+" TOTAL_CHANGES() c"))[0].c;t==(d??=t)&&s==(u??=s)&&n==(p??=n)||(a(),d=t,u=s)}catch{}},s=v,t(),setInterval(t,1e3*s)),n((t=>L.has(t)?a():0))];var t,s}),(([a,t])=>{r(a),d=u=null,i(t)}),c,A,R(L),l,y)};a.createExpoSqliteNextPersister=(a,e,s,n,i)=>fa(a,s,(async(a,t=[])=>await e.getAllAsync(a,t)),(a=>t.addDatabaseChangeListener((({tableName:t})=>a(t)))),(a=>a.remove()),n,i,e)},"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("expo-sqlite/next")):"function"==typeof define&&define.amd?define(["exports","expo-sqlite/next"],t):t((a="undefined"!=typeof globalThis?globalThis:a||self).TinyBasePersisterExpoSqliteNext={},a["expo-sqlite/next"]);
|
|
Binary file
|
package/lib/umd/ui-react.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var e,s;e=this,s=function(e,s){"use strict";const t=e=>typeof e,o="",u=t(o),r=t(t),l="Listener",d="Result",n="Has",i="has",a="Ids",c="Table",I=c+"s",C=c+a,b="Row",p=b+"Count",w=b+a,R="Sorted"+b+a,k="Cell",g=k+a,L="Value",h=L+"s",m=L+a,y=e=>null==e,T=(e,s,t)=>y(e)?t?.():s(e),V=e=>t(e)==u,S=e=>t(e)==r,f=()=>{},v=(e,s)=>e.map(s),x=Object.keys,P=(e,s)=>T(e,(e=>e[s])),q=(e,s)=>(delete e[s],e),{createContext:B,useContext:H,useEffect:M}=s,D=B([]),F=(e,s)=>{const t=H(D);return y(e)?t[s]:V(e)?P(t[s+1]??{},e):e},O=(e,s)=>{const t=F(e,s);return y(e)||V(e)?t:e},Q=e=>x(H(D)[e]??{}),E=e=>O(e,0),A=e=>O(e,2),G=e=>O(e,4),j=e=>O(e,6),U=e=>O(e,8),W=e=>O(e,10),z=e=>e.toLowerCase();z(l);const J="Transaction";z(J);const{useCallback:K,useEffect:N,useMemo:X,useLayoutEffect:Y,useRef:Z,useState:$}=s,_=[],ee={},se=[[],void 0,[]],te=(e,s,t=_)=>{const o=X((()=>s(e)),[e,...t]);return N((()=>()=>o.destroy()),[o]),o},oe=(e,s,t,o=_,u,r="get",l="")=>{const[,d]=$(),n=K((()=>s?.[r+e]?.(...o)??t),[s,e,...o,t]),i=Z();return X((()=>i.current=n()),[n]),ue(l+e,s,((...e)=>{i.current=y(u)?n():e[u],d([])}),[n,u],o),i.current},ue=(e,s,t,o=_,u=_,...r)=>Y((()=>{const o=s?.["add"+e+l]?.(...u,t,...r);return()=>s?.delListener(o)}),[s,e,...u,...o,...r]),re=(e,s,t,o=_,u=f,r=_,...l)=>{const d=E(e);return K((e=>T(d,(o=>T(t(e,o),(t=>u(o["set"+s](...v(l,(s=>S(s)?s(e,o):s)),t),t)))))),[d,s,...o,...r,...l])},le=(e,s,t=f,o=_,...u)=>{const r=E(e);return K((()=>t(r?.["del"+s](...u))),[r,s,...o,...u])},de=(e,s,t)=>{const o=W(e);return K((()=>o?.[s](t)),[o,s,t])},ne=e=>oe(C,E(e),_),ie=(e,s)=>oe(w,E(s),_,[e]),ae=(e,s,t,o=0,u,r)=>oe(R,E(r),_,[e,s,t,o,u],6),ce=(e,s,t)=>oe(g,E(t),_,[e,s]),Ie=(e,s,t,o)=>oe(k,E(o),void 0,[e,s,t],4),Ce=e=>oe(m,E(e),_),be=(e,s)=>oe(L,E(s),void 0,[e]),pe=(e,s)=>oe("Metric",A(s),void 0,[e]),we=(e,s)=>oe("SliceIds",G(s),_,[e]),Re=(e,s,t)=>oe("Slice"+w,G(t),_,[e,s]),ke=(e,s,t)=>oe("RemoteRowId",j(t),void 0,[e,s]),ge=(e,s,t)=>oe("Local"+w,j(t),_,[e,s]),Le=(e,s,t)=>oe("Linked"+w,j(t),_,[e,s]),he=(e,s)=>oe(d+w,U(s),_,[e]),me=(e,s,t,o=0,u,r)=>oe(d+R,U(r),_,[e,s,t,o,u],6),ye=(e,s,t)=>oe(d+g,U(t),_,[e,s]),Te=(e,s,t,o)=>oe(d+k,U(o),void 0,[e,s,t]),Ve=e=>oe("CheckpointIds",W(e),se),Se=(e,s)=>oe("Checkpoint",W(s),void 0,[e]),fe=e=>de(e,"goBackward"),ve=e=>de(e,"goForward"),{PureComponent:xe,Fragment:Pe,createElement:qe,useCallback:Be,useLayoutEffect:He,useRef:Me,useState:De}=s,Fe=(e,...s)=>y(e)?{}:e(...s),Oe=(e,s)=>[e,e?.getStore(),e?.getLocalTableId(s),e?.getRemoteTableId(s)],{useCallback:Qe,useContext:Ee,useMemo:Ae,useState:Ge}=s,je=({tableId:e,store:s,rowComponent:t=Ne,getRowComponentProps:o,customCellIds:u,separator:r,debugIds:l},d)=>Je(v(d,(r=>qe(t,{...Fe(o,r),key:r,tableId:e,rowId:r,customCellIds:u,store:s,debugIds:l}))),r,l,e),Ue=({queryId:e,queries:s,resultRowComponent:t=_e,getResultRowComponentProps:o,separator:u,debugIds:r},l)=>Je(v(l,(u=>qe(t,{...Fe(o,u),key:u,queryId:e,rowId:u,queries:s,debugIds:r}))),u,r,e),We=({relationshipId:e,relationships:s,rowComponent:t=Ne,getRowComponentProps:o,separator:u,debugIds:r},l,d)=>{const[n,i,a]=Oe(j(s),e),c=l(e,d,n);return Je(v(c,(e=>qe(t,{...Fe(o,e),key:e,tableId:a,rowId:e,store:i,debugIds:r}))),u,r,d)},ze=e=>({checkpoints:s,checkpointComponent:t=es,getCheckpointComponentProps:o,separator:u,debugIds:r})=>{const l=W(s);return Je(v(e(Ve(l)),(e=>qe(t,{...Fe(o,e),key:e,checkpoints:l,checkpointId:e,debugIds:r}))),u)},Je=(e,s,t,o)=>{const u=y(s)||!Array.isArray(e)?e:v(e,((e,t)=>t>0?[s,e]:e));return t?[o,":{",u,"}"]:u},Ke=({tableId:e,rowId:s,cellId:t,store:u,debugIds:r})=>Je(o+(Ie(e,s,t,u)??o),void 0,r,t),Ne=({tableId:e,rowId:s,store:t,cellComponent:o=Ke,getCellComponentProps:u,customCellIds:r,separator:l,debugIds:d})=>Je(v(((e,s,t,o)=>{const u=ce(s,t,o);return e??u})(r,e,s,t),(r=>qe(o,{...Fe(u,r),key:r,tableId:e,rowId:s,cellId:r,store:t,debugIds:d}))),l,d,s),Xe=e=>je(e,ie(e.tableId,e.store)),Ye=({valueId:e,store:s,debugIds:t})=>Je(o+(be(e,s)??o),void 0,t,e),Ze=({indexId:e,sliceId:s,indexes:t,rowComponent:o=Ne,getRowComponentProps:u,separator:r,debugIds:l})=>{const[d,n,i]=((e,s)=>[e,e?.getStore(),e?.getTableId(s)])(G(t),e),a=Re(e,s,d);return Je(v(a,(e=>qe(o,{...Fe(u,e),key:e,tableId:i,rowId:e,store:n,debugIds:l}))),r,l,s)},$e=({queryId:e,rowId:s,cellId:t,queries:u,debugIds:r})=>Je(o+(Te(e,s,t,u)??o),void 0,r,t),_e=({queryId:e,rowId:s,queries:t,resultCellComponent:o=$e,getResultCellComponentProps:u,separator:r,debugIds:l})=>Je(v(ye(e,s,t),(r=>qe(o,{...Fe(u,r),key:r,queryId:e,rowId:s,cellId:r,queries:t,debugIds:l}))),r,l,s),es=({checkpoints:e,checkpointId:s,debugIds:t})=>Je(Se(s,e)??o,void 0,t,s),ss=ze((e=>e[0])),ts=ze((e=>y(e[1])?[]:[e[1]])),os=ze((e=>e[2]));e.BackwardCheckpointsView=ss,e.CellView=Ke,e.CheckpointView=es,e.CurrentCheckpointView=ts,e.ForwardCheckpointsView=os,e.IndexView=({indexId:e,indexes:s,sliceComponent:t=Ze,getSliceComponentProps:o,separator:u,debugIds:r})=>Je(v(we(e,s),(u=>qe(t,{...Fe(o,u),key:u,indexId:e,sliceId:u,indexes:s,debugIds:r}))),u,r,e),e.LinkedRowsView=e=>We(e,Le,e.firstRowId),e.LocalRowsView=e=>We(e,ge,e.remoteRowId),e.MetricView=({metricId:e,metrics:s,debugIds:t})=>Je(pe(e,s)??o,void 0,t,e),e.Provider=({store:e,storesById:s,metrics:t,metricsById:o,indexes:u,indexesById:r,relationships:l,relationshipsById:d,queries:n,queriesById:i,checkpoints:a,checkpointsById:c,children:I})=>{const C=Ee(D),[b,p]=Ge({}),w=Qe(((e,s)=>p((t=>P(t,e)==s?t:{...t,[e]:s}))),[]),R=Qe((e=>p((s=>({...q(s,e)})))),[]);return qe(D.Provider,{value:Ae((()=>[e??C[0],{...C[1],...s,...b},t??C[2],{...C[3],...o},u??C[4],{...C[5],...r},l??C[6],{...C[7],...d},n??C[8],{...C[9],...i},a??C[10],{...C[11],...c},w,R]),[e,s,b,t,o,u,r,l,d,n,i,a,c,C,w,R])},I)},e.RemoteRowView=({relationshipId:e,localRowId:s,relationships:t,rowComponent:o=Ne,getRowComponentProps:u,debugIds:r})=>{const[l,d,,n]=Oe(j(t),e),i=ke(e,s,l);return Je(y(n)||y(i)?null:qe(o,{...Fe(u,i),key:i,tableId:n,rowId:i,store:d,debugIds:r}),void 0,r,s)},e.ResultCellView=$e,e.ResultRowView=_e,e.ResultSortedTableView=({cellId:e,descending:s,offset:t,limit:o,...u})=>Ue(u,me(u.queryId,e,s,t,o,u.queries)),e.ResultTableView=e=>Ue(e,he(e.queryId,e.queries)),e.RowView=Ne,e.SliceView=Ze,e.SortedTableView=({cellId:e,descending:s,offset:t,limit:o,...u})=>je(u,ae(u.tableId,e,s,t,o,u.store)),e.TableView=Xe,e.TablesView=({store:e,tableComponent:s=Xe,getTableComponentProps:t,separator:o,debugIds:u})=>Je(v(ne(e),(o=>qe(s,{...Fe(t,o),key:o,tableId:o,store:e,debugIds:u}))),o),e.ValueView=Ye,e.ValuesView=({store:e,valueComponent:s=Ye,getValueComponentProps:t,separator:o,debugIds:u})=>Je(v(Ce(e),(o=>qe(s,{...Fe(t,o),key:o,valueId:o,store:e,debugIds:u}))),o),e.useAddRowCallback=(e,s,t=_,o,u=f,r=_,l=!0)=>{const d=E(o);return K((t=>T(d,(o=>T(s(t,o),(s=>u(o.addRow(S(e)?e(t,o):e,s,l),o,s)))))),[d,e,...t,...r,l])},e.useCell=Ie,e.useCellIds=ce,e.useCellIdsListener=(e,s,t,o,u,r)=>ue(g,E(r),t,o,[e,s],u),e.useCellListener=(e,s,t,o,u,r,l)=>ue(k,E(l),o,u,[e,s,t],r),e.useCheckpoint=Se,e.useCheckpointIds=Ve,e.useCheckpointIdsListener=(e,s,t)=>ue("CheckpointIds",W(t),e,s),e.useCheckpointListener=(e,s,t,o)=>ue("Checkpoint",W(o),s,t,[e]),e.useCheckpoints=e=>F(e,10),e.useCheckpointsIds=()=>Q(11),e.useCheckpointsOrCheckpointsById=W,e.useCreateCheckpoints=(e,s,t)=>te(e,s,t),e.useCreateIndexes=(e,s,t)=>te(e,s,t),e.useCreateMetrics=(e,s,t)=>te(e,s,t),e.useCreatePersister=(e,s,t=_,o,u=_,r,l=_)=>{const[,d]=$(),n=X((()=>s(e)),[e,...t]);return N((()=>((async()=>{o&&(await o(n),d([]))})(),()=>{n?.destroy(),r?.(n)})),[n,...u,...l]),n},e.useCreateQueries=(e,s,t)=>te(e,s,t),e.useCreateRelationships=(e,s,t)=>te(e,s,t),e.useCreateStore=(e,s=_)=>X(e,s),e.useDelCellCallback=(e,s,t,o,u,r,l)=>le(u,k,r,l,e,s,t,o),e.useDelRowCallback=(e,s,t,o,u)=>le(t,b,o,u,e,s),e.useDelTableCallback=(e,s,t,o)=>le(s,c,t,o,e),e.useDelTablesCallback=(e,s,t)=>le(e,I,s,t),e.useDelValueCallback=(e,s,t,o)=>le(s,L,t,o,e),e.useDelValuesCallback=(e,s,t)=>le(e,h,s,t),e.useDidFinishTransactionListener=(e,s,t)=>ue("DidFinish"+J,E(t),e,s),e.useGoBackwardCallback=fe,e.useGoForwardCallback=ve,e.useGoToCallback=(e,s=_,t,o=f,u=_)=>{const r=W(t);return K((s=>T(r,(t=>T(e(s),(e=>o(t.goTo(e),e)))))),[r,...s,...u])},e.useHasCell=(e,s,t,o)=>oe(k,E(o),!1,[e,s,t],4,i,n),e.useHasCellListener=(e,s,t,o,u,r,l)=>ue(n+k,E(l),o,u,[e,s,t],r),e.useHasRow=(e,s,t)=>oe(b,E(t),!1,[e,s],3,i,n),e.useHasRowListener=(e,s,t,o,u,r)=>ue(n+b,E(r),t,o,[e,s],u),e.useHasTable=(e,s)=>oe(c,E(s),!1,[e],2,i,n),e.useHasTableCell=(e,s,t)=>oe(c+k,E(t),!1,[e,s],3,i,n),e.useHasTableCellListener=(e,s,t,o,u,r)=>ue(n+c+k,E(r),t,o,[e,s],u),e.useHasTableListener=(e,s,t,o,u)=>ue(n+c,E(u),s,t,[e],o),e.useHasTables=e=>oe(I,E(e),!1,[],1,i,n),e.useHasTablesListener=(e,s,t,o)=>ue(n+I,E(o),e,s,[],t),e.useHasValue=(e,s)=>oe(L,E(s),!1,[e],2,i,n),e.useHasValueListener=(e,s,t,o,u)=>ue(n+L,E(u),s,t,[e],o),e.useHasValues=e=>oe(h,E(e),!1,[],1,i,n),e.useHasValuesListener=(e,s,t,o)=>ue(n+h,E(o),e,s,[],t),e.useIndexIds=e=>oe("IndexIds",G(e),_),e.useIndexes=e=>F(e,4),e.useIndexesIds=()=>Q(5),e.useIndexesOrIndexesById=G,e.useLinkedRowIds=Le,e.useLinkedRowIdsListener=(e,s,t,o,u)=>ue("Linked"+w,j(u),t,o,[e,s]),e.useLocalRowIds=ge,e.useLocalRowIdsListener=(e,s,t,o,u)=>ue("Local"+w,j(u),t,o,[e,s]),e.useMetric=pe,e.useMetricIds=e=>oe("MetricIds",A(e),_),e.useMetricListener=(e,s,t,o)=>ue("Metric",A(o),s,t,[e]),e.useMetrics=e=>F(e,2),e.useMetricsIds=()=>Q(3),e.useMetricsOrMetricsById=A,e.useProvideStore=(e,s)=>{const{12:t,13:o}=H(D);M((()=>(t?.(e,s),()=>o?.(e))),[t,e,s,o])},e.useQueries=e=>F(e,8),e.useQueriesIds=()=>Q(9),e.useQueriesOrQueriesById=U,e.useQueryIds=e=>oe("QueryIds",U(e),_),e.useRedoInformation=e=>{const s=W(e),[,,[t]]=Ve(s);return[!y(t),ve(s),t,T(t,(e=>s?.getCheckpoint(e)))??o]},e.useRelationshipIds=e=>oe("RelationshipIds",j(e),_),e.useRelationships=e=>F(e,6),e.useRelationshipsIds=()=>Q(7),e.useRelationshipsOrRelationshipsById=j,e.useRemoteRowId=ke,e.useRemoteRowIdListener=(e,s,t,o,u)=>ue("RemoteRowId",j(u),t,o,[e,s]),e.useResultCell=Te,e.useResultCellIds=ye,e.useResultCellIdsListener=(e,s,t,o,u)=>ue(d+g,U(u),t,o,[e,s]),e.useResultCellListener=(e,s,t,o,u,r)=>ue(d+k,U(r),o,u,[e,s,t]),e.useResultRow=(e,s,t)=>oe(d+b,U(t),ee,[e,s]),e.useResultRowCount=(e,s)=>oe(d+p,U(s),0,[e]),e.useResultRowCountListener=(e,s,t,o)=>ue(d+p,U(o),s,t,[e]),e.useResultRowIds=he,e.useResultRowIdsListener=(e,s,t,o)=>ue(d+w,U(o),s,t,[e]),e.useResultRowListener=(e,s,t,o,u)=>ue(d+b,U(u),t,o,[e,s]),e.useResultSortedRowIds=me,e.useResultSortedRowIdsListener=(e,s,t,o,u,r,l,n)=>ue(d+R,U(n),r,l,[e,s,t,o,u]),e.useResultTable=(e,s)=>oe(d+c,U(s),ee,[e]),e.useResultTableCellIds=(e,s)=>oe(d+c+g,U(s),_,[e]),e.useResultTableCellIdsListener=(e,s,t,o)=>ue(d+c+g,U(o),s,t,[e]),e.useResultTableListener=(e,s,t,o)=>ue(d+c,U(o),s,t,[e]),e.useRow=(e,s,t)=>oe(b,E(t),ee,[e,s]),e.useRowCount=(e,s)=>oe(p,E(s),0,[e]),e.useRowCountListener=(e,s,t,o,u)=>ue(p,E(u),s,t,[e],o),e.useRowIds=ie,e.useRowIdsListener=(e,s,t,o,u)=>ue(w,E(u),s,t,[e],o),e.useRowListener=(e,s,t,o,u,r)=>ue(b,E(r),t,o,[e,s],u),e.useSetCellCallback=(e,s,t,o,u,r,l,d)=>re(r,k,o,u,l,d,e,s,t),e.useSetCheckpointCallback=(e=f,s=_,t,o=f,u=_)=>{const r=W(t);return K((s=>T(r,(t=>{const u=e(s);o(t.addCheckpoint(u),t,u)}))),[r,...s,...u])},e.useSetPartialRowCallback=(e,s,t,o,u,r,l)=>re(u,"PartialRow",t,o,r,l,e,s),e.useSetPartialValuesCallback=(e,s,t,o,u)=>re(t,"PartialValues",e,s,o,u),e.useSetRowCallback=(e,s,t,o,u,r,l)=>re(u,b,t,o,r,l,e,s),e.useSetTableCallback=(e,s,t,o,u,r)=>re(o,c,s,t,u,r,e),e.useSetTablesCallback=(e,s,t,o,u)=>re(t,I,e,s,o,u),e.useSetValueCallback=(e,s,t,o,u,r)=>re(o,L,s,t,u,r,e),e.useSetValuesCallback=(e,s,t,o,u)=>re(t,h,e,s,o,u),e.useSliceIds=we,e.useSliceIdsListener=(e,s,t,o)=>ue("SliceIds",G(o),s,t,[e]),e.useSliceRowIds=Re,e.useSliceRowIdsListener=(e,s,t,o,u)=>ue("Slice"+w,G(u),t,o,[e,s]),e.useSortedRowIds=ae,e.useSortedRowIdsListener=(e,s,t,o,u,r,l,d,n)=>ue(R,E(n),r,l,[e,s,t,o,u],d),e.useStartTransactionListener=(e,s,t)=>ue("Start"+J,E(t),e,s),e.useStore=e=>F(e,0),e.useStoreIds=()=>Q(1),e.useStoreOrStoreById=E,e.useTable=(e,s)=>oe(c,E(s),ee,[e]),e.useTableCellIds=(e,s)=>oe(c+g,E(s),_,[e]),e.useTableCellIdsListener=(e,s,t,o,u)=>ue(c+g,E(u),s,t,[e],o),e.useTableIds=ne,e.useTableIdsListener=(e,s,t,o)=>ue(C,E(o),e,s,_,t),e.useTableListener=(e,s,t,o,u)=>ue(c,E(u),s,t,[e],o),e.useTables=e=>oe(I,E(e),ee),e.useTablesListener=(e,s,t,o)=>ue(I,E(o),e,s,_,t),e.useUndoInformation=e=>{const s=W(e),[t,u]=Ve(s);return[(r=t,!(0==r.length)),fe(s),u,T(u,(e=>s?.getCheckpoint(e)))??o];var r},e.useValue=be,e.useValueIds=Ce,e.useValueIdsListener=(e,s,t,o)=>ue(m,E(o),e,s,_,t),e.useValueListener=(e,s,t,o,u)=>ue(L,E(u),s,t,[e],o),e.useValues=e=>oe(h,E(e),ee),e.useValuesListener=(e,s,t,o)=>ue(h,E(o),e,s,_,t),e.useWillFinishTransactionListener=(e,s,t)=>ue("WillFinish"+J,E(t),e,s)},"object"==typeof exports&&"undefined"!=typeof module?s(exports,require("react")):"function"==typeof define&&define.amd?define(["exports","react"],s):s((e="undefined"!=typeof globalThis?globalThis:e||self).TinyBaseUiReact={},e.React);
|
|
1
|
+
var e,s;e=this,s=function(e,s){"use strict";const t=e=>typeof e,o="",u=t(o),r=t(t),l="Listener",d="Result",n="Has",i="has",a="Ids",c="Table",I=c+"s",C=c+a,b="Row",p=b+"Count",w=b+a,R="Sorted"+b+a,k="Cell",g=k+a,L="Value",h=L+"s",m=L+a,y=e=>null==e,T=(e,s,t)=>y(e)?t?.():s(e),V=e=>t(e)==u,S=e=>t(e)==r,f=()=>{},v=(e,s)=>e.map(s),x=Object.keys,P=(e,s)=>T(e,(e=>e[s])),q=(e,s)=>(delete e[s],e),{createContext:B,useContext:H,useEffect:M}=s,D=B([]),F=(e,s)=>{const t=H(D);return y(e)?t[s]:V(e)?P(t[s+1]??{},e):e},O=(e,s)=>{const t=F(e,s);return y(e)||V(e)?t:e},Q=e=>x(H(D)[e]??{}),E=e=>O(e,0),A=e=>O(e,2),G=e=>O(e,4),j=e=>O(e,6),U=e=>O(e,8),W=e=>O(e,10),z=e=>e.toLowerCase();z(l);const J="Transaction";z(J);const{useCallback:K,useEffect:N,useMemo:X,useLayoutEffect:Y,useRef:Z,useState:$}=s,_=[],ee={},se=[[],void 0,[]],te=(e,s,t=_)=>{const o=X((()=>s(e)),[e,...t]);return N((()=>()=>o.destroy()),[o]),o},oe=(e,s,t,o=_,u,r="get",l="")=>{const[,d]=$(),n=K((()=>s?.[r+e]?.(...o)??t),[s,r,e,...o,t]),i=Z();return X((()=>i.current=n()),[n]),ue(l+e,s,((...e)=>{i.current=y(u)?n():e[u],d([])}),[n,u],o),i.current},ue=(e,s,t,o=_,u=_,...r)=>Y((()=>{const o=s?.["add"+e+l]?.(...u,t,...r);return()=>s?.delListener(o)}),[s,e,...u,...o,...r]),re=(e,s,t,o=_,u=f,r=_,...l)=>{const d=E(e);return K((e=>T(d,(o=>T(t(e,o),(t=>u(o["set"+s](...v(l,(s=>S(s)?s(e,o):s)),t),t)))))),[d,s,...o,...r,...l])},le=(e,s,t=f,o=_,...u)=>{const r=E(e);return K((()=>t(r?.["del"+s](...u))),[r,s,...o,...u])},de=(e,s,t)=>{const o=W(e);return K((()=>o?.[s](t)),[o,s,t])},ne=e=>oe(C,E(e),_),ie=(e,s)=>oe(w,E(s),_,[e]),ae=(e,s,t,o=0,u,r)=>oe(R,E(r),_,[e,s,t,o,u],6),ce=(e,s,t)=>oe(g,E(t),_,[e,s]),Ie=(e,s,t,o)=>oe(k,E(o),void 0,[e,s,t],4),Ce=e=>oe(m,E(e),_),be=(e,s)=>oe(L,E(s),void 0,[e]),pe=(e,s)=>oe("Metric",A(s),void 0,[e]),we=(e,s)=>oe("SliceIds",G(s),_,[e]),Re=(e,s,t)=>oe("Slice"+w,G(t),_,[e,s]),ke=(e,s,t)=>oe("RemoteRowId",j(t),void 0,[e,s]),ge=(e,s,t)=>oe("Local"+w,j(t),_,[e,s]),Le=(e,s,t)=>oe("Linked"+w,j(t),_,[e,s]),he=(e,s)=>oe(d+w,U(s),_,[e]),me=(e,s,t,o=0,u,r)=>oe(d+R,U(r),_,[e,s,t,o,u],6),ye=(e,s,t)=>oe(d+g,U(t),_,[e,s]),Te=(e,s,t,o)=>oe(d+k,U(o),void 0,[e,s,t]),Ve=e=>oe("CheckpointIds",W(e),se),Se=(e,s)=>oe("Checkpoint",W(s),void 0,[e]),fe=e=>de(e,"goBackward"),ve=e=>de(e,"goForward"),{PureComponent:xe,Fragment:Pe,createElement:qe,useCallback:Be,useLayoutEffect:He,useRef:Me,useState:De}=s,Fe=(e,...s)=>y(e)?{}:e(...s),Oe=(e,s)=>[e,e?.getStore(),e?.getLocalTableId(s),e?.getRemoteTableId(s)],{useCallback:Qe,useContext:Ee,useMemo:Ae,useState:Ge}=s,je=({tableId:e,store:s,rowComponent:t=Ne,getRowComponentProps:o,customCellIds:u,separator:r,debugIds:l},d)=>Je(v(d,(r=>qe(t,{...Fe(o,r),key:r,tableId:e,rowId:r,customCellIds:u,store:s,debugIds:l}))),r,l,e),Ue=({queryId:e,queries:s,resultRowComponent:t=_e,getResultRowComponentProps:o,separator:u,debugIds:r},l)=>Je(v(l,(u=>qe(t,{...Fe(o,u),key:u,queryId:e,rowId:u,queries:s,debugIds:r}))),u,r,e),We=({relationshipId:e,relationships:s,rowComponent:t=Ne,getRowComponentProps:o,separator:u,debugIds:r},l,d)=>{const[n,i,a]=Oe(j(s),e),c=l(e,d,n);return Je(v(c,(e=>qe(t,{...Fe(o,e),key:e,tableId:a,rowId:e,store:i,debugIds:r}))),u,r,d)},ze=e=>({checkpoints:s,checkpointComponent:t=es,getCheckpointComponentProps:o,separator:u,debugIds:r})=>{const l=W(s);return Je(v(e(Ve(l)),(e=>qe(t,{...Fe(o,e),key:e,checkpoints:l,checkpointId:e,debugIds:r}))),u)},Je=(e,s,t,o)=>{const u=y(s)||!Array.isArray(e)?e:v(e,((e,t)=>t>0?[s,e]:e));return t?[o,":{",u,"}"]:u},Ke=({tableId:e,rowId:s,cellId:t,store:u,debugIds:r})=>Je(o+(Ie(e,s,t,u)??o),void 0,r,t),Ne=({tableId:e,rowId:s,store:t,cellComponent:o=Ke,getCellComponentProps:u,customCellIds:r,separator:l,debugIds:d})=>Je(v(((e,s,t,o)=>{const u=ce(s,t,o);return e??u})(r,e,s,t),(r=>qe(o,{...Fe(u,r),key:r,tableId:e,rowId:s,cellId:r,store:t,debugIds:d}))),l,d,s),Xe=e=>je(e,ie(e.tableId,e.store)),Ye=({valueId:e,store:s,debugIds:t})=>Je(o+(be(e,s)??o),void 0,t,e),Ze=({indexId:e,sliceId:s,indexes:t,rowComponent:o=Ne,getRowComponentProps:u,separator:r,debugIds:l})=>{const[d,n,i]=((e,s)=>[e,e?.getStore(),e?.getTableId(s)])(G(t),e),a=Re(e,s,d);return Je(v(a,(e=>qe(o,{...Fe(u,e),key:e,tableId:i,rowId:e,store:n,debugIds:l}))),r,l,s)},$e=({queryId:e,rowId:s,cellId:t,queries:u,debugIds:r})=>Je(o+(Te(e,s,t,u)??o),void 0,r,t),_e=({queryId:e,rowId:s,queries:t,resultCellComponent:o=$e,getResultCellComponentProps:u,separator:r,debugIds:l})=>Je(v(ye(e,s,t),(r=>qe(o,{...Fe(u,r),key:r,queryId:e,rowId:s,cellId:r,queries:t,debugIds:l}))),r,l,s),es=({checkpoints:e,checkpointId:s,debugIds:t})=>Je(Se(s,e)??o,void 0,t,s),ss=ze((e=>e[0])),ts=ze((e=>y(e[1])?[]:[e[1]])),os=ze((e=>e[2]));e.BackwardCheckpointsView=ss,e.CellView=Ke,e.CheckpointView=es,e.CurrentCheckpointView=ts,e.ForwardCheckpointsView=os,e.IndexView=({indexId:e,indexes:s,sliceComponent:t=Ze,getSliceComponentProps:o,separator:u,debugIds:r})=>Je(v(we(e,s),(u=>qe(t,{...Fe(o,u),key:u,indexId:e,sliceId:u,indexes:s,debugIds:r}))),u,r,e),e.LinkedRowsView=e=>We(e,Le,e.firstRowId),e.LocalRowsView=e=>We(e,ge,e.remoteRowId),e.MetricView=({metricId:e,metrics:s,debugIds:t})=>Je(pe(e,s)??o,void 0,t,e),e.Provider=({store:e,storesById:s,metrics:t,metricsById:o,indexes:u,indexesById:r,relationships:l,relationshipsById:d,queries:n,queriesById:i,checkpoints:a,checkpointsById:c,children:I})=>{const C=Ee(D),[b,p]=Ge({}),w=Qe(((e,s)=>p((t=>P(t,e)==s?t:{...t,[e]:s}))),[]),R=Qe((e=>p((s=>({...q(s,e)})))),[]);return qe(D.Provider,{value:Ae((()=>[e??C[0],{...C[1],...s,...b},t??C[2],{...C[3],...o},u??C[4],{...C[5],...r},l??C[6],{...C[7],...d},n??C[8],{...C[9],...i},a??C[10],{...C[11],...c},w,R]),[e,s,b,t,o,u,r,l,d,n,i,a,c,C,w,R])},I)},e.RemoteRowView=({relationshipId:e,localRowId:s,relationships:t,rowComponent:o=Ne,getRowComponentProps:u,debugIds:r})=>{const[l,d,,n]=Oe(j(t),e),i=ke(e,s,l);return Je(y(n)||y(i)?null:qe(o,{...Fe(u,i),key:i,tableId:n,rowId:i,store:d,debugIds:r}),void 0,r,s)},e.ResultCellView=$e,e.ResultRowView=_e,e.ResultSortedTableView=({cellId:e,descending:s,offset:t,limit:o,...u})=>Ue(u,me(u.queryId,e,s,t,o,u.queries)),e.ResultTableView=e=>Ue(e,he(e.queryId,e.queries)),e.RowView=Ne,e.SliceView=Ze,e.SortedTableView=({cellId:e,descending:s,offset:t,limit:o,...u})=>je(u,ae(u.tableId,e,s,t,o,u.store)),e.TableView=Xe,e.TablesView=({store:e,tableComponent:s=Xe,getTableComponentProps:t,separator:o,debugIds:u})=>Je(v(ne(e),(o=>qe(s,{...Fe(t,o),key:o,tableId:o,store:e,debugIds:u}))),o),e.ValueView=Ye,e.ValuesView=({store:e,valueComponent:s=Ye,getValueComponentProps:t,separator:o,debugIds:u})=>Je(v(Ce(e),(o=>qe(s,{...Fe(t,o),key:o,valueId:o,store:e,debugIds:u}))),o),e.useAddRowCallback=(e,s,t=_,o,u=f,r=_,l=!0)=>{const d=E(o);return K((t=>T(d,(o=>T(s(t,o),(s=>u(o.addRow(S(e)?e(t,o):e,s,l),o,s)))))),[d,e,...t,...r,l])},e.useCell=Ie,e.useCellIds=ce,e.useCellIdsListener=(e,s,t,o,u,r)=>ue(g,E(r),t,o,[e,s],u),e.useCellListener=(e,s,t,o,u,r,l)=>ue(k,E(l),o,u,[e,s,t],r),e.useCheckpoint=Se,e.useCheckpointIds=Ve,e.useCheckpointIdsListener=(e,s,t)=>ue("CheckpointIds",W(t),e,s),e.useCheckpointListener=(e,s,t,o)=>ue("Checkpoint",W(o),s,t,[e]),e.useCheckpoints=e=>F(e,10),e.useCheckpointsIds=()=>Q(11),e.useCheckpointsOrCheckpointsById=W,e.useCreateCheckpoints=(e,s,t)=>te(e,s,t),e.useCreateIndexes=(e,s,t)=>te(e,s,t),e.useCreateMetrics=(e,s,t)=>te(e,s,t),e.useCreatePersister=(e,s,t=_,o,u=_,r,l=_)=>{const[,d]=$(),n=X((()=>s(e)),[e,...t]);return N((()=>((async()=>{o&&(await o(n),d([]))})(),()=>{n?.destroy(),r?.(n)})),[n,...u,...l]),n},e.useCreateQueries=(e,s,t)=>te(e,s,t),e.useCreateRelationships=(e,s,t)=>te(e,s,t),e.useCreateStore=(e,s=_)=>X(e,s),e.useDelCellCallback=(e,s,t,o,u,r,l)=>le(u,k,r,l,e,s,t,o),e.useDelRowCallback=(e,s,t,o,u)=>le(t,b,o,u,e,s),e.useDelTableCallback=(e,s,t,o)=>le(s,c,t,o,e),e.useDelTablesCallback=(e,s,t)=>le(e,I,s,t),e.useDelValueCallback=(e,s,t,o)=>le(s,L,t,o,e),e.useDelValuesCallback=(e,s,t)=>le(e,h,s,t),e.useDidFinishTransactionListener=(e,s,t)=>ue("DidFinish"+J,E(t),e,s),e.useGoBackwardCallback=fe,e.useGoForwardCallback=ve,e.useGoToCallback=(e,s=_,t,o=f,u=_)=>{const r=W(t);return K((s=>T(r,(t=>T(e(s),(e=>o(t.goTo(e),e)))))),[r,...s,...u])},e.useHasCell=(e,s,t,o)=>oe(k,E(o),!1,[e,s,t],4,i,n),e.useHasCellListener=(e,s,t,o,u,r,l)=>ue(n+k,E(l),o,u,[e,s,t],r),e.useHasRow=(e,s,t)=>oe(b,E(t),!1,[e,s],3,i,n),e.useHasRowListener=(e,s,t,o,u,r)=>ue(n+b,E(r),t,o,[e,s],u),e.useHasTable=(e,s)=>oe(c,E(s),!1,[e],2,i,n),e.useHasTableCell=(e,s,t)=>oe(c+k,E(t),!1,[e,s],3,i,n),e.useHasTableCellListener=(e,s,t,o,u,r)=>ue(n+c+k,E(r),t,o,[e,s],u),e.useHasTableListener=(e,s,t,o,u)=>ue(n+c,E(u),s,t,[e],o),e.useHasTables=e=>oe(I,E(e),!1,[],1,i,n),e.useHasTablesListener=(e,s,t,o)=>ue(n+I,E(o),e,s,[],t),e.useHasValue=(e,s)=>oe(L,E(s),!1,[e],2,i,n),e.useHasValueListener=(e,s,t,o,u)=>ue(n+L,E(u),s,t,[e],o),e.useHasValues=e=>oe(h,E(e),!1,[],1,i,n),e.useHasValuesListener=(e,s,t,o)=>ue(n+h,E(o),e,s,[],t),e.useIndexIds=e=>oe("IndexIds",G(e),_),e.useIndexes=e=>F(e,4),e.useIndexesIds=()=>Q(5),e.useIndexesOrIndexesById=G,e.useLinkedRowIds=Le,e.useLinkedRowIdsListener=(e,s,t,o,u)=>ue("Linked"+w,j(u),t,o,[e,s]),e.useLocalRowIds=ge,e.useLocalRowIdsListener=(e,s,t,o,u)=>ue("Local"+w,j(u),t,o,[e,s]),e.useMetric=pe,e.useMetricIds=e=>oe("MetricIds",A(e),_),e.useMetricListener=(e,s,t,o)=>ue("Metric",A(o),s,t,[e]),e.useMetrics=e=>F(e,2),e.useMetricsIds=()=>Q(3),e.useMetricsOrMetricsById=A,e.useProvideStore=(e,s)=>{const{12:t,13:o}=H(D);M((()=>(t?.(e,s),()=>o?.(e))),[t,e,s,o])},e.useQueries=e=>F(e,8),e.useQueriesIds=()=>Q(9),e.useQueriesOrQueriesById=U,e.useQueryIds=e=>oe("QueryIds",U(e),_),e.useRedoInformation=e=>{const s=W(e),[,,[t]]=Ve(s);return[!y(t),ve(s),t,T(t,(e=>s?.getCheckpoint(e)))??o]},e.useRelationshipIds=e=>oe("RelationshipIds",j(e),_),e.useRelationships=e=>F(e,6),e.useRelationshipsIds=()=>Q(7),e.useRelationshipsOrRelationshipsById=j,e.useRemoteRowId=ke,e.useRemoteRowIdListener=(e,s,t,o,u)=>ue("RemoteRowId",j(u),t,o,[e,s]),e.useResultCell=Te,e.useResultCellIds=ye,e.useResultCellIdsListener=(e,s,t,o,u)=>ue(d+g,U(u),t,o,[e,s]),e.useResultCellListener=(e,s,t,o,u,r)=>ue(d+k,U(r),o,u,[e,s,t]),e.useResultRow=(e,s,t)=>oe(d+b,U(t),ee,[e,s]),e.useResultRowCount=(e,s)=>oe(d+p,U(s),0,[e]),e.useResultRowCountListener=(e,s,t,o)=>ue(d+p,U(o),s,t,[e]),e.useResultRowIds=he,e.useResultRowIdsListener=(e,s,t,o)=>ue(d+w,U(o),s,t,[e]),e.useResultRowListener=(e,s,t,o,u)=>ue(d+b,U(u),t,o,[e,s]),e.useResultSortedRowIds=me,e.useResultSortedRowIdsListener=(e,s,t,o,u,r,l,n)=>ue(d+R,U(n),r,l,[e,s,t,o,u]),e.useResultTable=(e,s)=>oe(d+c,U(s),ee,[e]),e.useResultTableCellIds=(e,s)=>oe(d+c+g,U(s),_,[e]),e.useResultTableCellIdsListener=(e,s,t,o)=>ue(d+c+g,U(o),s,t,[e]),e.useResultTableListener=(e,s,t,o)=>ue(d+c,U(o),s,t,[e]),e.useRow=(e,s,t)=>oe(b,E(t),ee,[e,s]),e.useRowCount=(e,s)=>oe(p,E(s),0,[e]),e.useRowCountListener=(e,s,t,o,u)=>ue(p,E(u),s,t,[e],o),e.useRowIds=ie,e.useRowIdsListener=(e,s,t,o,u)=>ue(w,E(u),s,t,[e],o),e.useRowListener=(e,s,t,o,u,r)=>ue(b,E(r),t,o,[e,s],u),e.useSetCellCallback=(e,s,t,o,u,r,l,d)=>re(r,k,o,u,l,d,e,s,t),e.useSetCheckpointCallback=(e=f,s=_,t,o=f,u=_)=>{const r=W(t);return K((s=>T(r,(t=>{const u=e(s);o(t.addCheckpoint(u),t,u)}))),[r,...s,...u])},e.useSetPartialRowCallback=(e,s,t,o,u,r,l)=>re(u,"PartialRow",t,o,r,l,e,s),e.useSetPartialValuesCallback=(e,s,t,o,u)=>re(t,"PartialValues",e,s,o,u),e.useSetRowCallback=(e,s,t,o,u,r,l)=>re(u,b,t,o,r,l,e,s),e.useSetTableCallback=(e,s,t,o,u,r)=>re(o,c,s,t,u,r,e),e.useSetTablesCallback=(e,s,t,o,u)=>re(t,I,e,s,o,u),e.useSetValueCallback=(e,s,t,o,u,r)=>re(o,L,s,t,u,r,e),e.useSetValuesCallback=(e,s,t,o,u)=>re(t,h,e,s,o,u),e.useSliceIds=we,e.useSliceIdsListener=(e,s,t,o)=>ue("SliceIds",G(o),s,t,[e]),e.useSliceRowIds=Re,e.useSliceRowIdsListener=(e,s,t,o,u)=>ue("Slice"+w,G(u),t,o,[e,s]),e.useSortedRowIds=ae,e.useSortedRowIdsListener=(e,s,t,o,u,r,l,d,n)=>ue(R,E(n),r,l,[e,s,t,o,u],d),e.useStartTransactionListener=(e,s,t)=>ue("Start"+J,E(t),e,s),e.useStore=e=>F(e,0),e.useStoreIds=()=>Q(1),e.useStoreOrStoreById=E,e.useTable=(e,s)=>oe(c,E(s),ee,[e]),e.useTableCellIds=(e,s)=>oe(c+g,E(s),_,[e]),e.useTableCellIdsListener=(e,s,t,o,u)=>ue(c+g,E(u),s,t,[e],o),e.useTableIds=ne,e.useTableIdsListener=(e,s,t,o)=>ue(C,E(o),e,s,_,t),e.useTableListener=(e,s,t,o,u)=>ue(c,E(u),s,t,[e],o),e.useTables=e=>oe(I,E(e),ee),e.useTablesListener=(e,s,t,o)=>ue(I,E(o),e,s,_,t),e.useUndoInformation=e=>{const s=W(e),[t,u]=Ve(s);return[(r=t,!(0==r.length)),fe(s),u,T(u,(e=>s?.getCheckpoint(e)))??o];var r},e.useValue=be,e.useValueIds=Ce,e.useValueIdsListener=(e,s,t,o)=>ue(m,E(o),e,s,_,t),e.useValueListener=(e,s,t,o,u)=>ue(L,E(u),s,t,[e],o),e.useValues=e=>oe(h,E(e),ee),e.useValuesListener=(e,s,t,o)=>ue(h,E(o),e,s,_,t),e.useWillFinishTransactionListener=(e,s,t)=>ue("WillFinish"+J,E(t),e,s)},"object"==typeof exports&&"undefined"!=typeof module?s(exports,require("react")):"function"==typeof define&&define.amd?define(["exports","react"],s):s((e="undefined"!=typeof globalThis?globalThis:e||self).TinyBaseUiReact={},e.React);
|
package/lib/umd/ui-react.js.gz
CHANGED
|
Binary file
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var e,n;e=this,n=function(e,n){"use strict";const t=e=>typeof e,l="tinybase",o=",",i=t(""),r=(e,n)=>e.repeat(n),u=Promise,
|
|
1
|
+
var e,n;e=this,n=function(e,n){"use strict";const t=e=>typeof e,l="tinybase",o=",",i=t(""),r=(e,n)=>e.repeat(n),u=Promise,d=clearInterval,a=e=>null==e,s=(e,n,t)=>a(e)?null==t?void 0:t():n(e),c=e=>t(e)==i,v=(e,n,t)=>e.slice(n,t),y=e=>e.length,f=e=>{return n=function*(){return u.all(e)},new Promise(((e,t)=>{var l=e=>{try{i(n.next(e))}catch(e){t(e)}},o=e=>{try{i(n.throw(e))}catch(e){t(e)}},i=n=>n.done?e(n.value):Promise.resolve(n.value).then(l,o);i((n=n.apply(void 0,null)).next())}));var n},p="_",h="_id",E=e=>`"${e.replace(/"/g,'""')}"`,m="SELECT",T=(e,n="")=>e.join(n),x=(e,n)=>e.map(n),A=e=>0==y(e),O=(e,n)=>e.filter(n),P=(e,...n)=>e.push(...n),b=(e,n)=>{var t;return null!=(t=null==e?void 0:e.has(n))&&t},L=e=>{var n;return[...null!=(n=null==e?void 0:e.values())?n:[]]},N=(e,n)=>null==e?void 0:e.delete(n),R=Object,w=e=>R.getPrototypeOf(e),g=R.keys,S=R.freeze,C=(e=[])=>R.fromEntries(e),D=(...e)=>R.assign({},...e),I=(e,n)=>x(R.entries(e),(([e,t])=>n(t,e))),F=e=>R.values(e),M=e=>y(g(e)),$=e=>(e=>!a(e)&&s(w(e),(e=>e==R.prototype||a(w(e))),(()=>!0)))(e)&&0==M(e),j=e=>new Map(e),_=e=>{var n;return[...null!=(n=null==e?void 0:e.keys())?n:[]]},B=(e,n)=>null==e?void 0:e.get(n),q=(e,n)=>{var t;return x([...null!=(t=null==e?void 0:e.entries())?t:[]],(([e,t])=>n(t,e)))},H=(e,n,t)=>a(t)?(N(e,n),e):null==e?void 0:e.set(n,t),W=(e,n,t)=>(b(e,n)||H(e,n,t()),B(e,n)),Y=(e,n,t,l=H)=>(I(n,((n,l)=>t(e,l,n))),((e,n)=>{((e,n)=>{null==e||e.forEach(n)})(e,((e,t)=>n(t)))})(e,(t=>((e,n)=>!a(((e,n)=>s(e,(e=>e[n])))(e,n)))(n,t)?0:l(e,t))),e),k=e=>new Set(Array.isArray(e)||a(e)?e:[e]),G=(e,n)=>null==e?void 0:e.add(n);var J=Object.defineProperty,U=Object.getOwnPropertySymbols,z=Object.prototype.hasOwnProperty,K=Object.prototype.propertyIsEnumerable,V=(e,n,t)=>n in e?J(e,n,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[n]=t,Q=(e,n)=>{for(var t in n||(n={}))z.call(n,t)&&V(e,t,n[t]);if(U)for(var t of U(n))K.call(n,t)&&V(e,t,n[t]);return e},X=(e,n,t)=>new Promise(((l,o)=>{var i=e=>{try{u(t.next(e))}catch(e){o(e)}},r=e=>{try{u(t.throw(e))}catch(e){o(e)}},u=e=>e.done?l(e.value):Promise.resolve(e.value).then(i,r);u((t=t.apply(e,n)).next())}));const Z=m+"*FROM",ee="FROM pragma_table_",ne="WHERE",te=(e,n,t)=>{const l=j();return[()=>X(void 0,null,(function*(){return Y(l,C(yield f(x(yield e("SELECT name "+ee+"list WHERE schema='main'AND type='table'AND name IN("+oe(n)+")ORDER BY name",n),(n=>X(void 0,[n],(function*({name:n}){return[n,C(x(yield e(m+" name,type "+ee+"info(?)",[n]),(({name:e,type:n})=>[e,n])))]})))))),((e,n,t)=>H(l,n,Y(W(l,n,j),t,((e,n,t)=>{t!=B(e,n)&&H(e,n,t)}),((e,n)=>H(e,n))))),((e,n)=>H(l,n)))})),(n,t)=>X(void 0,null,(function*(){return((e,n)=>!a(B(B(l,e),n)))(n,t)?C(O(x(yield e(Z+E(n)),(e=>{return[e[t],(n=Q({},e),l=t,delete n[l],n)];var n,l})),(([e,n])=>!a(e)&&!$(n)))):{}})),(n,t,i,r,u,d=!1)=>X(void 0,null,(function*(){const s=k();I(null!=i?i:{},(e=>x(g(null!=e?e:{}),(e=>G(s,e)))));const c=L(s);if(!d&&u&&A(c)&&b(l,n))return yield e("DROP TABLE"+E(n)),void H(l,n);if(A(c)||b(l,n)){const o=B(l,n),i=k(_(o));yield f([...x(c,(t=>X(void 0,null,(function*(){N(i,t)||(yield e(`ALTER TABLE${E(n)}ADD${E(t)}`),H(o,t,""))})))),...!d&&r?x(L(i),(l=>X(void 0,null,(function*(){l!=t&&(yield e(`ALTER TABLE${E(n)}DROP${E(l)}`),H(o,l))})))):[]])}else yield e(`CREATE TABLE${E(n)}(${E(t)} PRIMARY KEY ON CONFLICT REPLACE${T(x(c,(e=>o+E(e))))});`),H(l,n,j([[t,""],...x(c,(e=>[e,""]))]));if(d)a(i)?yield e("DELETE FROM"+E(n)+"WHERE 1"):yield f(I(i,((l,o)=>X(void 0,null,(function*(){a(l)?yield e("DELETE FROM"+E(n)+ne+E(t)+"=?",[o]):A(c)||(yield le(e,n,t,g(l),[o,...F(l)]))})))));else if(A(c))b(l,n)&&(yield e("DELETE FROM"+E(n)+"WHERE 1"));else{const o=O(_(B(l,n)),(e=>e!=t)),r=[],u=[];I(null!=i?i:{},((e,n)=>{P(r,n,...x(o,(n=>null==e?void 0:e[n]))),P(u,n)})),yield le(e,n,t,o,r),yield e("DELETE FROM"+E(n)+ne+E(t)+"NOT IN("+oe(u)+")",u)}})),n=>X(void 0,null,(function*(){let l;yield e("BEGIN");try{l=yield n()}catch(e){null==t||t(e)}return yield e("END"),l}))]},le=(e,n,t,l,i)=>X(void 0,null,(function*(){return yield e("INSERT INTO"+E(n)+"("+E(t)+T(x(l,(e=>o+E(e))))+")VALUES"+v(r(`,(?${r(",?",y(l))})`,y(i)/(y(l)+1)),1)+"ON CONFLICT("+E(t)+")DO UPDATE SET"+T(x(l,(e=>E(e)+"=excluded."+E(e))),o),i)})),oe=e=>T(x(e,(()=>"?")),o),ie=JSON.parse;var re=(e,n,t)=>new Promise(((l,o)=>{var i=e=>{try{u(t.next(e))}catch(e){o(e)}},r=e=>{try{u(t.throw(e))}catch(e){o(e)}},u=e=>e.done?l(e.value):Promise.resolve(e.value).then(i,r);u((t=t.apply(e,n)).next())}));const ue=j(),de=j(),ae=(e,n,t,l,o,i,[r,u]=[],d=[])=>{let c,v,y,f=0,p=0;W(ue,d,(()=>0)),W(de,d,(()=>[]));const h=e=>re(void 0,null,(function*(){return 2!=f&&(f=1,yield E.schedule((()=>re(void 0,null,(function*(){yield e(),f=0}))))),E})),E={load:(t,l)=>re(void 0,null,(function*(){return yield h((()=>re(void 0,null,(function*(){try{e.setContent(yield n())}catch(n){e.setContent([t,l])}}))))})),startAutoLoad:(...t)=>re(void 0,[...t],(function*(t={},o={}){return E.stopAutoLoad(),yield E.load(t,o),p=1,y=l(((t,l)=>re(void 0,null,(function*(){if(l){const n=l();yield h((()=>re(void 0,null,(function*(){return e.setTransactionChanges(n)}))))}else yield h((()=>re(void 0,null,(function*(){var l;try{e.setContent(null!=(l=null==t?void 0:t())?l:yield n())}catch(e){null==i||i(e)}}))))})))),E})),stopAutoLoad:()=>(p&&(o(y),y=void 0,p=0),E),save:n=>re(void 0,null,(function*(){return 1!=f&&(f=2,yield E.schedule((()=>re(void 0,null,(function*(){try{yield t(e.getContent,n)}catch(e){null==i||i(e)}f=0}))))),E})),startAutoSave:()=>re(void 0,null,(function*(){return yield E.stopAutoSave().save(),c=e.addDidFinishTransactionListener(((e,n)=>{const[t,l]=n();$(t)&&$(l)||E.save((()=>[t,l]))})),E})),stopAutoSave:()=>(s(c,e.delListener),c=void 0,E),schedule:(...e)=>re(void 0,null,(function*(){return P(B(de,d),...e),yield re(void 0,null,(function*(){if(!B(ue,d)){for(H(ue,d,1);!a((e=B(de,d),v=e.shift()));)try{yield v()}catch(e){null==i||i(e)}H(ue,d,0)}var e})),E})),getStore:()=>e,destroy:()=>E.stopAutoLoad().stopAutoSave(),getStats:()=>({})};return r&&(E[r]=()=>u),S(E)};var se=(e,n,t)=>new Promise(((l,o)=>{var i=e=>{try{u(t.next(e))}catch(e){o(e)}},r=e=>{try{u(t.throw(e))}catch(e){o(e)}},u=e=>e.done?l(e.value):Promise.resolve(e.value).then(i,r);u((t=t.apply(e,n)).next())}));const ce="store",ve=(e,n,t,l,o,[i],r,u,d)=>{const[a,s,c,v]=te(n,r,o);return ae(e,(()=>se(void 0,null,(function*(){return yield v((()=>se(void 0,null,(function*(){var e,n;return yield a(),ie(null!=(n=null==(e=(yield s(i,h))[p])?void 0:e[ce])?n:"null")}))))}))),(e=>se(void 0,null,(function*(){return yield v((()=>se(void 0,null,(function*(){var n,t;yield a(),yield c(i,h,{[p]:{[ce]:(t=null!=(n=e())?n:null,JSON.stringify(t,((e,n)=>n instanceof Map?R.fromEntries([...n]):n)))}},!0,!0)}))))}))),t,l,o,[d,u],u)};var ye=(e,n,t)=>new Promise(((l,o)=>{var i=e=>{try{u(t.next(e))}catch(e){o(e)}},r=e=>{try{u(t.throw(e))}catch(e){o(e)}},u=e=>e.done?l(e.value):Promise.resolve(e.value).then(i,r);u((t=t.apply(e,n)).next())}));const fe=(e,n,t,l,o,[i,r,[u,d,s]],c,v,y)=>{const[E,m,T,x]=te(n,c,o),A=(e,n)=>ye(void 0,null,(function*(){return yield f(q(r,((t,l)=>ye(void 0,[t,l],(function*([t,l,o,i],r){const u=e[r];n&&void 0===u||(yield T(t,l,u,o,i,n))})))))})),P=(e,n)=>ye(void 0,null,(function*(){return d?yield T(s,h,{[p]:e},!0,!0,n):null}));return ae(e,(()=>ye(void 0,null,(function*(){return yield x((()=>ye(void 0,null,(function*(){yield E();const e=yield ye(void 0,null,(function*(){return C(O(yield f(q(i,((e,n)=>ye(void 0,[e,n],(function*([e,n],t){return[e,yield m(t,n)]}))))),(e=>!$(e[1]))))})),n=yield ye(void 0,null,(function*(){return u?(yield m(s,h))[p]:{}}));return $(e)&&a(n)?void 0:[e,n]}))))}))),((e,n)=>ye(void 0,null,(function*(){return yield x((()=>ye(void 0,null,(function*(){if(yield E(),a(n)){const[n,t]=e();yield A(n),yield P(t)}else{const[e,t]=n();yield A(e,!0),yield P(t,!0)}}))))}))),t,l,o,[y,v],v)},pe="json",he="autoLoadIntervalSeconds",Ee="rowIdColumnName",me="tableId",Te="tableName",xe={mode:pe,[he]:1},Ae={load:0,save:0,[Te]:l+"_values"},Oe=(e,n,t,l)=>{const o=j();return I(e,((e,i)=>{const r=v(F(D(n,c(e)?{[t]:e}:e)),0,M(n));a(r[0])||l(i,r[0])||H(o,i,r)})),o};var Pe=(e,n,t)=>new Promise(((l,o)=>{var i=e=>{try{u(t.next(e))}catch(e){o(e)}},r=e=>{try{u(t.throw(e))}catch(e){o(e)}},u=e=>e.done?l(e.value):Promise.resolve(e.value).then(i,r);u((t=t.apply(e,n)).next())}));const be="pragma ",Le="data_version",Ne="schema_version",Re=(e,n,t,o,i,r,u,a,s="getDb")=>{let y,f,p;const[E,T,x,A]=(e=>{const n=(e=>D(xe,c(e)?{storeTableName:e}:null!=e?e:{}))(e),t=n[he];if(n.mode==pe){const{storeTableName:e=l}=n;return[1,t,[e],k(e)]}const{tables:{load:o={},save:i={}}={},values:r={}}=n,u=v(F(D(Ae,r)),0,M(Ae)),d=u[2],a=k(d);return[0,t,[Oe(o,{[me]:null,[Ee]:h},me,(e=>G(a,e)&&e==d)),Oe(i,{[Te]:null,[Ee]:h,deleteEmptyColumns:0,deleteEmptyTable:0},Te,((e,n)=>G(a,n)&&n==d)),u],a]})(n);return(E?ve:fe)(e,r?(e,n)=>Pe(void 0,null,(function*(){return r(e,n),yield t(e,n)})):t,(e=>{return[(n=()=>Pe(void 0,null,(function*(){try{const n=(yield t(be+Le))[0][Le],l=(yield t(be+Ne))[0][Ne],o=(yield t(m+" TOTAL_CHANGES() c"))[0].c;n==(null!=y?y:y=n)&&l==(null!=f?f:f=l)&&o==(null!=p?p:p=o)||(e(),y=n,f=l)}catch(e){}})),l=T,n(),setInterval(n,1e3*l)),o((n=>A.has(n)?e():0))];var n,l}),(([e,n])=>{d(e),y=f=null,i(n)}),u,x,L(A),a,s)};e.createExpoSqliteNextPersister=(e,t,l,o,i)=>Re(e,l,((e,...n)=>{return l=[e,...n],o=function*(e,n=[]){return yield t.getAllAsync(e,n)},new Promise(((e,n)=>{var t=e=>{try{r(o.next(e))}catch(e){n(e)}},i=e=>{try{r(o.throw(e))}catch(e){n(e)}},r=n=>n.done?e(n.value):Promise.resolve(n.value).then(t,i);r((o=o.apply(void 0,l)).next())}));var l,o}),(e=>n.addDatabaseChangeListener((({tableName:n})=>e(n)))),(e=>e.remove()),o,i,t)},"object"==typeof exports&&"undefined"!=typeof module?n(exports,require("expo-sqlite/next")):"function"==typeof define&&define.amd?define(["exports","expo-sqlite/next"],n):n((e="undefined"!=typeof globalThis?globalThis:e||self).TinyBasePersisterExpoSqliteNext={},e["expo-sqlite/next"]);
|
|
Binary file
|
package/lib/umd-es6/ui-react.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var e,s;e=this,s=function(e,s){"use strict";const t=e=>typeof e,l="",o=t(l),r=t(t),u="Listener",n="Result",d="Has",i="has",a="Ids",c="Table",I=c+"s",C=c+a,p="Row",b=p+"Count",w=p+a,R="Sorted"+p+a,k="Cell",v=k+a,g="Value",h=g+"s",y=g+a,m=e=>null==e,L=(e,s,t)=>m(e)?null==t?void 0:t():s(e),f=e=>t(e)==o,T=e=>t(e)==r,V=()=>{},S=(e,s)=>e.map(s),P=Object.keys,x=(e,s)=>L(e,(e=>e[s])),{createContext:O,useContext:q,useEffect:B}=s,H=O([]),M=(e,s)=>{var t;const l=q(H);return m(e)?l[s]:f(e)?x(null!=(t=l[s+1])?t:{},e):e},D=(e,s)=>{const t=M(e,s);return m(e)||f(e)?t:e},j=e=>{var s;return P(null!=(s=q(H)[e])?s:{})},F=e=>D(e,0),Q=e=>D(e,2),E=e=>D(e,4),A=e=>D(e,6),G=e=>D(e,8),U=e=>D(e,10),W=e=>e.toLowerCase();W(u);const z="Transaction";W(z);const{useCallback:J,useEffect:K,useMemo:N,useLayoutEffect:X,useRef:Y,useState:Z}=s,$=[],_={},ee=[[],void 0,[]],se=(e,s,t=$)=>{const l=N((()=>s(e)),[e,...t]);return K((()=>()=>l.destroy()),[l]),l},te=(e,s,t,l=$,o,r="get",u="")=>{const[,n]=Z(),d=J((()=>{var o,u;return null!=(u=null==(o=null==s?void 0:s[r+e])?void 0:o.call(s,...l))?u:t}),[s,e,...l,t]),i=Y();return N((()=>i.current=d()),[d]),le(u+e,s,((...e)=>{i.current=m(o)?d():e[o],n([])}),[d,o],l),i.current},le=(e,s,t,l=$,o=$,...r)=>X((()=>{var l;const n=null==(l=null==s?void 0:s["add"+e+u])?void 0:l.call(s,...o,t,...r);return()=>null==s?void 0:s.delListener(n)}),[s,e,...o,...l,...r]),oe=(e,s,t,l=$,o=V,r=$,...u)=>{const n=F(e);return J((e=>L(n,(l=>L(t(e,l),(t=>o(l["set"+s](...S(u,(s=>T(s)?s(e,l):s)),t),t)))))),[n,s,...l,...r,...u])},re=(e,s,t=V,l=$,...o)=>{const r=F(e);return J((()=>t(null==r?void 0:r["del"+s](...o))),[r,s,...l,...o])},ue=(e,s,t)=>{const l=U(e);return J((()=>null==l?void 0:l[s](t)),[l,s,t])},ne=e=>te(C,F(e),$),de=(e,s)=>te(w,F(s),$,[e]),ie=(e,s,t,l=0,o,r)=>te(R,F(r),$,[e,s,t,l,o],6),ae=(e,s,t)=>te(v,F(t),$,[e,s]),ce=(e,s,t,l)=>te(k,F(l),void 0,[e,s,t],4),Ie=e=>te(y,F(e),$),Ce=(e,s)=>te(g,F(s),void 0,[e]),pe=(e,s)=>te("Metric",Q(s),void 0,[e]),be=(e,s)=>te("SliceIds",E(s),$,[e]),we=(e,s,t)=>te("Slice"+w,E(t),$,[e,s]),Re=(e,s,t)=>te("RemoteRowId",A(t),void 0,[e,s]),ke=(e,s,t)=>te("Local"+w,A(t),$,[e,s]),ve=(e,s,t)=>te("Linked"+w,A(t),$,[e,s]),ge=(e,s)=>te(n+w,G(s),$,[e]),he=(e,s,t,l=0,o,r)=>te(n+R,G(r),$,[e,s,t,l,o],6),ye=(e,s,t)=>te(n+v,G(t),$,[e,s]),me=(e,s,t,l)=>te(n+k,G(l),void 0,[e,s,t]),Le=e=>te("CheckpointIds",U(e),ee),fe=(e,s)=>te("Checkpoint",U(s),void 0,[e]),Te=e=>ue(e,"goBackward"),Ve=e=>ue(e,"goForward"),{PureComponent:Se,Fragment:Pe,createElement:xe,useCallback:Oe,useLayoutEffect:qe,useRef:Be,useState:He}=s,Me=(e,...s)=>m(e)?{}:e(...s),De=(e,s)=>[e,null==e?void 0:e.getStore(),null==e?void 0:e.getLocalTableId(s),null==e?void 0:e.getRemoteTableId(s)];var je=Object.defineProperty,Fe=Object.defineProperties,Qe=Object.getOwnPropertyDescriptors,Ee=Object.getOwnPropertySymbols,Ae=Object.prototype.hasOwnProperty,Ge=Object.prototype.propertyIsEnumerable,Ue=(e,s,t)=>s in e?je(e,s,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[s]=t,We=(e,s)=>{for(var t in s||(s={}))Ae.call(s,t)&&Ue(e,t,s[t]);if(Ee)for(var t of Ee(s))Ge.call(s,t)&&Ue(e,t,s[t]);return e},ze=(e,s)=>Fe(e,Qe(s)),Je=(e,s)=>{var t={};for(var l in e)Ae.call(e,l)&&s.indexOf(l)<0&&(t[l]=e[l]);if(null!=e&&Ee)for(var l of Ee(e))s.indexOf(l)<0&&Ge.call(e,l)&&(t[l]=e[l]);return t};const{useCallback:Ke,useContext:Ne,useMemo:Xe,useState:Ye}=s,Ze=({tableId:e,store:s,rowComponent:t=ls,getRowComponentProps:l,customCellIds:o,separator:r,debugIds:u},n)=>ss(S(n,(r=>xe(t,ze(We({},Me(l,r)),{key:r,tableId:e,rowId:r,customCellIds:o,store:s,debugIds:u})))),r,u,e),$e=({queryId:e,queries:s,resultRowComponent:t=ds,getResultRowComponentProps:l,separator:o,debugIds:r},u)=>ss(S(u,(o=>xe(t,ze(We({},Me(l,o)),{key:o,queryId:e,rowId:o,queries:s,debugIds:r})))),o,r,e),_e=({relationshipId:e,relationships:s,rowComponent:t=ls,getRowComponentProps:l,separator:o,debugIds:r},u,n)=>{const[d,i,a]=De(A(s),e),c=u(e,n,d);return ss(S(c,(e=>xe(t,ze(We({},Me(l,e)),{key:e,tableId:a,rowId:e,store:i,debugIds:r})))),o,r,n)},es=e=>({checkpoints:s,checkpointComponent:t=is,getCheckpointComponentProps:l,separator:o,debugIds:r})=>{const u=U(s);return ss(S(e(Le(u)),(e=>xe(t,ze(We({},Me(l,e)),{key:e,checkpoints:u,checkpointId:e,debugIds:r})))),o)},ss=(e,s,t,l)=>{const o=m(s)||!Array.isArray(e)?e:S(e,((e,t)=>t>0?[s,e]:e));return t?[l,":{",o,"}"]:o},ts=({tableId:e,rowId:s,cellId:t,store:o,debugIds:r})=>{var u;return ss(l+(null!=(u=ce(e,s,t,o))?u:l),void 0,r,t)},ls=({tableId:e,rowId:s,store:t,cellComponent:l=ts,getCellComponentProps:o,customCellIds:r,separator:u,debugIds:n})=>ss(S(((e,s,t,l)=>{const o=ae(s,t,l);return null!=e?e:o})(r,e,s,t),(r=>xe(l,ze(We({},Me(o,r)),{key:r,tableId:e,rowId:s,cellId:r,store:t,debugIds:n})))),u,n,s),os=e=>Ze(e,de(e.tableId,e.store)),rs=({valueId:e,store:s,debugIds:t})=>{var o;return ss(l+(null!=(o=Ce(e,s))?o:l),void 0,t,e)},us=({indexId:e,sliceId:s,indexes:t,rowComponent:l=ls,getRowComponentProps:o,separator:r,debugIds:u})=>{const[n,d,i]=((e,s)=>[e,null==e?void 0:e.getStore(),null==e?void 0:e.getTableId(s)])(E(t),e),a=we(e,s,n);return ss(S(a,(e=>xe(l,ze(We({},Me(o,e)),{key:e,tableId:i,rowId:e,store:d,debugIds:u})))),r,u,s)},ns=({queryId:e,rowId:s,cellId:t,queries:o,debugIds:r})=>{var u;return ss(l+(null!=(u=me(e,s,t,o))?u:l),void 0,r,t)},ds=({queryId:e,rowId:s,queries:t,resultCellComponent:l=ns,getResultCellComponentProps:o,separator:r,debugIds:u})=>ss(S(ye(e,s,t),(r=>xe(l,ze(We({},Me(o,r)),{key:r,queryId:e,rowId:s,cellId:r,queries:t,debugIds:u})))),r,u,s),is=({checkpoints:e,checkpointId:s,debugIds:t})=>{var o;return ss(null!=(o=fe(s,e))?o:l,void 0,t,s)},as=es((e=>e[0])),cs=es((e=>m(e[1])?[]:[e[1]])),Is=es((e=>e[2]));e.BackwardCheckpointsView=as,e.CellView=ts,e.CheckpointView=is,e.CurrentCheckpointView=cs,e.ForwardCheckpointsView=Is,e.IndexView=({indexId:e,indexes:s,sliceComponent:t=us,getSliceComponentProps:l,separator:o,debugIds:r})=>ss(S(be(e,s),(o=>xe(t,ze(We({},Me(l,o)),{key:o,indexId:e,sliceId:o,indexes:s,debugIds:r})))),o,r,e),e.LinkedRowsView=e=>_e(e,ve,e.firstRowId),e.LocalRowsView=e=>_e(e,ke,e.remoteRowId),e.MetricView=({metricId:e,metrics:s,debugIds:t})=>{var o;return ss(null!=(o=pe(e,s))?o:l,void 0,t,e)},e.Provider=({store:e,storesById:s,metrics:t,metricsById:l,indexes:o,indexesById:r,relationships:u,relationshipsById:n,queries:d,queriesById:i,checkpoints:a,checkpointsById:c,children:I})=>{const C=Ne(H),[p,b]=Ye({}),w=Ke(((e,s)=>b((t=>x(t,e)==s?t:ze(We({},t),{[e]:s})))),[]),R=Ke((e=>b((s=>We({},((e,s)=>(delete e[s],e))(s,e))))),[]);return xe(H.Provider,{value:Xe((()=>[null!=e?e:C[0],We(We(We({},C[1]),s),p),null!=t?t:C[2],We(We({},C[3]),l),null!=o?o:C[4],We(We({},C[5]),r),null!=u?u:C[6],We(We({},C[7]),n),null!=d?d:C[8],We(We({},C[9]),i),null!=a?a:C[10],We(We({},C[11]),c),w,R]),[e,s,p,t,l,o,r,u,n,d,i,a,c,C,w,R])},I)},e.RemoteRowView=({relationshipId:e,localRowId:s,relationships:t,rowComponent:l=ls,getRowComponentProps:o,debugIds:r})=>{const[u,n,,d]=De(A(t),e),i=Re(e,s,u);return ss(m(d)||m(i)?null:xe(l,ze(We({},Me(o,i)),{key:i,tableId:d,rowId:i,store:n,debugIds:r})),void 0,r,s)},e.ResultCellView=ns,e.ResultRowView=ds,e.ResultSortedTableView=e=>{var s=e,{cellId:t,descending:l,offset:o,limit:r}=s,u=Je(s,["cellId","descending","offset","limit"]);return $e(u,he(u.queryId,t,l,o,r,u.queries))},e.ResultTableView=e=>$e(e,ge(e.queryId,e.queries)),e.RowView=ls,e.SliceView=us,e.SortedTableView=e=>{var s=e,{cellId:t,descending:l,offset:o,limit:r}=s,u=Je(s,["cellId","descending","offset","limit"]);return Ze(u,ie(u.tableId,t,l,o,r,u.store))},e.TableView=os,e.TablesView=({store:e,tableComponent:s=os,getTableComponentProps:t,separator:l,debugIds:o})=>ss(S(ne(e),(l=>xe(s,ze(We({},Me(t,l)),{key:l,tableId:l,store:e,debugIds:o})))),l),e.ValueView=rs,e.ValuesView=({store:e,valueComponent:s=rs,getValueComponentProps:t,separator:l,debugIds:o})=>ss(S(Ie(e),(l=>xe(s,ze(We({},Me(t,l)),{key:l,valueId:l,store:e,debugIds:o})))),l),e.useAddRowCallback=(e,s,t=$,l,o=V,r=$,u=!0)=>{const n=F(l);return J((t=>L(n,(l=>L(s(t,l),(s=>o(l.addRow(T(e)?e(t,l):e,s,u),l,s)))))),[n,e,...t,...r,u])},e.useCell=ce,e.useCellIds=ae,e.useCellIdsListener=(e,s,t,l,o,r)=>le(v,F(r),t,l,[e,s],o),e.useCellListener=(e,s,t,l,o,r,u)=>le(k,F(u),l,o,[e,s,t],r),e.useCheckpoint=fe,e.useCheckpointIds=Le,e.useCheckpointIdsListener=(e,s,t)=>le("CheckpointIds",U(t),e,s),e.useCheckpointListener=(e,s,t,l)=>le("Checkpoint",U(l),s,t,[e]),e.useCheckpoints=e=>M(e,10),e.useCheckpointsIds=()=>j(11),e.useCheckpointsOrCheckpointsById=U,e.useCreateCheckpoints=(e,s,t)=>se(e,s,t),e.useCreateIndexes=(e,s,t)=>se(e,s,t),e.useCreateMetrics=(e,s,t)=>se(e,s,t),e.useCreatePersister=(e,s,t=$,l,o=$,r,u=$)=>{const[,n]=Z(),d=N((()=>s(e)),[e,...t]);return K((()=>{var e;return e=function*(){l&&(yield l(d),n([]))},new Promise(((s,t)=>{var l=s=>{try{r(e.next(s))}catch(e){t(e)}},o=s=>{try{r(e.throw(s))}catch(e){t(e)}},r=e=>e.done?s(e.value):Promise.resolve(e.value).then(l,o);r((e=e.apply(void 0,null)).next())})),()=>{null==d||d.destroy(),null==r||r(d)}}),[d,...o,...u]),d},e.useCreateQueries=(e,s,t)=>se(e,s,t),e.useCreateRelationships=(e,s,t)=>se(e,s,t),e.useCreateStore=(e,s=$)=>N(e,s),e.useDelCellCallback=(e,s,t,l,o,r,u)=>re(o,k,r,u,e,s,t,l),e.useDelRowCallback=(e,s,t,l,o)=>re(t,p,l,o,e,s),e.useDelTableCallback=(e,s,t,l)=>re(s,c,t,l,e),e.useDelTablesCallback=(e,s,t)=>re(e,I,s,t),e.useDelValueCallback=(e,s,t,l)=>re(s,g,t,l,e),e.useDelValuesCallback=(e,s,t)=>re(e,h,s,t),e.useDidFinishTransactionListener=(e,s,t)=>le("DidFinish"+z,F(t),e,s),e.useGoBackwardCallback=Te,e.useGoForwardCallback=Ve,e.useGoToCallback=(e,s=$,t,l=V,o=$)=>{const r=U(t);return J((s=>L(r,(t=>L(e(s),(e=>l(t.goTo(e),e)))))),[r,...s,...o])},e.useHasCell=(e,s,t,l)=>te(k,F(l),!1,[e,s,t],4,i,d),e.useHasCellListener=(e,s,t,l,o,r,u)=>le(d+k,F(u),l,o,[e,s,t],r),e.useHasRow=(e,s,t)=>te(p,F(t),!1,[e,s],3,i,d),e.useHasRowListener=(e,s,t,l,o,r)=>le(d+p,F(r),t,l,[e,s],o),e.useHasTable=(e,s)=>te(c,F(s),!1,[e],2,i,d),e.useHasTableCell=(e,s,t)=>te(c+k,F(t),!1,[e,s],3,i,d),e.useHasTableCellListener=(e,s,t,l,o,r)=>le(d+c+k,F(r),t,l,[e,s],o),e.useHasTableListener=(e,s,t,l,o)=>le(d+c,F(o),s,t,[e],l),e.useHasTables=e=>te(I,F(e),!1,[],1,i,d),e.useHasTablesListener=(e,s,t,l)=>le(d+I,F(l),e,s,[],t),e.useHasValue=(e,s)=>te(g,F(s),!1,[e],2,i,d),e.useHasValueListener=(e,s,t,l,o)=>le(d+g,F(o),s,t,[e],l),e.useHasValues=e=>te(h,F(e),!1,[],1,i,d),e.useHasValuesListener=(e,s,t,l)=>le(d+h,F(l),e,s,[],t),e.useIndexIds=e=>te("IndexIds",E(e),$),e.useIndexes=e=>M(e,4),e.useIndexesIds=()=>j(5),e.useIndexesOrIndexesById=E,e.useLinkedRowIds=ve,e.useLinkedRowIdsListener=(e,s,t,l,o)=>le("Linked"+w,A(o),t,l,[e,s]),e.useLocalRowIds=ke,e.useLocalRowIdsListener=(e,s,t,l,o)=>le("Local"+w,A(o),t,l,[e,s]),e.useMetric=pe,e.useMetricIds=e=>te("MetricIds",Q(e),$),e.useMetricListener=(e,s,t,l)=>le("Metric",Q(l),s,t,[e]),e.useMetrics=e=>M(e,2),e.useMetricsIds=()=>j(3),e.useMetricsOrMetricsById=Q,e.useProvideStore=(e,s)=>{const{12:t,13:l}=q(H);B((()=>(null==t||t(e,s),()=>null==l?void 0:l(e))),[t,e,s,l])},e.useQueries=e=>M(e,8),e.useQueriesIds=()=>j(9),e.useQueriesOrQueriesById=G,e.useQueryIds=e=>te("QueryIds",G(e),$),e.useRedoInformation=e=>{var s;const t=U(e),[,,[o]]=Le(t);return[!m(o),Ve(t),o,null!=(s=L(o,(e=>null==t?void 0:t.getCheckpoint(e))))?s:l]},e.useRelationshipIds=e=>te("RelationshipIds",A(e),$),e.useRelationships=e=>M(e,6),e.useRelationshipsIds=()=>j(7),e.useRelationshipsOrRelationshipsById=A,e.useRemoteRowId=Re,e.useRemoteRowIdListener=(e,s,t,l,o)=>le("RemoteRowId",A(o),t,l,[e,s]),e.useResultCell=me,e.useResultCellIds=ye,e.useResultCellIdsListener=(e,s,t,l,o)=>le(n+v,G(o),t,l,[e,s]),e.useResultCellListener=(e,s,t,l,o,r)=>le(n+k,G(r),l,o,[e,s,t]),e.useResultRow=(e,s,t)=>te(n+p,G(t),_,[e,s]),e.useResultRowCount=(e,s)=>te(n+b,G(s),0,[e]),e.useResultRowCountListener=(e,s,t,l)=>le(n+b,G(l),s,t,[e]),e.useResultRowIds=ge,e.useResultRowIdsListener=(e,s,t,l)=>le(n+w,G(l),s,t,[e]),e.useResultRowListener=(e,s,t,l,o)=>le(n+p,G(o),t,l,[e,s]),e.useResultSortedRowIds=he,e.useResultSortedRowIdsListener=(e,s,t,l,o,r,u,d)=>le(n+R,G(d),r,u,[e,s,t,l,o]),e.useResultTable=(e,s)=>te(n+c,G(s),_,[e]),e.useResultTableCellIds=(e,s)=>te(n+c+v,G(s),$,[e]),e.useResultTableCellIdsListener=(e,s,t,l)=>le(n+c+v,G(l),s,t,[e]),e.useResultTableListener=(e,s,t,l)=>le(n+c,G(l),s,t,[e]),e.useRow=(e,s,t)=>te(p,F(t),_,[e,s]),e.useRowCount=(e,s)=>te(b,F(s),0,[e]),e.useRowCountListener=(e,s,t,l,o)=>le(b,F(o),s,t,[e],l),e.useRowIds=de,e.useRowIdsListener=(e,s,t,l,o)=>le(w,F(o),s,t,[e],l),e.useRowListener=(e,s,t,l,o,r)=>le(p,F(r),t,l,[e,s],o),e.useSetCellCallback=(e,s,t,l,o,r,u,n)=>oe(r,k,l,o,u,n,e,s,t),e.useSetCheckpointCallback=(e=V,s=$,t,l=V,o=$)=>{const r=U(t);return J((s=>L(r,(t=>{const o=e(s);l(t.addCheckpoint(o),t,o)}))),[r,...s,...o])},e.useSetPartialRowCallback=(e,s,t,l,o,r,u)=>oe(o,"PartialRow",t,l,r,u,e,s),e.useSetPartialValuesCallback=(e,s,t,l,o)=>oe(t,"PartialValues",e,s,l,o),e.useSetRowCallback=(e,s,t,l,o,r,u)=>oe(o,p,t,l,r,u,e,s),e.useSetTableCallback=(e,s,t,l,o,r)=>oe(l,c,s,t,o,r,e),e.useSetTablesCallback=(e,s,t,l,o)=>oe(t,I,e,s,l,o),e.useSetValueCallback=(e,s,t,l,o,r)=>oe(l,g,s,t,o,r,e),e.useSetValuesCallback=(e,s,t,l,o)=>oe(t,h,e,s,l,o),e.useSliceIds=be,e.useSliceIdsListener=(e,s,t,l)=>le("SliceIds",E(l),s,t,[e]),e.useSliceRowIds=we,e.useSliceRowIdsListener=(e,s,t,l,o)=>le("Slice"+w,E(o),t,l,[e,s]),e.useSortedRowIds=ie,e.useSortedRowIdsListener=(e,s,t,l,o,r,u,n,d)=>le(R,F(d),r,u,[e,s,t,l,o],n),e.useStartTransactionListener=(e,s,t)=>le("Start"+z,F(t),e,s),e.useStore=e=>M(e,0),e.useStoreIds=()=>j(1),e.useStoreOrStoreById=F,e.useTable=(e,s)=>te(c,F(s),_,[e]),e.useTableCellIds=(e,s)=>te(c+v,F(s),$,[e]),e.useTableCellIdsListener=(e,s,t,l,o)=>le(c+v,F(o),s,t,[e],l),e.useTableIds=ne,e.useTableIdsListener=(e,s,t,l)=>le(C,F(l),e,s,$,t),e.useTableListener=(e,s,t,l,o)=>le(c,F(o),s,t,[e],l),e.useTables=e=>te(I,F(e),_),e.useTablesListener=(e,s,t,l)=>le(I,F(l),e,s,$,t),e.useUndoInformation=e=>{var s;const t=U(e),[o,r]=Le(t);return[(u=o,!(0==u.length)),Te(t),r,null!=(s=L(r,(e=>null==t?void 0:t.getCheckpoint(e))))?s:l];var u},e.useValue=Ce,e.useValueIds=Ie,e.useValueIdsListener=(e,s,t,l)=>le(y,F(l),e,s,$,t),e.useValueListener=(e,s,t,l,o)=>le(g,F(o),s,t,[e],l),e.useValues=e=>te(h,F(e),_),e.useValuesListener=(e,s,t,l)=>le(h,F(l),e,s,$,t),e.useWillFinishTransactionListener=(e,s,t)=>le("WillFinish"+z,F(t),e,s)},"object"==typeof exports&&"undefined"!=typeof module?s(exports,require("react")):"function"==typeof define&&define.amd?define(["exports","react"],s):s((e="undefined"!=typeof globalThis?globalThis:e||self).TinyBaseUiReact={},e.React);
|
|
1
|
+
var e,s;e=this,s=function(e,s){"use strict";const t=e=>typeof e,l="",o=t(l),r=t(t),u="Listener",n="Result",d="Has",i="has",a="Ids",c="Table",I=c+"s",C=c+a,p="Row",b=p+"Count",w=p+a,R="Sorted"+p+a,k="Cell",v=k+a,g="Value",h=g+"s",y=g+a,m=e=>null==e,L=(e,s,t)=>m(e)?null==t?void 0:t():s(e),f=e=>t(e)==o,T=e=>t(e)==r,V=()=>{},S=(e,s)=>e.map(s),P=Object.keys,x=(e,s)=>L(e,(e=>e[s])),{createContext:O,useContext:q,useEffect:B}=s,H=O([]),M=(e,s)=>{var t;const l=q(H);return m(e)?l[s]:f(e)?x(null!=(t=l[s+1])?t:{},e):e},D=(e,s)=>{const t=M(e,s);return m(e)||f(e)?t:e},j=e=>{var s;return P(null!=(s=q(H)[e])?s:{})},F=e=>D(e,0),Q=e=>D(e,2),E=e=>D(e,4),A=e=>D(e,6),G=e=>D(e,8),U=e=>D(e,10),W=e=>e.toLowerCase();W(u);const z="Transaction";W(z);const{useCallback:J,useEffect:K,useMemo:N,useLayoutEffect:X,useRef:Y,useState:Z}=s,$=[],_={},ee=[[],void 0,[]],se=(e,s,t=$)=>{const l=N((()=>s(e)),[e,...t]);return K((()=>()=>l.destroy()),[l]),l},te=(e,s,t,l=$,o,r="get",u="")=>{const[,n]=Z(),d=J((()=>{var o,u;return null!=(u=null==(o=null==s?void 0:s[r+e])?void 0:o.call(s,...l))?u:t}),[s,r,e,...l,t]),i=Y();return N((()=>i.current=d()),[d]),le(u+e,s,((...e)=>{i.current=m(o)?d():e[o],n([])}),[d,o],l),i.current},le=(e,s,t,l=$,o=$,...r)=>X((()=>{var l;const n=null==(l=null==s?void 0:s["add"+e+u])?void 0:l.call(s,...o,t,...r);return()=>null==s?void 0:s.delListener(n)}),[s,e,...o,...l,...r]),oe=(e,s,t,l=$,o=V,r=$,...u)=>{const n=F(e);return J((e=>L(n,(l=>L(t(e,l),(t=>o(l["set"+s](...S(u,(s=>T(s)?s(e,l):s)),t),t)))))),[n,s,...l,...r,...u])},re=(e,s,t=V,l=$,...o)=>{const r=F(e);return J((()=>t(null==r?void 0:r["del"+s](...o))),[r,s,...l,...o])},ue=(e,s,t)=>{const l=U(e);return J((()=>null==l?void 0:l[s](t)),[l,s,t])},ne=e=>te(C,F(e),$),de=(e,s)=>te(w,F(s),$,[e]),ie=(e,s,t,l=0,o,r)=>te(R,F(r),$,[e,s,t,l,o],6),ae=(e,s,t)=>te(v,F(t),$,[e,s]),ce=(e,s,t,l)=>te(k,F(l),void 0,[e,s,t],4),Ie=e=>te(y,F(e),$),Ce=(e,s)=>te(g,F(s),void 0,[e]),pe=(e,s)=>te("Metric",Q(s),void 0,[e]),be=(e,s)=>te("SliceIds",E(s),$,[e]),we=(e,s,t)=>te("Slice"+w,E(t),$,[e,s]),Re=(e,s,t)=>te("RemoteRowId",A(t),void 0,[e,s]),ke=(e,s,t)=>te("Local"+w,A(t),$,[e,s]),ve=(e,s,t)=>te("Linked"+w,A(t),$,[e,s]),ge=(e,s)=>te(n+w,G(s),$,[e]),he=(e,s,t,l=0,o,r)=>te(n+R,G(r),$,[e,s,t,l,o],6),ye=(e,s,t)=>te(n+v,G(t),$,[e,s]),me=(e,s,t,l)=>te(n+k,G(l),void 0,[e,s,t]),Le=e=>te("CheckpointIds",U(e),ee),fe=(e,s)=>te("Checkpoint",U(s),void 0,[e]),Te=e=>ue(e,"goBackward"),Ve=e=>ue(e,"goForward"),{PureComponent:Se,Fragment:Pe,createElement:xe,useCallback:Oe,useLayoutEffect:qe,useRef:Be,useState:He}=s,Me=(e,...s)=>m(e)?{}:e(...s),De=(e,s)=>[e,null==e?void 0:e.getStore(),null==e?void 0:e.getLocalTableId(s),null==e?void 0:e.getRemoteTableId(s)];var je=Object.defineProperty,Fe=Object.defineProperties,Qe=Object.getOwnPropertyDescriptors,Ee=Object.getOwnPropertySymbols,Ae=Object.prototype.hasOwnProperty,Ge=Object.prototype.propertyIsEnumerable,Ue=(e,s,t)=>s in e?je(e,s,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[s]=t,We=(e,s)=>{for(var t in s||(s={}))Ae.call(s,t)&&Ue(e,t,s[t]);if(Ee)for(var t of Ee(s))Ge.call(s,t)&&Ue(e,t,s[t]);return e},ze=(e,s)=>Fe(e,Qe(s)),Je=(e,s)=>{var t={};for(var l in e)Ae.call(e,l)&&s.indexOf(l)<0&&(t[l]=e[l]);if(null!=e&&Ee)for(var l of Ee(e))s.indexOf(l)<0&&Ge.call(e,l)&&(t[l]=e[l]);return t};const{useCallback:Ke,useContext:Ne,useMemo:Xe,useState:Ye}=s,Ze=({tableId:e,store:s,rowComponent:t=ls,getRowComponentProps:l,customCellIds:o,separator:r,debugIds:u},n)=>ss(S(n,(r=>xe(t,ze(We({},Me(l,r)),{key:r,tableId:e,rowId:r,customCellIds:o,store:s,debugIds:u})))),r,u,e),$e=({queryId:e,queries:s,resultRowComponent:t=ds,getResultRowComponentProps:l,separator:o,debugIds:r},u)=>ss(S(u,(o=>xe(t,ze(We({},Me(l,o)),{key:o,queryId:e,rowId:o,queries:s,debugIds:r})))),o,r,e),_e=({relationshipId:e,relationships:s,rowComponent:t=ls,getRowComponentProps:l,separator:o,debugIds:r},u,n)=>{const[d,i,a]=De(A(s),e),c=u(e,n,d);return ss(S(c,(e=>xe(t,ze(We({},Me(l,e)),{key:e,tableId:a,rowId:e,store:i,debugIds:r})))),o,r,n)},es=e=>({checkpoints:s,checkpointComponent:t=is,getCheckpointComponentProps:l,separator:o,debugIds:r})=>{const u=U(s);return ss(S(e(Le(u)),(e=>xe(t,ze(We({},Me(l,e)),{key:e,checkpoints:u,checkpointId:e,debugIds:r})))),o)},ss=(e,s,t,l)=>{const o=m(s)||!Array.isArray(e)?e:S(e,((e,t)=>t>0?[s,e]:e));return t?[l,":{",o,"}"]:o},ts=({tableId:e,rowId:s,cellId:t,store:o,debugIds:r})=>{var u;return ss(l+(null!=(u=ce(e,s,t,o))?u:l),void 0,r,t)},ls=({tableId:e,rowId:s,store:t,cellComponent:l=ts,getCellComponentProps:o,customCellIds:r,separator:u,debugIds:n})=>ss(S(((e,s,t,l)=>{const o=ae(s,t,l);return null!=e?e:o})(r,e,s,t),(r=>xe(l,ze(We({},Me(o,r)),{key:r,tableId:e,rowId:s,cellId:r,store:t,debugIds:n})))),u,n,s),os=e=>Ze(e,de(e.tableId,e.store)),rs=({valueId:e,store:s,debugIds:t})=>{var o;return ss(l+(null!=(o=Ce(e,s))?o:l),void 0,t,e)},us=({indexId:e,sliceId:s,indexes:t,rowComponent:l=ls,getRowComponentProps:o,separator:r,debugIds:u})=>{const[n,d,i]=((e,s)=>[e,null==e?void 0:e.getStore(),null==e?void 0:e.getTableId(s)])(E(t),e),a=we(e,s,n);return ss(S(a,(e=>xe(l,ze(We({},Me(o,e)),{key:e,tableId:i,rowId:e,store:d,debugIds:u})))),r,u,s)},ns=({queryId:e,rowId:s,cellId:t,queries:o,debugIds:r})=>{var u;return ss(l+(null!=(u=me(e,s,t,o))?u:l),void 0,r,t)},ds=({queryId:e,rowId:s,queries:t,resultCellComponent:l=ns,getResultCellComponentProps:o,separator:r,debugIds:u})=>ss(S(ye(e,s,t),(r=>xe(l,ze(We({},Me(o,r)),{key:r,queryId:e,rowId:s,cellId:r,queries:t,debugIds:u})))),r,u,s),is=({checkpoints:e,checkpointId:s,debugIds:t})=>{var o;return ss(null!=(o=fe(s,e))?o:l,void 0,t,s)},as=es((e=>e[0])),cs=es((e=>m(e[1])?[]:[e[1]])),Is=es((e=>e[2]));e.BackwardCheckpointsView=as,e.CellView=ts,e.CheckpointView=is,e.CurrentCheckpointView=cs,e.ForwardCheckpointsView=Is,e.IndexView=({indexId:e,indexes:s,sliceComponent:t=us,getSliceComponentProps:l,separator:o,debugIds:r})=>ss(S(be(e,s),(o=>xe(t,ze(We({},Me(l,o)),{key:o,indexId:e,sliceId:o,indexes:s,debugIds:r})))),o,r,e),e.LinkedRowsView=e=>_e(e,ve,e.firstRowId),e.LocalRowsView=e=>_e(e,ke,e.remoteRowId),e.MetricView=({metricId:e,metrics:s,debugIds:t})=>{var o;return ss(null!=(o=pe(e,s))?o:l,void 0,t,e)},e.Provider=({store:e,storesById:s,metrics:t,metricsById:l,indexes:o,indexesById:r,relationships:u,relationshipsById:n,queries:d,queriesById:i,checkpoints:a,checkpointsById:c,children:I})=>{const C=Ne(H),[p,b]=Ye({}),w=Ke(((e,s)=>b((t=>x(t,e)==s?t:ze(We({},t),{[e]:s})))),[]),R=Ke((e=>b((s=>We({},((e,s)=>(delete e[s],e))(s,e))))),[]);return xe(H.Provider,{value:Xe((()=>[null!=e?e:C[0],We(We(We({},C[1]),s),p),null!=t?t:C[2],We(We({},C[3]),l),null!=o?o:C[4],We(We({},C[5]),r),null!=u?u:C[6],We(We({},C[7]),n),null!=d?d:C[8],We(We({},C[9]),i),null!=a?a:C[10],We(We({},C[11]),c),w,R]),[e,s,p,t,l,o,r,u,n,d,i,a,c,C,w,R])},I)},e.RemoteRowView=({relationshipId:e,localRowId:s,relationships:t,rowComponent:l=ls,getRowComponentProps:o,debugIds:r})=>{const[u,n,,d]=De(A(t),e),i=Re(e,s,u);return ss(m(d)||m(i)?null:xe(l,ze(We({},Me(o,i)),{key:i,tableId:d,rowId:i,store:n,debugIds:r})),void 0,r,s)},e.ResultCellView=ns,e.ResultRowView=ds,e.ResultSortedTableView=e=>{var s=e,{cellId:t,descending:l,offset:o,limit:r}=s,u=Je(s,["cellId","descending","offset","limit"]);return $e(u,he(u.queryId,t,l,o,r,u.queries))},e.ResultTableView=e=>$e(e,ge(e.queryId,e.queries)),e.RowView=ls,e.SliceView=us,e.SortedTableView=e=>{var s=e,{cellId:t,descending:l,offset:o,limit:r}=s,u=Je(s,["cellId","descending","offset","limit"]);return Ze(u,ie(u.tableId,t,l,o,r,u.store))},e.TableView=os,e.TablesView=({store:e,tableComponent:s=os,getTableComponentProps:t,separator:l,debugIds:o})=>ss(S(ne(e),(l=>xe(s,ze(We({},Me(t,l)),{key:l,tableId:l,store:e,debugIds:o})))),l),e.ValueView=rs,e.ValuesView=({store:e,valueComponent:s=rs,getValueComponentProps:t,separator:l,debugIds:o})=>ss(S(Ie(e),(l=>xe(s,ze(We({},Me(t,l)),{key:l,valueId:l,store:e,debugIds:o})))),l),e.useAddRowCallback=(e,s,t=$,l,o=V,r=$,u=!0)=>{const n=F(l);return J((t=>L(n,(l=>L(s(t,l),(s=>o(l.addRow(T(e)?e(t,l):e,s,u),l,s)))))),[n,e,...t,...r,u])},e.useCell=ce,e.useCellIds=ae,e.useCellIdsListener=(e,s,t,l,o,r)=>le(v,F(r),t,l,[e,s],o),e.useCellListener=(e,s,t,l,o,r,u)=>le(k,F(u),l,o,[e,s,t],r),e.useCheckpoint=fe,e.useCheckpointIds=Le,e.useCheckpointIdsListener=(e,s,t)=>le("CheckpointIds",U(t),e,s),e.useCheckpointListener=(e,s,t,l)=>le("Checkpoint",U(l),s,t,[e]),e.useCheckpoints=e=>M(e,10),e.useCheckpointsIds=()=>j(11),e.useCheckpointsOrCheckpointsById=U,e.useCreateCheckpoints=(e,s,t)=>se(e,s,t),e.useCreateIndexes=(e,s,t)=>se(e,s,t),e.useCreateMetrics=(e,s,t)=>se(e,s,t),e.useCreatePersister=(e,s,t=$,l,o=$,r,u=$)=>{const[,n]=Z(),d=N((()=>s(e)),[e,...t]);return K((()=>{var e;return e=function*(){l&&(yield l(d),n([]))},new Promise(((s,t)=>{var l=s=>{try{r(e.next(s))}catch(e){t(e)}},o=s=>{try{r(e.throw(s))}catch(e){t(e)}},r=e=>e.done?s(e.value):Promise.resolve(e.value).then(l,o);r((e=e.apply(void 0,null)).next())})),()=>{null==d||d.destroy(),null==r||r(d)}}),[d,...o,...u]),d},e.useCreateQueries=(e,s,t)=>se(e,s,t),e.useCreateRelationships=(e,s,t)=>se(e,s,t),e.useCreateStore=(e,s=$)=>N(e,s),e.useDelCellCallback=(e,s,t,l,o,r,u)=>re(o,k,r,u,e,s,t,l),e.useDelRowCallback=(e,s,t,l,o)=>re(t,p,l,o,e,s),e.useDelTableCallback=(e,s,t,l)=>re(s,c,t,l,e),e.useDelTablesCallback=(e,s,t)=>re(e,I,s,t),e.useDelValueCallback=(e,s,t,l)=>re(s,g,t,l,e),e.useDelValuesCallback=(e,s,t)=>re(e,h,s,t),e.useDidFinishTransactionListener=(e,s,t)=>le("DidFinish"+z,F(t),e,s),e.useGoBackwardCallback=Te,e.useGoForwardCallback=Ve,e.useGoToCallback=(e,s=$,t,l=V,o=$)=>{const r=U(t);return J((s=>L(r,(t=>L(e(s),(e=>l(t.goTo(e),e)))))),[r,...s,...o])},e.useHasCell=(e,s,t,l)=>te(k,F(l),!1,[e,s,t],4,i,d),e.useHasCellListener=(e,s,t,l,o,r,u)=>le(d+k,F(u),l,o,[e,s,t],r),e.useHasRow=(e,s,t)=>te(p,F(t),!1,[e,s],3,i,d),e.useHasRowListener=(e,s,t,l,o,r)=>le(d+p,F(r),t,l,[e,s],o),e.useHasTable=(e,s)=>te(c,F(s),!1,[e],2,i,d),e.useHasTableCell=(e,s,t)=>te(c+k,F(t),!1,[e,s],3,i,d),e.useHasTableCellListener=(e,s,t,l,o,r)=>le(d+c+k,F(r),t,l,[e,s],o),e.useHasTableListener=(e,s,t,l,o)=>le(d+c,F(o),s,t,[e],l),e.useHasTables=e=>te(I,F(e),!1,[],1,i,d),e.useHasTablesListener=(e,s,t,l)=>le(d+I,F(l),e,s,[],t),e.useHasValue=(e,s)=>te(g,F(s),!1,[e],2,i,d),e.useHasValueListener=(e,s,t,l,o)=>le(d+g,F(o),s,t,[e],l),e.useHasValues=e=>te(h,F(e),!1,[],1,i,d),e.useHasValuesListener=(e,s,t,l)=>le(d+h,F(l),e,s,[],t),e.useIndexIds=e=>te("IndexIds",E(e),$),e.useIndexes=e=>M(e,4),e.useIndexesIds=()=>j(5),e.useIndexesOrIndexesById=E,e.useLinkedRowIds=ve,e.useLinkedRowIdsListener=(e,s,t,l,o)=>le("Linked"+w,A(o),t,l,[e,s]),e.useLocalRowIds=ke,e.useLocalRowIdsListener=(e,s,t,l,o)=>le("Local"+w,A(o),t,l,[e,s]),e.useMetric=pe,e.useMetricIds=e=>te("MetricIds",Q(e),$),e.useMetricListener=(e,s,t,l)=>le("Metric",Q(l),s,t,[e]),e.useMetrics=e=>M(e,2),e.useMetricsIds=()=>j(3),e.useMetricsOrMetricsById=Q,e.useProvideStore=(e,s)=>{const{12:t,13:l}=q(H);B((()=>(null==t||t(e,s),()=>null==l?void 0:l(e))),[t,e,s,l])},e.useQueries=e=>M(e,8),e.useQueriesIds=()=>j(9),e.useQueriesOrQueriesById=G,e.useQueryIds=e=>te("QueryIds",G(e),$),e.useRedoInformation=e=>{var s;const t=U(e),[,,[o]]=Le(t);return[!m(o),Ve(t),o,null!=(s=L(o,(e=>null==t?void 0:t.getCheckpoint(e))))?s:l]},e.useRelationshipIds=e=>te("RelationshipIds",A(e),$),e.useRelationships=e=>M(e,6),e.useRelationshipsIds=()=>j(7),e.useRelationshipsOrRelationshipsById=A,e.useRemoteRowId=Re,e.useRemoteRowIdListener=(e,s,t,l,o)=>le("RemoteRowId",A(o),t,l,[e,s]),e.useResultCell=me,e.useResultCellIds=ye,e.useResultCellIdsListener=(e,s,t,l,o)=>le(n+v,G(o),t,l,[e,s]),e.useResultCellListener=(e,s,t,l,o,r)=>le(n+k,G(r),l,o,[e,s,t]),e.useResultRow=(e,s,t)=>te(n+p,G(t),_,[e,s]),e.useResultRowCount=(e,s)=>te(n+b,G(s),0,[e]),e.useResultRowCountListener=(e,s,t,l)=>le(n+b,G(l),s,t,[e]),e.useResultRowIds=ge,e.useResultRowIdsListener=(e,s,t,l)=>le(n+w,G(l),s,t,[e]),e.useResultRowListener=(e,s,t,l,o)=>le(n+p,G(o),t,l,[e,s]),e.useResultSortedRowIds=he,e.useResultSortedRowIdsListener=(e,s,t,l,o,r,u,d)=>le(n+R,G(d),r,u,[e,s,t,l,o]),e.useResultTable=(e,s)=>te(n+c,G(s),_,[e]),e.useResultTableCellIds=(e,s)=>te(n+c+v,G(s),$,[e]),e.useResultTableCellIdsListener=(e,s,t,l)=>le(n+c+v,G(l),s,t,[e]),e.useResultTableListener=(e,s,t,l)=>le(n+c,G(l),s,t,[e]),e.useRow=(e,s,t)=>te(p,F(t),_,[e,s]),e.useRowCount=(e,s)=>te(b,F(s),0,[e]),e.useRowCountListener=(e,s,t,l,o)=>le(b,F(o),s,t,[e],l),e.useRowIds=de,e.useRowIdsListener=(e,s,t,l,o)=>le(w,F(o),s,t,[e],l),e.useRowListener=(e,s,t,l,o,r)=>le(p,F(r),t,l,[e,s],o),e.useSetCellCallback=(e,s,t,l,o,r,u,n)=>oe(r,k,l,o,u,n,e,s,t),e.useSetCheckpointCallback=(e=V,s=$,t,l=V,o=$)=>{const r=U(t);return J((s=>L(r,(t=>{const o=e(s);l(t.addCheckpoint(o),t,o)}))),[r,...s,...o])},e.useSetPartialRowCallback=(e,s,t,l,o,r,u)=>oe(o,"PartialRow",t,l,r,u,e,s),e.useSetPartialValuesCallback=(e,s,t,l,o)=>oe(t,"PartialValues",e,s,l,o),e.useSetRowCallback=(e,s,t,l,o,r,u)=>oe(o,p,t,l,r,u,e,s),e.useSetTableCallback=(e,s,t,l,o,r)=>oe(l,c,s,t,o,r,e),e.useSetTablesCallback=(e,s,t,l,o)=>oe(t,I,e,s,l,o),e.useSetValueCallback=(e,s,t,l,o,r)=>oe(l,g,s,t,o,r,e),e.useSetValuesCallback=(e,s,t,l,o)=>oe(t,h,e,s,l,o),e.useSliceIds=be,e.useSliceIdsListener=(e,s,t,l)=>le("SliceIds",E(l),s,t,[e]),e.useSliceRowIds=we,e.useSliceRowIdsListener=(e,s,t,l,o)=>le("Slice"+w,E(o),t,l,[e,s]),e.useSortedRowIds=ie,e.useSortedRowIdsListener=(e,s,t,l,o,r,u,n,d)=>le(R,F(d),r,u,[e,s,t,l,o],n),e.useStartTransactionListener=(e,s,t)=>le("Start"+z,F(t),e,s),e.useStore=e=>M(e,0),e.useStoreIds=()=>j(1),e.useStoreOrStoreById=F,e.useTable=(e,s)=>te(c,F(s),_,[e]),e.useTableCellIds=(e,s)=>te(c+v,F(s),$,[e]),e.useTableCellIdsListener=(e,s,t,l,o)=>le(c+v,F(o),s,t,[e],l),e.useTableIds=ne,e.useTableIdsListener=(e,s,t,l)=>le(C,F(l),e,s,$,t),e.useTableListener=(e,s,t,l,o)=>le(c,F(o),s,t,[e],l),e.useTables=e=>te(I,F(e),_),e.useTablesListener=(e,s,t,l)=>le(I,F(l),e,s,$,t),e.useUndoInformation=e=>{var s;const t=U(e),[o,r]=Le(t);return[(u=o,!(0==u.length)),Te(t),r,null!=(s=L(r,(e=>null==t?void 0:t.getCheckpoint(e))))?s:l];var u},e.useValue=Ce,e.useValueIds=Ie,e.useValueIdsListener=(e,s,t,l)=>le(y,F(l),e,s,$,t),e.useValueListener=(e,s,t,l,o)=>le(g,F(o),s,t,[e],l),e.useValues=e=>te(h,F(e),_),e.useValuesListener=(e,s,t,l)=>le(h,F(l),e,s,$,t),e.useWillFinishTransactionListener=(e,s,t)=>le("WillFinish"+z,F(t),e,s)},"object"==typeof exports&&"undefined"!=typeof module?s(exports,require("react")):"function"==typeof define&&define.amd?define(["exports","react"],s):s((e="undefined"!=typeof globalThis?globalThis:e||self).TinyBaseUiReact={},e.React);
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tinybase",
|
|
3
|
-
"version": "4.6.
|
|
3
|
+
"version": "4.6.2",
|
|
4
4
|
"author": "jamesgpearce",
|
|
5
5
|
"repository": "github:tinyplex/tinybase",
|
|
6
6
|
"license": "MIT",
|
|
@@ -231,14 +231,14 @@
|
|
|
231
231
|
"@types/jest": "^29.5.11",
|
|
232
232
|
"@types/jest-environment-puppeteer": "^5.0.6",
|
|
233
233
|
"@types/less": "^3.0.6",
|
|
234
|
-
"@types/node": "^20.
|
|
234
|
+
"@types/node": "^20.11.4",
|
|
235
235
|
"@types/puppeteer": "^5.4.7",
|
|
236
|
-
"@types/react": "^18.2.
|
|
236
|
+
"@types/react": "^18.2.48",
|
|
237
237
|
"@types/react-dom": "^18.2.18",
|
|
238
238
|
"@types/react-test-renderer": "^18.0.7",
|
|
239
239
|
"@types/tmp": "^0.2.6",
|
|
240
|
-
"@typescript-eslint/eslint-plugin": "^6.
|
|
241
|
-
"@typescript-eslint/parser": "^6.
|
|
240
|
+
"@typescript-eslint/eslint-plugin": "^6.19.0",
|
|
241
|
+
"@typescript-eslint/parser": "^6.19.0",
|
|
242
242
|
"@vlcn.io/crsqlite-wasm": "^0.16.0",
|
|
243
243
|
"asciichart": "^1.5.25",
|
|
244
244
|
"automerge-repo": "^0.1.0",
|
|
@@ -254,11 +254,11 @@
|
|
|
254
254
|
"esbuild": "^0.19.11",
|
|
255
255
|
"eslint": "^8.56.0",
|
|
256
256
|
"eslint-config-prettier": "^9.1.0",
|
|
257
|
-
"eslint-plugin-jest": "^27.6.
|
|
257
|
+
"eslint-plugin-jest": "^27.6.3",
|
|
258
258
|
"eslint-plugin-jsdoc": "^48.0.2",
|
|
259
259
|
"eslint-plugin-react": "7.33.2",
|
|
260
260
|
"eslint-plugin-react-hooks": "^4.6.0",
|
|
261
|
-
"expo-sqlite": "^
|
|
261
|
+
"expo-sqlite": "^13.2.1",
|
|
262
262
|
"fake-indexeddb": "^5.0.2",
|
|
263
263
|
"gulp": "^4.0.2",
|
|
264
264
|
"gulp-gzip": "^1.4.2",
|
|
@@ -269,14 +269,14 @@
|
|
|
269
269
|
"jest-fetch-mock": "^3.0.3",
|
|
270
270
|
"jest-puppeteer": "^9.0.2",
|
|
271
271
|
"less": "^4.2.0",
|
|
272
|
-
"partykit": "^0.0.
|
|
272
|
+
"partykit": "^0.0.72",
|
|
273
273
|
"partysocket": "^0.0.20",
|
|
274
|
-
"prettier": "^3.
|
|
274
|
+
"prettier": "^3.2.2",
|
|
275
275
|
"puppeteer": "21.7.0",
|
|
276
276
|
"react": "^18.2.0",
|
|
277
277
|
"react-dom": "^18.2.0",
|
|
278
278
|
"react-test-renderer": "^18.2.0",
|
|
279
|
-
"rollup": "^4.9.
|
|
279
|
+
"rollup": "^4.9.5",
|
|
280
280
|
"rollup-plugin-esbuild": "^6.1.0",
|
|
281
281
|
"rollup-plugin-gzip": "^3.1.1",
|
|
282
282
|
"rollup-plugin-preserve-shebang": "^1.0.1",
|
|
@@ -295,9 +295,9 @@
|
|
|
295
295
|
"@vlcn.io/crsqlite-wasm": "^0.16.0",
|
|
296
296
|
"automerge-repo": "^0.1.0",
|
|
297
297
|
"electric-sql": "^0.8.2",
|
|
298
|
-
"partykit": "^0.0.
|
|
298
|
+
"partykit": "^0.0.72",
|
|
299
299
|
"partysocket": "^0.0.20",
|
|
300
|
-
"prettier": "^3.
|
|
300
|
+
"prettier": "^3.2.2",
|
|
301
301
|
"react": "^18.2.0",
|
|
302
302
|
"react-dom": "^18.2.0",
|
|
303
303
|
"sqlite3": "^5.1.7",
|
package/readme.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
<section id="hero"><h2 id="the-reactive-data-store-for-local-first-apps">The <em>reactive</em> data store for <span>local-first apps</span>.</h2><p id="copy">Build blisteringly fast web apps that work both online and offline. Manage your state locally, synchronize it to the cloud when you need to, or even make it collaborative. But, most importantly... have fun building stuff again!</p></section><p><a href="https://tinybase.org/guides/releases/#v4-6"><em>NEW!</em> v4.6 release</a> <span id="one-with">"The One With ElectricSQL"</span></p><p><a class="start" href="https://tinybase.org/guides/the-basics/getting-started/">Get started</a></p><p><a href="https://tinybase.org/demos/">Try the demos</a></p><p><a href="https://tinybase.org/api/store/interfaces/store/store/">Read the docs</a></p><hr><ul><li>Manage <a href="#start-with-a-simple-key-value-store">key-value data</a>, <a href="#level-up-to-use-tabular-data">tabular data</a> - or both - with optional <a href="#apply-schemas-to-tables-values">schematization</a> to model your app's data structures.</li><li><a href="#register-granular-listeners">Flexibly reactive</a> to reconciled updates, so you only spend rendering cycles on things that change.</li><li><a href="#build-complex-queries-with-tinyql">Powerful query engine</a> to select, join, filter, group, sort and paginate data - reactively - and without SQL.</li><li>Built-in <a href="#create-indexes-for-fast-lookups">indexing</a>, <a href="#define-metrics-and-aggregations">metric aggregation</a>, <a href="#model-table-relationships">tabular relationships</a> - and even an <a href="#set-checkpoints-for-an-undo-stack">undo stack</a> for your app state.</li><li>Create <a href="#type-definitions-orm-like-apis">type definitions & ORM-like APIs</a>, from schema or inference. <a href="#an-inspector-for-your-data">Inspect your data</a> (<em>new!</em>) directly in the browser.</li><li>Easily <a href="#persist-to-storage-sqlite-crdts">sync your data</a> to browser <a href="https://tinybase.org/api/persister-browser">storage</a>, <a href="https://tinybase.org/api/persister-indexed-db/">IndexedDB</a>, <a href="https://tinybase.org/guides/schemas-and-persistence/database-persistence/">SQLite</a>, <a href="https://tinybase.org/guides/schemas-and-persistence/synchronizing-data/">CRDTs</a>; and (<em>new!</em>) <a href="https://tinybase.org/api/persister-partykit-client/">PartyKit</a> and <a href="https://electric-sql.com/">ElectricSQL</a>.</li><li>Optional <a href="#call-hooks-to-bind-to-data">bindings to React</a> and (<em>new!</em>) <a href="#pre-built-reactive-components">pre-built components</a> that let you easily build fully reactive user interfaces.</li><li>Tiny by name, tiny by nature: <a href="#did-we-say-tiny">5.0kB - 9.4kB</a>, no dependencies. <a href="#well-tested-and-documented">100% tested</a>, <a href="https://tinybase.org/guides/the-basics/getting-started/">fully documented</a>, and of course, <a href="https://github.com/tinyplex/tinybase">open source</a>!</li></ul><hr><section id="friends"><h2 id="tinybase-works-great-on-its-own-but-also-plays-well-with-friends">TinyBase works great on its own, but also plays well with friends!</h2><div><a href="https://tinybase.org/guides/building-uis/getting-started-with-ui-react"><img width="48" src="https://tinybase.org/react.svg"> React</a></div><div><a href="https://tinybase.org/api/persister-partykit-client"><img width="48" src="https://tinybase.org/partykit.svg"> PartyKit</a></div><div><a href="https://tinybase.org/guides/schemas-and-persistence/database-persistence"><img width="48" src="https://tinybase.org/expo.svg">Expo SQLite</a></div><div><a href="https://tinybase.org/guides/schemas-and-persistence/database-persistence"><img width="48" src="https://tinybase.org/electric.svg">ElectricSQL</a></div><div><a href="https://tinybase.org/guides/schemas-and-persistence/database-persistence"><img width="48" src="https://tinybase.org/sqlite.svg"> SQLite</a></div><div><a href="https://tinybase.org/api/persister-indexed-db/functions/creation/createindexeddbpersister"><img width="48" src="https://tinybase.org/indexeddb.svg"> IndexedDB</a></div><div><a href="https://tinybase.org/api/persister-yjs/functions/creation/createyjspersister"><img width="48" src="https://tinybase.org/yjs.svg"> YJS</a></div><div><a href="https://tinybase.org/api/persister-cr-sqlite-wasm"><img width="48" src="https://tinybase.org/crsqlite.png"> CR-SQLite</a></div><div><a href="https://tinybase.org/api/persister-automerge"><img width="48" src="https://tinybase.org/automerge.svg"> Automerge</a></div></section><hr><section id="follow"><a href="https://github.com/tinyplex/tinybase" target="_blank"><img src="https://img.shields.io/github/stars/tinyplex/tinybase?style=for-the-badge&logo=GitHub&logoColor=%23fff&label=GitHub&labelColor=%23d81b60&color=%23333"> </a><a href="https://discord.com/invite/mGz3mevwP8" target="_blank"><img src="https://img.shields.io/discord/1027918215323590676?style=for-the-badge&logo=discord&logoColor=%23fff&label=Discord&labelColor=%233131e8&color=%23333"> </a><a href="https://twitter.com/tinybasejs" target="_blank"><img src="https://img.shields.io/twitter/follow/tinybasejs?style=for-the-badge&logo=x&logoColor=%23fff&label=Twitter&labelColor=%23333&color=%23333"></a><br><a href="https://github.com/tinyplex/tinybase/discussions" target="_blank"><img src="https://img.shields.io/github/discussions/tinyplex/tinybase?style=for-the-badge&logo=GitHub&logoColor=%23fff&label=Ideas&labelColor=%23d81b60&color=%23333"> </a><a href="https://github.com/tinyplex/tinybase/issues" target="_blank"><img src="https://img.shields.io/github/issues/tinyplex/tinybase?style=for-the-badge&logo=GitHub&logoColor=%23fff&label=Issues&labelColor=%23d81b60&color=%23333"> </a><a href="#well-tested-and-documented"><img src="https://img.shields.io/badge/Tests-100%25-green?style=for-the-badge&logo=jest&logoColor=%23fff&color=%23333&labelColor=%2387c305"> </a><a href="https://www.npmjs.com/package/tinybase/v/4.6.
|
|
1
|
+
<section id="hero"><h2 id="the-reactive-data-store-for-local-first-apps">The <em>reactive</em> data store for <span>local-first apps</span>.</h2><p id="copy">Build blisteringly fast web apps that work both online and offline. Manage your state locally, synchronize it to the cloud when you need to, or even make it collaborative. But, most importantly... have fun building stuff again!</p></section><p><a href="https://tinybase.org/guides/releases/#v4-6"><em>NEW!</em> v4.6 release</a> <span id="one-with">"The One With ElectricSQL"</span></p><p><a class="start" href="https://tinybase.org/guides/the-basics/getting-started/">Get started</a></p><p><a href="https://tinybase.org/demos/">Try the demos</a></p><p><a href="https://tinybase.org/api/store/interfaces/store/store/">Read the docs</a></p><hr><ul><li>Manage <a href="#start-with-a-simple-key-value-store">key-value data</a>, <a href="#level-up-to-use-tabular-data">tabular data</a> - or both - with optional <a href="#apply-schemas-to-tables-values">schematization</a> to model your app's data structures.</li><li><a href="#register-granular-listeners">Flexibly reactive</a> to reconciled updates, so you only spend rendering cycles on things that change.</li><li><a href="#build-complex-queries-with-tinyql">Powerful query engine</a> to select, join, filter, group, sort and paginate data - reactively - and without SQL.</li><li>Built-in <a href="#create-indexes-for-fast-lookups">indexing</a>, <a href="#define-metrics-and-aggregations">metric aggregation</a>, <a href="#model-table-relationships">tabular relationships</a> - and even an <a href="#set-checkpoints-for-an-undo-stack">undo stack</a> for your app state.</li><li>Create <a href="#type-definitions-orm-like-apis">type definitions & ORM-like APIs</a>, from schema or inference. <a href="#an-inspector-for-your-data">Inspect your data</a> (<em>new!</em>) directly in the browser.</li><li>Easily <a href="#persist-to-storage-sqlite-crdts">sync your data</a> to browser <a href="https://tinybase.org/api/persister-browser">storage</a>, <a href="https://tinybase.org/api/persister-indexed-db/">IndexedDB</a>, <a href="https://tinybase.org/guides/schemas-and-persistence/database-persistence/">SQLite</a>, <a href="https://tinybase.org/guides/schemas-and-persistence/synchronizing-data/">CRDTs</a>; and (<em>new!</em>) <a href="https://tinybase.org/api/persister-partykit-client/">PartyKit</a> and <a href="https://electric-sql.com/">ElectricSQL</a>.</li><li>Optional <a href="#call-hooks-to-bind-to-data">bindings to React</a> and (<em>new!</em>) <a href="#pre-built-reactive-components">pre-built components</a> that let you easily build fully reactive user interfaces.</li><li>Tiny by name, tiny by nature: <a href="#did-we-say-tiny">5.0kB - 9.4kB</a>, no dependencies. <a href="#well-tested-and-documented">100% tested</a>, <a href="https://tinybase.org/guides/the-basics/getting-started/">fully documented</a>, and of course, <a href="https://github.com/tinyplex/tinybase">open source</a>!</li></ul><hr><section id="friends"><h2 id="tinybase-works-great-on-its-own-but-also-plays-well-with-friends">TinyBase works great on its own, but also plays well with friends!</h2><div><a href="https://tinybase.org/guides/building-uis/getting-started-with-ui-react"><img width="48" src="https://tinybase.org/react.svg"> React</a></div><div><a href="https://tinybase.org/api/persister-partykit-client"><img width="48" src="https://tinybase.org/partykit.svg"> PartyKit</a></div><div><a href="https://tinybase.org/guides/schemas-and-persistence/database-persistence"><img width="48" src="https://tinybase.org/expo.svg">Expo SQLite</a></div><div><a href="https://tinybase.org/guides/schemas-and-persistence/database-persistence"><img width="48" src="https://tinybase.org/electric.svg">ElectricSQL</a></div><div><a href="https://tinybase.org/guides/schemas-and-persistence/database-persistence"><img width="48" src="https://tinybase.org/sqlite.svg"> SQLite</a></div><div><a href="https://tinybase.org/api/persister-indexed-db/functions/creation/createindexeddbpersister"><img width="48" src="https://tinybase.org/indexeddb.svg"> IndexedDB</a></div><div><a href="https://tinybase.org/api/persister-yjs/functions/creation/createyjspersister"><img width="48" src="https://tinybase.org/yjs.svg"> YJS</a></div><div><a href="https://tinybase.org/api/persister-cr-sqlite-wasm"><img width="48" src="https://tinybase.org/crsqlite.png"> CR-SQLite</a></div><div><a href="https://tinybase.org/api/persister-automerge"><img width="48" src="https://tinybase.org/automerge.svg"> Automerge</a></div></section><hr><section id="follow"><a href="https://github.com/tinyplex/tinybase" target="_blank"><img src="https://img.shields.io/github/stars/tinyplex/tinybase?style=for-the-badge&logo=GitHub&logoColor=%23fff&label=GitHub&labelColor=%23d81b60&color=%23333"> </a><a href="https://discord.com/invite/mGz3mevwP8" target="_blank"><img src="https://img.shields.io/discord/1027918215323590676?style=for-the-badge&logo=discord&logoColor=%23fff&label=Discord&labelColor=%233131e8&color=%23333"> </a><a href="https://twitter.com/tinybasejs" target="_blank"><img src="https://img.shields.io/twitter/follow/tinybasejs?style=for-the-badge&logo=x&logoColor=%23fff&label=Twitter&labelColor=%23333&color=%23333"></a><br><a href="https://github.com/tinyplex/tinybase/discussions" target="_blank"><img src="https://img.shields.io/github/discussions/tinyplex/tinybase?style=for-the-badge&logo=GitHub&logoColor=%23fff&label=Ideas&labelColor=%23d81b60&color=%23333"> </a><a href="https://github.com/tinyplex/tinybase/issues" target="_blank"><img src="https://img.shields.io/github/issues/tinyplex/tinybase?style=for-the-badge&logo=GitHub&logoColor=%23fff&label=Issues&labelColor=%23d81b60&color=%23333"> </a><a href="#well-tested-and-documented"><img src="https://img.shields.io/badge/Tests-100%25-green?style=for-the-badge&logo=jest&logoColor=%23fff&color=%23333&labelColor=%2387c305"> </a><a href="https://www.npmjs.com/package/tinybase/v/4.6.2" target="_blank"><img src="https://img.shields.io/npm/v/tinybase?style=for-the-badge&logo=npm&logoColor=%23fff&labelColor=%23bd0005&color=%23333"></a></section><hr><section><h2 id="start-with-a-simple-key-value-store">Start with a simple key-value store.</h2><p>Creating a <a href="https://tinybase.org/api/store/interfaces/store/store/"><code>Store</code></a> requires just a simple call to the <a href="https://tinybase.org/api/store/functions/creation/createstore/"><code>createStore</code></a> function. Once you have one, you can easily set <a href="https://tinybase.org/api/store/type-aliases/store/values/"><code>Values</code></a> in it by unique <a href="https://tinybase.org/api/common/type-aliases/identity/id/"><code>Id</code></a>. And of course you can easily get them back out again.</p><p>Read more about using keyed value data in <a href="https://tinybase.org/guides/the-basics/">The Basics</a> guide.</p></section>
|
|
2
2
|
|
|
3
3
|
```js
|
|
4
4
|
const store = createStore()
|