tinybase 2.0.0-beta.3 → 2.0.0-beta.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/checkpoints.d.ts +1 -1
- package/lib/debug/checkpoints.d.ts +1 -1
- package/lib/debug/persisters.d.ts +1 -1
- package/lib/debug/queries.d.ts +53 -45
- package/lib/debug/queries.js +9 -8
- package/lib/debug/relationships.d.ts +1 -1
- package/lib/debug/tinybase.js +9 -8
- package/lib/debug/ui-react.d.ts +29 -9
- package/lib/persisters.d.ts +1 -1
- package/lib/queries.d.ts +53 -45
- package/lib/queries.js +1 -1
- package/lib/queries.js.gz +0 -0
- package/lib/relationships.d.ts +1 -1
- package/lib/tinybase.js +1 -1
- package/lib/tinybase.js.gz +0 -0
- package/lib/ui-react.d.ts +29 -9
- package/lib/umd/queries.js +1 -1
- package/lib/umd/queries.js.gz +0 -0
- package/lib/umd/tinybase.js +1 -1
- package/lib/umd/tinybase.js.gz +0 -0
- package/package.json +20 -19
- package/readme.md +11 -11
package/lib/debug/ui-react.d.ts
CHANGED
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
* @see Building UIs With Checkpoints guide
|
|
18
18
|
* @see Countries demo
|
|
19
19
|
* @see Todo App demos
|
|
20
|
-
* @see
|
|
20
|
+
* @see Drawing demo
|
|
21
21
|
* @packageDocumentation
|
|
22
22
|
* @module ui-react
|
|
23
23
|
*/
|
|
@@ -154,6 +154,7 @@ export type RelationshipsOrRelationshipsId = Relationships | Id;
|
|
|
154
154
|
* parameter or a prop, allowing you to pass in either the Store or its Id.
|
|
155
155
|
*
|
|
156
156
|
* @category Identity
|
|
157
|
+
* @since v2.0.0
|
|
157
158
|
*/
|
|
158
159
|
export type QueriesOrQueriesId = Queries | Id;
|
|
159
160
|
|
|
@@ -2187,6 +2188,7 @@ export function useRowIdsListener(
|
|
|
2187
2188
|
* // -> 0
|
|
2188
2189
|
* ```
|
|
2189
2190
|
* @category Store hooks
|
|
2191
|
+
* @since v2.0.0
|
|
2190
2192
|
*/
|
|
2191
2193
|
export function useSortedRowIdsListener(
|
|
2192
2194
|
tableId: Id,
|
|
@@ -4236,7 +4238,7 @@ export function useLinkedRowIdsListener(
|
|
|
4236
4238
|
* // -> '<span>brown</span>'
|
|
4237
4239
|
* ```
|
|
4238
4240
|
* @category Queries hooks
|
|
4239
|
-
* @since v2.0.0
|
|
4241
|
+
* @since v2.0.0
|
|
4240
4242
|
*/
|
|
4241
4243
|
export function useCreateQueries(
|
|
4242
4244
|
store: Store,
|
|
@@ -4304,6 +4306,7 @@ export function useCreateQueries(
|
|
|
4304
4306
|
* // -> '<span>0</span>'
|
|
4305
4307
|
* ```
|
|
4306
4308
|
* @category Queries hooks
|
|
4309
|
+
* @since v2.0.0
|
|
4307
4310
|
*/
|
|
4308
4311
|
export function useQueries(id?: Id): Queries | undefined;
|
|
4309
4312
|
|
|
@@ -4420,6 +4423,7 @@ export function useQueries(id?: Id): Queries | undefined;
|
|
|
4420
4423
|
* // -> '<span>{"fido":{"color":"brown"},"cujo":{"color":"black"}}</span>'
|
|
4421
4424
|
* ```
|
|
4422
4425
|
* @category Queries hooks
|
|
4426
|
+
* @since v2.0.0
|
|
4423
4427
|
*/
|
|
4424
4428
|
export function useResultTable(
|
|
4425
4429
|
queryId: Id,
|
|
@@ -4540,6 +4544,7 @@ export function useResultTable(
|
|
|
4540
4544
|
* // -> '<span>["fido","cujo"]</span>'
|
|
4541
4545
|
* ```
|
|
4542
4546
|
* @category Queries hooks
|
|
4547
|
+
* @since v2.0.0
|
|
4543
4548
|
*/
|
|
4544
4549
|
export function useResultRowIds(
|
|
4545
4550
|
queryId: Id,
|
|
@@ -4688,6 +4693,7 @@ export function useResultRowIds(
|
|
|
4688
4693
|
* // -> '<span>["cujo","fido"]</span>'
|
|
4689
4694
|
* ```
|
|
4690
4695
|
* @category Queries hooks
|
|
4696
|
+
* @since v2.0.0
|
|
4691
4697
|
*/
|
|
4692
4698
|
export function useResultSortedRowIds(
|
|
4693
4699
|
queryId: Id,
|
|
@@ -4815,6 +4821,7 @@ export function useResultSortedRowIds(
|
|
|
4815
4821
|
* // -> '<span>{"color":"brown"}</span>'
|
|
4816
4822
|
* ```
|
|
4817
4823
|
* @category Queries hooks
|
|
4824
|
+
* @since v2.0.0
|
|
4818
4825
|
*/
|
|
4819
4826
|
export function useResultRow(
|
|
4820
4827
|
queryId: Id,
|
|
@@ -4945,6 +4952,7 @@ export function useResultRow(
|
|
|
4945
4952
|
* // -> '<span>["species","color"]</span>'
|
|
4946
4953
|
* ```
|
|
4947
4954
|
* @category Queries hooks
|
|
4955
|
+
* @since v2.0.0
|
|
4948
4956
|
*/
|
|
4949
4957
|
export function useResultCellIds(
|
|
4950
4958
|
queryId: Id,
|
|
@@ -5071,6 +5079,7 @@ export function useResultCellIds(
|
|
|
5071
5079
|
* // -> '<span>brown</span>'
|
|
5072
5080
|
* ```
|
|
5073
5081
|
* @category Queries hooks
|
|
5082
|
+
* @since v2.0.0
|
|
5074
5083
|
*/
|
|
5075
5084
|
export function useResultCell(
|
|
5076
5085
|
queryId: Id,
|
|
@@ -5147,6 +5156,7 @@ export function useResultCell(
|
|
|
5147
5156
|
* // -> 0
|
|
5148
5157
|
* ```
|
|
5149
5158
|
* @category Queries hooks
|
|
5159
|
+
* @since v2.0.0
|
|
5150
5160
|
*/
|
|
5151
5161
|
export function useResultTableListener(
|
|
5152
5162
|
queryId: IdOrNull,
|
|
@@ -5223,6 +5233,7 @@ export function useResultTableListener(
|
|
|
5223
5233
|
* // -> 0
|
|
5224
5234
|
* ```
|
|
5225
5235
|
* @category Queries hooks
|
|
5236
|
+
* @since v2.0.0
|
|
5226
5237
|
*/
|
|
5227
5238
|
export function useResultRowIdsListener(
|
|
5228
5239
|
queryId: IdOrNull,
|
|
@@ -5306,6 +5317,7 @@ export function useResultRowIdsListener(
|
|
|
5306
5317
|
* // -> 0
|
|
5307
5318
|
* ```
|
|
5308
5319
|
* @category Queries hooks
|
|
5320
|
+
* @since v2.0.0
|
|
5309
5321
|
*/
|
|
5310
5322
|
export function useResultSortedRowIdsListener(
|
|
5311
5323
|
queryId: Id,
|
|
@@ -5392,6 +5404,7 @@ export function useResultSortedRowIdsListener(
|
|
|
5392
5404
|
* // -> 0
|
|
5393
5405
|
* ```
|
|
5394
5406
|
* @category Queries hooks
|
|
5407
|
+
* @since v2.0.0
|
|
5395
5408
|
*/
|
|
5396
5409
|
export function useResultRowListener(
|
|
5397
5410
|
queryId: IdOrNull,
|
|
@@ -5475,6 +5488,7 @@ export function useResultRowListener(
|
|
|
5475
5488
|
* // -> 0
|
|
5476
5489
|
* ```
|
|
5477
5490
|
* @category Queries hooks
|
|
5491
|
+
* @since v2.0.0
|
|
5478
5492
|
*/
|
|
5479
5493
|
export function useResultCellIdsListener(
|
|
5480
5494
|
queryId: IdOrNull,
|
|
@@ -5560,6 +5574,7 @@ export function useResultCellIdsListener(
|
|
|
5560
5574
|
* // -> 0
|
|
5561
5575
|
* ```
|
|
5562
5576
|
* @category Queries hooks
|
|
5577
|
+
* @since v2.0.0
|
|
5563
5578
|
*/
|
|
5564
5579
|
export function useResultCellListener(
|
|
5565
5580
|
queryId: IdOrNull,
|
|
@@ -7283,8 +7298,8 @@ export type ForwardCheckpointsProps = {
|
|
|
7283
7298
|
|
|
7284
7299
|
/**
|
|
7285
7300
|
* ProviderProps props are used with the Provider component, so that Store
|
|
7286
|
-
* Metrics, Indexes, Relationships, and Checkpoints objects can be
|
|
7287
|
-
* the context of an application and used throughout.
|
|
7301
|
+
* Metrics, Indexes, Relationships, Queries, and Checkpoints objects can be
|
|
7302
|
+
* passed into the context of an application and used throughout.
|
|
7288
7303
|
*
|
|
7289
7304
|
* One of each type of object can be provided as a default within the context.
|
|
7290
7305
|
* Additionally, multiple of each type of object can be provided in an Id-keyed
|
|
@@ -7335,12 +7350,12 @@ export type ProviderProps = {
|
|
|
7335
7350
|
readonly relationshipsById?: {[relationshipsId: Id]: Relationships};
|
|
7336
7351
|
/**
|
|
7337
7352
|
* A default single Queries object that will be available within the Provider
|
|
7338
|
-
* context.
|
|
7353
|
+
* context, since v2.0.0.
|
|
7339
7354
|
*/
|
|
7340
7355
|
readonly queries?: Queries;
|
|
7341
7356
|
/**
|
|
7342
7357
|
* An object containing multiple Queries objects that will be available within
|
|
7343
|
-
* the Provider context by their Id.
|
|
7358
|
+
* the Provider context by their Id, since v2.0.0.
|
|
7344
7359
|
*/
|
|
7345
7360
|
readonly queriesById?: {[queriesId: Id]: Queries};
|
|
7346
7361
|
/**
|
|
@@ -7367,9 +7382,9 @@ export type ComponentReturnType = ReactElement<any, any> | null;
|
|
|
7367
7382
|
* The Provider component is used to wrap part of an application in a context
|
|
7368
7383
|
* that provides default objects to be used by hooks and components within.
|
|
7369
7384
|
*
|
|
7370
|
-
* Store, Metrics, Indexes, Relationships, and Checkpoints objects can
|
|
7371
|
-
* into the context of an application and used throughout. One of each
|
|
7372
|
-
* object can be provided as a default within the context. Additionally,
|
|
7385
|
+
* Store, Metrics, Indexes, Relationships, Queries, and Checkpoints objects can
|
|
7386
|
+
* be passed into the context of an application and used throughout. One of each
|
|
7387
|
+
* type of object can be provided as a default within the context. Additionally,
|
|
7373
7388
|
* multiple of each type of object can be provided in an Id-keyed map to the
|
|
7374
7389
|
* `___ById` props.
|
|
7375
7390
|
*
|
|
@@ -7792,6 +7807,7 @@ export function RowView(props: RowProps): ComponentReturnType;
|
|
|
7792
7807
|
* // -> '<div><span>felix: cat</span><span><b>fido</b>: dog</span></div>'
|
|
7793
7808
|
* ```
|
|
7794
7809
|
* @category Store components
|
|
7810
|
+
* @since v2.0.0
|
|
7795
7811
|
*/
|
|
7796
7812
|
export function SortedTableView(props: SortedTableProps): ComponentReturnType;
|
|
7797
7813
|
|
|
@@ -8888,6 +8904,7 @@ export function LinkedRowsView(props: LinkedRowsProps): ComponentReturnType;
|
|
|
8888
8904
|
* // -> '<span></span>'
|
|
8889
8905
|
* ```
|
|
8890
8906
|
* @category Queries components
|
|
8907
|
+
* @since v2.0.0
|
|
8891
8908
|
*/
|
|
8892
8909
|
export function ResultCellView(props: ResultCellProps): ComponentReturnType;
|
|
8893
8910
|
|
|
@@ -9034,6 +9051,7 @@ export function ResultCellView(props: ResultCellProps): ComponentReturnType;
|
|
|
9034
9051
|
* // -> '<div><span><b>species</b>: dog</span><span>color: brown</span></div>'
|
|
9035
9052
|
* ```
|
|
9036
9053
|
* @category Queries components
|
|
9054
|
+
* @since v2.0.0
|
|
9037
9055
|
*/
|
|
9038
9056
|
export function ResultRowView(props: ResultRowProps): ComponentReturnType;
|
|
9039
9057
|
|
|
@@ -9171,6 +9189,7 @@ export function ResultRowView(props: ResultRowProps): ComponentReturnType;
|
|
|
9171
9189
|
* // -> '<div><span>felix: black</span><span><b>fido</b>: brown</span></div>'
|
|
9172
9190
|
* ```
|
|
9173
9191
|
* @category Queries components
|
|
9192
|
+
* @since v2.0.0
|
|
9174
9193
|
*/
|
|
9175
9194
|
export function ResultSortedTableView(
|
|
9176
9195
|
props: ResultSortedTableProps,
|
|
@@ -9295,6 +9314,7 @@ export function ResultSortedTableView(
|
|
|
9295
9314
|
* // -> '<div><span><b>fido</b>: brown</span><span>felix: black</span></div>'
|
|
9296
9315
|
* ```
|
|
9297
9316
|
* @category Queries components
|
|
9317
|
+
* @since v2.0.0
|
|
9298
9318
|
*/
|
|
9299
9319
|
export function ResultTableView(props: ResultTableProps): ComponentReturnType;
|
|
9300
9320
|
|
package/lib/persisters.d.ts
CHANGED
package/lib/queries.d.ts
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
*
|
|
10
10
|
* @packageDocumentation
|
|
11
11
|
* @module queries
|
|
12
|
-
* @since v2.0.0
|
|
12
|
+
* @since v2.0.0
|
|
13
13
|
*/
|
|
14
14
|
|
|
15
15
|
import {
|
|
@@ -38,7 +38,7 @@ import {Id, IdOrNull, Ids} from './common.d';
|
|
|
38
38
|
* @param length The length of the array of Cell values to be aggregated.
|
|
39
39
|
* @returns The value of the aggregation.
|
|
40
40
|
* @category Aggregators
|
|
41
|
-
* @since v2.0.0
|
|
41
|
+
* @since v2.0.0
|
|
42
42
|
*/
|
|
43
43
|
export type Aggregate = (cells: Cell[], length: number) => Cell;
|
|
44
44
|
|
|
@@ -64,7 +64,7 @@ export type Aggregate = (cells: Cell[], length: number) => Cell;
|
|
|
64
64
|
* @param length The length of the array of Cell values in the aggregation.
|
|
65
65
|
* @returns The new value of the aggregation.
|
|
66
66
|
* @category Aggregators
|
|
67
|
-
* @since v2.0.0
|
|
67
|
+
* @since v2.0.0
|
|
68
68
|
*/
|
|
69
69
|
export type AggregateAdd = (
|
|
70
70
|
current: Cell,
|
|
@@ -97,7 +97,7 @@ export type AggregateAdd = (
|
|
|
97
97
|
* @param length The length of the array of Cell values in the aggregation.
|
|
98
98
|
* @returns The new value of the aggregation.
|
|
99
99
|
* @category Aggregators
|
|
100
|
-
* @since v2.0.0
|
|
100
|
+
* @since v2.0.0
|
|
101
101
|
*/
|
|
102
102
|
export type AggregateRemove = (
|
|
103
103
|
current: Cell,
|
|
@@ -129,7 +129,7 @@ export type AggregateRemove = (
|
|
|
129
129
|
* @param length The length of the array of Cell values in the aggregation.
|
|
130
130
|
* @returns The new value of the aggregation.
|
|
131
131
|
* @category Aggregators
|
|
132
|
-
* @since v2.0.0
|
|
132
|
+
* @since v2.0.0
|
|
133
133
|
*/
|
|
134
134
|
export type AggregateReplace = (
|
|
135
135
|
current: Cell,
|
|
@@ -147,7 +147,7 @@ export type AggregateReplace = (
|
|
|
147
147
|
*
|
|
148
148
|
* @param queryId The Id of the query that the callback can operate on.
|
|
149
149
|
* @category Callback
|
|
150
|
-
* @since v2.0.0
|
|
150
|
+
* @since v2.0.0
|
|
151
151
|
*/
|
|
152
152
|
export type QueryCallback = (queryId: Id) => void;
|
|
153
153
|
|
|
@@ -168,7 +168,7 @@ export type QueryCallback = (queryId: Id) => void;
|
|
|
168
168
|
* @param getCellChange A function that returns information about any Cell's
|
|
169
169
|
* changes.
|
|
170
170
|
* @category Listener
|
|
171
|
-
* @since v2.0.0
|
|
171
|
+
* @since v2.0.0
|
|
172
172
|
*/
|
|
173
173
|
export type ResultTableListener = (
|
|
174
174
|
queries: Queries,
|
|
@@ -190,7 +190,7 @@ export type ResultTableListener = (
|
|
|
190
190
|
* @param queries A reference to the Queries object that changed.
|
|
191
191
|
* @param tableId The Id of the Table that changed, which is also the query Id.
|
|
192
192
|
* @category Listener
|
|
193
|
-
* @since v2.0.0
|
|
193
|
+
* @since v2.0.0
|
|
194
194
|
*/
|
|
195
195
|
export type ResultRowIdsListener = (queries: Queries, tableId: Id) => void;
|
|
196
196
|
|
|
@@ -217,7 +217,7 @@ export type ResultRowIdsListener = (queries: Queries, tableId: Id) => void;
|
|
|
217
217
|
* @param limit The maximum number of Row Ids returned.
|
|
218
218
|
* @param sortedRowIds The sorted Row Ids themselves.
|
|
219
219
|
* @category Listener
|
|
220
|
-
* @since v2.0.0
|
|
220
|
+
* @since v2.0.0
|
|
221
221
|
*/
|
|
222
222
|
export type ResultSortedRowIdsListener = (
|
|
223
223
|
queries: Queries,
|
|
@@ -247,7 +247,7 @@ export type ResultSortedRowIdsListener = (
|
|
|
247
247
|
* @param getCellChange A function that returns information about any Cell's
|
|
248
248
|
* changes.
|
|
249
249
|
* @category Listener
|
|
250
|
-
* @since v2.0.0
|
|
250
|
+
* @since v2.0.0
|
|
251
251
|
*/
|
|
252
252
|
export type ResultRowListener = (
|
|
253
253
|
queries: Queries,
|
|
@@ -271,7 +271,7 @@ export type ResultRowListener = (
|
|
|
271
271
|
* @param tableId The Id of the Table that changed, which is also the query Id.
|
|
272
272
|
* @param rowId The Id of the Row that changed.
|
|
273
273
|
* @category Listener
|
|
274
|
-
* @since v2.0.0
|
|
274
|
+
* @since v2.0.0
|
|
275
275
|
*/
|
|
276
276
|
export type ResultCellIdsListener = (
|
|
277
277
|
queries: Queries,
|
|
@@ -301,7 +301,7 @@ export type ResultCellIdsListener = (
|
|
|
301
301
|
* @param getCellChange A function that returns information about any Cell's
|
|
302
302
|
* changes.
|
|
303
303
|
* @category Listener
|
|
304
|
-
* @since v2.0.0
|
|
304
|
+
* @since v2.0.0
|
|
305
305
|
*/
|
|
306
306
|
export type ResultCellListener = (
|
|
307
307
|
queries: Queries,
|
|
@@ -321,7 +321,7 @@ export type ResultCellListener = (
|
|
|
321
321
|
* and is only populated in a debug build.
|
|
322
322
|
*
|
|
323
323
|
* @category Development
|
|
324
|
-
* @since v2.0.0
|
|
324
|
+
* @since v2.0.0
|
|
325
325
|
*/
|
|
326
326
|
export type QueriesListenerStats = {
|
|
327
327
|
/**
|
|
@@ -355,7 +355,7 @@ export type QueriesListenerStats = {
|
|
|
355
355
|
* calculated values. See those methods for specific examples.
|
|
356
356
|
*
|
|
357
357
|
* @category Callback
|
|
358
|
-
* @since v2.0.0
|
|
358
|
+
* @since v2.0.0
|
|
359
359
|
*/
|
|
360
360
|
export type GetTableCell = {
|
|
361
361
|
/**
|
|
@@ -476,7 +476,7 @@ export type GetTableCell = {
|
|
|
476
476
|
* // -> {cujo: {description: 'dog for Carol'}}
|
|
477
477
|
* ```
|
|
478
478
|
* @category Definition
|
|
479
|
-
* @since v2.0.0
|
|
479
|
+
* @since v2.0.0
|
|
480
480
|
*/
|
|
481
481
|
export type Select = {
|
|
482
482
|
/**
|
|
@@ -561,7 +561,7 @@ export type Select = {
|
|
|
561
561
|
* // -> {cujo: {petSpecies: 'dog', ownerName: 'Carol'}}
|
|
562
562
|
* ```
|
|
563
563
|
* @category Definition
|
|
564
|
-
* @since v2.0.0
|
|
564
|
+
* @since v2.0.0
|
|
565
565
|
*/
|
|
566
566
|
export type SelectedAs = {
|
|
567
567
|
/**
|
|
@@ -734,7 +734,7 @@ export type SelectedAs = {
|
|
|
734
734
|
* // -> {cujo: {description: 'dog in Washington'}}
|
|
735
735
|
* ```
|
|
736
736
|
* @category Definition
|
|
737
|
-
* @since v2.0.0
|
|
737
|
+
* @since v2.0.0
|
|
738
738
|
*/
|
|
739
739
|
export type Join = {
|
|
740
740
|
/**
|
|
@@ -848,7 +848,7 @@ export type Join = {
|
|
|
848
848
|
* // -> {cujo: {buyer: 'Carol', seller: 'Alice'}}
|
|
849
849
|
* ```
|
|
850
850
|
* @category Definition
|
|
851
|
-
* @since v2.0.0
|
|
851
|
+
* @since v2.0.0
|
|
852
852
|
*/
|
|
853
853
|
export type JoinedAs = {as: (joinedTableId: Id) => void};
|
|
854
854
|
|
|
@@ -966,7 +966,7 @@ export type JoinedAs = {as: (joinedTableId: Id) => void};
|
|
|
966
966
|
* // -> {cujo: {species: 'dog', state: 'WA'}}
|
|
967
967
|
* ```
|
|
968
968
|
* @category Definition
|
|
969
|
-
* @since v2.0.0
|
|
969
|
+
* @since v2.0.0
|
|
970
970
|
*/
|
|
971
971
|
export type Where = {
|
|
972
972
|
/**
|
|
@@ -1171,6 +1171,8 @@ export type Where = {
|
|
|
1171
1171
|
* // -> {1: {owner: 'bob', lowestPriceOver2: 3}}
|
|
1172
1172
|
* // Both have a parrot at 3. Alice's worm at 1 is excluded from aggregation.
|
|
1173
1173
|
* ```
|
|
1174
|
+
* @category Definition
|
|
1175
|
+
* @since v2.0.0
|
|
1174
1176
|
*/
|
|
1175
1177
|
export type Group = (
|
|
1176
1178
|
selectedCellId: Id,
|
|
@@ -1215,7 +1217,7 @@ export type Group = (
|
|
|
1215
1217
|
* // -> {1: {species: 'cat', minPrice: 3, maxPrice: 4}}
|
|
1216
1218
|
* ```
|
|
1217
1219
|
* @category Definition
|
|
1218
|
-
* @since v2.0.0
|
|
1220
|
+
* @since v2.0.0
|
|
1219
1221
|
*/
|
|
1220
1222
|
export type GroupedAs = {as: (groupedCellId: Id) => void};
|
|
1221
1223
|
|
|
@@ -1305,7 +1307,7 @@ export type GroupedAs = {as: (groupedCellId: Id) => void};
|
|
|
1305
1307
|
* // Parrots are filtered out because they have zero range in price.
|
|
1306
1308
|
* ```
|
|
1307
1309
|
* @category Definition
|
|
1308
|
-
* @since v2.0.0
|
|
1310
|
+
* @since v2.0.0
|
|
1309
1311
|
*/
|
|
1310
1312
|
export type Having = {
|
|
1311
1313
|
/**
|
|
@@ -1421,7 +1423,7 @@ export type Having = {
|
|
|
1421
1423
|
* ```
|
|
1422
1424
|
* @see Queries guides
|
|
1423
1425
|
* @category Queries
|
|
1424
|
-
* @since v2.0.0
|
|
1426
|
+
* @since v2.0.0
|
|
1425
1427
|
*/
|
|
1426
1428
|
export interface Queries {
|
|
1427
1429
|
/**
|
|
@@ -1485,7 +1487,7 @@ export interface Queries {
|
|
|
1485
1487
|
* // -> {fido: {color: 'brown'}, cujo: {color: 'black'}}
|
|
1486
1488
|
* ```
|
|
1487
1489
|
* @category Configuration
|
|
1488
|
-
* @since v2.0.0
|
|
1490
|
+
* @since v2.0.0
|
|
1489
1491
|
*/
|
|
1490
1492
|
setQueryDefinition(
|
|
1491
1493
|
queryId: Id,
|
|
@@ -1528,7 +1530,7 @@ export interface Queries {
|
|
|
1528
1530
|
* // -> []
|
|
1529
1531
|
* ```
|
|
1530
1532
|
* @category Configuration
|
|
1531
|
-
* @since v2.0.0
|
|
1533
|
+
* @since v2.0.0
|
|
1532
1534
|
*/
|
|
1533
1535
|
delQueryDefinition(queryId: Id): Queries;
|
|
1534
1536
|
|
|
@@ -1554,7 +1556,7 @@ export interface Queries {
|
|
|
1554
1556
|
* // -> {fido: {color: 'brown'}}
|
|
1555
1557
|
* ```
|
|
1556
1558
|
* @category Getter
|
|
1557
|
-
* @since v2.0.0
|
|
1559
|
+
* @since v2.0.0
|
|
1558
1560
|
*/
|
|
1559
1561
|
getStore(): Store;
|
|
1560
1562
|
|
|
@@ -1582,7 +1584,7 @@ export interface Queries {
|
|
|
1582
1584
|
* // -> ['dogColors', 'catColors']
|
|
1583
1585
|
* ```
|
|
1584
1586
|
* @category Getter
|
|
1585
|
-
* @since v2.0.0
|
|
1587
|
+
* @since v2.0.0
|
|
1586
1588
|
*/
|
|
1587
1589
|
getQueryIds(): Ids;
|
|
1588
1590
|
|
|
@@ -1616,7 +1618,7 @@ export interface Queries {
|
|
|
1616
1618
|
* // -> 'catColors'
|
|
1617
1619
|
* ```
|
|
1618
1620
|
* @category Iterator
|
|
1619
|
-
* @since v2.0.0
|
|
1621
|
+
* @since v2.0.0
|
|
1620
1622
|
*/
|
|
1621
1623
|
forEachQuery(queryCallback: QueryCallback): void;
|
|
1622
1624
|
|
|
@@ -1645,7 +1647,7 @@ export interface Queries {
|
|
|
1645
1647
|
* // -> false
|
|
1646
1648
|
* ```
|
|
1647
1649
|
* @category Getter
|
|
1648
|
-
* @since v2.0.0
|
|
1650
|
+
* @since v2.0.0
|
|
1649
1651
|
*/
|
|
1650
1652
|
hasQuery(queryId: Id): boolean;
|
|
1651
1653
|
|
|
@@ -1678,7 +1680,7 @@ export interface Queries {
|
|
|
1678
1680
|
* // -> undefined
|
|
1679
1681
|
* ```
|
|
1680
1682
|
* @category Getter
|
|
1681
|
-
* @since v2.0.0
|
|
1683
|
+
* @since v2.0.0
|
|
1682
1684
|
*/
|
|
1683
1685
|
getTableId(queryId: Id): Id | undefined;
|
|
1684
1686
|
|
|
@@ -1724,7 +1726,7 @@ export interface Queries {
|
|
|
1724
1726
|
* // -> {}
|
|
1725
1727
|
* ```
|
|
1726
1728
|
* @category Result
|
|
1727
|
-
* @since v2.0.0
|
|
1729
|
+
* @since v2.0.0
|
|
1728
1730
|
*/
|
|
1729
1731
|
getResultTable(queryId: Id): Table;
|
|
1730
1732
|
|
|
@@ -1767,7 +1769,7 @@ export interface Queries {
|
|
|
1767
1769
|
* // -> []
|
|
1768
1770
|
* ```
|
|
1769
1771
|
* @category Result
|
|
1770
|
-
* @since v2.0.0
|
|
1772
|
+
* @since v2.0.0
|
|
1771
1773
|
*/
|
|
1772
1774
|
getResultRowIds(queryId: Id): Ids;
|
|
1773
1775
|
|
|
@@ -1827,7 +1829,7 @@ export interface Queries {
|
|
|
1827
1829
|
* // -> []
|
|
1828
1830
|
* ```
|
|
1829
1831
|
* @category Result
|
|
1830
|
-
* @since v2.0.0
|
|
1832
|
+
* @since v2.0.0
|
|
1831
1833
|
*/
|
|
1832
1834
|
getResultSortedRowIds(
|
|
1833
1835
|
queryId: Id,
|
|
@@ -1879,7 +1881,7 @@ export interface Queries {
|
|
|
1879
1881
|
* // -> {}
|
|
1880
1882
|
* ```
|
|
1881
1883
|
* @category Result
|
|
1882
|
-
* @since v2.0.0
|
|
1884
|
+
* @since v2.0.0
|
|
1883
1885
|
*/
|
|
1884
1886
|
getResultRow(queryId: Id, rowId: Id): Row;
|
|
1885
1887
|
|
|
@@ -1925,7 +1927,7 @@ export interface Queries {
|
|
|
1925
1927
|
* // -> []
|
|
1926
1928
|
* ```
|
|
1927
1929
|
* @category Result
|
|
1928
|
-
* @since v2.0.0
|
|
1930
|
+
* @since v2.0.0
|
|
1929
1931
|
*/
|
|
1930
1932
|
getResultCellIds(queryId: Id, rowId: Id): Ids;
|
|
1931
1933
|
|
|
@@ -1968,7 +1970,7 @@ export interface Queries {
|
|
|
1968
1970
|
* // -> undefined
|
|
1969
1971
|
* ```
|
|
1970
1972
|
* @category Result
|
|
1971
|
-
* @since v2.0.0
|
|
1973
|
+
* @since v2.0.0
|
|
1972
1974
|
*/
|
|
1973
1975
|
getResultCell(queryId: Id, rowId: Id, cellId: Id): CellOrUndefined;
|
|
1974
1976
|
|
|
@@ -2003,7 +2005,7 @@ export interface Queries {
|
|
|
2003
2005
|
* // -> false
|
|
2004
2006
|
* ```
|
|
2005
2007
|
* @category Result
|
|
2006
|
-
* @since v2.0.0
|
|
2008
|
+
* @since v2.0.0
|
|
2007
2009
|
*/
|
|
2008
2010
|
hasResultTable(queryId: Id): boolean;
|
|
2009
2011
|
|
|
@@ -2039,7 +2041,7 @@ export interface Queries {
|
|
|
2039
2041
|
* // -> false
|
|
2040
2042
|
* ```
|
|
2041
2043
|
* @category Result
|
|
2042
|
-
* @since v2.0.0
|
|
2044
|
+
* @since v2.0.0
|
|
2043
2045
|
*/
|
|
2044
2046
|
hasResultRow(queryId: Id, rowId: Id): boolean;
|
|
2045
2047
|
|
|
@@ -2076,7 +2078,7 @@ export interface Queries {
|
|
|
2076
2078
|
* // -> false
|
|
2077
2079
|
* ```
|
|
2078
2080
|
* @category Result
|
|
2079
|
-
* @since v2.0.0
|
|
2081
|
+
* @since v2.0.0
|
|
2080
2082
|
*/
|
|
2081
2083
|
hasResultCell(queryId: Id, rowId: Id, cellId: Id): boolean;
|
|
2082
2084
|
|
|
@@ -2123,7 +2125,7 @@ export interface Queries {
|
|
|
2123
2125
|
* // -> '- felix'
|
|
2124
2126
|
* ```
|
|
2125
2127
|
* @category Iterator
|
|
2126
|
-
* @since v2.0.0
|
|
2128
|
+
* @since v2.0.0
|
|
2127
2129
|
*/
|
|
2128
2130
|
forEachResultTable(tableCallback: TableCallback): void;
|
|
2129
2131
|
|
|
@@ -2169,7 +2171,7 @@ export interface Queries {
|
|
|
2169
2171
|
* // -> '- color'
|
|
2170
2172
|
* ```
|
|
2171
2173
|
* @category Iterator
|
|
2172
|
-
* @since v2.0.0
|
|
2174
|
+
* @since v2.0.0
|
|
2173
2175
|
*/
|
|
2174
2176
|
forEachResultRow(queryId: Id, rowCallback: RowCallback): void;
|
|
2175
2177
|
|
|
@@ -2212,7 +2214,7 @@ export interface Queries {
|
|
|
2212
2214
|
* // -> 'color: brown'
|
|
2213
2215
|
* ```
|
|
2214
2216
|
* @category Iterator
|
|
2215
|
-
* @since v2.0.0
|
|
2217
|
+
* @since v2.0.0
|
|
2216
2218
|
*/
|
|
2217
2219
|
forEachResultCell(queryId: Id, rowId: Id, cellCallback: CellCallback): void;
|
|
2218
2220
|
|
|
@@ -2303,6 +2305,7 @@ export interface Queries {
|
|
|
2303
2305
|
* store.delListener(listenerId);
|
|
2304
2306
|
* ```
|
|
2305
2307
|
* @category Listener
|
|
2308
|
+
* @since v2.0.0
|
|
2306
2309
|
*/
|
|
2307
2310
|
addResultTableListener(queryId: IdOrNull, listener: ResultTableListener): Id;
|
|
2308
2311
|
|
|
@@ -2397,6 +2400,7 @@ export interface Queries {
|
|
|
2397
2400
|
* store.delListener(listenerId);
|
|
2398
2401
|
* ```
|
|
2399
2402
|
* @category Listener
|
|
2403
|
+
* @since v2.0.0
|
|
2400
2404
|
*/
|
|
2401
2405
|
addResultRowIdsListener(
|
|
2402
2406
|
queryId: IdOrNull,
|
|
@@ -2523,6 +2527,7 @@ export interface Queries {
|
|
|
2523
2527
|
* store.delListener(listenerId);
|
|
2524
2528
|
* ```
|
|
2525
2529
|
* @category Listener
|
|
2530
|
+
* @since v2.0.0
|
|
2526
2531
|
*/
|
|
2527
2532
|
addResultSortedRowIdsListener(
|
|
2528
2533
|
queryId: Id,
|
|
@@ -2629,6 +2634,7 @@ export interface Queries {
|
|
|
2629
2634
|
* store.delListener(listenerId);
|
|
2630
2635
|
* ```
|
|
2631
2636
|
* @category Listener
|
|
2637
|
+
* @since v2.0.0
|
|
2632
2638
|
*/
|
|
2633
2639
|
addResultRowListener(
|
|
2634
2640
|
queryId: IdOrNull,
|
|
@@ -2741,6 +2747,7 @@ export interface Queries {
|
|
|
2741
2747
|
* store.delListener(listenerId);
|
|
2742
2748
|
* ```
|
|
2743
2749
|
* @category Listener
|
|
2750
|
+
* @since v2.0.0
|
|
2744
2751
|
*/
|
|
2745
2752
|
addResultCellIdsListener(
|
|
2746
2753
|
queryId: IdOrNull,
|
|
@@ -2857,6 +2864,7 @@ export interface Queries {
|
|
|
2857
2864
|
* store.delListener(listenerId);
|
|
2858
2865
|
* ```
|
|
2859
2866
|
* @category Listener
|
|
2867
|
+
* @since v2.0.0
|
|
2860
2868
|
*/
|
|
2861
2869
|
addResultCellListener(
|
|
2862
2870
|
queryId: IdOrNull,
|
|
@@ -2907,7 +2915,7 @@ export interface Queries {
|
|
|
2907
2915
|
* // The listener is not called.
|
|
2908
2916
|
* ```
|
|
2909
2917
|
* @category Listener
|
|
2910
|
-
* @since v2.0.0
|
|
2918
|
+
* @since v2.0.0
|
|
2911
2919
|
*/
|
|
2912
2920
|
delListener(listenerId: Id): Queries;
|
|
2913
2921
|
|
|
@@ -2943,7 +2951,7 @@ export interface Queries {
|
|
|
2943
2951
|
* // -> 0
|
|
2944
2952
|
* ```
|
|
2945
2953
|
* @category Lifecycle
|
|
2946
|
-
* @since v2.0.0
|
|
2954
|
+
* @since v2.0.0
|
|
2947
2955
|
*/
|
|
2948
2956
|
destroy(): void;
|
|
2949
2957
|
|
|
@@ -2973,7 +2981,7 @@ export interface Queries {
|
|
|
2973
2981
|
* // -> 0
|
|
2974
2982
|
* ```
|
|
2975
2983
|
* @category Development
|
|
2976
|
-
* @since v2.0.0
|
|
2984
|
+
* @since v2.0.0
|
|
2977
2985
|
*/
|
|
2978
2986
|
getListenerStats(): QueriesListenerStats;
|
|
2979
2987
|
}
|
|
@@ -3011,6 +3019,6 @@ export interface Queries {
|
|
|
3011
3019
|
* // -> true
|
|
3012
3020
|
* ```
|
|
3013
3021
|
* @category Creation
|
|
3014
|
-
* @since v2.0.0
|
|
3022
|
+
* @since v2.0.0
|
|
3015
3023
|
*/
|
|
3016
3024
|
export function createQueries(store: Store): Queries;
|
package/lib/queries.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const e=e=>typeof e,t=e(""),n=e(!0),s=e(0),r=e(e),o=(e,t)=>e.every(t),l=(e,t)=>e.forEach(t),a=e=>c(e,((e,t)=>e+t),0),i=e=>e.length,d=e=>0==i(e),c=(e,t,n)=>e.reduce(t,n),u=(e,...t)=>e.push(...t),h=Math.max,w=Math.min,R=isFinite,g=e=>null==e,f=(e,t,n)=>g(e)?n?.():t(e),L=t=>e(t)==r,v=()=>{},y=e=>e.size,T=(e,t)=>e?.has(t)??!1,b=e=>g(e)||0==y(e),C=e=>[...e?.values()??[]],I=e=>e.clear(),p=(e,t)=>e?.forEach(t),S=(e,t)=>e?.delete(t),m=e=>new Map(e),Q=(e,t)=>e?.get(t),E=(e,t)=>p(e,((e,n)=>t(n,e))),M=(e,t,n)=>g(n)?(S(e,t),e):e?.set(t,n),x=(e,t,n)=>(T(e,t)||M(e,t,n()),Q(e,t)),D=(e,t,n,s,r=0)=>f((n?x:Q)(e,t[r],r>i(t)-2?n:m),(o=>{if(r>i(t)-2)return s?.(o)&&M(e,t[r]),o;const l=D(o,t,n,s,r+1);return b(o)&&M(e,t[r]),l})),F=e=>new Set(e),j=(e,t)=>e?.add(t),k=m([["avg",[(e,t)=>a(e)/t,(e,t,n)=>e+(t-e)/(n+1),(e,t,n)=>e+(e-t)/(n-1),(e,t,n,s)=>e+(t-n)/s]],["max",[e=>h(...e),(e,t)=>h(t,e),(e,t)=>t==e?void 0:e,(e,t,n)=>n==e?void 0:h(t,e)]],["min",[e=>w(...e),(e,t)=>w(t,e),(e,t)=>t==e?void 0:e,(e,t,n)=>n==e?void 0:w(t,e)]],["sum",[e=>a(e),(e,t)=>e+t,(e,t)=>e-t,(e,t,n)=>e-n+t]]]),z=r=>{const o=e(r);return(e=>e==t||e==n)(o)||o==s&&R(r)?o:void 0},W=Object,O=W.freeze,q=(e=>{const t=new WeakMap;return n=>(t.has(n)||t.set(n,e(n)),t.get(n))})((e=>{const t=e.createStore,[n,s,r,a,c,,,h,,w,R,q,A]=((e,t,n)=>{const s=e.hasRow,r=m(),o=m(),a=m(),i=m(),c=m(),u=(t,n,...s)=>{const r=x(c,t,F);return l(s,(t=>j(r,t)&&n&&e.callListener(t))),s},h=(t,...n)=>f(Q(c,t),(s=>{l(d(n)?C(s):n,(t=>{e.delListener(t),S(s,t)})),b(s)&&M(c,t)})),w=(e,n)=>{M(r,e,n),T(o,e)||(M(o,e,t()),M(a,e,m()),M(i,e,m()))},R=e=>{M(r,e),M(o,e),M(a,e),M(i,e),h(e)};return[()=>e,()=>[...r?.keys()??[]],e=>E(o,e),e=>T(o,e),e=>Q(r,e),e=>Q(o,e),(e,t)=>M(o,e,t),w,(t,r,o,d,c)=>{w(t,r);const R=m(),f=m(),L=Q(a,t),v=Q(i,t),y=t=>{const o=n=>e.getCell(r,t,n),l=Q(L,t),a=s(r,t)?n(d(o,t)):void 0;if(l!=a&&M(R,t,[l,a]),!g(c)){const e=Q(v,t),n=s(r,t)?c(o,t):void 0;e!=n&&M(f,t,n)}},b=e=>{o((()=>{p(R,(([,e],t)=>M(L,t,e))),p(f,((e,t)=>M(v,t,e)))}),R,f,L,v,e),I(R),I(f)};E(L,y),e.hasTable(r)&&l(e.getRowIds(r),(e=>{T(L,e)||y(e)})),b(!0),h(t),u(t,0,e.addRowListener(r,null,((e,t,n)=>y(n))),e.addTableListener(r,(()=>b())))},R,()=>E(c,R),u,h]})(e,(()=>!0),v),B=t(),G=t(),H=m(),J=(e,t,...n)=>l(n,(n=>j(x(x(H,t,m),e,F),n))),K=e=>l([G,B],(t=>t.delTable(e))),N=(e,t,n)=>J(t,e,t.addWillFinishTransactionListener(n.startTransaction),t.addDidFinishTransactionListener((()=>n.finishTransaction()))),P={setQueryDefinition:(t,n,s)=>{h(t,n),K(t);const r=[],a=[[null,[n,null,null,[],m()]]],c=[],w=[],R=[];s({select:(e,t)=>{const n=L(e)?[i(r)+"",e]:[g(t)?e:t,n=>n(e,t)];return u(r,n),{as:e=>n[0]=e}},join:(e,t,n)=>{const s=g(n)||L(t)?null:t,r=g(s)?t:n,o=[e,[e,s,L(r)?r:e=>e(r),[],m()]];return u(a,o),{as:e=>o[0]=e}},where:(e,t,n)=>u(c,L(e)?e:g(n)?n=>n(e)===t:s=>s(e,t)===n),group:(e,t,n,s,r)=>{const o=[e,[e,L(t)?[t,n,s,r]:Q(k,t)??[(e,t)=>t]]];return u(w,o),{as:e=>o[0]=e}},having:(e,t)=>u(R,L(e)?e:n=>n(e)===t)});const v=m(r);if(b(v))return P;const I=m(a);E(I,((e,[,t])=>f(Q(I,t),(({3:t})=>g(e)?0:u(t,e)))));const W=m(w);let O=B;if(b(W)&&d(R))O=G;else{N(t,O,G);const e=m();E(W,((t,[n,s])=>j(x(e,n,F),[t,s])));const n=F();E(v,(t=>T(e,t)?0:j(n,t)));const s=m(),r=(n,s,r,l)=>f(n,(([n,a,i,d])=>{E(s,((t,[s])=>{const o=x(n,t,m),a=Q(o,r),i=l?void 0:s;if(a!==i){const n=F([[a,i]]),s=y(o);M(o,r,i),p(Q(e,t),(([e,t])=>{const r=((e,t,n,s,r,o=!1)=>{if(b(n))return;const[l,a,i,d]=r;return o||=g(e),p(s,(([n,s])=>{o||(e=g(n)?a?.(e,s,t++):g(s)?i?.(e,n,t--):d?.(e,s,n,t),o||=g(e))})),o?l(C(n),y(n)):e})(d[e],s,o,n,t);d[e]=g(z(r))?null:r}))}})),(b(a)||!o(R,(e=>e((e=>d[e]))))?G.delRow:G.setRow)(t,i,d)}));J(O,t,O.addRowListener(t,null,((o,l,a,i)=>{const d=[],c=[],h=m(),w=O.hasRow(t,a);let R=!w;p(n,(e=>{const[n,s,r]=i(t,a,e);u(d,s),u(c,r),R||=n})),E(e,(e=>{const[n,,s]=i(t,a,e);(R||n)&&M(h,e,[s])})),R&&r(D(s,d,void 0,(([,e,n])=>{if(S(e,a),b(e))return G.delRow(t,n),1})),h,a,1),w&&r(D(s,c,(()=>{const e={};return p(n,(n=>e[n]=O.getCell(t,a,n))),[m(),F(),G.addRow(t,e,1),e]}),(([,e])=>{j(e,a)})),h,a)})))}N(t,e,O);const H=s=>{const r=(t,r)=>e.getCell(...g(r)?[n,s,t]:t===n?[n,s,r]:[Q(I,t)?.[0],Q(Q(I,t)?.[4],s)?.[0],r]);O.transaction((()=>o(c,(e=>e(r)))?E(v,((e,n)=>((e,t,n,s,r)=>g(r)?e.delCell(t,n,s,!0):e.setCell(t,n,s,r))(O,t,s,e,n(r,s)))):O.delRow(t,s)))},U=(n,s,r,o)=>{const a=t=>e.getCell(s,r,t);l(o,(s=>{const[r,,o,l,i]=Q(I,s),d=o?.(a,n),[c,u]=Q(i,n)??[];d!=c&&(g(u)||A(t,u),M(i,n,g(d)?null:[d,...q(t,1,e.addRowListener(r,d,(()=>U(n,r,d,l))))]))})),H(n)},{3:V}=Q(I,null);return O.transaction((()=>q(t,1,e.addRowListener(n,null,((s,r,o)=>{e.hasRow(n,o)?U(o,n,o,V):(O.delRow(t,o),p(I,(({4:e})=>f(Q(e,o),(([,n])=>{A(t,n),M(e,o)})))))}))))),P},delQueryDefinition:e=>(
|
|
1
|
+
const e=e=>typeof e,t=e(""),n=e(!0),s=e(0),r=e(e),o=(e,t)=>e.every(t),l=(e,t)=>e.forEach(t),a=e=>c(e,((e,t)=>e+t),0),i=e=>e.length,d=e=>0==i(e),c=(e,t,n)=>e.reduce(t,n),u=(e,...t)=>e.push(...t),h=Math.max,w=Math.min,R=isFinite,g=e=>null==e,f=(e,t,n)=>g(e)?n?.():t(e),L=t=>e(t)==r,v=()=>{},y=e=>e.size,T=(e,t)=>e?.has(t)??!1,b=e=>g(e)||0==y(e),C=e=>[...e?.values()??[]],I=e=>e.clear(),p=(e,t)=>e?.forEach(t),S=(e,t)=>e?.delete(t),m=e=>new Map(e),Q=(e,t)=>e?.get(t),E=(e,t)=>p(e,((e,n)=>t(n,e))),M=(e,t,n)=>g(n)?(S(e,t),e):e?.set(t,n),x=(e,t,n)=>(T(e,t)||M(e,t,n()),Q(e,t)),D=(e,t,n,s,r=0)=>f((n?x:Q)(e,t[r],r>i(t)-2?n:m),(o=>{if(r>i(t)-2)return s?.(o)&&M(e,t[r]),o;const l=D(o,t,n,s,r+1);return b(o)&&M(e,t[r]),l})),F=e=>new Set(e),j=(e,t)=>e?.add(t),k=m([["avg",[(e,t)=>a(e)/t,(e,t,n)=>e+(t-e)/(n+1),(e,t,n)=>e+(e-t)/(n-1),(e,t,n,s)=>e+(t-n)/s]],["max",[e=>h(...e),(e,t)=>h(t,e),(e,t)=>t==e?void 0:e,(e,t,n)=>n==e?void 0:h(t,e)]],["min",[e=>w(...e),(e,t)=>w(t,e),(e,t)=>t==e?void 0:e,(e,t,n)=>n==e?void 0:w(t,e)]],["sum",[e=>a(e),(e,t)=>e+t,(e,t)=>e-t,(e,t,n)=>e-n+t]]]),z=r=>{const o=e(r);return(e=>e==t||e==n)(o)||o==s&&R(r)?o:void 0},W=Object,O=W.freeze,q=(e=>{const t=new WeakMap;return n=>(t.has(n)||t.set(n,e(n)),t.get(n))})((e=>{const t=e.createStore,[n,s,r,a,c,,,h,,w,R,q,A]=((e,t,n)=>{const s=e.hasRow,r=m(),o=m(),a=m(),i=m(),c=m(),u=(t,n,...s)=>{const r=x(c,t,F);return l(s,(t=>j(r,t)&&n&&e.callListener(t))),s},h=(t,...n)=>f(Q(c,t),(s=>{l(d(n)?C(s):n,(t=>{e.delListener(t),S(s,t)})),b(s)&&M(c,t)})),w=(e,n)=>{M(r,e,n),T(o,e)||(M(o,e,t()),M(a,e,m()),M(i,e,m()))},R=e=>{M(r,e),M(o,e),M(a,e),M(i,e),h(e)};return[()=>e,()=>[...r?.keys()??[]],e=>E(o,e),e=>T(o,e),e=>Q(r,e),e=>Q(o,e),(e,t)=>M(o,e,t),w,(t,r,o,d,c)=>{w(t,r);const R=m(),f=m(),L=Q(a,t),v=Q(i,t),y=t=>{const o=n=>e.getCell(r,t,n),l=Q(L,t),a=s(r,t)?n(d(o,t)):void 0;if(l!=a&&M(R,t,[l,a]),!g(c)){const e=Q(v,t),n=s(r,t)?c(o,t):void 0;e!=n&&M(f,t,n)}},b=e=>{o((()=>{p(R,(([,e],t)=>M(L,t,e))),p(f,((e,t)=>M(v,t,e)))}),R,f,L,v,e),I(R),I(f)};E(L,y),e.hasTable(r)&&l(e.getRowIds(r),(e=>{T(L,e)||y(e)})),b(!0),h(t),u(t,0,e.addRowListener(r,null,((e,t,n)=>y(n))),e.addTableListener(r,(()=>b())))},R,()=>E(c,R),u,h]})(e,(()=>!0),v),B=t(),G=t(),H=m(),J=(e,t,...n)=>l(n,(n=>j(x(x(H,t,m),e,F),n))),K=e=>{E(Q(H,e),((e,t)=>p(t,(t=>e.delListener(t))))),l([G,B],(t=>t.delTable(e)))},N=(e,t,n)=>J(t,e,t.addWillFinishTransactionListener(n.startTransaction),t.addDidFinishTransactionListener((()=>n.finishTransaction()))),P={setQueryDefinition:(t,n,s)=>{h(t,n),K(t);const r=[],a=[[null,[n,null,null,[],m()]]],c=[],w=[],R=[];s({select:(e,t)=>{const n=L(e)?[i(r)+"",e]:[g(t)?e:t,n=>n(e,t)];return u(r,n),{as:e=>n[0]=e}},join:(e,t,n)=>{const s=g(n)||L(t)?null:t,r=g(s)?t:n,o=[e,[e,s,L(r)?r:e=>e(r),[],m()]];return u(a,o),{as:e=>o[0]=e}},where:(e,t,n)=>u(c,L(e)?e:g(n)?n=>n(e)===t:s=>s(e,t)===n),group:(e,t,n,s,r)=>{const o=[e,[e,L(t)?[t,n,s,r]:Q(k,t)??[(e,t)=>t]]];return u(w,o),{as:e=>o[0]=e}},having:(e,t)=>u(R,L(e)?e:n=>n(e)===t)});const v=m(r);if(b(v))return P;const I=m(a);E(I,((e,[,t])=>f(Q(I,t),(({3:t})=>g(e)?0:u(t,e)))));const W=m(w);let O=B;if(b(W)&&d(R))O=G;else{N(t,O,G);const e=m();E(W,((t,[n,s])=>j(x(e,n,F),[t,s])));const n=F();E(v,(t=>T(e,t)?0:j(n,t)));const s=m(),r=(n,s,r,l)=>f(n,(([n,a,i,d])=>{E(s,((t,[s])=>{const o=x(n,t,m),a=Q(o,r),i=l?void 0:s;if(a!==i){const n=F([[a,i]]),s=y(o);M(o,r,i),p(Q(e,t),(([e,t])=>{const r=((e,t,n,s,r,o=!1)=>{if(b(n))return;const[l,a,i,d]=r;return o||=g(e),p(s,(([n,s])=>{o||(e=g(n)?a?.(e,s,t++):g(s)?i?.(e,n,t--):d?.(e,s,n,t),o||=g(e))})),o?l(C(n),y(n)):e})(d[e],s,o,n,t);d[e]=g(z(r))?null:r}))}})),(b(a)||!o(R,(e=>e((e=>d[e]))))?G.delRow:G.setRow)(t,i,d)}));J(O,t,O.addRowListener(t,null,((o,l,a,i)=>{const d=[],c=[],h=m(),w=O.hasRow(t,a);let R=!w;p(n,(e=>{const[n,s,r]=i(t,a,e);u(d,s),u(c,r),R||=n})),E(e,(e=>{const[n,,s]=i(t,a,e);(R||n)&&M(h,e,[s])})),R&&r(D(s,d,void 0,(([,e,n])=>{if(S(e,a),b(e))return G.delRow(t,n),1})),h,a,1),w&&r(D(s,c,(()=>{const e={};return p(n,(n=>e[n]=O.getCell(t,a,n))),[m(),F(),G.addRow(t,e,1),e]}),(([,e])=>{j(e,a)})),h,a)})))}N(t,e,O);const H=s=>{const r=(t,r)=>e.getCell(...g(r)?[n,s,t]:t===n?[n,s,r]:[Q(I,t)?.[0],Q(Q(I,t)?.[4],s)?.[0],r]);O.transaction((()=>o(c,(e=>e(r)))?E(v,((e,n)=>((e,t,n,s,r)=>g(r)?e.delCell(t,n,s,!0):e.setCell(t,n,s,r))(O,t,s,e,n(r,s)))):O.delRow(t,s)))},U=(n,s,r,o)=>{const a=t=>e.getCell(s,r,t);l(o,(s=>{const[r,,o,l,i]=Q(I,s),d=o?.(a,n),[c,u]=Q(i,n)??[];d!=c&&(g(u)||A(t,u),M(i,n,g(d)?null:[d,...q(t,1,e.addRowListener(r,d,(()=>U(n,r,d,l))))]))})),H(n)},{3:V}=Q(I,null);return O.transaction((()=>q(t,1,e.addRowListener(n,null,((s,r,o)=>{e.hasRow(n,o)?U(o,n,o,V):(O.delRow(t,o),p(I,(({4:e})=>f(Q(e,o),(([,n])=>{A(t,n),M(e,o)})))))}))))),P},delQueryDefinition:e=>(K(e),w(e),P),getStore:n,getQueryIds:s,forEachQuery:r,hasQuery:a,getTableId:c,delListener:e=>(G.delListener(e),P),destroy:R,getListenerStats:()=>{const{tables:e,tableIds:t,transaction:n,...s}=G.getListenerStats();return s}};var U,V;return U={Table:[1,1],RowIds:[0,1],SortedRowIds:[0,5],Row:[1,2],CellIds:[0,2],Cell:[1,3]},V=([e,t],n)=>{l(e?["get","has","forEach"]:["get"],(e=>P[e+"Result"+n]=(...t)=>G[e+n](...t))),P["addResult"+n+"Listener"]=(...e)=>{return G["add"+n+"Listener"](...(s=e,r=0,o=t,s.slice(r,o)),((n,...s)=>e[t](P,...s)));var s,r,o}},l(W.entries(U),(([e,t])=>V(t,e))),O(P)}));export{q as createQueries};
|
package/lib/queries.js.gz
CHANGED
|
Binary file
|
package/lib/relationships.d.ts
CHANGED
|
@@ -244,7 +244,7 @@ export type RelationshipsListenerStats = {
|
|
|
244
244
|
* relationships.destroy();
|
|
245
245
|
* ```
|
|
246
246
|
* @see Relationships And Checkpoints guides
|
|
247
|
-
* @see
|
|
247
|
+
* @see Drawing demo
|
|
248
248
|
* @category Relationships
|
|
249
249
|
*/
|
|
250
250
|
export interface Relationships {
|