cross-state 0.56.4 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (107) hide show
  1. package/dist/{diff-CElc7pJI.d.ts → diff-CAQaunfv.d.cts} +3 -3
  2. package/dist/{diff-BslUrJZE.d.cts → diff-DFvRd-Gf.d.ts} +3 -3
  3. package/dist/{extendedJson-BZkQBXEv.js → extendedJson-Dv9q6rps.js} +2 -2
  4. package/dist/{extendedJson-BZkQBXEv.js.map → extendedJson-Dv9q6rps.js.map} +1 -1
  5. package/dist/{extendedJson-Dn2F7Edo.cjs → extendedJson-ursQ8DbQ.cjs} +1 -1
  6. package/dist/{extendedJson-Dn2F7Edo.cjs.map → extendedJson-ursQ8DbQ.cjs.map} +1 -1
  7. package/dist/index.cjs +9 -11
  8. package/dist/index.cjs.map +1 -1
  9. package/dist/index.d.cts +4 -4
  10. package/dist/index.d.ts +4 -4
  11. package/dist/index.js +7 -9
  12. package/dist/index.js.map +1 -1
  13. package/dist/mutative/index.cjs +2 -1
  14. package/dist/mutative/index.d.cts +2 -2
  15. package/dist/mutative/index.d.ts +2 -2
  16. package/dist/mutative/index.js +2 -1
  17. package/dist/mutative/register.cjs +4 -3
  18. package/dist/mutative/register.cjs.map +1 -1
  19. package/dist/mutative/register.d.cts +2 -4
  20. package/dist/mutative/register.d.ts +2 -2
  21. package/dist/mutative/register.js +4 -3
  22. package/dist/mutative/register.js.map +1 -1
  23. package/dist/{mutativeMethods-Bhd1Yi22.d.ts → mutativeMethods-BT1Cim3p.d.ts} +3 -3
  24. package/dist/{mutativeMethods-DWhwZRzv.d.cts → mutativeMethods-C8VcZWED.d.cts} +3 -3
  25. package/dist/{mutativeMethods-CgXk_bMt.cjs → mutativeMethods-CkNycpO9.cjs} +6 -7
  26. package/dist/{mutativeMethods-CgXk_bMt.cjs.map → mutativeMethods-CkNycpO9.cjs.map} +1 -1
  27. package/dist/{mutativeMethods-CZKeRIDL.js → mutativeMethods-Jowr0Znn.js} +4 -6
  28. package/dist/{mutativeMethods-CZKeRIDL.js.map → mutativeMethods-Jowr0Znn.js.map} +1 -1
  29. package/dist/{patchMethods-hhlLwtqE.cjs → patchMethods-B7Hm5-Qh.cjs} +4 -6
  30. package/dist/{patchMethods-hhlLwtqE.cjs.map → patchMethods-B7Hm5-Qh.cjs.map} +1 -1
  31. package/dist/{patchMethods-DXWygPZ6.d.ts → patchMethods-BmyvvHnP.d.cts} +4 -4
  32. package/dist/{patchMethods-BT4Tg5aG.d.cts → patchMethods-CixmHmNt.d.ts} +4 -4
  33. package/dist/{patchMethods-C_f3PORQ.js → patchMethods-iK2F87G0.js} +5 -7
  34. package/dist/{patchMethods-C_f3PORQ.js.map → patchMethods-iK2F87G0.js.map} +1 -1
  35. package/dist/patches/index.cjs +3 -3
  36. package/dist/patches/index.d.cts +3 -3
  37. package/dist/patches/index.d.ts +3 -3
  38. package/dist/patches/index.js +3 -3
  39. package/dist/patches/register.cjs +4 -4
  40. package/dist/patches/register.cjs.map +1 -1
  41. package/dist/patches/register.d.cts +3 -5
  42. package/dist/patches/register.d.ts +3 -3
  43. package/dist/patches/register.js +4 -4
  44. package/dist/patches/register.js.map +1 -1
  45. package/dist/{chunk-CUT6urMc.cjs → path-B-Rq5q6m.cjs} +14 -1
  46. package/dist/path-B-Rq5q6m.cjs.map +1 -0
  47. package/dist/path-CyYq74W8.js +8 -0
  48. package/dist/path-CyYq74W8.js.map +1 -0
  49. package/dist/persist/register.cjs +5 -5
  50. package/dist/persist/register.cjs.map +1 -1
  51. package/dist/persist/register.d.cts +2 -4
  52. package/dist/persist/register.d.ts +2 -2
  53. package/dist/persist/register.js +5 -5
  54. package/dist/persist/register.js.map +1 -1
  55. package/dist/{persist-CLgS5Cqw.js → persist-Bunx8xfQ.js} +12 -15
  56. package/dist/persist-Bunx8xfQ.js.map +1 -0
  57. package/dist/{persist-olbNkcdZ.d.ts → persist-CHRYYolx.d.cts} +3 -3
  58. package/dist/{persist-DboMIMOK.cjs → persist-DMbVdqS_.cjs} +11 -14
  59. package/dist/persist-DMbVdqS_.cjs.map +1 -0
  60. package/dist/{persist-DVKRq8RQ.d.cts → persist-DyI_JLxZ.d.ts} +3 -3
  61. package/dist/{propAccess-BdLsqViO.cjs → propAccess-C2AIn9RC.cjs} +4 -6
  62. package/dist/{propAccess-BdLsqViO.cjs.map → propAccess-C2AIn9RC.cjs.map} +1 -1
  63. package/dist/{propAccess-B260LXN1.js → propAccess-DvWFpYoj.js} +5 -7
  64. package/dist/{propAccess-B260LXN1.js.map → propAccess-DvWFpYoj.js.map} +1 -1
  65. package/dist/react/index.cjs +66 -80
  66. package/dist/react/index.cjs.map +1 -1
  67. package/dist/react/index.d.cts +70 -70
  68. package/dist/react/index.d.ts +70 -70
  69. package/dist/react/index.js +62 -77
  70. package/dist/react/index.js.map +1 -1
  71. package/dist/react/register.cjs +5 -5
  72. package/dist/react/register.cjs.map +1 -1
  73. package/dist/react/register.d.cts +3 -5
  74. package/dist/react/register.d.ts +3 -3
  75. package/dist/react/register.js +5 -5
  76. package/dist/react/register.js.map +1 -1
  77. package/dist/{scope-CfLlLxo9.cjs → scope-C1bcfK8e.cjs} +32 -7
  78. package/dist/scope-C1bcfK8e.cjs.map +1 -0
  79. package/dist/{scope-D3jkIPgn.d.ts → scope-CESkVNvI.d.cts} +3 -3
  80. package/dist/{scope-7LeON9bZ.js → scope-CKGsCVn3.js} +20 -7
  81. package/dist/scope-CKGsCVn3.js.map +1 -0
  82. package/dist/{scope-CcBxgcrs.d.cts → scope-DJXSRsGy.d.ts} +3 -3
  83. package/dist/{store-MBrcOgtz.d.cts → store-BRHFhRPm.d.ts} +21 -21
  84. package/dist/{store-CdST5wJZ.cjs → store-C1NYHLgR.cjs} +12 -13
  85. package/dist/store-C1NYHLgR.cjs.map +1 -0
  86. package/dist/{store-DnZ6fsiJ.d.ts → store-XcnTdeiJ.d.cts} +21 -21
  87. package/dist/{store-Dx8w7yT-.js → store-v3RYWzVg.js} +13 -14
  88. package/dist/store-v3RYWzVg.js.map +1 -0
  89. package/dist/{storeMethods-B_RzvMaV.cjs → storeMethods-CNu7VD6w.cjs} +135 -60
  90. package/dist/storeMethods-CNu7VD6w.cjs.map +1 -0
  91. package/dist/{storeMethods-BrKuusQ2.js → storeMethods-CQhXlHpl.js} +115 -59
  92. package/dist/storeMethods-CQhXlHpl.js.map +1 -0
  93. package/dist/{storeMethods-CmWv1YMe.d.cts → storeMethods-Dsz0-Cda.d.ts} +4 -4
  94. package/dist/{storeMethods-Cb1ur5K3.d.ts → storeMethods-y3PlfTHV.d.cts} +4 -4
  95. package/package.json +26 -37
  96. package/dist/hash-DNFM5y_h.js +0 -19
  97. package/dist/hash-DNFM5y_h.js.map +0 -1
  98. package/dist/hash-Dv3XlmHn.cjs +0 -30
  99. package/dist/hash-Dv3XlmHn.cjs.map +0 -1
  100. package/dist/persist-CLgS5Cqw.js.map +0 -1
  101. package/dist/persist-DboMIMOK.cjs.map +0 -1
  102. package/dist/scope-7LeON9bZ.js.map +0 -1
  103. package/dist/scope-CfLlLxo9.cjs.map +0 -1
  104. package/dist/store-CdST5wJZ.cjs.map +0 -1
  105. package/dist/store-Dx8w7yT-.js.map +0 -1
  106. package/dist/storeMethods-B_RzvMaV.cjs.map +0 -1
  107. package/dist/storeMethods-BrKuusQ2.js.map +0 -1
@@ -1,4 +1,4 @@
1
- import { KeyType } from "./store-DnZ6fsiJ.js";
1
+ import { M as KeyType } from "./store-XcnTdeiJ.cjs";
2
2
 
3
3
  //#region src/lib/diff.d.ts
4
4
  type Patch = {
@@ -18,5 +18,5 @@ interface DiffOptions {
18
18
  }
19
19
  declare function diff(a: any, b: any, options?: DiffOptions): [patches: Patch[], reversePatches: Patch[]];
20
20
  //#endregion
21
- export { DiffOptions, Patch, diff };
22
- //# sourceMappingURL=diff-CElc7pJI.d.ts.map
21
+ export { Patch as n, diff as r, DiffOptions as t };
22
+ //# sourceMappingURL=diff-CAQaunfv.d.cts.map
@@ -1,4 +1,4 @@
1
- import { KeyType } from "./store-MBrcOgtz.cjs";
1
+ import { M as KeyType } from "./store-BRHFhRPm.js";
2
2
 
3
3
  //#region src/lib/diff.d.ts
4
4
  type Patch = {
@@ -18,5 +18,5 @@ interface DiffOptions {
18
18
  }
19
19
  declare function diff(a: any, b: any, options?: DiffOptions): [patches: Patch[], reversePatches: Patch[]];
20
20
  //#endregion
21
- export { DiffOptions, Patch, diff };
22
- //# sourceMappingURL=diff-BslUrJZE.d.cts.map
21
+ export { Patch as n, diff as r, DiffOptions as t };
22
+ //# sourceMappingURL=diff-DFvRd-Gf.d.ts.map
@@ -25,5 +25,5 @@ function fromExtendedJsonString(value, reviver) {
25
25
  }
26
26
 
27
27
  //#endregion
28
- export { fromExtendedJson, fromExtendedJsonString, toExtendedJson, toExtendedJsonString };
29
- //# sourceMappingURL=extendedJson-BZkQBXEv.js.map
28
+ export { toExtendedJsonString as i, fromExtendedJsonString as n, toExtendedJson as r, fromExtendedJson as t };
29
+ //# sourceMappingURL=extendedJson-Dv9q6rps.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"extendedJson-BZkQBXEv.js","names":[],"sources":["../src/lib/extendedJson.ts"],"sourcesContent":["export function toExtendedJson(value: unknown): unknown {\n if (value instanceof Map) {\n return {\n __map: [...value].map(([k, v]) => [toExtendedJson(k), toExtendedJson(v)]),\n };\n }\n\n if (value instanceof Set) {\n return {\n __set: [...value].map(toExtendedJson),\n };\n }\n\n if (value instanceof Date) {\n return {\n __date: value.toISOString(),\n };\n }\n\n if (typeof value === 'bigint') {\n return {\n __bigint: value.toString(),\n };\n }\n\n if (Array.isArray(value)) {\n return value.map(toExtendedJson);\n }\n\n if (typeof value === 'object' && value !== null) {\n return Object.fromEntries(Object.entries(value).map(([k, v]) => [k, toExtendedJson(v)]));\n }\n\n return value;\n}\n\nexport function toExtendedJsonString(\n value: any,\n replacer?: (this: any, key: string, value: any) => any,\n space?: string | number,\n): string;\nexport function toExtendedJsonString(\n value: any,\n replacer?: (number | string)[] | null,\n space?: string | number,\n): string;\nexport function toExtendedJsonString(value: unknown, ...args: any[]): string {\n return JSON.stringify(toExtendedJson(value), ...args);\n}\n\nexport function fromExtendedJson(value: unknown): unknown {\n if (typeof value !== 'object' || value === null) {\n return value;\n }\n\n if ('__map' in value) {\n return new Map(\n (value.__map as [unknown, unknown][]).map(([k, v]) => [\n fromExtendedJson(k),\n fromExtendedJson(v),\n ]),\n );\n }\n\n if ('__set' in value) {\n return new Set((value.__set as unknown[]).map(fromExtendedJson));\n }\n\n if ('__date' in value) {\n return new Date(value.__date as string);\n }\n\n if ('__bigint' in value) {\n return BigInt(value.__bigint as string);\n }\n\n if (Array.isArray(value)) {\n return value.map(fromExtendedJson);\n }\n\n return Object.fromEntries(Object.entries(value).map(([k, v]) => [k, fromExtendedJson(v)]));\n}\n\nexport function fromExtendedJsonString(\n value: string,\n reviver?: (this: any, key: string, value: any) => any,\n): unknown {\n return fromExtendedJson(JSON.parse(value, reviver));\n}\n"],"mappings":";AAAA,SAAgB,eAAe,OAAyB;AACtD,KAAI,iBAAiB,IACnB,QAAO,EACL,OAAO,CAAC,GAAG,OAAO,KAAK,CAAC,GAAG,OAAO,CAAC,eAAe,IAAI,eAAe;AAIzE,KAAI,iBAAiB,IACnB,QAAO,EACL,OAAO,CAAC,GAAG,OAAO,IAAI;AAI1B,KAAI,iBAAiB,KACnB,QAAO,EACL,QAAQ,MAAM;AAIlB,KAAI,OAAO,UAAU,SACnB,QAAO,EACL,UAAU,MAAM;AAIpB,KAAI,MAAM,QAAQ,OAChB,QAAO,MAAM,IAAI;AAGnB,KAAI,OAAO,UAAU,YAAY,UAAU,KACzC,QAAO,OAAO,YAAY,OAAO,QAAQ,OAAO,KAAK,CAAC,GAAG,OAAO,CAAC,GAAG,eAAe;AAGrF,QAAO;;AAaT,SAAgB,qBAAqB,OAAgB,GAAG,MAAqB;AAC3E,QAAO,KAAK,UAAU,eAAe,QAAQ,GAAG;;AAGlD,SAAgB,iBAAiB,OAAyB;AACxD,KAAI,OAAO,UAAU,YAAY,UAAU,KACzC,QAAO;AAGT,KAAI,WAAW,MACb,QAAO,IAAI,IACR,MAAM,MAA+B,KAAK,CAAC,GAAG,OAAO,CACpD,iBAAiB,IACjB,iBAAiB;AAKvB,KAAI,WAAW,MACb,QAAO,IAAI,IAAK,MAAM,MAAoB,IAAI;AAGhD,KAAI,YAAY,MACd,QAAO,IAAI,KAAK,MAAM;AAGxB,KAAI,cAAc,MAChB,QAAO,OAAO,MAAM;AAGtB,KAAI,MAAM,QAAQ,OAChB,QAAO,MAAM,IAAI;AAGnB,QAAO,OAAO,YAAY,OAAO,QAAQ,OAAO,KAAK,CAAC,GAAG,OAAO,CAAC,GAAG,iBAAiB;;AAGvF,SAAgB,uBACd,OACA,SACS;AACT,QAAO,iBAAiB,KAAK,MAAM,OAAO"}
1
+ {"version":3,"file":"extendedJson-Dv9q6rps.js","names":[],"sources":["../src/lib/extendedJson.ts"],"sourcesContent":["export function toExtendedJson(value: unknown): unknown {\n if (value instanceof Map) {\n return {\n __map: [...value].map(([k, v]) => [toExtendedJson(k), toExtendedJson(v)]),\n };\n }\n\n if (value instanceof Set) {\n return {\n __set: [...value].map(toExtendedJson),\n };\n }\n\n if (value instanceof Date) {\n return {\n __date: value.toISOString(),\n };\n }\n\n if (typeof value === 'bigint') {\n return {\n __bigint: value.toString(),\n };\n }\n\n if (Array.isArray(value)) {\n return value.map(toExtendedJson);\n }\n\n if (typeof value === 'object' && value !== null) {\n return Object.fromEntries(Object.entries(value).map(([k, v]) => [k, toExtendedJson(v)]));\n }\n\n return value;\n}\n\nexport function toExtendedJsonString(\n value: any,\n replacer?: (this: any, key: string, value: any) => any,\n space?: string | number,\n): string;\nexport function toExtendedJsonString(\n value: any,\n replacer?: (number | string)[] | null,\n space?: string | number,\n): string;\nexport function toExtendedJsonString(value: unknown, ...args: any[]): string {\n return JSON.stringify(toExtendedJson(value), ...args);\n}\n\nexport function fromExtendedJson(value: unknown): unknown {\n if (typeof value !== 'object' || value === null) {\n return value;\n }\n\n if ('__map' in value) {\n return new Map(\n (value.__map as [unknown, unknown][]).map(([k, v]) => [\n fromExtendedJson(k),\n fromExtendedJson(v),\n ]),\n );\n }\n\n if ('__set' in value) {\n return new Set((value.__set as unknown[]).map(fromExtendedJson));\n }\n\n if ('__date' in value) {\n return new Date(value.__date as string);\n }\n\n if ('__bigint' in value) {\n return BigInt(value.__bigint as string);\n }\n\n if (Array.isArray(value)) {\n return value.map(fromExtendedJson);\n }\n\n return Object.fromEntries(Object.entries(value).map(([k, v]) => [k, fromExtendedJson(v)]));\n}\n\nexport function fromExtendedJsonString(\n value: string,\n reviver?: (this: any, key: string, value: any) => any,\n): unknown {\n return fromExtendedJson(JSON.parse(value, reviver));\n}\n"],"mappings":";AAAA,SAAgB,eAAe,OAAyB;AACtD,KAAI,iBAAiB,IACnB,QAAO,EACL,OAAO,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC,GAAG,OAAO,CAAC,eAAe,EAAE,EAAE,eAAe,EAAE,CAAC,CAAC,EAC1E;AAGH,KAAI,iBAAiB,IACnB,QAAO,EACL,OAAO,CAAC,GAAG,MAAM,CAAC,IAAI,eAAe,EACtC;AAGH,KAAI,iBAAiB,KACnB,QAAO,EACL,QAAQ,MAAM,aAAa,EAC5B;AAGH,KAAI,OAAO,UAAU,SACnB,QAAO,EACL,UAAU,MAAM,UAAU,EAC3B;AAGH,KAAI,MAAM,QAAQ,MAAM,CACtB,QAAO,MAAM,IAAI,eAAe;AAGlC,KAAI,OAAO,UAAU,YAAY,UAAU,KACzC,QAAO,OAAO,YAAY,OAAO,QAAQ,MAAM,CAAC,KAAK,CAAC,GAAG,OAAO,CAAC,GAAG,eAAe,EAAE,CAAC,CAAC,CAAC;AAG1F,QAAO;;AAaT,SAAgB,qBAAqB,OAAgB,GAAG,MAAqB;AAC3E,QAAO,KAAK,UAAU,eAAe,MAAM,EAAE,GAAG,KAAK;;AAGvD,SAAgB,iBAAiB,OAAyB;AACxD,KAAI,OAAO,UAAU,YAAY,UAAU,KACzC,QAAO;AAGT,KAAI,WAAW,MACb,QAAO,IAAI,IACR,MAAM,MAA+B,KAAK,CAAC,GAAG,OAAO,CACpD,iBAAiB,EAAE,EACnB,iBAAiB,EAAE,CACpB,CAAC,CACH;AAGH,KAAI,WAAW,MACb,QAAO,IAAI,IAAK,MAAM,MAAoB,IAAI,iBAAiB,CAAC;AAGlE,KAAI,YAAY,MACd,QAAO,IAAI,KAAK,MAAM,OAAiB;AAGzC,KAAI,cAAc,MAChB,QAAO,OAAO,MAAM,SAAmB;AAGzC,KAAI,MAAM,QAAQ,MAAM,CACtB,QAAO,MAAM,IAAI,iBAAiB;AAGpC,QAAO,OAAO,YAAY,OAAO,QAAQ,MAAM,CAAC,KAAK,CAAC,GAAG,OAAO,CAAC,GAAG,iBAAiB,EAAE,CAAC,CAAC,CAAC;;AAG5F,SAAgB,uBACd,OACA,SACS;AACT,QAAO,iBAAiB,KAAK,MAAM,OAAO,QAAQ,CAAC"}
@@ -50,4 +50,4 @@ Object.defineProperty(exports, 'toExtendedJsonString', {
50
50
  return toExtendedJsonString;
51
51
  }
52
52
  });
53
- //# sourceMappingURL=extendedJson-Dn2F7Edo.cjs.map
53
+ //# sourceMappingURL=extendedJson-ursQ8DbQ.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"extendedJson-Dn2F7Edo.cjs","names":[],"sources":["../src/lib/extendedJson.ts"],"sourcesContent":["export function toExtendedJson(value: unknown): unknown {\n if (value instanceof Map) {\n return {\n __map: [...value].map(([k, v]) => [toExtendedJson(k), toExtendedJson(v)]),\n };\n }\n\n if (value instanceof Set) {\n return {\n __set: [...value].map(toExtendedJson),\n };\n }\n\n if (value instanceof Date) {\n return {\n __date: value.toISOString(),\n };\n }\n\n if (typeof value === 'bigint') {\n return {\n __bigint: value.toString(),\n };\n }\n\n if (Array.isArray(value)) {\n return value.map(toExtendedJson);\n }\n\n if (typeof value === 'object' && value !== null) {\n return Object.fromEntries(Object.entries(value).map(([k, v]) => [k, toExtendedJson(v)]));\n }\n\n return value;\n}\n\nexport function toExtendedJsonString(\n value: any,\n replacer?: (this: any, key: string, value: any) => any,\n space?: string | number,\n): string;\nexport function toExtendedJsonString(\n value: any,\n replacer?: (number | string)[] | null,\n space?: string | number,\n): string;\nexport function toExtendedJsonString(value: unknown, ...args: any[]): string {\n return JSON.stringify(toExtendedJson(value), ...args);\n}\n\nexport function fromExtendedJson(value: unknown): unknown {\n if (typeof value !== 'object' || value === null) {\n return value;\n }\n\n if ('__map' in value) {\n return new Map(\n (value.__map as [unknown, unknown][]).map(([k, v]) => [\n fromExtendedJson(k),\n fromExtendedJson(v),\n ]),\n );\n }\n\n if ('__set' in value) {\n return new Set((value.__set as unknown[]).map(fromExtendedJson));\n }\n\n if ('__date' in value) {\n return new Date(value.__date as string);\n }\n\n if ('__bigint' in value) {\n return BigInt(value.__bigint as string);\n }\n\n if (Array.isArray(value)) {\n return value.map(fromExtendedJson);\n }\n\n return Object.fromEntries(Object.entries(value).map(([k, v]) => [k, fromExtendedJson(v)]));\n}\n\nexport function fromExtendedJsonString(\n value: string,\n reviver?: (this: any, key: string, value: any) => any,\n): unknown {\n return fromExtendedJson(JSON.parse(value, reviver));\n}\n"],"mappings":";;AAAA,SAAgB,eAAe,OAAyB;AACtD,KAAI,iBAAiB,IACnB,QAAO,EACL,OAAO,CAAC,GAAG,OAAO,KAAK,CAAC,GAAG,OAAO,CAAC,eAAe,IAAI,eAAe;AAIzE,KAAI,iBAAiB,IACnB,QAAO,EACL,OAAO,CAAC,GAAG,OAAO,IAAI;AAI1B,KAAI,iBAAiB,KACnB,QAAO,EACL,QAAQ,MAAM;AAIlB,KAAI,OAAO,UAAU,SACnB,QAAO,EACL,UAAU,MAAM;AAIpB,KAAI,MAAM,QAAQ,OAChB,QAAO,MAAM,IAAI;AAGnB,KAAI,OAAO,UAAU,YAAY,UAAU,KACzC,QAAO,OAAO,YAAY,OAAO,QAAQ,OAAO,KAAK,CAAC,GAAG,OAAO,CAAC,GAAG,eAAe;AAGrF,QAAO;;AAaT,SAAgB,qBAAqB,OAAgB,GAAG,MAAqB;AAC3E,QAAO,KAAK,UAAU,eAAe,QAAQ,GAAG;;AAGlD,SAAgB,iBAAiB,OAAyB;AACxD,KAAI,OAAO,UAAU,YAAY,UAAU,KACzC,QAAO;AAGT,KAAI,WAAW,MACb,QAAO,IAAI,IACR,MAAM,MAA+B,KAAK,CAAC,GAAG,OAAO,CACpD,iBAAiB,IACjB,iBAAiB;AAKvB,KAAI,WAAW,MACb,QAAO,IAAI,IAAK,MAAM,MAAoB,IAAI;AAGhD,KAAI,YAAY,MACd,QAAO,IAAI,KAAK,MAAM;AAGxB,KAAI,cAAc,MAChB,QAAO,OAAO,MAAM;AAGtB,KAAI,MAAM,QAAQ,OAChB,QAAO,MAAM,IAAI;AAGnB,QAAO,OAAO,YAAY,OAAO,QAAQ,OAAO,KAAK,CAAC,GAAG,OAAO,CAAC,GAAG,iBAAiB;;AAGvF,SAAgB,uBACd,OACA,SACS;AACT,QAAO,iBAAiB,KAAK,MAAM,OAAO"}
1
+ {"version":3,"file":"extendedJson-ursQ8DbQ.cjs","names":[],"sources":["../src/lib/extendedJson.ts"],"sourcesContent":["export function toExtendedJson(value: unknown): unknown {\n if (value instanceof Map) {\n return {\n __map: [...value].map(([k, v]) => [toExtendedJson(k), toExtendedJson(v)]),\n };\n }\n\n if (value instanceof Set) {\n return {\n __set: [...value].map(toExtendedJson),\n };\n }\n\n if (value instanceof Date) {\n return {\n __date: value.toISOString(),\n };\n }\n\n if (typeof value === 'bigint') {\n return {\n __bigint: value.toString(),\n };\n }\n\n if (Array.isArray(value)) {\n return value.map(toExtendedJson);\n }\n\n if (typeof value === 'object' && value !== null) {\n return Object.fromEntries(Object.entries(value).map(([k, v]) => [k, toExtendedJson(v)]));\n }\n\n return value;\n}\n\nexport function toExtendedJsonString(\n value: any,\n replacer?: (this: any, key: string, value: any) => any,\n space?: string | number,\n): string;\nexport function toExtendedJsonString(\n value: any,\n replacer?: (number | string)[] | null,\n space?: string | number,\n): string;\nexport function toExtendedJsonString(value: unknown, ...args: any[]): string {\n return JSON.stringify(toExtendedJson(value), ...args);\n}\n\nexport function fromExtendedJson(value: unknown): unknown {\n if (typeof value !== 'object' || value === null) {\n return value;\n }\n\n if ('__map' in value) {\n return new Map(\n (value.__map as [unknown, unknown][]).map(([k, v]) => [\n fromExtendedJson(k),\n fromExtendedJson(v),\n ]),\n );\n }\n\n if ('__set' in value) {\n return new Set((value.__set as unknown[]).map(fromExtendedJson));\n }\n\n if ('__date' in value) {\n return new Date(value.__date as string);\n }\n\n if ('__bigint' in value) {\n return BigInt(value.__bigint as string);\n }\n\n if (Array.isArray(value)) {\n return value.map(fromExtendedJson);\n }\n\n return Object.fromEntries(Object.entries(value).map(([k, v]) => [k, fromExtendedJson(v)]));\n}\n\nexport function fromExtendedJsonString(\n value: string,\n reviver?: (this: any, key: string, value: any) => any,\n): unknown {\n return fromExtendedJson(JSON.parse(value, reviver));\n}\n"],"mappings":";;AAAA,SAAgB,eAAe,OAAyB;AACtD,KAAI,iBAAiB,IACnB,QAAO,EACL,OAAO,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC,GAAG,OAAO,CAAC,eAAe,EAAE,EAAE,eAAe,EAAE,CAAC,CAAC,EAC1E;AAGH,KAAI,iBAAiB,IACnB,QAAO,EACL,OAAO,CAAC,GAAG,MAAM,CAAC,IAAI,eAAe,EACtC;AAGH,KAAI,iBAAiB,KACnB,QAAO,EACL,QAAQ,MAAM,aAAa,EAC5B;AAGH,KAAI,OAAO,UAAU,SACnB,QAAO,EACL,UAAU,MAAM,UAAU,EAC3B;AAGH,KAAI,MAAM,QAAQ,MAAM,CACtB,QAAO,MAAM,IAAI,eAAe;AAGlC,KAAI,OAAO,UAAU,YAAY,UAAU,KACzC,QAAO,OAAO,YAAY,OAAO,QAAQ,MAAM,CAAC,KAAK,CAAC,GAAG,OAAO,CAAC,GAAG,eAAe,EAAE,CAAC,CAAC,CAAC;AAG1F,QAAO;;AAaT,SAAgB,qBAAqB,OAAgB,GAAG,MAAqB;AAC3E,QAAO,KAAK,UAAU,eAAe,MAAM,EAAE,GAAG,KAAK;;AAGvD,SAAgB,iBAAiB,OAAyB;AACxD,KAAI,OAAO,UAAU,YAAY,UAAU,KACzC,QAAO;AAGT,KAAI,WAAW,MACb,QAAO,IAAI,IACR,MAAM,MAA+B,KAAK,CAAC,GAAG,OAAO,CACpD,iBAAiB,EAAE,EACnB,iBAAiB,EAAE,CACpB,CAAC,CACH;AAGH,KAAI,WAAW,MACb,QAAO,IAAI,IAAK,MAAM,MAAoB,IAAI,iBAAiB,CAAC;AAGlE,KAAI,YAAY,MACd,QAAO,IAAI,KAAK,MAAM,OAAiB;AAGzC,KAAI,cAAc,MAChB,QAAO,OAAO,MAAM,SAAmB;AAGzC,KAAI,MAAM,QAAQ,MAAM,CACtB,QAAO,MAAM,IAAI,iBAAiB;AAGpC,QAAO,OAAO,YAAY,OAAO,QAAQ,MAAM,CAAC,KAAK,CAAC,GAAG,OAAO,CAAC,GAAG,iBAAiB,EAAE,CAAC,CAAC,CAAC;;AAG5F,SAAgB,uBACd,OACA,SACS;AACT,QAAO,iBAAiB,KAAK,MAAM,OAAO,QAAQ,CAAC"}
package/dist/index.cjs CHANGED
@@ -1,10 +1,9 @@
1
- const require_store = require('./store-CdST5wJZ.cjs');
2
- const require_propAccess = require('./propAccess-BdLsqViO.cjs');
3
- const require_hash = require('./hash-Dv3XlmHn.cjs');
4
- const require_scope = require('./scope-CfLlLxo9.cjs');
5
- const require_patchMethods = require('./patchMethods-hhlLwtqE.cjs');
6
- const require_extendedJson = require('./extendedJson-Dn2F7Edo.cjs');
7
- const require_persist = require('./persist-DboMIMOK.cjs');
1
+ const require_store = require('./store-C1NYHLgR.cjs');
2
+ const require_propAccess = require('./propAccess-C2AIn9RC.cjs');
3
+ const require_scope = require('./scope-C1bcfK8e.cjs');
4
+ const require_patchMethods = require('./patchMethods-B7Hm5-Qh.cjs');
5
+ const require_extendedJson = require('./extendedJson-ursQ8DbQ.cjs');
6
+ const require_persist = require('./persist-DMbVdqS_.cjs');
8
7
 
9
8
  //#region src/core/pagedCache.ts
10
9
  var PagedCache = class PagedCache extends require_scope.Cache {
@@ -60,10 +59,9 @@ async function loadPage(cache, helpers, oldPages) {
60
59
  });
61
60
  const pages = page === null ? oldPages : oldPages.concat(page);
62
61
  const pageCount = getPageCount?.call(cache, pages) ?? null;
63
- const hasMore = hasMorePages ? hasMorePages.call(cache, pages) : pageCount !== null ? pages.length < pageCount : page !== null;
64
62
  return {
65
63
  pages,
66
- hasMore,
64
+ hasMore: hasMorePages ? hasMorePages.call(cache, pages) : pageCount !== null ? pages.length < pageCount : page !== null,
67
65
  pageCount
68
66
  };
69
67
  }
@@ -107,14 +105,14 @@ exports.findOrDefault = findOrDefault;
107
105
  exports.fromExtendedJson = require_extendedJson.fromExtendedJson;
108
106
  exports.fromExtendedJsonString = require_extendedJson.fromExtendedJsonString;
109
107
  exports.get = require_propAccess.get;
110
- exports.hash = require_hash.hash;
108
+ exports.hash = require_scope.hash;
111
109
  exports.mapMethods = require_store.mapMethods;
112
110
  exports.persist = require_persist.persist;
113
111
  exports.recordMethods = require_store.recordMethods;
114
112
  exports.set = require_propAccess.set;
115
113
  exports.setMethods = require_store.setMethods;
116
114
  exports.shallowEqual = require_propAccess.shallowEqual;
117
- exports.simpleHash = require_hash.simpleHash;
115
+ exports.simpleHash = require_scope.simpleHash;
118
116
  exports.strictEqual = require_propAccess.strictEqual;
119
117
  exports.toExtendedJson = require_extendedJson.toExtendedJson;
120
118
  exports.toExtendedJsonString = require_extendedJson.toExtendedJsonString;
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","names":["Cache","definition: PagedCacheDefinition<T, Args>","internalCreate","options","createPagedCache: typeof createPaged & { defaultOptions: CacheOptions<any, any> }","defaultCacheOptions"],"sources":["../src/core/pagedCache.ts","../src/lib/updateHelpers.ts"],"sourcesContent":["import {\n Cache,\n defaultCacheOptions,\n internalCreate,\n type CacheOptions,\n type CreateCacheResult,\n} from '@core/cache';\nimport type { CalculationActions } from '@core/commonTypes';\nimport { autobind } from '@lib/autobind';\n\nexport interface PageCacheFunctionProps<T> extends CalculationActions<Promise<PagedCacheState<T>>> {\n /**\n * Previously fetched pages (in order).\n */\n pages: T[];\n /**\n * Last fetched page or null if there are no previously fetched pages.\n */\n prevPage: T | null;\n}\n\nexport interface PageCacheFunction<T> {\n (props: PageCacheFunctionProps<T>): Promise<T | null>;\n}\n\nexport interface PagedCacheDefinition<T, Args extends any[]> {\n /**\n * Function to fetch a page.\n * The function receives the current state of the cache, including previously fetched pages.\n */\n fetchPage: (this: PagedCache<T, Args>, props: PageCacheFunctionProps<T>) => Promise<T | null>;\n /**\n * Optional function to determine the total number of pages - usually based on data in the fetched pages.\n */\n getPageCount?: (this: PagedCache<T, Args>, pages: T[]) => number | null;\n /**\n * Optional function to determine if there are more pages to fetch - usually based on data in the fetched pages.\n * If not provided, it will be assumed there are more pages until getPageCount is provided and the number of fetched pages equals the page count or until fetchPage returns null.\n */\n hasMorePages?: (this: PagedCache<T, Args>, pages: T[]) => boolean;\n}\n\nexport interface PagedCacheDefinitionFunction<T, Args extends any[]> {\n (...args: Args): PagedCacheDefinition<T, Args>;\n}\n\nexport interface PagedCacheState<T> {\n pages: T[];\n hasMore: boolean;\n pageCount: number | null;\n}\n\nexport interface FetchNextPageOptions {\n /**\n * If true, will throw if the cache is in an error state or if another page is being fetched.\n */\n throwOnError?: boolean;\n}\n\nexport class PagedCache<T, Args extends any[] = []> extends Cache<PagedCacheState<T>, Args> {\n constructor(\n public readonly definition: PagedCacheDefinition<T, Args>,\n args: Args,\n options: CacheOptions<PagedCacheState<T>, Args> = {},\n ) {\n super(async (helpers) => loadPage(this, helpers, []), args, options, undefined);\n autobind(PagedCache);\n }\n\n async fetchNextPage({ throwOnError }: FetchNextPageOptions = {}): Promise<void> {\n const { status, isStale, isUpdating, value } = this.state.get();\n\n if (status === 'error') {\n if (!throwOnError) return;\n throw new Error('Cannot fetch next page while cache is in error state');\n }\n\n if (isUpdating) {\n if (!throwOnError) return;\n throw new Error('Cannot fetch next page while another page is being fetched');\n }\n\n if (status === 'pending' || isStale) {\n await this.get().catch(() => {});\n return;\n }\n\n if (!value.hasMore) {\n if (!throwOnError) return;\n throw new Error('No more pages to fetch');\n }\n\n this.stalePromise = this.calculatedValue?.value;\n\n const ac = new AbortController();\n const promise = loadPage(\n this,\n {\n use() {\n throw new Error('Not implemented');\n },\n connect() {\n throw new Error('Not implemented');\n },\n signal: ac.signal,\n },\n value.pages,\n );\n\n this.updateValue(promise);\n\n try {\n await promise;\n } catch (error) {\n if (!throwOnError) return;\n throw error;\n }\n }\n}\n\nasync function loadPage<T, Args extends any[]>(\n cache: PagedCache<T, Args>,\n helpers: CalculationActions<Promise<PagedCacheState<T>>>,\n oldPages: T[],\n) {\n const { fetchPage, hasMorePages, getPageCount } = cache.definition;\n\n const page = await fetchPage.call(cache, {\n ...helpers,\n pages: oldPages,\n prevPage: oldPages.length > 0 ? oldPages[oldPages.length - 1]! : null,\n });\n\n const pages = page === null ? oldPages : oldPages.concat(page);\n const pageCount = getPageCount?.call(cache, pages) ?? null;\n const hasMore = hasMorePages\n ? hasMorePages.call(cache, pages)\n : pageCount !== null\n ? pages.length < pageCount\n : page !== null;\n\n return { pages, hasMore, pageCount };\n}\n\nfunction createPaged<T, Args extends any[] = []>(\n definition: PagedCacheDefinitionFunction<T, Args>,\n options?: CacheOptions<PagedCacheState<T>, Args>,\n): CreateCacheResult<PagedCacheState<T>, Args, PagedCache<T, Args>>;\n\nfunction createPaged<T>(\n definition: PagedCacheDefinition<T, []>,\n options?: CacheOptions<PagedCacheState<T>, []>,\n): CreateCacheResult<PagedCacheState<T>, [], PagedCache<T, []>>;\n\nfunction createPaged<T, Args extends any[] = []>(\n definition: PagedCacheDefinitionFunction<T, Args> | PagedCacheDefinition<T, Args>,\n options?: CacheOptions<PagedCacheState<T>, Args>,\n): CreateCacheResult<PagedCacheState<T>, Args, PagedCache<T, Args>> {\n return internalCreate<PagedCacheState<T>, Args, PagedCache<T, Args>>((args, options) => {\n let currentDefinition = definition;\n if (currentDefinition instanceof Function) {\n currentDefinition = currentDefinition(...args);\n }\n return new PagedCache(currentDefinition, args, options);\n }, options);\n}\n\nexport const createPagedCache: typeof createPaged & { defaultOptions: CacheOptions<any, any> } =\n /* @__PURE__ */ Object.assign(createPaged, {\n defaultOptions: defaultCacheOptions,\n });\n","export function findOrDefault<T>(\n array: T[],\n predicate: (item: T) => boolean,\n defaultValue: T | (() => T),\n): T {\n const index = array.findIndex(predicate);\n\n if (index >= 0) {\n return array[index]!;\n }\n\n const value = defaultValue instanceof Function ? defaultValue() : defaultValue;\n array.push(value);\n return value;\n}\n"],"mappings":";;;;;;;;;AA2DA,IAAa,aAAb,MAAa,mBAA+CA,oBAAgC;CAC1F,YACE,AAAgBC,YAChB,MACA,UAAkD,IAClD;AACA,QAAM,OAAO,YAAY,SAAS,MAAM,SAAS,KAAK,MAAM,SAAS;EAJrD;AAKhB,yBAAS;;CAGX,MAAM,cAAc,EAAE,iBAAuC,IAAmB;EAC9E,MAAM,EAAE,QAAQ,SAAS,YAAY,UAAU,KAAK,MAAM;AAE1D,MAAI,WAAW,SAAS;AACtB,OAAI,CAAC,aAAc;AACnB,SAAM,IAAI,MAAM;;AAGlB,MAAI,YAAY;AACd,OAAI,CAAC,aAAc;AACnB,SAAM,IAAI,MAAM;;AAGlB,MAAI,WAAW,aAAa,SAAS;AACnC,SAAM,KAAK,MAAM,YAAY;AAC7B;;AAGF,MAAI,CAAC,MAAM,SAAS;AAClB,OAAI,CAAC,aAAc;AACnB,SAAM,IAAI,MAAM;;AAGlB,OAAK,eAAe,KAAK,iBAAiB;EAE1C,MAAM,KAAK,IAAI;EACf,MAAM,UAAU,SACd,MACA;GACE,MAAM;AACJ,UAAM,IAAI,MAAM;;GAElB,UAAU;AACR,UAAM,IAAI,MAAM;;GAElB,QAAQ,GAAG;KAEb,MAAM;AAGR,OAAK,YAAY;AAEjB,MAAI;AACF,SAAM;WACC,OAAO;AACd,OAAI,CAAC,aAAc;AACnB,SAAM;;;;AAKZ,eAAe,SACb,OACA,SACA,UACA;CACA,MAAM,EAAE,WAAW,cAAc,iBAAiB,MAAM;CAExD,MAAM,OAAO,MAAM,UAAU,KAAK,OAAO;EACvC,GAAG;EACH,OAAO;EACP,UAAU,SAAS,SAAS,IAAI,SAAS,SAAS,SAAS,KAAM;;CAGnE,MAAM,QAAQ,SAAS,OAAO,WAAW,SAAS,OAAO;CACzD,MAAM,YAAY,cAAc,KAAK,OAAO,UAAU;CACtD,MAAM,UAAU,eACZ,aAAa,KAAK,OAAO,SACzB,cAAc,OACZ,MAAM,SAAS,YACf,SAAS;AAEf,QAAO;EAAE;EAAO;EAAS;;;AAa3B,SAAS,YACP,YACA,SACkE;AAClE,QAAOC,8BAA+D,MAAM,cAAY;EACtF,IAAI,oBAAoB;AACxB,MAAI,6BAA6B,SAC/B,qBAAoB,kBAAkB,GAAG;AAE3C,SAAO,IAAI,WAAW,mBAAmB,MAAMC;IAC9C;;AAGL,MAAaC,mBACK,uBAAO,OAAO,aAAa,EACzC,gBAAgBC;;;;ACzKpB,SAAgB,cACd,OACA,WACA,cACG;CACH,MAAM,QAAQ,MAAM,UAAU;AAE9B,KAAI,SAAS,EACX,QAAO,MAAM;CAGf,MAAM,QAAQ,wBAAwB,WAAW,iBAAiB;AAClE,OAAM,KAAK;AACX,QAAO"}
1
+ {"version":3,"file":"index.cjs","names":["Cache","definition: PagedCacheDefinition<T, Args>","internalCreate","options","createPagedCache: typeof createPaged & { defaultOptions: CacheOptions<any, any> }","defaultCacheOptions"],"sources":["../src/core/pagedCache.ts","../src/lib/updateHelpers.ts"],"sourcesContent":["import {\n Cache,\n defaultCacheOptions,\n internalCreate,\n type CacheOptions,\n type CreateCacheResult,\n} from '@core/cache';\nimport type { CalculationActions } from '@core/commonTypes';\nimport { autobind } from '@lib/autobind';\n\nexport interface PageCacheFunctionProps<T> extends CalculationActions<Promise<PagedCacheState<T>>> {\n /**\n * Previously fetched pages (in order).\n */\n pages: T[];\n /**\n * Last fetched page or null if there are no previously fetched pages.\n */\n prevPage: T | null;\n}\n\nexport interface PageCacheFunction<T> {\n (props: PageCacheFunctionProps<T>): Promise<T | null>;\n}\n\nexport interface PagedCacheDefinition<T, Args extends any[]> {\n /**\n * Function to fetch a page.\n * The function receives the current state of the cache, including previously fetched pages.\n */\n fetchPage: (this: PagedCache<T, Args>, props: PageCacheFunctionProps<T>) => Promise<T | null>;\n /**\n * Optional function to determine the total number of pages - usually based on data in the fetched pages.\n */\n getPageCount?: (this: PagedCache<T, Args>, pages: T[]) => number | null;\n /**\n * Optional function to determine if there are more pages to fetch - usually based on data in the fetched pages.\n * If not provided, it will be assumed there are more pages until getPageCount is provided and the number of fetched pages equals the page count or until fetchPage returns null.\n */\n hasMorePages?: (this: PagedCache<T, Args>, pages: T[]) => boolean;\n}\n\nexport interface PagedCacheDefinitionFunction<T, Args extends any[]> {\n (...args: Args): PagedCacheDefinition<T, Args>;\n}\n\nexport interface PagedCacheState<T> {\n pages: T[];\n hasMore: boolean;\n pageCount: number | null;\n}\n\nexport interface FetchNextPageOptions {\n /**\n * If true, will throw if the cache is in an error state or if another page is being fetched.\n */\n throwOnError?: boolean;\n}\n\nexport class PagedCache<T, Args extends any[] = []> extends Cache<PagedCacheState<T>, Args> {\n constructor(\n public readonly definition: PagedCacheDefinition<T, Args>,\n args: Args,\n options: CacheOptions<PagedCacheState<T>, Args> = {},\n ) {\n super(async (helpers) => loadPage(this, helpers, []), args, options, undefined);\n autobind(PagedCache);\n }\n\n async fetchNextPage({ throwOnError }: FetchNextPageOptions = {}): Promise<void> {\n const { status, isStale, isUpdating, value } = this.state.get();\n\n if (status === 'error') {\n if (!throwOnError) return;\n throw new Error('Cannot fetch next page while cache is in error state');\n }\n\n if (isUpdating) {\n if (!throwOnError) return;\n throw new Error('Cannot fetch next page while another page is being fetched');\n }\n\n if (status === 'pending' || isStale) {\n await this.get().catch(() => {});\n return;\n }\n\n if (!value.hasMore) {\n if (!throwOnError) return;\n throw new Error('No more pages to fetch');\n }\n\n this.stalePromise = this.calculatedValue?.value;\n\n const ac = new AbortController();\n const promise = loadPage(\n this,\n {\n use() {\n throw new Error('Not implemented');\n },\n connect() {\n throw new Error('Not implemented');\n },\n signal: ac.signal,\n },\n value.pages,\n );\n\n this.updateValue(promise);\n\n try {\n await promise;\n } catch (error) {\n if (!throwOnError) return;\n throw error;\n }\n }\n}\n\nasync function loadPage<T, Args extends any[]>(\n cache: PagedCache<T, Args>,\n helpers: CalculationActions<Promise<PagedCacheState<T>>>,\n oldPages: T[],\n) {\n const { fetchPage, hasMorePages, getPageCount } = cache.definition;\n\n const page = await fetchPage.call(cache, {\n ...helpers,\n pages: oldPages,\n prevPage: oldPages.length > 0 ? oldPages[oldPages.length - 1]! : null,\n });\n\n const pages = page === null ? oldPages : oldPages.concat(page);\n const pageCount = getPageCount?.call(cache, pages) ?? null;\n const hasMore = hasMorePages\n ? hasMorePages.call(cache, pages)\n : pageCount !== null\n ? pages.length < pageCount\n : page !== null;\n\n return { pages, hasMore, pageCount };\n}\n\nfunction createPaged<T, Args extends any[] = []>(\n definition: PagedCacheDefinitionFunction<T, Args>,\n options?: CacheOptions<PagedCacheState<T>, Args>,\n): CreateCacheResult<PagedCacheState<T>, Args, PagedCache<T, Args>>;\n\nfunction createPaged<T>(\n definition: PagedCacheDefinition<T, []>,\n options?: CacheOptions<PagedCacheState<T>, []>,\n): CreateCacheResult<PagedCacheState<T>, [], PagedCache<T, []>>;\n\nfunction createPaged<T, Args extends any[] = []>(\n definition: PagedCacheDefinitionFunction<T, Args> | PagedCacheDefinition<T, Args>,\n options?: CacheOptions<PagedCacheState<T>, Args>,\n): CreateCacheResult<PagedCacheState<T>, Args, PagedCache<T, Args>> {\n return internalCreate<PagedCacheState<T>, Args, PagedCache<T, Args>>((args, options) => {\n let currentDefinition = definition;\n if (currentDefinition instanceof Function) {\n currentDefinition = currentDefinition(...args);\n }\n return new PagedCache(currentDefinition, args, options);\n }, options);\n}\n\nexport const createPagedCache: typeof createPaged & { defaultOptions: CacheOptions<any, any> } =\n /* @__PURE__ */ Object.assign(createPaged, {\n defaultOptions: defaultCacheOptions,\n });\n","export function findOrDefault<T>(\n array: T[],\n predicate: (item: T) => boolean,\n defaultValue: T | (() => T),\n): T {\n const index = array.findIndex(predicate);\n\n if (index >= 0) {\n return array[index]!;\n }\n\n const value = defaultValue instanceof Function ? defaultValue() : defaultValue;\n array.push(value);\n return value;\n}\n"],"mappings":";;;;;;;;AA2DA,IAAa,aAAb,MAAa,mBAA+CA,oBAAgC;CAC1F,YACE,AAAgBC,YAChB,MACA,UAAkD,EAAE,EACpD;AACA,QAAM,OAAO,YAAY,SAAS,MAAM,SAAS,EAAE,CAAC,EAAE,MAAM,SAAS,OAAU;EAJ/D;AAKhB,yBAAS,WAAW;;CAGtB,MAAM,cAAc,EAAE,iBAAuC,EAAE,EAAiB;EAC9E,MAAM,EAAE,QAAQ,SAAS,YAAY,UAAU,KAAK,MAAM,KAAK;AAE/D,MAAI,WAAW,SAAS;AACtB,OAAI,CAAC,aAAc;AACnB,SAAM,IAAI,MAAM,uDAAuD;;AAGzE,MAAI,YAAY;AACd,OAAI,CAAC,aAAc;AACnB,SAAM,IAAI,MAAM,6DAA6D;;AAG/E,MAAI,WAAW,aAAa,SAAS;AACnC,SAAM,KAAK,KAAK,CAAC,YAAY,GAAG;AAChC;;AAGF,MAAI,CAAC,MAAM,SAAS;AAClB,OAAI,CAAC,aAAc;AACnB,SAAM,IAAI,MAAM,yBAAyB;;AAG3C,OAAK,eAAe,KAAK,iBAAiB;EAE1C,MAAM,KAAK,IAAI,iBAAiB;EAChC,MAAM,UAAU,SACd,MACA;GACE,MAAM;AACJ,UAAM,IAAI,MAAM,kBAAkB;;GAEpC,UAAU;AACR,UAAM,IAAI,MAAM,kBAAkB;;GAEpC,QAAQ,GAAG;GACZ,EACD,MAAM,MACP;AAED,OAAK,YAAY,QAAQ;AAEzB,MAAI;AACF,SAAM;WACC,OAAO;AACd,OAAI,CAAC,aAAc;AACnB,SAAM;;;;AAKZ,eAAe,SACb,OACA,SACA,UACA;CACA,MAAM,EAAE,WAAW,cAAc,iBAAiB,MAAM;CAExD,MAAM,OAAO,MAAM,UAAU,KAAK,OAAO;EACvC,GAAG;EACH,OAAO;EACP,UAAU,SAAS,SAAS,IAAI,SAAS,SAAS,SAAS,KAAM;EAClE,CAAC;CAEF,MAAM,QAAQ,SAAS,OAAO,WAAW,SAAS,OAAO,KAAK;CAC9D,MAAM,YAAY,cAAc,KAAK,OAAO,MAAM,IAAI;AAOtD,QAAO;EAAE;EAAO,SANA,eACZ,aAAa,KAAK,OAAO,MAAM,GAC/B,cAAc,OACZ,MAAM,SAAS,YACf,SAAS;EAEU;EAAW;;AAatC,SAAS,YACP,YACA,SACkE;AAClE,QAAOC,8BAA+D,MAAM,cAAY;EACtF,IAAI,oBAAoB;AACxB,MAAI,6BAA6B,SAC/B,qBAAoB,kBAAkB,GAAG,KAAK;AAEhD,SAAO,IAAI,WAAW,mBAAmB,MAAMC,UAAQ;IACtD,QAAQ;;AAGb,MAAaC,mBACK,uBAAO,OAAO,aAAa,EACzC,gBAAgBC,mCACjB,CAAC;;;;AC1KJ,SAAgB,cACd,OACA,WACA,cACG;CACH,MAAM,QAAQ,MAAM,UAAU,UAAU;AAExC,KAAI,SAAS,EACX,QAAO,MAAM;CAGf,MAAM,QAAQ,wBAAwB,WAAW,cAAc,GAAG;AAClE,OAAM,KAAK,MAAM;AACjB,QAAO"}
package/dist/index.d.cts CHANGED
@@ -1,7 +1,7 @@
1
- import { Cache, CacheBundle, CacheFunction, CacheGetOptions, CacheOptions, CacheState, CreateCacheResult, ErrorState, PendingState, Resource, ResourceGroup, Scope, ValueState, allResources, createCache, createResourceGroup, createScope } from "./scope-CcBxgcrs.cjs";
2
- import { AsyncConnectionActions, AsyncUpdateFunction, BaseConnectionActions, BoundStoreMethods, CalculationActions, Cancel, Connection, ConnectionActions, Constrain, DisposableCancel, Duration, Effect, KeyType, Listener, Path, PathAsArray, PathAsString, Selector, SettablePath, SettablePathAsArray, SettablePathAsString, SettableValue, Store, StoreMethods, StoreOptions, StoreOptionsWithMethods, SubscribeOptions, Update, UpdateFrom, UpdateFunction, Use, Value, arrayMethods, createStore, mapMethods, recordMethods, setMethods } from "./store-MBrcOgtz.cjs";
3
- import { Patch, diff } from "./diff-BslUrJZE.cjs";
4
- import { Persist, PersistOptions, PersistStorage, PersistStorageBase, PersistStorageWithKeys, PersistStorageWithLength, PersistStorageWithListItems, persist } from "./persist-DVKRq8RQ.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-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";
5
5
 
6
6
  //#region src/core/pagedCache.d.ts
7
7
  interface PageCacheFunctionProps<T> extends CalculationActions<Promise<PagedCacheState<T>>> {
package/dist/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
- import { Cache, CacheBundle, CacheFunction, CacheGetOptions, CacheOptions, CacheState, CreateCacheResult, ErrorState, PendingState, Resource, ResourceGroup, Scope, ValueState, allResources, createCache, createResourceGroup, createScope } from "./scope-D3jkIPgn.js";
2
- import { AsyncConnectionActions, AsyncUpdateFunction, BaseConnectionActions, BoundStoreMethods, CalculationActions, Cancel, Connection, ConnectionActions, Constrain, DisposableCancel, Duration, Effect, KeyType, Listener, Path, PathAsArray, PathAsString, Selector, SettablePath, SettablePathAsArray, SettablePathAsString, SettableValue, Store, StoreMethods, StoreOptions, StoreOptionsWithMethods, SubscribeOptions, Update, UpdateFrom, UpdateFunction, Use, Value, arrayMethods, createStore, mapMethods, recordMethods, setMethods } from "./store-DnZ6fsiJ.js";
3
- import { Patch, diff } from "./diff-CElc7pJI.js";
4
- import { Persist, PersistOptions, PersistStorage, PersistStorageBase, PersistStorageWithKeys, PersistStorageWithLength, PersistStorageWithListItems, persist } from "./persist-olbNkcdZ.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-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";
5
5
 
6
6
  //#region src/core/pagedCache.d.ts
7
7
  interface PageCacheFunctionProps<T> extends CalculationActions<Promise<PagedCacheState<T>>> {
package/dist/index.js CHANGED
@@ -1,10 +1,9 @@
1
- import { Store, arrayMethods, autobind, calcDuration, createStore, mapMethods, recordMethods, setMethods } from "./store-Dx8w7yT-.js";
2
- import { deepEqual, get, set, shallowEqual, strictEqual } from "./propAccess-B260LXN1.js";
3
- import { hash, simpleHash } from "./hash-DNFM5y_h.js";
4
- import { Cache, InstanceCache, ResourceGroup, Scope, allResources, createCache, createResourceGroup, createScope, defaultCacheOptions, internalCreate } from "./scope-7LeON9bZ.js";
5
- import { applyPatches, diff } from "./patchMethods-C_f3PORQ.js";
6
- import { fromExtendedJson, fromExtendedJsonString, toExtendedJson, toExtendedJsonString } from "./extendedJson-BZkQBXEv.js";
7
- import { persist } from "./persist-CLgS5Cqw.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-v3RYWzVg.js";
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";
4
+ import { i as applyPatches, r as diff } from "./patchMethods-iK2F87G0.js";
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";
8
7
 
9
8
  //#region src/core/pagedCache.ts
10
9
  var PagedCache = class PagedCache extends Cache {
@@ -60,10 +59,9 @@ async function loadPage(cache, helpers, oldPages) {
60
59
  });
61
60
  const pages = page === null ? oldPages : oldPages.concat(page);
62
61
  const pageCount = getPageCount?.call(cache, pages) ?? null;
63
- const hasMore = hasMorePages ? hasMorePages.call(cache, pages) : pageCount !== null ? pages.length < pageCount : page !== null;
64
62
  return {
65
63
  pages,
66
- hasMore,
64
+ hasMore: hasMorePages ? hasMorePages.call(cache, pages) : pageCount !== null ? pages.length < pageCount : page !== null,
67
65
  pageCount
68
66
  };
69
67
  }
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["definition: PagedCacheDefinition<T, Args>","options","createPagedCache: typeof createPaged & { defaultOptions: CacheOptions<any, any> }"],"sources":["../src/core/pagedCache.ts","../src/lib/updateHelpers.ts"],"sourcesContent":["import {\n Cache,\n defaultCacheOptions,\n internalCreate,\n type CacheOptions,\n type CreateCacheResult,\n} from '@core/cache';\nimport type { CalculationActions } from '@core/commonTypes';\nimport { autobind } from '@lib/autobind';\n\nexport interface PageCacheFunctionProps<T> extends CalculationActions<Promise<PagedCacheState<T>>> {\n /**\n * Previously fetched pages (in order).\n */\n pages: T[];\n /**\n * Last fetched page or null if there are no previously fetched pages.\n */\n prevPage: T | null;\n}\n\nexport interface PageCacheFunction<T> {\n (props: PageCacheFunctionProps<T>): Promise<T | null>;\n}\n\nexport interface PagedCacheDefinition<T, Args extends any[]> {\n /**\n * Function to fetch a page.\n * The function receives the current state of the cache, including previously fetched pages.\n */\n fetchPage: (this: PagedCache<T, Args>, props: PageCacheFunctionProps<T>) => Promise<T | null>;\n /**\n * Optional function to determine the total number of pages - usually based on data in the fetched pages.\n */\n getPageCount?: (this: PagedCache<T, Args>, pages: T[]) => number | null;\n /**\n * Optional function to determine if there are more pages to fetch - usually based on data in the fetched pages.\n * If not provided, it will be assumed there are more pages until getPageCount is provided and the number of fetched pages equals the page count or until fetchPage returns null.\n */\n hasMorePages?: (this: PagedCache<T, Args>, pages: T[]) => boolean;\n}\n\nexport interface PagedCacheDefinitionFunction<T, Args extends any[]> {\n (...args: Args): PagedCacheDefinition<T, Args>;\n}\n\nexport interface PagedCacheState<T> {\n pages: T[];\n hasMore: boolean;\n pageCount: number | null;\n}\n\nexport interface FetchNextPageOptions {\n /**\n * If true, will throw if the cache is in an error state or if another page is being fetched.\n */\n throwOnError?: boolean;\n}\n\nexport class PagedCache<T, Args extends any[] = []> extends Cache<PagedCacheState<T>, Args> {\n constructor(\n public readonly definition: PagedCacheDefinition<T, Args>,\n args: Args,\n options: CacheOptions<PagedCacheState<T>, Args> = {},\n ) {\n super(async (helpers) => loadPage(this, helpers, []), args, options, undefined);\n autobind(PagedCache);\n }\n\n async fetchNextPage({ throwOnError }: FetchNextPageOptions = {}): Promise<void> {\n const { status, isStale, isUpdating, value } = this.state.get();\n\n if (status === 'error') {\n if (!throwOnError) return;\n throw new Error('Cannot fetch next page while cache is in error state');\n }\n\n if (isUpdating) {\n if (!throwOnError) return;\n throw new Error('Cannot fetch next page while another page is being fetched');\n }\n\n if (status === 'pending' || isStale) {\n await this.get().catch(() => {});\n return;\n }\n\n if (!value.hasMore) {\n if (!throwOnError) return;\n throw new Error('No more pages to fetch');\n }\n\n this.stalePromise = this.calculatedValue?.value;\n\n const ac = new AbortController();\n const promise = loadPage(\n this,\n {\n use() {\n throw new Error('Not implemented');\n },\n connect() {\n throw new Error('Not implemented');\n },\n signal: ac.signal,\n },\n value.pages,\n );\n\n this.updateValue(promise);\n\n try {\n await promise;\n } catch (error) {\n if (!throwOnError) return;\n throw error;\n }\n }\n}\n\nasync function loadPage<T, Args extends any[]>(\n cache: PagedCache<T, Args>,\n helpers: CalculationActions<Promise<PagedCacheState<T>>>,\n oldPages: T[],\n) {\n const { fetchPage, hasMorePages, getPageCount } = cache.definition;\n\n const page = await fetchPage.call(cache, {\n ...helpers,\n pages: oldPages,\n prevPage: oldPages.length > 0 ? oldPages[oldPages.length - 1]! : null,\n });\n\n const pages = page === null ? oldPages : oldPages.concat(page);\n const pageCount = getPageCount?.call(cache, pages) ?? null;\n const hasMore = hasMorePages\n ? hasMorePages.call(cache, pages)\n : pageCount !== null\n ? pages.length < pageCount\n : page !== null;\n\n return { pages, hasMore, pageCount };\n}\n\nfunction createPaged<T, Args extends any[] = []>(\n definition: PagedCacheDefinitionFunction<T, Args>,\n options?: CacheOptions<PagedCacheState<T>, Args>,\n): CreateCacheResult<PagedCacheState<T>, Args, PagedCache<T, Args>>;\n\nfunction createPaged<T>(\n definition: PagedCacheDefinition<T, []>,\n options?: CacheOptions<PagedCacheState<T>, []>,\n): CreateCacheResult<PagedCacheState<T>, [], PagedCache<T, []>>;\n\nfunction createPaged<T, Args extends any[] = []>(\n definition: PagedCacheDefinitionFunction<T, Args> | PagedCacheDefinition<T, Args>,\n options?: CacheOptions<PagedCacheState<T>, Args>,\n): CreateCacheResult<PagedCacheState<T>, Args, PagedCache<T, Args>> {\n return internalCreate<PagedCacheState<T>, Args, PagedCache<T, Args>>((args, options) => {\n let currentDefinition = definition;\n if (currentDefinition instanceof Function) {\n currentDefinition = currentDefinition(...args);\n }\n return new PagedCache(currentDefinition, args, options);\n }, options);\n}\n\nexport const createPagedCache: typeof createPaged & { defaultOptions: CacheOptions<any, any> } =\n /* @__PURE__ */ Object.assign(createPaged, {\n defaultOptions: defaultCacheOptions,\n });\n","export function findOrDefault<T>(\n array: T[],\n predicate: (item: T) => boolean,\n defaultValue: T | (() => T),\n): T {\n const index = array.findIndex(predicate);\n\n if (index >= 0) {\n return array[index]!;\n }\n\n const value = defaultValue instanceof Function ? defaultValue() : defaultValue;\n array.push(value);\n return value;\n}\n"],"mappings":";;;;;;;;;AA2DA,IAAa,aAAb,MAAa,mBAA+C,MAAgC;CAC1F,YACE,AAAgBA,YAChB,MACA,UAAkD,IAClD;AACA,QAAM,OAAO,YAAY,SAAS,MAAM,SAAS,KAAK,MAAM,SAAS;EAJrD;AAKhB,WAAS;;CAGX,MAAM,cAAc,EAAE,iBAAuC,IAAmB;EAC9E,MAAM,EAAE,QAAQ,SAAS,YAAY,UAAU,KAAK,MAAM;AAE1D,MAAI,WAAW,SAAS;AACtB,OAAI,CAAC,aAAc;AACnB,SAAM,IAAI,MAAM;;AAGlB,MAAI,YAAY;AACd,OAAI,CAAC,aAAc;AACnB,SAAM,IAAI,MAAM;;AAGlB,MAAI,WAAW,aAAa,SAAS;AACnC,SAAM,KAAK,MAAM,YAAY;AAC7B;;AAGF,MAAI,CAAC,MAAM,SAAS;AAClB,OAAI,CAAC,aAAc;AACnB,SAAM,IAAI,MAAM;;AAGlB,OAAK,eAAe,KAAK,iBAAiB;EAE1C,MAAM,KAAK,IAAI;EACf,MAAM,UAAU,SACd,MACA;GACE,MAAM;AACJ,UAAM,IAAI,MAAM;;GAElB,UAAU;AACR,UAAM,IAAI,MAAM;;GAElB,QAAQ,GAAG;KAEb,MAAM;AAGR,OAAK,YAAY;AAEjB,MAAI;AACF,SAAM;WACC,OAAO;AACd,OAAI,CAAC,aAAc;AACnB,SAAM;;;;AAKZ,eAAe,SACb,OACA,SACA,UACA;CACA,MAAM,EAAE,WAAW,cAAc,iBAAiB,MAAM;CAExD,MAAM,OAAO,MAAM,UAAU,KAAK,OAAO;EACvC,GAAG;EACH,OAAO;EACP,UAAU,SAAS,SAAS,IAAI,SAAS,SAAS,SAAS,KAAM;;CAGnE,MAAM,QAAQ,SAAS,OAAO,WAAW,SAAS,OAAO;CACzD,MAAM,YAAY,cAAc,KAAK,OAAO,UAAU;CACtD,MAAM,UAAU,eACZ,aAAa,KAAK,OAAO,SACzB,cAAc,OACZ,MAAM,SAAS,YACf,SAAS;AAEf,QAAO;EAAE;EAAO;EAAS;;;AAa3B,SAAS,YACP,YACA,SACkE;AAClE,QAAO,gBAA+D,MAAM,cAAY;EACtF,IAAI,oBAAoB;AACxB,MAAI,6BAA6B,SAC/B,qBAAoB,kBAAkB,GAAG;AAE3C,SAAO,IAAI,WAAW,mBAAmB,MAAMC;IAC9C;;AAGL,MAAaC,mBACK,uBAAO,OAAO,aAAa,EACzC,gBAAgB;;;;ACzKpB,SAAgB,cACd,OACA,WACA,cACG;CACH,MAAM,QAAQ,MAAM,UAAU;AAE9B,KAAI,SAAS,EACX,QAAO,MAAM;CAGf,MAAM,QAAQ,wBAAwB,WAAW,iBAAiB;AAClE,OAAM,KAAK;AACX,QAAO"}
1
+ {"version":3,"file":"index.js","names":["definition: PagedCacheDefinition<T, Args>","options","createPagedCache: typeof createPaged & { defaultOptions: CacheOptions<any, any> }"],"sources":["../src/core/pagedCache.ts","../src/lib/updateHelpers.ts"],"sourcesContent":["import {\n Cache,\n defaultCacheOptions,\n internalCreate,\n type CacheOptions,\n type CreateCacheResult,\n} from '@core/cache';\nimport type { CalculationActions } from '@core/commonTypes';\nimport { autobind } from '@lib/autobind';\n\nexport interface PageCacheFunctionProps<T> extends CalculationActions<Promise<PagedCacheState<T>>> {\n /**\n * Previously fetched pages (in order).\n */\n pages: T[];\n /**\n * Last fetched page or null if there are no previously fetched pages.\n */\n prevPage: T | null;\n}\n\nexport interface PageCacheFunction<T> {\n (props: PageCacheFunctionProps<T>): Promise<T | null>;\n}\n\nexport interface PagedCacheDefinition<T, Args extends any[]> {\n /**\n * Function to fetch a page.\n * The function receives the current state of the cache, including previously fetched pages.\n */\n fetchPage: (this: PagedCache<T, Args>, props: PageCacheFunctionProps<T>) => Promise<T | null>;\n /**\n * Optional function to determine the total number of pages - usually based on data in the fetched pages.\n */\n getPageCount?: (this: PagedCache<T, Args>, pages: T[]) => number | null;\n /**\n * Optional function to determine if there are more pages to fetch - usually based on data in the fetched pages.\n * If not provided, it will be assumed there are more pages until getPageCount is provided and the number of fetched pages equals the page count or until fetchPage returns null.\n */\n hasMorePages?: (this: PagedCache<T, Args>, pages: T[]) => boolean;\n}\n\nexport interface PagedCacheDefinitionFunction<T, Args extends any[]> {\n (...args: Args): PagedCacheDefinition<T, Args>;\n}\n\nexport interface PagedCacheState<T> {\n pages: T[];\n hasMore: boolean;\n pageCount: number | null;\n}\n\nexport interface FetchNextPageOptions {\n /**\n * If true, will throw if the cache is in an error state or if another page is being fetched.\n */\n throwOnError?: boolean;\n}\n\nexport class PagedCache<T, Args extends any[] = []> extends Cache<PagedCacheState<T>, Args> {\n constructor(\n public readonly definition: PagedCacheDefinition<T, Args>,\n args: Args,\n options: CacheOptions<PagedCacheState<T>, Args> = {},\n ) {\n super(async (helpers) => loadPage(this, helpers, []), args, options, undefined);\n autobind(PagedCache);\n }\n\n async fetchNextPage({ throwOnError }: FetchNextPageOptions = {}): Promise<void> {\n const { status, isStale, isUpdating, value } = this.state.get();\n\n if (status === 'error') {\n if (!throwOnError) return;\n throw new Error('Cannot fetch next page while cache is in error state');\n }\n\n if (isUpdating) {\n if (!throwOnError) return;\n throw new Error('Cannot fetch next page while another page is being fetched');\n }\n\n if (status === 'pending' || isStale) {\n await this.get().catch(() => {});\n return;\n }\n\n if (!value.hasMore) {\n if (!throwOnError) return;\n throw new Error('No more pages to fetch');\n }\n\n this.stalePromise = this.calculatedValue?.value;\n\n const ac = new AbortController();\n const promise = loadPage(\n this,\n {\n use() {\n throw new Error('Not implemented');\n },\n connect() {\n throw new Error('Not implemented');\n },\n signal: ac.signal,\n },\n value.pages,\n );\n\n this.updateValue(promise);\n\n try {\n await promise;\n } catch (error) {\n if (!throwOnError) return;\n throw error;\n }\n }\n}\n\nasync function loadPage<T, Args extends any[]>(\n cache: PagedCache<T, Args>,\n helpers: CalculationActions<Promise<PagedCacheState<T>>>,\n oldPages: T[],\n) {\n const { fetchPage, hasMorePages, getPageCount } = cache.definition;\n\n const page = await fetchPage.call(cache, {\n ...helpers,\n pages: oldPages,\n prevPage: oldPages.length > 0 ? oldPages[oldPages.length - 1]! : null,\n });\n\n const pages = page === null ? oldPages : oldPages.concat(page);\n const pageCount = getPageCount?.call(cache, pages) ?? null;\n const hasMore = hasMorePages\n ? hasMorePages.call(cache, pages)\n : pageCount !== null\n ? pages.length < pageCount\n : page !== null;\n\n return { pages, hasMore, pageCount };\n}\n\nfunction createPaged<T, Args extends any[] = []>(\n definition: PagedCacheDefinitionFunction<T, Args>,\n options?: CacheOptions<PagedCacheState<T>, Args>,\n): CreateCacheResult<PagedCacheState<T>, Args, PagedCache<T, Args>>;\n\nfunction createPaged<T>(\n definition: PagedCacheDefinition<T, []>,\n options?: CacheOptions<PagedCacheState<T>, []>,\n): CreateCacheResult<PagedCacheState<T>, [], PagedCache<T, []>>;\n\nfunction createPaged<T, Args extends any[] = []>(\n definition: PagedCacheDefinitionFunction<T, Args> | PagedCacheDefinition<T, Args>,\n options?: CacheOptions<PagedCacheState<T>, Args>,\n): CreateCacheResult<PagedCacheState<T>, Args, PagedCache<T, Args>> {\n return internalCreate<PagedCacheState<T>, Args, PagedCache<T, Args>>((args, options) => {\n let currentDefinition = definition;\n if (currentDefinition instanceof Function) {\n currentDefinition = currentDefinition(...args);\n }\n return new PagedCache(currentDefinition, args, options);\n }, options);\n}\n\nexport const createPagedCache: typeof createPaged & { defaultOptions: CacheOptions<any, any> } =\n /* @__PURE__ */ Object.assign(createPaged, {\n defaultOptions: defaultCacheOptions,\n });\n","export function findOrDefault<T>(\n array: T[],\n predicate: (item: T) => boolean,\n defaultValue: T | (() => T),\n): T {\n const index = array.findIndex(predicate);\n\n if (index >= 0) {\n return array[index]!;\n }\n\n const value = defaultValue instanceof Function ? defaultValue() : defaultValue;\n array.push(value);\n return value;\n}\n"],"mappings":";;;;;;;;AA2DA,IAAa,aAAb,MAAa,mBAA+C,MAAgC;CAC1F,YACE,AAAgBA,YAChB,MACA,UAAkD,EAAE,EACpD;AACA,QAAM,OAAO,YAAY,SAAS,MAAM,SAAS,EAAE,CAAC,EAAE,MAAM,SAAS,OAAU;EAJ/D;AAKhB,WAAS,WAAW;;CAGtB,MAAM,cAAc,EAAE,iBAAuC,EAAE,EAAiB;EAC9E,MAAM,EAAE,QAAQ,SAAS,YAAY,UAAU,KAAK,MAAM,KAAK;AAE/D,MAAI,WAAW,SAAS;AACtB,OAAI,CAAC,aAAc;AACnB,SAAM,IAAI,MAAM,uDAAuD;;AAGzE,MAAI,YAAY;AACd,OAAI,CAAC,aAAc;AACnB,SAAM,IAAI,MAAM,6DAA6D;;AAG/E,MAAI,WAAW,aAAa,SAAS;AACnC,SAAM,KAAK,KAAK,CAAC,YAAY,GAAG;AAChC;;AAGF,MAAI,CAAC,MAAM,SAAS;AAClB,OAAI,CAAC,aAAc;AACnB,SAAM,IAAI,MAAM,yBAAyB;;AAG3C,OAAK,eAAe,KAAK,iBAAiB;EAE1C,MAAM,KAAK,IAAI,iBAAiB;EAChC,MAAM,UAAU,SACd,MACA;GACE,MAAM;AACJ,UAAM,IAAI,MAAM,kBAAkB;;GAEpC,UAAU;AACR,UAAM,IAAI,MAAM,kBAAkB;;GAEpC,QAAQ,GAAG;GACZ,EACD,MAAM,MACP;AAED,OAAK,YAAY,QAAQ;AAEzB,MAAI;AACF,SAAM;WACC,OAAO;AACd,OAAI,CAAC,aAAc;AACnB,SAAM;;;;AAKZ,eAAe,SACb,OACA,SACA,UACA;CACA,MAAM,EAAE,WAAW,cAAc,iBAAiB,MAAM;CAExD,MAAM,OAAO,MAAM,UAAU,KAAK,OAAO;EACvC,GAAG;EACH,OAAO;EACP,UAAU,SAAS,SAAS,IAAI,SAAS,SAAS,SAAS,KAAM;EAClE,CAAC;CAEF,MAAM,QAAQ,SAAS,OAAO,WAAW,SAAS,OAAO,KAAK;CAC9D,MAAM,YAAY,cAAc,KAAK,OAAO,MAAM,IAAI;AAOtD,QAAO;EAAE;EAAO,SANA,eACZ,aAAa,KAAK,OAAO,MAAM,GAC/B,cAAc,OACZ,MAAM,SAAS,YACf,SAAS;EAEU;EAAW;;AAatC,SAAS,YACP,YACA,SACkE;AAClE,QAAO,gBAA+D,MAAM,cAAY;EACtF,IAAI,oBAAoB;AACxB,MAAI,6BAA6B,SAC/B,qBAAoB,kBAAkB,GAAG,KAAK;AAEhD,SAAO,IAAI,WAAW,mBAAmB,MAAMC,UAAQ;IACtD,QAAQ;;AAGb,MAAaC,mBACK,uBAAO,OAAO,aAAa,EACzC,gBAAgB,qBACjB,CAAC;;;;AC1KJ,SAAgB,cACd,OACA,WACA,cACG;CACH,MAAM,QAAQ,MAAM,UAAU,UAAU;AAExC,KAAI,SAAS,EACX,QAAO,MAAM;CAGf,MAAM,QAAQ,wBAAwB,WAAW,cAAc,GAAG;AAClE,OAAM,KAAK,MAAM;AACjB,QAAO"}
@@ -1,3 +1,4 @@
1
- const require_mutativeMethods = require('../mutativeMethods-CgXk_bMt.cjs');
1
+ require('../path-B-Rq5q6m.cjs');
2
+ const require_mutativeMethods = require('../mutativeMethods-CkNycpO9.cjs');
2
3
 
3
4
  exports.mutativeMethods = require_mutativeMethods.mutativeMethods;
@@ -1,3 +1,3 @@
1
- import "../store-MBrcOgtz.cjs";
2
- import { Mutation, mutativeMethods } from "../mutativeMethods-DWhwZRzv.cjs";
1
+ import "../store-XcnTdeiJ.cjs";
2
+ import { n as mutativeMethods, t as Mutation } from "../mutativeMethods-C8VcZWED.cjs";
3
3
  export { type Mutation, mutativeMethods };
@@ -1,3 +1,3 @@
1
- import "../store-DnZ6fsiJ.js";
2
- import { Mutation, mutativeMethods } from "../mutativeMethods-Bhd1Yi22.js";
1
+ import "../store-BRHFhRPm.js";
2
+ import { n as mutativeMethods, t as Mutation } from "../mutativeMethods-BT1Cim3p.js";
3
3
  export { type Mutation, mutativeMethods };
@@ -1,3 +1,4 @@
1
- import { mutativeMethods } from "../mutativeMethods-CZKeRIDL.js";
1
+ import "../path-CyYq74W8.js";
2
+ import { t as mutativeMethods } from "../mutativeMethods-Jowr0Znn.js";
2
3
 
3
4
  export { mutativeMethods };
@@ -1,6 +1,7 @@
1
- const require_store = require('../store-CdST5wJZ.cjs');
2
- require('../propAccess-BdLsqViO.cjs');
3
- const require_mutativeMethods = require('../mutativeMethods-CgXk_bMt.cjs');
1
+ require('../path-B-Rq5q6m.cjs');
2
+ const require_store = require('../store-C1NYHLgR.cjs');
3
+ require('../propAccess-C2AIn9RC.cjs');
4
+ const require_mutativeMethods = require('../mutativeMethods-CkNycpO9.cjs');
4
5
 
5
6
  //#region src/mutative/register.ts
6
7
  Object.assign(require_store.Store.prototype, require_mutativeMethods.mutativeMethods);
@@ -1 +1 @@
1
- {"version":3,"file":"register.cjs","names":["Store","mutativeMethods","autobind"],"sources":["../../src/mutative/register.ts"],"sourcesContent":["import { autobind } from '@lib/autobind';\nimport { mutativeMethods } from './mutativeMethods';\nimport { Store } from '@core';\n\ntype MutativeMethods = typeof mutativeMethods;\n\ndeclare module '..' {\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n interface Store<T> extends MutativeMethods {}\n}\n\nObject.assign(Store.prototype, mutativeMethods);\nautobind(Store);\n"],"mappings":";;;;;AAWA,OAAO,OAAOA,oBAAM,WAAWC;AAC/BC,uBAASF"}
1
+ {"version":3,"file":"register.cjs","names":["Store","mutativeMethods","autobind"],"sources":["../../src/mutative/register.ts"],"sourcesContent":["import { autobind } from '@lib/autobind';\nimport { mutativeMethods } from './mutativeMethods';\nimport { Store } from '@core';\n\ntype MutativeMethods = typeof mutativeMethods;\n\ndeclare module '..' {\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n interface Store<T> extends MutativeMethods {}\n}\n\nObject.assign(Store.prototype, mutativeMethods);\nautobind(Store);\n"],"mappings":";;;;;;AAWA,OAAO,OAAOA,oBAAM,WAAWC,wCAAgB;AAC/CC,uBAASF,oBAAM"}
@@ -1,11 +1,9 @@
1
- import "../store-MBrcOgtz.cjs";
2
- import { mutativeMethods } from "../mutativeMethods-DWhwZRzv.cjs";
1
+ import "../store-XcnTdeiJ.cjs";
2
+ import { n as mutativeMethods } from "../mutativeMethods-C8VcZWED.cjs";
3
3
 
4
4
  //#region src/mutative/register.d.ts
5
5
  type MutativeMethods = typeof mutativeMethods;
6
6
  declare module ".." {
7
7
  interface Store<T> extends MutativeMethods {}
8
8
  }
9
- //#endregion
10
- export {};
11
9
  //# sourceMappingURL=register.d.cts.map
@@ -1,5 +1,5 @@
1
- import "../store-DnZ6fsiJ.js";
2
- import { mutativeMethods } from "../mutativeMethods-Bhd1Yi22.js";
1
+ import "../store-BRHFhRPm.js";
2
+ import { n as mutativeMethods } from "../mutativeMethods-BT1Cim3p.js";
3
3
 
4
4
  //#region src/mutative/register.d.ts
5
5
  type MutativeMethods = typeof mutativeMethods;
@@ -1,6 +1,7 @@
1
- import { Store, autobind } from "../store-Dx8w7yT-.js";
2
- import "../propAccess-B260LXN1.js";
3
- import { mutativeMethods } from "../mutativeMethods-CZKeRIDL.js";
1
+ import { h as autobind, t as Store } from "../store-v3RYWzVg.js";
2
+ import "../propAccess-DvWFpYoj.js";
3
+ import "../path-CyYq74W8.js";
4
+ import { t as mutativeMethods } from "../mutativeMethods-Jowr0Znn.js";
4
5
 
5
6
  //#region src/mutative/register.ts
6
7
  Object.assign(Store.prototype, mutativeMethods);
@@ -1 +1 @@
1
- {"version":3,"file":"register.js","names":[],"sources":["../../src/mutative/register.ts"],"sourcesContent":["import { autobind } from '@lib/autobind';\nimport { mutativeMethods } from './mutativeMethods';\nimport { Store } from '@core';\n\ntype MutativeMethods = typeof mutativeMethods;\n\ndeclare module '..' {\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n interface Store<T> extends MutativeMethods {}\n}\n\nObject.assign(Store.prototype, mutativeMethods);\nautobind(Store);\n"],"mappings":";;;;;AAWA,OAAO,OAAO,MAAM,WAAW;AAC/B,SAAS"}
1
+ {"version":3,"file":"register.js","names":[],"sources":["../../src/mutative/register.ts"],"sourcesContent":["import { autobind } from '@lib/autobind';\nimport { mutativeMethods } from './mutativeMethods';\nimport { Store } from '@core';\n\ntype MutativeMethods = typeof mutativeMethods;\n\ndeclare module '..' {\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n interface Store<T> extends MutativeMethods {}\n}\n\nObject.assign(Store.prototype, mutativeMethods);\nautobind(Store);\n"],"mappings":";;;;;;AAWA,OAAO,OAAO,MAAM,WAAW,gBAAgB;AAC/C,SAAS,MAAM"}
@@ -1,4 +1,4 @@
1
- import { Constrain, Path, Store, Value } from "./store-DnZ6fsiJ.js";
1
+ import { B as Value, K as Constrain, N as Path, r as Store } from "./store-BRHFhRPm.js";
2
2
  import { Draft } from "mutative";
3
3
 
4
4
  //#region src/mutative/mutativeMethods.d.ts
@@ -9,5 +9,5 @@ declare const mutativeMethods: {
9
9
  update: typeof update;
10
10
  };
11
11
  //#endregion
12
- export { Mutation, mutativeMethods };
13
- //# sourceMappingURL=mutativeMethods-Bhd1Yi22.d.ts.map
12
+ export { mutativeMethods as n, Mutation as t };
13
+ //# sourceMappingURL=mutativeMethods-BT1Cim3p.d.ts.map
@@ -1,4 +1,4 @@
1
- import { Constrain, Path, Store, Value } from "./store-MBrcOgtz.cjs";
1
+ import { B as Value, K as Constrain, N as Path, r as Store } from "./store-XcnTdeiJ.cjs";
2
2
  import { Draft } from "mutative";
3
3
 
4
4
  //#region src/mutative/mutativeMethods.d.ts
@@ -9,5 +9,5 @@ declare const mutativeMethods: {
9
9
  update: typeof update;
10
10
  };
11
11
  //#endregion
12
- export { Mutation, mutativeMethods };
13
- //# sourceMappingURL=mutativeMethods-DWhwZRzv.d.cts.map
12
+ export { mutativeMethods as n, Mutation as t };
13
+ //# sourceMappingURL=mutativeMethods-C8VcZWED.d.cts.map
@@ -1,23 +1,22 @@
1
- const require_chunk = require('./chunk-CUT6urMc.cjs');
2
- const mutative = require_chunk.__toESM(require("mutative"));
1
+ const require_path = require('./path-B-Rq5q6m.cjs');
2
+ let mutative = require("mutative");
3
+ mutative = require_path.__toESM(mutative);
3
4
 
4
5
  //#region src/mutative/mutativeMethods.ts
5
6
  function update(...args) {
6
7
  if (args.length === 1) {
7
8
  const [mutation] = args;
8
9
  this.set((value) => {
9
- const result = (0, mutative.create)(value, (draft) => {
10
+ return (0, mutative.create)(value, (draft) => {
10
11
  mutation(draft);
11
12
  });
12
- return result;
13
13
  });
14
14
  } else {
15
15
  const [path, mutation] = args;
16
16
  this.set(path, (value) => {
17
- const result = (0, mutative.create)(value, (draft) => {
17
+ return (0, mutative.create)(value, (draft) => {
18
18
  mutation(draft);
19
19
  });
20
- return result;
21
20
  });
22
21
  }
23
22
  }
@@ -30,4 +29,4 @@ Object.defineProperty(exports, 'mutativeMethods', {
30
29
  return mutativeMethods;
31
30
  }
32
31
  });
33
- //# sourceMappingURL=mutativeMethods-CgXk_bMt.cjs.map
32
+ //# sourceMappingURL=mutativeMethods-CkNycpO9.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"mutativeMethods-CgXk_bMt.cjs","names":["mutativeMethods: {\n update: typeof update;\n}"],"sources":["../src/mutative/mutativeMethods.ts"],"sourcesContent":["import type { Store } from '@core/store';\nimport type { Constrain } from '@lib/constrain';\nimport { type Path, type Value } from '@lib/path';\nimport { create, type Draft } from 'mutative';\n\nexport type Mutation<T> = (draft: Draft<T>) => void;\n\nfunction update<T>(this: Store<T>, mutation: Mutation<T>): void;\n\nfunction update<T, const P>(\n this: Store<T>,\n path: Constrain<P, Path<T>>,\n mutation: Mutation<Value<T, P>>,\n): void;\n\nfunction update<T, const TPath>(\n this: Store<T>,\n ...args:\n | [recipe: Mutation<T>]\n | [path: Constrain<TPath, Path<T>>, mutation: Mutation<Value<T, TPath>>]\n) {\n if (args.length === 1) {\n const [mutation] = args;\n\n this.set((value) => {\n const result = create(value, (draft) => {\n mutation(draft);\n });\n return result;\n });\n } else {\n const [path, mutation] = args;\n\n this.set(path, (value) => {\n const result = create(value, (draft) => {\n mutation(draft);\n });\n return result;\n });\n }\n}\n\nexport const mutativeMethods: {\n update: typeof update;\n} = {\n update,\n};\n"],"mappings":";;;;AAeA,SAAS,OAEP,GAAG,MAGH;AACA,KAAI,KAAK,WAAW,GAAG;EACrB,MAAM,CAAC,YAAY;AAEnB,OAAK,KAAK,UAAU;GAClB,MAAM,8BAAgB,QAAQ,UAAU;AACtC,aAAS;;AAEX,UAAO;;QAEJ;EACL,MAAM,CAAC,MAAM,YAAY;AAEzB,OAAK,IAAI,OAAO,UAAU;GACxB,MAAM,8BAAgB,QAAQ,UAAU;AACtC,aAAS;;AAEX,UAAO;;;;AAKb,MAAaA,kBAET,EACF"}
1
+ {"version":3,"file":"mutativeMethods-CkNycpO9.cjs","names":["mutativeMethods: {\n update: typeof update;\n}"],"sources":["../src/mutative/mutativeMethods.ts"],"sourcesContent":["import type { Store } from '@core/store';\nimport type { Constrain } from '@lib/constrain';\nimport { type Path, type Value } from '@lib/path';\nimport { create, type Draft } from 'mutative';\n\nexport type Mutation<T> = (draft: Draft<T>) => void;\n\nfunction update<T>(this: Store<T>, mutation: Mutation<T>): void;\n\nfunction update<T, const P>(\n this: Store<T>,\n path: Constrain<P, Path<T>>,\n mutation: Mutation<Value<T, P>>,\n): void;\n\nfunction update<T, const TPath>(\n this: Store<T>,\n ...args:\n | [recipe: Mutation<T>]\n | [path: Constrain<TPath, Path<T>>, mutation: Mutation<Value<T, TPath>>]\n) {\n if (args.length === 1) {\n const [mutation] = args;\n\n this.set((value) => {\n const result = create(value, (draft) => {\n mutation(draft);\n });\n return result;\n });\n } else {\n const [path, mutation] = args;\n\n this.set(path, (value) => {\n const result = create(value, (draft) => {\n mutation(draft);\n });\n return result;\n });\n }\n}\n\nexport const mutativeMethods: {\n update: typeof update;\n} = {\n update,\n};\n"],"mappings":";;;;;AAeA,SAAS,OAEP,GAAG,MAGH;AACA,KAAI,KAAK,WAAW,GAAG;EACrB,MAAM,CAAC,YAAY;AAEnB,OAAK,KAAK,UAAU;AAIlB,+BAHsB,QAAQ,UAAU;AACtC,aAAS,MAAM;KACf;IAEF;QACG;EACL,MAAM,CAAC,MAAM,YAAY;AAEzB,OAAK,IAAI,OAAO,UAAU;AAIxB,+BAHsB,QAAQ,UAAU;AACtC,aAAS,MAAM;KACf;IAEF;;;AAIN,MAAaA,kBAET,EACF,QACD"}
@@ -5,23 +5,21 @@ function update(...args) {
5
5
  if (args.length === 1) {
6
6
  const [mutation] = args;
7
7
  this.set((value) => {
8
- const result = create(value, (draft) => {
8
+ return create(value, (draft) => {
9
9
  mutation(draft);
10
10
  });
11
- return result;
12
11
  });
13
12
  } else {
14
13
  const [path, mutation] = args;
15
14
  this.set(path, (value) => {
16
- const result = create(value, (draft) => {
15
+ return create(value, (draft) => {
17
16
  mutation(draft);
18
17
  });
19
- return result;
20
18
  });
21
19
  }
22
20
  }
23
21
  const mutativeMethods = { update };
24
22
 
25
23
  //#endregion
26
- export { mutativeMethods };
27
- //# sourceMappingURL=mutativeMethods-CZKeRIDL.js.map
24
+ export { mutativeMethods as t };
25
+ //# sourceMappingURL=mutativeMethods-Jowr0Znn.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"mutativeMethods-CZKeRIDL.js","names":["mutativeMethods: {\n update: typeof update;\n}"],"sources":["../src/mutative/mutativeMethods.ts"],"sourcesContent":["import type { Store } from '@core/store';\nimport type { Constrain } from '@lib/constrain';\nimport { type Path, type Value } from '@lib/path';\nimport { create, type Draft } from 'mutative';\n\nexport type Mutation<T> = (draft: Draft<T>) => void;\n\nfunction update<T>(this: Store<T>, mutation: Mutation<T>): void;\n\nfunction update<T, const P>(\n this: Store<T>,\n path: Constrain<P, Path<T>>,\n mutation: Mutation<Value<T, P>>,\n): void;\n\nfunction update<T, const TPath>(\n this: Store<T>,\n ...args:\n | [recipe: Mutation<T>]\n | [path: Constrain<TPath, Path<T>>, mutation: Mutation<Value<T, TPath>>]\n) {\n if (args.length === 1) {\n const [mutation] = args;\n\n this.set((value) => {\n const result = create(value, (draft) => {\n mutation(draft);\n });\n return result;\n });\n } else {\n const [path, mutation] = args;\n\n this.set(path, (value) => {\n const result = create(value, (draft) => {\n mutation(draft);\n });\n return result;\n });\n }\n}\n\nexport const mutativeMethods: {\n update: typeof update;\n} = {\n update,\n};\n"],"mappings":";;;AAeA,SAAS,OAEP,GAAG,MAGH;AACA,KAAI,KAAK,WAAW,GAAG;EACrB,MAAM,CAAC,YAAY;AAEnB,OAAK,KAAK,UAAU;GAClB,MAAM,SAAS,OAAO,QAAQ,UAAU;AACtC,aAAS;;AAEX,UAAO;;QAEJ;EACL,MAAM,CAAC,MAAM,YAAY;AAEzB,OAAK,IAAI,OAAO,UAAU;GACxB,MAAM,SAAS,OAAO,QAAQ,UAAU;AACtC,aAAS;;AAEX,UAAO;;;;AAKb,MAAaA,kBAET,EACF"}
1
+ {"version":3,"file":"mutativeMethods-Jowr0Znn.js","names":["mutativeMethods: {\n update: typeof update;\n}"],"sources":["../src/mutative/mutativeMethods.ts"],"sourcesContent":["import type { Store } from '@core/store';\nimport type { Constrain } from '@lib/constrain';\nimport { type Path, type Value } from '@lib/path';\nimport { create, type Draft } from 'mutative';\n\nexport type Mutation<T> = (draft: Draft<T>) => void;\n\nfunction update<T>(this: Store<T>, mutation: Mutation<T>): void;\n\nfunction update<T, const P>(\n this: Store<T>,\n path: Constrain<P, Path<T>>,\n mutation: Mutation<Value<T, P>>,\n): void;\n\nfunction update<T, const TPath>(\n this: Store<T>,\n ...args:\n | [recipe: Mutation<T>]\n | [path: Constrain<TPath, Path<T>>, mutation: Mutation<Value<T, TPath>>]\n) {\n if (args.length === 1) {\n const [mutation] = args;\n\n this.set((value) => {\n const result = create(value, (draft) => {\n mutation(draft);\n });\n return result;\n });\n } else {\n const [path, mutation] = args;\n\n this.set(path, (value) => {\n const result = create(value, (draft) => {\n mutation(draft);\n });\n return result;\n });\n }\n}\n\nexport const mutativeMethods: {\n update: typeof update;\n} = {\n update,\n};\n"],"mappings":";;;AAeA,SAAS,OAEP,GAAG,MAGH;AACA,KAAI,KAAK,WAAW,GAAG;EACrB,MAAM,CAAC,YAAY;AAEnB,OAAK,KAAK,UAAU;AAIlB,UAHe,OAAO,QAAQ,UAAU;AACtC,aAAS,MAAM;KACf;IAEF;QACG;EACL,MAAM,CAAC,MAAM,YAAY;AAEzB,OAAK,IAAI,OAAO,UAAU;AAIxB,UAHe,OAAO,QAAQ,UAAU;AACtC,aAAS,MAAM;KACf;IAEF;;;AAIN,MAAaA,kBAET,EACF,QACD"}
@@ -1,5 +1,5 @@
1
- const require_propAccess = require('./propAccess-BdLsqViO.cjs');
2
- const require_extendedJson = require('./extendedJson-Dn2F7Edo.cjs');
1
+ const require_propAccess = require('./propAccess-C2AIn9RC.cjs');
2
+ const require_extendedJson = require('./extendedJson-ursQ8DbQ.cjs');
3
3
 
4
4
  //#region src/lib/applyPatches.ts
5
5
  function applySinglePatch(target, patch) {
@@ -15,9 +15,7 @@ function applyPatches(target, ...patches) {
15
15
  //#region src/lib/diff.ts
16
16
  function diff(a, b, options = {}) {
17
17
  const result = [..._diff(a, b, options)];
18
- const patches = result.map(([patch]) => patch);
19
- const reversePatches = result.map(([, reversePatch]) => reversePatch);
20
- return [patches, reversePatches];
18
+ return [result.map(([patch]) => patch), result.map(([, reversePatch]) => reversePatch)];
21
19
  }
22
20
  function* _diff(a, b, options, prefix = []) {
23
21
  if (a === b) return;
@@ -261,4 +259,4 @@ Object.defineProperty(exports, 'subscribePatches', {
261
259
  return subscribePatches;
262
260
  }
263
261
  });
264
- //# sourceMappingURL=patchMethods-hhlLwtqE.cjs.map
262
+ //# sourceMappingURL=patchMethods-B7Hm5-Qh.cjs.map