cross-state 1.2.0 → 1.3.0

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 (67) hide show
  1. package/dist/{diff-DFvRd-Gf.d.ts → diff-BMTUoQbh.d.ts} +2 -2
  2. package/dist/{diff-CAQaunfv.d.cts → diff-KThbuSdG.d.cts} +2 -2
  3. package/dist/index.cjs +3 -3
  4. package/dist/index.d.cts +5 -5
  5. package/dist/index.d.ts +5 -5
  6. package/dist/index.js +3 -3
  7. package/dist/mutative/index.d.cts +2 -2
  8. package/dist/mutative/index.d.ts +2 -2
  9. package/dist/mutative/register.cjs +1 -1
  10. package/dist/mutative/register.d.cts +2 -2
  11. package/dist/mutative/register.d.ts +2 -2
  12. package/dist/mutative/register.js +1 -1
  13. package/dist/{mutativeMethods-C8VcZWED.d.cts → mutativeMethods-B7SX-j8W.d.cts} +2 -2
  14. package/dist/{mutativeMethods-BT1Cim3p.d.ts → mutativeMethods-B_5NowHX.d.ts} +2 -2
  15. package/dist/{patchMethods-CixmHmNt.d.ts → patchMethods-6lMoH5Yl.d.ts} +3 -3
  16. package/dist/{patchMethods-BmyvvHnP.d.cts → patchMethods-RjlgKjla.d.cts} +3 -3
  17. package/dist/patches/index.d.cts +3 -3
  18. package/dist/patches/index.d.ts +3 -3
  19. package/dist/patches/register.cjs +1 -1
  20. package/dist/patches/register.d.cts +3 -3
  21. package/dist/patches/register.d.ts +3 -3
  22. package/dist/patches/register.js +1 -1
  23. package/dist/persist/register.cjs +2 -2
  24. package/dist/persist/register.d.cts +2 -2
  25. package/dist/persist/register.d.ts +2 -2
  26. package/dist/persist/register.js +2 -2
  27. package/dist/{persist-DMbVdqS_.cjs → persist-4m05KVTt.cjs} +5 -5
  28. package/dist/persist-4m05KVTt.cjs.map +1 -0
  29. package/dist/{persist-Bunx8xfQ.js → persist-BepySE7U.js} +5 -5
  30. package/dist/persist-BepySE7U.js.map +1 -0
  31. package/dist/{persist-DyI_JLxZ.d.ts → persist-BpqycKqI.d.ts} +2 -2
  32. package/dist/{persist-CHRYYolx.d.cts → persist-CSKaACQ7.d.cts} +2 -2
  33. package/dist/react/index.cjs +6 -9
  34. package/dist/react/index.cjs.map +1 -1
  35. package/dist/react/index.d.cts +3 -3
  36. package/dist/react/index.d.ts +3 -3
  37. package/dist/react/index.js +6 -9
  38. package/dist/react/index.js.map +1 -1
  39. package/dist/react/register.cjs +3 -3
  40. package/dist/react/register.d.cts +3 -3
  41. package/dist/react/register.d.ts +3 -3
  42. package/dist/react/register.js +3 -3
  43. package/dist/{scope-CESkVNvI.d.cts → scope-B2hakm8Z.d.cts} +2 -2
  44. package/dist/{scope-C1bcfK8e.cjs → scope-D1ECH_XM.cjs} +2 -2
  45. package/dist/scope-D1ECH_XM.cjs.map +1 -0
  46. package/dist/{scope-DJXSRsGy.d.ts → scope-GDM3ftpp.d.ts} +2 -2
  47. package/dist/{scope-CKGsCVn3.js → scope-aMWojX__.js} +2 -2
  48. package/dist/scope-aMWojX__.js.map +1 -0
  49. package/dist/{store-XcnTdeiJ.d.cts → store-BAutdl4v.d.cts} +6 -3
  50. package/dist/{store-C1NYHLgR.cjs → store-Bcb8hcQj.cjs} +59 -4
  51. package/dist/store-Bcb8hcQj.cjs.map +1 -0
  52. package/dist/{store-v3RYWzVg.js → store-BpT1JkhI.js} +59 -4
  53. package/dist/store-BpT1JkhI.js.map +1 -0
  54. package/dist/{store-BRHFhRPm.d.ts → store-T0xgcd1b.d.ts} +6 -3
  55. package/dist/{storeMethods-BBq6PMbA.js → storeMethods-B4Dkqiq9.js} +2 -2
  56. package/dist/{storeMethods-BBq6PMbA.js.map → storeMethods-B4Dkqiq9.js.map} +1 -1
  57. package/dist/{storeMethods-DmseqZrw.d.ts → storeMethods-Bi_q7EAY.d.ts} +3 -3
  58. package/dist/{storeMethods-D71fizqI.d.cts → storeMethods-ChKICR6o.d.cts} +3 -3
  59. package/dist/{storeMethods-XSKXj4TX.cjs → storeMethods-DvvwXRlz.cjs} +2 -2
  60. package/dist/{storeMethods-XSKXj4TX.cjs.map → storeMethods-DvvwXRlz.cjs.map} +1 -1
  61. package/package.json +7 -7
  62. package/dist/persist-Bunx8xfQ.js.map +0 -1
  63. package/dist/persist-DMbVdqS_.cjs.map +0 -1
  64. package/dist/scope-C1bcfK8e.cjs.map +0 -1
  65. package/dist/scope-CKGsCVn3.js.map +0 -1
  66. package/dist/store-C1NYHLgR.cjs.map +0 -1
  67. package/dist/store-v3RYWzVg.js.map +0 -1
@@ -1,4 +1,4 @@
1
- import { M as KeyType } from "./store-BRHFhRPm.js";
1
+ import { M as KeyType } from "./store-T0xgcd1b.js";
2
2
 
3
3
  //#region src/lib/diff.d.ts
4
4
  type Patch = {
@@ -19,4 +19,4 @@ interface DiffOptions {
19
19
  declare function diff(a: any, b: any, options?: DiffOptions): [patches: Patch[], reversePatches: Patch[]];
20
20
  //#endregion
21
21
  export { Patch as n, diff as r, DiffOptions as t };
22
- //# sourceMappingURL=diff-DFvRd-Gf.d.ts.map
22
+ //# sourceMappingURL=diff-BMTUoQbh.d.ts.map
@@ -1,4 +1,4 @@
1
- import { M as KeyType } from "./store-XcnTdeiJ.cjs";
1
+ import { M as KeyType } from "./store-BAutdl4v.cjs";
2
2
 
3
3
  //#region src/lib/diff.d.ts
4
4
  type Patch = {
@@ -19,4 +19,4 @@ interface DiffOptions {
19
19
  declare function diff(a: any, b: any, options?: DiffOptions): [patches: Patch[], reversePatches: Patch[]];
20
20
  //#endregion
21
21
  export { Patch as n, diff as r, DiffOptions as t };
22
- //# sourceMappingURL=diff-CAQaunfv.d.cts.map
22
+ //# sourceMappingURL=diff-KThbuSdG.d.cts.map
package/dist/index.cjs CHANGED
@@ -1,9 +1,9 @@
1
- const require_store = require('./store-C1NYHLgR.cjs');
1
+ const require_store = require('./store-Bcb8hcQj.cjs');
2
2
  const require_propAccess = require('./propAccess-C2AIn9RC.cjs');
3
- const require_scope = require('./scope-C1bcfK8e.cjs');
3
+ const require_scope = require('./scope-D1ECH_XM.cjs');
4
4
  const require_patchMethods = require('./patchMethods-B7Hm5-Qh.cjs');
5
5
  const require_extendedJson = require('./extendedJson-ursQ8DbQ.cjs');
6
- const require_persist = require('./persist-DMbVdqS_.cjs');
6
+ const require_persist = require('./persist-4m05KVTt.cjs');
7
7
 
8
8
  //#region src/core/pagedCache.ts
9
9
  var PagedCache = class PagedCache extends require_scope.Cache {
package/dist/index.d.cts CHANGED
@@ -1,7 +1,7 @@
1
- import { _ as ValueState, a as CacheFunction, c as CreateCacheResult, d as ResourceGroup, f as allResources, g as PendingState, h as ErrorState, i as CacheBundle, l as createCache, m as CacheState, n as createScope, o as CacheGetOptions, p as createResourceGroup, r as Cache, s as CacheOptions, t as Scope, u as Resource } from "./scope-CESkVNvI.cjs";
2
- import { B as Value, C as Selector, D as UpdateFunction, E as UpdateFrom, F as PathAsString, I as SettablePath, K as Constrain, L as SettablePathAsArray, M as KeyType, N as Path, O as Use, P as PathAsArray, R as SettablePathAsString, S as Listener, T as Update, _ as Connection, a as StoreOptions, b as Duration, c as arrayMethods, d as setMethods, f as AsyncConnectionActions, g as Cancel, h as CalculationActions, i as StoreMethods, l as mapMethods, m as BaseConnectionActions, o as StoreOptionsWithMethods, p as AsyncUpdateFunction, r as Store, s as createStore, t as BoundStoreMethods, u as recordMethods, v as ConnectionActions, w as SubscribeOptions, x as Effect, y as DisposableCancel, z as SettableValue } from "./store-XcnTdeiJ.cjs";
3
- import { n as Patch, r as diff } from "./diff-CAQaunfv.cjs";
4
- import { a as PersistStorageBase, c as PersistStorageWithListItems, i as PersistStorage, n as PersistOptions, o as PersistStorageWithKeys, r as persist, s as PersistStorageWithLength, t as Persist } from "./persist-CHRYYolx.cjs";
1
+ import { _ as ValueState, a as CacheFunction, c as CreateCacheResult, d as ResourceGroup, f as allResources, g as PendingState, h as ErrorState, i as CacheBundle, l as createCache, m as CacheState, n as createScope, o as CacheGetOptions, p as createResourceGroup, r as Cache, s as CacheOptions, t as Scope, u as Resource } from "./scope-B2hakm8Z.cjs";
2
+ import { B as Value, C as Selector, D as UpdateFunction, E as UpdateFrom, F as PathAsString, I as SettablePath, K as Constrain, L as SettablePathAsArray, M as KeyType, N as Path, O as Use, P as PathAsArray, R as SettablePathAsString, S as Listener, T as Update, _ as Connection, a as StoreOptions, b as Duration, c as arrayMethods, d as setMethods, f as AsyncConnectionActions, g as Cancel, h as CalculationActions, i as StoreMethods, l as mapMethods, m as BaseConnectionActions, o as StoreOptionsWithMethods, p as AsyncUpdateFunction, r as Store, s as createStore, t as BoundStoreMethods, u as recordMethods, v as ConnectionActions, w as SubscribeOptions, x as Effect, y as DisposableCancel, z as SettableValue } from "./store-BAutdl4v.cjs";
3
+ import { n as Patch, r as diff } from "./diff-KThbuSdG.cjs";
4
+ import { a as PersistStorageBase, c as PersistStorageWithListItems, i as PersistStorage, n as PersistOptions, o as PersistStorageWithKeys, r as persist, s as PersistStorageWithLength, t as Persist } from "./persist-CSKaACQ7.cjs";
5
5
 
6
6
  //#region src/core/pagedCache.d.ts
7
7
  interface PageCacheFunctionProps<T> extends CalculationActions<Promise<PagedCacheState<T>>> {
@@ -63,7 +63,7 @@ declare const createPagedCache: typeof createPaged & {
63
63
  //#region src/lib/applyPatches.d.ts
64
64
  declare function applyPatches<T>(target: T, ...patches: Patch[]): T;
65
65
  //#endregion
66
- //#region src/lib/calcDuration.d.ts
66
+ //#region src/lib/duration.d.ts
67
67
  declare function calcDuration(t: Duration): number;
68
68
  //#endregion
69
69
  //#region src/lib/equals.d.ts
package/dist/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
- import { _ as ValueState, a as CacheFunction, c as CreateCacheResult, d as ResourceGroup, f as allResources, g as PendingState, h as ErrorState, i as CacheBundle, l as createCache, m as CacheState, n as createScope, o as CacheGetOptions, p as createResourceGroup, r as Cache, s as CacheOptions, t as Scope, u as Resource } from "./scope-DJXSRsGy.js";
2
- import { B as Value, C as Selector, D as UpdateFunction, E as UpdateFrom, F as PathAsString, I as SettablePath, K as Constrain, L as SettablePathAsArray, M as KeyType, N as Path, O as Use, P as PathAsArray, R as SettablePathAsString, S as Listener, T as Update, _ as Connection, a as StoreOptions, b as Duration, c as arrayMethods, d as setMethods, f as AsyncConnectionActions, g as Cancel, h as CalculationActions, i as StoreMethods, l as mapMethods, m as BaseConnectionActions, o as StoreOptionsWithMethods, p as AsyncUpdateFunction, r as Store, s as createStore, t as BoundStoreMethods, u as recordMethods, v as ConnectionActions, w as SubscribeOptions, x as Effect, y as DisposableCancel, z as SettableValue } from "./store-BRHFhRPm.js";
3
- import { n as Patch, r as diff } from "./diff-DFvRd-Gf.js";
4
- import { a as PersistStorageBase, c as PersistStorageWithListItems, i as PersistStorage, n as PersistOptions, o as PersistStorageWithKeys, r as persist, s as PersistStorageWithLength, t as Persist } from "./persist-DyI_JLxZ.js";
1
+ import { _ as ValueState, a as CacheFunction, c as CreateCacheResult, d as ResourceGroup, f as allResources, g as PendingState, h as ErrorState, i as CacheBundle, l as createCache, m as CacheState, n as createScope, o as CacheGetOptions, p as createResourceGroup, r as Cache, s as CacheOptions, t as Scope, u as Resource } from "./scope-GDM3ftpp.js";
2
+ import { B as Value, C as Selector, D as UpdateFunction, E as UpdateFrom, F as PathAsString, I as SettablePath, K as Constrain, L as SettablePathAsArray, M as KeyType, N as Path, O as Use, P as PathAsArray, R as SettablePathAsString, S as Listener, T as Update, _ as Connection, a as StoreOptions, b as Duration, c as arrayMethods, d as setMethods, f as AsyncConnectionActions, g as Cancel, h as CalculationActions, i as StoreMethods, l as mapMethods, m as BaseConnectionActions, o as StoreOptionsWithMethods, p as AsyncUpdateFunction, r as Store, s as createStore, t as BoundStoreMethods, u as recordMethods, v as ConnectionActions, w as SubscribeOptions, x as Effect, y as DisposableCancel, z as SettableValue } from "./store-T0xgcd1b.js";
3
+ import { n as Patch, r as diff } from "./diff-BMTUoQbh.js";
4
+ import { a as PersistStorageBase, c as PersistStorageWithListItems, i as PersistStorage, n as PersistOptions, o as PersistStorageWithKeys, r as persist, s as PersistStorageWithLength, t as Persist } from "./persist-BpqycKqI.js";
5
5
 
6
6
  //#region src/core/pagedCache.d.ts
7
7
  interface PageCacheFunctionProps<T> extends CalculationActions<Promise<PagedCacheState<T>>> {
@@ -63,7 +63,7 @@ declare const createPagedCache: typeof createPaged & {
63
63
  //#region src/lib/applyPatches.d.ts
64
64
  declare function applyPatches<T>(target: T, ...patches: Patch[]): T;
65
65
  //#endregion
66
- //#region src/lib/calcDuration.d.ts
66
+ //#region src/lib/duration.d.ts
67
67
  declare function calcDuration(t: Duration): number;
68
68
  //#endregion
69
69
  //#region src/lib/equals.d.ts
package/dist/index.js CHANGED
@@ -1,9 +1,9 @@
1
- import { a as mapMethods, h as autobind, i as arrayMethods, m as calcDuration, n as createStore, o as recordMethods, s as setMethods, t as Store } from "./store-v3RYWzVg.js";
1
+ import { a as mapMethods, h as autobind, i as arrayMethods, m as calcDuration, n as createStore, o as recordMethods, s as setMethods, t as Store } from "./store-BpT1JkhI.js";
2
2
  import { a as set, c as deepEqual, l as shallowEqual, n as get, u as strictEqual } from "./propAccess-DvWFpYoj.js";
3
- import { a as defaultCacheOptions, c as allResources, d as hash, f as simpleHash, i as createCache, l as createResourceGroup, n as createScope, o as internalCreate, r as Cache, s as ResourceGroup, t as Scope, u as InstanceCache } from "./scope-CKGsCVn3.js";
3
+ import { a as defaultCacheOptions, c as allResources, d as hash, f as simpleHash, i as createCache, l as createResourceGroup, n as createScope, o as internalCreate, r as Cache, s as ResourceGroup, t as Scope, u as InstanceCache } from "./scope-aMWojX__.js";
4
4
  import { i as applyPatches, r as diff } from "./patchMethods-iK2F87G0.js";
5
5
  import { i as toExtendedJsonString, n as fromExtendedJsonString, r as toExtendedJson, t as fromExtendedJson } from "./extendedJson-Dv9q6rps.js";
6
- import { t as persist } from "./persist-Bunx8xfQ.js";
6
+ import { t as persist } from "./persist-BepySE7U.js";
7
7
 
8
8
  //#region src/core/pagedCache.ts
9
9
  var PagedCache = class PagedCache extends Cache {
@@ -1,3 +1,3 @@
1
- import "../store-XcnTdeiJ.cjs";
2
- import { n as mutativeMethods, t as Mutation } from "../mutativeMethods-C8VcZWED.cjs";
1
+ import "../store-BAutdl4v.cjs";
2
+ import { n as mutativeMethods, t as Mutation } from "../mutativeMethods-B7SX-j8W.cjs";
3
3
  export { type Mutation, mutativeMethods };
@@ -1,3 +1,3 @@
1
- import "../store-BRHFhRPm.js";
2
- import { n as mutativeMethods, t as Mutation } from "../mutativeMethods-BT1Cim3p.js";
1
+ import "../store-T0xgcd1b.js";
2
+ import { n as mutativeMethods, t as Mutation } from "../mutativeMethods-B_5NowHX.js";
3
3
  export { type Mutation, mutativeMethods };
@@ -1,5 +1,5 @@
1
1
  require('../path-B-Rq5q6m.cjs');
2
- const require_store = require('../store-C1NYHLgR.cjs');
2
+ const require_store = require('../store-Bcb8hcQj.cjs');
3
3
  require('../propAccess-C2AIn9RC.cjs');
4
4
  const require_mutativeMethods = require('../mutativeMethods-CkNycpO9.cjs');
5
5
 
@@ -1,5 +1,5 @@
1
- import "../store-XcnTdeiJ.cjs";
2
- import { n as mutativeMethods } from "../mutativeMethods-C8VcZWED.cjs";
1
+ import "../store-BAutdl4v.cjs";
2
+ import { n as mutativeMethods } from "../mutativeMethods-B7SX-j8W.cjs";
3
3
 
4
4
  //#region src/mutative/register.d.ts
5
5
  type MutativeMethods = typeof mutativeMethods;
@@ -1,5 +1,5 @@
1
- import "../store-BRHFhRPm.js";
2
- import { n as mutativeMethods } from "../mutativeMethods-BT1Cim3p.js";
1
+ import "../store-T0xgcd1b.js";
2
+ import { n as mutativeMethods } from "../mutativeMethods-B_5NowHX.js";
3
3
 
4
4
  //#region src/mutative/register.d.ts
5
5
  type MutativeMethods = typeof mutativeMethods;
@@ -1,4 +1,4 @@
1
- import { h as autobind, t as Store } from "../store-v3RYWzVg.js";
1
+ import { h as autobind, t as Store } from "../store-BpT1JkhI.js";
2
2
  import "../propAccess-DvWFpYoj.js";
3
3
  import "../path-CyYq74W8.js";
4
4
  import { t as mutativeMethods } from "../mutativeMethods-Jowr0Znn.js";
@@ -1,4 +1,4 @@
1
- import { B as Value, K as Constrain, N as Path, r as Store } from "./store-XcnTdeiJ.cjs";
1
+ import { B as Value, K as Constrain, N as Path, r as Store } from "./store-BAutdl4v.cjs";
2
2
  import { Draft } from "mutative";
3
3
 
4
4
  //#region src/mutative/mutativeMethods.d.ts
@@ -10,4 +10,4 @@ declare const mutativeMethods: {
10
10
  };
11
11
  //#endregion
12
12
  export { mutativeMethods as n, Mutation as t };
13
- //# sourceMappingURL=mutativeMethods-C8VcZWED.d.cts.map
13
+ //# sourceMappingURL=mutativeMethods-B7SX-j8W.d.cts.map
@@ -1,4 +1,4 @@
1
- import { B as Value, K as Constrain, N as Path, r as Store } from "./store-BRHFhRPm.js";
1
+ import { B as Value, K as Constrain, N as Path, r as Store } from "./store-T0xgcd1b.js";
2
2
  import { Draft } from "mutative";
3
3
 
4
4
  //#region src/mutative/mutativeMethods.d.ts
@@ -10,4 +10,4 @@ declare const mutativeMethods: {
10
10
  };
11
11
  //#endregion
12
12
  export { mutativeMethods as n, Mutation as t };
13
- //# sourceMappingURL=mutativeMethods-BT1Cim3p.d.ts.map
13
+ //# sourceMappingURL=mutativeMethods-B_5NowHX.d.ts.map
@@ -1,5 +1,5 @@
1
- import { g as Cancel, r as Store, w as SubscribeOptions, y as DisposableCancel } from "./store-BRHFhRPm.js";
2
- import { n as Patch, t as DiffOptions } from "./diff-DFvRd-Gf.js";
1
+ import { g as Cancel, r as Store, w as SubscribeOptions, y as DisposableCancel } from "./store-T0xgcd1b.js";
2
+ import { n as Patch, t as DiffOptions } from "./diff-BMTUoQbh.js";
3
3
 
4
4
  //#region src/patches/patchMethods.d.ts
5
5
  interface SyncMessage {
@@ -45,4 +45,4 @@ declare const patchMethods: {
45
45
  };
46
46
  //#endregion
47
47
  export { SyncMessage as n, patchMethods as r, SubscribePatchOptions as t };
48
- //# sourceMappingURL=patchMethods-CixmHmNt.d.ts.map
48
+ //# sourceMappingURL=patchMethods-6lMoH5Yl.d.ts.map
@@ -1,5 +1,5 @@
1
- import { g as Cancel, r as Store, w as SubscribeOptions, y as DisposableCancel } from "./store-XcnTdeiJ.cjs";
2
- import { n as Patch, t as DiffOptions } from "./diff-CAQaunfv.cjs";
1
+ import { g as Cancel, r as Store, w as SubscribeOptions, y as DisposableCancel } from "./store-BAutdl4v.cjs";
2
+ import { n as Patch, t as DiffOptions } from "./diff-KThbuSdG.cjs";
3
3
 
4
4
  //#region src/patches/patchMethods.d.ts
5
5
  interface SyncMessage {
@@ -45,4 +45,4 @@ declare const patchMethods: {
45
45
  };
46
46
  //#endregion
47
47
  export { SyncMessage as n, patchMethods as r, SubscribePatchOptions as t };
48
- //# sourceMappingURL=patchMethods-BmyvvHnP.d.cts.map
48
+ //# sourceMappingURL=patchMethods-RjlgKjla.d.cts.map
@@ -1,4 +1,4 @@
1
- import "../store-XcnTdeiJ.cjs";
2
- import "../diff-CAQaunfv.cjs";
3
- import { n as SyncMessage, r as patchMethods, t as SubscribePatchOptions } from "../patchMethods-BmyvvHnP.cjs";
1
+ import "../store-BAutdl4v.cjs";
2
+ import "../diff-KThbuSdG.cjs";
3
+ import { n as SyncMessage, r as patchMethods, t as SubscribePatchOptions } from "../patchMethods-RjlgKjla.cjs";
4
4
  export { type SubscribePatchOptions, type SyncMessage, patchMethods };
@@ -1,4 +1,4 @@
1
- import "../store-BRHFhRPm.js";
2
- import "../diff-DFvRd-Gf.js";
3
- import { n as SyncMessage, r as patchMethods, t as SubscribePatchOptions } from "../patchMethods-CixmHmNt.js";
1
+ import "../store-T0xgcd1b.js";
2
+ import "../diff-BMTUoQbh.js";
3
+ import { n as SyncMessage, r as patchMethods, t as SubscribePatchOptions } from "../patchMethods-6lMoH5Yl.js";
4
4
  export { type SubscribePatchOptions, type SyncMessage, patchMethods };
@@ -1,4 +1,4 @@
1
- const require_store = require('../store-C1NYHLgR.cjs');
1
+ const require_store = require('../store-Bcb8hcQj.cjs');
2
2
  require('../propAccess-C2AIn9RC.cjs');
3
3
  const require_patchMethods = require('../patchMethods-B7Hm5-Qh.cjs');
4
4
  require('../extendedJson-ursQ8DbQ.cjs');
@@ -1,6 +1,6 @@
1
- import "../store-XcnTdeiJ.cjs";
2
- import "../diff-CAQaunfv.cjs";
3
- import { r as patchMethods } from "../patchMethods-BmyvvHnP.cjs";
1
+ import "../store-BAutdl4v.cjs";
2
+ import "../diff-KThbuSdG.cjs";
3
+ import { r as patchMethods } from "../patchMethods-RjlgKjla.cjs";
4
4
 
5
5
  //#region src/patches/register.d.ts
6
6
  type PatchMethods = typeof patchMethods;
@@ -1,6 +1,6 @@
1
- import "../store-BRHFhRPm.js";
2
- import "../diff-DFvRd-Gf.js";
3
- import { r as patchMethods } from "../patchMethods-CixmHmNt.js";
1
+ import "../store-T0xgcd1b.js";
2
+ import "../diff-BMTUoQbh.js";
3
+ import { r as patchMethods } from "../patchMethods-6lMoH5Yl.js";
4
4
 
5
5
  //#region src/patches/register.d.ts
6
6
  type PatchMethods = typeof patchMethods;
@@ -1,4 +1,4 @@
1
- import { h as autobind, t as Store } from "../store-v3RYWzVg.js";
1
+ import { h as autobind, t as Store } from "../store-BpT1JkhI.js";
2
2
  import "../propAccess-DvWFpYoj.js";
3
3
  import { t as patchMethods } from "../patchMethods-iK2F87G0.js";
4
4
  import "../extendedJson-Dv9q6rps.js";
@@ -1,8 +1,8 @@
1
- const require_store = require('../store-C1NYHLgR.cjs');
1
+ const require_store = require('../store-Bcb8hcQj.cjs');
2
2
  require('../propAccess-C2AIn9RC.cjs');
3
3
  require('../patchMethods-B7Hm5-Qh.cjs');
4
4
  require('../extendedJson-ursQ8DbQ.cjs');
5
- const require_persist = require('../persist-DMbVdqS_.cjs');
5
+ const require_persist = require('../persist-4m05KVTt.cjs');
6
6
 
7
7
  //#region src/persist/register.ts
8
8
  require_store.Store.addHook((store) => {
@@ -1,5 +1,5 @@
1
- import "../store-XcnTdeiJ.cjs";
2
- import { n as PersistOptions, t as Persist } from "../persist-CHRYYolx.cjs";
1
+ import "../store-BAutdl4v.cjs";
2
+ import { n as PersistOptions, t as Persist } from "../persist-CSKaACQ7.cjs";
3
3
 
4
4
  //#region src/persist/register.d.ts
5
5
  declare module ".." {
@@ -1,5 +1,5 @@
1
- import "../store-BRHFhRPm.js";
2
- import { n as PersistOptions, t as Persist } from "../persist-DyI_JLxZ.js";
1
+ import "../store-T0xgcd1b.js";
2
+ import { n as PersistOptions, t as Persist } from "../persist-BpqycKqI.js";
3
3
 
4
4
  //#region src/persist/register.d.ts
5
5
  declare module ".." {
@@ -1,8 +1,8 @@
1
- import { t as Store } from "../store-v3RYWzVg.js";
1
+ import { t as Store } from "../store-BpT1JkhI.js";
2
2
  import "../propAccess-DvWFpYoj.js";
3
3
  import "../patchMethods-iK2F87G0.js";
4
4
  import "../extendedJson-Dv9q6rps.js";
5
- import { t as persist } from "../persist-Bunx8xfQ.js";
5
+ import { t as persist } from "../persist-BepySE7U.js";
6
6
 
7
7
  //#region src/persist/register.ts
8
8
  Store.addHook((store) => {
@@ -1,4 +1,4 @@
1
- const require_store = require('./store-C1NYHLgR.cjs');
1
+ const require_store = require('./store-Bcb8hcQj.cjs');
2
2
  const require_propAccess = require('./propAccess-C2AIn9RC.cjs');
3
3
  const require_patchMethods = require('./patchMethods-B7Hm5-Qh.cjs');
4
4
  const require_extendedJson = require('./extendedJson-ursQ8DbQ.cjs');
@@ -96,17 +96,17 @@ var Persist = class {
96
96
  this.paths = (options.paths ?? []).map((p) => {
97
97
  if (isPlainPath(p)) return {
98
98
  path: require_propAccess.castArrayPath(p),
99
- throttle: options.throttle && require_store.calcDuration(options.throttle)
99
+ throttle: options.throttle ? require_store.calcDuration(options.throttle) : void 0
100
100
  };
101
101
  const _p = p;
102
102
  return {
103
103
  path: require_propAccess.castArrayPath(_p.path),
104
- throttle: (_p.throttle && require_store.calcDuration(_p.throttle)) ?? (options.throttle && require_store.calcDuration(options.throttle))
104
+ throttle: (_p.throttle ? require_store.calcDuration(_p.throttle) : void 0) ?? (options.throttle ? require_store.calcDuration(options.throttle) : void 0)
105
105
  };
106
106
  }).sort((a, b) => b.path.length - a.path.length);
107
107
  if (this.paths.length === 0) this.paths.push({
108
108
  path: ["*"],
109
- throttle: options.throttle && require_store.calcDuration(options.throttle)
109
+ throttle: options.throttle ? require_store.calcDuration(options.throttle) : void 0
110
110
  });
111
111
  this.initialized = new Promise((resolve) => {
112
112
  this.resolveInitialized = resolve;
@@ -257,4 +257,4 @@ Object.defineProperty(exports, 'persist', {
257
257
  return persist;
258
258
  }
259
259
  });
260
- //# sourceMappingURL=persist-DMbVdqS_.cjs.map
260
+ //# sourceMappingURL=persist-4m05KVTt.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"persist-4m05KVTt.cjs","names":["isPromise","value","entries: Map<KeyType, unknown>","path","isPromise","store: Store<T>","options: PersistOptions<T>","queue","castArrayPath","calcDuration","subscribePatches","path","shallowEqual","isPromise","fromExtendedJsonString","remove","set","get","toExtendedJsonString"],"sources":["../src/lib/promiseChain.ts","../src/persist/persistPathHelpers.ts","../src/persist/persistStorage.ts","../src/persist/persist.ts"],"sourcesContent":["import isPromise from '@lib/isPromise';\n\nexport interface Chain<T> {\n value: T;\n next<S>(fn: (value: Awaited<T>) => S): T extends Promise<any> ? Chain<Promise<S>> : Chain<S>;\n}\n\nexport default function promiseChain<T>(value: T | (() => T)): Chain<T> {\n if (value instanceof Function) {\n value = value();\n }\n\n return {\n value,\n next(fn) {\n const next = isPromise(value)\n ? value.then((value) => fn(value as Awaited<T>))\n : fn(value as Awaited<T>);\n\n return promiseChain(next) as any;\n },\n };\n}\n","import type { KeyType } from '@lib/path';\n\nexport const isAncestor = (ancestor: KeyType[], path: KeyType[]): boolean => {\n return (\n ancestor.length <= path.length &&\n ancestor.every((v, i) => v === '*' || path[i] === '*' || v === path[i])\n );\n};\n\nexport const split = (value: any, path: KeyType[]): { path: KeyType[]; value: unknown }[] => {\n const [first, ...rest] = path;\n if (first === undefined) return [{ path: [], value }];\n\n let entries: Map<KeyType, unknown>;\n if (value instanceof Map) {\n entries = value;\n } else if (value instanceof Set) {\n entries = new Map([...value].map((v, i) => [i, v]));\n } else if (Array.isArray(value)) {\n entries = new Map(value.map((v, i) => [i, v]));\n } else if (typeof value === 'object' && value !== null) {\n entries = new Map(Object.entries(value));\n } else {\n return [{ path: [], value }];\n }\n\n if (first === '*') {\n return [...entries].flatMap(([k, v]) =>\n split(v, rest).map(({ path, value }) => ({ path: [k, ...path], value })),\n );\n }\n\n const subValue = entries.get(first);\n if (subValue === undefined) return [{ path: [], value }];\n\n return split(subValue, rest).map(({ path, value }) => ({ path: [first, ...path], value }));\n};\n","import isPromise from '@lib/isPromise';\nimport promiseChain from '@lib/promiseChain';\n\nexport interface PersistStorageBase {\n getItem: (key: string) => string | null | Promise<string | null>;\n setItem: (key: string, value: string) => void | Promise<unknown>;\n removeItem: (key: string) => void | Promise<unknown>;\n}\n\nexport interface PersistStorageWithKeys extends PersistStorageBase {\n keys: () => string[] | Promise<string[]>;\n}\n\nexport interface PersistStorageWithLength extends PersistStorageBase {\n length: number | (() => number | Promise<number>);\n key: (keyIndex: number) => string | null | Promise<string | null>;\n}\n\nexport interface PersistStorageWithListItems extends PersistStorageBase {\n listItems: () => Map<string, string> | Promise<Map<string, string>>;\n}\n\nexport type PersistStorage =\n | PersistStorageWithKeys\n | PersistStorageWithLength\n | PersistStorageWithListItems;\n\nexport function normalizeStorage(storage: PersistStorage): PersistStorageWithListItems {\n return {\n getItem: storage.getItem.bind(storage),\n setItem: storage.setItem.bind(storage),\n removeItem: storage.removeItem.bind(storage),\n\n listItems() {\n if ('listItems' in storage) {\n return storage.listItems();\n }\n\n return promiseChain(() => {\n if ('keys' in storage) {\n return storage.keys();\n } else {\n return promiseChain(\n storage.length instanceof Function ? storage.length() : storage.length,\n )\n .next((length) => {\n const keys = Array.from({ length }, (_, index) => storage.key(index));\n return keys.some(isPromise) ? Promise.all(keys) : (keys as (string | null)[]);\n })\n .next((keys) => {\n return keys.filter((key): key is string => typeof key === 'string');\n }).value;\n }\n })\n .next((keys) => {\n const results = keys.map(\n (key) =>\n promiseChain(storage.getItem(key)).next((value) => [key, value] as const).value,\n );\n\n return results.some(isPromise)\n ? Promise.all(results)\n : (results as [string, string | null][]);\n })\n .next((results) => {\n return new Map(results.filter(([, value]) => value !== null) as [string, string][]);\n }).value;\n },\n };\n}\n","import { type Cancel, type Duration, type Store } from '@core';\nimport { calcDuration } from '@lib/duration';\nimport { shallowEqual } from '@lib/equals';\nimport { fromExtendedJsonString, toExtendedJsonString } from '@lib/extendedJson';\nimport isPromise from '@lib/isPromise';\nimport type { KeyType, WildcardPath } from '@lib/path';\nimport promiseChain from '@lib/promiseChain';\nimport { castArrayPath, get, remove, set } from '@lib/propAccess';\nimport { queue } from '@lib/queue';\nimport { subscribePatches } from '@patches/patchMethods';\nimport { isAncestor, split } from '@persist/persistPathHelpers';\nimport {\n normalizeStorage,\n type PersistStorage,\n type PersistStorageWithListItems,\n} from './persistStorage';\n\ntype PathOption<T> =\n | WildcardPath<T>\n | {\n path: WildcardPath<T>;\n // throttle?: Duration;\n };\n\ntype Key = { type: 'internal'; path: string } | { type: 'data'; path: KeyType[] };\n\nexport interface PersistOptions<T> {\n id: string;\n storage: PersistStorage;\n paths?: PathOption<T>[];\n throttle?: Duration;\n persistInitialState?: boolean;\n}\n\nexport class Persist<T> {\n readonly storage: PersistStorageWithListItems;\n readonly [Symbol.dispose]!: Cancel;\n\n readonly paths: {\n path: KeyType[];\n throttle?: number;\n }[];\n\n readonly initialized: Promise<void>;\n\n private resolveInitialized?: () => void;\n\n private channel: BroadcastChannel;\n\n private queue = queue();\n\n private handles = new Set<Cancel>();\n\n private stopped = false;\n\n private updateInProgress = new Map<string, unknown>();\n\n private prefix;\n\n constructor(\n public readonly store: Store<T>,\n public readonly options: PersistOptions<T>,\n ) {\n this.storage = normalizeStorage(options.storage);\n this.channel = new BroadcastChannel(`cross-state-persist_${options.id}`);\n this.prefix = `${options.id}:`;\n\n if (Symbol.dispose) {\n this[Symbol.dispose] = () => this.stop();\n }\n\n this.paths = (options.paths ?? [])\n .map<{\n path: KeyType[];\n throttle?: number;\n }>((p) => {\n if (isPlainPath(p)) {\n return {\n path: castArrayPath(p),\n throttle: options.throttle ? calcDuration(options.throttle) : undefined,\n };\n }\n\n const _p = p as { path: KeyType[]; throttle?: Duration };\n\n return {\n path: castArrayPath(_p.path),\n throttle:\n (_p.throttle ? calcDuration(_p.throttle) : undefined) ??\n (options.throttle ? calcDuration(options.throttle) : undefined),\n };\n })\n .sort((a, b) => b.path.length - a.path.length);\n\n if (this.paths.length === 0) {\n this.paths.push({\n path: ['*'],\n throttle: options.throttle ? calcDuration(options.throttle) : undefined,\n });\n }\n\n this.initialized = new Promise((resolve) => {\n this.resolveInitialized = resolve;\n });\n\n this.watchStore();\n this.watchStorage();\n }\n\n private watchStore() {\n const throttle = Math.min(...this.paths.map((p) => p.throttle ?? 0)) || undefined;\n\n const cancel = subscribePatches.apply(this.store as Store<unknown>, [\n (patches, reversePatches) => {\n let i = 0;\n for (const patch of patches) {\n const reversePatch = reversePatches[i++];\n\n const stringPath = JSON.stringify(patch.path);\n if (\n this.updateInProgress.has(stringPath) &&\n this.updateInProgress.get(stringPath) ===\n (patch.op === 'remove' ? undefined : patch.value)\n ) {\n continue;\n }\n\n const matchingPaths = this.paths.filter(\n (p) => isAncestor(p.path, patch.path) || isAncestor(patch.path, p.path),\n );\n\n for (const { path } of matchingPaths) {\n if (path.length <= patch.path.length) {\n const pathToSave = patch.path.slice(0, path.length);\n this.queue(() => this.save(pathToSave), pathToSave);\n } else if (patch.op === 'remove') {\n const subValues = split(\n reversePatch?.op === 'add' ? reversePatch.value : {},\n path.slice(patch.path.length),\n );\n\n for (const { path } of subValues) {\n this.queue(() => this.save([...patch.path, ...path]), [...patch.path, ...path]);\n }\n } else {\n const updatedValues = split(patch.value, path.slice(patch.path.length));\n const removedValues = split(\n reversePatch?.op !== 'remove' ? (reversePatch?.value ?? {}) : {},\n path.slice(patch.path.length),\n ).filter((v) => !updatedValues.some((u) => shallowEqual(u.path, v.path)));\n\n for (const { path } of updatedValues) {\n this.queue(() => this.save([...patch.path, ...path]), [...patch.path, ...path]);\n }\n for (const { path } of removedValues) {\n this.queue(() => this.save([...patch.path, ...path]), [...patch.path, ...path]);\n }\n }\n }\n }\n },\n { runNow: this.options.persistInitialState ?? false, passive: true, throttle },\n ]);\n\n this.handles.add(cancel);\n }\n\n private async watchStorage() {\n if (!this.options.persistInitialState) {\n let items = this.storage.listItems();\n if (isPromise(items)) {\n items = await items;\n }\n\n if (this.stopped) {\n return;\n }\n\n const toLoad = new Map(\n [...items.entries()]\n .sort((a, b) => b[1].length - a[1].length)\n .map(([key, value]) => [this.parseKey(key), value])\n .filter(([key]) => key) as [Key, string][],\n );\n\n this.queue(() => this.load(toLoad));\n }\n\n this.queue(() => this.resolveInitialized?.());\n\n const listener = (event: MessageEvent) => {\n this.queue(() => this.load([{ type: 'data', path: event.data }]));\n };\n\n this.channel.addEventListener('message', listener);\n this.handles.add(() => this.channel.removeEventListener('message', listener));\n }\n\n private buildKey({ type, path }: Key) {\n return `${this.prefix}${type === 'internal' ? path : JSON.stringify(path)}`;\n }\n\n private parseKey(key: string): Key | undefined {\n if (!key.startsWith(this.prefix)) {\n return;\n }\n\n key = key.slice(this.prefix.length);\n\n if (!key.startsWith('[')) {\n return { type: 'internal', path: key };\n }\n\n return { type: 'data', path: JSON.parse(key) as KeyType[] };\n }\n\n private load(items: Key[] | Map<Key, string>): void | Promise<void> {\n return promiseChain(() => {\n if (Array.isArray(items)) {\n return promiseChain(() => {\n const entries = items.map(\n (key) =>\n promiseChain(() => {\n return this.storage.getItem(this.buildKey(key));\n }).next((value) => [key, value] as const).value,\n );\n\n return entries.some(isPromise)\n ? Promise.all(entries)\n : (entries as [Key, string | null][]);\n }).next((entries) => {\n return entries.filter((entry) => entry !== null) as [Key, string][];\n }).value;\n } else {\n return [...items.entries()];\n }\n }).next((entries) => {\n if (this.stopped) {\n return;\n }\n\n const toWrite = entries\n .filter(([key, value]) => {\n if (key.type !== 'data' || !value) {\n return;\n }\n\n if (\n !this.paths.find(\n (p) =>\n (p.path.length === 1 && p.path[0] === '*' && key.path.length === 0) ||\n (p.path.length === key.path.length && isAncestor(p.path, key.path)),\n )\n ) {\n return null;\n }\n\n const inSaveQueue = this.queue\n .getRefs()\n .find((ref) => isAncestor(ref, key.path) || isAncestor(key.path, ref));\n return !inSaveQueue;\n })\n .map(([key, value]) => {\n try {\n return {\n path: key.path,\n value: !value || value === 'undefined' ? undefined : fromExtendedJsonString(value),\n };\n } catch {\n return undefined;\n }\n })\n .filter(Boolean) as { path: KeyType[]; value: unknown }[];\n\n if (toWrite.length > 0) {\n for (const { path, value } of toWrite) {\n this.updateInProgress.set(JSON.stringify(path), value);\n }\n\n this.store.set((state) => {\n for (const { path, value } of toWrite) {\n if (value === undefined) {\n state = remove(state, path as any);\n } else {\n state = set(state, path as any, value);\n }\n }\n\n return state;\n });\n\n this.updateInProgress.clear();\n }\n\n const versionEntry = entries.find(\n ([key]) => key.type === 'internal' && key.path === 'version',\n );\n if (versionEntry) {\n this.store.version = versionEntry[1];\n }\n }).value;\n }\n\n private save(path: KeyType[]): void | Promise<unknown> {\n const key = this.buildKey({ type: 'data', path });\n const value = get(this.store.get() as any, path);\n\n return promiseChain(value)\n .next((value) => {\n if (value === undefined) {\n return this.storage.removeItem(key);\n } else {\n return this.storage.setItem(key, toExtendedJsonString(value));\n }\n })\n .next(() => {\n this.channel.postMessage(path);\n\n if (this.store.version) {\n return this.storage.setItem(\n this.buildKey({ type: 'internal', path: 'version' }),\n this.store.version,\n );\n } else {\n return this.storage.removeItem(this.buildKey({ type: 'internal', path: 'version' }));\n }\n }).value;\n }\n\n async stop(): Promise<void> {\n this.stopped = true;\n\n for (const handle of this.handles) {\n handle();\n }\n\n await this.queue.whenDone();\n this.channel.close();\n }\n}\n\nexport function persist<T>(store: Store<T>, options: PersistOptions<T>): Persist<T> {\n return new Persist<T>(store, options);\n}\n\nfunction isPlainPath<T>(p: PathOption<T>): p is WildcardPath<T> & (KeyType[] | string) {\n return typeof p === 'string' || Array.isArray(p);\n}\n"],"mappings":";;;;;;AAOA,SAAwB,aAAgB,OAAgC;AACtE,KAAI,iBAAiB,SACnB,SAAQ,OAAO;AAGjB,QAAO;EACL;EACA,KAAK,IAAI;AAKP,UAAO,aAJMA,wBAAU,MAAM,GACzB,MAAM,MAAM,YAAU,GAAGC,QAAoB,CAAC,GAC9C,GAAG,MAAoB,CAEF;;EAE5B;;;;;ACnBH,MAAa,cAAc,UAAqB,SAA6B;AAC3E,QACE,SAAS,UAAU,KAAK,UACxB,SAAS,OAAO,GAAG,MAAM,MAAM,OAAO,KAAK,OAAO,OAAO,MAAM,KAAK,GAAG;;AAI3E,MAAa,SAAS,OAAY,SAA2D;CAC3F,MAAM,CAAC,OAAO,GAAG,QAAQ;AACzB,KAAI,UAAU,OAAW,QAAO,CAAC;EAAE,MAAM,EAAE;EAAE;EAAO,CAAC;CAErD,IAAIC;AACJ,KAAI,iBAAiB,IACnB,WAAU;UACD,iBAAiB,IAC1B,WAAU,IAAI,IAAI,CAAC,GAAG,MAAM,CAAC,KAAK,GAAG,MAAM,CAAC,GAAG,EAAE,CAAC,CAAC;UAC1C,MAAM,QAAQ,MAAM,CAC7B,WAAU,IAAI,IAAI,MAAM,KAAK,GAAG,MAAM,CAAC,GAAG,EAAE,CAAC,CAAC;UACrC,OAAO,UAAU,YAAY,UAAU,KAChD,WAAU,IAAI,IAAI,OAAO,QAAQ,MAAM,CAAC;KAExC,QAAO,CAAC;EAAE,MAAM,EAAE;EAAE;EAAO,CAAC;AAG9B,KAAI,UAAU,IACZ,QAAO,CAAC,GAAG,QAAQ,CAAC,SAAS,CAAC,GAAG,OAC/B,MAAM,GAAG,KAAK,CAAC,KAAK,EAAE,cAAM,sBAAa;EAAE,MAAM,CAAC,GAAG,GAAGC,OAAK;EAAE;EAAO,EAAE,CACzE;CA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import { d as queue, m as calcDuration, p as isPromise } from "./store-BpT1JkhI.js";
2
2
  import { a as set, i as remove, l as shallowEqual, n as get, t as castArrayPath } from "./propAccess-DvWFpYoj.js";
3
3
  import { n as subscribePatches } from "./patchMethods-iK2F87G0.js";
4
4
  import { i as toExtendedJsonString, n as fromExtendedJsonString } from "./extendedJson-Dv9q6rps.js";
@@ -96,17 +96,17 @@ var Persist = class {
96
96
  this.paths = (options.paths ?? []).map((p) => {
97
97
  if (isPlainPath(p)) return {
98
98
  path: castArrayPath(p),
99
- throttle: options.throttle && calcDuration(options.throttle)
99
+ throttle: options.throttle ? calcDuration(options.throttle) : void 0
100
100
  };
101
101
  const _p = p;
102
102
  return {
103
103
  path: castArrayPath(_p.path),
104
- throttle: (_p.throttle && calcDuration(_p.throttle)) ?? (options.throttle && calcDuration(options.throttle))
104
+ throttle: (_p.throttle ? calcDuration(_p.throttle) : void 0) ?? (options.throttle ? calcDuration(options.throttle) : void 0)
105
105
  };
106
106
  }).sort((a, b) => b.path.length - a.path.length);
107
107
  if (this.paths.length === 0) this.paths.push({
108
108
  path: ["*"],
109
- throttle: options.throttle && calcDuration(options.throttle)
109
+ throttle: options.throttle ? calcDuration(options.throttle) : void 0
110
110
  });
111
111
  this.initialized = new Promise((resolve) => {
112
112
  this.resolveInitialized = resolve;
@@ -252,4 +252,4 @@ function isPlainPath(p) {
252
252
 
253
253
  //#endregion
254
254
  export { persist as t };
255
- //# sourceMappingURL=persist-Bunx8xfQ.js.map
255
+ //# sourceMappingURL=persist-BepySE7U.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"persist-BepySE7U.js","names":["value","entries: Map<KeyType, unknown>","path","store: Store<T>","options: PersistOptions<T>","path"],"sources":["../src/lib/promiseChain.ts","../src/persist/persistPathHelpers.ts","../src/persist/persistStorage.ts","../src/persist/persist.ts"],"sourcesContent":["import isPromise from '@lib/isPromise';\n\nexport interface Chain<T> {\n value: T;\n next<S>(fn: (value: Awaited<T>) => S): T extends Promise<any> ? Chain<Promise<S>> : Chain<S>;\n}\n\nexport default function promiseChain<T>(value: T | (() => T)): Chain<T> {\n if (value instanceof Function) {\n value = value();\n }\n\n return {\n value,\n next(fn) {\n const next = isPromise(value)\n ? value.then((value) => fn(value as Awaited<T>))\n : fn(value as Awaited<T>);\n\n return promiseChain(next) as any;\n },\n };\n}\n","import type { KeyType } from '@lib/path';\n\nexport const isAncestor = (ancestor: KeyType[], path: KeyType[]): boolean => {\n return (\n ancestor.length <= path.length &&\n ancestor.every((v, i) => v === '*' || path[i] === '*' || v === path[i])\n );\n};\n\nexport const split = (value: any, path: KeyType[]): { path: KeyType[]; value: unknown }[] => {\n const [first, ...rest] = path;\n if (first === undefined) return [{ path: [], value }];\n\n let entries: Map<KeyType, unknown>;\n if (value instanceof Map) {\n entries = value;\n } else if (value instanceof Set) {\n entries = new Map([...value].map((v, i) => [i, v]));\n } else if (Array.isArray(value)) {\n entries = new Map(value.map((v, i) => [i, v]));\n } else if (typeof value === 'object' && value !== null) {\n entries = new Map(Object.entries(value));\n } else {\n return [{ path: [], value }];\n }\n\n if (first === '*') {\n return [...entries].flatMap(([k, v]) =>\n split(v, rest).map(({ path, value }) => ({ path: [k, ...path], value })),\n );\n }\n\n const subValue = entries.get(first);\n if (subValue === undefined) return [{ path: [], value }];\n\n return split(subValue, rest).map(({ path, value }) => ({ path: [first, ...path], value }));\n};\n","import isPromise from '@lib/isPromise';\nimport promiseChain from '@lib/promiseChain';\n\nexport interface PersistStorageBase {\n getItem: (key: string) => string | null | Promise<string | null>;\n setItem: (key: string, value: string) => void | Promise<unknown>;\n removeItem: (key: string) => void | Promise<unknown>;\n}\n\nexport interface PersistStorageWithKeys extends PersistStorageBase {\n keys: () => string[] | Promise<string[]>;\n}\n\nexport interface PersistStorageWithLength extends PersistStorageBase {\n length: number | (() => number | Promise<number>);\n key: (keyIndex: number) => string | null | Promise<string | null>;\n}\n\nexport interface PersistStorageWithListItems extends PersistStorageBase {\n listItems: () => Map<string, string> | Promise<Map<string, string>>;\n}\n\nexport type PersistStorage =\n | PersistStorageWithKeys\n | PersistStorageWithLength\n | PersistStorageWithListItems;\n\nexport function normalizeStorage(storage: PersistStorage): PersistStorageWithListItems {\n return {\n getItem: storage.getItem.bind(storage),\n setItem: storage.setItem.bind(storage),\n removeItem: storage.removeItem.bind(storage),\n\n listItems() {\n if ('listItems' in storage) {\n return storage.listItems();\n }\n\n return promiseChain(() => {\n if ('keys' in storage) {\n return storage.keys();\n } else {\n return promiseChain(\n storage.length instanceof Function ? storage.length() : storage.length,\n )\n .next((length) => {\n const keys = Array.from({ length }, (_, index) => storage.key(index));\n return keys.some(isPromise) ? Promise.all(keys) : (keys as (string | null)[]);\n })\n .next((keys) => {\n return keys.filter((key): key is string => typeof key === 'string');\n }).value;\n }\n })\n .next((keys) => {\n const results = keys.map(\n (key) =>\n promiseChain(storage.getItem(key)).next((value) => [key, value] as const).value,\n );\n\n return results.some(isPromise)\n ? Promise.all(results)\n : (results as [string, string | null][]);\n })\n .next((results) => {\n return new Map(results.filter(([, value]) => value !== null) as [string, string][]);\n }).value;\n },\n };\n}\n","import { type Cancel, type Duration, type Store } from '@core';\nimport { calcDuration } from '@lib/duration';\nimport { shallowEqual } from '@lib/equals';\nimport { fromExtendedJsonString, toExtendedJsonString } from '@lib/extendedJson';\nimport isPromise from '@lib/isPromise';\nimport type { KeyType, WildcardPath } from '@lib/path';\nimport promiseChain from '@lib/promiseChain';\nimport { castArrayPath, get, remove, set } from '@lib/propAccess';\nimport { queue } from '@lib/queue';\nimport { subscribePatches } from '@patches/patchMethods';\nimport { isAncestor, split } from '@persist/persistPathHelpers';\nimport {\n normalizeStorage,\n type PersistStorage,\n type PersistStorageWithListItems,\n} from './persistStorage';\n\ntype PathOption<T> =\n | WildcardPath<T>\n | {\n path: WildcardPath<T>;\n // throttle?: Duration;\n };\n\ntype Key = { type: 'internal'; path: string } | { type: 'data'; path: KeyType[] };\n\nexport interface PersistOptions<T> {\n id: string;\n storage: PersistStorage;\n paths?: PathOption<T>[];\n throttle?: Duration;\n persistInitialState?: boolean;\n}\n\nexport class Persist<T> {\n readonly storage: PersistStorageWithListItems;\n readonly [Symbol.dispose]!: Cancel;\n\n readonly paths: {\n path: KeyType[];\n throttle?: number;\n }[];\n\n readonly initialized: Promise<void>;\n\n private resolveInitialized?: () => void;\n\n private channel: BroadcastChannel;\n\n private queue = queue();\n\n private handles = new Set<Cancel>();\n\n private stopped = false;\n\n private updateInProgress = new Map<string, unknown>();\n\n private prefix;\n\n constructor(\n public readonly store: Store<T>,\n public readonly options: PersistOptions<T>,\n ) {\n this.storage = normalizeStorage(options.storage);\n this.channel = new BroadcastChannel(`cross-state-persist_${options.id}`);\n this.prefix = `${options.id}:`;\n\n if (Symbol.dispose) {\n this[Symbol.dispose] = () => this.stop();\n }\n\n this.paths = (options.paths ?? [])\n .map<{\n path: KeyType[];\n throttle?: number;\n }>((p) => {\n if (isPlainPath(p)) {\n return {\n path: castArrayPath(p),\n throttle: options.throttle ? calcDuration(options.throttle) : undefined,\n };\n }\n\n const _p = p as { path: KeyType[]; throttle?: Duration };\n\n return {\n path: castArrayPath(_p.path),\n throttle:\n (_p.throttle ? calcDuration(_p.throttle) : undefined) ??\n (options.throttle ? calcDuration(options.throttle) : undefined),\n };\n })\n .sort((a, b) => b.path.length - a.path.length);\n\n if (this.paths.length === 0) {\n this.paths.push({\n path: ['*'],\n throttle: options.throttle ? calcDuration(options.throttle) : undefined,\n });\n }\n\n this.initialized = new Promise((resolve) => {\n this.resolveInitialized = resolve;\n });\n\n this.watchStore();\n this.watchStorage();\n }\n\n private watchStore() {\n const throttle = Math.min(...this.paths.map((p) => p.throttle ?? 0)) || undefined;\n\n const cancel = subscribePatches.apply(this.store as Store<unknown>, [\n (patches, reversePatches) => {\n let i = 0;\n for (const patch of patches) {\n const reversePatch = reversePatches[i++];\n\n const stringPath = JSON.stringify(patch.path);\n if (\n this.updateInProgress.has(stringPath) &&\n this.updateInProgress.get(stringPath) ===\n (patch.op === 'remove' ? undefined : patch.value)\n ) {\n continue;\n }\n\n const matchingPaths = this.paths.filter(\n (p) => isAncestor(p.path, patch.path) || isAncestor(patch.path, p.path),\n );\n\n for (const { path } of matchingPaths) {\n if (path.length <= patch.path.length) {\n const pathToSave = patch.path.slice(0, path.length);\n this.queue(() => this.save(pathToSave), pathToSave);\n } else if (patch.op === 'remove') {\n const subValues = split(\n reversePatch?.op === 'add' ? reversePatch.value : {},\n path.slice(patch.path.length),\n );\n\n for (const { path } of subValues) {\n this.queue(() => this.save([...patch.path, ...path]), [...patch.path, ...path]);\n }\n } else {\n const updatedValues = split(patch.value, path.slice(patch.path.length));\n const removedValues = split(\n reversePatch?.op !== 'remove' ? (reversePatch?.value ?? {}) : {},\n path.slice(patch.path.length),\n ).filter((v) => !updatedValues.some((u) => shallowEqual(u.path, v.path)));\n\n for (const { path } of updatedValues) {\n this.queue(() => this.save([...patch.path, ...path]), [...patch.path, ...path]);\n }\n for (const { path } of removedValues) {\n this.queue(() => this.save([...patch.path, ...path]), [...patch.path, ...path]);\n }\n }\n }\n }\n },\n { runNow: this.options.persistInitialState ?? false, passive: true, throttle },\n ]);\n\n this.handles.add(cancel);\n }\n\n private async watchStorage() {\n if (!this.options.persistInitialState) {\n let items = this.storage.listItems();\n if (isPromise(items)) {\n items = await items;\n }\n\n if (this.stopped) {\n return;\n }\n\n const toLoad = new Map(\n [...items.entries()]\n .sort((a, b) => b[1].length - a[1].length)\n .map(([key, value]) => [this.parseKey(key), value])\n .filter(([key]) => key) as [Key, string][],\n );\n\n this.queue(() => this.load(toLoad));\n }\n\n this.queue(() => this.resolveInitialized?.());\n\n const listener = (event: MessageEvent) => {\n this.queue(() => this.load([{ type: 'data', path: event.data }]));\n };\n\n this.channel.addEventListener('message', listener);\n this.handles.add(() => this.channel.removeEventListener('message', listener));\n }\n\n private buildKey({ type, path }: Key) {\n return `${this.prefix}${type === 'internal' ? path : JSON.stringify(path)}`;\n }\n\n private parseKey(key: string): Key | undefined {\n if (!key.startsWith(this.prefix)) {\n return;\n }\n\n key = key.slice(this.prefix.length);\n\n if (!key.startsWith('[')) {\n return { type: 'internal', path: key };\n }\n\n return { type: 'data', path: JSON.parse(key) as KeyType[] };\n }\n\n private load(items: Key[] | Map<Key, string>): void | Promise<void> {\n return promiseChain(() => {\n if (Array.isArray(items)) {\n return promiseChain(() => {\n const entries = items.map(\n (key) =>\n promiseChain(() => {\n return this.storage.getItem(this.buildKey(key));\n }).next((value) => [key, value] as const).value,\n );\n\n return entries.some(isPromise)\n ? Promise.all(entries)\n : (entries as [Key, string | null][]);\n }).next((entries) => {\n return entries.filter((entry) => entry !== null) as [Key, string][];\n }).value;\n } else {\n return [...items.entries()];\n }\n }).next((entries) => {\n if (this.stopped) {\n return;\n }\n\n const toWrite = entries\n .filter(([key, value]) => {\n if (key.type !== 'data' || !value) {\n return;\n }\n\n if (\n !this.paths.find(\n (p) =>\n (p.path.length === 1 && p.path[0] === '*' && key.path.length === 0) ||\n (p.path.length === key.path.length && isAncestor(p.path, key.path)),\n )\n ) {\n return null;\n }\n\n const inSaveQueue = this.queue\n .getRefs()\n .find((ref) => isAncestor(ref, key.path) || isAncestor(key.path, ref));\n return !inSaveQueue;\n })\n .map(([key, value]) => {\n try {\n return {\n path: key.path,\n value: !value || value === 'undefined' ? undefined : fromExtendedJsonString(value),\n };\n } catch {\n return undefined;\n }\n })\n .filter(Boolean) as { path: KeyType[]; value: unknown }[];\n\n if (toWrite.length > 0) {\n for (const { path, value } of toWrite) {\n this.updateInProgress.set(JSON.stringify(path), value);\n }\n\n this.store.set((state) => {\n for (const { path, value } of toWrite) {\n if (value === undefined) {\n state = remove(state, path as any);\n } else {\n state = set(state, path as any, value);\n }\n }\n\n return state;\n });\n\n this.updateInProgress.clear();\n }\n\n const versionEntry = entries.find(\n ([key]) => key.type === 'internal' && key.path === 'version',\n );\n if (versionEntry) {\n this.store.version = versionEntry[1];\n }\n }).value;\n }\n\n private save(path: KeyType[]): void | Promise<unknown> {\n const key = this.buildKey({ type: 'data', path });\n const value = get(this.store.get() as any, path);\n\n return promiseChain(value)\n .next((value) => {\n if (value === undefined) {\n return this.storage.removeItem(key);\n } else {\n return this.storage.setItem(key, toExtendedJsonString(value));\n }\n })\n .next(() => {\n this.channel.postMessage(path);\n\n if (this.store.version) {\n return this.storage.setItem(\n this.buildKey({ type: 'internal', path: 'version' }),\n this.store.version,\n );\n } else {\n return this.storage.removeItem(this.buildKey({ type: 'internal', path: 'version' }));\n }\n }).value;\n }\n\n async stop(): Promise<void> {\n this.stopped = true;\n\n for (const handle of this.handles) {\n handle();\n }\n\n await this.queue.whenDone();\n this.channel.close();\n }\n}\n\nexport function persist<T>(store: Store<T>, options: PersistOptions<T>): Persist<T> {\n return new Persist<T>(store, options);\n}\n\nfunction isPlainPath<T>(p: PathOption<T>): p is WildcardPath<T> & (KeyType[] | string) {\n return typeof p === 'string' || Array.isArray(p);\n}\n"],"mappings":";;;;;;AAOA,SAAwB,aAAgB,OAAgC;AACtE,KAAI,iBAAiB,SACnB,SAAQ,OAAO;AAGjB,QAAO;EACL;EACA,KAAK,IAAI;AAKP,UAAO,aAJM,UAAU,MAAM,GACzB,MAAM,MAAM,YAAU,GAAGA,QAAoB,CAAC,GAC9C,GAAG,MAAoB,CAEF;;EAE5B;;;;;ACnBH,MAAa,cAAc,UAAqB,SAA6B;AAC3E,QACE,SAAS,UAAU,KAAK,UACxB,SAAS,OAAO,GAAG,MAAM,MAAM,OAAO,KAAK,OAAO,OAAO,MAAM,KAAK,GAAG;;AAI3E,MAAa,SAAS,OAAY,SAA2D;CAC3F,MAAM,CAAC,OAAO,GAAG,QAAQ;AACzB,KAAI,UAAU,OAAW,QAAO,CAAC;EAAE,MAAM,EAAE;EAAE;EAAO,CAAC;CAErD,IAAIC;AACJ,KAAI,iBAAiB,IACnB,WAAU;UACD,iBAAiB,IAC1B,WAAU,IAAI,IAAI,CAAC,GAAG,MAAM,CAAC,KAAK,GAAG,MAAM,CAAC,GAAG,EAAE,CAAC,CA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M;IAAW,CAAC,CAAC;IAEtF,CAAC;;CAGP,MAAM,OAAsB;AAC1B,OAAK,UAAU;AAEf,OAAK,MAAM,UAAU,KAAK,QACxB,SAAQ;AAGV,QAAM,KAAK,MAAM,UAAU;AAC3B,OAAK,QAAQ,OAAO;;;AAIxB,SAAgB,QAAW,OAAiB,SAAwC;AAClF,QAAO,IAAI,QAAW,OAAO,QAAQ;;AAGvC,SAAS,YAAe,GAA+D;AACrF,QAAO,OAAO,MAAM,YAAY,MAAM,QAAQ,EAAE"}
@@ -1,4 +1,4 @@
1
- import { M as KeyType, V as WildcardPath, b as Duration, g as Cancel, r as Store } from "./store-BRHFhRPm.js";
1
+ import { M as KeyType, V as WildcardPath, b as Duration, g as Cancel, r as Store } from "./store-T0xgcd1b.js";
2
2
 
3
3
  //#region src/persist/persistStorage.d.ts
4
4
  interface PersistStorageBase {
@@ -58,4 +58,4 @@ declare class Persist<T> {
58
58
  declare function persist<T>(store: Store<T>, options: PersistOptions<T>): Persist<T>;
59
59
  //#endregion
60
60
  export { PersistStorageBase as a, PersistStorageWithListItems as c, PersistStorage as i, PersistOptions as n, PersistStorageWithKeys as o, persist as r, PersistStorageWithLength as s, Persist as t };
61
- //# sourceMappingURL=persist-DyI_JLxZ.d.ts.map
61
+ //# sourceMappingURL=persist-BpqycKqI.d.ts.map
@@ -1,4 +1,4 @@
1
- import { M as KeyType, V as WildcardPath, b as Duration, g as Cancel, r as Store } from "./store-XcnTdeiJ.cjs";
1
+ import { M as KeyType, V as WildcardPath, b as Duration, g as Cancel, r as Store } from "./store-BAutdl4v.cjs";
2
2
 
3
3
  //#region src/persist/persistStorage.d.ts
4
4
  interface PersistStorageBase {
@@ -58,4 +58,4 @@ declare class Persist<T> {
58
58
  declare function persist<T>(store: Store<T>, options: PersistOptions<T>): Persist<T>;
59
59
  //#endregion
60
60
  export { PersistStorageBase as a, PersistStorageWithListItems as c, PersistStorage as i, PersistOptions as n, PersistStorageWithKeys as o, persist as r, PersistStorageWithLength as s, Persist as t };
61
- //# sourceMappingURL=persist-CHRYYolx.d.cts.map
61
+ //# sourceMappingURL=persist-CSKaACQ7.d.cts.map
@@ -1,8 +1,8 @@
1
1
  const require_path = require('../path-B-Rq5q6m.cjs');
2
- const require_store = require('../store-C1NYHLgR.cjs');
2
+ const require_store = require('../store-Bcb8hcQj.cjs');
3
3
  const require_propAccess = require('../propAccess-C2AIn9RC.cjs');
4
4
  const require_extendedJson = require('../extendedJson-ursQ8DbQ.cjs');
5
- const require_storeMethods = require('../storeMethods-XSKXj4TX.cjs');
5
+ const require_storeMethods = require('../storeMethods-DvvwXRlz.cjs');
6
6
  let react = require("react");
7
7
  react = require_path.__toESM(react);
8
8
  let react_jsx_runtime = require("react/jsx-runtime");
@@ -194,7 +194,6 @@ function FormContainer({ form,...formProps }) {
194
194
  }
195
195
  });
196
196
  (0, react.useEffect)(() => {
197
- if (!formInstance.options.reportValidity) return;
198
197
  return formInstance.formState.map(() => formInstance.getErrors()).subscribe((errors) => updateValidity(errors));
199
198
  }, [formInstance, updateValidity]);
200
199
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("form", {
@@ -209,12 +208,10 @@ function FormContainer({ form,...formProps }) {
209
208
  try {
210
209
  formInstance.formState.set("saveInProgress", true);
211
210
  event.preventDefault();
212
- if (formInstance.options.reportValidity) {
213
- const formElement = event.currentTarget;
214
- const buttonElement = event.nativeEvent instanceof SubmitEvent && event.nativeEvent.submitter instanceof HTMLButtonElement ? event.nativeEvent.submitter : void 0;
215
- updateValidity(formInstance.getErrors(), buttonElement);
216
- formElement.reportValidity();
217
- }
211
+ const formElement = event.currentTarget;
212
+ const buttonElement = event.nativeEvent instanceof SubmitEvent && event.nativeEvent.submitter instanceof HTMLButtonElement ? event.nativeEvent.submitter : void 0;
213
+ updateValidity(formInstance.getErrors(), buttonElement);
214
+ if (formInstance.options.reportValidity) formElement.reportValidity();
218
215
  if (formInstance.validate()) await formProps.onSubmit?.(event, {
219
216
  ...formInstance,
220
217
  ...getDerivedState(formInstance)