tinybase 4.2.0 → 4.2.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.
Files changed (56) hide show
  1. package/lib/cjs/store.cjs +1 -1
  2. package/lib/cjs/store.cjs.gz +0 -0
  3. package/lib/cjs/tinybase.cjs +1 -1
  4. package/lib/cjs/tinybase.cjs.gz +0 -0
  5. package/lib/cjs/ui-react-dom-debug.cjs +1 -1
  6. package/lib/cjs/ui-react-dom-debug.cjs.gz +0 -0
  7. package/lib/cjs/ui-react.cjs +1 -1
  8. package/lib/cjs/ui-react.cjs.gz +0 -0
  9. package/lib/cjs-es6/store.cjs +1 -1
  10. package/lib/cjs-es6/store.cjs.gz +0 -0
  11. package/lib/cjs-es6/tinybase.cjs +1 -1
  12. package/lib/cjs-es6/tinybase.cjs.gz +0 -0
  13. package/lib/cjs-es6/ui-react-dom-debug.cjs +1 -1
  14. package/lib/cjs-es6/ui-react-dom-debug.cjs.gz +0 -0
  15. package/lib/cjs-es6/ui-react.cjs +1 -1
  16. package/lib/cjs-es6/ui-react.cjs.gz +0 -0
  17. package/lib/debug/store.js +10 -10
  18. package/lib/debug/tinybase.js +10 -10
  19. package/lib/debug/ui-react-dom.js +10 -10
  20. package/lib/debug/ui-react.js +37 -0
  21. package/lib/es6/store.js +1 -1
  22. package/lib/es6/store.js.gz +0 -0
  23. package/lib/es6/tinybase.js +1 -1
  24. package/lib/es6/tinybase.js.gz +0 -0
  25. package/lib/es6/ui-react-dom-debug.js +1 -1
  26. package/lib/es6/ui-react-dom-debug.js.gz +0 -0
  27. package/lib/es6/ui-react.js +1 -1
  28. package/lib/es6/ui-react.js.gz +0 -0
  29. package/lib/store.js +1 -1
  30. package/lib/store.js.gz +0 -0
  31. package/lib/tinybase.js +1 -1
  32. package/lib/tinybase.js.gz +0 -0
  33. package/lib/types/store.d.ts +6 -0
  34. package/lib/types/ui-react.d.ts +175 -0
  35. package/lib/types/with-schemas/store.d.ts +6 -0
  36. package/lib/types/with-schemas/ui-react.d.ts +205 -0
  37. package/lib/ui-react.js +1 -1
  38. package/lib/ui-react.js.gz +0 -0
  39. package/lib/umd/store.js +1 -1
  40. package/lib/umd/store.js.gz +0 -0
  41. package/lib/umd/tinybase.js +1 -1
  42. package/lib/umd/tinybase.js.gz +0 -0
  43. package/lib/umd/ui-react-dom-debug.js +1 -1
  44. package/lib/umd/ui-react-dom-debug.js.gz +0 -0
  45. package/lib/umd/ui-react.js +1 -1
  46. package/lib/umd/ui-react.js.gz +0 -0
  47. package/lib/umd-es6/store.js +1 -1
  48. package/lib/umd-es6/store.js.gz +0 -0
  49. package/lib/umd-es6/tinybase.js +1 -1
  50. package/lib/umd-es6/tinybase.js.gz +0 -0
  51. package/lib/umd-es6/ui-react-dom-debug.js +1 -1
  52. package/lib/umd-es6/ui-react-dom-debug.js.gz +0 -0
  53. package/lib/umd-es6/ui-react.js +1 -1
  54. package/lib/umd-es6/ui-react.js.gz +0 -0
  55. package/package.json +11 -10
  56. package/readme.md +1 -1
@@ -5619,6 +5619,8 @@ export interface Store {
5619
5619
  * Note that a TransactionListener added to the Store with this method can
5620
5620
  * mutate the Store, and its changes will be treated as part of the
5621
5621
  * transaction that is starting.
5622
+ * @param listener The function that will be called at the start of a
5623
+ * transaction.
5622
5624
  * @returns A unique Id for the listener that can later be used to remove it.
5623
5625
  * @example
5624
5626
  * This example registers a listener that is called at start end of the
@@ -5675,6 +5677,8 @@ export interface Store {
5675
5677
  * mutate the Store itself, and its changes will be treated as part of the
5676
5678
  * transaction that is starting (and may fire non-mutating listeners after
5677
5679
  * this).
5680
+ * @param listener The function that will be called before the end of a
5681
+ * transaction.
5678
5682
  * @returns A unique Id for the listener that can later be used to remove it.
5679
5683
  * @example
5680
5684
  * This example registers a listener that is called at the end of the
@@ -5771,6 +5775,8 @@ export interface Store {
5771
5775
  *
5772
5776
  * Note that a TransactionListener added to the Store with this method
5773
5777
  * _cannot_ mutate the Store itself, and attempts to do so will fail silently.
5778
+ * @param listener The function that will be called after the end of a
5779
+ * transaction.
5774
5780
  * @returns A unique Id for the listener that can later be used to remove it.
5775
5781
  * @example
5776
5782
  * This example registers a listener that is called at the end of the
@@ -42,6 +42,7 @@ import {
42
42
  TableListener,
43
43
  Tables,
44
44
  TablesListener,
45
+ TransactionListener,
45
46
  Value,
46
47
  ValueIdsListener,
47
48
  ValueListener,
@@ -3621,6 +3622,180 @@ export function useValueListener(
3621
3622
  storeOrStoreId?: StoreOrStoreId,
3622
3623
  ): void;
3623
3624
 
3625
+ /**
3626
+ * The useStartTransactionListener hook registers a listener function with the
3627
+ * Store that will be called at the start of a transaction.
3628
+ *
3629
+ * Unlike the addStartTransactionListener method, which returns a listener Id
3630
+ * and requires you to remove it manually, the useStartTransactionListener hook
3631
+ * manages this lifecycle for you: when the listener changes (per its
3632
+ * `listenerDeps` dependencies) or the component unmounts, the listener on the
3633
+ * underlying Store will be deleted.
3634
+ * @param listener The function that will be called at the start of a
3635
+ * transaction.
3636
+ * @param listenerDeps An optional array of dependencies for the `listener`
3637
+ * function, which, if any change, result in the re-registration of the
3638
+ * listener. This parameter defaults to an empty array.
3639
+ * @param storeOrStoreId The Store to register the listener with: omit for the
3640
+ * default context Store, provide an Id for a named context Store, or provide an
3641
+ * explicit reference.
3642
+ * @example
3643
+ * This example uses the useStartTransactionListener hook to create a listener
3644
+ * that is scoped to a single component. When the component is unmounted, the
3645
+ * listener is removed from the Store.
3646
+ *
3647
+ * ```jsx
3648
+ * const App = ({store}) => (
3649
+ * <Provider store={store}>
3650
+ * <Pane />
3651
+ * </Provider>
3652
+ * );
3653
+ * const Pane = () => {
3654
+ * useStartTransactionListener(() => console.log('Start transaction'));
3655
+ * return <span>App</span>;
3656
+ * };
3657
+ *
3658
+ * const store = createStore();
3659
+ * const app = document.createElement('div');
3660
+ * const root = ReactDOMClient.createRoot(app);
3661
+ * root.render(<App store={store} />); // !act
3662
+ * console.log(store.getListenerStats().transaction);
3663
+ * // -> 1
3664
+ *
3665
+ * store.setValue('open', false); // !act
3666
+ * // -> 'Start transaction'
3667
+ *
3668
+ * root.unmount(); // !act
3669
+ * console.log(store.getListenerStats().transaction);
3670
+ * // -> 0
3671
+ * ```
3672
+ * @category Store hooks
3673
+ * @since v4.2.2
3674
+ */
3675
+ export function useStartTransactionListener(
3676
+ listener: TransactionListener,
3677
+ listenerDeps?: React.DependencyList,
3678
+ storeOrStoreId?: StoreOrStoreId,
3679
+ ): void;
3680
+
3681
+ /**
3682
+ * The useWillFinishTransactionListener hook registers a listener function with
3683
+ * a Store that will be called just before other non-mutating listeners are
3684
+ * called at the end of the transaction.
3685
+ *
3686
+ * Unlike the addWillFinisTransactionListener method, which returns a listener
3687
+ * Id and requires you to remove it manually, the
3688
+ * useWillFinishTransactionListener hook manages this lifecycle for you: when
3689
+ * the listener changes (per its `listenerDeps` dependencies) or the component
3690
+ * unmounts, the listener on the underlying Store will be deleted.
3691
+ * @param listener The function that will be called before the end of a
3692
+ * transaction.
3693
+ * @param listenerDeps An optional array of dependencies for the `listener`
3694
+ * function, which, if any change, result in the re-registration of the
3695
+ * listener. This parameter defaults to an empty array.
3696
+ * @param storeOrStoreId The Store to register the listener with: omit for the
3697
+ * default context Store, provide an Id for a named context Store, or provide an
3698
+ * explicit reference.
3699
+ * @example
3700
+ * This example uses the useWillFinishTransactionListener hook to create a
3701
+ * listener that is scoped to a single component. When the component is
3702
+ * unmounted, the listener is removed from the Store.
3703
+ *
3704
+ * ```jsx
3705
+ * const App = ({store}) => (
3706
+ * <Provider store={store}>
3707
+ * <Pane />
3708
+ * </Provider>
3709
+ * );
3710
+ * const Pane = () => {
3711
+ * useWillFinishTransactionListener(
3712
+ * () => console.log('Will finish transaction'),
3713
+ * );
3714
+ * return <span>App</span>;
3715
+ * };
3716
+ *
3717
+ * const store = createStore();
3718
+ * const app = document.createElement('div');
3719
+ * const root = ReactDOMClient.createRoot(app);
3720
+ * root.render(<App store={store} />); // !act
3721
+ * console.log(store.getListenerStats().transaction);
3722
+ * // -> 1
3723
+ *
3724
+ * store.setValue('open', false); // !act
3725
+ * // -> 'Will finish transaction'
3726
+ *
3727
+ * root.unmount(); // !act
3728
+ * console.log(store.getListenerStats().transaction);
3729
+ * // -> 0
3730
+ * ```
3731
+ * @category Store hooks
3732
+ * @since v4.2.2
3733
+ */
3734
+ export function useWillFinishTransactionListener(
3735
+ listener: TransactionListener,
3736
+ listenerDeps?: React.DependencyList,
3737
+ storeOrStoreId?: StoreOrStoreId,
3738
+ ): void;
3739
+
3740
+ /**
3741
+ * The useDidFinishTransactionListener hook registers a listener function with a
3742
+ * Store that will be called just after other non-mutating listeners are called
3743
+ * at the end of the transaction.
3744
+ *
3745
+ * Unlike the addDidFinishTransactionListener method, which returns a listener
3746
+ * Id and requires you to remove it manually, the
3747
+ * useDidFinishTransactionListener hook manages this lifecycle for you: when the
3748
+ * listener changes (per its `listenerDeps` dependencies) or the component
3749
+ * unmounts, the listener on the underlying Store will be deleted.
3750
+ * @param listener The function that will be called after the end of a
3751
+ * transaction.
3752
+ * @param listenerDeps An optional array of dependencies for the `listener`
3753
+ * function, which, if any change, result in the re-registration of the
3754
+ * listener. This parameter defaults to an empty array.
3755
+ * @param storeOrStoreId The Store to register the listener with: omit for the
3756
+ * default context Store, provide an Id for a named context Store, or provide an
3757
+ * explicit reference.
3758
+ * @example
3759
+ * This example uses the useDidFinishTransactionListener hook to create a
3760
+ * listener that is scoped to a single component. When the component is
3761
+ * unmounted, the listener is removed from the Store.
3762
+ *
3763
+ * ```jsx
3764
+ * const App = ({store}) => (
3765
+ * <Provider store={store}>
3766
+ * <Pane />
3767
+ * </Provider>
3768
+ * );
3769
+ * const Pane = () => {
3770
+ * useDidFinishTransactionListener(
3771
+ * () => console.log('Did finish transaction'),
3772
+ * );
3773
+ * return <span>App</span>;
3774
+ * };
3775
+ *
3776
+ * const store = createStore();
3777
+ * const app = document.createElement('div');
3778
+ * const root = ReactDOMClient.createRoot(app);
3779
+ * root.render(<App store={store} />); // !act
3780
+ * console.log(store.getListenerStats().transaction);
3781
+ * // -> 1
3782
+ *
3783
+ * store.setValue('open', false); // !act
3784
+ * // -> 'Did finish transaction'
3785
+ *
3786
+ * root.unmount(); // !act
3787
+ * console.log(store.getListenerStats().transaction);
3788
+ * // -> 0
3789
+ * ```
3790
+ * @category Store hooks
3791
+ * @since v4.2.2
3792
+ */
3793
+ export function useDidFinishTransactionListener(
3794
+ listener: TransactionListener,
3795
+ listenerDeps?: React.DependencyList,
3796
+ storeOrStoreId?: StoreOrStoreId,
3797
+ ): void;
3798
+
3624
3799
  /**
3625
3800
  * The useCreateMetrics hook is used to create a Metrics object within a React
3626
3801
  * application with convenient memoization.
@@ -6949,6 +6949,8 @@ export interface Store<in out Schemas extends OptionalSchemas> {
6949
6949
  * Note that a TransactionListener added to the Store with this method can
6950
6950
  * mutate the Store, and its changes will be treated as part of the
6951
6951
  * transaction that is starting.
6952
+ * @param listener The function that will be called at the start of a
6953
+ * transaction.
6952
6954
  * @returns A unique Id for the listener that can later be used to remove it.
6953
6955
  * @example
6954
6956
  * This example registers a listener that is called at start end of the
@@ -7011,6 +7013,8 @@ export interface Store<in out Schemas extends OptionalSchemas> {
7011
7013
  * mutate the Store itself, and its changes will be treated as part of the
7012
7014
  * transaction that is starting (and may fire non-mutating listeners after
7013
7015
  * this).
7016
+ * @param listener The function that will be called before the end of a
7017
+ * transaction.
7014
7018
  * @returns A unique Id for the listener that can later be used to remove it.
7015
7019
  * @example
7016
7020
  * This example registers a listener that is called at the end of the
@@ -7113,6 +7117,8 @@ export interface Store<in out Schemas extends OptionalSchemas> {
7113
7117
  *
7114
7118
  * Note that a TransactionListener added to the Store with this method
7115
7119
  * _cannot_ mutate the Store itself, and attempts to do so will fail silently.
7120
+ * @param listener The function that will be called after the end of a
7121
+ * transaction.
7116
7122
  * @returns A unique Id for the listener that can later be used to remove it.
7117
7123
  * @example
7118
7124
  * This example registers a listener that is called at the end of the
@@ -84,6 +84,7 @@ import {
84
84
  TableListener,
85
85
  Tables,
86
86
  TablesListener,
87
+ TransactionListener,
87
88
  Value,
88
89
  ValueIdsListener,
89
90
  ValueListener,
@@ -4286,6 +4287,210 @@ export type WithSchemas<Schemas extends OptionalSchemas> = {
4286
4287
  storeOrStoreId?: StoreOrStoreId<Schemas>,
4287
4288
  ) => void;
4288
4289
 
4290
+ /**
4291
+ * The useStartTransactionListener hook registers a listener function with the
4292
+ * Store that will be called at the start of a transaction.
4293
+ *
4294
+ * This has schema-based typing. The following is a simplified representation:
4295
+ *
4296
+ * ```ts override
4297
+ * useStartTransactionListener(
4298
+ * listener: TransactionListener,
4299
+ * listenerDeps?: React.DependencyList,
4300
+ * storeOrStoreId?: StoreOrStoreId,
4301
+ * ): void;
4302
+ * ```
4303
+ *
4304
+ * Unlike the addStartTransactionListener method, which returns a listener Id
4305
+ * and requires you to remove it manually, the useStartTransactionListener hook
4306
+ * manages this lifecycle for you: when the listener changes (per its
4307
+ * `listenerDeps` dependencies) or the component unmounts, the listener on the
4308
+ * underlying Store will be deleted.
4309
+ * @param listener The function that will be called at the start of a
4310
+ * transaction.
4311
+ * @param listenerDeps An optional array of dependencies for the `listener`
4312
+ * function, which, if any change, result in the re-registration of the
4313
+ * listener. This parameter defaults to an empty array.
4314
+ * @param storeOrStoreId The Store to register the listener with: omit for the
4315
+ * default context Store, provide an Id for a named context Store, or provide an
4316
+ * explicit reference.
4317
+ * @example
4318
+ * This example uses the useStartTransactionListener hook to create a listener
4319
+ * that is scoped to a single component. When the component is unmounted, the
4320
+ * listener is removed from the Store.
4321
+ *
4322
+ * ```jsx
4323
+ * const App = ({store}) => (
4324
+ * <Provider store={store}>
4325
+ * <Pane />
4326
+ * </Provider>
4327
+ * );
4328
+ * const Pane = () => {
4329
+ * useStartTransactionListener(() => console.log('Start transaction'));
4330
+ * return <span>App</span>;
4331
+ * };
4332
+ *
4333
+ * const store = createStore();
4334
+ * const app = document.createElement('div');
4335
+ * const root = ReactDOMClient.createRoot(app);
4336
+ * root.render(<App store={store} />); // !act
4337
+ * console.log(store.getListenerStats().transaction);
4338
+ * // -> 1
4339
+ *
4340
+ * store.setValue('open', false); // !act
4341
+ * // -> 'Start transaction'
4342
+ *
4343
+ * root.unmount(); // !act
4344
+ * console.log(store.getListenerStats().transaction);
4345
+ * // -> 0
4346
+ * ```
4347
+ * @category Store hooks
4348
+ * @since v4.2.2
4349
+ */
4350
+ useStartTransactionListener: (
4351
+ listener: TransactionListener<Schemas>,
4352
+ listenerDeps?: React.DependencyList,
4353
+ storeOrStoreId?: StoreOrStoreId<Schemas>,
4354
+ ) => void;
4355
+
4356
+ /**
4357
+ * The useWillFinishTransactionListener hook registers a listener function with
4358
+ * a Store that will be called just before other non-mutating listeners are
4359
+ * called at the end of the transaction.
4360
+ *
4361
+ * This has schema-based typing. The following is a simplified representation:
4362
+ *
4363
+ * ```ts override
4364
+ * useWillFinishTransactionListener(
4365
+ * listener: TransactionListener,
4366
+ * listenerDeps?: React.DependencyList,
4367
+ * storeOrStoreId?: StoreOrStoreId,
4368
+ * ): void;
4369
+ * ```
4370
+ *
4371
+ * Unlike the addWillFinisTransactionListener method, which returns a listener
4372
+ * Id and requires you to remove it manually, the
4373
+ * useWillFinishTransactionListener hook manages this lifecycle for you: when
4374
+ * the listener changes (per its `listenerDeps` dependencies) or the component
4375
+ * unmounts, the listener on the underlying Store will be deleted.
4376
+ * @param listener The function that will be called before the end of a
4377
+ * transaction.
4378
+ * @param listenerDeps An optional array of dependencies for the `listener`
4379
+ * function, which, if any change, result in the re-registration of the
4380
+ * listener. This parameter defaults to an empty array.
4381
+ * @param storeOrStoreId The Store to register the listener with: omit for the
4382
+ * default context Store, provide an Id for a named context Store, or provide an
4383
+ * explicit reference.
4384
+ * @example
4385
+ * This example uses the useWillFinishTransactionListener hook to create a
4386
+ * listener that is scoped to a single component. When the component is
4387
+ * unmounted, the listener is removed from the Store.
4388
+ *
4389
+ * ```jsx
4390
+ * const App = ({store}) => (
4391
+ * <Provider store={store}>
4392
+ * <Pane />
4393
+ * </Provider>
4394
+ * );
4395
+ * const Pane = () => {
4396
+ * useWillFinishTransactionListener(
4397
+ * () => console.log('Will finish transaction'),
4398
+ * );
4399
+ * return <span>App</span>;
4400
+ * };
4401
+ *
4402
+ * const store = createStore();
4403
+ * const app = document.createElement('div');
4404
+ * const root = ReactDOMClient.createRoot(app);
4405
+ * root.render(<App store={store} />); // !act
4406
+ * console.log(store.getListenerStats().transaction);
4407
+ * // -> 1
4408
+ *
4409
+ * store.setValue('open', false); // !act
4410
+ * // -> 'Will finish transaction'
4411
+ *
4412
+ * root.unmount(); // !act
4413
+ * console.log(store.getListenerStats().transaction);
4414
+ * // -> 0
4415
+ * ```
4416
+ * @category Store hooks
4417
+ * @since v4.2.2
4418
+ */
4419
+ useWillFinishTransactionListener: (
4420
+ listener: TransactionListener<Schemas>,
4421
+ listenerDeps?: React.DependencyList,
4422
+ storeOrStoreId?: StoreOrStoreId<Schemas>,
4423
+ ) => void;
4424
+
4425
+ /**
4426
+ * The useDidFinishTransactionListener hook registers a listener function with a
4427
+ * Store that will be called just after other non-mutating listeners are called
4428
+ * at the end of the transaction.
4429
+ *
4430
+ * This has schema-based typing. The following is a simplified representation:
4431
+ *
4432
+ * ```ts override
4433
+ * useDidFinishTransactionListener(
4434
+ * listener: TransactionListener,
4435
+ * listenerDeps?: React.DependencyList,
4436
+ * storeOrStoreId?: StoreOrStoreId,
4437
+ * ): void;
4438
+ * ```
4439
+ *
4440
+ * Unlike the addDidFinishTransactionListener method, which returns a listener
4441
+ * Id and requires you to remove it manually, the
4442
+ * useDidFinishTransactionListener hook manages this lifecycle for you: when the
4443
+ * listener changes (per its `listenerDeps` dependencies) or the component
4444
+ * unmounts, the listener on the underlying Store will be deleted.
4445
+ * @param listener The function that will be called after the end of a
4446
+ * transaction.
4447
+ * @param listenerDeps An optional array of dependencies for the `listener`
4448
+ * function, which, if any change, result in the re-registration of the
4449
+ * listener. This parameter defaults to an empty array.
4450
+ * @param storeOrStoreId The Store to register the listener with: omit for the
4451
+ * default context Store, provide an Id for a named context Store, or provide an
4452
+ * explicit reference.
4453
+ * @example
4454
+ * This example uses the useDidFinishTransactionListener hook to create a
4455
+ * listener that is scoped to a single component. When the component is
4456
+ * unmounted, the listener is removed from the Store.
4457
+ *
4458
+ * ```jsx
4459
+ * const App = ({store}) => (
4460
+ * <Provider store={store}>
4461
+ * <Pane />
4462
+ * </Provider>
4463
+ * );
4464
+ * const Pane = () => {
4465
+ * useDidFinishTransactionListener(
4466
+ * () => console.log('Did finish transaction'),
4467
+ * );
4468
+ * return <span>App</span>;
4469
+ * };
4470
+ *
4471
+ * const store = createStore();
4472
+ * const app = document.createElement('div');
4473
+ * const root = ReactDOMClient.createRoot(app);
4474
+ * root.render(<App store={store} />); // !act
4475
+ * console.log(store.getListenerStats().transaction);
4476
+ * // -> 1
4477
+ *
4478
+ * store.setValue('open', false); // !act
4479
+ * // -> 'Did finish transaction'
4480
+ *
4481
+ * root.unmount(); // !act
4482
+ * console.log(store.getListenerStats().transaction);
4483
+ * // -> 0
4484
+ * ```
4485
+ * @category Store hooks
4486
+ * @since v4.2.2
4487
+ */
4488
+ useDidFinishTransactionListener: (
4489
+ listener: TransactionListener<Schemas>,
4490
+ listenerDeps?: React.DependencyList,
4491
+ storeOrStoreId?: StoreOrStoreId<Schemas>,
4492
+ ) => void;
4493
+
4289
4494
  /**
4290
4495
  * The useCreateMetrics hook is used to create a Metrics object within a React
4291
4496
  * application with convenient memoization.
package/lib/ui-react.js CHANGED
@@ -1 +1 @@
1
- import e,{useContext as t}from"react";const o=e=>typeof e,s="",r=o(s),d="Result",n="Ids",I="Table",u=I+"s",l=I+n,i="Row",c=i+"Count",a=i+n,p="Sorted"+i+n,g="Cell",b=g+n,C="Value",m=C+"s",k=C+n,y=e=>null==e,w=(e,t,o)=>y(e)?o?.():t(e),h=e=>o(e)==r,R=()=>{},v=(e,t)=>e.map(t),q=Object.keys,{createContext:P,useContext:f}=e,x=P([]),S=(e,t)=>{const o=f(x);return y(e)?o[t]:h(e)?((e,t)=>w(e,(e=>e[t])))(o[t+1]??{},e):e},L=(e,t)=>{const o=S(e,t);return y(e)||h(e)?o:e},B=e=>q(f(x)[e]??{}),T=e=>S(e,0),M=e=>L(e,0),E=e=>S(e,2),V=e=>L(e,2),A=e=>S(e,4),F=e=>L(e,4),j=e=>S(e,6),O=e=>L(e,6),Q=e=>S(e,8),z=e=>L(e,8),D=e=>S(e,10),G=e=>L(e,10),{useCallback:H,useEffect:J,useMemo:K,useRef:N,useState:U}=e,W=(e,t,o=[])=>{const s=K((()=>t(e)),[e,...o]);return J((()=>()=>s.destroy()),[s]),s},X=(e,t,o,s=[],r)=>{const[,d]=U(),n=H((()=>t?.["get"+e]?.(...s)??o),[t,...s]),[I]=U(n),u=N(I);return K((()=>u.current=n()),[n]),Y(e,t,((...e)=>{u.current=y(r)?n():e[r],d([])}),[],s),u.current},Y=(e,t,o,s=[],r=[],...d)=>J((()=>{const s=t?.["add"+e+"Listener"]?.(...r,o,...d);return()=>t?.delListener(s)}),[t,...r,...s,...d]),Z=(e,t,o,s=[],r=R,d=[],...n)=>{const I=M(e);return H((e=>w(I,(s=>w(o(e,s),(e=>r(s["set"+t](...n,e),e)))))),[I,t,...s,...d,...n])},$=(e,t,o=R,s=[],...r)=>{const d=M(e);return H((()=>o(d?.["del"+t](...r))),[d,t,...s,...r])},_=(e,t,o)=>{const s=G(e);return H((()=>s?.[t](o)),[s,t,o])},ee=(e,t=[])=>K(e,t),te=()=>B(1),oe=e=>X(u,M(e),{}),se=e=>X(l,M(e),[],[]),re=(e,t)=>X(I,M(t),{},[e]),de=(e,t)=>X(I+b,M(t),[],[e]),ne=(e,t)=>X(c,M(t),[],[e]),Ie=(e,t)=>X(a,M(t),[],[e]),ue=(e,t,o,s=0,r,d)=>X(p,M(d),[],[e,t,o,s,r],6),le=(e,t,o)=>X(i,M(o),{},[e,t]),ie=(e,t,o)=>X(b,M(o),[],[e,t]),ce=(e,t,o,s)=>X(g,M(s),void 0,[e,t,o],4),ae=e=>X(m,M(e),{}),pe=e=>X(k,M(e),[],[]),ge=(e,t)=>X(C,M(t),void 0,[e]),be=(e,t,o,s,r)=>Z(o,u,e,t,s,r),Ce=(e,t,o,s,r,d)=>Z(s,I,t,o,r,d,e),me=(e,t,o,s,r,d,n)=>Z(r,i,o,s,d,n,e,t),ke=(e,t,o=[],s,r=R,d=[],n=!0)=>{const I=M(s);return H((o=>w(I,(s=>w(t(o,s),(t=>r(s.addRow(e,t,n),s,t)))))),[I,e,...o,...d,n])},ye=(e,t,o,s,r,d,n)=>Z(r,"PartialRow",o,s,d,n,e,t),we=(e,t,o,s,r,d,n,I)=>Z(d,g,s,r,n,I,e,t,o),he=(e,t,o,s,r)=>Z(o,m,e,t,s,r),Re=(e,t,o,s,r)=>Z(o,"PartialValues",e,t,s,r),ve=(e,t,o,s,r,d)=>Z(s,C,t,o,r,d,e),qe=(e,t,o)=>$(e,u,t,o),Pe=(e,t,o,s)=>$(t,I,o,s,e),fe=(e,t,o,s,r)=>$(o,i,s,r,e,t),xe=(e,t,o,s,r,d,n)=>$(r,g,d,n,e,t,o,s),Se=(e,t,o)=>$(e,m,t,o),Le=(e,t,o,s)=>$(t,C,o,s,e),Be=(e,t,o,s)=>Y(u,M(s),e,t,[],o),Te=(e,t,o,s)=>Y(l,M(s),e,t,[],o),Me=(e,t,o,s,r)=>Y(I,M(r),t,o,[e],s),Ee=(e,t,o,s,r)=>Y(I+b,M(r),t,o,[e],s),Ve=(e,t,o,s,r)=>Y(c,M(r),t,o,[e],s),Ae=(e,t,o,s,r)=>Y(a,M(r),t,o,[e],s),Fe=(e,t,o,s,r,d,n,I,u)=>Y(p,M(u),d,n,[e,t,o,s,r],I),je=(e,t,o,s,r,d)=>Y(i,M(d),o,s,[e,t],r),Oe=(e,t,o,s,r,d)=>Y(b,M(d),o,s,[e,t],r),Qe=(e,t,o,s,r,d,n)=>Y(g,M(n),s,r,[e,t,o],d),ze=(e,t,o,s)=>Y(m,M(s),e,t,[],o),De=(e,t,o,s)=>Y(k,M(s),e,t,[],o),Ge=(e,t,o,s,r)=>Y(C,M(r),t,o,[e],s),He=(e,t,o)=>W(e,t,o),Je=()=>B(3),Ke=e=>X("MetricIds",V(e),[]),Ne=(e,t)=>X("Metric",V(t),void 0,[e]),Ue=(e,t,o,s)=>Y("Metric",V(s),t,o,[e]),We=(e,t,o)=>W(e,t,o),Xe=()=>B(5),Ye=(e,t)=>X("SliceIds",F(t),[],[e]),Ze=e=>X("IndexIds",F(e),[]),$e=(e,t,o)=>X("Slice"+a,F(o),[],[e,t]),_e=(e,t,o,s)=>Y("SliceIds",F(s),t,o,[e]),et=(e,t,o,s,r)=>Y("Slice"+a,F(r),o,s,[e,t]),tt=(e,t,o)=>W(e,t,o),ot=()=>B(7),st=e=>X("RelationshipIds",O(e),[]),rt=(e,t,o)=>X("RemoteRowId",O(o),void 0,[e,t]),dt=(e,t,o)=>X("Local"+a,O(o),[],[e,t]),nt=(e,t,o)=>X("Linked"+a,O(o),[],[e,t]),It=(e,t,o,s,r)=>Y("RemoteRowId",O(r),o,s,[e,t]),ut=(e,t,o,s,r)=>Y("Local"+a,O(r),o,s,[e,t]),lt=(e,t,o,s,r)=>Y("Linked"+a,O(r),o,s,[e,t]),it=(e,t,o)=>W(e,t,o),ct=()=>B(9),at=e=>X("QueryIds",z(e),[]),pt=(e,t)=>X(d+I,z(t),{},[e]),gt=(e,t)=>X(d+I+b,z(t),[],[e]),bt=(e,t)=>X(d+c,z(t),[],[e]),Ct=(e,t)=>X(d+a,z(t),[],[e]),mt=(e,t,o,s=0,r,n)=>X(d+p,z(n),[],[e,t,o,s,r],6),kt=(e,t,o)=>X(d+i,z(o),{},[e,t]),yt=(e,t,o)=>X(d+b,z(o),[],[e,t]),wt=(e,t,o,s)=>X(d+g,z(s),void 0,[e,t,o]),ht=(e,t,o,s)=>Y(d+I,z(s),t,o,[e]),Rt=(e,t,o,s)=>Y(d+I+b,z(s),t,o,[e]),vt=(e,t,o,s)=>Y(d+c,z(s),t,o,[e]),qt=(e,t,o,s)=>Y(d+a,z(s),t,o,[e]),Pt=(e,t,o,s,r,n,I,u)=>Y(d+p,z(u),n,I,[e,t,o,s,r]),ft=(e,t,o,s,r)=>Y(d+i,z(r),o,s,[e,t]),xt=(e,t,o,s,r)=>Y(d+b,z(r),o,s,[e,t]),St=(e,t,o,s,r,n)=>Y(d+g,z(n),s,r,[e,t,o]),Lt=(e,t,o)=>W(e,t,o),Bt=()=>B(11),Tt=e=>X("CheckpointIds",G(e),[[],void 0,[]]),Mt=(e,t)=>X("Checkpoint",G(t),void 0,[e]),Et=(e=R,t=[],o,s=R,r=[])=>{const d=G(o);return H((t=>w(d,(o=>{const r=e(t);s(o.addCheckpoint(r),o,r)}))),[d,...t,...r])},Vt=e=>_(e,"goBackward"),At=e=>_(e,"goForward"),Ft=(e,t=[],o,s=R,r=[])=>{const d=G(o);return H((t=>w(d,(o=>w(e(t),(e=>s(o.goTo(e),e)))))),[d,...t,...r])},jt=e=>{const t=G(e),[o,r]=Tt(t);return[(d=o,!(0==(e=>e.length)(d))),Vt(t),r,w(r,(e=>t?.getCheckpoint(e)))??s];var d},Ot=e=>{const t=G(e),[,,[o]]=Tt(t);return[!y(o),At(t),o,w(o,(e=>t?.getCheckpoint(e)))??s]},Qt=(e,t,o)=>Y("CheckpointIds",G(o),e,t),zt=(e,t,o,s)=>Y("Checkpoint",G(s),t,o,[e]),Dt=(e,t,o=[],s,r=[])=>{const[,d]=U(),n=K((()=>t(e)),[e,...o]);return J((()=>((async()=>{await(s?.(n)),d(1)})(),()=>{n.destroy()})),[n,...r]),n},{PureComponent:Gt,Fragment:Ht,createElement:Jt,useCallback:Kt,useLayoutEffect:Nt,useRef:Ut,useState:Wt}=e,Xt=(e,...t)=>y(e)?{}:e(...t),Yt=(e,t)=>[e,e?.getStore(),e?.getLocalTableId(t),e?.getRemoteTableId(t)],{useMemo:Zt}=e,$t=({tableId:e,store:t,rowComponent:o=no,getRowComponentProps:s,customCellIds:r,separator:d,debugIds:n},I)=>so(v(I,(d=>Jt(o,{...Xt(s,d),key:d,tableId:e,rowId:d,customCellIds:r,store:t,debugIds:n}))),d,n,e),_t=({queryId:e,queries:t,resultRowComponent:o=yo,getResultRowComponentProps:s,separator:r,debugIds:d},n)=>so(v(n,(r=>Jt(o,{...Xt(s,r),key:r,queryId:e,rowId:r,queries:t,debugIds:d}))),r,d,e),eo=({relationshipId:e,relationships:t,rowComponent:o=no,getRowComponentProps:s,separator:r,debugIds:d},n,I)=>{const[u,l,i]=Yt(O(t),e),c=n(e,I,u);return so(v(c,(e=>Jt(o,{...Xt(s,e),key:e,tableId:i,rowId:e,store:l,debugIds:d}))),r,d,I)},to=e=>({checkpoints:t,checkpointComponent:o=Ro,getCheckpointComponentProps:s,separator:r,debugIds:d})=>{const n=G(t);return so(v(e(Tt(n)),(e=>Jt(o,{...Xt(s,e),key:e,checkpoints:n,checkpointId:e,debugIds:d}))),r)},oo=({store:e,storesById:o,metrics:s,metricsById:r,indexes:d,indexesById:n,relationships:I,relationshipsById:u,queries:l,queriesById:i,checkpoints:c,checkpointsById:a,children:p})=>{const g=t(x);return Jt(x.Provider,{value:Zt((()=>[e??g[0],{...g[1],...o},s??g[2],{...g[3],...r},d??g[4],{...g[5],...n},I??g[6],{...g[7],...u},l??g[8],{...g[9],...i},c??g[10],{...g[11],...a}]),[e,o,s,r,d,n,I,u,l,i,c,a,g])},p)},so=(e,t,o,s)=>{const r=y(t)||!Array.isArray(e)?e:v(e,((e,o)=>o>0?[t,e]:e));return o?[s,":{",r,"}"]:r},ro=({tableId:e,rowId:t,cellId:o,store:r,debugIds:d})=>so(s+(ce(e,t,o,r)??s),void 0,d,o),no=({tableId:e,rowId:t,store:o,cellComponent:s=ro,getCellComponentProps:r,customCellIds:d,separator:n,debugIds:I})=>so(v(((e,t,o,s)=>{const r=ie(t,o,s);return e??r})(d,e,t,o),(d=>Jt(s,{...Xt(r,d),key:d,tableId:e,rowId:t,cellId:d,store:o,debugIds:I}))),n,I,t),Io=e=>$t(e,Ie(e.tableId,e.store)),uo=({cellId:e,descending:t,offset:o,limit:s,...r})=>$t(r,ue(r.tableId,e,t,o,s,r.store)),lo=({store:e,tableComponent:t=Io,getTableComponentProps:o,separator:s,debugIds:r})=>so(v(se(e),(s=>Jt(t,{...Xt(o,s),key:s,tableId:s,store:e,debugIds:r}))),s),io=({valueId:e,store:t,debugIds:o})=>so(s+(ge(e,t)??s),void 0,o,e),co=({store:e,valueComponent:t=io,getValueComponentProps:o,separator:s,debugIds:r})=>so(v(pe(e),(s=>Jt(t,{...Xt(o,s),key:s,valueId:s,store:e,debugIds:r}))),s),ao=({metricId:e,metrics:t,debugIds:o})=>so(Ne(e,t)??s,void 0,o,e),po=({indexId:e,sliceId:t,indexes:o,rowComponent:s=no,getRowComponentProps:r,separator:d,debugIds:n})=>{const[I,u,l]=((e,t)=>[e,e?.getStore(),e?.getTableId(t)])(F(o),e),i=$e(e,t,I);return so(v(i,(e=>Jt(s,{...Xt(r,e),key:e,tableId:l,rowId:e,store:u,debugIds:n}))),d,n,t)},go=({indexId:e,indexes:t,sliceComponent:o=po,getSliceComponentProps:s,separator:r,debugIds:d})=>so(v(Ye(e,t),(r=>Jt(o,{...Xt(s,r),key:r,indexId:e,sliceId:r,indexes:t,debugIds:d}))),r,d,e),bo=({relationshipId:e,localRowId:t,relationships:o,rowComponent:s=no,getRowComponentProps:r,debugIds:d})=>{const[n,I,,u]=Yt(O(o),e),l=rt(e,t,n);return so(y(u)||y(l)?null:Jt(s,{...Xt(r,l),key:l,tableId:u,rowId:l,store:I,debugIds:d}),void 0,d,t)},Co=e=>eo(e,dt,e.remoteRowId),mo=e=>eo(e,nt,e.firstRowId),ko=({queryId:e,rowId:t,cellId:o,queries:r,debugIds:d})=>so(s+(wt(e,t,o,r)??s),void 0,d,o),yo=({queryId:e,rowId:t,queries:o,resultCellComponent:s=ko,getResultCellComponentProps:r,separator:d,debugIds:n})=>so(v(yt(e,t,o),(d=>Jt(s,{...Xt(r,d),key:d,queryId:e,rowId:t,cellId:d,queries:o,debugIds:n}))),d,n,t),wo=e=>_t(e,Ct(e.queryId,e.queries)),ho=({cellId:e,descending:t,offset:o,limit:s,...r})=>_t(r,mt(r.queryId,e,t,o,s,r.queries)),Ro=({checkpoints:e,checkpointId:t,debugIds:o})=>so(Mt(t,e)??s,void 0,o,t),vo=to((e=>e[0])),qo=to((e=>y(e[1])?[]:[e[1]])),Po=to((e=>e[2]));export{vo as BackwardCheckpointsView,ro as CellView,Ro as CheckpointView,qo as CurrentCheckpointView,Po as ForwardCheckpointsView,go as IndexView,mo as LinkedRowsView,Co as LocalRowsView,ao as MetricView,oo as Provider,bo as RemoteRowView,ko as ResultCellView,yo as ResultRowView,ho as ResultSortedTableView,wo as ResultTableView,no as RowView,po as SliceView,uo as SortedTableView,Io as TableView,lo as TablesView,io as ValueView,co as ValuesView,ke as useAddRowCallback,ce as useCell,ie as useCellIds,Oe as useCellIdsListener,Qe as useCellListener,Mt as useCheckpoint,Tt as useCheckpointIds,Qt as useCheckpointIdsListener,zt as useCheckpointListener,D as useCheckpoints,Bt as useCheckpointsIds,G as useCheckpointsOrCheckpointsById,Lt as useCreateCheckpoints,We as useCreateIndexes,He as useCreateMetrics,Dt as useCreatePersister,it as useCreateQueries,tt as useCreateRelationships,ee as useCreateStore,xe as useDelCellCallback,fe as useDelRowCallback,Pe as useDelTableCallback,qe as useDelTablesCallback,Le as useDelValueCallback,Se as useDelValuesCallback,Vt as useGoBackwardCallback,At as useGoForwardCallback,Ft as useGoToCallback,Ze as useIndexIds,A as useIndexes,Xe as useIndexesIds,F as useIndexesOrIndexesById,nt as useLinkedRowIds,lt as useLinkedRowIdsListener,dt as useLocalRowIds,ut as useLocalRowIdsListener,Ne as useMetric,Ke as useMetricIds,Ue as useMetricListener,E as useMetrics,Je as useMetricsIds,V as useMetricsOrMetricsById,Q as useQueries,ct as useQueriesIds,z as useQueriesOrQueriesById,at as useQueryIds,Ot as useRedoInformation,st as useRelationshipIds,j as useRelationships,ot as useRelationshipsIds,O as useRelationshipsOrRelationshipsById,rt as useRemoteRowId,It as useRemoteRowIdListener,wt as useResultCell,yt as useResultCellIds,xt as useResultCellIdsListener,St as useResultCellListener,kt as useResultRow,bt as useResultRowCount,vt as useResultRowCountListener,Ct as useResultRowIds,qt as useResultRowIdsListener,ft as useResultRowListener,mt as useResultSortedRowIds,Pt as useResultSortedRowIdsListener,pt as useResultTable,gt as useResultTableCellIds,Rt as useResultTableCellIdsListener,ht as useResultTableListener,le as useRow,ne as useRowCount,Ve as useRowCountListener,Ie as useRowIds,Ae as useRowIdsListener,je as useRowListener,we as useSetCellCallback,Et as useSetCheckpointCallback,ye as useSetPartialRowCallback,Re as useSetPartialValuesCallback,me as useSetRowCallback,Ce as useSetTableCallback,be as useSetTablesCallback,ve as useSetValueCallback,he as useSetValuesCallback,Ye as useSliceIds,_e as useSliceIdsListener,$e as useSliceRowIds,et as useSliceRowIdsListener,ue as useSortedRowIds,Fe as useSortedRowIdsListener,T as useStore,te as useStoreIds,M as useStoreOrStoreById,re as useTable,de as useTableCellIds,Ee as useTableCellIdsListener,se as useTableIds,Te as useTableIdsListener,Me as useTableListener,oe as useTables,Be as useTablesListener,jt as useUndoInformation,ge as useValue,pe as useValueIds,De as useValueIdsListener,Ge as useValueListener,ae as useValues,ze as useValuesListener};
1
+ import e,{useContext as t}from"react";const o=e=>typeof e,s="",r=o(s),d="Listener",n="Result",I="Ids",i="Table",u=i+"s",l=i+I,c="Row",a=c+"Count",p=c+I,g="Sorted"+c+I,b="Cell",C=b+I,m="Value",k=m+"s",w=m+I,y=e=>null==e,h=(e,t,o)=>y(e)?o?.():t(e),R=e=>o(e)==r,v=()=>{},q=(e,t)=>e.map(t),P=Object.keys,{createContext:f,useContext:x}=e,S=f([]),L=(e,t)=>{const o=x(S);return y(e)?o[t]:R(e)?((e,t)=>h(e,(e=>e[t])))(o[t+1]??{},e):e},B=(e,t)=>{const o=L(e,t);return y(e)||R(e)?o:e},T=e=>P(x(S)[e]??{}),M=e=>L(e,0),F=e=>B(e,0),E=e=>L(e,2),V=e=>B(e,2),A=e=>L(e,4),j=e=>B(e,4),D=e=>L(e,6),O=e=>B(e,6),Q=e=>L(e,8),W=e=>B(e,8),z=e=>L(e,10),G=e=>B(e,10),H=e=>e.toLowerCase();H(d);const J="Transaction";H(J);const{useCallback:K,useEffect:N,useMemo:U,useRef:X,useState:Y}=e,Z=(e,t,o=[])=>{const s=U((()=>t(e)),[e,...o]);return N((()=>()=>s.destroy()),[s]),s},$=(e,t,o,s=[],r)=>{const[,d]=Y(),n=K((()=>t?.["get"+e]?.(...s)??o),[t,...s]),[I]=Y(n),i=X(I);return U((()=>i.current=n()),[n]),_(e,t,((...e)=>{i.current=y(r)?n():e[r],d([])}),[],s),i.current},_=(e,t,o,s=[],r=[],...n)=>N((()=>{const s=t?.["add"+e+d]?.(...r,o,...n);return()=>t?.delListener(s)}),[t,...r,...s,...n]),ee=(e,t,o,s=[],r=v,d=[],...n)=>{const I=F(e);return K((e=>h(I,(s=>h(o(e,s),(e=>r(s["set"+t](...n,e),e)))))),[I,t,...s,...d,...n])},te=(e,t,o=v,s=[],...r)=>{const d=F(e);return K((()=>o(d?.["del"+t](...r))),[d,t,...s,...r])},oe=(e,t,o)=>{const s=G(e);return K((()=>s?.[t](o)),[s,t,o])},se=(e,t=[])=>U(e,t),re=()=>T(1),de=e=>$(u,F(e),{}),ne=e=>$(l,F(e),[],[]),Ie=(e,t)=>$(i,F(t),{},[e]),ie=(e,t)=>$(i+C,F(t),[],[e]),ue=(e,t)=>$(a,F(t),[],[e]),le=(e,t)=>$(p,F(t),[],[e]),ce=(e,t,o,s=0,r,d)=>$(g,F(d),[],[e,t,o,s,r],6),ae=(e,t,o)=>$(c,F(o),{},[e,t]),pe=(e,t,o)=>$(C,F(o),[],[e,t]),ge=(e,t,o,s)=>$(b,F(s),void 0,[e,t,o],4),be=e=>$(k,F(e),{}),Ce=e=>$(w,F(e),[],[]),me=(e,t)=>$(m,F(t),void 0,[e]),ke=(e,t,o,s,r)=>ee(o,u,e,t,s,r),we=(e,t,o,s,r,d)=>ee(s,i,t,o,r,d,e),ye=(e,t,o,s,r,d,n)=>ee(r,c,o,s,d,n,e,t),he=(e,t,o=[],s,r=v,d=[],n=!0)=>{const I=F(s);return K((o=>h(I,(s=>h(t(o,s),(t=>r(s.addRow(e,t,n),s,t)))))),[I,e,...o,...d,n])},Re=(e,t,o,s,r,d,n)=>ee(r,"PartialRow",o,s,d,n,e,t),ve=(e,t,o,s,r,d,n,I)=>ee(d,b,s,r,n,I,e,t,o),qe=(e,t,o,s,r)=>ee(o,k,e,t,s,r),Pe=(e,t,o,s,r)=>ee(o,"PartialValues",e,t,s,r),fe=(e,t,o,s,r,d)=>ee(s,m,t,o,r,d,e),xe=(e,t,o)=>te(e,u,t,o),Se=(e,t,o,s)=>te(t,i,o,s,e),Le=(e,t,o,s,r)=>te(o,c,s,r,e,t),Be=(e,t,o,s,r,d,n)=>te(r,b,d,n,e,t,o,s),Te=(e,t,o)=>te(e,k,t,o),Me=(e,t,o,s)=>te(t,m,o,s,e),Fe=(e,t,o,s)=>_(u,F(s),e,t,[],o),Ee=(e,t,o,s)=>_(l,F(s),e,t,[],o),Ve=(e,t,o,s,r)=>_(i,F(r),t,o,[e],s),Ae=(e,t,o,s,r)=>_(i+C,F(r),t,o,[e],s),je=(e,t,o,s,r)=>_(a,F(r),t,o,[e],s),De=(e,t,o,s,r)=>_(p,F(r),t,o,[e],s),Oe=(e,t,o,s,r,d,n,I,i)=>_(g,F(i),d,n,[e,t,o,s,r],I),Qe=(e,t,o,s,r,d)=>_(c,F(d),o,s,[e,t],r),We=(e,t,o,s,r,d)=>_(C,F(d),o,s,[e,t],r),ze=(e,t,o,s,r,d,n)=>_(b,F(n),s,r,[e,t,o],d),Ge=(e,t,o,s)=>_(k,F(s),e,t,[],o),He=(e,t,o,s)=>_(w,F(s),e,t,[],o),Je=(e,t,o,s,r)=>_(m,F(r),t,o,[e],s),Ke=(e,t,o)=>_("Start"+J,F(o),e,t),Ne=(e,t,o)=>_("WillFinish"+J,F(o),e,t),Ue=(e,t,o)=>_("DidFinish"+J,F(o),e,t),Xe=(e,t,o)=>Z(e,t,o),Ye=()=>T(3),Ze=e=>$("MetricIds",V(e),[]),$e=(e,t)=>$("Metric",V(t),void 0,[e]),_e=(e,t,o,s)=>_("Metric",V(s),t,o,[e]),et=(e,t,o)=>Z(e,t,o),tt=()=>T(5),ot=(e,t)=>$("SliceIds",j(t),[],[e]),st=e=>$("IndexIds",j(e),[]),rt=(e,t,o)=>$("Slice"+p,j(o),[],[e,t]),dt=(e,t,o,s)=>_("SliceIds",j(s),t,o,[e]),nt=(e,t,o,s,r)=>_("Slice"+p,j(r),o,s,[e,t]),It=(e,t,o)=>Z(e,t,o),it=()=>T(7),ut=e=>$("RelationshipIds",O(e),[]),lt=(e,t,o)=>$("RemoteRowId",O(o),void 0,[e,t]),ct=(e,t,o)=>$("Local"+p,O(o),[],[e,t]),at=(e,t,o)=>$("Linked"+p,O(o),[],[e,t]),pt=(e,t,o,s,r)=>_("RemoteRowId",O(r),o,s,[e,t]),gt=(e,t,o,s,r)=>_("Local"+p,O(r),o,s,[e,t]),bt=(e,t,o,s,r)=>_("Linked"+p,O(r),o,s,[e,t]),Ct=(e,t,o)=>Z(e,t,o),mt=()=>T(9),kt=e=>$("QueryIds",W(e),[]),wt=(e,t)=>$(n+i,W(t),{},[e]),yt=(e,t)=>$(n+i+C,W(t),[],[e]),ht=(e,t)=>$(n+a,W(t),[],[e]),Rt=(e,t)=>$(n+p,W(t),[],[e]),vt=(e,t,o,s=0,r,d)=>$(n+g,W(d),[],[e,t,o,s,r],6),qt=(e,t,o)=>$(n+c,W(o),{},[e,t]),Pt=(e,t,o)=>$(n+C,W(o),[],[e,t]),ft=(e,t,o,s)=>$(n+b,W(s),void 0,[e,t,o]),xt=(e,t,o,s)=>_(n+i,W(s),t,o,[e]),St=(e,t,o,s)=>_(n+i+C,W(s),t,o,[e]),Lt=(e,t,o,s)=>_(n+a,W(s),t,o,[e]),Bt=(e,t,o,s)=>_(n+p,W(s),t,o,[e]),Tt=(e,t,o,s,r,d,I,i)=>_(n+g,W(i),d,I,[e,t,o,s,r]),Mt=(e,t,o,s,r)=>_(n+c,W(r),o,s,[e,t]),Ft=(e,t,o,s,r)=>_(n+C,W(r),o,s,[e,t]),Et=(e,t,o,s,r,d)=>_(n+b,W(d),s,r,[e,t,o]),Vt=(e,t,o)=>Z(e,t,o),At=()=>T(11),jt=e=>$("CheckpointIds",G(e),[[],void 0,[]]),Dt=(e,t)=>$("Checkpoint",G(t),void 0,[e]),Ot=(e=v,t=[],o,s=v,r=[])=>{const d=G(o);return K((t=>h(d,(o=>{const r=e(t);s(o.addCheckpoint(r),o,r)}))),[d,...t,...r])},Qt=e=>oe(e,"goBackward"),Wt=e=>oe(e,"goForward"),zt=(e,t=[],o,s=v,r=[])=>{const d=G(o);return K((t=>h(d,(o=>h(e(t),(e=>s(o.goTo(e),e)))))),[d,...t,...r])},Gt=e=>{const t=G(e),[o,r]=jt(t);return[(d=o,!(0==(e=>e.length)(d))),Qt(t),r,h(r,(e=>t?.getCheckpoint(e)))??s];var d},Ht=e=>{const t=G(e),[,,[o]]=jt(t);return[!y(o),Wt(t),o,h(o,(e=>t?.getCheckpoint(e)))??s]},Jt=(e,t,o)=>_("CheckpointIds",G(o),e,t),Kt=(e,t,o,s)=>_("Checkpoint",G(s),t,o,[e]),Nt=(e,t,o=[],s,r=[])=>{const[,d]=Y(),n=U((()=>t(e)),[e,...o]);return N((()=>((async()=>{await(s?.(n)),d(1)})(),()=>{n.destroy()})),[n,...r]),n},{PureComponent:Ut,Fragment:Xt,createElement:Yt,useCallback:Zt,useLayoutEffect:$t,useRef:_t,useState:eo}=e,to=(e,...t)=>y(e)?{}:e(...t),oo=(e,t)=>[e,e?.getStore(),e?.getLocalTableId(t),e?.getRemoteTableId(t)],{useMemo:so}=e,ro=({tableId:e,store:t,rowComponent:o=ao,getRowComponentProps:s,customCellIds:r,separator:d,debugIds:n},I)=>lo(q(I,(d=>Yt(o,{...to(s,d),key:d,tableId:e,rowId:d,customCellIds:r,store:t,debugIds:n}))),d,n,e),no=({queryId:e,queries:t,resultRowComponent:o=Po,getResultRowComponentProps:s,separator:r,debugIds:d},n)=>lo(q(n,(r=>Yt(o,{...to(s,r),key:r,queryId:e,rowId:r,queries:t,debugIds:d}))),r,d,e),Io=({relationshipId:e,relationships:t,rowComponent:o=ao,getRowComponentProps:s,separator:r,debugIds:d},n,I)=>{const[i,u,l]=oo(O(t),e),c=n(e,I,i);return lo(q(c,(e=>Yt(o,{...to(s,e),key:e,tableId:l,rowId:e,store:u,debugIds:d}))),r,d,I)},io=e=>({checkpoints:t,checkpointComponent:o=So,getCheckpointComponentProps:s,separator:r,debugIds:d})=>{const n=G(t);return lo(q(e(jt(n)),(e=>Yt(o,{...to(s,e),key:e,checkpoints:n,checkpointId:e,debugIds:d}))),r)},uo=({store:e,storesById:o,metrics:s,metricsById:r,indexes:d,indexesById:n,relationships:I,relationshipsById:i,queries:u,queriesById:l,checkpoints:c,checkpointsById:a,children:p})=>{const g=t(S);return Yt(S.Provider,{value:so((()=>[e??g[0],{...g[1],...o},s??g[2],{...g[3],...r},d??g[4],{...g[5],...n},I??g[6],{...g[7],...i},u??g[8],{...g[9],...l},c??g[10],{...g[11],...a}]),[e,o,s,r,d,n,I,i,u,l,c,a,g])},p)},lo=(e,t,o,s)=>{const r=y(t)||!Array.isArray(e)?e:q(e,((e,o)=>o>0?[t,e]:e));return o?[s,":{",r,"}"]:r},co=({tableId:e,rowId:t,cellId:o,store:r,debugIds:d})=>lo(s+(ge(e,t,o,r)??s),void 0,d,o),ao=({tableId:e,rowId:t,store:o,cellComponent:s=co,getCellComponentProps:r,customCellIds:d,separator:n,debugIds:I})=>lo(q(((e,t,o,s)=>{const r=pe(t,o,s);return e??r})(d,e,t,o),(d=>Yt(s,{...to(r,d),key:d,tableId:e,rowId:t,cellId:d,store:o,debugIds:I}))),n,I,t),po=e=>ro(e,le(e.tableId,e.store)),go=({cellId:e,descending:t,offset:o,limit:s,...r})=>ro(r,ce(r.tableId,e,t,o,s,r.store)),bo=({store:e,tableComponent:t=po,getTableComponentProps:o,separator:s,debugIds:r})=>lo(q(ne(e),(s=>Yt(t,{...to(o,s),key:s,tableId:s,store:e,debugIds:r}))),s),Co=({valueId:e,store:t,debugIds:o})=>lo(s+(me(e,t)??s),void 0,o,e),mo=({store:e,valueComponent:t=Co,getValueComponentProps:o,separator:s,debugIds:r})=>lo(q(Ce(e),(s=>Yt(t,{...to(o,s),key:s,valueId:s,store:e,debugIds:r}))),s),ko=({metricId:e,metrics:t,debugIds:o})=>lo($e(e,t)??s,void 0,o,e),wo=({indexId:e,sliceId:t,indexes:o,rowComponent:s=ao,getRowComponentProps:r,separator:d,debugIds:n})=>{const[I,i,u]=((e,t)=>[e,e?.getStore(),e?.getTableId(t)])(j(o),e),l=rt(e,t,I);return lo(q(l,(e=>Yt(s,{...to(r,e),key:e,tableId:u,rowId:e,store:i,debugIds:n}))),d,n,t)},yo=({indexId:e,indexes:t,sliceComponent:o=wo,getSliceComponentProps:s,separator:r,debugIds:d})=>lo(q(ot(e,t),(r=>Yt(o,{...to(s,r),key:r,indexId:e,sliceId:r,indexes:t,debugIds:d}))),r,d,e),ho=({relationshipId:e,localRowId:t,relationships:o,rowComponent:s=ao,getRowComponentProps:r,debugIds:d})=>{const[n,I,,i]=oo(O(o),e),u=lt(e,t,n);return lo(y(i)||y(u)?null:Yt(s,{...to(r,u),key:u,tableId:i,rowId:u,store:I,debugIds:d}),void 0,d,t)},Ro=e=>Io(e,ct,e.remoteRowId),vo=e=>Io(e,at,e.firstRowId),qo=({queryId:e,rowId:t,cellId:o,queries:r,debugIds:d})=>lo(s+(ft(e,t,o,r)??s),void 0,d,o),Po=({queryId:e,rowId:t,queries:o,resultCellComponent:s=qo,getResultCellComponentProps:r,separator:d,debugIds:n})=>lo(q(Pt(e,t,o),(d=>Yt(s,{...to(r,d),key:d,queryId:e,rowId:t,cellId:d,queries:o,debugIds:n}))),d,n,t),fo=e=>no(e,Rt(e.queryId,e.queries)),xo=({cellId:e,descending:t,offset:o,limit:s,...r})=>no(r,vt(r.queryId,e,t,o,s,r.queries)),So=({checkpoints:e,checkpointId:t,debugIds:o})=>lo(Dt(t,e)??s,void 0,o,t),Lo=io((e=>e[0])),Bo=io((e=>y(e[1])?[]:[e[1]])),To=io((e=>e[2]));export{Lo as BackwardCheckpointsView,co as CellView,So as CheckpointView,Bo as CurrentCheckpointView,To as ForwardCheckpointsView,yo as IndexView,vo as LinkedRowsView,Ro as LocalRowsView,ko as MetricView,uo as Provider,ho as RemoteRowView,qo as ResultCellView,Po as ResultRowView,xo as ResultSortedTableView,fo as ResultTableView,ao as RowView,wo as SliceView,go as SortedTableView,po as TableView,bo as TablesView,Co as ValueView,mo as ValuesView,he as useAddRowCallback,ge as useCell,pe as useCellIds,We as useCellIdsListener,ze as useCellListener,Dt as useCheckpoint,jt as useCheckpointIds,Jt as useCheckpointIdsListener,Kt as useCheckpointListener,z as useCheckpoints,At as useCheckpointsIds,G as useCheckpointsOrCheckpointsById,Vt as useCreateCheckpoints,et as useCreateIndexes,Xe as useCreateMetrics,Nt as useCreatePersister,Ct as useCreateQueries,It as useCreateRelationships,se as useCreateStore,Be as useDelCellCallback,Le as useDelRowCallback,Se as useDelTableCallback,xe as useDelTablesCallback,Me as useDelValueCallback,Te as useDelValuesCallback,Ue as useDidFinishTransactionListener,Qt as useGoBackwardCallback,Wt as useGoForwardCallback,zt as useGoToCallback,st as useIndexIds,A as useIndexes,tt as useIndexesIds,j as useIndexesOrIndexesById,at as useLinkedRowIds,bt as useLinkedRowIdsListener,ct as useLocalRowIds,gt as useLocalRowIdsListener,$e as useMetric,Ze as useMetricIds,_e as useMetricListener,E as useMetrics,Ye as useMetricsIds,V as useMetricsOrMetricsById,Q as useQueries,mt as useQueriesIds,W as useQueriesOrQueriesById,kt as useQueryIds,Ht as useRedoInformation,ut as useRelationshipIds,D as useRelationships,it as useRelationshipsIds,O as useRelationshipsOrRelationshipsById,lt as useRemoteRowId,pt as useRemoteRowIdListener,ft as useResultCell,Pt as useResultCellIds,Ft as useResultCellIdsListener,Et as useResultCellListener,qt as useResultRow,ht as useResultRowCount,Lt as useResultRowCountListener,Rt as useResultRowIds,Bt as useResultRowIdsListener,Mt as useResultRowListener,vt as useResultSortedRowIds,Tt as useResultSortedRowIdsListener,wt as useResultTable,yt as useResultTableCellIds,St as useResultTableCellIdsListener,xt as useResultTableListener,ae as useRow,ue as useRowCount,je as useRowCountListener,le as useRowIds,De as useRowIdsListener,Qe as useRowListener,ve as useSetCellCallback,Ot as useSetCheckpointCallback,Re as useSetPartialRowCallback,Pe as useSetPartialValuesCallback,ye as useSetRowCallback,we as useSetTableCallback,ke as useSetTablesCallback,fe as useSetValueCallback,qe as useSetValuesCallback,ot as useSliceIds,dt as useSliceIdsListener,rt as useSliceRowIds,nt as useSliceRowIdsListener,ce as useSortedRowIds,Oe as useSortedRowIdsListener,Ke as useStartTransactionListener,M as useStore,re as useStoreIds,F as useStoreOrStoreById,Ie as useTable,ie as useTableCellIds,Ae as useTableCellIdsListener,ne as useTableIds,Ee as useTableIdsListener,Ve as useTableListener,de as useTables,Fe as useTablesListener,Gt as useUndoInformation,me as useValue,Ce as useValueIds,He as useValueIdsListener,Je as useValueListener,be as useValues,Ge as useValuesListener,Ne as useWillFinishTransactionListener};
Binary file
package/lib/umd/store.js CHANGED
@@ -1 +1 @@
1
- var e,t;e=this,t=function(e){"use strict";const t=e=>typeof e,s="",l=t(s),n=t(!0),a=t(0),o=t(t),r="type",c="default",i="Ids",d="Table",u=d+"s",h=d+i,f="Row",g=f+"Count",T=f+i,b="Cell",V=b+i,C="Value",S=C+"s",v=C+i,y=e=>s+e,m=isFinite,w=(e,t)=>e instanceof t,p=e=>null==e,I=(e,t,s)=>p(e)?s?.():t(e),R=e=>e==l||e==n,J=e=>t(e)==o,L=(e,t)=>e.forEach(t),E=(e,t)=>e.map(t),F=e=>e.length,x=(e,t,s)=>e.slice(t,s),z=(e,...t)=>e.push(...t),O=Object,j=O.keys,k=O.isFrozen,A=O.freeze,M=e=>w(e,O)&&e.constructor==O,N=(e,t)=>!p(((e,t)=>I(e,(e=>e[t])))(e,t)),P=(e,t)=>(delete e[t],e),B=(e,t)=>E(O.entries(e),(([e,s])=>t(s,e))),D=e=>M(e)&&0==(e=>F(j(e)))(e),W=e=>e?.size??0,$=(e,t)=>e?.has(t)??!1,q=e=>p(e)||0==W(e),G=e=>e.clear(),H=(e,t)=>e?.forEach(t),K=(e,t)=>e?.delete(t),Q=e=>new Map(e),U=e=>[...e?.keys()??[]],X=(e,t)=>e?.get(t),Y=(e,t)=>H(e,((e,s)=>t(s,e))),Z=(e,t,s)=>p(s)?(K(e,t),e):e?.set(t,s),_=(e,t,s)=>($(e,t)||Z(e,t,s()),X(e,t)),ee=(e,t,s,l=Z)=>(B(t,((t,l)=>s(e,l,t))),Y(e,(s=>N(t,s)?0:l(e,s))),e),te=(e,t,s)=>{const l={};return H(e,((e,n)=>{const a=t?t(e,n):e;!s?.(a,e)&&(l[n]=a)})),l},se=(e,t,s)=>te(e,(e=>te(e,t,s)),D),le=(e,t,s)=>te(e,(e=>se(e,t,s)),D),ne=(e,t)=>{const s=Q();return H(e,((e,l)=>s.set(l,t?.(e)??e))),s},ae=e=>ne(e,ne),oe=e=>ne(e,ae),re=(e,t,s,l,n=0)=>I((s?_:X)(e,t[n],n>F(t)-2?s:Q),(a=>{if(n>F(t)-2)return l?.(a)&&Z(e,t[n]),a;const o=re(a,t,s,l,n+1);return q(a)&&Z(e,t[n]),o})),ce=e=>new Set(Array.isArray(e)||p(e)?e:[e]),ie=(e,t)=>e?.add(t),de=/^\d+$/,ue=()=>{const e=[];let t=0;return[l=>(l?e.shift():null)??s+t++,t=>{de.test(t)&&F(e)<1e3&&z(e,t)}]},he=e=>[e,e],fe=()=>[Q(),Q()],ge=e=>[...e],Te=([e,t])=>e===t,be=e=>{const s=t(e);return R(s)||s==a&&m(e)?s:void 0},Ve=(e,t,s,l,n)=>p(n)?e.delCell(t,s,l,!0):e.setCell(t,s,l,n),Ce=(e,t,s)=>p(s)?e.delValue(t):e.setValue(t,s),Se=e=>JSON.stringify(e,((e,t)=>w(t,Map)?O.fromEntries([...t]):t)),ve=JSON.parse,ye=(e,t,s)=>p(e)||!M(e)||D(e)||k(e)?(s?.(),!1):(B(e,((s,l)=>{t(s,l)||P(e,l)})),!D(e)),me=(e,t,s)=>Z(e,t,X(e,t)==-s?void 0:s),we=()=>{let e,t,l=!1,n=!1,o=0;const i=Q(),m=Q(),w=Q(),O=Q(),j=Q(),k=Q(),M=Q(),de=Q(),pe=Q(),Ie=Q(),Re=Q(),Je=Q(),Le=Q(),Ee=Q(),Fe=ce(),xe=Q(),ze=Q(),Oe=Q(),je=Q(),ke=fe(),Ae=fe(),Me=fe(),Ne=fe(),Pe=fe(),Be=fe(),De=fe(),We=fe(),$e=fe(),qe=fe(),Ge=fe(),He=fe(),Ke=fe(),Qe=fe(),Ue=fe(),Xe=Q(),Ye=fe(),[Ze,_e,et,tt]=(e=>{let t;const[l,n]=ue(),a=Q();return[(e,n,o,r=[],c=(()=>[]))=>{t??=Ts;const i=l(1);return Z(a,i,[e,n,o,r,c]),ie(re(n,o??[s],ce),i),i},(e,l,...n)=>L(((e,t=[s])=>{const l=[],n=(e,s)=>s==F(t)?z(l,e):null===t[s]?H(e,(e=>n(e,s+1))):L([t[s],null],(t=>n(X(e,t),s+1)));return n(e,0),l})(e,l),(e=>H(e,(e=>X(a,e)[0](t,...l??[],...n))))),e=>I(X(a,e),(([,t,l])=>(re(t,l??[s],void 0,(t=>(K(t,e),q(t)?1:0))),Z(a,e),n(e),l))),e=>I(X(a,e),(([e,,s=[],l,n])=>{const a=(...o)=>{const r=F(o);r==F(s)?e(t,...o,...n(o)):p(s[r])?L(l[r]?.(...o)??[],(e=>a(...o,e))):a(...o,s[r])};a()}))]})(),st=e=>{if(!ye(e,((e,t)=>[r,c].includes(t))))return!1;const t=e[r];return!(!R(t)&&t!=a||(be(e[c])!=t&&P(e,c),0))},lt=(t,s)=>(!e||$(Re,s)||Ot(s))&&ye(t,((e,t)=>nt(s,t,e)),(()=>Ot(s))),nt=(e,t,s,l)=>ye(l?s:ct(s,e,t),((l,n)=>I(at(e,t,n,l),(e=>(s[n]=e,!0)),(()=>!1))),(()=>Ot(e,t))),at=(t,s,l,n)=>e?I(X(X(Re,t),l),(e=>be(n)!=e[r]?Ot(t,s,l,n,e[c]):n),(()=>Ot(t,s,l,n))):p(be(n))?Ot(t,s,l,n):n,ot=(e,t)=>ye(t?e:it(e),((t,s)=>I(rt(s,t),(t=>(e[s]=t,!0)),(()=>!1))),(()=>jt())),rt=(e,s)=>t?I(X(Le,e),(t=>be(s)!=t[r]?jt(e,s,t[c]):s),(()=>jt(e,s))):p(be(s))?jt(e,s):s,ct=(e,t,s)=>(I(X(Je,t),(([l,n])=>{H(l,((t,s)=>{N(e,s)||(e[s]=t)})),H(n,(l=>{N(e,l)||Ot(t,s,l)}))})),e),it=e=>(t&&(H(Ee,((t,s)=>{N(e,s)||(e[s]=t)})),H(Fe,(t=>{N(e,t)||jt(t)}))),e),dt=e=>ee(Re,e,((e,t,s)=>{const l=Q(),n=ce();ee(_(Re,t,Q),s,((e,t,s)=>{Z(e,t,s),I(s[c],(e=>Z(l,t,e)),(()=>ie(n,t)))})),Z(Je,t,[l,n])}),((e,t)=>{Z(Re,t),Z(Je,t)})),ut=e=>ee(Le,e,((e,t,s)=>{Z(Le,t,s),I(s[c],(e=>Z(Ee,t,e)),(()=>ie(Fe,t)))}),((e,t)=>{Z(Le,t),Z(Ee,t),K(Fe,t)})),ht=e=>D(e)?os():ts(e),ft=e=>ee(Oe,e,((e,t,s)=>gt(t,s)),((e,t)=>wt(t))),gt=(e,t)=>ee(_(Oe,e,(()=>(Jt(e,1),Z(xe,e,ue()),Z(ze,e,Q()),Q()))),t,((t,s,l)=>Tt(e,t,s,l)),((t,s)=>pt(e,t,s))),Tt=(e,t,s,l,n)=>ee(_(t,s,(()=>(Lt(e,s,1),Q()))),l,((t,l,n)=>bt(e,s,t,l,n)),((l,a)=>It(e,t,s,l,a,n))),bt=(e,t,s,l,n)=>{$(s,l)||Et(e,t,l,1);const a=X(s,l);n!==a&&(Ft(e,t,l,a,n),Z(s,l,n))},Vt=(e,t,s,l,n)=>I(X(t,s),(t=>bt(e,s,t,l,n)),(()=>Tt(e,t,s,ct({[l]:n},e,s)))),Ct=e=>D(e)?is():ss(e),St=e=>ee(je,e,((e,t,s)=>vt(t,s)),((e,t)=>Rt(t))),vt=(e,t)=>{$(je,e)||xt(e,1);const s=X(je,e);t!==s&&(zt(e,s,t),Z(je,e,t))},yt=(e,t)=>{const[s]=X(xe,e),l=s(t);return $(X(Oe,e),l)?yt(e,t):l},mt=e=>X(Oe,e)??gt(e,{}),wt=e=>gt(e,{}),pt=(e,t,s)=>{const[,l]=X(xe,e);l(s),Tt(e,t,s,{},!0)},It=(e,t,s,l,n,a)=>{const o=X(X(Je,e)?.[0],n);if(!p(o)&&!a)return bt(e,s,l,n,o);const r=t=>{Ft(e,s,t,X(l,t)),Et(e,s,t,-1),Z(l,t)};p(o)?r(n):Y(l,r),q(l)&&(Lt(e,s,-1),q(Z(t,s))&&(Jt(e,-1),Z(Oe,e),Z(xe,e),Z(ze,e)))},Rt=e=>{const t=X(Ee,e);if(!p(t))return vt(e,t);zt(e,X(je,e)),xt(e,-1),Z(je,e)},Jt=(e,t)=>me(i,e,t),Lt=(e,t,s)=>me(_(O,e,Q),t,s)&&Z(w,e,_(w,e,(()=>0))+s),Et=(e,t,s,l)=>{const n=X(ze,e),a=X(n,s)??0;(0==a&&1==l||1==a&&-1==l)&&me(_(m,e,Q),s,l),Z(n,s,a!=-l?a+l:null),me(_(_(j,e,Q),t,Q),s,l)},Ft=(e,t,s,l,n)=>_(_(_(k,e,Q),t,Q),s,(()=>[l,0]))[1]=n,xt=(e,t)=>me(M,e,t),zt=(e,t,s)=>_(de,e,(()=>[t,0]))[1]=s,Ot=(e,t,s,l,n)=>(z(_(_(_(pe,e,Q),t,Q),s,(()=>[])),l),n),jt=(e,t,s)=>(z(_(Ie,e,(()=>[])),t),s),kt=(e,t,s)=>I(X(X(X(k,e),t),s),(([e,t])=>[!0,e,t]),(()=>[!1,...he(Yt(e,t,s))])),At=e=>I(X(de,e),(([e,t])=>[!0,e,t]),(()=>[!1,...he(es(e))])),Mt=e=>q(pe)||q(Ge[e])?0:H(e?oe(pe):pe,((t,s)=>H(t,((t,l)=>H(t,((t,n)=>_e(Ge[e],[s,l,n],t))))))),Nt=e=>q(Ie)||q(He[e])?0:H(e?ne(Ie):Ie,((t,s)=>_e(He[e],[s],t))),Pt=(e,t,s)=>{if(!q(t))return _e(e,s,(()=>te(t))),1},Bt=e=>{const t=q(De[e]),s=q($e[e])&&q(Ne[e])&&q(Pe[e])&&q(Be[e])&&t&&q(Ae[e]),l=q(qe[e])&&q(We[e])&&q(Me[e])&&q(ke[e]);if(!s||!l){const n=e?[ne(i),ae(m),ne(w),ae(O),oe(j),oe(k)]:[i,m,w,O,j,k];if(!s){Pt(Ae[e],n[0]),H(n[1],((t,s)=>Pt(Ne[e],t,[s]))),H(n[2],((t,s)=>{0!=t&&_e(Pe[e],[s],Kt(s))}));const s=ce();H(n[3],((l,n)=>{Pt(Be[e],l,[n])&&!t&&(_e(De[e],[n,null]),ie(s,n))})),t||H(n[5],((t,l)=>{if(!$(s,l)){const s=ce();H(t,(e=>H(e,(([t,l],n)=>l!==t?ie(s,n):K(e,n))))),H(s,(t=>_e(De[e],[l,t])))}})),H(n[4],((t,s)=>H(t,((t,l)=>Pt($e[e],t,[s,l])))))}if(!l){let t;H(n[5],((s,l)=>{let n;H(s,((s,a)=>{let o;H(s,(([s,r],c)=>{r!==s&&(_e(qe[e],[l,a,c],r,s,kt),t=n=o=1)})),o&&_e(We[e],[l,a],kt)})),n&&_e(Me[e],[l],kt)})),t&&_e(ke[e],void 0,kt)}}},Dt=e=>{const t=q(Qe[e]),s=q(Ue[e])&&q(Ke[e]);if(!t||!s){const l=e?[ne(M),ne(de)]:[M,de];if(t||Pt(Qe[e],l[0]),!s){let t;H(l[1],(([s,l],n)=>{l!==s&&(_e(Ue[e],[n],l,s,At),t=1)})),t&&_e(Ke[e],void 0,At)}}},Wt=(e,...t)=>(hs((()=>e(...E(t,y)))),Ts),$t=()=>[te(k,((e,t)=>-1===X(i,t)?null:te(e,((e,s)=>-1===X(X(O,t),s)?null:te(e,(([,e])=>e??null),((e,t)=>Te(t)))),D)),D),te(de,(([,e])=>e??null),((e,t)=>Te(t)))],qt=()=>({cellsTouched:l,valuesTouched:n,changedCells:le(k,ge,Te),invalidCells:le(pe),changedValues:te(de,ge,Te),invalidValues:te(Ie),changedTableIds:te(i),changedRowIds:se(O),changedCellIds:le(j),changedValueIds:te(M)}),Gt=()=>le(Oe),Ht=()=>U(Oe),Kt=e=>W(X(Oe,y(e))),Qt=e=>U(X(Oe,y(e))),Ut=(e,t,s,l=0,n)=>{return E(x((o=X(Oe,y(e)),r=(e,s)=>[p(t)?s:X(e,y(t)),s],a=([e],[t])=>((e??0)<(t??0)?-1:1)*(s?-1:1),E([...o?.entries()??[]],(([e,t])=>r(t,e))).sort(a)),l,p(n)?n:l+n),(([,e])=>e));var a,o,r},Xt=(e,t)=>U(X(X(Oe,y(e)),y(t))),Yt=(e,t,s)=>X(X(X(Oe,y(e)),y(t)),y(s)),Zt=()=>te(je),_t=()=>U(je),es=e=>X(je,y(e)),ts=e=>Wt((()=>(e=>ye(e,lt,Ot))(e)?ft(e):0)),ss=e=>Wt((()=>ot(e)?St(e):0)),ls=e=>{try{ht(ve(e))}catch{}return Ts},ns=t=>Wt((()=>{if((e=ye(t,(e=>ye(e,st))))&&(dt(t),!q(Oe))){const e=Gt();os(),ts(e)}})),as=e=>Wt((()=>{if(t=(e=>ye(e,st))(e)){const s=Zt();us(),is(),t=!0,ut(e),ss(s)}})),os=()=>Wt((()=>ft({}))),rs=e=>Wt((e=>$(Oe,e)?wt(e):0),e),cs=(e,t)=>Wt(((e,t)=>I(X(Oe,e),(s=>$(s,t)?pt(e,s,t):0))),e,t),is=()=>Wt((()=>St({}))),ds=()=>Wt((()=>{dt({}),e=!1})),us=()=>Wt((()=>{ut({}),t=!1})),hs=(e,t)=>{if(-1!=o){fs();const s=e();return gs(t),s}},fs=()=>(-1!=o&&o++,1==o&&_e(Xe,void 0,$t,qt),Ts),gs=e=>(o>0&&(o--,0==o&&(l=!q(k),n=!q(de),o=1,Mt(1),l&&Bt(1),Nt(1),n&&Dt(1),e?.($t,qt)&&(H(k,((e,t)=>H(e,((e,s)=>H(e,(([e],l)=>Ve(Ts,t,s,l,e))))))),H(de,(([e],t)=>Ce(Ts,t,e))),l=n=!1),_e(Ye[0],void 0,$t,qt),o=-1,Mt(0),l&&Bt(0),Nt(0),n&&Dt(0),_e(Ye[1],void 0,$t,qt),o=0,l=n=!1,L([i,m,w,O,j,k,pe,M,de,Ie],G))),Ts),Ts={getContent:()=>[Gt(),Zt()],getTables:Gt,getTableIds:Ht,getTable:e=>se(X(Oe,y(e))),getTableCellIds:e=>U(X(ze,y(e))),getRowCount:Kt,getRowIds:Qt,getSortedRowIds:Ut,getRow:(e,t)=>te(X(X(Oe,y(e)),y(t))),getCellIds:Xt,getCell:Yt,getValues:Zt,getValueIds:_t,getValue:es,hasTables:()=>!q(Oe),hasTable:e=>$(Oe,y(e)),hasTableCell:(e,t)=>$(X(ze,y(e)),y(t)),hasRow:(e,t)=>$(X(Oe,y(e)),y(t)),hasCell:(e,t,s)=>$(X(X(Oe,y(e)),y(t)),y(s)),hasValues:()=>!q(je),hasValue:e=>$(je,y(e)),getTablesJson:()=>Se(Oe),getValuesJson:()=>Se(je),getJson:()=>Se([Oe,je]),getTablesSchemaJson:()=>Se(Re),getValuesSchemaJson:()=>Se(Le),getSchemaJson:()=>Se([Re,Le]),hasTablesSchema:()=>e,hasValuesSchema:()=>t,setContent:([e,t])=>Wt((()=>{(D(e)?os:ts)(e),(D(t)?is:ss)(t)})),setTables:ts,setTable:(e,t)=>Wt((e=>lt(t,e)?gt(e,t):0),e),setRow:(e,t,s)=>Wt(((e,t)=>nt(e,t,s)?Tt(e,mt(e),t,s):0),e,t),addRow:(e,t,s=!0)=>hs((()=>{let l;return nt(e,l,t)&&(e=y(e),Tt(e,mt(e),l=yt(e,s?1:0),t)),l})),setPartialRow:(e,t,s)=>Wt(((e,t)=>{if(nt(e,t,s,1)){const l=mt(e);B(s,((s,n)=>Vt(e,l,t,n,s)))}}),e,t),setCell:(e,t,s,l)=>Wt(((e,t,s)=>I(at(e,t,s,J(l)?l(Yt(e,t,s)):l),(l=>Vt(e,mt(e),t,s,l)))),e,t,s),setValues:ss,setPartialValues:e=>Wt((()=>ot(e,1)?B(e,((e,t)=>vt(t,e))):0)),setValue:(e,t)=>Wt((e=>I(rt(e,J(t)?t(es(e)):t),(t=>vt(e,t)))),e),setTransactionChanges:e=>Wt((()=>{B(e[0],((e,t)=>p(e)?rs(t):B(e,((e,s)=>p(e)?cs(t,s):B(e,((e,l)=>Ve(Ts,t,s,l,e))))))),B(e[1],((e,t)=>Ce(Ts,t,e)))})),setTablesJson:ls,setValuesJson:e=>{try{Ct(ve(e))}catch{}return Ts},setJson:e=>{try{const[t,s]=ve(e);ht(t),Ct(s)}catch{ls(e)}return Ts},setTablesSchema:ns,setValuesSchema:as,setSchema:(e,t)=>Wt((()=>{ns(e),as(t)})),delTables:os,delTable:rs,delRow:cs,delCell:(e,t,s,l)=>Wt(((e,t,s)=>I(X(Oe,e),(n=>I(X(n,t),(a=>$(a,s)?It(e,n,t,a,s,l):0))))),e,t,s),delValues:is,delValue:e=>Wt((e=>$(je,e)?Rt(e):0),e),delTablesSchema:ds,delValuesSchema:us,delSchema:()=>Wt((()=>{ds(),us()})),transaction:hs,startTransaction:fs,finishTransaction:gs,forEachTable:e=>H(Oe,((t,s)=>e(s,(e=>H(t,((t,s)=>e(s,(e=>Y(t,e))))))))),forEachTableCell:(e,t)=>Y(X(ze,y(e)),t),forEachRow:(e,t)=>H(X(Oe,y(e)),((e,s)=>t(s,(t=>Y(e,t))))),forEachCell:(e,t,s)=>Y(X(X(Oe,y(e)),y(t)),s),forEachValue:e=>Y(je,e),addSortedRowIdsListener:(e,t,s,l,n,a,o)=>{let r=Ut(e,t,s,l,n);return Ze((()=>{const o=Ut(e,t,s,l,n);var c,i,d;i=r,F(c=o)===F(i)&&(d=(e,t)=>i[t]===e,c.every(d))||(r=o,a(Ts,e,t,s,l,n,r))}),De[o?1:0],[e,t],[Ht])},addStartTransactionListener:e=>Ze(e,Xe),addWillFinishTransactionListener:e=>Ze(e,Ye[0]),addDidFinishTransactionListener:e=>Ze(e,Ye[1]),callListener:e=>(tt(e),Ts),delListener:e=>(et(e),Ts),getListenerStats:()=>({}),createStore:we,addListener:Ze,callListeners:_e};return B({[u]:[0,ke],[h]:[0,Ae],[d]:[1,Me,[Ht]],[d+V]:[1,Ne,[Ht]],[g]:[1,Pe,[Ht]],[T]:[1,Be,[Ht]],[f]:[2,We,[Ht,Qt]],[V]:[2,$e,[Ht,Qt]],[b]:[3,qe,[Ht,Qt,Xt],e=>he(Yt(...e))],InvalidCell:[3,Ge],[S]:[0,Ke],[v]:[0,Qe],[C]:[1,Ue,[_t],e=>he(es(e[0]))],InvalidValue:[1,He]},(([e,t,s,l],n)=>{Ts["add"+n+"Listener"]=(...n)=>Ze(n[e],t[n[e+1]?1:0],e>0?x(n,0,e):void 0,s,l)})),A(Ts)};e.createStore=we},"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).TinyBaseStore={});
1
+ var e,t;e=this,t=function(e){"use strict";const t=e=>typeof e,s="",l=t(s),n=t(!0),a=t(0),o=t(t),r="type",c="default",i="Ids",d="Table",u=d+"s",h=d+i,f="Row",g=f+"Count",T=f+i,b="Cell",V=b+i,C="Value",S=C+"s",v=C+i,y=e=>s+e,m=isFinite,w=(e,t)=>e instanceof t,p=e=>null==e,I=(e,t,s)=>p(e)?s?.():t(e),R=e=>e==l||e==n,J=e=>t(e)==o,L=(e,t)=>e.forEach(t),E=(e,t)=>e.map(t),F=e=>e.length,x=(e,t,s)=>e.slice(t,s),z=(e,...t)=>e.push(...t),O=Object,j=O.keys,k=O.isFrozen,A=O.freeze,M=e=>w(e,O)&&e.constructor==O,N=(e,t)=>!p(((e,t)=>I(e,(e=>e[t])))(e,t)),P=(e,t)=>(delete e[t],e),B=(e,t)=>E(O.entries(e),(([e,s])=>t(s,e))),D=e=>M(e)&&0==(e=>F(j(e)))(e),W=e=>e?.size??0,$=(e,t)=>e?.has(t)??!1,q=e=>p(e)||0==W(e),G=e=>e.clear(),H=(e,t)=>e?.forEach(t),K=(e,t)=>e?.delete(t),Q=e=>new Map(e),U=e=>[...e?.keys()??[]],X=(e,t)=>e?.get(t),Y=(e,t)=>H(e,((e,s)=>t(s,e))),Z=(e,t,s)=>p(s)?(K(e,t),e):e?.set(t,s),_=(e,t,s)=>($(e,t)||Z(e,t,s()),X(e,t)),ee=(e,t,s,l=Z)=>(B(t,((t,l)=>s(e,l,t))),Y(e,(s=>N(t,s)?0:l(e,s))),e),te=(e,t,s)=>{const l={};return H(e,((e,n)=>{const a=t?t(e,n):e;!s?.(a,e)&&(l[n]=a)})),l},se=(e,t,s)=>te(e,(e=>te(e,t,s)),D),le=(e,t,s)=>te(e,(e=>se(e,t,s)),D),ne=(e,t)=>{const s=Q();return H(e,((e,l)=>s.set(l,t?.(e)??e))),s},ae=e=>ne(e,ne),oe=e=>ne(e,ae),re=(e,t,s,l,n=0)=>I((s?_:X)(e,t[n],n>F(t)-2?s:Q),(a=>{if(n>F(t)-2)return l?.(a)&&Z(e,t[n]),a;const o=re(a,t,s,l,n+1);return q(a)&&Z(e,t[n]),o})),ce=e=>new Set(Array.isArray(e)||p(e)?e:[e]),ie=(e,t)=>e?.add(t),de=/^\d+$/,ue=()=>{const e=[];let t=0;return[l=>(l?e.shift():null)??s+t++,t=>{de.test(t)&&F(e)<1e3&&z(e,t)}]},he=e=>[e,e],fe=()=>[Q(),Q()],ge=e=>[...e],Te=([e,t])=>e===t,be=e=>{const s=t(e);return R(s)||s==a&&m(e)?s:void 0},Ve=(e,t,s,l,n)=>p(n)?e.delCell(t,s,l,!0):e.setCell(t,s,l,n),Ce=(e,t,s)=>p(s)?e.delValue(t):e.setValue(t,s),Se=e=>JSON.stringify(e,((e,t)=>w(t,Map)?O.fromEntries([...t]):t)),ve=JSON.parse,ye=(e,t,s)=>p(e)||!M(e)||D(e)||k(e)?(s?.(),!1):(B(e,((s,l)=>{t(s,l)||P(e,l)})),!D(e)),me=(e,t,s)=>Z(e,t,X(e,t)==-s?void 0:s),we=()=>{let e,t,l=!1,n=!1,o=0;const i=Q(),m=Q(),w=Q(),O=Q(),j=Q(),k=Q(),M=Q(),de=Q(),pe=Q(),Ie=Q(),Re=Q(),Je=Q(),Le=Q(),Ee=Q(),Fe=ce(),xe=Q(),ze=Q(),Oe=Q(),je=Q(),ke=fe(),Ae=fe(),Me=fe(),Ne=fe(),Pe=fe(),Be=fe(),De=fe(),We=fe(),$e=fe(),qe=fe(),Ge=fe(),He=fe(),Ke=fe(),Qe=fe(),Ue=fe(),Xe=Q(),Ye=fe(),[Ze,_e,et,tt]=(e=>{let t;const[l,n]=ue(),a=Q();return[(e,n,o,r=[],c=(()=>[]))=>{t??=Ts;const i=l(1);return Z(a,i,[e,n,o,r,c]),ie(re(n,o??[s],ce),i),i},(e,l,...n)=>L(((e,t=[s])=>{const l=[],n=(e,s)=>s==F(t)?z(l,e):null===t[s]?H(e,(e=>n(e,s+1))):L([t[s],null],(t=>n(X(e,t),s+1)));return n(e,0),l})(e,l),(e=>H(e,(e=>X(a,e)[0](t,...l??[],...n))))),e=>I(X(a,e),(([,t,l])=>(re(t,l??[s],void 0,(t=>(K(t,e),q(t)?1:0))),Z(a,e),n(e),l))),e=>I(X(a,e),(([e,,s=[],l,n])=>{const a=(...o)=>{const r=F(o);r==F(s)?e(t,...o,...n(o)):p(s[r])?L(l[r]?.(...o)??[],(e=>a(...o,e))):a(...o,s[r])};a()}))]})(),st=e=>{if(!ye(e,((e,t)=>[r,c].includes(t))))return!1;const t=e[r];return!(!R(t)&&t!=a||(be(e[c])!=t&&P(e,c),0))},lt=(t,s)=>(!e||$(Re,s)||Ot(s))&&ye(t,((e,t)=>nt(s,t,e)),(()=>Ot(s))),nt=(e,t,s,l)=>ye(l?s:ct(s,e,t),((l,n)=>I(at(e,t,n,l),(e=>(s[n]=e,!0)),(()=>!1))),(()=>Ot(e,t))),at=(t,s,l,n)=>e?I(X(X(Re,t),l),(e=>be(n)!=e[r]?Ot(t,s,l,n,e[c]):n),(()=>Ot(t,s,l,n))):p(be(n))?Ot(t,s,l,n):n,ot=(e,t)=>ye(t?e:it(e),((t,s)=>I(rt(s,t),(t=>(e[s]=t,!0)),(()=>!1))),(()=>jt())),rt=(e,s)=>t?I(X(Le,e),(t=>be(s)!=t[r]?jt(e,s,t[c]):s),(()=>jt(e,s))):p(be(s))?jt(e,s):s,ct=(e,t,s)=>(I(X(Je,t),(([l,n])=>{H(l,((t,s)=>{N(e,s)||(e[s]=t)})),H(n,(l=>{N(e,l)||Ot(t,s,l)}))})),e),it=e=>(t&&(H(Ee,((t,s)=>{N(e,s)||(e[s]=t)})),H(Fe,(t=>{N(e,t)||jt(t)}))),e),dt=e=>ee(Re,e,((e,t,s)=>{const l=Q(),n=ce();ee(_(Re,t,Q),s,((e,t,s)=>{Z(e,t,s),I(s[c],(e=>Z(l,t,e)),(()=>ie(n,t)))})),Z(Je,t,[l,n])}),((e,t)=>{Z(Re,t),Z(Je,t)})),ut=e=>ee(Le,e,((e,t,s)=>{Z(Le,t,s),I(s[c],(e=>Z(Ee,t,e)),(()=>ie(Fe,t)))}),((e,t)=>{Z(Le,t),Z(Ee,t),K(Fe,t)})),ht=e=>D(e)?os():ts(e),ft=e=>ee(Oe,e,((e,t,s)=>gt(t,s)),((e,t)=>wt(t))),gt=(e,t)=>ee(_(Oe,e,(()=>(Jt(e,1),Z(xe,e,ue()),Z(ze,e,Q()),Q()))),t,((t,s,l)=>Tt(e,t,s,l)),((t,s)=>pt(e,t,s))),Tt=(e,t,s,l,n)=>ee(_(t,s,(()=>(Lt(e,s,1),Q()))),l,((t,l,n)=>bt(e,s,t,l,n)),((l,a)=>It(e,t,s,l,a,n))),bt=(e,t,s,l,n)=>{$(s,l)||Et(e,t,l,1);const a=X(s,l);n!==a&&(Ft(e,t,l,a,n),Z(s,l,n))},Vt=(e,t,s,l,n)=>I(X(t,s),(t=>bt(e,s,t,l,n)),(()=>Tt(e,t,s,ct({[l]:n},e,s)))),Ct=e=>D(e)?is():ss(e),St=e=>ee(je,e,((e,t,s)=>vt(t,s)),((e,t)=>Rt(t))),vt=(e,t)=>{$(je,e)||xt(e,1);const s=X(je,e);t!==s&&(zt(e,s,t),Z(je,e,t))},yt=(e,t)=>{const[s]=X(xe,e),l=s(t);return $(X(Oe,e),l)?yt(e,t):l},mt=e=>X(Oe,e)??gt(e,{}),wt=e=>gt(e,{}),pt=(e,t,s)=>{const[,l]=X(xe,e);l(s),Tt(e,t,s,{},!0)},It=(e,t,s,l,n,a)=>{const o=X(X(Je,e)?.[0],n);if(!p(o)&&!a)return bt(e,s,l,n,o);const r=t=>{Ft(e,s,t,X(l,t)),Et(e,s,t,-1),Z(l,t)};p(o)?r(n):Y(l,r),q(l)&&(Lt(e,s,-1),q(Z(t,s))&&(Jt(e,-1),Z(Oe,e),Z(xe,e),Z(ze,e)))},Rt=e=>{const t=X(Ee,e);if(!p(t))return vt(e,t);zt(e,X(je,e)),xt(e,-1),Z(je,e)},Jt=(e,t)=>me(i,e,t),Lt=(e,t,s)=>me(_(O,e,Q),t,s)&&Z(w,e,_(w,e,(()=>0))+s),Et=(e,t,s,l)=>{const n=X(ze,e),a=X(n,s)??0;(0==a&&1==l||1==a&&-1==l)&&me(_(m,e,Q),s,l),Z(n,s,a!=-l?a+l:null),me(_(_(j,e,Q),t,Q),s,l)},Ft=(e,t,s,l,n)=>_(_(_(k,e,Q),t,Q),s,(()=>[l,0]))[1]=n,xt=(e,t)=>me(M,e,t),zt=(e,t,s)=>_(de,e,(()=>[t,0]))[1]=s,Ot=(e,t,s,l,n)=>(z(_(_(_(pe,e,Q),t,Q),s,(()=>[])),l),n),jt=(e,t,s)=>(z(_(Ie,e,(()=>[])),t),s),kt=(e,t,s)=>I(X(X(X(k,e),t),s),(([e,t])=>[!0,e,t]),(()=>[!1,...he(Yt(e,t,s))])),At=e=>I(X(de,e),(([e,t])=>[!0,e,t]),(()=>[!1,...he(es(e))])),Mt=e=>q(pe)||q(Ge[e])?0:H(e?oe(pe):pe,((t,s)=>H(t,((t,l)=>H(t,((t,n)=>_e(Ge[e],[s,l,n],t))))))),Nt=e=>q(Ie)||q(He[e])?0:H(e?ne(Ie):Ie,((t,s)=>_e(He[e],[s],t))),Pt=(e,t,s)=>{if(!q(t))return _e(e,s,(()=>te(t))),1},Bt=e=>{const t=q(De[e]),s=q($e[e])&&q(Ne[e])&&q(Pe[e])&&q(Be[e])&&t&&q(Ae[e]),l=q(qe[e])&&q(We[e])&&q(Me[e])&&q(ke[e]);if(!s||!l){const n=e?[ne(i),ae(m),ne(w),ae(O),oe(j),oe(k)]:[i,m,w,O,j,k];if(!s){Pt(Ae[e],n[0]),H(n[1],((t,s)=>Pt(Ne[e],t,[s]))),H(n[2],((t,s)=>{0!=t&&_e(Pe[e],[s],Kt(s))}));const s=ce();H(n[3],((l,n)=>{Pt(Be[e],l,[n])&&!t&&(_e(De[e],[n,null]),ie(s,n))})),t||H(n[5],((t,l)=>{if(!$(s,l)){const s=ce();H(t,(e=>H(e,(([t,l],n)=>l!==t?ie(s,n):K(e,n))))),H(s,(t=>_e(De[e],[l,t])))}})),H(n[4],((t,s)=>H(t,((t,l)=>Pt($e[e],t,[s,l])))))}if(!l){let t;H(n[5],((s,l)=>{let n;H(s,((s,a)=>{let o;H(s,(([s,r],c)=>{r!==s&&(_e(qe[e],[l,a,c],r,s,kt),t=n=o=1)})),o&&_e(We[e],[l,a],kt)})),n&&_e(Me[e],[l],kt)})),t&&_e(ke[e],void 0,kt)}}},Dt=e=>{const t=q(Qe[e]),s=q(Ue[e])&&q(Ke[e]);if(!t||!s){const l=e?[ne(M),ne(de)]:[M,de];if(t||Pt(Qe[e],l[0]),!s){let t;H(l[1],(([s,l],n)=>{l!==s&&(_e(Ue[e],[n],l,s,At),t=1)})),t&&_e(Ke[e],void 0,At)}}},Wt=(e,...t)=>(hs((()=>e(...E(t,y)))),Ts),$t=()=>[te(k,((e,t)=>-1===X(i,t)?null:te(e,((e,s)=>-1===X(X(O,t),s)?null:te(e,(([,e])=>e??null),((e,t)=>Te(t)))),D)),D),te(de,(([,e])=>e??null),((e,t)=>Te(t)))],qt=()=>({cellsTouched:l,valuesTouched:n,changedCells:le(k,ge,Te),invalidCells:le(pe),changedValues:te(de,ge,Te),invalidValues:te(Ie),changedTableIds:te(i),changedRowIds:se(O),changedCellIds:le(j),changedValueIds:te(M)}),Gt=()=>le(Oe),Ht=()=>U(Oe),Kt=e=>W(X(Oe,y(e))),Qt=e=>U(X(Oe,y(e))),Ut=(e,t,s,l=0,n)=>{return E(x((o=X(Oe,y(e)),r=(e,s)=>[p(t)?s:X(e,y(t)),s],a=([e],[t])=>((e??0)<(t??0)?-1:1)*(s?-1:1),E([...o?.entries()??[]],(([e,t])=>r(t,e))).sort(a)),l,p(n)?n:l+n),(([,e])=>e));var a,o,r},Xt=(e,t)=>U(X(X(Oe,y(e)),y(t))),Yt=(e,t,s)=>X(X(X(Oe,y(e)),y(t)),y(s)),Zt=()=>te(je),_t=()=>U(je),es=e=>X(je,y(e)),ts=e=>Wt((()=>(e=>ye(e,lt,Ot))(e)?ft(e):0)),ss=e=>Wt((()=>ot(e)?St(e):0)),ls=e=>{try{ht(ve(e))}catch{}return Ts},ns=t=>Wt((()=>{if((e=ye(t,(e=>ye(e,st))))&&(dt(t),!q(Oe))){const e=Gt();os(),ts(e)}})),as=e=>Wt((()=>{if(t=(e=>ye(e,st))(e)){const s=Zt();us(),is(),t=!0,ut(e),ss(s)}})),os=()=>Wt((()=>ft({}))),rs=e=>Wt((e=>$(Oe,e)?wt(e):0),e),cs=(e,t)=>Wt(((e,t)=>I(X(Oe,e),(s=>$(s,t)?pt(e,s,t):0))),e,t),is=()=>Wt((()=>St({}))),ds=()=>Wt((()=>{dt({}),e=!1})),us=()=>Wt((()=>{ut({}),t=!1})),hs=(e,t)=>{if(-1!=o){fs();const s=e();return gs(t),s}},fs=()=>(-1!=o&&o++,1==o&&_e(Xe,void 0,$t,qt),Ts),gs=e=>(o>0&&(o--,0==o&&(l=!q(k),n=!q(de),o=1,Mt(1),l&&Bt(1),Nt(1),n&&Dt(1),e?.($t,qt)&&(H(k,((e,t)=>H(e,((e,s)=>H(e,(([e],l)=>Ve(Ts,t,s,l,e))))))),H(de,(([e],t)=>Ce(Ts,t,e))),l=n=!1),_e(Ye[0],void 0,$t,qt),o=-1,Mt(0),l&&Bt(0),Nt(0),n&&Dt(0),_e(Ye[1],void 0,$t,qt),o=0,l=n=!1,L([i,m,w,O,j,k,pe,M,de,Ie],G))),Ts),Ts={getContent:()=>[Gt(),Zt()],getTables:Gt,getTableIds:Ht,getTable:e=>se(X(Oe,y(e))),getTableCellIds:e=>U(X(ze,y(e))),getRowCount:Kt,getRowIds:Qt,getSortedRowIds:Ut,getRow:(e,t)=>te(X(X(Oe,y(e)),y(t))),getCellIds:Xt,getCell:Yt,getValues:Zt,getValueIds:_t,getValue:es,hasTables:()=>!q(Oe),hasTable:e=>$(Oe,y(e)),hasTableCell:(e,t)=>$(X(ze,y(e)),y(t)),hasRow:(e,t)=>$(X(Oe,y(e)),y(t)),hasCell:(e,t,s)=>$(X(X(Oe,y(e)),y(t)),y(s)),hasValues:()=>!q(je),hasValue:e=>$(je,y(e)),getTablesJson:()=>Se(Oe),getValuesJson:()=>Se(je),getJson:()=>Se([Oe,je]),getTablesSchemaJson:()=>Se(Re),getValuesSchemaJson:()=>Se(Le),getSchemaJson:()=>Se([Re,Le]),hasTablesSchema:()=>e,hasValuesSchema:()=>t,setContent:([e,t])=>Wt((()=>{(D(e)?os:ts)(e),(D(t)?is:ss)(t)})),setTables:ts,setTable:(e,t)=>Wt((e=>lt(t,e)?gt(e,t):0),e),setRow:(e,t,s)=>Wt(((e,t)=>nt(e,t,s)?Tt(e,mt(e),t,s):0),e,t),addRow:(e,t,s=!0)=>hs((()=>{let l;return nt(e,l,t)&&(e=y(e),Tt(e,mt(e),l=yt(e,s?1:0),t)),l})),setPartialRow:(e,t,s)=>Wt(((e,t)=>{if(nt(e,t,s,1)){const l=mt(e);B(s,((s,n)=>Vt(e,l,t,n,s)))}}),e,t),setCell:(e,t,s,l)=>Wt(((e,t,s)=>I(at(e,t,s,J(l)?l(Yt(e,t,s)):l),(l=>Vt(e,mt(e),t,s,l)))),e,t,s),setValues:ss,setPartialValues:e=>Wt((()=>ot(e,1)?B(e,((e,t)=>vt(t,e))):0)),setValue:(e,t)=>Wt((e=>I(rt(e,J(t)?t(es(e)):t),(t=>vt(e,t)))),e),setTransactionChanges:e=>Wt((()=>{B(e[0],((e,t)=>p(e)?rs(t):B(e,((e,s)=>p(e)?cs(t,s):B(e,((e,l)=>Ve(Ts,t,s,l,e))))))),B(e[1],((e,t)=>Ce(Ts,t,e)))})),setTablesJson:ls,setValuesJson:e=>{try{Ct(ve(e))}catch{}return Ts},setJson:e=>Wt((()=>{try{const[t,s]=ve(e);ht(t),Ct(s)}catch{ls(e)}})),setTablesSchema:ns,setValuesSchema:as,setSchema:(e,t)=>Wt((()=>{ns(e),as(t)})),delTables:os,delTable:rs,delRow:cs,delCell:(e,t,s,l)=>Wt(((e,t,s)=>I(X(Oe,e),(n=>I(X(n,t),(a=>$(a,s)?It(e,n,t,a,s,l):0))))),e,t,s),delValues:is,delValue:e=>Wt((e=>$(je,e)?Rt(e):0),e),delTablesSchema:ds,delValuesSchema:us,delSchema:()=>Wt((()=>{ds(),us()})),transaction:hs,startTransaction:fs,finishTransaction:gs,forEachTable:e=>H(Oe,((t,s)=>e(s,(e=>H(t,((t,s)=>e(s,(e=>Y(t,e))))))))),forEachTableCell:(e,t)=>Y(X(ze,y(e)),t),forEachRow:(e,t)=>H(X(Oe,y(e)),((e,s)=>t(s,(t=>Y(e,t))))),forEachCell:(e,t,s)=>Y(X(X(Oe,y(e)),y(t)),s),forEachValue:e=>Y(je,e),addSortedRowIdsListener:(e,t,s,l,n,a,o)=>{let r=Ut(e,t,s,l,n);return Ze((()=>{const o=Ut(e,t,s,l,n);var c,i,d;i=r,F(c=o)===F(i)&&(d=(e,t)=>i[t]===e,c.every(d))||(r=o,a(Ts,e,t,s,l,n,r))}),De[o?1:0],[e,t],[Ht])},addStartTransactionListener:e=>Ze(e,Xe),addWillFinishTransactionListener:e=>Ze(e,Ye[0]),addDidFinishTransactionListener:e=>Ze(e,Ye[1]),callListener:e=>(tt(e),Ts),delListener:e=>(et(e),Ts),getListenerStats:()=>({}),createStore:we,addListener:Ze,callListeners:_e};return B({[u]:[0,ke],[h]:[0,Ae],[d]:[1,Me,[Ht]],[d+V]:[1,Ne,[Ht]],[g]:[1,Pe,[Ht]],[T]:[1,Be,[Ht]],[f]:[2,We,[Ht,Qt]],[V]:[2,$e,[Ht,Qt]],[b]:[3,qe,[Ht,Qt,Xt],e=>he(Yt(...e))],InvalidCell:[3,Ge],[S]:[0,Ke],[v]:[0,Qe],[C]:[1,Ue,[_t],e=>he(es(e[0]))],InvalidValue:[1,He]},(([e,t,s,l],n)=>{Ts["add"+n+"Listener"]=(...n)=>Ze(n[e],t[n[e+1]?1:0],e>0?x(n,0,e):void 0,s,l)})),A(Ts)};e.createStore=we},"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).TinyBaseStore={});
Binary file