tinybase 3.0.2 → 3.1.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/tools.cjs +1 -1
- package/lib/cjs/tools.cjs.gz +0 -0
- package/lib/cjs/tools.d.ts +59 -35
- package/lib/cjs/ui-react.cjs +1 -1
- package/lib/cjs/ui-react.cjs.gz +0 -0
- package/lib/cjs-es6/tools.cjs +1 -1
- package/lib/cjs-es6/tools.cjs.gz +0 -0
- package/lib/cjs-es6/tools.d.ts +59 -35
- package/lib/cjs-es6/ui-react.cjs +1 -1
- package/lib/cjs-es6/ui-react.cjs.gz +0 -0
- package/lib/debug/queries.js +4 -3
- package/lib/debug/store.js +7 -6
- package/lib/debug/tinybase.js +8 -7
- package/lib/debug/tools.d.ts +59 -35
- package/lib/debug/tools.js +1637 -727
- package/lib/debug/ui-react.js +30 -28
- package/lib/es6/tools.d.ts +59 -35
- package/lib/es6/tools.js +1 -1
- package/lib/es6/tools.js.gz +0 -0
- package/lib/es6/ui-react.js +1 -1
- package/lib/es6/ui-react.js.gz +0 -0
- package/lib/tools.d.ts +59 -35
- package/lib/tools.js +1 -1
- package/lib/tools.js.gz +0 -0
- package/lib/ui-react.js +1 -1
- package/lib/ui-react.js.gz +0 -0
- package/lib/umd/tinybase.js +1 -1
- package/lib/umd/tinybase.js.gz +0 -0
- package/lib/umd/tools.d.ts +59 -35
- package/lib/umd/tools.js +1 -1
- package/lib/umd/tools.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/tinybase.js +1 -1
- package/lib/umd-es6/tinybase.js.gz +0 -0
- package/lib/umd-es6/tools.d.ts +59 -35
- package/lib/umd-es6/tools.js +1 -1
- package/lib/umd-es6/tools.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 +10 -10
- package/readme.md +14 -14
package/lib/cjs-es6/tools.d.ts
CHANGED
|
@@ -272,26 +272,35 @@ export interface Tools {
|
|
|
272
272
|
getStoreValuesSchema(): ValuesSchema;
|
|
273
273
|
|
|
274
274
|
/**
|
|
275
|
-
* The getStoreApi method returns
|
|
276
|
-
*
|
|
275
|
+
* The getStoreApi method returns code-generated .d.ts and .ts(x) files that
|
|
276
|
+
* describe the schema of a Store and React bindings (since v3.1.0) in an ORM
|
|
277
|
+
* style.
|
|
277
278
|
*
|
|
278
|
-
* If the Store does not already have an explicit TablesSchema
|
|
279
|
-
* it, the data in the Store will be scanned to attempt to
|
|
280
|
-
*
|
|
281
|
-
* files) though if no schema can be inferred, the strings will be empty.
|
|
279
|
+
* If the Store does not already have an explicit TablesSchema or ValuesSchema
|
|
280
|
+
* associated with it, the data in the Store will be scanned to attempt to
|
|
281
|
+
* infer new schemas. The method returns four strings (which should be saved
|
|
282
|
+
* as files) though if no schema can be inferred, the strings will be empty.
|
|
282
283
|
*
|
|
283
284
|
* The method takes a single argument which represents the name you want the
|
|
284
|
-
* generated store object to have in code. You are expected to save the
|
|
285
|
-
*
|
|
286
|
-
*
|
|
285
|
+
* generated store object to have in code. You are expected to save the four
|
|
286
|
+
* files yourself, as, respectively:
|
|
287
|
+
*
|
|
288
|
+
* - `[storeName].d.ts`
|
|
289
|
+
* - `[storeName].ts`
|
|
290
|
+
* - `[storeName]-ui-react.d.ts`
|
|
291
|
+
* - `[storeName]-ui-react.tsx`
|
|
292
|
+
*
|
|
293
|
+
* Also you should save these alongside each other so that the .ts(x) files
|
|
294
|
+
* can import types from the .d.ts files.
|
|
287
295
|
*
|
|
288
|
-
* The .d.ts and .ts files that are generated are designed to resemble the
|
|
289
|
-
* main TinyBase
|
|
290
|
-
*
|
|
296
|
+
* The .d.ts and .ts(x) files that are generated are designed to resemble the
|
|
297
|
+
* main TinyBase Store and React binding files, but provide named types and
|
|
298
|
+
* methods that describe the domain of the schema in the store.
|
|
291
299
|
*
|
|
292
300
|
* For example, from a Store that has a `pets` Table, you will get methods
|
|
293
|
-
* like `getPetsTable`,
|
|
294
|
-
* versions of the underlying getTable method or the Row
|
|
301
|
+
* like `getPetsTable`, types like `PetsRow`, and hooks and components that
|
|
302
|
+
* are more specific versions of the underlying getTable method or the Row
|
|
303
|
+
* type, and so on. For example:
|
|
295
304
|
*
|
|
296
305
|
* |Store type|Equivalent generated type|
|
|
297
306
|
* |-|-|
|
|
@@ -321,9 +330,9 @@ export interface Tools {
|
|
|
321
330
|
* directly.
|
|
322
331
|
*
|
|
323
332
|
* @param storeName The name you want to provide to the generated Store, which
|
|
324
|
-
* should also be used to save the `.d.ts
|
|
325
|
-
* @returns A
|
|
326
|
-
* `.ts` files.
|
|
333
|
+
* should also be used to save the `.d.ts`, `.ts`, and `.tsx` files.
|
|
334
|
+
* @returns A set of four strings representing the contents of the `.d.ts`,
|
|
335
|
+
* `.ts`, and `.tsx` files for the generated Store and React modules.
|
|
327
336
|
* @example
|
|
328
337
|
* This example creates a Tools object and generates code for a Store that
|
|
329
338
|
* already has a TablesSchema.
|
|
@@ -333,7 +342,8 @@ export interface Tools {
|
|
|
333
342
|
* price: {type: 'number'},
|
|
334
343
|
* },
|
|
335
344
|
* });
|
|
336
|
-
* const [dTs, ts] =
|
|
345
|
+
* const [dTs, ts, dTsUiReact, tsUiReact] =
|
|
346
|
+
* createTools(store).getStoreApi('shop');
|
|
337
347
|
*
|
|
338
348
|
* const dTsLines = dTs.split('\n');
|
|
339
349
|
* console.log(dTsLines[3]);
|
|
@@ -342,7 +352,7 @@ export interface Tools {
|
|
|
342
352
|
* // -> 'export type PetsRow = {\'price\'?: number;};'
|
|
343
353
|
*
|
|
344
354
|
* const tsLines = ts.split('\n');
|
|
345
|
-
* console.log(tsLines[
|
|
355
|
+
* console.log(tsLines[39]);
|
|
346
356
|
* // -> 'getPetsTable: (): PetsTable => store.getTable(PETS) as PetsTable,'
|
|
347
357
|
* ```
|
|
348
358
|
* @example
|
|
@@ -353,7 +363,8 @@ export interface Tools {
|
|
|
353
363
|
* fido: {price: 5},
|
|
354
364
|
* felix: {price: 4},
|
|
355
365
|
* });
|
|
356
|
-
* const [dTs, ts] =
|
|
366
|
+
* const [dTs, ts, dTsUiReact, tsUiReact] =
|
|
367
|
+
* createTools(store).getStoreApi('shop');
|
|
357
368
|
*
|
|
358
369
|
* const dTsLines = dTs.split('\n');
|
|
359
370
|
* console.log(dTsLines[3]);
|
|
@@ -362,18 +373,18 @@ export interface Tools {
|
|
|
362
373
|
* // -> 'export type PetsRow = {\'price\': number;};'
|
|
363
374
|
*
|
|
364
375
|
* const tsLines = ts.split('\n');
|
|
365
|
-
* console.log(tsLines[
|
|
376
|
+
* console.log(tsLines[41]);
|
|
366
377
|
* // -> 'getPetsTable: (): PetsTable => store.getTable(PETS) as PetsTable,'
|
|
367
378
|
* ```
|
|
368
379
|
* @category Modelling
|
|
369
380
|
* @since v2.2.0
|
|
370
381
|
*/
|
|
371
|
-
getStoreApi(storeName: string): [string, string];
|
|
382
|
+
getStoreApi(storeName: string): [string, string, string, string];
|
|
372
383
|
|
|
373
384
|
/**
|
|
374
385
|
* The getPrettyStoreApi method attempts to returns a prettified
|
|
375
|
-
* code-generated .d.ts
|
|
376
|
-
*
|
|
386
|
+
* code-generated .d.ts and .ts(x) files that describe the schema of a Store
|
|
387
|
+
* and React bindings (since v3.1.0) in an ORM style.
|
|
377
388
|
*
|
|
378
389
|
* This is simply a wrapper around the getStoreApi method that attempts to
|
|
379
390
|
* invoke the `prettier` module (which it hopes you have installed) to format
|
|
@@ -384,17 +395,24 @@ export interface Tools {
|
|
|
384
395
|
* the results as a promise.
|
|
385
396
|
*
|
|
386
397
|
* The method takes a single argument which represents the name you want the
|
|
387
|
-
* generated store object to have in code. You are expected to save the
|
|
388
|
-
*
|
|
389
|
-
*
|
|
398
|
+
* generated store object to have in code. You are expected to save the four
|
|
399
|
+
* files yourself, as, respectively:
|
|
400
|
+
*
|
|
401
|
+
* - `[storeName].d.ts`
|
|
402
|
+
* - `[storeName].ts`
|
|
403
|
+
* - `[storeName]-ui-react.d.ts`
|
|
404
|
+
* - `[storeName]-ui-react.tsx`
|
|
405
|
+
*
|
|
406
|
+
* Also you should save these alongside each other so that the .ts(x) files
|
|
407
|
+
* can import types from the .d.ts files.
|
|
390
408
|
*
|
|
391
409
|
* See the documentation for the getStoreApi method for details of the content
|
|
392
410
|
* of the generated files.
|
|
393
411
|
*
|
|
394
412
|
* @param storeName The name you want to provide to the generated Store, which
|
|
395
|
-
* should also be used to save the `.d.ts
|
|
396
|
-
* @returns A
|
|
397
|
-
* `.ts` files.
|
|
413
|
+
* should also be used to save the `.d.ts`, `.ts`, and `.tsx` files.
|
|
414
|
+
* @returns A set of four strings representing the contents of the `.d.ts`,
|
|
415
|
+
* `.ts`, and `.tsx` files for the generated Store and React modules.
|
|
398
416
|
* @example
|
|
399
417
|
* This example creates a Tools object and generates code for a Store that
|
|
400
418
|
* already has a TablesSchema.
|
|
@@ -405,7 +423,9 @@ export interface Tools {
|
|
|
405
423
|
* },
|
|
406
424
|
* });
|
|
407
425
|
* const tools = createTools(store);
|
|
408
|
-
* const [dTs, ts] = await
|
|
426
|
+
* const [dTs, ts, dTsUiReact, tsUiReact] = await createTools(
|
|
427
|
+
* store,
|
|
428
|
+
* ).getPrettyStoreApi('shop');
|
|
409
429
|
*
|
|
410
430
|
* const dTsLines = dTs.split('\n');
|
|
411
431
|
* console.log(dTsLines[5]);
|
|
@@ -414,7 +434,7 @@ export interface Tools {
|
|
|
414
434
|
* // -> 'export type PetsRow = {price?: number};'
|
|
415
435
|
*
|
|
416
436
|
* const tsLines = ts.split('\n');
|
|
417
|
-
* console.log(tsLines[
|
|
437
|
+
* console.log(tsLines[75]);
|
|
418
438
|
* // -> ' hasPetsTable: (): boolean => store.hasTable(PETS),'
|
|
419
439
|
* ```
|
|
420
440
|
* @example
|
|
@@ -426,7 +446,9 @@ export interface Tools {
|
|
|
426
446
|
* felix: {price: 4},
|
|
427
447
|
* });
|
|
428
448
|
* const tools = createTools(store);
|
|
429
|
-
* const [dTs, ts] = await
|
|
449
|
+
* const [dTs, ts, dTsUiReact, tsUiReact] = await createTools(
|
|
450
|
+
* store,
|
|
451
|
+
* ).getPrettyStoreApi('shop');
|
|
430
452
|
*
|
|
431
453
|
* const dTsLines = dTs.split('\n');
|
|
432
454
|
* console.log(dTsLines[5]);
|
|
@@ -435,13 +457,15 @@ export interface Tools {
|
|
|
435
457
|
* // -> 'export type PetsRow = {price: number};'
|
|
436
458
|
*
|
|
437
459
|
* const tsLines = ts.split('\n');
|
|
438
|
-
* console.log(tsLines[
|
|
460
|
+
* console.log(tsLines[77]);
|
|
439
461
|
* // -> ' hasPetsTable: (): boolean => store.hasTable(PETS),'
|
|
440
462
|
* ```
|
|
441
463
|
* @category Modelling
|
|
442
464
|
* @since v2.2.0
|
|
443
465
|
*/
|
|
444
|
-
getPrettyStoreApi(
|
|
466
|
+
getPrettyStoreApi(
|
|
467
|
+
storeName: string,
|
|
468
|
+
): Promise<[string, string, string, string]>;
|
|
445
469
|
|
|
446
470
|
/**
|
|
447
471
|
* The getStore method returns a reference to the underlying Store that is
|
package/lib/cjs-es6/ui-react.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var e=require("react");const s=e=>typeof e,t=s(""),o=(e,s)=>e.map(s),r=e=>null==e,l=(e,s,t)=>r(e)?null==t?void 0:t():s(e),u=()=>{},{createContext:d,useContext:n}=e,a=d([]),i=(e,s)=>{const t=n(a);return r(e)?t[s]:((e,s)=>l(e,(e=>e[s])))(t[s+1],e)},p=(e,o)=>{const l=i(e,o);return r(e)||(e=>s(e)==t)(e)?l:e},c=e=>p(e,0),I=e=>p(e,2),x=e=>p(e,4),w=e=>p(e,6),b=e=>p(e,8),R=e=>p(e,10),{useCallback:C,useEffect:k,useMemo:v,useRef:g,useState:m}=e,V=(e,s,t=[])=>{const o=v((()=>s(e)),[e,...t]);return k((()=>()=>o.destroy()),[o]),o},h=(e,s,t,o=[],l)=>{const[,u]=m(),d=C((()=>{var r,l;return null!=(l=null==(r=null==s?void 0:s["get"+e])?void 0:r.call(s,...o))?l:t}),[s,...o]),[n]=m(d),a=g(n);return v((()=>a.current=d()),[d]),y(e,s,((...e)=>{a.current=r(l)?d():e[l],u([])}),[],o),a.current},y=(e,s,t,o=[],r=[],...l)=>k((()=>{var o;const u=null==(o=null==s?void 0:s["add"+e+"Listener"])?void 0:o.call(s,...r,t,...l);return()=>null==s?void 0:s.delListener(u)}),[s,...r,...o,...l]),L=(e,s,t,o=[],r=u,d=[],...n)=>{const a=c(e);return C((e=>l(a,(o=>l(t(e,o),(e=>r(o["set"+s](...n,e),e)))))),[a,s,...o,...d,...n])},S=(e,s,t=u,o=[],...r)=>{const l=c(e);return C((()=>t(null==l?void 0:l["del"+s](...r))),[l,s,...o,...r])},T=(e,s,t)=>{const o=R(e);return C((()=>null==o?void 0:o[s](t)),[o,s,t])},f=e=>h("TableIds",c(e),[],[]),P=(e,s)=>h("RowIds",c(s),[],[e]),q=(e,s,t,o=0,r,l)=>h("SortedRowIds",c(l),[],[e,s,t,o,r],6),O=(e,s,t)=>h("CellIds",c(t),[],[e,s]),B=(e,s,t,o)=>h("Cell",c(o),void 0,[e,s,t],4),M=e=>h("ValueIds",c(e),[],[]),D=(e,s)=>h("Value",c(s),void 0,[e]),j=(e,s)=>h("Metric",I(s),void 0,[e]),A=(e,s)=>h("SliceIds",x(s),[],[e]),E=(e,s,t)=>h("SliceRowIds",x(t),[],[e,s]),F=(e,s,t)=>h("RemoteRowId",w(t),void 0,[e,s]),G=(e,s,t)=>h("LocalRowIds",w(t),[],[e,s]),Q=(e,s,t)=>h("LinkedRowIds",w(t),[],[e,s]),U=(e,s)=>h("ResultRowIds",b(s),[],[e]),z=(e,s,t,o=0,r,l)=>h("ResultSortedRowIds",b(l),[],[e,s,t,o,r],6),H=(e,s,t)=>h("ResultCellIds",b(t),[],[e,s]),J=(e,s,t,o)=>h("ResultCell",b(o),void 0,[e,s,t]),K=e=>h("CheckpointIds",R(e),[[],void 0,[]]),N=(e,s)=>h("Checkpoint",R(s),void 0,[e]),W=e=>T(e,"goBackward"),X=e=>T(e,"goForward");var Y=Object.defineProperty,Z=Object.defineProperties,$=Object.getOwnPropertyDescriptors,_=Object.getOwnPropertySymbols,ee=Object.prototype.hasOwnProperty,se=Object.prototype.propertyIsEnumerable,te=(e,s,t)=>s in e?Y(e,s,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[s]=t,oe=(e,s)=>{for(var t in s||(s={}))ee.call(s,t)&&te(e,t,s[t]);if(_)for(var t of _(s))se.call(s,t)&&te(e,t,s[t]);return e},re=(e,s)=>Z(e,$(s)),le=(e,s)=>{var t={};for(var o in e)ee.call(e,o)&&s.indexOf(o)<0&&(t[o]=e[o]);if(null!=e&&_)for(var o of _(e))s.indexOf(o)<0&&se.call(e,o)&&(t[o]=e[o]);return t};const{createElement:ue,useMemo:de}=e,ne=({tableId:e,store:s,rowComponent:t=be,getRowComponentProps:r,separator:l,debugIds:u},d)=>xe(o(d,(o=>ue(t,re(oe({},Ie(r,o)),{key:o,tableId:e,rowId:o,store:s,debugIds:u})))),l,u,e),ae=({queryId:e,queries:s,resultRowComponent:t=ge,getResultRowComponentProps:r,separator:l,debugIds:u},d)=>xe(o(d,(o=>ue(t,re(oe({},Ie(r,o)),{key:o,queryId:e,rowId:o,queries:s,debugIds:u})))),l,u,e),ie=e=>{const s=w(e);return[s,null==s?void 0:s.getStore()]},pe=({relationshipId:e,relationships:s,rowComponent:t=be,getRowComponentProps:r,separator:l,debugIds:u},d,n)=>{const[a,i]=ie(s),p=null==a?void 0:a.getLocalTableId(e),c=d(e,n,a);return xe(o(c,(e=>ue(t,re(oe({},Ie(r,e)),{key:e,tableId:p,rowId:e,store:i,debugIds:u})))),l,u,n)},ce=e=>({checkpoints:s,checkpointComponent:t=me,getCheckpointComponentProps:r,separator:l,debugIds:u})=>{const d=R(s);return xe(o(e(K(d)),(e=>ue(t,re(oe({},Ie(r,e)),{key:e,checkpoints:d,checkpointId:e,debugIds:u})))),l)},Ie=(e,s)=>r(e)?{}:e(s),xe=(e,s,t,l)=>{const u=r(s)||!Array.isArray(e)?e:o(e,((e,t)=>t>0?[s,e]:e));return t?[l,":{",u,"}"]:u},we=({tableId:e,rowId:s,cellId:t,store:o,debugIds:r})=>{var l;return xe(""+(null!=(l=B(e,s,t,o))?l:""),void 0,r,t)},be=({tableId:e,rowId:s,store:t,cellComponent:r=we,getCellComponentProps:l,separator:u,debugIds:d})=>xe(o(O(e,s,t),(o=>ue(r,re(oe({},Ie(l,o)),{key:o,tableId:e,rowId:s,cellId:o,store:t,debugIds:d})))),u,d,s),Re=e=>ne(e,P(e.tableId,e.store)),Ce=({valueId:e,store:s,debugIds:t})=>{var o;return xe(""+(null!=(o=D(e,s))?o:""),void 0,t,e)},ke=({indexId:e,sliceId:s,indexes:t,rowComponent:r=be,getRowComponentProps:l,separator:u,debugIds:d})=>{const n=x(t),a=null==n?void 0:n.getStore(),i=null==n?void 0:n.getTableId(e),p=E(e,s,n);return xe(o(p,(e=>ue(r,re(oe({},Ie(l,e)),{key:e,tableId:i,rowId:e,store:a,debugIds:d})))),u,d,s)},ve=({queryId:e,rowId:s,cellId:t,queries:o,debugIds:r})=>{var l;return xe(""+(null!=(l=J(e,s,t,o))?l:""),void 0,r,t)},ge=({queryId:e,rowId:s,queries:t,resultCellComponent:r=ve,getResultCellComponentProps:l,separator:u,debugIds:d})=>xe(o(H(e,s,t),(o=>ue(r,re(oe({},Ie(l,o)),{key:o,queryId:e,rowId:s,cellId:o,queries:t,debugIds:d})))),u,d,s),me=({checkpoints:e,checkpointId:s,debugIds:t})=>{var o;return xe(null!=(o=N(s,e))?o:"",void 0,t,s)},Ve=ce((e=>e[0])),he=ce((e=>r(e[1])?[]:[e[1]])),ye=ce((e=>e[2]));exports.BackwardCheckpointsView=Ve,exports.CellView=we,exports.CheckpointView=me,exports.CurrentCheckpointView=he,exports.ForwardCheckpointsView=ye,exports.IndexView=({indexId:e,indexes:s,sliceComponent:t=ke,getSliceComponentProps:r,separator:l,debugIds:u})=>xe(o(A(e,s),(o=>ue(t,re(oe({},Ie(r,o)),{key:o,indexId:e,sliceId:o,indexes:s,debugIds:u})))),l,u,e),exports.LinkedRowsView=e=>pe(e,Q,e.firstRowId),exports.LocalRowsView=e=>pe(e,G,e.remoteRowId),exports.MetricView=({metricId:e,metrics:s,debugIds:t})=>{var o;return xe(null!=(o=j(e,s))?o:"",void 0,t,e)},exports.Provider=({store:s,storesById:t,metrics:o,metricsById:r,indexes:l,indexesById:u,relationships:d,relationshipsById:n,queries:i,queriesById:p,checkpoints:c,checkpointsById:I,children:x})=>{const w=e.useContext(a);return ue(a.Provider,{value:de((()=>[null!=s?s:w[0],oe(oe({},w[1]),t),null!=o?o:w[2],oe(oe({},w[3]),r),null!=l?l:w[4],oe(oe({},w[5]),u),null!=d?d:w[6],oe(oe({},w[7]),n),null!=i?i:w[8],oe(oe({},w[9]),p),null!=c?c:w[10],oe(oe({},w[11]),I)]),[s,t,o,r,l,u,d,n,i,p,c,I,w])},x)},exports.RemoteRowView=({relationshipId:e,localRowId:s,relationships:t,rowComponent:o=be,getRowComponentProps:l,debugIds:u})=>{const[d,n]=ie(t),a=null==d?void 0:d.getRemoteTableId(e),i=F(e,s,d);return xe(r(a)||r(i)?null:ue(o,re(oe({},Ie(l,i)),{key:i,tableId:a,rowId:i,store:n,debugIds:u})),void 0,u,s)},exports.ResultCellView=ve,exports.ResultRowView=ge,exports.ResultSortedTableView=e=>{var s=e,{cellId:t,descending:o,offset:r,limit:l}=s,u=le(s,["cellId","descending","offset","limit"]);return ae(u,z(u.queryId,t,o,r,l,u.queries))},exports.ResultTableView=e=>ae(e,U(e.queryId,e.queries)),exports.RowView=be,exports.SliceView=ke,exports.SortedTableView=e=>{var s=e,{cellId:t,descending:o,offset:r,limit:l}=s,u=le(s,["cellId","descending","offset","limit"]);return ne(u,q(u.tableId,t,o,r,l,u.store))},exports.TableView=Re,exports.TablesView=({store:e,tableComponent:s=Re,getTableComponentProps:t,separator:r,debugIds:l})=>xe(o(f(e),(o=>ue(s,re(oe({},Ie(t,o)),{key:o,tableId:o,store:e,debugIds:l})))),r),exports.ValueView=Ce,exports.ValuesView=({store:e,valueComponent:s=Ce,getValueComponentProps:t,separator:r,debugIds:l})=>xe(o(M(e),(o=>ue(s,re(oe({},Ie(t,o)),{key:o,valueId:o,store:e,debugIds:l})))),r),exports.tableView=ne,exports.useAddRowCallback=(e,s,t=[],o,r=u,d=[])=>{const n=c(o);return C((t=>l(n,(o=>l(s(t,o),(s=>r(o.addRow(e,s),o,s)))))),[n,e,...t,...d])},exports.useCell=B,exports.useCellIds=O,exports.useCellIdsListener=(e,s,t,o,r,l)=>y("CellIds",c(l),t,o,[e,s],r),exports.useCellListener=(e,s,t,o,r,l,u)=>y("Cell",c(u),o,r,[e,s,t],l),exports.useCheckpoint=N,exports.useCheckpointIds=K,exports.useCheckpointIdsListener=(e,s,t)=>y("CheckpointIds",R(t),e,s),exports.useCheckpointListener=(e,s,t,o)=>y("Checkpoint",R(o),s,t,[e]),exports.useCheckpoints=e=>i(e,10),exports.useCreateCheckpoints=(e,s,t)=>V(e,s,t),exports.useCreateIndexes=(e,s,t)=>V(e,s,t),exports.useCreateMetrics=(e,s,t)=>V(e,s,t),exports.useCreatePersister=(e,s,t=[],o,r=[])=>{const[,l]=m(),u=v((()=>s(e)),[e,...t]);return k((()=>{var e;return e=function*(){yield null==o?void 0:o(u),l(1)},new Promise(((s,t)=>{var o=s=>{try{l(e.next(s))}catch(e){t(e)}},r=s=>{try{l(e.throw(s))}catch(e){t(e)}},l=e=>e.done?s(e.value):Promise.resolve(e.value).then(o,r);l((e=e.apply(void 0,null)).next())})),()=>{u.destroy()}}),[u,...r]),u},exports.useCreateQueries=(e,s,t)=>V(e,s,t),exports.useCreateRelationships=(e,s,t)=>V(e,s,t),exports.useCreateStore=(e,s=[])=>v(e,s),exports.useDelCellCallback=(e,s,t,o,r,l,u)=>S(r,"Cell",l,u,e,s,t,o),exports.useDelRowCallback=(e,s,t,o,r)=>S(t,"Row",o,r,e,s),exports.useDelTableCallback=(e,s,t,o)=>S(s,"Table",t,o,e),exports.useDelTablesCallback=(e,s,t)=>S(e,"Tables",s,t),exports.useDelValueCallback=(e,s,t,o)=>S(s,"Value",t,o,e),exports.useDelValuesCallback=(e,s,t)=>S(e,"Values",s,t),exports.useGoBackwardCallback=W,exports.useGoForwardCallback=X,exports.useGoToCallback=(e,s=[],t,o=u,r=[])=>{const d=R(t);return C((s=>l(d,(t=>l(e(s),(e=>o(t.goTo(e),e)))))),[d,...s,...r])},exports.useIndexes=e=>i(e,4),exports.useLinkedRowIds=Q,exports.useLinkedRowIdsListener=(e,s,t,o,r)=>y("LinkedRowIds",w(r),t,o,[e,s]),exports.useLocalRowIds=G,exports.useLocalRowIdsListener=(e,s,t,o,r)=>y("LocalRowIds",w(r),t,o,[e,s]),exports.useMetric=j,exports.useMetricListener=(e,s,t,o)=>y("Metric",I(o),s,t,[e]),exports.useMetrics=e=>i(e,2),exports.useQueries=e=>i(e,8),exports.useRedoInformation=e=>{var s;const t=R(e),[,,[o]]=K(t);return[!r(o),X(t),o,null!=(s=l(o,(e=>null==t?void 0:t.getCheckpoint(e))))?s:""]},exports.useRelationships=e=>i(e,6),exports.useRemoteRowId=F,exports.useRemoteRowIdListener=(e,s,t,o,r)=>y("RemoteRowId",w(r),t,o,[e,s]),exports.useResultCell=J,exports.useResultCellIds=H,exports.useResultCellIdsListener=(e,s,t,o,r)=>y("ResultCellIds",b(r),t,o,[e,s]),exports.useResultCellListener=(e,s,t,o,r,l)=>y("ResultCell",b(l),o,r,[e,s,t]),exports.useResultRow=(e,s,t)=>h("ResultRow",b(t),{},[e,s]),exports.useResultRowIds=U,exports.useResultRowIdsListener=(e,s,t,o)=>y("ResultRowIds",b(o),s,t,[e]),exports.useResultRowListener=(e,s,t,o,r)=>y("ResultRow",b(r),t,o,[e,s]),exports.useResultSortedRowIds=z,exports.useResultSortedRowIdsListener=(e,s,t,o,r,l,u,d)=>y("ResultSortedRowIds",b(d),l,u,[e,s,t,o,r]),exports.useResultTable=(e,s)=>h("ResultTable",b(s),{},[e]),exports.useResultTableListener=(e,s,t,o)=>y("ResultTable",b(o),s,t,[e]),exports.useRow=(e,s,t)=>h("Row",c(t),{},[e,s]),exports.useRowIds=P,exports.useRowIdsListener=(e,s,t,o,r)=>y("RowIds",c(r),s,t,[e],o),exports.useRowListener=(e,s,t,o,r,l)=>y("Row",c(l),t,o,[e,s],r),exports.useSetCellCallback=(e,s,t,o,r,l,u,d)=>L(l,"Cell",o,r,u,d,e,s,t),exports.useSetCheckpointCallback=(e=u,s=[],t,o=u,r=[])=>{const d=R(t);return C((s=>l(d,(t=>{const r=e(s);o(t.addCheckpoint(r),t,r)}))),[d,...s,...r])},exports.useSetPartialRowCallback=(e,s,t,o,r,l,u)=>L(r,"PartialRow",t,o,l,u,e,s),exports.useSetPartialValuesCallback=(e,s,t,o,r)=>L(t,"PartialValues",e,s,o,r),exports.useSetRowCallback=(e,s,t,o,r,l,u)=>L(r,"Row",t,o,l,u,e,s),exports.useSetTableCallback=(e,s,t,o,r,l)=>L(o,"Table",s,t,r,l,e),exports.useSetTablesCallback=(e,s,t,o,r)=>L(t,"Tables",e,s,o,r),exports.useSetValueCallback=(e,s,t,o,r,l)=>L(o,"Value",s,t,r,l,e),exports.useSetValuesCallback=(e,s,t,o,r)=>L(t,"Values",e,s,o,r),exports.useSliceIds=A,exports.useSliceIdsListener=(e,s,t,o)=>y("SliceIds",x(o),s,t,[e]),exports.useSliceRowIds=E,exports.useSliceRowIdsListener=(e,s,t,o,r)=>y("SliceRowIds",x(r),t,o,[e,s]),exports.useSortedRowIds=q,exports.useSortedRowIdsListener=(e,s,t,o,r,l,u,d,n)=>y("SortedRowIds",c(n),l,u,[e,s,t,o,r],d),exports.useStore=e=>i(e,0),exports.useTable=(e,s)=>h("Table",c(s),{},[e]),exports.useTableIds=f,exports.useTableIdsListener=(e,s,t,o)=>y("TableIds",c(o),e,s,[],t),exports.useTableListener=(e,s,t,o,r)=>y("Table",c(r),s,t,[e],o),exports.useTables=e=>h("Tables",c(e),{}),exports.useTablesListener=(e,s,t,o)=>y("Tables",c(o),e,s,[],t),exports.useUndoInformation=e=>{var s;const t=R(e),[o,r]=K(t);return[(u=o,!(0==(e=>e.length)(u))),W(t),r,null!=(s=l(r,(e=>null==t?void 0:t.getCheckpoint(e))))?s:""];var u},exports.useValue=D,exports.useValueIds=M,exports.useValueIdsListener=(e,s,t,o)=>y("ValueIds",c(o),e,s,[],t),exports.useValueListener=(e,s,t,o,r)=>y("Value",c(r),s,t,[e],o),exports.useValues=e=>h("Values",c(e),{}),exports.useValuesListener=(e,s,t,o)=>y("Values",c(o),e,s,[],t);
|
|
1
|
+
"use strict";var e=require("react");const s=e=>typeof e,t=s(""),o=(e,s)=>e.map(s),r=e=>null==e,l=(e,s,t)=>r(e)?null==t?void 0:t():s(e),u=e=>s(e)==t,d=()=>{},{createContext:n,useContext:a}=e,i=n([]),p=(e,s)=>{const t=a(i);return r(e)?t[s]:u(e)?((e,s)=>l(e,(e=>e[s])))(t[s+1],e):e},c=(e,s)=>{const t=p(e,s);return r(e)||u(e)?t:e},I=e=>c(e,0),x=e=>c(e,2),w=e=>c(e,4),b=e=>c(e,6),R=e=>c(e,8),C=e=>c(e,10),{useCallback:k,useEffect:v,useMemo:g,useRef:m,useState:V}=e,h=(e,s,t=[])=>{const o=g((()=>s(e)),[e,...t]);return v((()=>()=>o.destroy()),[o]),o},y=(e,s,t,o=[],l)=>{const[,u]=V(),d=k((()=>{var r,l;return null!=(l=null==(r=null==s?void 0:s["get"+e])?void 0:r.call(s,...o))?l:t}),[s,...o]),[n]=V(d),a=m(n);return g((()=>a.current=d()),[d]),L(e,s,((...e)=>{a.current=r(l)?d():e[l],u([])}),[],o),a.current},L=(e,s,t,o=[],r=[],...l)=>v((()=>{var o;const u=null==(o=null==s?void 0:s["add"+e+"Listener"])?void 0:o.call(s,...r,t,...l);return()=>null==s?void 0:s.delListener(u)}),[s,...r,...o,...l]),S=(e,s,t,o=[],r=d,u=[],...n)=>{const a=I(e);return k((e=>l(a,(o=>l(t(e,o),(e=>r(o["set"+s](...n,e),e)))))),[a,s,...o,...u,...n])},T=(e,s,t=d,o=[],...r)=>{const l=I(e);return k((()=>t(null==l?void 0:l["del"+s](...r))),[l,s,...o,...r])},f=(e,s,t)=>{const o=C(e);return k((()=>null==o?void 0:o[s](t)),[o,s,t])},P=e=>y("TableIds",I(e),[],[]),q=(e,s)=>y("RowIds",I(s),[],[e]),O=(e,s,t,o=0,r,l)=>y("SortedRowIds",I(l),[],[e,s,t,o,r],6),B=(e,s,t)=>y("CellIds",I(t),[],[e,s]),M=(e,s,t,o)=>y("Cell",I(o),void 0,[e,s,t],4),D=e=>y("ValueIds",I(e),[],[]),j=(e,s)=>y("Value",I(s),void 0,[e]),A=(e,s)=>y("Metric",x(s),void 0,[e]),E=(e,s)=>y("SliceIds",w(s),[],[e]),F=(e,s,t)=>y("SliceRowIds",w(t),[],[e,s]),G=(e,s,t)=>y("RemoteRowId",b(t),void 0,[e,s]),Q=(e,s,t)=>y("LocalRowIds",b(t),[],[e,s]),U=(e,s,t)=>y("LinkedRowIds",b(t),[],[e,s]),z=(e,s)=>y("ResultRowIds",R(s),[],[e]),H=(e,s,t,o=0,r,l)=>y("ResultSortedRowIds",R(l),[],[e,s,t,o,r],6),J=(e,s,t)=>y("ResultCellIds",R(t),[],[e,s]),K=(e,s,t,o)=>y("ResultCell",R(o),void 0,[e,s,t]),N=e=>y("CheckpointIds",C(e),[[],void 0,[]]),W=(e,s)=>y("Checkpoint",C(s),void 0,[e]),X=e=>f(e,"goBackward"),Y=e=>f(e,"goForward");var Z=Object.defineProperty,$=Object.defineProperties,_=Object.getOwnPropertyDescriptors,ee=Object.getOwnPropertySymbols,se=Object.prototype.hasOwnProperty,te=Object.prototype.propertyIsEnumerable,oe=(e,s,t)=>s in e?Z(e,s,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[s]=t,re=(e,s)=>{for(var t in s||(s={}))se.call(s,t)&&oe(e,t,s[t]);if(ee)for(var t of ee(s))te.call(s,t)&&oe(e,t,s[t]);return e},le=(e,s)=>$(e,_(s)),ue=(e,s)=>{var t={};for(var o in e)se.call(e,o)&&s.indexOf(o)<0&&(t[o]=e[o]);if(null!=e&&ee)for(var o of ee(e))s.indexOf(o)<0&&te.call(e,o)&&(t[o]=e[o]);return t};const{createElement:de,useMemo:ne}=e,ae=({tableId:e,store:s,rowComponent:t=Re,getRowComponentProps:r,separator:l,debugIds:u},d)=>we(o(d,(o=>de(t,le(re({},xe(r,o)),{key:o,tableId:e,rowId:o,store:s,debugIds:u})))),l,u,e),ie=({queryId:e,queries:s,resultRowComponent:t=me,getResultRowComponentProps:r,separator:l,debugIds:u},d)=>we(o(d,(o=>de(t,le(re({},xe(r,o)),{key:o,queryId:e,rowId:o,queries:s,debugIds:u})))),l,u,e),pe=e=>{const s=b(e);return[s,null==s?void 0:s.getStore()]},ce=({relationshipId:e,relationships:s,rowComponent:t=Re,getRowComponentProps:r,separator:l,debugIds:u},d,n)=>{const[a,i]=pe(s),p=null==a?void 0:a.getLocalTableId(e),c=d(e,n,a);return we(o(c,(e=>de(t,le(re({},xe(r,e)),{key:e,tableId:p,rowId:e,store:i,debugIds:u})))),l,u,n)},Ie=e=>({checkpoints:s,checkpointComponent:t=Ve,getCheckpointComponentProps:r,separator:l,debugIds:u})=>{const d=C(s);return we(o(e(N(d)),(e=>de(t,le(re({},xe(r,e)),{key:e,checkpoints:d,checkpointId:e,debugIds:u})))),l)},xe=(e,s)=>r(e)?{}:e(s),we=(e,s,t,l)=>{const u=r(s)||!Array.isArray(e)?e:o(e,((e,t)=>t>0?[s,e]:e));return t?[l,":{",u,"}"]:u},be=({tableId:e,rowId:s,cellId:t,store:o,debugIds:r})=>{var l;return we(""+(null!=(l=M(e,s,t,o))?l:""),void 0,r,t)},Re=({tableId:e,rowId:s,store:t,cellComponent:r=be,getCellComponentProps:l,separator:u,debugIds:d})=>we(o(B(e,s,t),(o=>de(r,le(re({},xe(l,o)),{key:o,tableId:e,rowId:s,cellId:o,store:t,debugIds:d})))),u,d,s),Ce=e=>ae(e,q(e.tableId,e.store)),ke=({valueId:e,store:s,debugIds:t})=>{var o;return we(""+(null!=(o=j(e,s))?o:""),void 0,t,e)},ve=({indexId:e,sliceId:s,indexes:t,rowComponent:r=Re,getRowComponentProps:l,separator:u,debugIds:d})=>{const n=w(t),a=null==n?void 0:n.getStore(),i=null==n?void 0:n.getTableId(e),p=F(e,s,n);return we(o(p,(e=>de(r,le(re({},xe(l,e)),{key:e,tableId:i,rowId:e,store:a,debugIds:d})))),u,d,s)},ge=({queryId:e,rowId:s,cellId:t,queries:o,debugIds:r})=>{var l;return we(""+(null!=(l=K(e,s,t,o))?l:""),void 0,r,t)},me=({queryId:e,rowId:s,queries:t,resultCellComponent:r=ge,getResultCellComponentProps:l,separator:u,debugIds:d})=>we(o(J(e,s,t),(o=>de(r,le(re({},xe(l,o)),{key:o,queryId:e,rowId:s,cellId:o,queries:t,debugIds:d})))),u,d,s),Ve=({checkpoints:e,checkpointId:s,debugIds:t})=>{var o;return we(null!=(o=W(s,e))?o:"",void 0,t,s)},he=Ie((e=>e[0])),ye=Ie((e=>r(e[1])?[]:[e[1]])),Le=Ie((e=>e[2]));exports.BackwardCheckpointsView=he,exports.CellView=be,exports.CheckpointView=Ve,exports.CurrentCheckpointView=ye,exports.ForwardCheckpointsView=Le,exports.IndexView=({indexId:e,indexes:s,sliceComponent:t=ve,getSliceComponentProps:r,separator:l,debugIds:u})=>we(o(E(e,s),(o=>de(t,le(re({},xe(r,o)),{key:o,indexId:e,sliceId:o,indexes:s,debugIds:u})))),l,u,e),exports.LinkedRowsView=e=>ce(e,U,e.firstRowId),exports.LocalRowsView=e=>ce(e,Q,e.remoteRowId),exports.MetricView=({metricId:e,metrics:s,debugIds:t})=>{var o;return we(null!=(o=A(e,s))?o:"",void 0,t,e)},exports.Provider=({store:s,storesById:t,metrics:o,metricsById:r,indexes:l,indexesById:u,relationships:d,relationshipsById:n,queries:a,queriesById:p,checkpoints:c,checkpointsById:I,children:x})=>{const w=e.useContext(i);return de(i.Provider,{value:ne((()=>[null!=s?s:w[0],re(re({},w[1]),t),null!=o?o:w[2],re(re({},w[3]),r),null!=l?l:w[4],re(re({},w[5]),u),null!=d?d:w[6],re(re({},w[7]),n),null!=a?a:w[8],re(re({},w[9]),p),null!=c?c:w[10],re(re({},w[11]),I)]),[s,t,o,r,l,u,d,n,a,p,c,I,w])},x)},exports.RemoteRowView=({relationshipId:e,localRowId:s,relationships:t,rowComponent:o=Re,getRowComponentProps:l,debugIds:u})=>{const[d,n]=pe(t),a=null==d?void 0:d.getRemoteTableId(e),i=G(e,s,d);return we(r(a)||r(i)?null:de(o,le(re({},xe(l,i)),{key:i,tableId:a,rowId:i,store:n,debugIds:u})),void 0,u,s)},exports.ResultCellView=ge,exports.ResultRowView=me,exports.ResultSortedTableView=e=>{var s=e,{cellId:t,descending:o,offset:r,limit:l}=s,u=ue(s,["cellId","descending","offset","limit"]);return ie(u,H(u.queryId,t,o,r,l,u.queries))},exports.ResultTableView=e=>ie(e,z(e.queryId,e.queries)),exports.RowView=Re,exports.SliceView=ve,exports.SortedTableView=e=>{var s=e,{cellId:t,descending:o,offset:r,limit:l}=s,u=ue(s,["cellId","descending","offset","limit"]);return ae(u,O(u.tableId,t,o,r,l,u.store))},exports.TableView=Ce,exports.TablesView=({store:e,tableComponent:s=Ce,getTableComponentProps:t,separator:r,debugIds:l})=>we(o(P(e),(o=>de(s,le(re({},xe(t,o)),{key:o,tableId:o,store:e,debugIds:l})))),r),exports.ValueView=ke,exports.ValuesView=({store:e,valueComponent:s=ke,getValueComponentProps:t,separator:r,debugIds:l})=>we(o(D(e),(o=>de(s,le(re({},xe(t,o)),{key:o,valueId:o,store:e,debugIds:l})))),r),exports.tableView=ae,exports.useAddRowCallback=(e,s,t=[],o,r=d,u=[])=>{const n=I(o);return k((t=>l(n,(o=>l(s(t,o),(s=>r(o.addRow(e,s),o,s)))))),[n,e,...t,...u])},exports.useCell=M,exports.useCellIds=B,exports.useCellIdsListener=(e,s,t,o,r,l)=>L("CellIds",I(l),t,o,[e,s],r),exports.useCellListener=(e,s,t,o,r,l,u)=>L("Cell",I(u),o,r,[e,s,t],l),exports.useCheckpoint=W,exports.useCheckpointIds=N,exports.useCheckpointIdsListener=(e,s,t)=>L("CheckpointIds",C(t),e,s),exports.useCheckpointListener=(e,s,t,o)=>L("Checkpoint",C(o),s,t,[e]),exports.useCheckpoints=e=>p(e,10),exports.useCreateCheckpoints=(e,s,t)=>h(e,s,t),exports.useCreateIndexes=(e,s,t)=>h(e,s,t),exports.useCreateMetrics=(e,s,t)=>h(e,s,t),exports.useCreatePersister=(e,s,t=[],o,r=[])=>{const[,l]=V(),u=g((()=>s(e)),[e,...t]);return v((()=>{var e;return e=function*(){yield null==o?void 0:o(u),l(1)},new Promise(((s,t)=>{var o=s=>{try{l(e.next(s))}catch(e){t(e)}},r=s=>{try{l(e.throw(s))}catch(e){t(e)}},l=e=>e.done?s(e.value):Promise.resolve(e.value).then(o,r);l((e=e.apply(void 0,null)).next())})),()=>{u.destroy()}}),[u,...r]),u},exports.useCreateQueries=(e,s,t)=>h(e,s,t),exports.useCreateRelationships=(e,s,t)=>h(e,s,t),exports.useCreateStore=(e,s=[])=>g(e,s),exports.useDelCellCallback=(e,s,t,o,r,l,u)=>T(r,"Cell",l,u,e,s,t,o),exports.useDelRowCallback=(e,s,t,o,r)=>T(t,"Row",o,r,e,s),exports.useDelTableCallback=(e,s,t,o)=>T(s,"Table",t,o,e),exports.useDelTablesCallback=(e,s,t)=>T(e,"Tables",s,t),exports.useDelValueCallback=(e,s,t,o)=>T(s,"Value",t,o,e),exports.useDelValuesCallback=(e,s,t)=>T(e,"Values",s,t),exports.useGoBackwardCallback=X,exports.useGoForwardCallback=Y,exports.useGoToCallback=(e,s=[],t,o=d,r=[])=>{const u=C(t);return k((s=>l(u,(t=>l(e(s),(e=>o(t.goTo(e),e)))))),[u,...s,...r])},exports.useIndexes=e=>p(e,4),exports.useLinkedRowIds=U,exports.useLinkedRowIdsListener=(e,s,t,o,r)=>L("LinkedRowIds",b(r),t,o,[e,s]),exports.useLocalRowIds=Q,exports.useLocalRowIdsListener=(e,s,t,o,r)=>L("LocalRowIds",b(r),t,o,[e,s]),exports.useMetric=A,exports.useMetricListener=(e,s,t,o)=>L("Metric",x(o),s,t,[e]),exports.useMetrics=e=>p(e,2),exports.useQueries=e=>p(e,8),exports.useRedoInformation=e=>{var s;const t=C(e),[,,[o]]=N(t);return[!r(o),Y(t),o,null!=(s=l(o,(e=>null==t?void 0:t.getCheckpoint(e))))?s:""]},exports.useRelationships=e=>p(e,6),exports.useRemoteRowId=G,exports.useRemoteRowIdListener=(e,s,t,o,r)=>L("RemoteRowId",b(r),t,o,[e,s]),exports.useResultCell=K,exports.useResultCellIds=J,exports.useResultCellIdsListener=(e,s,t,o,r)=>L("ResultCellIds",R(r),t,o,[e,s]),exports.useResultCellListener=(e,s,t,o,r,l)=>L("ResultCell",R(l),o,r,[e,s,t]),exports.useResultRow=(e,s,t)=>y("ResultRow",R(t),{},[e,s]),exports.useResultRowIds=z,exports.useResultRowIdsListener=(e,s,t,o)=>L("ResultRowIds",R(o),s,t,[e]),exports.useResultRowListener=(e,s,t,o,r)=>L("ResultRow",R(r),t,o,[e,s]),exports.useResultSortedRowIds=H,exports.useResultSortedRowIdsListener=(e,s,t,o,r,l,u,d)=>L("ResultSortedRowIds",R(d),l,u,[e,s,t,o,r]),exports.useResultTable=(e,s)=>y("ResultTable",R(s),{},[e]),exports.useResultTableListener=(e,s,t,o)=>L("ResultTable",R(o),s,t,[e]),exports.useRow=(e,s,t)=>y("Row",I(t),{},[e,s]),exports.useRowIds=q,exports.useRowIdsListener=(e,s,t,o,r)=>L("RowIds",I(r),s,t,[e],o),exports.useRowListener=(e,s,t,o,r,l)=>L("Row",I(l),t,o,[e,s],r),exports.useSetCellCallback=(e,s,t,o,r,l,u,d)=>S(l,"Cell",o,r,u,d,e,s,t),exports.useSetCheckpointCallback=(e=d,s=[],t,o=d,r=[])=>{const u=C(t);return k((s=>l(u,(t=>{const r=e(s);o(t.addCheckpoint(r),t,r)}))),[u,...s,...r])},exports.useSetPartialRowCallback=(e,s,t,o,r,l,u)=>S(r,"PartialRow",t,o,l,u,e,s),exports.useSetPartialValuesCallback=(e,s,t,o,r)=>S(t,"PartialValues",e,s,o,r),exports.useSetRowCallback=(e,s,t,o,r,l,u)=>S(r,"Row",t,o,l,u,e,s),exports.useSetTableCallback=(e,s,t,o,r,l)=>S(o,"Table",s,t,r,l,e),exports.useSetTablesCallback=(e,s,t,o,r)=>S(t,"Tables",e,s,o,r),exports.useSetValueCallback=(e,s,t,o,r,l)=>S(o,"Value",s,t,r,l,e),exports.useSetValuesCallback=(e,s,t,o,r)=>S(t,"Values",e,s,o,r),exports.useSliceIds=E,exports.useSliceIdsListener=(e,s,t,o)=>L("SliceIds",w(o),s,t,[e]),exports.useSliceRowIds=F,exports.useSliceRowIdsListener=(e,s,t,o,r)=>L("SliceRowIds",w(r),t,o,[e,s]),exports.useSortedRowIds=O,exports.useSortedRowIdsListener=(e,s,t,o,r,l,u,d,n)=>L("SortedRowIds",I(n),l,u,[e,s,t,o,r],d),exports.useStore=e=>p(e,0),exports.useTable=(e,s)=>y("Table",I(s),{},[e]),exports.useTableIds=P,exports.useTableIdsListener=(e,s,t,o)=>L("TableIds",I(o),e,s,[],t),exports.useTableListener=(e,s,t,o,r)=>L("Table",I(r),s,t,[e],o),exports.useTables=e=>y("Tables",I(e),{}),exports.useTablesListener=(e,s,t,o)=>L("Tables",I(o),e,s,[],t),exports.useUndoInformation=e=>{var s;const t=C(e),[o,r]=N(t);return[(u=o,!(0==(e=>e.length)(u))),X(t),r,null!=(s=l(r,(e=>null==t?void 0:t.getCheckpoint(e))))?s:""];var u},exports.useValue=j,exports.useValueIds=D,exports.useValueIdsListener=(e,s,t,o)=>L("ValueIds",I(o),e,s,[],t),exports.useValueListener=(e,s,t,o,r)=>L("Value",I(r),s,t,[e],o),exports.useValues=e=>y("Values",I(e),{}),exports.useValuesListener=(e,s,t,o)=>L("Values",I(o),e,s,[],t);
|
|
Binary file
|
package/lib/debug/queries.js
CHANGED
|
@@ -12,12 +12,13 @@ const LISTENER = 'Listener';
|
|
|
12
12
|
const RESULT = 'Result';
|
|
13
13
|
const GET = 'get';
|
|
14
14
|
const ADD = 'add';
|
|
15
|
+
const IDS = 'Ids';
|
|
15
16
|
const TABLE = 'Table';
|
|
16
|
-
const ROW_IDS = 'RowIds';
|
|
17
|
-
const SORTED_ROW_IDS = 'SortedRowIds';
|
|
18
17
|
const ROW = 'Row';
|
|
19
|
-
const
|
|
18
|
+
const ROW_IDS = ROW + IDS;
|
|
19
|
+
const SORTED_ROW_IDS = 'Sorted' + ROW + IDS;
|
|
20
20
|
const CELL = 'Cell';
|
|
21
|
+
const CELL_IDS = CELL + IDS;
|
|
21
22
|
|
|
22
23
|
const arrayEvery = (array, cb) => array.every(cb);
|
|
23
24
|
const arrayIsEqual = (array1, array2) =>
|
package/lib/debug/store.js
CHANGED
|
@@ -8,16 +8,17 @@ const TYPE = 'type';
|
|
|
8
8
|
const DEFAULT = 'default';
|
|
9
9
|
const LISTENER = 'Listener';
|
|
10
10
|
const ADD = 'add';
|
|
11
|
-
const
|
|
12
|
-
const TABLE_IDS = 'TableIds';
|
|
11
|
+
const IDS = 'Ids';
|
|
13
12
|
const TABLE = 'Table';
|
|
14
|
-
const
|
|
13
|
+
const TABLES = TABLE + 's';
|
|
14
|
+
const TABLE_IDS = TABLE + IDS;
|
|
15
15
|
const ROW = 'Row';
|
|
16
|
-
const
|
|
16
|
+
const ROW_IDS = ROW + IDS;
|
|
17
17
|
const CELL = 'Cell';
|
|
18
|
-
const
|
|
19
|
-
const VALUE_IDS = 'ValueIds';
|
|
18
|
+
const CELL_IDS = CELL + IDS;
|
|
20
19
|
const VALUE = 'Value';
|
|
20
|
+
const VALUES = VALUE + 's';
|
|
21
|
+
const VALUE_IDS = VALUE + IDS;
|
|
21
22
|
const id = (key) => EMPTY_STRING + key;
|
|
22
23
|
|
|
23
24
|
const arrayHas = (array, value) => array.includes(value);
|
package/lib/debug/tinybase.js
CHANGED
|
@@ -17,17 +17,18 @@ const LISTENER = 'Listener';
|
|
|
17
17
|
const RESULT = 'Result';
|
|
18
18
|
const GET = 'get';
|
|
19
19
|
const ADD = 'add';
|
|
20
|
-
const
|
|
21
|
-
const TABLE_IDS = 'TableIds';
|
|
20
|
+
const IDS = 'Ids';
|
|
22
21
|
const TABLE = 'Table';
|
|
23
|
-
const
|
|
24
|
-
const
|
|
22
|
+
const TABLES = TABLE + 's';
|
|
23
|
+
const TABLE_IDS = TABLE + IDS;
|
|
25
24
|
const ROW = 'Row';
|
|
26
|
-
const
|
|
25
|
+
const ROW_IDS = ROW + IDS;
|
|
26
|
+
const SORTED_ROW_IDS = 'Sorted' + ROW + IDS;
|
|
27
27
|
const CELL = 'Cell';
|
|
28
|
-
const
|
|
29
|
-
const VALUE_IDS = 'ValueIds';
|
|
28
|
+
const CELL_IDS = CELL + IDS;
|
|
30
29
|
const VALUE = 'Value';
|
|
30
|
+
const VALUES = VALUE + 's';
|
|
31
|
+
const VALUE_IDS = VALUE + IDS;
|
|
31
32
|
const id = (key) => EMPTY_STRING + key;
|
|
32
33
|
|
|
33
34
|
const arrayHas = (array, value) => array.includes(value);
|
package/lib/debug/tools.d.ts
CHANGED
|
@@ -272,26 +272,35 @@ export interface Tools {
|
|
|
272
272
|
getStoreValuesSchema(): ValuesSchema;
|
|
273
273
|
|
|
274
274
|
/**
|
|
275
|
-
* The getStoreApi method returns
|
|
276
|
-
*
|
|
275
|
+
* The getStoreApi method returns code-generated .d.ts and .ts(x) files that
|
|
276
|
+
* describe the schema of a Store and React bindings (since v3.1.0) in an ORM
|
|
277
|
+
* style.
|
|
277
278
|
*
|
|
278
|
-
* If the Store does not already have an explicit TablesSchema
|
|
279
|
-
* it, the data in the Store will be scanned to attempt to
|
|
280
|
-
*
|
|
281
|
-
* files) though if no schema can be inferred, the strings will be empty.
|
|
279
|
+
* If the Store does not already have an explicit TablesSchema or ValuesSchema
|
|
280
|
+
* associated with it, the data in the Store will be scanned to attempt to
|
|
281
|
+
* infer new schemas. The method returns four strings (which should be saved
|
|
282
|
+
* as files) though if no schema can be inferred, the strings will be empty.
|
|
282
283
|
*
|
|
283
284
|
* The method takes a single argument which represents the name you want the
|
|
284
|
-
* generated store object to have in code. You are expected to save the
|
|
285
|
-
*
|
|
286
|
-
*
|
|
285
|
+
* generated store object to have in code. You are expected to save the four
|
|
286
|
+
* files yourself, as, respectively:
|
|
287
|
+
*
|
|
288
|
+
* - `[storeName].d.ts`
|
|
289
|
+
* - `[storeName].ts`
|
|
290
|
+
* - `[storeName]-ui-react.d.ts`
|
|
291
|
+
* - `[storeName]-ui-react.tsx`
|
|
292
|
+
*
|
|
293
|
+
* Also you should save these alongside each other so that the .ts(x) files
|
|
294
|
+
* can import types from the .d.ts files.
|
|
287
295
|
*
|
|
288
|
-
* The .d.ts and .ts files that are generated are designed to resemble the
|
|
289
|
-
* main TinyBase
|
|
290
|
-
*
|
|
296
|
+
* The .d.ts and .ts(x) files that are generated are designed to resemble the
|
|
297
|
+
* main TinyBase Store and React binding files, but provide named types and
|
|
298
|
+
* methods that describe the domain of the schema in the store.
|
|
291
299
|
*
|
|
292
300
|
* For example, from a Store that has a `pets` Table, you will get methods
|
|
293
|
-
* like `getPetsTable`,
|
|
294
|
-
* versions of the underlying getTable method or the Row
|
|
301
|
+
* like `getPetsTable`, types like `PetsRow`, and hooks and components that
|
|
302
|
+
* are more specific versions of the underlying getTable method or the Row
|
|
303
|
+
* type, and so on. For example:
|
|
295
304
|
*
|
|
296
305
|
* |Store type|Equivalent generated type|
|
|
297
306
|
* |-|-|
|
|
@@ -321,9 +330,9 @@ export interface Tools {
|
|
|
321
330
|
* directly.
|
|
322
331
|
*
|
|
323
332
|
* @param storeName The name you want to provide to the generated Store, which
|
|
324
|
-
* should also be used to save the `.d.ts
|
|
325
|
-
* @returns A
|
|
326
|
-
* `.ts` files.
|
|
333
|
+
* should also be used to save the `.d.ts`, `.ts`, and `.tsx` files.
|
|
334
|
+
* @returns A set of four strings representing the contents of the `.d.ts`,
|
|
335
|
+
* `.ts`, and `.tsx` files for the generated Store and React modules.
|
|
327
336
|
* @example
|
|
328
337
|
* This example creates a Tools object and generates code for a Store that
|
|
329
338
|
* already has a TablesSchema.
|
|
@@ -333,7 +342,8 @@ export interface Tools {
|
|
|
333
342
|
* price: {type: 'number'},
|
|
334
343
|
* },
|
|
335
344
|
* });
|
|
336
|
-
* const [dTs, ts] =
|
|
345
|
+
* const [dTs, ts, dTsUiReact, tsUiReact] =
|
|
346
|
+
* createTools(store).getStoreApi('shop');
|
|
337
347
|
*
|
|
338
348
|
* const dTsLines = dTs.split('\n');
|
|
339
349
|
* console.log(dTsLines[3]);
|
|
@@ -342,7 +352,7 @@ export interface Tools {
|
|
|
342
352
|
* // -> 'export type PetsRow = {\'price\'?: number;};'
|
|
343
353
|
*
|
|
344
354
|
* const tsLines = ts.split('\n');
|
|
345
|
-
* console.log(tsLines[
|
|
355
|
+
* console.log(tsLines[39]);
|
|
346
356
|
* // -> 'getPetsTable: (): PetsTable => store.getTable(PETS) as PetsTable,'
|
|
347
357
|
* ```
|
|
348
358
|
* @example
|
|
@@ -353,7 +363,8 @@ export interface Tools {
|
|
|
353
363
|
* fido: {price: 5},
|
|
354
364
|
* felix: {price: 4},
|
|
355
365
|
* });
|
|
356
|
-
* const [dTs, ts] =
|
|
366
|
+
* const [dTs, ts, dTsUiReact, tsUiReact] =
|
|
367
|
+
* createTools(store).getStoreApi('shop');
|
|
357
368
|
*
|
|
358
369
|
* const dTsLines = dTs.split('\n');
|
|
359
370
|
* console.log(dTsLines[3]);
|
|
@@ -362,18 +373,18 @@ export interface Tools {
|
|
|
362
373
|
* // -> 'export type PetsRow = {\'price\': number;};'
|
|
363
374
|
*
|
|
364
375
|
* const tsLines = ts.split('\n');
|
|
365
|
-
* console.log(tsLines[
|
|
376
|
+
* console.log(tsLines[41]);
|
|
366
377
|
* // -> 'getPetsTable: (): PetsTable => store.getTable(PETS) as PetsTable,'
|
|
367
378
|
* ```
|
|
368
379
|
* @category Modelling
|
|
369
380
|
* @since v2.2.0
|
|
370
381
|
*/
|
|
371
|
-
getStoreApi(storeName: string): [string, string];
|
|
382
|
+
getStoreApi(storeName: string): [string, string, string, string];
|
|
372
383
|
|
|
373
384
|
/**
|
|
374
385
|
* The getPrettyStoreApi method attempts to returns a prettified
|
|
375
|
-
* code-generated .d.ts
|
|
376
|
-
*
|
|
386
|
+
* code-generated .d.ts and .ts(x) files that describe the schema of a Store
|
|
387
|
+
* and React bindings (since v3.1.0) in an ORM style.
|
|
377
388
|
*
|
|
378
389
|
* This is simply a wrapper around the getStoreApi method that attempts to
|
|
379
390
|
* invoke the `prettier` module (which it hopes you have installed) to format
|
|
@@ -384,17 +395,24 @@ export interface Tools {
|
|
|
384
395
|
* the results as a promise.
|
|
385
396
|
*
|
|
386
397
|
* The method takes a single argument which represents the name you want the
|
|
387
|
-
* generated store object to have in code. You are expected to save the
|
|
388
|
-
*
|
|
389
|
-
*
|
|
398
|
+
* generated store object to have in code. You are expected to save the four
|
|
399
|
+
* files yourself, as, respectively:
|
|
400
|
+
*
|
|
401
|
+
* - `[storeName].d.ts`
|
|
402
|
+
* - `[storeName].ts`
|
|
403
|
+
* - `[storeName]-ui-react.d.ts`
|
|
404
|
+
* - `[storeName]-ui-react.tsx`
|
|
405
|
+
*
|
|
406
|
+
* Also you should save these alongside each other so that the .ts(x) files
|
|
407
|
+
* can import types from the .d.ts files.
|
|
390
408
|
*
|
|
391
409
|
* See the documentation for the getStoreApi method for details of the content
|
|
392
410
|
* of the generated files.
|
|
393
411
|
*
|
|
394
412
|
* @param storeName The name you want to provide to the generated Store, which
|
|
395
|
-
* should also be used to save the `.d.ts
|
|
396
|
-
* @returns A
|
|
397
|
-
* `.ts` files.
|
|
413
|
+
* should also be used to save the `.d.ts`, `.ts`, and `.tsx` files.
|
|
414
|
+
* @returns A set of four strings representing the contents of the `.d.ts`,
|
|
415
|
+
* `.ts`, and `.tsx` files for the generated Store and React modules.
|
|
398
416
|
* @example
|
|
399
417
|
* This example creates a Tools object and generates code for a Store that
|
|
400
418
|
* already has a TablesSchema.
|
|
@@ -405,7 +423,9 @@ export interface Tools {
|
|
|
405
423
|
* },
|
|
406
424
|
* });
|
|
407
425
|
* const tools = createTools(store);
|
|
408
|
-
* const [dTs, ts] = await
|
|
426
|
+
* const [dTs, ts, dTsUiReact, tsUiReact] = await createTools(
|
|
427
|
+
* store,
|
|
428
|
+
* ).getPrettyStoreApi('shop');
|
|
409
429
|
*
|
|
410
430
|
* const dTsLines = dTs.split('\n');
|
|
411
431
|
* console.log(dTsLines[5]);
|
|
@@ -414,7 +434,7 @@ export interface Tools {
|
|
|
414
434
|
* // -> 'export type PetsRow = {price?: number};'
|
|
415
435
|
*
|
|
416
436
|
* const tsLines = ts.split('\n');
|
|
417
|
-
* console.log(tsLines[
|
|
437
|
+
* console.log(tsLines[75]);
|
|
418
438
|
* // -> ' hasPetsTable: (): boolean => store.hasTable(PETS),'
|
|
419
439
|
* ```
|
|
420
440
|
* @example
|
|
@@ -426,7 +446,9 @@ export interface Tools {
|
|
|
426
446
|
* felix: {price: 4},
|
|
427
447
|
* });
|
|
428
448
|
* const tools = createTools(store);
|
|
429
|
-
* const [dTs, ts] = await
|
|
449
|
+
* const [dTs, ts, dTsUiReact, tsUiReact] = await createTools(
|
|
450
|
+
* store,
|
|
451
|
+
* ).getPrettyStoreApi('shop');
|
|
430
452
|
*
|
|
431
453
|
* const dTsLines = dTs.split('\n');
|
|
432
454
|
* console.log(dTsLines[5]);
|
|
@@ -435,13 +457,15 @@ export interface Tools {
|
|
|
435
457
|
* // -> 'export type PetsRow = {price: number};'
|
|
436
458
|
*
|
|
437
459
|
* const tsLines = ts.split('\n');
|
|
438
|
-
* console.log(tsLines[
|
|
460
|
+
* console.log(tsLines[77]);
|
|
439
461
|
* // -> ' hasPetsTable: (): boolean => store.hasTable(PETS),'
|
|
440
462
|
* ```
|
|
441
463
|
* @category Modelling
|
|
442
464
|
* @since v2.2.0
|
|
443
465
|
*/
|
|
444
|
-
getPrettyStoreApi(
|
|
466
|
+
getPrettyStoreApi(
|
|
467
|
+
storeName: string,
|
|
468
|
+
): Promise<[string, string, string, string]>;
|
|
445
469
|
|
|
446
470
|
/**
|
|
447
471
|
* The getStore method returns a reference to the underlying Store that is
|