cross-state 0.53.1 → 0.54.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 (237) hide show
  1. package/dist/chunk-CUT6urMc.cjs +30 -0
  2. package/dist/diff-BQ8bB3Wk.d.cts +22 -0
  3. package/dist/diff-gZezL04N.d.ts +22 -0
  4. package/dist/extendedJson-BZkQBXEv.js +29 -0
  5. package/dist/extendedJson-BZkQBXEv.js.map +1 -0
  6. package/dist/extendedJson-Dn2F7Edo.cjs +53 -0
  7. package/dist/extendedJson-Dn2F7Edo.cjs.map +1 -0
  8. package/dist/hash-BV06P7va.js +19 -0
  9. package/dist/hash-BV06P7va.js.map +1 -0
  10. package/dist/hash-CJPl7SRj.cjs +30 -0
  11. package/dist/hash-CJPl7SRj.cjs.map +1 -0
  12. package/dist/index.cjs +49 -0
  13. package/dist/index.cjs.map +1 -0
  14. package/dist/index.d.cts +59 -0
  15. package/dist/index.d.ts +59 -0
  16. package/dist/index.js +20 -0
  17. package/dist/index.js.map +1 -0
  18. package/dist/mutative/index.cjs +3 -0
  19. package/dist/mutative/index.d.cts +3 -0
  20. package/dist/mutative/index.d.ts +3 -0
  21. package/dist/mutative/index.js +3 -0
  22. package/dist/mutative/register.cjs +10 -0
  23. package/dist/mutative/register.cjs.map +1 -0
  24. package/dist/mutative/register.d.cts +11 -0
  25. package/dist/mutative/register.d.ts +9 -0
  26. package/dist/mutative/register.js +10 -0
  27. package/dist/mutative/register.js.map +1 -0
  28. package/dist/mutativeMethods-6QzygG3W.d.cts +13 -0
  29. package/dist/mutativeMethods-Br3xN2Iq.d.ts +13 -0
  30. package/dist/mutativeMethods-CZKeRIDL.js +27 -0
  31. package/dist/mutativeMethods-CZKeRIDL.js.map +1 -0
  32. package/dist/mutativeMethods-CgXk_bMt.cjs +33 -0
  33. package/dist/mutativeMethods-CgXk_bMt.cjs.map +1 -0
  34. package/dist/patchMethods-C3L7Kh8T.d.cts +48 -0
  35. package/dist/patchMethods-D5YJwcpn.cjs +264 -0
  36. package/dist/patchMethods-D5YJwcpn.cjs.map +1 -0
  37. package/dist/patchMethods-DRPfkhAe.js +241 -0
  38. package/dist/patchMethods-DRPfkhAe.js.map +1 -0
  39. package/dist/patchMethods-Dxad6HF6.d.ts +48 -0
  40. package/dist/patches/index.cjs +5 -0
  41. package/dist/patches/index.d.cts +4 -0
  42. package/dist/patches/index.d.ts +4 -0
  43. package/dist/patches/index.js +5 -0
  44. package/dist/patches/register.cjs +11 -0
  45. package/dist/patches/register.cjs.map +1 -0
  46. package/dist/patches/register.d.cts +12 -0
  47. package/dist/patches/register.d.ts +10 -0
  48. package/dist/patches/register.js +11 -0
  49. package/dist/patches/register.js.map +1 -0
  50. package/dist/persist/register.cjs +13 -0
  51. package/dist/persist/register.cjs.map +1 -0
  52. package/dist/persist/register.d.cts +15 -0
  53. package/dist/persist/register.d.ts +13 -0
  54. package/dist/persist/register.js +13 -0
  55. package/dist/persist/register.js.map +1 -0
  56. package/dist/persist-BluRVcW6.js +258 -0
  57. package/dist/persist-BluRVcW6.js.map +1 -0
  58. package/dist/persist-CPjpg6D0.d.ts +61 -0
  59. package/dist/persist-CztClydq.cjs +263 -0
  60. package/dist/persist-CztClydq.cjs.map +1 -0
  61. package/dist/persist-D7MAsyyW.d.cts +61 -0
  62. package/dist/propAccess-ByqBjC19.cjs +173 -0
  63. package/dist/propAccess-ByqBjC19.cjs.map +1 -0
  64. package/dist/propAccess-DGchzVfy.js +113 -0
  65. package/dist/propAccess-DGchzVfy.js.map +1 -0
  66. package/dist/react/index.cjs +610 -0
  67. package/dist/react/index.cjs.map +1 -0
  68. package/dist/react/index.d.cts +305 -0
  69. package/dist/react/index.d.ts +305 -0
  70. package/dist/react/index.js +590 -0
  71. package/dist/react/index.js.map +1 -0
  72. package/dist/react/register.cjs +16 -0
  73. package/dist/react/register.cjs.map +1 -0
  74. package/dist/react/register.d.cts +16 -0
  75. package/dist/react/register.d.ts +14 -0
  76. package/dist/react/register.js +16 -0
  77. package/dist/react/register.js.map +1 -0
  78. package/dist/scope-DI1OFHcr.d.ts +167 -0
  79. package/dist/scope-DO5vpLPV.d.cts +167 -0
  80. package/dist/scope-DU5dFP1T.js +322 -0
  81. package/dist/scope-DU5dFP1T.js.map +1 -0
  82. package/dist/scope-DvqvkIHB.cjs +369 -0
  83. package/dist/scope-DvqvkIHB.cjs.map +1 -0
  84. package/dist/store-BEsiS8y7.d.cts +242 -0
  85. package/dist/store-BWMWEUpu.cjs +819 -0
  86. package/dist/store-BWMWEUpu.cjs.map +1 -0
  87. package/dist/store-DKaeE840.d.ts +242 -0
  88. package/dist/store-Dr8gM3lq.js +730 -0
  89. package/dist/store-Dr8gM3lq.js.map +1 -0
  90. package/dist/storeMethods-AIJSwxHz.js +315 -0
  91. package/dist/storeMethods-AIJSwxHz.js.map +1 -0
  92. package/dist/storeMethods-BQwU2Uia.d.cts +107 -0
  93. package/dist/storeMethods-C4luym7C.d.ts +107 -0
  94. package/dist/storeMethods-DVVsmUg1.cjs +375 -0
  95. package/dist/storeMethods-DVVsmUg1.cjs.map +1 -0
  96. package/package.json +92 -135
  97. package/dist/cjs/hash.cjs +0 -30
  98. package/dist/cjs/hash.cjs.map +0 -1
  99. package/dist/cjs/index.cjs +0 -56
  100. package/dist/cjs/index.cjs.map +0 -1
  101. package/dist/cjs/index2.cjs +0 -300
  102. package/dist/cjs/index2.cjs.map +0 -1
  103. package/dist/cjs/mutative/index.cjs +0 -10
  104. package/dist/cjs/mutative/index.cjs.map +0 -1
  105. package/dist/cjs/mutative/register.cjs +0 -8
  106. package/dist/cjs/mutative/register.cjs.map +0 -1
  107. package/dist/cjs/mutativeMethods.cjs +0 -29
  108. package/dist/cjs/mutativeMethods.cjs.map +0 -1
  109. package/dist/cjs/patches/index.cjs +0 -10
  110. package/dist/cjs/patches/index.cjs.map +0 -1
  111. package/dist/cjs/patches/register.cjs +0 -8
  112. package/dist/cjs/patches/register.cjs.map +0 -1
  113. package/dist/cjs/persist/register.cjs +0 -11
  114. package/dist/cjs/persist/register.cjs.map +0 -1
  115. package/dist/cjs/persist.cjs +0 -302
  116. package/dist/cjs/persist.cjs.map +0 -1
  117. package/dist/cjs/propAccess.cjs +0 -162
  118. package/dist/cjs/propAccess.cjs.map +0 -1
  119. package/dist/cjs/react/index.cjs +0 -628
  120. package/dist/cjs/react/index.cjs.map +0 -1
  121. package/dist/cjs/react/register.cjs +0 -13
  122. package/dist/cjs/react/register.cjs.map +0 -1
  123. package/dist/cjs/scope.cjs +0 -402
  124. package/dist/cjs/scope.cjs.map +0 -1
  125. package/dist/cjs/store.cjs +0 -839
  126. package/dist/cjs/store.cjs.map +0 -1
  127. package/dist/cjs/storeMethods.cjs +0 -856
  128. package/dist/cjs/storeMethods.cjs.map +0 -1
  129. package/dist/cjs/urlStore.cjs +0 -120
  130. package/dist/cjs/urlStore.cjs.map +0 -1
  131. package/dist/es/hash.mjs +0 -27
  132. package/dist/es/hash.mjs.map +0 -1
  133. package/dist/es/index.mjs +0 -20
  134. package/dist/es/index.mjs.map +0 -1
  135. package/dist/es/index2.mjs +0 -291
  136. package/dist/es/index2.mjs.map +0 -1
  137. package/dist/es/mutative/index.mjs +0 -2
  138. package/dist/es/mutative/index.mjs.map +0 -1
  139. package/dist/es/mutative/register.mjs +0 -6
  140. package/dist/es/mutative/register.mjs.map +0 -1
  141. package/dist/es/mutativeMethods.mjs +0 -27
  142. package/dist/es/mutativeMethods.mjs.map +0 -1
  143. package/dist/es/patches/index.mjs +0 -2
  144. package/dist/es/patches/index.mjs.map +0 -1
  145. package/dist/es/patches/register.mjs +0 -6
  146. package/dist/es/patches/register.mjs.map +0 -1
  147. package/dist/es/persist/register.mjs +0 -9
  148. package/dist/es/persist/register.mjs.map +0 -1
  149. package/dist/es/persist.mjs +0 -300
  150. package/dist/es/persist.mjs.map +0 -1
  151. package/dist/es/propAccess.mjs +0 -151
  152. package/dist/es/propAccess.mjs.map +0 -1
  153. package/dist/es/react/index.mjs +0 -611
  154. package/dist/es/react/index.mjs.map +0 -1
  155. package/dist/es/react/register.mjs +0 -11
  156. package/dist/es/react/register.mjs.map +0 -1
  157. package/dist/es/scope.mjs +0 -393
  158. package/dist/es/scope.mjs.map +0 -1
  159. package/dist/es/store.mjs +0 -822
  160. package/dist/es/store.mjs.map +0 -1
  161. package/dist/es/storeMethods.mjs +0 -845
  162. package/dist/es/storeMethods.mjs.map +0 -1
  163. package/dist/es/urlStore.mjs +0 -116
  164. package/dist/es/urlStore.mjs.map +0 -1
  165. package/dist/types/core/cache.d.ts +0 -119
  166. package/dist/types/core/commonTypes.d.ts +0 -76
  167. package/dist/types/core/index.d.ts +0 -6
  168. package/dist/types/core/resourceGroup.d.ts +0 -16
  169. package/dist/types/core/scope.d.ts +0 -5
  170. package/dist/types/core/store.d.ts +0 -88
  171. package/dist/types/core/urlStore.d.ts +0 -21
  172. package/dist/types/index.d.ts +0 -14
  173. package/dist/types/lib/applyPatches.d.ts +0 -2
  174. package/dist/types/lib/autobind.d.ts +0 -1
  175. package/dist/types/lib/cacheState.d.ts +0 -20
  176. package/dist/types/lib/calcDuration.d.ts +0 -2
  177. package/dist/types/lib/calculatedValue.d.ts +0 -9
  178. package/dist/types/lib/callable.d.ts +0 -4
  179. package/dist/types/lib/castArray.d.ts +0 -1
  180. package/dist/types/lib/clone.d.ts +0 -1
  181. package/dist/types/lib/constrain.d.ts +0 -1
  182. package/dist/types/lib/debounce.d.ts +0 -12
  183. package/dist/types/lib/deferred.d.ts +0 -5
  184. package/dist/types/lib/diff.d.ts +0 -17
  185. package/dist/types/lib/disposable.d.ts +0 -3
  186. package/dist/types/lib/equals.d.ts +0 -3
  187. package/dist/types/lib/extendedJson.d.ts +0 -5
  188. package/dist/types/lib/forwardError.d.ts +0 -1
  189. package/dist/types/lib/hash.d.ts +0 -5
  190. package/dist/types/lib/helpers.d.ts +0 -2
  191. package/dist/types/lib/instanceCache.d.ts +0 -18
  192. package/dist/types/lib/isPromise.d.ts +0 -1
  193. package/dist/types/lib/makeSelector.d.ts +0 -2
  194. package/dist/types/lib/maybePromise.d.ts +0 -1
  195. package/dist/types/lib/path.d.ts +0 -41
  196. package/dist/types/lib/promiseChain.d.ts +0 -5
  197. package/dist/types/lib/promiseWithCancel.d.ts +0 -8
  198. package/dist/types/lib/promiseWithState.d.ts +0 -9
  199. package/dist/types/lib/propAccess.d.ts +0 -7
  200. package/dist/types/lib/queue.d.ts +0 -11
  201. package/dist/types/lib/standardMethods.d.ts +0 -20
  202. package/dist/types/lib/throttle.d.ts +0 -2
  203. package/dist/types/lib/trackingProxy.d.ts +0 -2
  204. package/dist/types/lib/trie.d.ts +0 -11
  205. package/dist/types/lib/typeHelpers.d.ts +0 -12
  206. package/dist/types/lib/unwrapPromise.d.ts +0 -1
  207. package/dist/types/lib/updateHelpers.d.ts +0 -1
  208. package/dist/types/lib/wildcardMatch.d.ts +0 -3
  209. package/dist/types/mutative/index.d.ts +0 -1
  210. package/dist/types/mutative/mutativeMethods.d.ts +0 -11
  211. package/dist/types/mutative/register.d.ts +0 -7
  212. package/dist/types/patches/index.d.ts +0 -1
  213. package/dist/types/patches/patchMethods.d.ts +0 -44
  214. package/dist/types/patches/register.d.ts +0 -7
  215. package/dist/types/persist/index.d.ts +0 -3
  216. package/dist/types/persist/persist.d.ts +0 -40
  217. package/dist/types/persist/persistPathHelpers.d.ts +0 -6
  218. package/dist/types/persist/persistStorage.d.ts +0 -17
  219. package/dist/types/persist/register.d.ts +0 -9
  220. package/dist/types/react/cacheMethods.d.ts +0 -5
  221. package/dist/types/react/form/customInput.d.ts +0 -6
  222. package/dist/types/react/form/form.d.ts +0 -98
  223. package/dist/types/react/form/formField.d.ts +0 -68
  224. package/dist/types/react/form/formForEach.d.ts +0 -19
  225. package/dist/types/react/form/index.d.ts +0 -3
  226. package/dist/types/react/form/useFormAutosave.d.ts +0 -9
  227. package/dist/types/react/index.d.ts +0 -11
  228. package/dist/types/react/loadingBoundary.d.ts +0 -21
  229. package/dist/types/react/register.d.ts +0 -15
  230. package/dist/types/react/scope.d.ts +0 -24
  231. package/dist/types/react/scopeMethods.d.ts +0 -20
  232. package/dist/types/react/storeMethods.d.ts +0 -15
  233. package/dist/types/react/useCache.d.ts +0 -34
  234. package/dist/types/react/useDecoupledState.d.ts +0 -7
  235. package/dist/types/react/useProp.d.ts +0 -8
  236. package/dist/types/react/useStore.d.ts +0 -16
  237. package/dist/types/react/useUrlParamScope.d.ts +0 -4
@@ -0,0 +1,30 @@
1
+ //#region rolldown:runtime
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __copyProps = (to, from, except, desc) => {
9
+ if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
10
+ key = keys[i];
11
+ if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
12
+ get: ((k) => from[k]).bind(null, key),
13
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
14
+ });
15
+ }
16
+ return to;
17
+ };
18
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
19
+ value: mod,
20
+ enumerable: true
21
+ }) : target, mod));
22
+
23
+ //#endregion
24
+
25
+ Object.defineProperty(exports, '__toESM', {
26
+ enumerable: true,
27
+ get: function () {
28
+ return __toESM;
29
+ }
30
+ });
@@ -0,0 +1,22 @@
1
+ import { KeyType } from "./store-BEsiS8y7.cjs";
2
+
3
+ //#region src/lib/diff.d.ts
4
+ type Patch = {
5
+ op: "add";
6
+ path: KeyType[];
7
+ value: any;
8
+ } | {
9
+ op: "remove";
10
+ path: KeyType[];
11
+ } | {
12
+ op: "replace";
13
+ path: KeyType[];
14
+ value: any;
15
+ };
16
+ interface DiffOptions {
17
+ stopAt?: number | ((path: KeyType[]) => boolean);
18
+ }
19
+ declare function diff(a: any, b: any, options?: DiffOptions): [patches: Patch[], reversePatches: Patch[]];
20
+ //#endregion
21
+ export { DiffOptions, Patch, diff };
22
+ //# sourceMappingURL=diff-BQ8bB3Wk.d.cts.map
@@ -0,0 +1,22 @@
1
+ import { KeyType } from "./store-DKaeE840.js";
2
+
3
+ //#region src/lib/diff.d.ts
4
+ type Patch = {
5
+ op: "add";
6
+ path: KeyType[];
7
+ value: any;
8
+ } | {
9
+ op: "remove";
10
+ path: KeyType[];
11
+ } | {
12
+ op: "replace";
13
+ path: KeyType[];
14
+ value: any;
15
+ };
16
+ interface DiffOptions {
17
+ stopAt?: number | ((path: KeyType[]) => boolean);
18
+ }
19
+ declare function diff(a: any, b: any, options?: DiffOptions): [patches: Patch[], reversePatches: Patch[]];
20
+ //#endregion
21
+ export { DiffOptions, Patch, diff };
22
+ //# sourceMappingURL=diff-gZezL04N.d.ts.map
@@ -0,0 +1,29 @@
1
+ //#region src/lib/extendedJson.ts
2
+ function toExtendedJson(value) {
3
+ if (value instanceof Map) return { __map: [...value].map(([k, v]) => [toExtendedJson(k), toExtendedJson(v)]) };
4
+ if (value instanceof Set) return { __set: [...value].map(toExtendedJson) };
5
+ if (value instanceof Date) return { __date: value.toISOString() };
6
+ if (typeof value === "bigint") return { __bigint: value.toString() };
7
+ if (Array.isArray(value)) return value.map(toExtendedJson);
8
+ if (typeof value === "object" && value !== null) return Object.fromEntries(Object.entries(value).map(([k, v]) => [k, toExtendedJson(v)]));
9
+ return value;
10
+ }
11
+ function toExtendedJsonString(value, ...args) {
12
+ return JSON.stringify(toExtendedJson(value), ...args);
13
+ }
14
+ function fromExtendedJson(value) {
15
+ if (typeof value !== "object" || value === null) return value;
16
+ if ("__map" in value) return new Map(value.__map.map(([k, v]) => [fromExtendedJson(k), fromExtendedJson(v)]));
17
+ if ("__set" in value) return new Set(value.__set.map(fromExtendedJson));
18
+ if ("__date" in value) return new Date(value.__date);
19
+ if ("__bigint" in value) return BigInt(value.__bigint);
20
+ if (Array.isArray(value)) return value.map(fromExtendedJson);
21
+ return Object.fromEntries(Object.entries(value).map(([k, v]) => [k, fromExtendedJson(v)]));
22
+ }
23
+ function fromExtendedJsonString(value, reviver) {
24
+ return fromExtendedJson(JSON.parse(value, reviver));
25
+ }
26
+
27
+ //#endregion
28
+ export { fromExtendedJson, fromExtendedJsonString, toExtendedJson, toExtendedJsonString };
29
+ //# sourceMappingURL=extendedJson-BZkQBXEv.js.map
@@ -0,0 +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"}
@@ -0,0 +1,53 @@
1
+
2
+ //#region src/lib/extendedJson.ts
3
+ function toExtendedJson(value) {
4
+ if (value instanceof Map) return { __map: [...value].map(([k, v]) => [toExtendedJson(k), toExtendedJson(v)]) };
5
+ if (value instanceof Set) return { __set: [...value].map(toExtendedJson) };
6
+ if (value instanceof Date) return { __date: value.toISOString() };
7
+ if (typeof value === "bigint") return { __bigint: value.toString() };
8
+ if (Array.isArray(value)) return value.map(toExtendedJson);
9
+ if (typeof value === "object" && value !== null) return Object.fromEntries(Object.entries(value).map(([k, v]) => [k, toExtendedJson(v)]));
10
+ return value;
11
+ }
12
+ function toExtendedJsonString(value, ...args) {
13
+ return JSON.stringify(toExtendedJson(value), ...args);
14
+ }
15
+ function fromExtendedJson(value) {
16
+ if (typeof value !== "object" || value === null) return value;
17
+ if ("__map" in value) return new Map(value.__map.map(([k, v]) => [fromExtendedJson(k), fromExtendedJson(v)]));
18
+ if ("__set" in value) return new Set(value.__set.map(fromExtendedJson));
19
+ if ("__date" in value) return new Date(value.__date);
20
+ if ("__bigint" in value) return BigInt(value.__bigint);
21
+ if (Array.isArray(value)) return value.map(fromExtendedJson);
22
+ return Object.fromEntries(Object.entries(value).map(([k, v]) => [k, fromExtendedJson(v)]));
23
+ }
24
+ function fromExtendedJsonString(value, reviver) {
25
+ return fromExtendedJson(JSON.parse(value, reviver));
26
+ }
27
+
28
+ //#endregion
29
+ Object.defineProperty(exports, 'fromExtendedJson', {
30
+ enumerable: true,
31
+ get: function () {
32
+ return fromExtendedJson;
33
+ }
34
+ });
35
+ Object.defineProperty(exports, 'fromExtendedJsonString', {
36
+ enumerable: true,
37
+ get: function () {
38
+ return fromExtendedJsonString;
39
+ }
40
+ });
41
+ Object.defineProperty(exports, 'toExtendedJson', {
42
+ enumerable: true,
43
+ get: function () {
44
+ return toExtendedJson;
45
+ }
46
+ });
47
+ Object.defineProperty(exports, 'toExtendedJsonString', {
48
+ enumerable: true,
49
+ get: function () {
50
+ return toExtendedJsonString;
51
+ }
52
+ });
53
+ //# sourceMappingURL=extendedJson-Dn2F7Edo.cjs.map
@@ -0,0 +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"}
@@ -0,0 +1,19 @@
1
+ import { isPlainObject } from "./propAccess-DGchzVfy.js";
2
+
3
+ //#region src/lib/hash.ts
4
+ const hash = Symbol("hash");
5
+ function hasHashFunction(value) {
6
+ return typeof value === "object" && value !== null && hash in value && typeof value[hash] === "function" && value[hash].length === 0;
7
+ }
8
+ function simpleHash(value) {
9
+ if (hasHashFunction(value)) return value[hash]();
10
+ if (value instanceof Set) return `s[${[...value].map(simpleHash).sort().join(",")}]`;
11
+ if (value instanceof Map) return `m[${[...value.entries()].map(simpleHash).sort().join(",")}]`;
12
+ if (Array.isArray(value)) return `[${value.map(simpleHash).join(",")}]`;
13
+ if (isPlainObject(value)) return `o[${Object.entries(value).map(simpleHash).sort().join(",")}]`;
14
+ return JSON.stringify(value);
15
+ }
16
+
17
+ //#endregion
18
+ export { hash, simpleHash };
19
+ //# sourceMappingURL=hash-BV06P7va.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hash-BV06P7va.js","names":["hash: unique symbol"],"sources":["../src/lib/hash.ts"],"sourcesContent":["import { isPlainObject } from '@lib/helpers';\n\nexport interface Hashable {\n [hash](): string;\n}\n\nexport const hash: unique symbol = Symbol('hash');\n\nfunction hasHashFunction(value: unknown): value is Hashable {\n return (\n typeof value === 'object' &&\n value !== null &&\n hash in value &&\n typeof (value as any)[hash] === 'function' &&\n (value as any)[hash].length === 0\n );\n}\n\nexport function simpleHash(value: unknown): string {\n if (hasHashFunction(value)) {\n return value[hash]();\n }\n\n if (value instanceof Set) {\n return `s[${[...value].map(simpleHash).sort().join(',')}]`;\n }\n\n if (value instanceof Map) {\n return `m[${[...value.entries()].map(simpleHash).sort().join(',')}]`;\n }\n\n if (Array.isArray(value)) {\n return `[${value.map(simpleHash).join(',')}]`;\n }\n\n if (isPlainObject(value)) {\n return `o[${Object.entries(value).map(simpleHash).sort().join(',')}]`;\n }\n\n return JSON.stringify(value);\n}\n"],"mappings":";;;AAMA,MAAaA,OAAsB,OAAO;AAE1C,SAAS,gBAAgB,OAAmC;AAC1D,QACE,OAAO,UAAU,YACjB,UAAU,QACV,QAAQ,SACR,OAAQ,MAAc,UAAU,cAC/B,MAAc,MAAM,WAAW;;AAIpC,SAAgB,WAAW,OAAwB;AACjD,KAAI,gBAAgB,OAClB,QAAO,MAAM;AAGf,KAAI,iBAAiB,IACnB,QAAO,KAAK,CAAC,GAAG,OAAO,IAAI,YAAY,OAAO,KAAK,KAAK;AAG1D,KAAI,iBAAiB,IACnB,QAAO,KAAK,CAAC,GAAG,MAAM,WAAW,IAAI,YAAY,OAAO,KAAK,KAAK;AAGpE,KAAI,MAAM,QAAQ,OAChB,QAAO,IAAI,MAAM,IAAI,YAAY,KAAK,KAAK;AAG7C,KAAI,cAAc,OAChB,QAAO,KAAK,OAAO,QAAQ,OAAO,IAAI,YAAY,OAAO,KAAK,KAAK;AAGrE,QAAO,KAAK,UAAU"}
@@ -0,0 +1,30 @@
1
+ const require_propAccess = require('./propAccess-ByqBjC19.cjs');
2
+
3
+ //#region src/lib/hash.ts
4
+ const hash = Symbol("hash");
5
+ function hasHashFunction(value) {
6
+ return typeof value === "object" && value !== null && hash in value && typeof value[hash] === "function" && value[hash].length === 0;
7
+ }
8
+ function simpleHash(value) {
9
+ if (hasHashFunction(value)) return value[hash]();
10
+ if (value instanceof Set) return `s[${[...value].map(simpleHash).sort().join(",")}]`;
11
+ if (value instanceof Map) return `m[${[...value.entries()].map(simpleHash).sort().join(",")}]`;
12
+ if (Array.isArray(value)) return `[${value.map(simpleHash).join(",")}]`;
13
+ if (require_propAccess.isPlainObject(value)) return `o[${Object.entries(value).map(simpleHash).sort().join(",")}]`;
14
+ return JSON.stringify(value);
15
+ }
16
+
17
+ //#endregion
18
+ Object.defineProperty(exports, 'hash', {
19
+ enumerable: true,
20
+ get: function () {
21
+ return hash;
22
+ }
23
+ });
24
+ Object.defineProperty(exports, 'simpleHash', {
25
+ enumerable: true,
26
+ get: function () {
27
+ return simpleHash;
28
+ }
29
+ });
30
+ //# sourceMappingURL=hash-CJPl7SRj.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hash-CJPl7SRj.cjs","names":["hash: unique symbol","isPlainObject"],"sources":["../src/lib/hash.ts"],"sourcesContent":["import { isPlainObject } from '@lib/helpers';\n\nexport interface Hashable {\n [hash](): string;\n}\n\nexport const hash: unique symbol = Symbol('hash');\n\nfunction hasHashFunction(value: unknown): value is Hashable {\n return (\n typeof value === 'object' &&\n value !== null &&\n hash in value &&\n typeof (value as any)[hash] === 'function' &&\n (value as any)[hash].length === 0\n );\n}\n\nexport function simpleHash(value: unknown): string {\n if (hasHashFunction(value)) {\n return value[hash]();\n }\n\n if (value instanceof Set) {\n return `s[${[...value].map(simpleHash).sort().join(',')}]`;\n }\n\n if (value instanceof Map) {\n return `m[${[...value.entries()].map(simpleHash).sort().join(',')}]`;\n }\n\n if (Array.isArray(value)) {\n return `[${value.map(simpleHash).join(',')}]`;\n }\n\n if (isPlainObject(value)) {\n return `o[${Object.entries(value).map(simpleHash).sort().join(',')}]`;\n }\n\n return JSON.stringify(value);\n}\n"],"mappings":";;;AAMA,MAAaA,OAAsB,OAAO;AAE1C,SAAS,gBAAgB,OAAmC;AAC1D,QACE,OAAO,UAAU,YACjB,UAAU,QACV,QAAQ,SACR,OAAQ,MAAc,UAAU,cAC/B,MAAc,MAAM,WAAW;;AAIpC,SAAgB,WAAW,OAAwB;AACjD,KAAI,gBAAgB,OAClB,QAAO,MAAM;AAGf,KAAI,iBAAiB,IACnB,QAAO,KAAK,CAAC,GAAG,OAAO,IAAI,YAAY,OAAO,KAAK,KAAK;AAG1D,KAAI,iBAAiB,IACnB,QAAO,KAAK,CAAC,GAAG,MAAM,WAAW,IAAI,YAAY,OAAO,KAAK,KAAK;AAGpE,KAAI,MAAM,QAAQ,OAChB,QAAO,IAAI,MAAM,IAAI,YAAY,KAAK,KAAK;AAG7C,KAAIC,iCAAc,OAChB,QAAO,KAAK,OAAO,QAAQ,OAAO,IAAI,YAAY,OAAO,KAAK,KAAK;AAGrE,QAAO,KAAK,UAAU"}
package/dist/index.cjs ADDED
@@ -0,0 +1,49 @@
1
+ const require_store = require('./store-BWMWEUpu.cjs');
2
+ const require_propAccess = require('./propAccess-ByqBjC19.cjs');
3
+ const require_hash = require('./hash-CJPl7SRj.cjs');
4
+ const require_scope = require('./scope-DvqvkIHB.cjs');
5
+ const require_patchMethods = require('./patchMethods-D5YJwcpn.cjs');
6
+ const require_extendedJson = require('./extendedJson-Dn2F7Edo.cjs');
7
+ const require_persist = require('./persist-CztClydq.cjs');
8
+
9
+ //#region src/lib/updateHelpers.ts
10
+ function findOrDefault(array, predicate, defaultValue) {
11
+ const index = array.findIndex(predicate);
12
+ if (index >= 0) return array[index];
13
+ const value = defaultValue instanceof Function ? defaultValue() : defaultValue;
14
+ array.push(value);
15
+ return value;
16
+ }
17
+
18
+ //#endregion
19
+ exports.Cache = require_scope.Cache;
20
+ exports.InstanceCache = require_scope.InstanceCache;
21
+ exports.ResourceGroup = require_scope.ResourceGroup;
22
+ exports.Scope = require_scope.Scope;
23
+ exports.Store = require_store.Store;
24
+ exports.allResources = require_scope.allResources;
25
+ exports.applyPatches = require_patchMethods.applyPatches;
26
+ exports.arrayMethods = require_store.arrayMethods;
27
+ exports.calcDuration = require_store.calcDuration;
28
+ exports.createCache = require_scope.createCache;
29
+ exports.createResourceGroup = require_scope.createResourceGroup;
30
+ exports.createScope = require_scope.createScope;
31
+ exports.createStore = require_store.createStore;
32
+ exports.deepEqual = require_propAccess.deepEqual;
33
+ exports.diff = require_patchMethods.diff;
34
+ exports.findOrDefault = findOrDefault;
35
+ exports.fromExtendedJson = require_extendedJson.fromExtendedJson;
36
+ exports.fromExtendedJsonString = require_extendedJson.fromExtendedJsonString;
37
+ exports.get = require_propAccess.get;
38
+ exports.hash = require_hash.hash;
39
+ exports.mapMethods = require_store.mapMethods;
40
+ exports.persist = require_persist.persist;
41
+ exports.recordMethods = require_store.recordMethods;
42
+ exports.set = require_propAccess.set;
43
+ exports.setMethods = require_store.setMethods;
44
+ exports.shallowEqual = require_propAccess.shallowEqual;
45
+ exports.simpleHash = require_hash.simpleHash;
46
+ exports.strictEqual = require_propAccess.strictEqual;
47
+ exports.toExtendedJson = require_extendedJson.toExtendedJson;
48
+ exports.toExtendedJsonString = require_extendedJson.toExtendedJsonString;
49
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.cjs","names":[],"sources":["../src/lib/updateHelpers.ts"],"sourcesContent":["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":";;;;;;;;;AAAA,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"}
@@ -0,0 +1,59 @@
1
+ import { Cache, CacheBundle, CacheFunction, CacheGetOptions, CacheOptions, CacheState, CreateCacheResult, ErrorState, PendingState, Resource, ResourceGroup, Scope, ValueState, allResources, createCache, createResourceGroup, createScope } from "./scope-DO5vpLPV.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-BEsiS8y7.cjs";
3
+ import { Patch, diff } from "./diff-BQ8bB3Wk.cjs";
4
+ import { Persist, PersistOptions, PersistStorage, PersistStorageBase, PersistStorageWithKeys, PersistStorageWithLength, PersistStorageWithListItems, persist } from "./persist-D7MAsyyW.cjs";
5
+
6
+ //#region src/lib/applyPatches.d.ts
7
+ declare function applyPatches<T>(target: T, ...patches: Patch[]): T;
8
+ //#endregion
9
+ //#region src/lib/calcDuration.d.ts
10
+ declare function calcDuration(t: Duration): number;
11
+ //#endregion
12
+ //#region src/lib/equals.d.ts
13
+ declare function strictEqual(a: any, b: any): boolean;
14
+ declare function shallowEqual(a: any, b: any): boolean;
15
+ declare function deepEqual(a: any, b: any): boolean;
16
+ //#endregion
17
+ //#region src/lib/extendedJson.d.ts
18
+ declare function toExtendedJson(value: unknown): unknown;
19
+ declare function toExtendedJsonString(value: any, replacer?: (this: any, key: string, value: any) => any, space?: string | number): string;
20
+ declare function toExtendedJsonString(value: any, replacer?: (number | string)[] | null, space?: string | number): string;
21
+ declare function fromExtendedJson(value: unknown): unknown;
22
+ declare function fromExtendedJsonString(value: string, reviver?: (this: any, key: string, value: any) => any): unknown;
23
+ //#endregion
24
+ //#region src/lib/hash.d.ts
25
+ interface Hashable {
26
+ [hash](): string;
27
+ }
28
+ declare const hash: unique symbol;
29
+ declare function simpleHash(value: unknown): string;
30
+ //#endregion
31
+ //#region src/lib/instanceCache.d.ts
32
+ declare class InstanceCache<Args extends any[], T extends object> {
33
+ readonly factory: (...args: Args) => T;
34
+ readonly cacheTime?: number | undefined;
35
+ private cache;
36
+ private interval;
37
+ constructor(factory: (...args: Args) => T, cacheTime?: number | undefined);
38
+ cleanup(): void;
39
+ get(...args: Args): T;
40
+ getWithKey(args: Args, cacheKey: unknown): T;
41
+ values(): T[];
42
+ stop(): void;
43
+ stats(): {
44
+ count: number;
45
+ withRef: number;
46
+ withWeakRef: number;
47
+ };
48
+ private now;
49
+ }
50
+ //#endregion
51
+ //#region src/lib/propAccess.d.ts
52
+ declare function get<T, const P>(object: T, path: Constrain<P, Path<T>>): Value<T, P>;
53
+ declare function set<T, const P>(object: T, path: Constrain<P, SettablePath<T>>, value: SettableValue<T, P>, rootPath?: string | readonly KeyType[]): T;
54
+ //#endregion
55
+ //#region src/lib/updateHelpers.d.ts
56
+ declare function findOrDefault<T>(array: T[], predicate: (item: T) => boolean, defaultValue: T | (() => T)): T;
57
+ //#endregion
58
+ export { AsyncConnectionActions, AsyncUpdateFunction, BaseConnectionActions, BoundStoreMethods, Cache, CacheBundle, CacheFunction, CacheGetOptions, CacheOptions, CacheState, CalculationActions, Cancel, Connection, ConnectionActions, CreateCacheResult, DisposableCancel, Duration, Effect, ErrorState, type Hashable, InstanceCache, Listener, type Patch, type Path, type PathAsArray, type PathAsString, PendingState, Persist, PersistOptions, PersistStorage, PersistStorageBase, PersistStorageWithKeys, PersistStorageWithLength, PersistStorageWithListItems, Resource, ResourceGroup, Scope, Selector, type SettablePath, type SettablePathAsArray, type SettablePathAsString, Store, StoreMethods, StoreOptions, StoreOptionsWithMethods, SubscribeOptions, Update, UpdateFrom, UpdateFunction, Use, type Value, ValueState, allResources, applyPatches, arrayMethods, calcDuration, createCache, createResourceGroup, createScope, createStore, deepEqual, diff, findOrDefault, fromExtendedJson, fromExtendedJsonString, get, hash, mapMethods, persist, recordMethods, set, setMethods, shallowEqual, simpleHash, strictEqual, toExtendedJson, toExtendedJsonString };
59
+ //# sourceMappingURL=index.d.cts.map
@@ -0,0 +1,59 @@
1
+ import { Cache, CacheBundle, CacheFunction, CacheGetOptions, CacheOptions, CacheState, CreateCacheResult, ErrorState, PendingState, Resource, ResourceGroup, Scope, ValueState, allResources, createCache, createResourceGroup, createScope } from "./scope-DI1OFHcr.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-DKaeE840.js";
3
+ import { Patch, diff } from "./diff-gZezL04N.js";
4
+ import { Persist, PersistOptions, PersistStorage, PersistStorageBase, PersistStorageWithKeys, PersistStorageWithLength, PersistStorageWithListItems, persist } from "./persist-CPjpg6D0.js";
5
+
6
+ //#region src/lib/applyPatches.d.ts
7
+ declare function applyPatches<T>(target: T, ...patches: Patch[]): T;
8
+ //#endregion
9
+ //#region src/lib/calcDuration.d.ts
10
+ declare function calcDuration(t: Duration): number;
11
+ //#endregion
12
+ //#region src/lib/equals.d.ts
13
+ declare function strictEqual(a: any, b: any): boolean;
14
+ declare function shallowEqual(a: any, b: any): boolean;
15
+ declare function deepEqual(a: any, b: any): boolean;
16
+ //#endregion
17
+ //#region src/lib/extendedJson.d.ts
18
+ declare function toExtendedJson(value: unknown): unknown;
19
+ declare function toExtendedJsonString(value: any, replacer?: (this: any, key: string, value: any) => any, space?: string | number): string;
20
+ declare function toExtendedJsonString(value: any, replacer?: (number | string)[] | null, space?: string | number): string;
21
+ declare function fromExtendedJson(value: unknown): unknown;
22
+ declare function fromExtendedJsonString(value: string, reviver?: (this: any, key: string, value: any) => any): unknown;
23
+ //#endregion
24
+ //#region src/lib/hash.d.ts
25
+ interface Hashable {
26
+ [hash](): string;
27
+ }
28
+ declare const hash: unique symbol;
29
+ declare function simpleHash(value: unknown): string;
30
+ //#endregion
31
+ //#region src/lib/instanceCache.d.ts
32
+ declare class InstanceCache<Args extends any[], T extends object> {
33
+ readonly factory: (...args: Args) => T;
34
+ readonly cacheTime?: number | undefined;
35
+ private cache;
36
+ private interval;
37
+ constructor(factory: (...args: Args) => T, cacheTime?: number | undefined);
38
+ cleanup(): void;
39
+ get(...args: Args): T;
40
+ getWithKey(args: Args, cacheKey: unknown): T;
41
+ values(): T[];
42
+ stop(): void;
43
+ stats(): {
44
+ count: number;
45
+ withRef: number;
46
+ withWeakRef: number;
47
+ };
48
+ private now;
49
+ }
50
+ //#endregion
51
+ //#region src/lib/propAccess.d.ts
52
+ declare function get<T, const P>(object: T, path: Constrain<P, Path<T>>): Value<T, P>;
53
+ declare function set<T, const P>(object: T, path: Constrain<P, SettablePath<T>>, value: SettableValue<T, P>, rootPath?: string | readonly KeyType[]): T;
54
+ //#endregion
55
+ //#region src/lib/updateHelpers.d.ts
56
+ declare function findOrDefault<T>(array: T[], predicate: (item: T) => boolean, defaultValue: T | (() => T)): T;
57
+ //#endregion
58
+ export { AsyncConnectionActions, AsyncUpdateFunction, BaseConnectionActions, BoundStoreMethods, Cache, CacheBundle, CacheFunction, CacheGetOptions, CacheOptions, CacheState, CalculationActions, Cancel, Connection, ConnectionActions, CreateCacheResult, DisposableCancel, Duration, Effect, ErrorState, type Hashable, InstanceCache, Listener, type Patch, type Path, type PathAsArray, type PathAsString, PendingState, Persist, PersistOptions, PersistStorage, PersistStorageBase, PersistStorageWithKeys, PersistStorageWithLength, PersistStorageWithListItems, Resource, ResourceGroup, Scope, Selector, type SettablePath, type SettablePathAsArray, type SettablePathAsString, Store, StoreMethods, StoreOptions, StoreOptionsWithMethods, SubscribeOptions, Update, UpdateFrom, UpdateFunction, Use, type Value, ValueState, allResources, applyPatches, arrayMethods, calcDuration, createCache, createResourceGroup, createScope, createStore, deepEqual, diff, findOrDefault, fromExtendedJson, fromExtendedJsonString, get, hash, mapMethods, persist, recordMethods, set, setMethods, shallowEqual, simpleHash, strictEqual, toExtendedJson, toExtendedJsonString };
59
+ //# sourceMappingURL=index.d.ts.map
package/dist/index.js ADDED
@@ -0,0 +1,20 @@
1
+ import { Store, arrayMethods, calcDuration, createStore, mapMethods, recordMethods, setMethods } from "./store-Dr8gM3lq.js";
2
+ import { deepEqual, get, set, shallowEqual, strictEqual } from "./propAccess-DGchzVfy.js";
3
+ import { hash, simpleHash } from "./hash-BV06P7va.js";
4
+ import { Cache, InstanceCache, ResourceGroup, Scope, allResources, createCache, createResourceGroup, createScope } from "./scope-DU5dFP1T.js";
5
+ import { applyPatches, diff } from "./patchMethods-DRPfkhAe.js";
6
+ import { fromExtendedJson, fromExtendedJsonString, toExtendedJson, toExtendedJsonString } from "./extendedJson-BZkQBXEv.js";
7
+ import { persist } from "./persist-BluRVcW6.js";
8
+
9
+ //#region src/lib/updateHelpers.ts
10
+ function findOrDefault(array, predicate, defaultValue) {
11
+ const index = array.findIndex(predicate);
12
+ if (index >= 0) return array[index];
13
+ const value = defaultValue instanceof Function ? defaultValue() : defaultValue;
14
+ array.push(value);
15
+ return value;
16
+ }
17
+
18
+ //#endregion
19
+ export { Cache, InstanceCache, ResourceGroup, Scope, Store, allResources, applyPatches, arrayMethods, calcDuration, createCache, createResourceGroup, createScope, createStore, deepEqual, diff, findOrDefault, fromExtendedJson, fromExtendedJsonString, get, hash, mapMethods, persist, recordMethods, set, setMethods, shallowEqual, simpleHash, strictEqual, toExtendedJson, toExtendedJsonString };
20
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":[],"sources":["../src/lib/updateHelpers.ts"],"sourcesContent":["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":";;;;;;;;;AAAA,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"}
@@ -0,0 +1,3 @@
1
+ const require_mutativeMethods = require('../mutativeMethods-CgXk_bMt.cjs');
2
+
3
+ exports.mutativeMethods = require_mutativeMethods.mutativeMethods;
@@ -0,0 +1,3 @@
1
+ import "../store-BEsiS8y7.cjs";
2
+ import { Mutation, mutativeMethods } from "../mutativeMethods-6QzygG3W.cjs";
3
+ export { type Mutation, mutativeMethods };
@@ -0,0 +1,3 @@
1
+ import "../store-DKaeE840.js";
2
+ import { Mutation, mutativeMethods } from "../mutativeMethods-Br3xN2Iq.js";
3
+ export { type Mutation, mutativeMethods };
@@ -0,0 +1,3 @@
1
+ import { mutativeMethods } from "../mutativeMethods-CZKeRIDL.js";
2
+
3
+ export { mutativeMethods };
@@ -0,0 +1,10 @@
1
+ const require_store = require('../store-BWMWEUpu.cjs');
2
+ require('../propAccess-ByqBjC19.cjs');
3
+ const require_mutativeMethods = require('../mutativeMethods-CgXk_bMt.cjs');
4
+
5
+ //#region src/mutative/register.ts
6
+ Object.assign(require_store.Store.prototype, require_mutativeMethods.mutativeMethods);
7
+ require_store.autobind(require_store.Store);
8
+
9
+ //#endregion
10
+ //# sourceMappingURL=register.cjs.map
@@ -0,0 +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 '@core' {\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"}
@@ -0,0 +1,11 @@
1
+ import "../store-BEsiS8y7.cjs";
2
+ import { mutativeMethods } from "../mutativeMethods-6QzygG3W.cjs";
3
+
4
+ //#region src/mutative/register.d.ts
5
+ type MutativeMethods = typeof mutativeMethods;
6
+ declare module "@core" {
7
+ interface Store<T> extends MutativeMethods {}
8
+ }
9
+ //#endregion
10
+ export {};
11
+ //# sourceMappingURL=register.d.cts.map
@@ -0,0 +1,9 @@
1
+ import "../store-DKaeE840.js";
2
+ import { mutativeMethods } from "../mutativeMethods-Br3xN2Iq.js";
3
+
4
+ //#region src/mutative/register.d.ts
5
+ type MutativeMethods = typeof mutativeMethods;
6
+ declare module "@core" {
7
+ interface Store<T> extends MutativeMethods {}
8
+ }
9
+ //# sourceMappingURL=register.d.ts.map
@@ -0,0 +1,10 @@
1
+ import { Store, autobind } from "../store-Dr8gM3lq.js";
2
+ import "../propAccess-DGchzVfy.js";
3
+ import { mutativeMethods } from "../mutativeMethods-CZKeRIDL.js";
4
+
5
+ //#region src/mutative/register.ts
6
+ Object.assign(Store.prototype, mutativeMethods);
7
+ autobind(Store);
8
+
9
+ //#endregion
10
+ //# sourceMappingURL=register.js.map
@@ -0,0 +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 '@core' {\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"}
@@ -0,0 +1,13 @@
1
+ import { Constrain, Path, Store, Value } from "./store-BEsiS8y7.cjs";
2
+ import { Draft } from "mutative";
3
+
4
+ //#region src/mutative/mutativeMethods.d.ts
5
+ type Mutation<T> = (draft: Draft<T>) => void;
6
+ declare function update<T>(this: Store<T>, mutation: Mutation<T>): void;
7
+ declare function update<T, const P>(this: Store<T>, path: Constrain<P, Path<T>>, mutation: Mutation<Value<T, P>>): void;
8
+ declare const mutativeMethods: {
9
+ update: typeof update;
10
+ };
11
+ //#endregion
12
+ export { Mutation, mutativeMethods };
13
+ //# sourceMappingURL=mutativeMethods-6QzygG3W.d.cts.map
@@ -0,0 +1,13 @@
1
+ import { Constrain, Path, Store, Value } from "./store-DKaeE840.js";
2
+ import { Draft } from "mutative";
3
+
4
+ //#region src/mutative/mutativeMethods.d.ts
5
+ type Mutation<T> = (draft: Draft<T>) => void;
6
+ declare function update<T>(this: Store<T>, mutation: Mutation<T>): void;
7
+ declare function update<T, const P>(this: Store<T>, path: Constrain<P, Path<T>>, mutation: Mutation<Value<T, P>>): void;
8
+ declare const mutativeMethods: {
9
+ update: typeof update;
10
+ };
11
+ //#endregion
12
+ export { Mutation, mutativeMethods };
13
+ //# sourceMappingURL=mutativeMethods-Br3xN2Iq.d.ts.map
@@ -0,0 +1,27 @@
1
+ import { create } from "mutative";
2
+
3
+ //#region src/mutative/mutativeMethods.ts
4
+ function update(...args) {
5
+ if (args.length === 1) {
6
+ const [mutation] = args;
7
+ this.set((value) => {
8
+ const result = create(value, (draft) => {
9
+ mutation(draft);
10
+ });
11
+ return result;
12
+ });
13
+ } else {
14
+ const [path, mutation] = args;
15
+ this.set(path, (value) => {
16
+ const result = create(value, (draft) => {
17
+ mutation(draft);
18
+ });
19
+ return result;
20
+ });
21
+ }
22
+ }
23
+ const mutativeMethods = { update };
24
+
25
+ //#endregion
26
+ export { mutativeMethods };
27
+ //# sourceMappingURL=mutativeMethods-CZKeRIDL.js.map
@@ -0,0 +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"}
@@ -0,0 +1,33 @@
1
+ const require_chunk = require('./chunk-CUT6urMc.cjs');
2
+ const mutative = require_chunk.__toESM(require("mutative"));
3
+
4
+ //#region src/mutative/mutativeMethods.ts
5
+ function update(...args) {
6
+ if (args.length === 1) {
7
+ const [mutation] = args;
8
+ this.set((value) => {
9
+ const result = (0, mutative.create)(value, (draft) => {
10
+ mutation(draft);
11
+ });
12
+ return result;
13
+ });
14
+ } else {
15
+ const [path, mutation] = args;
16
+ this.set(path, (value) => {
17
+ const result = (0, mutative.create)(value, (draft) => {
18
+ mutation(draft);
19
+ });
20
+ return result;
21
+ });
22
+ }
23
+ }
24
+ const mutativeMethods = { update };
25
+
26
+ //#endregion
27
+ Object.defineProperty(exports, 'mutativeMethods', {
28
+ enumerable: true,
29
+ get: function () {
30
+ return mutativeMethods;
31
+ }
32
+ });
33
+ //# sourceMappingURL=mutativeMethods-CgXk_bMt.cjs.map
@@ -0,0 +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"}