cross-state 1.9.6 → 1.9.7

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 (109) hide show
  1. package/dist/{diff-Bcr0h7-x.d.cts → diff-BzE2cDaU.d.cts} +2 -2
  2. package/dist/{diff-CwiTYAVK.d.ts → diff-Cvc-z20n.d.ts} +2 -2
  3. package/dist/{extendedJson-DA3RQ_ly.js → extendedJson-BOmrkRrD.js} +2 -2
  4. package/dist/{extendedJson-DA3RQ_ly.js.map → extendedJson-BOmrkRrD.js.map} +1 -1
  5. package/dist/{extendedJson-DzXMFE1P.cjs → extendedJson-pbOLcymB.cjs} +2 -2
  6. package/dist/{extendedJson-DzXMFE1P.cjs.map → extendedJson-pbOLcymB.cjs.map} +1 -1
  7. package/dist/index.cjs +9 -8
  8. package/dist/index.cjs.map +1 -1
  9. package/dist/index.d.cts +6 -6
  10. package/dist/index.d.ts +6 -6
  11. package/dist/index.js +8 -8
  12. package/dist/index.js.map +1 -1
  13. package/dist/mutative/index.cjs +2 -1
  14. package/dist/mutative/index.d.cts +1 -1
  15. package/dist/mutative/index.d.ts +1 -1
  16. package/dist/mutative/index.js +1 -1
  17. package/dist/mutative/register.cjs +2 -2
  18. package/dist/mutative/register.cjs.map +1 -1
  19. package/dist/mutative/register.d.cts +2 -2
  20. package/dist/mutative/register.d.ts +2 -2
  21. package/dist/mutative/register.js +2 -2
  22. package/dist/mutative/register.js.map +1 -1
  23. package/dist/{mutativeMethods-CwDMtUNs.cjs → mutativeMethods-AiKkraqx.cjs} +1 -1
  24. package/dist/mutativeMethods-AiKkraqx.cjs.map +1 -0
  25. package/dist/{mutativeMethods-Do8JiJ5A.d.cts → mutativeMethods-BHPlSHBi.d.cts} +2 -2
  26. package/dist/{mutativeMethods-t67Kp1uA.d.ts → mutativeMethods-COQxFB3B.d.ts} +2 -2
  27. package/dist/{mutativeMethods-BrDU8SwY.js → mutativeMethods-qVJ36MY5.js} +1 -1
  28. package/dist/mutativeMethods-qVJ36MY5.js.map +1 -0
  29. package/dist/{patchMethods-C21iQqML.d.ts → patchMethods--ekCkYUF.d.ts} +4 -4
  30. package/dist/{patchMethods-CZje49Dk.cjs → patchMethods-BBQDDqwe.cjs} +9 -9
  31. package/dist/patchMethods-BBQDDqwe.cjs.map +1 -0
  32. package/dist/{patchMethods-Cui462lc.js → patchMethods-D3cdG80W.js} +9 -9
  33. package/dist/patchMethods-D3cdG80W.js.map +1 -0
  34. package/dist/{patchMethods-Cyb6MEOG.d.cts → patchMethods-R3f7HxTy.d.cts} +4 -4
  35. package/dist/patches/index.cjs +2 -1
  36. package/dist/patches/index.d.cts +1 -1
  37. package/dist/patches/index.d.ts +1 -1
  38. package/dist/patches/index.js +1 -1
  39. package/dist/patches/register.cjs +2 -2
  40. package/dist/patches/register.cjs.map +1 -1
  41. package/dist/patches/register.d.cts +2 -2
  42. package/dist/patches/register.d.ts +2 -2
  43. package/dist/patches/register.js +2 -2
  44. package/dist/patches/register.js.map +1 -1
  45. package/dist/{path-Il5r4PV4.cjs → path-B9-Z0127.cjs} +1 -1
  46. package/dist/{path-Il5r4PV4.cjs.map → path-B9-Z0127.cjs.map} +1 -1
  47. package/dist/{path-CCEtQjMB.js → path-C-5jTZu5.js} +1 -1
  48. package/dist/{path-CCEtQjMB.js.map → path-C-5jTZu5.js.map} +1 -1
  49. package/dist/persist/register.cjs +2 -2
  50. package/dist/persist/register.cjs.map +1 -1
  51. package/dist/persist/register.d.cts +2 -2
  52. package/dist/persist/register.d.ts +2 -2
  53. package/dist/persist/register.js +2 -2
  54. package/dist/persist/register.js.map +1 -1
  55. package/dist/{persist-CG1WHP6D.cjs → persist-B341lrOA.cjs} +43 -45
  56. package/dist/persist-B341lrOA.cjs.map +1 -0
  57. package/dist/{persist-CkZ7CzW8.d.cts → persist-CoSWtRt0.d.cts} +3 -3
  58. package/dist/{persist-3Nff6j1f.d.ts → persist-XVT4fROX.d.ts} +3 -3
  59. package/dist/{persist-CNA2sYtB.js → persist-xv73m7UR.js} +43 -45
  60. package/dist/persist-xv73m7UR.js.map +1 -0
  61. package/dist/{propAccess-BxCKNeOj.js → propAccess-CsUaG5V_.js} +8 -8
  62. package/dist/propAccess-CsUaG5V_.js.map +1 -0
  63. package/dist/{propAccess-udIdjqwY.cjs → propAccess-DdLF12Jq.cjs} +8 -8
  64. package/dist/propAccess-DdLF12Jq.cjs.map +1 -0
  65. package/dist/react/index.cjs +118 -117
  66. package/dist/react/index.cjs.map +1 -1
  67. package/dist/react/index.d.cts +98 -98
  68. package/dist/react/index.d.ts +97 -97
  69. package/dist/react/index.js +119 -119
  70. package/dist/react/index.js.map +1 -1
  71. package/dist/react/register.cjs +3 -3
  72. package/dist/react/register.cjs.map +1 -1
  73. package/dist/react/register.d.cts +2 -2
  74. package/dist/react/register.d.ts +2 -2
  75. package/dist/react/register.js +3 -3
  76. package/dist/react/register.js.map +1 -1
  77. package/dist/{scope-DkX72a-2.cjs → scope-8MUrzqlS.cjs} +60 -60
  78. package/dist/scope-8MUrzqlS.cjs.map +1 -0
  79. package/dist/{scope-8uUaV6I8.d.cts → scope-BQjncWGt.d.cts} +25 -25
  80. package/dist/{scope-CQE3HDNI.js → scope-BfaweXvz.js} +61 -61
  81. package/dist/scope-BfaweXvz.js.map +1 -0
  82. package/dist/{scope-qdOAlRWQ.d.ts → scope-BztVo2P8.d.ts} +25 -25
  83. package/dist/{store-D4q5zD7q.js → store-BmlnyYal.js} +81 -81
  84. package/dist/store-BmlnyYal.js.map +1 -0
  85. package/dist/{store-Cq1PqvEo.d.ts → store-dThvqc0k.d.cts} +55 -55
  86. package/dist/{store-21GsOOLS.d.cts → store-dThvqc0k.d.ts} +55 -55
  87. package/dist/{store-CPqOf4y5.cjs → store-fmAYV5hy.cjs} +80 -80
  88. package/dist/store-fmAYV5hy.cjs.map +1 -0
  89. package/dist/{storeMethods-BjuI0joo.d.cts → storeMethods-CYX3AAnA.d.ts} +4 -4
  90. package/dist/{storeMethods-BZb4k7Ma.cjs → storeMethods-DYgUGHSk.cjs} +14 -14
  91. package/dist/storeMethods-DYgUGHSk.cjs.map +1 -0
  92. package/dist/{storeMethods-CK9-Q17H.d.ts → storeMethods-DrMQ7hqX.d.cts} +4 -4
  93. package/dist/{storeMethods-CWeGkXoz.js → storeMethods-pGlt0zfb.js} +14 -14
  94. package/dist/storeMethods-pGlt0zfb.js.map +1 -0
  95. package/package.json +46 -63
  96. package/dist/mutativeMethods-BrDU8SwY.js.map +0 -1
  97. package/dist/mutativeMethods-CwDMtUNs.cjs.map +0 -1
  98. package/dist/patchMethods-CZje49Dk.cjs.map +0 -1
  99. package/dist/patchMethods-Cui462lc.js.map +0 -1
  100. package/dist/persist-CG1WHP6D.cjs.map +0 -1
  101. package/dist/persist-CNA2sYtB.js.map +0 -1
  102. package/dist/propAccess-BxCKNeOj.js.map +0 -1
  103. package/dist/propAccess-udIdjqwY.cjs.map +0 -1
  104. package/dist/scope-CQE3HDNI.js.map +0 -1
  105. package/dist/scope-DkX72a-2.cjs.map +0 -1
  106. package/dist/store-CPqOf4y5.cjs.map +0 -1
  107. package/dist/store-D4q5zD7q.js.map +0 -1
  108. package/dist/storeMethods-BZb4k7Ma.cjs.map +0 -1
  109. package/dist/storeMethods-CWeGkXoz.js.map +0 -1
@@ -1,12 +1,12 @@
1
- const require_propAccess = require('./propAccess-udIdjqwY.cjs');
2
- const require_extendedJson = require('./extendedJson-DzXMFE1P.cjs');
1
+ const require_propAccess = require('./propAccess-DdLF12Jq.cjs');
2
+ const require_extendedJson = require('./extendedJson-pbOLcymB.cjs');
3
3
 
4
4
  //#region src/lib/applyPatches.ts
5
5
  function applySinglePatch(target, patch) {
6
6
  if (patch.op === "remove") return require_propAccess.remove(target, patch.path);
7
7
  return require_propAccess.set(target, patch.path, patch.value);
8
8
  }
9
- function applyPatches(target, ...patches) {
9
+ function applyPatches$1(target, ...patches) {
10
10
  for (const patch of patches) target = applySinglePatch(target, patch);
11
11
  return target;
12
12
  }
@@ -90,8 +90,8 @@ function subscribePatches(listener, options = {}) {
90
90
  ]);
91
91
  }, options);
92
92
  }
93
- function applyPatches$1(...patches) {
94
- this.set((value) => applyPatches(value, ...patches.flat()));
93
+ function applyPatches(...patches) {
94
+ this.set((value) => applyPatches$1(value, ...patches.flat()));
95
95
  }
96
96
  function sync(listener, options) {
97
97
  const debounce = typeof options?.debounce === "object" && "wait" in options.debounce ? { ...options.debounce } : options?.debounce !== void 0 ? { wait: options.debounce } : void 0;
@@ -118,11 +118,11 @@ function acceptSync(message) {
118
118
  if (message.fromVersion && message.fromVersion !== this.version) throw new Error(`version mismatch! version=${this.version}, fromVersion=${message.fromVersion}`);
119
119
  const patches = require_extendedJson.fromExtendedJson(message.patches);
120
120
  this.version = message.toVersion;
121
- applyPatches$1.apply(this, patches);
121
+ applyPatches.apply(this, patches);
122
122
  }
123
123
  const patchMethods = {
124
124
  subscribePatches,
125
- applyPatches: applyPatches$1,
125
+ applyPatches,
126
126
  sync,
127
127
  acceptSync
128
128
  };
@@ -131,7 +131,7 @@ const patchMethods = {
131
131
  Object.defineProperty(exports, 'applyPatches', {
132
132
  enumerable: true,
133
133
  get: function () {
134
- return applyPatches;
134
+ return applyPatches$1;
135
135
  }
136
136
  });
137
137
  Object.defineProperty(exports, 'patchMethods', {
@@ -146,4 +146,4 @@ Object.defineProperty(exports, 'subscribePatches', {
146
146
  return subscribePatches;
147
147
  }
148
148
  });
149
- //# sourceMappingURL=patchMethods-CZje49Dk.cjs.map
149
+ //# sourceMappingURL=patchMethods-BBQDDqwe.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"patchMethods-BBQDDqwe.cjs","names":["remove","set","applyPatches","diff","_applyPatches","toExtendedJson","fromExtendedJson"],"sources":["../src/lib/applyPatches.ts","../src/lib/trie.ts","../src/patches/patchMethods.ts"],"sourcesContent":["import type { Patch } from './diff';\nimport { remove, set } from './propAccess';\n\nfunction applySinglePatch<T>(target: T, patch: Patch): T {\n if (patch.op === 'remove') {\n return remove(target, patch.path as any);\n }\n\n return set(target, patch.path as any, patch.value);\n}\n\nexport function applyPatches<T>(target: T, ...patches: Patch[]): T {\n for (const patch of patches) {\n target = applySinglePatch(target, patch);\n }\n\n return target;\n}\n","import type { KeyType } from '@lib/path';\n\nclass TrieNode {\n children: Map<KeyType, TrieNode> = new Map();\n isLeaf = false;\n}\n\nexport class Trie {\n root: TrieNode = new TrieNode();\n\n add(path: KeyType[]): void {\n let node = this.root;\n for (const key of path) {\n let next = node.children.get(key);\n if (!next) node.children.set(key, (next = new TrieNode()));\n node = next;\n }\n node.isLeaf = true;\n }\n\n hasSubPath(path: KeyType[]): boolean {\n let node = this.root;\n for (const key of path) {\n const next = node.children.get(key);\n if (!next) return false;\n node = next;\n }\n return node.isLeaf;\n }\n}\n","import type { Cancel, DisposableCancel, SubscribeOptions } from '@core/commonTypes';\nimport type { Store } from '@core/store';\nimport { applyPatches as _applyPatches } from '@lib/applyPatches';\nimport { diff, type DiffOptions, type Patch } from '@lib/diff';\nimport { fromExtendedJson, toExtendedJson } from '@lib/extendedJson';\nimport { Trie } from '@lib/trie';\n\nexport interface SyncMessage {\n fromVersion?: string;\n toVersion: string;\n patches: Patch[];\n}\n\nexport interface HistoryEntry extends SyncMessage {\n reversePatches: Patch[];\n}\n\ndeclare module '@core' {\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n interface Store<T> {\n __patches?: {\n value: T;\n version: string;\n history: HistoryEntry[];\n };\n }\n}\n\nexport interface SubscribePatchOptions extends SubscribeOptions, DiffOptions {\n /** @default false */\n runNow?: boolean;\n /** try to start from a specific version and only receive patches after that.\n * If the id is not found, it will start from the beginning */\n startAt?: string;\n}\n\nexport type InteropPatch = Patch | { op: 'add' | 'replace' | 'remove'; value?: any };\n\nconst genId = () => Math.random().toString(36).slice(2);\n\nexport function subscribePatches<T>(\n this: Store<T>,\n listener: (\n this: { cancel: Cancel },\n patches: Patch[],\n reversePatches: Patch[],\n version: string,\n previousVersion: string | undefined,\n ) => void,\n options: SubscribePatchOptions = {},\n): DisposableCancel {\n const patches = (this.__patches ??= {\n value: this.get(),\n version: genId(),\n history: [],\n });\n\n options = { ...options };\n options.runNow ??= false;\n let cursor = options.startAt ?? (options.runNow ? undefined : this.__patches.version);\n\n return this.subscribe(function (value) {\n if (patches.value !== value) {\n const result = diff(patches.value, value, options);\n patches.value = value;\n\n if (result[0].length > 0) {\n const newVersion = genId();\n\n patches.history = patches.history\n .concat({\n fromVersion: patches.version,\n toVersion: newVersion,\n patches: result[0],\n reversePatches: result[1],\n })\n .slice(-1000);\n\n patches.version = newVersion;\n }\n }\n\n if (cursor === patches.version) return;\n const index = patches.history.findIndex((h) => h.fromVersion === cursor);\n let forward, backward, previousVersion;\n\n if (index === -1) {\n [forward, backward] = diff(undefined, value, options);\n previousVersion = undefined;\n } else {\n forward = patches.history.slice(index).flatMap((h) => h.patches);\n backward = patches.history.slice(index).flatMap((h) => h.reversePatches);\n previousVersion = cursor;\n }\n\n cursor = patches.version;\n listener.apply(this, [forward, backward, cursor, previousVersion]);\n }, options);\n}\n\nexport function applyPatches<T>(this: Store<T>, patches: InteropPatch[]): void;\nexport function applyPatches<T>(this: Store<T>, ...patches: InteropPatch[]): void;\nexport function applyPatches<T>(\n this: Store<T>,\n ...patches: (InteropPatch | InteropPatch[])[]\n): void {\n this.set((value) => _applyPatches(value, ...(patches.flat() as Patch[])));\n}\n\nexport function sync<T>(\n this: Store<T>,\n listener: (syncMessage: SyncMessage) => void,\n options?: Omit<SubscribePatchOptions, 'runNow'>,\n): DisposableCancel {\n const debounce =\n typeof options?.debounce === 'object' && 'wait' in options.debounce\n ? { ...options.debounce }\n : options?.debounce !== undefined\n ? { wait: options.debounce }\n : undefined;\n\n if (debounce) {\n debounce.waitOnRunNow ??= false;\n }\n\n return subscribePatches.apply<\n Store<T>,\n Parameters<typeof subscribePatches<T>>,\n ReturnType<typeof subscribePatches<T>>\n >(this, [\n (patches, _, version, previousVersion) => {\n const trie = new Trie();\n\n patches = [...patches]\n .reverse()\n .filter((patch) => {\n if (trie.hasSubPath(patch.path)) {\n return false;\n }\n\n trie.add(patch.path);\n return true;\n })\n .reverse();\n\n listener({\n fromVersion: previousVersion,\n toVersion: version,\n patches: toExtendedJson(patches) as Patch[],\n });\n },\n { ...options, debounce, runNow: true },\n ]);\n}\n\nexport function acceptSync<T>(this: Store<T>, message: SyncMessage): void {\n if (message.fromVersion && message.fromVersion !== this.version) {\n throw new Error(\n `version mismatch! version=${this.version}, fromVersion=${message.fromVersion}`,\n );\n }\n\n const patches = fromExtendedJson(message.patches) as Patch[];\n\n this.version = message.toVersion;\n applyPatches.apply<Store<T>, Patch[], void>(this, patches);\n}\n\nexport const patchMethods: {\n subscribePatches: typeof subscribePatches;\n applyPatches: typeof applyPatches;\n sync: typeof sync;\n acceptSync: typeof acceptSync;\n} = {\n subscribePatches,\n applyPatches,\n sync,\n acceptSync,\n};\n"],"mappings":";;;;AAGA,SAAS,iBAAoB,QAAW,OAAiB;CACvD,IAAI,MAAM,OAAO,UACf,OAAOA,0BAAO,QAAQ,MAAM,IAAW;CAGzC,OAAOC,uBAAI,QAAQ,MAAM,MAAa,MAAM,KAAK;AACnD;AAEA,SAAgBC,eAAgB,QAAW,GAAG,SAAqB;CACjE,KAAK,MAAM,SAAS,SAClB,SAAS,iBAAiB,QAAQ,KAAK;CAGzC,OAAO;AACT;;;;ACfA,IAAM,WAAN,MAAe;;kCACsB,IAAI,IAAI;gBAClC;;AACX;AAEA,IAAa,OAAb,MAAkB;;cACC,IAAI,SAAS;;CAE9B,IAAI,MAAuB;EACzB,IAAI,OAAO,KAAK;EAChB,KAAK,MAAM,OAAO,MAAM;GACtB,IAAI,OAAO,KAAK,SAAS,IAAI,GAAG;GAChC,IAAI,CAAC,MAAM,KAAK,SAAS,IAAI,KAAM,OAAO,IAAI,SAAS,CAAE;GACzD,OAAO;EACT;EACA,KAAK,SAAS;CAChB;CAEA,WAAW,MAA0B;EACnC,IAAI,OAAO,KAAK;EAChB,KAAK,MAAM,O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MAAM,MAAM;GAAC;GAAS;GAAU;GAAQ;EAAe,CAAC;CACnE,GAAG,OAAO;AACZ;AAIA,SAAgB,aAEd,GAAG,SACG;CACN,KAAK,KAAK,UAAUC,eAAc,OAAO,GAAI,QAAQ,KAAK,CAAa,CAAC;AAC1E;AAEA,SAAgB,KAEd,UACA,SACkB;CAClB,MAAM,WACJ,OAAO,SAAS,aAAa,YAAY,UAAU,QAAQ,WACvD,EAAE,GAAG,QAAQ,SAAS,IACtB,SAAS,aAAa,SACpB,EAAE,MAAM,QAAQ,SAAS,IACzB;CAER,IAAI,UACF,SAAS,iBAAiB;CAG5B,OAAO,iBAAiB,MAItB,MAAM,EACL,SAAS,GAAG,SAAS,oBAAoB;EACxC,MAAM,OAAO,IAAI,KAAK;EAEtB,UAAU,CAAC,GAAG,OAAO,EAClB,QAAQ,EACR,QAAQ,UAAU;GACjB,IAAI,KAAK,WAAW,MAAM,IAAI,GAC5B,OAAO;GAGT,KAAK,IAAI,MAAM,IAAI;GACnB,OAAO;EACT,CAAC,EACA,QAAQ;EAEX,SAAS;GACP,aAAa;GACb,WAAW;GACX,SAASC,oCAAe,OAAO;EACjC,CAAC;CACH,GACA;EAAE,GAAG;EAAS;EAAU,QAAQ;CAAK,CACvC,CAAC;AACH;AAEA,SAAgB,WAA8B,SAA4B;CACxE,IAAI,QAAQ,eAAe,QAAQ,gBAAgB,KAAK,SACtD,MAAM,IAAI,MACR,6BAA6B,KAAK,QAAQ,gBAAgB,QAAQ,aACpE;CAGF,MAAM,UAAUC,sCAAiB,QAAQ,OAAO;CAEhD,KAAK,UAAU,QAAQ;CACvB,aAAa,MAA+B,MAAM,OAAO;AAC3D;AAEA,MAAa,eAKT;CACF;CACA;CACA;CACA;AACF"}
@@ -1,12 +1,12 @@
1
- import { a as set, i as remove } from "./propAccess-BxCKNeOj.js";
2
- import { a as diff, r as toExtendedJson, t as fromExtendedJson } from "./extendedJson-DA3RQ_ly.js";
1
+ import { a as set, i as remove } from "./propAccess-CsUaG5V_.js";
2
+ import { a as diff, r as toExtendedJson, t as fromExtendedJson } from "./extendedJson-BOmrkRrD.js";
3
3
 
4
4
  //#region src/lib/applyPatches.ts
5
5
  function applySinglePatch(target, patch) {
6
6
  if (patch.op === "remove") return remove(target, patch.path);
7
7
  return set(target, patch.path, patch.value);
8
8
  }
9
- function applyPatches(target, ...patches) {
9
+ function applyPatches$1(target, ...patches) {
10
10
  for (const patch of patches) target = applySinglePatch(target, patch);
11
11
  return target;
12
12
  }
@@ -90,8 +90,8 @@ function subscribePatches(listener, options = {}) {
90
90
  ]);
91
91
  }, options);
92
92
  }
93
- function applyPatches$1(...patches) {
94
- this.set((value) => applyPatches(value, ...patches.flat()));
93
+ function applyPatches(...patches) {
94
+ this.set((value) => applyPatches$1(value, ...patches.flat()));
95
95
  }
96
96
  function sync(listener, options) {
97
97
  const debounce = typeof options?.debounce === "object" && "wait" in options.debounce ? { ...options.debounce } : options?.debounce !== void 0 ? { wait: options.debounce } : void 0;
@@ -118,15 +118,15 @@ function acceptSync(message) {
118
118
  if (message.fromVersion && message.fromVersion !== this.version) throw new Error(`version mismatch! version=${this.version}, fromVersion=${message.fromVersion}`);
119
119
  const patches = fromExtendedJson(message.patches);
120
120
  this.version = message.toVersion;
121
- applyPatches$1.apply(this, patches);
121
+ applyPatches.apply(this, patches);
122
122
  }
123
123
  const patchMethods = {
124
124
  subscribePatches,
125
- applyPatches: applyPatches$1,
125
+ applyPatches,
126
126
  sync,
127
127
  acceptSync
128
128
  };
129
129
 
130
130
  //#endregion
131
- export { subscribePatches as n, applyPatches as r, patchMethods as t };
132
- //# sourceMappingURL=patchMethods-Cui462lc.js.map
131
+ export { subscribePatches as n, applyPatches$1 as r, patchMethods as t };
132
+ //# sourceMappingURL=patchMethods-D3cdG80W.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"patchMethods-D3cdG80W.js","names":["applyPatches","_applyPatches"],"sources":["../src/lib/applyPatches.ts","../src/lib/trie.ts","../src/patches/patchMethods.ts"],"sourcesContent":["import type { Patch } from './diff';\nimport { remove, set } from './propAccess';\n\nfunction applySinglePatch<T>(target: T, patch: Patch): T {\n if (patch.op === 'remove') {\n return remove(target, patch.path as any);\n }\n\n return set(target, patch.path as any, patch.value);\n}\n\nexport function applyPatches<T>(target: T, ...patches: Patch[]): T {\n for (const patch of patches) {\n target = applySinglePatch(target, patch);\n }\n\n return target;\n}\n","import type { KeyType } from '@lib/path';\n\nclass TrieNode {\n children: Map<KeyType, TrieNode> = new Map();\n isLeaf = false;\n}\n\nexport class Trie {\n root: TrieNode = new TrieNode();\n\n add(path: KeyType[]): void {\n let node = this.root;\n for (const key of path) {\n let next = node.children.get(key);\n if (!next) node.children.set(key, (next = new TrieNode()));\n node = next;\n }\n node.isLeaf = true;\n }\n\n hasSubPath(path: KeyType[]): boolean {\n let node = this.root;\n for (const key of path) {\n const next = node.children.get(key);\n if (!next) return false;\n node = next;\n }\n return node.isLeaf;\n }\n}\n","import type { Cancel, DisposableCancel, SubscribeOptions } from '@core/commonTypes';\nimport type { Store } from '@core/store';\nimport { applyPatches as _applyPatches } from '@lib/applyPatches';\nimport { diff, type DiffOptions, type Patch } from '@lib/diff';\nimport { fromExtendedJson, toExtendedJson } from '@lib/extendedJson';\nimport { Trie } from '@lib/trie';\n\nexport interface SyncMessage {\n fromVersion?: string;\n toVersion: string;\n patches: Patch[];\n}\n\nexport interface HistoryEntry extends SyncMessage {\n reversePatches: Patch[];\n}\n\ndeclare module '@core' {\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n interface Store<T> {\n __patches?: {\n value: T;\n version: string;\n history: HistoryEntry[];\n };\n }\n}\n\nexport interface SubscribePatchOptions extends SubscribeOptions, DiffOptions {\n /** @default false */\n runNow?: boolean;\n /** try to start from a specific version and only receive patches after that.\n * If the id is not found, it will start from the beginning */\n startAt?: string;\n}\n\nexport type InteropPatch = Patch | { op: 'add' | 'replace' | 'remove'; value?: any };\n\nconst genId = () => Math.random().toString(36).slice(2);\n\nexport function subscribePatches<T>(\n this: Store<T>,\n listener: (\n this: { cancel: Cancel },\n patches: Patch[],\n reversePatches: Patch[],\n version: string,\n previousVersion: string | undefined,\n ) => void,\n options: SubscribePatchOptions = {},\n): DisposableCancel {\n const patches = (this.__patches ??= {\n value: this.get(),\n version: genId(),\n history: [],\n });\n\n options = { ...options };\n options.runNow ??= false;\n let cursor = options.startAt ?? (options.runNow ? undefined : this.__patches.version);\n\n return this.subscribe(function (value) {\n if (patches.value !== value) {\n const result = diff(patches.value, value, options);\n patches.value = value;\n\n if (result[0].length > 0) {\n const newVersion = genId();\n\n patches.history = patches.history\n .concat({\n fromVersion: patches.version,\n toVersion: newVersion,\n patches: result[0],\n reversePatches: result[1],\n })\n .slice(-1000);\n\n patches.version = newVersion;\n }\n }\n\n if (cursor === patches.version) return;\n const index = patches.history.findIndex((h) => h.fromVersion === cursor);\n let forward, backward, previousVersion;\n\n if (index === -1) {\n [forward, backward] = diff(undefined, value, options);\n previousVersion = undefined;\n } else {\n forward = patches.history.slice(index).flatMap((h) => h.patches);\n backward = patches.history.slice(index).flatMap((h) => h.reversePatches);\n previousVersion = cursor;\n }\n\n cursor = patches.version;\n listener.apply(this, [forward, backward, cursor, previousVersion]);\n }, options);\n}\n\nexport function applyPatches<T>(this: Store<T>, patches: InteropPatch[]): void;\nexport function applyPatches<T>(this: Store<T>, ...patches: InteropPatch[]): void;\nexport function applyPatches<T>(\n this: Store<T>,\n ...patches: (InteropPatch | InteropPatch[])[]\n): void {\n this.set((value) => _applyPatches(value, ...(patches.flat() as Patch[])));\n}\n\nexport function sync<T>(\n this: Store<T>,\n listener: (syncMessage: SyncMessage) => void,\n options?: Omit<SubscribePatchOptions, 'runNow'>,\n): DisposableCancel {\n const debounce =\n typeof options?.debounce === 'object' && 'wait' in options.debounce\n ? { ...options.debounce }\n : options?.debounce !== undefined\n ? { wait: options.debounce }\n : undefined;\n\n if (debounce) {\n debounce.waitOnRunNow ??= false;\n }\n\n return subscribePatches.apply<\n Store<T>,\n Parameters<typeof subscribePatches<T>>,\n ReturnType<typeof subscribePatches<T>>\n >(this, [\n (patches, _, version, previousVersion) => {\n const trie = new Trie();\n\n patches = [...patches]\n .reverse()\n .filter((patch) => {\n if (trie.hasSubPath(patch.path)) {\n return false;\n }\n\n trie.add(patch.path);\n return true;\n })\n .reverse();\n\n listener({\n fromVersion: previousVersion,\n toVersion: version,\n patches: toExtendedJson(patches) as Patch[],\n });\n },\n { ...options, debounce, runNow: true },\n ]);\n}\n\nexport function acceptSync<T>(this: Store<T>, message: SyncMessage): void {\n if (message.fromVersion && message.fromVersion !== this.version) {\n throw new Error(\n `version mismatch! version=${this.version}, fromVersion=${message.fromVersion}`,\n );\n }\n\n const patches = fromExtendedJson(message.patches) as Patch[];\n\n this.version = message.toVersion;\n applyPatches.apply<Store<T>, Patch[], void>(this, patches);\n}\n\nexport const patchMethods: {\n subscribePatches: typeof subscribePatches;\n applyPatches: typeof applyPatches;\n sync: typeof sync;\n acceptSync: typeof acceptSync;\n} = {\n subscribePatches,\n applyPatches,\n sync,\n acceptSync,\n};\n"],"mappings":";;;;AAGA,SAAS,iBAAoB,QAAW,OAAiB;CACvD,IAAI,MAAM,OAAO,UACf,OAAO,OAAO,QAAQ,MAAM,IAAW;CAGzC,OAAO,IAAI,QAAQ,MAAM,MAAa,MAAM,KAAK;AACnD;AAEA,SAAgBA,eAAgB,QAAW,GAAG,SAAqB;CACjE,KAAK,MAAM,SAAS,SAClB,SAAS,iBAAiB,QAAQ,KAAK;CAGzC,OAAO;AACT;;;;ACfA,IAAM,WAAN,MAAe;;kCACsB,IAAI,IAAI;gBAClC;;AACX;AAEA,IAAa,OAAb,MAAkB;;cACC,IAAI,SAAS;;CAE9B,IAAI,MAAuB;EACzB,IAAI,OAAO,KAAK;EAChB,KAAK,MAAM,OAAO,MAAM;GACtB,IAAI,OAAO,KAAK,SAAS,IAAI,GAAG;GAChC,IAAI,CAAC,MAAM,KAAK,SAAS,IAAI,KAAM,OAAO,IAAI,SAAS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, y as DisposableCancel } from "./store-21GsOOLS.cjs";
2
- import { n as Patch, t as DiffOptions } from "./diff-Bcr0h7-x.cjs";
1
+ import { I as DisposableCancel, N as Cancel, V as SubscribeOptions, r as Store } from "./store-dThvqc0k.cjs";
2
+ import { n as Patch, t as DiffOptions } from "./diff-BzE2cDaU.cjs";
3
3
 
4
4
  //#region src/patches/patchMethods.d.ts
5
5
  interface SyncMessage {
@@ -10,7 +10,7 @@ interface SyncMessage {
10
10
  interface HistoryEntry extends SyncMessage {
11
11
  reversePatches: Patch[];
12
12
  }
13
- declare module ".." {
13
+ declare module "@core" {
14
14
  interface Store<T> {
15
15
  __patches?: {
16
16
  value: T;
@@ -45,4 +45,4 @@ declare const patchMethods: {
45
45
  };
46
46
  //#endregion
47
47
  export { SyncMessage as n, patchMethods as r, SubscribePatchOptions as t };
48
- //# sourceMappingURL=patchMethods-Cyb6MEOG.d.cts.map
48
+ //# sourceMappingURL=patchMethods-R3f7HxTy.d.cts.map
@@ -1,3 +1,4 @@
1
- const require_patchMethods = require('../patchMethods-CZje49Dk.cjs');
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+ const require_patchMethods = require('../patchMethods-BBQDDqwe.cjs');
2
3
 
3
4
  exports.patchMethods = require_patchMethods.patchMethods;
@@ -1,2 +1,2 @@
1
- import { n as SyncMessage, r as patchMethods, t as SubscribePatchOptions } from "../patchMethods-Cyb6MEOG.cjs";
1
+ import { n as SyncMessage, r as patchMethods, t as SubscribePatchOptions } from "../patchMethods-R3f7HxTy.cjs";
2
2
  export { type SubscribePatchOptions, type SyncMessage, patchMethods };
@@ -1,2 +1,2 @@
1
- import { n as SyncMessage, r as patchMethods, t as SubscribePatchOptions } from "../patchMethods-C21iQqML.js";
1
+ import { n as SyncMessage, r as patchMethods, t as SubscribePatchOptions } from "../patchMethods--ekCkYUF.js";
2
2
  export { type SubscribePatchOptions, type SyncMessage, patchMethods };
@@ -1,3 +1,3 @@
1
- import { t as patchMethods } from "../patchMethods-Cui462lc.js";
1
+ import { t as patchMethods } from "../patchMethods-D3cdG80W.js";
2
2
 
3
3
  export { patchMethods };
@@ -1,5 +1,5 @@
1
- const require_store = require('../store-CPqOf4y5.cjs');
2
- const require_patchMethods = require('../patchMethods-CZje49Dk.cjs');
1
+ const require_store = require('../store-fmAYV5hy.cjs');
2
+ const require_patchMethods = require('../patchMethods-BBQDDqwe.cjs');
3
3
 
4
4
  //#region src/patches/register.ts
5
5
  Object.assign(require_store.Store.prototype, require_patchMethods.patchMethods);
@@ -1 +1 @@
1
- {"version":3,"file":"register.cjs","names":["Store","patchMethods","autobind"],"sources":["../../src/patches/register.ts"],"sourcesContent":["import { Store } from '@core';\nimport { autobind } from '@lib/autobind';\nimport { patchMethods } from './patchMethods';\n\ntype PatchMethods = typeof patchMethods;\n\ndeclare module '..' {\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n interface Store<T> extends PatchMethods {}\n}\n\nObject.assign(Store.prototype, patchMethods);\nautobind(Store);\n"],"mappings":";;;;AAWA,OAAO,OAAOA,oBAAM,WAAWC,kCAAa;AAC5CC,uBAASF,oBAAM"}
1
+ {"version":3,"file":"register.cjs","names":["Store","patchMethods","autobind"],"sources":["../../src/patches/register.ts"],"sourcesContent":["import { patchMethods } from './patchMethods';\nimport { Store } from '@core';\nimport { autobind } from '@lib/autobind';\n\ntype PatchMethods = typeof patchMethods;\n\ndeclare module '@core' {\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n interface Store<T> extends PatchMethods {}\n}\n\nObject.assign(Store.prototype, patchMethods);\nautobind(Store);\n"],"mappings":";;;;AAWA,OAAO,OAAOA,oBAAM,WAAWC,iCAAY;AAC3CC,uBAASF,mBAAK"}
@@ -1,8 +1,8 @@
1
- import { r as patchMethods } from "../patchMethods-Cyb6MEOG.cjs";
1
+ import { r as patchMethods } from "../patchMethods-R3f7HxTy.cjs";
2
2
 
3
3
  //#region src/patches/register.d.ts
4
4
  type PatchMethods = typeof patchMethods;
5
- declare module ".." {
5
+ declare module "@core" {
6
6
  interface Store<T> extends PatchMethods {}
7
7
  }
8
8
  //# sourceMappingURL=register.d.cts.map
@@ -1,8 +1,8 @@
1
- import { r as patchMethods } from "../patchMethods-C21iQqML.js";
1
+ import { r as patchMethods } from "../patchMethods--ekCkYUF.js";
2
2
 
3
3
  //#region src/patches/register.d.ts
4
4
  type PatchMethods = typeof patchMethods;
5
- declare module ".." {
5
+ declare module "@core" {
6
6
  interface Store<T> extends PatchMethods {}
7
7
  }
8
8
  //# sourceMappingURL=register.d.ts.map
@@ -1,5 +1,5 @@
1
- import { h as autobind, t as Store } from "../store-D4q5zD7q.js";
2
- import { t as patchMethods } from "../patchMethods-Cui462lc.js";
1
+ import { h as autobind, t as Store } from "../store-BmlnyYal.js";
2
+ import { t as patchMethods } from "../patchMethods-D3cdG80W.js";
3
3
 
4
4
  //#region src/patches/register.ts
5
5
  Object.assign(Store.prototype, patchMethods);
@@ -1 +1 @@
1
- {"version":3,"file":"register.js","names":[],"sources":["../../src/patches/register.ts"],"sourcesContent":["import { Store } from '@core';\nimport { autobind } from '@lib/autobind';\nimport { patchMethods } from './patchMethods';\n\ntype PatchMethods = typeof patchMethods;\n\ndeclare module '..' {\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n interface Store<T> extends PatchMethods {}\n}\n\nObject.assign(Store.prototype, patchMethods);\nautobind(Store);\n"],"mappings":";;;;AAWA,OAAO,OAAO,MAAM,WAAW,aAAa;AAC5C,SAAS,MAAM"}
1
+ {"version":3,"file":"register.js","names":[],"sources":["../../src/patches/register.ts"],"sourcesContent":["import { patchMethods } from './patchMethods';\nimport { Store } from '@core';\nimport { autobind } from '@lib/autobind';\n\ntype PatchMethods = typeof patchMethods;\n\ndeclare module '@core' {\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n interface Store<T> extends PatchMethods {}\n}\n\nObject.assign(Store.prototype, patchMethods);\nautobind(Store);\n"],"mappings":";;;;AAWA,OAAO,OAAO,MAAM,WAAW,YAAY;AAC3C,SAAS,KAAK"}
@@ -11,4 +11,4 @@ Object.defineProperty(exports, 'isAnyPath', {
11
11
  return isAnyPath;
12
12
  }
13
13
  });
14
- //# sourceMappingURL=path-Il5r4PV4.cjs.map
14
+ //# sourceMappingURL=path-B9-Z0127.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"path-Il5r4PV4.cjs","names":[],"sources":["../src/lib/path.ts"],"sourcesContent":["import type {\n ArrayToStringPath,\n Array_,\n IsAny,\n IsNever,\n Object_,\n OptionalPropertyOf,\n StringToArrayPath,\n StringToNumber,\n} from './typeHelpers';\n\nexport type KeyType = string | number | symbol;\n\nexport type AnyPath = string | readonly KeyType[];\n\nexport type GetKeys<T extends Object_ | Array_> = T extends Array_\n ? T extends readonly [] // special case empty tuple => no keys\n ? never\n : '0' extends keyof T // any tuple with at least one element\n ? StringToNumber<keyof T>\n : number // other array\n : keyof T;\n\nexport type _PathAsArray<T, Optional, MaxDepth, Depth extends 1[]> =\n | (Optional extends false ? readonly [] : never)\n | (true extends IsAny<T>\n ? readonly KeyType[]\n : T extends never\n ? never\n : T extends Object_\n ? Depth['length'] extends MaxDepth\n ? readonly string[]\n : T extends Map<infer K extends KeyType, infer V>\n ? readonly [K] | readonly [K, ..._PathAsArray<V, Optional, MaxDepth, [...Depth, 1]>]\n : T extends Set<any>\n ? readonly [number]\n : {\n [K in GetKeys<T>]:\n | (Optional extends true\n ? K extends OptionalPropertyOf<T>\n ? readonly [K]\n : never\n : readonly [K])\n | readonly [K, ..._PathAsArray<T[K], Optional, MaxDepth, [...Depth, 1]>];\n }[GetKeys<T>]\n : never);\n\nexport type PathAsArray<\n T,\n Optional extends boolean = false,\n MaxDepth extends number = 5,\n> = _PathAsArray<T, Optional, MaxDepth, []>;\n\nexport type PathAsString<\n T,\n Optional extends boolean = false,\n MaxDepth extends number = 5,\n> = ArrayToStringPath<PathAsArray<T, Optional, MaxDepth>>;\n\nexport type Path<T, Optional extends boolean = false, MaxDepth extends number = 5> =\n | PathAsString<T, Optional, MaxDepth>\n | PathAsArray<T, Optional, MaxDepth>;\n\nexport type Value<T, P> = P extends readonly []\n ? T\n : true extends IsAny<T> | IsAny<P>\n ? any\n : true extends IsNever<T> | IsNever<P>\n ? never\n : P extends string\n ? Value<T, StringToArrayPath<P>>\n : P extends readonly [infer First extends KeyType, ...infer Rest extends readonly KeyType[]]\n ? T extends Map<any, infer V> | Set<infer V>\n ? Value<V, Rest> | undefined\n : T extends Array_\n ? any[] extends T\n ? Value<T[First & keyof T], Rest> | undefined\n : Value<T[First & keyof T], Rest>\n : T extends Object_\n ? Record<any, any> extends T\n ? Value<T[First], Rest> | undefined\n : Value<T[First], Rest>\n : never\n : never;\n\nexport type _WildcardPathAsArray<T, MaxDepth, Depth extends 1[]> =\n | []\n | (0 extends 1 & T\n ? KeyType[]\n : T extends never\n ? never\n : T extends Object_\n ? Depth['length'] extends MaxDepth\n ? string[]\n : T extends Map<infer K extends KeyType, infer V>\n ? ['*'] | [K] | [K, ..._WildcardPathAsArray<V, MaxDepth, [...Depth, 1]>]\n : T extends Set<any>\n ? ['*'] | [number]\n : Record<string, any> extends T\n ? ['*'] | ['*', ..._WildcardPathAsArray<T[string], MaxDepth, [...Depth, 1]>]\n : {\n [K in GetKeys<T>]:\n | ['*']\n | [\n '*',\n ..._WildcardPathAsArray<\n T[T extends readonly any[] ? number : keyof T],\n MaxDepth,\n [...Depth, 1]\n >,\n ]\n | [K]\n | [K, ..._WildcardPathAsArray<T[K], MaxDepth, [...Depth, 1]>];\n }[GetKeys<T>]\n : never);\n\nexport type WildcardPathAsArray<T, MaxDepth extends number = 5> = _WildcardPathAsArray<\n T,\n MaxDepth,\n []\n>;\nexport type WildcardPathAsString<T, MaxDepth extends number = 5> = ArrayToStringPath<\n _WildcardPathAsArray<T, MaxDepth, []>\n>;\nexport type WildcardPath<T, MaxDepth extends number = 5> =\n | WildcardPathAsString<T, MaxDepth>\n | WildcardPathAsArray<T, MaxDepth>;\n\nexport type WildcardValue<T, P> = true extends IsAny<T> | IsAny<P>\n ? any\n : true extends IsNever<T> | IsNever<P>\n ? never\n : P extends string\n ? WildcardValue<T, StringToArrayPath<P>>\n : P extends readonly [infer First extends KeyType, ...infer Rest extends KeyType[]]\n ? T extends Map<any, infer V> | Set<infer V>\n ? WildcardValue<V, Rest> | (First extends '*' ? never : undefined)\n : T extends Array_\n ? First extends '*'\n ? WildcardValue<T[number], Rest>\n : any[] extends T\n ? WildcardValue<T[First & keyof T], Rest> | undefined\n : First extends keyof T\n ? WildcardValue<T[First], Rest>\n : undefined\n : T extends Object_\n ? First extends '*'\n ? WildcardValue<T[keyof T], Rest>\n : Record<any, any> extends T\n ? WildcardValue<T[First], Rest> | undefined\n : WildcardValue<T[First], Rest>\n : never\n : T;\n\nexport type WildcardMatch<S, W> = S extends string\n ? WildcardMatch<StringToArrayPath<S>, W>\n : W extends string\n ? WildcardMatch<S, StringToArrayPath<W>>\n : [S, W] extends [readonly [], readonly []]\n ? true\n : [S, W] extends [\n readonly [infer SFirst, ...infer SRest],\n readonly [infer WFirst, ...infer WRest],\n ]\n ? [WFirst, WRest['length']] extends ['*' | SFirst, SRest['length']]\n ? WildcardMatch<SRest, WRest>\n : false\n : false;\n\nexport type Join<A extends string | number, B extends string | number> = A extends ''\n ? B\n : B extends ''\n ? A\n : `${A}.${B}`;\n\ntype _SettablePathAsArray<T, MaxDepth, Depth extends 1[]> =\n | readonly []\n | (true extends IsAny<T>\n ? readonly KeyType[]\n : undefined extends T\n ? T extends Map<any, any> | Set<any>\n ? never\n : T extends Object_\n ? {\n [K in GetKeys<T>]: Partial<T> extends Omit<T, K>\n ?\n | readonly [K]\n | readonly [K, ..._SettablePathAsArray<T[K], MaxDepth, [...Depth, 1]>]\n : readonly [];\n }[GetKeys<T>]\n : never\n : T extends never\n ? never\n : T extends Object_\n ? Depth['length'] extends MaxDepth\n ? readonly string[]\n : T extends Map<infer K extends KeyType, infer V>\n ? readonly [K] | readonly [K, ..._SettablePathAsArray<V, MaxDepth, [...Depth, 1]>]\n : T extends Set<any>\n ? readonly [number]\n : {\n [K in GetKeys<T>]:\n | readonly [K]\n | readonly [K, ..._SettablePathAsArray<T[K], MaxDepth, [...Depth, 1]>];\n }[GetKeys<T>]\n : never);\n\nexport type SettablePathAsArray<T, MaxDepth extends number = 5> = _SettablePathAsArray<\n T,\n MaxDepth,\n []\n>;\nexport type SettablePathAsString<T, MaxDepth extends number = 5> = ArrayToStringPath<\n SettablePathAsArray<T, MaxDepth>\n>;\n\nexport type SettablePath<T, MaxDepth extends number = 5> =\n | SettablePathAsString<T, MaxDepth>\n | SettablePathAsArray<T, MaxDepth>;\n\nexport type SettableValue<T, P> = P extends readonly []\n ? T\n : true extends IsAny<T> | IsAny<P>\n ? any\n : true extends IsNever<T> | IsNever<P>\n ? never\n : P extends string\n ? SettableValue<T, StringToArrayPath<P>>\n : P extends readonly [infer First extends KeyType, ...infer Rest extends readonly KeyType[]]\n ? T extends Map<any, infer V> | Set<infer V>\n ? SettableValue<V, Rest>\n : T extends Array_\n ? SettableValue<T[First & keyof T], Rest>\n : T extends Object_\n ? SettableValue<T[First], Rest>\n : never\n : never;\n\nexport function isAnyPath(path: any): path is AnyPath {\n return typeof path === 'string' || Array.isArray(path);\n}\n"],"mappings":";;AA8OA,SAAgB,UAAU,MAA4B;AACpD,QAAO,OAAO,SAAS,YAAY,MAAM,QAAQ,KAAK"}
1
+ {"version":3,"file":"path-B9-Z0127.cjs","names":[],"sources":["../src/lib/path.ts"],"sourcesContent":["import type {\n ArrayToStringPath,\n Array_,\n IsAny,\n IsNever,\n Object_,\n OptionalPropertyOf,\n StringToArrayPath,\n StringToNumber,\n} from './typeHelpers';\n\nexport type KeyType = string | number | symbol;\n\nexport type AnyPath = string | readonly KeyType[];\n\nexport type GetKeys<T extends Object_ | Array_> = T extends Array_\n ? T extends readonly [] // special case empty tuple => no keys\n ? never\n : '0' extends keyof T // any tuple with at least one element\n ? StringToNumber<keyof T>\n : number // other array\n : keyof T;\n\nexport type _PathAsArray<T, Optional, MaxDepth, Depth extends 1[]> =\n | (Optional extends false ? readonly [] : never)\n | (true extends IsAny<T>\n ? readonly KeyType[]\n : T extends never\n ? never\n : T extends Object_\n ? Depth['length'] extends MaxDepth\n ? readonly string[]\n : T extends Map<infer K extends KeyType, infer V>\n ? readonly [K] | readonly [K, ..._PathAsArray<V, Optional, MaxDepth, [...Depth, 1]>]\n : T extends Set<any>\n ? readonly [number]\n : {\n [K in GetKeys<T>]:\n | (Optional extends true\n ? K extends OptionalPropertyOf<T>\n ? readonly [K]\n : never\n : readonly [K])\n | readonly [K, ..._PathAsArray<T[K], Optional, MaxDepth, [...Depth, 1]>];\n }[GetKeys<T>]\n : never);\n\nexport type PathAsArray<\n T,\n Optional extends boolean = false,\n MaxDepth extends number = 5,\n> = _PathAsArray<T, Optional, MaxDepth, []>;\n\nexport type PathAsString<\n T,\n Optional extends boolean = false,\n MaxDepth extends number = 5,\n> = ArrayToStringPath<PathAsArray<T, Optional, MaxDepth>>;\n\nexport type Path<T, Optional extends boolean = false, MaxDepth extends number = 5> =\n | PathAsString<T, Optional, MaxDepth>\n | PathAsArray<T, Optional, MaxDepth>;\n\nexport type Value<T, P> = P extends readonly []\n ? T\n : true extends IsAny<T> | IsAny<P>\n ? any\n : true extends IsNever<T> | IsNever<P>\n ? never\n : P extends string\n ? Value<T, StringToArrayPath<P>>\n : P extends readonly [infer First extends KeyType, ...infer Rest extends readonly KeyType[]]\n ? T extends Map<any, infer V> | Set<infer V>\n ? Value<V, Rest> | undefined\n : T extends Array_\n ? any[] extends T\n ? Value<T[First & keyof T], Rest> | undefined\n : Value<T[First & keyof T], Rest>\n : T extends Object_\n ? Record<any, any> extends T\n ? Value<T[First], Rest> | undefined\n : Value<T[First], Rest>\n : never\n : never;\n\nexport type _WildcardPathAsArray<T, MaxDepth, Depth extends 1[]> =\n | []\n | (0 extends 1 & T\n ? KeyType[]\n : T extends never\n ? never\n : T extends Object_\n ? Depth['length'] extends MaxDepth\n ? string[]\n : T extends Map<infer K extends KeyType, infer V>\n ? ['*'] | [K] | [K, ..._WildcardPathAsArray<V, MaxDepth, [...Depth, 1]>]\n : T extends Set<any>\n ? ['*'] | [number]\n : Record<string, any> extends T\n ? ['*'] | ['*', ..._WildcardPathAsArray<T[string], MaxDepth, [...Depth, 1]>]\n : {\n [K in GetKeys<T>]:\n | ['*']\n | [\n '*',\n ..._WildcardPathAsArray<\n T[T extends readonly any[] ? number : keyof T],\n MaxDepth,\n [...Depth, 1]\n >,\n ]\n | [K]\n | [K, ..._WildcardPathAsArray<T[K], MaxDepth, [...Depth, 1]>];\n }[GetKeys<T>]\n : never);\n\nexport type WildcardPathAsArray<T, MaxDepth extends number = 5> = _WildcardPathAsArray<\n T,\n MaxDepth,\n []\n>;\nexport type WildcardPathAsString<T, MaxDepth extends number = 5> = ArrayToStringPath<\n _WildcardPathAsArray<T, MaxDepth, []>\n>;\nexport type WildcardPath<T, MaxDepth extends number = 5> =\n | WildcardPathAsString<T, MaxDepth>\n | WildcardPathAsArray<T, MaxDepth>;\n\nexport type WildcardValue<T, P> = true extends IsAny<T> | IsAny<P>\n ? any\n : true extends IsNever<T> | IsNever<P>\n ? never\n : P extends string\n ? WildcardValue<T, StringToArrayPath<P>>\n : P extends readonly [infer First extends KeyType, ...infer Rest extends KeyType[]]\n ? T extends Map<any, infer V> | Set<infer V>\n ? WildcardValue<V, Rest> | (First extends '*' ? never : undefined)\n : T extends Array_\n ? First extends '*'\n ? WildcardValue<T[number], Rest>\n : any[] extends T\n ? WildcardValue<T[First & keyof T], Rest> | undefined\n : First extends keyof T\n ? WildcardValue<T[First], Rest>\n : undefined\n : T extends Object_\n ? First extends '*'\n ? WildcardValue<T[keyof T], Rest>\n : Record<any, any> extends T\n ? WildcardValue<T[First], Rest> | undefined\n : WildcardValue<T[First], Rest>\n : never\n : T;\n\nexport type WildcardMatch<S, W> = S extends string\n ? WildcardMatch<StringToArrayPath<S>, W>\n : W extends string\n ? WildcardMatch<S, StringToArrayPath<W>>\n : [S, W] extends [readonly [], readonly []]\n ? true\n : [S, W] extends [\n readonly [infer SFirst, ...infer SRest],\n readonly [infer WFirst, ...infer WRest],\n ]\n ? [WFirst, WRest['length']] extends ['*' | SFirst, SRest['length']]\n ? WildcardMatch<SRest, WRest>\n : false\n : false;\n\nexport type Join<A extends string | number, B extends string | number> = A extends ''\n ? B\n : B extends ''\n ? A\n : `${A}.${B}`;\n\ntype _SettablePathAsArray<T, MaxDepth, Depth extends 1[]> =\n | readonly []\n | (true extends IsAny<T>\n ? readonly KeyType[]\n : undefined extends T\n ? T extends Map<any, any> | Set<any>\n ? never\n : T extends Object_\n ? {\n [K in GetKeys<T>]: Partial<T> extends Omit<T, K>\n ?\n | readonly [K]\n | readonly [K, ..._SettablePathAsArray<T[K], MaxDepth, [...Depth, 1]>]\n : readonly [];\n }[GetKeys<T>]\n : never\n : T extends never\n ? never\n : T extends Object_\n ? Depth['length'] extends MaxDepth\n ? readonly string[]\n : T extends Map<infer K extends KeyType, infer V>\n ? readonly [K] | readonly [K, ..._SettablePathAsArray<V, MaxDepth, [...Depth, 1]>]\n : T extends Set<any>\n ? readonly [number]\n : {\n [K in GetKeys<T>]:\n | readonly [K]\n | readonly [K, ..._SettablePathAsArray<T[K], MaxDepth, [...Depth, 1]>];\n }[GetKeys<T>]\n : never);\n\nexport type SettablePathAsArray<T, MaxDepth extends number = 5> = _SettablePathAsArray<\n T,\n MaxDepth,\n []\n>;\nexport type SettablePathAsString<T, MaxDepth extends number = 5> = ArrayToStringPath<\n SettablePathAsArray<T, MaxDepth>\n>;\n\nexport type SettablePath<T, MaxDepth extends number = 5> =\n | SettablePathAsString<T, MaxDepth>\n | SettablePathAsArray<T, MaxDepth>;\n\nexport type SettableValue<T, P> = P extends readonly []\n ? T\n : true extends IsAny<T> | IsAny<P>\n ? any\n : true extends IsNever<T> | IsNever<P>\n ? never\n : P extends string\n ? SettableValue<T, StringToArrayPath<P>>\n : P extends readonly [infer First extends KeyType, ...infer Rest extends readonly KeyType[]]\n ? T extends Map<any, infer V> | Set<infer V>\n ? SettableValue<V, Rest>\n : T extends Array_\n ? SettableValue<T[First & keyof T], Rest>\n : T extends Object_\n ? SettableValue<T[First], Rest>\n : never\n : never;\n\nexport function isAnyPath(path: any): path is AnyPath {\n return typeof path === 'string' || Array.isArray(path);\n}\n"],"mappings":";;AA8OA,SAAgB,UAAU,MAA4B;CACpD,OAAO,OAAO,SAAS,YAAY,MAAM,QAAQ,IAAI;AACvD"}
@@ -5,4 +5,4 @@ function isAnyPath(path) {
5
5
 
6
6
  //#endregion
7
7
  export { isAnyPath as t };
8
- //# sourceMappingURL=path-CCEtQjMB.js.map
8
+ //# sourceMappingURL=path-C-5jTZu5.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"path-CCEtQjMB.js","names":[],"sources":["../src/lib/path.ts"],"sourcesContent":["import type {\n ArrayToStringPath,\n Array_,\n IsAny,\n IsNever,\n Object_,\n OptionalPropertyOf,\n StringToArrayPath,\n StringToNumber,\n} from './typeHelpers';\n\nexport type KeyType = string | number | symbol;\n\nexport type AnyPath = string | readonly KeyType[];\n\nexport type GetKeys<T extends Object_ | Array_> = T extends Array_\n ? T extends readonly [] // special case empty tuple => no keys\n ? never\n : '0' extends keyof T // any tuple with at least one element\n ? StringToNumber<keyof T>\n : number // other array\n : keyof T;\n\nexport type _PathAsArray<T, Optional, MaxDepth, Depth extends 1[]> =\n | (Optional extends false ? readonly [] : never)\n | (true extends IsAny<T>\n ? readonly KeyType[]\n : T extends never\n ? never\n : T extends Object_\n ? Depth['length'] extends MaxDepth\n ? readonly string[]\n : T extends Map<infer K extends KeyType, infer V>\n ? readonly [K] | readonly [K, ..._PathAsArray<V, Optional, MaxDepth, [...Depth, 1]>]\n : T extends Set<any>\n ? readonly [number]\n : {\n [K in GetKeys<T>]:\n | (Optional extends true\n ? K extends OptionalPropertyOf<T>\n ? readonly [K]\n : never\n : readonly [K])\n | readonly [K, ..._PathAsArray<T[K], Optional, MaxDepth, [...Depth, 1]>];\n }[GetKeys<T>]\n : never);\n\nexport type PathAsArray<\n T,\n Optional extends boolean = false,\n MaxDepth extends number = 5,\n> = _PathAsArray<T, Optional, MaxDepth, []>;\n\nexport type PathAsString<\n T,\n Optional extends boolean = false,\n MaxDepth extends number = 5,\n> = ArrayToStringPath<PathAsArray<T, Optional, MaxDepth>>;\n\nexport type Path<T, Optional extends boolean = false, MaxDepth extends number = 5> =\n | PathAsString<T, Optional, MaxDepth>\n | PathAsArray<T, Optional, MaxDepth>;\n\nexport type Value<T, P> = P extends readonly []\n ? T\n : true extends IsAny<T> | IsAny<P>\n ? any\n : true extends IsNever<T> | IsNever<P>\n ? never\n : P extends string\n ? Value<T, StringToArrayPath<P>>\n : P extends readonly [infer First extends KeyType, ...infer Rest extends readonly KeyType[]]\n ? T extends Map<any, infer V> | Set<infer V>\n ? Value<V, Rest> | undefined\n : T extends Array_\n ? any[] extends T\n ? Value<T[First & keyof T], Rest> | undefined\n : Value<T[First & keyof T], Rest>\n : T extends Object_\n ? Record<any, any> extends T\n ? Value<T[First], Rest> | undefined\n : Value<T[First], Rest>\n : never\n : never;\n\nexport type _WildcardPathAsArray<T, MaxDepth, Depth extends 1[]> =\n | []\n | (0 extends 1 & T\n ? KeyType[]\n : T extends never\n ? never\n : T extends Object_\n ? Depth['length'] extends MaxDepth\n ? string[]\n : T extends Map<infer K extends KeyType, infer V>\n ? ['*'] | [K] | [K, ..._WildcardPathAsArray<V, MaxDepth, [...Depth, 1]>]\n : T extends Set<any>\n ? ['*'] | [number]\n : Record<string, any> extends T\n ? ['*'] | ['*', ..._WildcardPathAsArray<T[string], MaxDepth, [...Depth, 1]>]\n : {\n [K in GetKeys<T>]:\n | ['*']\n | [\n '*',\n ..._WildcardPathAsArray<\n T[T extends readonly any[] ? number : keyof T],\n MaxDepth,\n [...Depth, 1]\n >,\n ]\n | [K]\n | [K, ..._WildcardPathAsArray<T[K], MaxDepth, [...Depth, 1]>];\n }[GetKeys<T>]\n : never);\n\nexport type WildcardPathAsArray<T, MaxDepth extends number = 5> = _WildcardPathAsArray<\n T,\n MaxDepth,\n []\n>;\nexport type WildcardPathAsString<T, MaxDepth extends number = 5> = ArrayToStringPath<\n _WildcardPathAsArray<T, MaxDepth, []>\n>;\nexport type WildcardPath<T, MaxDepth extends number = 5> =\n | WildcardPathAsString<T, MaxDepth>\n | WildcardPathAsArray<T, MaxDepth>;\n\nexport type WildcardValue<T, P> = true extends IsAny<T> | IsAny<P>\n ? any\n : true extends IsNever<T> | IsNever<P>\n ? never\n : P extends string\n ? WildcardValue<T, StringToArrayPath<P>>\n : P extends readonly [infer First extends KeyType, ...infer Rest extends KeyType[]]\n ? T extends Map<any, infer V> | Set<infer V>\n ? WildcardValue<V, Rest> | (First extends '*' ? never : undefined)\n : T extends Array_\n ? First extends '*'\n ? WildcardValue<T[number], Rest>\n : any[] extends T\n ? WildcardValue<T[First & keyof T], Rest> | undefined\n : First extends keyof T\n ? WildcardValue<T[First], Rest>\n : undefined\n : T extends Object_\n ? First extends '*'\n ? WildcardValue<T[keyof T], Rest>\n : Record<any, any> extends T\n ? WildcardValue<T[First], Rest> | undefined\n : WildcardValue<T[First], Rest>\n : never\n : T;\n\nexport type WildcardMatch<S, W> = S extends string\n ? WildcardMatch<StringToArrayPath<S>, W>\n : W extends string\n ? WildcardMatch<S, StringToArrayPath<W>>\n : [S, W] extends [readonly [], readonly []]\n ? true\n : [S, W] extends [\n readonly [infer SFirst, ...infer SRest],\n readonly [infer WFirst, ...infer WRest],\n ]\n ? [WFirst, WRest['length']] extends ['*' | SFirst, SRest['length']]\n ? WildcardMatch<SRest, WRest>\n : false\n : false;\n\nexport type Join<A extends string | number, B extends string | number> = A extends ''\n ? B\n : B extends ''\n ? A\n : `${A}.${B}`;\n\ntype _SettablePathAsArray<T, MaxDepth, Depth extends 1[]> =\n | readonly []\n | (true extends IsAny<T>\n ? readonly KeyType[]\n : undefined extends T\n ? T extends Map<any, any> | Set<any>\n ? never\n : T extends Object_\n ? {\n [K in GetKeys<T>]: Partial<T> extends Omit<T, K>\n ?\n | readonly [K]\n | readonly [K, ..._SettablePathAsArray<T[K], MaxDepth, [...Depth, 1]>]\n : readonly [];\n }[GetKeys<T>]\n : never\n : T extends never\n ? never\n : T extends Object_\n ? Depth['length'] extends MaxDepth\n ? readonly string[]\n : T extends Map<infer K extends KeyType, infer V>\n ? readonly [K] | readonly [K, ..._SettablePathAsArray<V, MaxDepth, [...Depth, 1]>]\n : T extends Set<any>\n ? readonly [number]\n : {\n [K in GetKeys<T>]:\n | readonly [K]\n | readonly [K, ..._SettablePathAsArray<T[K], MaxDepth, [...Depth, 1]>];\n }[GetKeys<T>]\n : never);\n\nexport type SettablePathAsArray<T, MaxDepth extends number = 5> = _SettablePathAsArray<\n T,\n MaxDepth,\n []\n>;\nexport type SettablePathAsString<T, MaxDepth extends number = 5> = ArrayToStringPath<\n SettablePathAsArray<T, MaxDepth>\n>;\n\nexport type SettablePath<T, MaxDepth extends number = 5> =\n | SettablePathAsString<T, MaxDepth>\n | SettablePathAsArray<T, MaxDepth>;\n\nexport type SettableValue<T, P> = P extends readonly []\n ? T\n : true extends IsAny<T> | IsAny<P>\n ? any\n : true extends IsNever<T> | IsNever<P>\n ? never\n : P extends string\n ? SettableValue<T, StringToArrayPath<P>>\n : P extends readonly [infer First extends KeyType, ...infer Rest extends readonly KeyType[]]\n ? T extends Map<any, infer V> | Set<infer V>\n ? SettableValue<V, Rest>\n : T extends Array_\n ? SettableValue<T[First & keyof T], Rest>\n : T extends Object_\n ? SettableValue<T[First], Rest>\n : never\n : never;\n\nexport function isAnyPath(path: any): path is AnyPath {\n return typeof path === 'string' || Array.isArray(path);\n}\n"],"mappings":";AA8OA,SAAgB,UAAU,MAA4B;AACpD,QAAO,OAAO,SAAS,YAAY,MAAM,QAAQ,KAAK"}
1
+ {"version":3,"file":"path-C-5jTZu5.js","names":[],"sources":["../src/lib/path.ts"],"sourcesContent":["import type {\n ArrayToStringPath,\n Array_,\n IsAny,\n IsNever,\n Object_,\n OptionalPropertyOf,\n StringToArrayPath,\n StringToNumber,\n} from './typeHelpers';\n\nexport type KeyType = string | number | symbol;\n\nexport type AnyPath = string | readonly KeyType[];\n\nexport type GetKeys<T extends Object_ | Array_> = T extends Array_\n ? T extends readonly [] // special case empty tuple => no keys\n ? never\n : '0' extends keyof T // any tuple with at least one element\n ? StringToNumber<keyof T>\n : number // other array\n : keyof T;\n\nexport type _PathAsArray<T, Optional, MaxDepth, Depth extends 1[]> =\n | (Optional extends false ? readonly [] : never)\n | (true extends IsAny<T>\n ? readonly KeyType[]\n : T extends never\n ? never\n : T extends Object_\n ? Depth['length'] extends MaxDepth\n ? readonly string[]\n : T extends Map<infer K extends KeyType, infer V>\n ? readonly [K] | readonly [K, ..._PathAsArray<V, Optional, MaxDepth, [...Depth, 1]>]\n : T extends Set<any>\n ? readonly [number]\n : {\n [K in GetKeys<T>]:\n | (Optional extends true\n ? K extends OptionalPropertyOf<T>\n ? readonly [K]\n : never\n : readonly [K])\n | readonly [K, ..._PathAsArray<T[K], Optional, MaxDepth, [...Depth, 1]>];\n }[GetKeys<T>]\n : never);\n\nexport type PathAsArray<\n T,\n Optional extends boolean = false,\n MaxDepth extends number = 5,\n> = _PathAsArray<T, Optional, MaxDepth, []>;\n\nexport type PathAsString<\n T,\n Optional extends boolean = false,\n MaxDepth extends number = 5,\n> = ArrayToStringPath<PathAsArray<T, Optional, MaxDepth>>;\n\nexport type Path<T, Optional extends boolean = false, MaxDepth extends number = 5> =\n | PathAsString<T, Optional, MaxDepth>\n | PathAsArray<T, Optional, MaxDepth>;\n\nexport type Value<T, P> = P extends readonly []\n ? T\n : true extends IsAny<T> | IsAny<P>\n ? any\n : true extends IsNever<T> | IsNever<P>\n ? never\n : P extends string\n ? Value<T, StringToArrayPath<P>>\n : P extends readonly [infer First extends KeyType, ...infer Rest extends readonly KeyType[]]\n ? T extends Map<any, infer V> | Set<infer V>\n ? Value<V, Rest> | undefined\n : T extends Array_\n ? any[] extends T\n ? Value<T[First & keyof T], Rest> | undefined\n : Value<T[First & keyof T], Rest>\n : T extends Object_\n ? Record<any, any> extends T\n ? Value<T[First], Rest> | undefined\n : Value<T[First], Rest>\n : never\n : never;\n\nexport type _WildcardPathAsArray<T, MaxDepth, Depth extends 1[]> =\n | []\n | (0 extends 1 & T\n ? KeyType[]\n : T extends never\n ? never\n : T extends Object_\n ? Depth['length'] extends MaxDepth\n ? string[]\n : T extends Map<infer K extends KeyType, infer V>\n ? ['*'] | [K] | [K, ..._WildcardPathAsArray<V, MaxDepth, [...Depth, 1]>]\n : T extends Set<any>\n ? ['*'] | [number]\n : Record<string, any> extends T\n ? ['*'] | ['*', ..._WildcardPathAsArray<T[string], MaxDepth, [...Depth, 1]>]\n : {\n [K in GetKeys<T>]:\n | ['*']\n | [\n '*',\n ..._WildcardPathAsArray<\n T[T extends readonly any[] ? number : keyof T],\n MaxDepth,\n [...Depth, 1]\n >,\n ]\n | [K]\n | [K, ..._WildcardPathAsArray<T[K], MaxDepth, [...Depth, 1]>];\n }[GetKeys<T>]\n : never);\n\nexport type WildcardPathAsArray<T, MaxDepth extends number = 5> = _WildcardPathAsArray<\n T,\n MaxDepth,\n []\n>;\nexport type WildcardPathAsString<T, MaxDepth extends number = 5> = ArrayToStringPath<\n _WildcardPathAsArray<T, MaxDepth, []>\n>;\nexport type WildcardPath<T, MaxDepth extends number = 5> =\n | WildcardPathAsString<T, MaxDepth>\n | WildcardPathAsArray<T, MaxDepth>;\n\nexport type WildcardValue<T, P> = true extends IsAny<T> | IsAny<P>\n ? any\n : true extends IsNever<T> | IsNever<P>\n ? never\n : P extends string\n ? WildcardValue<T, StringToArrayPath<P>>\n : P extends readonly [infer First extends KeyType, ...infer Rest extends KeyType[]]\n ? T extends Map<any, infer V> | Set<infer V>\n ? WildcardValue<V, Rest> | (First extends '*' ? never : undefined)\n : T extends Array_\n ? First extends '*'\n ? WildcardValue<T[number], Rest>\n : any[] extends T\n ? WildcardValue<T[First & keyof T], Rest> | undefined\n : First extends keyof T\n ? WildcardValue<T[First], Rest>\n : undefined\n : T extends Object_\n ? First extends '*'\n ? WildcardValue<T[keyof T], Rest>\n : Record<any, any> extends T\n ? WildcardValue<T[First], Rest> | undefined\n : WildcardValue<T[First], Rest>\n : never\n : T;\n\nexport type WildcardMatch<S, W> = S extends string\n ? WildcardMatch<StringToArrayPath<S>, W>\n : W extends string\n ? WildcardMatch<S, StringToArrayPath<W>>\n : [S, W] extends [readonly [], readonly []]\n ? true\n : [S, W] extends [\n readonly [infer SFirst, ...infer SRest],\n readonly [infer WFirst, ...infer WRest],\n ]\n ? [WFirst, WRest['length']] extends ['*' | SFirst, SRest['length']]\n ? WildcardMatch<SRest, WRest>\n : false\n : false;\n\nexport type Join<A extends string | number, B extends string | number> = A extends ''\n ? B\n : B extends ''\n ? A\n : `${A}.${B}`;\n\ntype _SettablePathAsArray<T, MaxDepth, Depth extends 1[]> =\n | readonly []\n | (true extends IsAny<T>\n ? readonly KeyType[]\n : undefined extends T\n ? T extends Map<any, any> | Set<any>\n ? never\n : T extends Object_\n ? {\n [K in GetKeys<T>]: Partial<T> extends Omit<T, K>\n ?\n | readonly [K]\n | readonly [K, ..._SettablePathAsArray<T[K], MaxDepth, [...Depth, 1]>]\n : readonly [];\n }[GetKeys<T>]\n : never\n : T extends never\n ? never\n : T extends Object_\n ? Depth['length'] extends MaxDepth\n ? readonly string[]\n : T extends Map<infer K extends KeyType, infer V>\n ? readonly [K] | readonly [K, ..._SettablePathAsArray<V, MaxDepth, [...Depth, 1]>]\n : T extends Set<any>\n ? readonly [number]\n : {\n [K in GetKeys<T>]:\n | readonly [K]\n | readonly [K, ..._SettablePathAsArray<T[K], MaxDepth, [...Depth, 1]>];\n }[GetKeys<T>]\n : never);\n\nexport type SettablePathAsArray<T, MaxDepth extends number = 5> = _SettablePathAsArray<\n T,\n MaxDepth,\n []\n>;\nexport type SettablePathAsString<T, MaxDepth extends number = 5> = ArrayToStringPath<\n SettablePathAsArray<T, MaxDepth>\n>;\n\nexport type SettablePath<T, MaxDepth extends number = 5> =\n | SettablePathAsString<T, MaxDepth>\n | SettablePathAsArray<T, MaxDepth>;\n\nexport type SettableValue<T, P> = P extends readonly []\n ? T\n : true extends IsAny<T> | IsAny<P>\n ? any\n : true extends IsNever<T> | IsNever<P>\n ? never\n : P extends string\n ? SettableValue<T, StringToArrayPath<P>>\n : P extends readonly [infer First extends KeyType, ...infer Rest extends readonly KeyType[]]\n ? T extends Map<any, infer V> | Set<infer V>\n ? SettableValue<V, Rest>\n : T extends Array_\n ? SettableValue<T[First & keyof T], Rest>\n : T extends Object_\n ? SettableValue<T[First], Rest>\n : never\n : never;\n\nexport function isAnyPath(path: any): path is AnyPath {\n return typeof path === 'string' || Array.isArray(path);\n}\n"],"mappings":";AA8OA,SAAgB,UAAU,MAA4B;CACpD,OAAO,OAAO,SAAS,YAAY,MAAM,QAAQ,IAAI;AACvD"}
@@ -1,5 +1,5 @@
1
- const require_store = require('../store-CPqOf4y5.cjs');
2
- const require_persist = require('../persist-CG1WHP6D.cjs');
1
+ const require_store = require('../store-fmAYV5hy.cjs');
2
+ const require_persist = require('../persist-B341lrOA.cjs');
3
3
 
4
4
  //#region src/persist/register.ts
5
5
  require_store.Store.addHook((store) => {
@@ -1 +1 @@
1
- {"version":3,"file":"register.cjs","names":["Store","persist"],"sources":["../../src/persist/register.ts"],"sourcesContent":["import { Store } from '@core';\nimport { persist, type Persist, type PersistOptions } from '@persist/persist';\n\ndeclare module '..' {\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n interface StoreOptions<T> {\n persist?: PersistOptions<T>;\n }\n\n interface Store<T> {\n persistance?: Persist<T>;\n }\n}\n\nStore.addHook((store) => {\n if (store.options.persist) {\n store.persistance = persist(store, store.options.persist);\n }\n});\n"],"mappings":";;;;AAcAA,oBAAM,SAAS,UAAU;AACvB,KAAI,MAAM,QAAQ,QAChB,OAAM,cAAcC,wBAAQ,OAAO,MAAM,QAAQ,QAAQ;EAE3D"}
1
+ {"version":3,"file":"register.cjs","names":["Store","persist"],"sources":["../../src/persist/register.ts"],"sourcesContent":["import { Store } from '@core';\nimport { persist, type Persist, type PersistOptions } from '@persist/persist';\n\ndeclare module '@core' {\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n interface StoreOptions<T> {\n persist?: PersistOptions<T>;\n }\n\n interface Store<T> {\n persistance?: Persist<T>;\n }\n}\n\nStore.addHook((store) => {\n if (store.options.persist) {\n store.persistance = persist(store, store.options.persist);\n }\n});\n"],"mappings":";;;;AAcAA,oBAAM,SAAS,UAAU;CACvB,IAAI,MAAM,QAAQ,SAChB,MAAM,cAAcC,wBAAQ,OAAO,MAAM,QAAQ,OAAO;AAE5D,CAAC"}
@@ -1,7 +1,7 @@
1
- import { n as PersistOptions, t as Persist } from "../persist-CkZ7CzW8.cjs";
1
+ import { n as PersistOptions, t as Persist } from "../persist-CoSWtRt0.cjs";
2
2
 
3
3
  //#region src/persist/register.d.ts
4
- declare module ".." {
4
+ declare module "@core" {
5
5
  interface StoreOptions<T> {
6
6
  persist?: PersistOptions<T>;
7
7
  }
@@ -1,7 +1,7 @@
1
- import { n as PersistOptions, t as Persist } from "../persist-3Nff6j1f.js";
1
+ import { n as PersistOptions, t as Persist } from "../persist-XVT4fROX.js";
2
2
 
3
3
  //#region src/persist/register.d.ts
4
- declare module ".." {
4
+ declare module "@core" {
5
5
  interface StoreOptions<T> {
6
6
  persist?: PersistOptions<T>;
7
7
  }
@@ -1,5 +1,5 @@
1
- import { t as Store } from "../store-D4q5zD7q.js";
2
- import { t as persist } from "../persist-CNA2sYtB.js";
1
+ import { t as Store } from "../store-BmlnyYal.js";
2
+ import { t as persist } from "../persist-xv73m7UR.js";
3
3
 
4
4
  //#region src/persist/register.ts
5
5
  Store.addHook((store) => {
@@ -1 +1 @@
1
- {"version":3,"file":"register.js","names":[],"sources":["../../src/persist/register.ts"],"sourcesContent":["import { Store } from '@core';\nimport { persist, type Persist, type PersistOptions } from '@persist/persist';\n\ndeclare module '..' {\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n interface StoreOptions<T> {\n persist?: PersistOptions<T>;\n }\n\n interface Store<T> {\n persistance?: Persist<T>;\n }\n}\n\nStore.addHook((store) => {\n if (store.options.persist) {\n store.persistance = persist(store, store.options.persist);\n }\n});\n"],"mappings":";;;;AAcA,MAAM,SAAS,UAAU;AACvB,KAAI,MAAM,QAAQ,QAChB,OAAM,cAAc,QAAQ,OAAO,MAAM,QAAQ,QAAQ;EAE3D"}
1
+ {"version":3,"file":"register.js","names":[],"sources":["../../src/persist/register.ts"],"sourcesContent":["import { Store } from '@core';\nimport { persist, type Persist, type PersistOptions } from '@persist/persist';\n\ndeclare module '@core' {\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n interface StoreOptions<T> {\n persist?: PersistOptions<T>;\n }\n\n interface Store<T> {\n persistance?: Persist<T>;\n }\n}\n\nStore.addHook((store) => {\n if (store.options.persist) {\n store.persistance = persist(store, store.options.persist);\n }\n});\n"],"mappings":";;;;AAcA,MAAM,SAAS,UAAU;CACvB,IAAI,MAAM,QAAQ,SAChB,MAAM,cAAc,QAAQ,OAAO,MAAM,QAAQ,OAAO;AAE5D,CAAC"}
@@ -1,7 +1,7 @@
1
- const require_store = require('./store-CPqOf4y5.cjs');
2
- const require_propAccess = require('./propAccess-udIdjqwY.cjs');
3
- const require_patchMethods = require('./patchMethods-CZje49Dk.cjs');
4
- const require_extendedJson = require('./extendedJson-DzXMFE1P.cjs');
1
+ const require_store = require('./store-fmAYV5hy.cjs');
2
+ const require_propAccess = require('./propAccess-DdLF12Jq.cjs');
3
+ const require_patchMethods = require('./patchMethods-BBQDDqwe.cjs');
4
+ const require_extendedJson = require('./extendedJson-pbOLcymB.cjs');
5
5
 
6
6
  //#region src/lib/promiseChain.ts
7
7
  function promiseChain(value) {
@@ -9,7 +9,34 @@ function promiseChain(value) {
9
9
  return {
10
10
  value,
11
11
  next(fn) {
12
- return promiseChain(require_store.isPromise(value) ? value.then((value$1) => fn(value$1)) : fn(value));
12
+ return promiseChain(require_store.isPromise(value) ? value.then((value) => fn(value)) : fn(value));
13
+ }
14
+ };
15
+ }
16
+
17
+ //#endregion
18
+ //#region src/persist/persistStorage.ts
19
+ function normalizeStorage(storage) {
20
+ return {
21
+ getItem: storage.getItem.bind(storage),
22
+ setItem: storage.setItem.bind(storage),
23
+ removeItem: storage.removeItem.bind(storage),
24
+ listItems() {
25
+ if ("listItems" in storage) return storage.listItems();
26
+ return promiseChain(() => {
27
+ if ("keys" in storage) return storage.keys();
28
+ else return promiseChain(storage.length instanceof Function ? storage.length() : storage.length).next((length) => {
29
+ const keys = Array.from({ length }, (_, index) => storage.key(index));
30
+ return keys.some(require_store.isPromise) ? Promise.all(keys) : keys;
31
+ }).next((keys) => {
32
+ return keys.filter((key) => typeof key === "string");
33
+ }).value;
34
+ }).next((keys) => {
35
+ const results = keys.map((key) => promiseChain(storage.getItem(key)).next((value) => [key, value]).value);
36
+ return results.some(require_store.isPromise) ? Promise.all(results) : results;
37
+ }).next((results) => {
38
+ return new Map(results.filter(([, value]) => value !== null));
39
+ }).value;
13
40
  }
14
41
  };
15
42
  }
@@ -34,54 +61,25 @@ const split = (value, path) => {
34
61
  path: [],
35
62
  value
36
63
  }];
37
- if (first === "*") return [...entries].flatMap(([k, v]) => split(v, rest).map(({ path: path$1, value: value$1 }) => ({
38
- path: [k, ...path$1],
39
- value: value$1
64
+ if (first === "*") return [...entries].flatMap(([k, v]) => split(v, rest).map(({ path, value }) => ({
65
+ path: [k, ...path],
66
+ value
40
67
  })));
41
68
  const subValue = entries.get(first);
42
69
  if (subValue === void 0) return [{
43
70
  path: [],
44
71
  value
45
72
  }];
46
- return split(subValue, rest).map(({ path: path$1, value: value$1 }) => ({
47
- path: [first, ...path$1],
48
- value: value$1
73
+ return split(subValue, rest).map(({ path, value }) => ({
74
+ path: [first, ...path],
75
+ value
49
76
  }));
50
77
  };
51
78
 
52
- //#endregion
53
- //#region src/persist/persistStorage.ts
54
- function normalizeStorage(storage) {
55
- return {
56
- getItem: storage.getItem.bind(storage),
57
- setItem: storage.setItem.bind(storage),
58
- removeItem: storage.removeItem.bind(storage),
59
- listItems() {
60
- if ("listItems" in storage) return storage.listItems();
61
- return promiseChain(() => {
62
- if ("keys" in storage) return storage.keys();
63
- else return promiseChain(storage.length instanceof Function ? storage.length() : storage.length).next((length) => {
64
- const keys = Array.from({ length }, (_, index) => storage.key(index));
65
- return keys.some(require_store.isPromise) ? Promise.all(keys) : keys;
66
- }).next((keys) => {
67
- return keys.filter((key) => typeof key === "string");
68
- }).value;
69
- }).next((keys) => {
70
- const results = keys.map((key) => promiseChain(storage.getItem(key)).next((value) => [key, value]).value);
71
- return results.some(require_store.isPromise) ? Promise.all(results) : results;
72
- }).next((results) => {
73
- return new Map(results.filter(([, value]) => value !== null));
74
- }).value;
75
- }
76
- };
77
- }
78
-
79
79
  //#endregion
80
80
  //#region src/persist/persist.ts
81
81
  var Persist = class {
82
- static {
83
- Symbol.dispose;
84
- }
82
+ static {}
85
83
  constructor(store, options) {
86
84
  this.store = store;
87
85
  this.options = options;
@@ -128,12 +126,12 @@ var Persist = class {
128
126
  this.queue(() => this.save(pathToSave), pathToSave);
129
127
  } else if (patch.op === "remove") {
130
128
  const subValues = split(reversePatch?.op === "add" ? reversePatch.value : {}, path.slice(patch.path.length));
131
- for (const { path: path$1 } of subValues) this.queue(() => this.save([...patch.path, ...path$1]), [...patch.path, ...path$1]);
129
+ for (const { path } of subValues) this.queue(() => this.save([...patch.path, ...path]), [...patch.path, ...path]);
132
130
  } else {
133
131
  const updatedValues = split(patch.value, path.slice(patch.path.length));
134
132
  const removedValues = split(reversePatch?.op !== "remove" ? reversePatch?.value ?? {} : {}, path.slice(patch.path.length)).filter((v) => !updatedValues.some((u) => require_propAccess.shallowEqual(u.path, v.path)));
135
- for (const { path: path$1 } of updatedValues) this.queue(() => this.save([...patch.path, ...path$1]), [...patch.path, ...path$1]);
136
- for (const { path: path$1 } of removedValues) this.queue(() => this.save([...patch.path, ...path$1]), [...patch.path, ...path$1]);
133
+ for (const { path } of updatedValues) this.queue(() => this.save([...patch.path, ...path]), [...patch.path, ...path]);
134
+ for (const { path } of removedValues) this.queue(() => this.save([...patch.path, ...path]), [...patch.path, ...path]);
137
135
  }
138
136
  }
139
137
  }, {
@@ -257,4 +255,4 @@ Object.defineProperty(exports, 'persist', {
257
255
  return persist;
258
256
  }
259
257
  });
260
- //# sourceMappingURL=persist-CG1WHP6D.cjs.map
258
+ //# sourceMappingURL=persist-B341lrOA.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"persist-B341lrOA.cjs","names":["isPromise","isPromise","queue","castArrayPath","calcDuration","subscribePatches","shallowEqual","isPromise","fromExtendedJsonString","remove","set","get","toExtendedJsonString"],"sources":["../src/lib/promiseChain.ts","../src/persist/persistStorage.ts","../src/persist/persistPathHelpers.ts","../src/persist/persist.ts"],"sourcesContent":["import isPromise from '@lib/isPromise';\n\nexport interface Chain<T> {\n value: T;\n next<S>(fn: (value: Awaited<T>) => S): T extends Promise<any> ? Chain<Promise<S>> : Chain<S>;\n}\n\nexport default function promiseChain<T>(value: T | (() => T)): Chain<T> {\n if (value instanceof Function) {\n value = value();\n }\n\n return {\n value,\n next(fn) {\n const next = isPromise(value)\n ? value.then((value) => fn(value as Awaited<T>))\n : fn(value as Awaited<T>);\n\n return promiseChain(next) as any;\n },\n };\n}\n","import isPromise from '@lib/isPromise';\nimport promiseChain from '@lib/promiseChain';\n\nexport interface PersistStorageBase {\n getItem: (key: string) => string | null | Promise<string | null>;\n setItem: (key: string, value: string) => void | Promise<unknown>;\n removeItem: (key: string) => void | Promise<unknown>;\n}\n\nexport interface PersistStorageWithKeys extends PersistStorageBase {\n keys: () => string[] | Promise<string[]>;\n}\n\nexport interface PersistStorageWithLength extends PersistStorageBase {\n length: number | (() => number | Promise<number>);\n key: (keyIndex: number) => string | null | Promise<string | null>;\n}\n\nexport interface PersistStorageWithListItems extends PersistStorageBase {\n listItems: () => Map<string, string> | Promise<Map<string, string>>;\n}\n\nexport type PersistStorage =\n | PersistStorageWithKeys\n | PersistStorageWithLength\n | PersistStorageWithListItems;\n\nexport function normalizeStorage(storage: PersistStorage): PersistStorageWithListItems {\n return {\n getItem: storage.getItem.bind(storage),\n setItem: storage.setItem.bind(storage),\n removeItem: storage.removeItem.bind(storage),\n\n listItems() {\n if ('listItems' in storage) {\n return storage.listItems();\n }\n\n return promiseChain(() => {\n if ('keys' in storage) {\n return storage.keys();\n } else {\n return promiseChain(\n storage.length instanceof Function ? storage.length() : storage.length,\n )\n .next((length) => {\n const keys = Array.from({ length }, (_, index) => storage.key(index));\n return keys.some(isPromise) ? Promise.all(keys) : (keys as (string | null)[]);\n })\n .next((keys) => {\n return keys.filter((key): key is string => typeof key === 'string');\n }).value;\n }\n })\n .next((keys) => {\n const results = keys.map(\n (key) =>\n promiseChain(storage.getItem(key)).next((value) => [key, value] as const).value,\n );\n\n return results.some(isPromise)\n ? Promise.all(results)\n : (results as [string, string | null][]);\n })\n .next((results) => {\n return new Map(results.filter(([, value]) => value !== null) as [string, string][]);\n }).value;\n },\n };\n}\n","import type { KeyType } from '@lib/path';\n\nexport const isAncestor = (ancestor: KeyType[], path: KeyType[]): boolean => {\n return (\n ancestor.length <= path.length &&\n ancestor.every((v, i) => v === '*' || path[i] === '*' || v === path[i])\n );\n};\n\nexport const split = (value: any, path: KeyType[]): { path: KeyType[]; value: unknown }[] => {\n const [first, ...rest] = path;\n if (first === undefined) return [{ path: [], value }];\n\n let entries: Map<KeyType, unknown>;\n if (value instanceof Map) {\n entries = value;\n } else if (value instanceof Set) {\n entries = new Map([...value].map((v, i) => [i, v]));\n } else if (Array.isArray(value)) {\n entries = new Map(value.map((v, i) => [i, v]));\n } else if (typeof value === 'object' && value !== null) {\n entries = new Map(Object.entries(value));\n } else {\n return [{ path: [], value }];\n }\n\n if (first === '*') {\n return [...entries].flatMap(([k, v]) =>\n split(v, rest).map(({ path, value }) => ({ path: [k, ...path], value })),\n );\n }\n\n const subValue = entries.get(first);\n if (subValue === undefined) return [{ path: [], value }];\n\n return split(subValue, rest).map(({ path, value }) => ({ path: [first, ...path], value }));\n};\n","import {\n normalizeStorage,\n type PersistStorage,\n type PersistStorageWithListItems,\n} from './persistStorage';\nimport { type Cancel, type Duration, type Store } from '@core';\nimport { calcDuration } from '@lib/duration';\nimport { shallowEqual } from '@lib/equals';\nimport { fromExtendedJsonString, toExtendedJsonString } from '@lib/extendedJson';\nimport isPromise from '@lib/isPromise';\nimport type { KeyType, WildcardPath } from '@lib/path';\nimport promiseChain from '@lib/promiseChain';\nimport { castArrayPath, get, remove, set } from '@lib/propAccess';\nimport { queue } from '@lib/queue';\nimport { subscribePatches } from '@patches/patchMethods';\nimport { isAncestor, split } from '@persist/persistPathHelpers';\n\ntype PathOption<T> =\n | WildcardPath<T>\n | {\n path: WildcardPath<T>;\n // throttle?: Duration;\n };\n\ntype Key = { type: 'internal'; path: string } | { type: 'data'; path: KeyType[] };\n\nexport interface PersistOptions<T> {\n id: string;\n storage: PersistStorage;\n paths?: PathOption<T>[];\n throttle?: Duration;\n persistInitialState?: boolean;\n}\n\nexport class Persist<T> {\n readonly storage: PersistStorageWithListItems;\n readonly [Symbol.dispose]!: Cancel;\n\n readonly paths: {\n path: KeyType[];\n throttle?: number;\n }[];\n\n readonly initialized: Promise<void>;\n\n private resolveInitialized?: () => void;\n\n private channel: BroadcastChannel;\n\n private queue = queue();\n\n private handles = new Set<Cancel>();\n\n private stopped = false;\n\n private updateInProgress = new Map<string, unknown>();\n\n private prefix;\n\n constructor(\n public readonly store: Store<T>,\n public readonly options: PersistOptions<T>,\n ) {\n this.storage = normalizeStorage(options.storage);\n this.channel = new BroadcastChannel(`cross-state-persist_${options.id}`);\n this.prefix = `${options.id}:`;\n\n if (Symbol.dispose) {\n this[Symbol.dispose] = () => this.stop();\n }\n\n this.paths = (options.paths ?? [])\n .map<{\n path: KeyType[];\n throttle?: number;\n }>((p) => {\n if (isPlainPath(p)) {\n return {\n path: castArrayPath(p),\n throttle: options.throttle ? calcDuration(options.throttle) : undefined,\n };\n }\n\n const _p = p as { path: KeyType[]; throttle?: Duration };\n\n return {\n path: castArrayPath(_p.path),\n throttle:\n (_p.throttle ? calcDuration(_p.throttle) : undefined) ??\n (options.throttle ? calcDuration(options.throttle) : undefined),\n };\n })\n .sort((a, b) => b.path.length - a.path.length);\n\n if (this.paths.length === 0) {\n this.paths.push({\n path: ['*'],\n throttle: options.throttle ? calcDuration(options.throttle) : undefined,\n });\n }\n\n this.initialized = new Promise((resolve) => {\n this.resolveInitialized = resolve;\n });\n\n this.watchStore();\n void this.watchStorage();\n }\n\n private watchStore() {\n const throttle = Math.min(...this.paths.map((p) => p.throttle ?? 0)) || undefined;\n\n const cancel = subscribePatches.apply(this.store as Store<unknown>, [\n (patches, reversePatches) => {\n let i = 0;\n for (const patch of patches) {\n const reversePatch = reversePatches[i++];\n\n const stringPath = JSON.stringify(patch.path);\n if (\n this.updateInProgress.has(stringPath) &&\n this.updateInProgress.get(stringPath) ===\n (patch.op === 'remove' ? undefined : patch.value)\n ) {\n continue;\n }\n\n const matchingPaths = this.paths.filter(\n (p) => isAncestor(p.path, patch.path) || isAncestor(patch.path, p.path),\n );\n\n for (const { path } of matchingPaths) {\n if (path.length <= patch.path.length) {\n const pathToSave = patch.path.slice(0, path.length);\n void this.queue(() => this.save(pathToSave), pathToSave);\n } else if (patch.op === 'remove') {\n const subValues = split(\n reversePatch?.op === 'add' ? reversePatch.value : {},\n path.slice(patch.path.length),\n );\n\n for (const { path } of subValues) {\n void this.queue(\n () => this.save([...patch.path, ...path]),\n [...patch.path, ...path],\n );\n }\n } else {\n const updatedValues = split(patch.value, path.slice(patch.path.length));\n const removedValues = split(\n reversePatch?.op !== 'remove' ? (reversePatch?.value ?? {}) : {},\n path.slice(patch.path.length),\n ).filter((v) => !updatedValues.some((u) => shallowEqual(u.path, v.path)));\n\n for (const { path } of updatedValues) {\n void this.queue(\n () => this.save([...patch.path, ...path]),\n [...patch.path, ...path],\n );\n }\n for (const { path } of removedValues) {\n void this.queue(\n () => this.save([...patch.path, ...path]),\n [...patch.path, ...path],\n );\n }\n }\n }\n }\n },\n { runNow: this.options.persistInitialState ?? false, passive: true, throttle },\n ]);\n\n this.handles.add(cancel);\n }\n\n private async watchStorage() {\n if (!this.options.persistInitialState) {\n let items = this.storage.listItems();\n if (isPromise(items)) {\n items = await items;\n }\n\n if (this.stopped) {\n return;\n }\n\n const toLoad = new Map(\n [...items.entries()]\n .sort((a, b) => b[1].length - a[1].length)\n .map(([key, value]) => [this.parseKey(key), value])\n .filter(([key]) => key) as [Key, string][],\n );\n\n void this.queue(() => this.load(toLoad));\n }\n\n void this.queue(() => this.resolveInitialized?.());\n\n const listener = (event: MessageEvent) => {\n void this.queue(() => this.load([{ type: 'data', path: event.data }]));\n };\n\n this.channel.addEventListener('message', listener);\n this.handles.add(() => this.channel.removeEventListener('message', listener));\n }\n\n private buildKey({ type, path }: Key) {\n return `${this.prefix}${type === 'internal' ? path : JSON.stringify(path)}`;\n }\n\n private parseKey(key: string): Key | undefined {\n if (!key.startsWith(this.prefix)) {\n return;\n }\n\n key = key.slice(this.prefix.length);\n\n if (!key.startsWith('[')) {\n return { type: 'internal', path: key };\n }\n\n return { type: 'data', path: JSON.parse(key) as KeyType[] };\n }\n\n private load(items: Key[] | Map<Key, string>): void | Promise<void> {\n return promiseChain(() => {\n if (Array.isArray(items)) {\n return promiseChain(() => {\n const entries = items.map(\n (key) =>\n promiseChain(() => {\n return this.storage.getItem(this.buildKey(key));\n }).next((value) => [key, value] as const).value,\n );\n\n return entries.some(isPromise)\n ? Promise.all(entries)\n : (entries as [Key, string | null][]);\n }).next((entries) => {\n return entries.filter((entry) => entry !== null) as [Key, string][];\n }).value;\n } else {\n return [...items.entries()];\n }\n }).next((entries) => {\n if (this.stopped) {\n return;\n }\n\n const toWrite = entries\n .filter(([key, value]) => {\n if (key.type !== 'data' || !value) {\n return;\n }\n\n if (\n !this.paths.find(\n (p) =>\n (p.path.length === 1 && p.path[0] === '*' && key.path.length === 0) ||\n (p.path.length === key.path.length && isAncestor(p.path, key.path)),\n )\n ) {\n return null;\n }\n\n const inSaveQueue = this.queue\n .getRefs()\n .find((ref) => isAncestor(ref, key.path) || isAncestor(key.path, ref));\n return !inSaveQueue;\n })\n .map(([key, value]) => {\n try {\n return {\n path: key.path,\n value: !value || value === 'undefined' ? undefined : fromExtendedJsonString(value),\n };\n } catch {\n return undefined;\n }\n })\n .filter(Boolean) as { path: KeyType[]; value: unknown }[];\n\n if (toWrite.length > 0) {\n for (const { path, value } of toWrite) {\n this.updateInProgress.set(JSON.stringify(path), value);\n }\n\n this.store.set((state) => {\n for (const { path, value } of toWrite) {\n if (value === undefined) {\n state = remove(state, path as any);\n } else {\n state = set(state, path as any, value);\n }\n }\n\n return state;\n });\n\n this.updateInProgress.clear();\n }\n\n const versionEntry = entries.find(\n ([key]) => key.type === 'internal' && key.path === 'version',\n );\n if (versionEntry) {\n this.store.version = versionEntry[1];\n }\n }).value;\n }\n\n private save(path: KeyType[]): void | Promise<unknown> {\n const key = this.buildKey({ type: 'data', path });\n const value = get(this.store.get() as any, path);\n\n return promiseChain(value)\n .next((value) => {\n if (value === undefined) {\n return this.storage.removeItem(key);\n } else {\n return this.storage.setItem(key, toExtendedJsonString(value));\n }\n })\n .next(() => {\n this.channel.postMessage(path);\n\n if (this.store.version) {\n return this.storage.setItem(\n this.buildKey({ type: 'internal', path: 'version' }),\n this.store.version,\n );\n } else {\n return this.storage.removeItem(this.buildKey({ type: 'internal', path: 'version' }));\n }\n }).value;\n }\n\n async stop(): Promise<void> {\n this.stopped = true;\n\n for (const handle of this.handles) {\n handle();\n }\n\n await this.queue.whenDone();\n this.channel.close();\n }\n}\n\nexport function persist<T>(store: Store<T>, options: PersistOptions<T>): Persist<T> {\n return new Persist<T>(store, options);\n}\n\nfunction isPlainPath<T>(p: PathOption<T>): p is WildcardPath<T> & (KeyType[] | string) {\n return typeof p === 'string' || Array.isArray(p);\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