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,4 +1,4 @@
1
- const require_propAccess = require('./propAccess-udIdjqwY.cjs');
1
+ const require_propAccess = require('./propAccess-DdLF12Jq.cjs');
2
2
 
3
3
  //#region src/lib/autobind.ts
4
4
  const marker = Symbol("autobind");
@@ -33,68 +33,6 @@ const autobind = (_class) => {
33
33
  return _class;
34
34
  };
35
35
 
36
- //#endregion
37
- //#region src/lib/duration.ts
38
- const unitToMilliseconds = {
39
- ns: 1e-6,
40
- us: .001,
41
- µs: .001,
42
- ms: 1,
43
- s: 1e3,
44
- m: 6e4,
45
- h: 36e5,
46
- D: 864e5,
47
- M: 2592e6,
48
- Y: 31536e6
49
- };
50
- function calcDuration(t) {
51
- switch (typeof t) {
52
- case "number": return t;
53
- case "string": return calcDurationString(t);
54
- default: return calcDurationObject(t);
55
- }
56
- }
57
- const plainNumberStyle = /^-?\d+(\.\d+)?$/;
58
- const golangStyle = /^-?(\d+(\.\d+)?(h|m|s|ms|us|µs|ns))+$/;
59
- const dotnetStyle = /^(?<sign>-)?((?<D>\d+)\.)?(?<h>\d{1,2}):(?<m>\d{1,2})(:(?<s>\d{1,2}))?(\.(?<ms>\d{1,3}))?$/;
60
- const iso8601Style = /^(?<sign>-)?P((?<Y>\d+)Y)?((?<M>\d+)M)?((?<D>\d+)D)?T?((?<h>\d+)H)?((?<m>\d+)M)?((?<s>\d+(\.\d+)?)S)?$/;
61
- function calcDurationString(t) {
62
- let match;
63
- if (plainNumberStyle.test(t)) return parseFloat(t);
64
- if (golangStyle.test(t)) {
65
- let ms = 0;
66
- let sign = 1;
67
- if (t.startsWith("-")) {
68
- sign = -1;
69
- t = t.slice(1);
70
- }
71
- const parts = t.split(/(\d+(?:\.\d+))|([a-zµ]+)/).filter(Boolean);
72
- for (let i = 0; i < parts.length; i += 2) {
73
- const value = parseFloat(parts[i]);
74
- const unit = parts[i + 1];
75
- ms += value * unitToMilliseconds[unit];
76
- }
77
- return ms * sign;
78
- }
79
- if (match = t.match(dotnetStyle) ?? t.match(iso8601Style)) {
80
- let ms = 0;
81
- let sign = 1;
82
- for (const [unit, factor] of Object.entries(match.groups ?? {})) {
83
- if (!factor) continue;
84
- if (unit === "sign") {
85
- sign = -1;
86
- continue;
87
- }
88
- ms += parseFloat(factor) * unitToMilliseconds[unit];
89
- }
90
- return ms * sign;
91
- }
92
- throw new Error(`Invalid duration string: "${t}"`);
93
- }
94
- function calcDurationObject(t) {
95
- return (t.milliseconds ?? 0) + (t.seconds ?? 0) * unitToMilliseconds.s + (t.minutes ?? 0) * unitToMilliseconds.m + (t.hours ?? 0) * unitToMilliseconds.h + (t.days ?? 0) * unitToMilliseconds.D + (t.months ?? 0) * unitToMilliseconds.M + (t.years ?? 0) * unitToMilliseconds.Y;
96
- }
97
-
98
36
  //#endregion
99
37
  //#region src/lib/deferred.ts
100
38
  var Deferred = class Deferred extends Promise {
@@ -135,10 +73,10 @@ var PromiseWithState = class PromiseWithState extends Promise {
135
73
  super((resolve) => resolve(value));
136
74
  this.state = state;
137
75
  Object.defineProperty(PromiseWithState, Symbol.species, { value: Promise });
138
- if (isPromise(value)) value.then((value$1) => {
76
+ if (isPromise(value)) value.then((value) => {
139
77
  this.state = {
140
78
  status: "value",
141
- value: value$1
79
+ value
142
80
  };
143
81
  }).catch((error) => {
144
82
  this.state = {
@@ -243,7 +181,7 @@ function calculatedValue(store, notify) {
243
181
  };
244
182
  });
245
183
  function use(dep) {
246
- const value$1 = dep.get();
184
+ const value = dep.get();
247
185
  let cancel;
248
186
  const on = () => {
249
187
  cancel ||= dep.subscribe(() => store.invalidate(), { runNow: false });
@@ -254,12 +192,12 @@ function calculatedValue(store, notify) {
254
192
  };
255
193
  deps.push({
256
194
  store: dep,
257
- value: value$1,
195
+ value,
258
196
  on,
259
197
  off
260
198
  });
261
199
  if (active) on();
262
- return value$1;
200
+ return value;
263
201
  }
264
202
  async function connect(createConnection) {
265
203
  if (!active) {
@@ -384,14 +322,65 @@ function staticValue(value) {
384
322
  }
385
323
 
386
324
  //#endregion
387
- //#region src/lib/makeSelector.ts
388
- function identity(x) {
389
- return x;
325
+ //#region src/lib/duration.ts
326
+ const unitToMilliseconds = {
327
+ ns: 1e-6,
328
+ us: .001,
329
+ µs: .001,
330
+ ms: 1,
331
+ s: 1e3,
332
+ m: 6e4,
333
+ h: 36e5,
334
+ D: 864e5,
335
+ M: 2592e6,
336
+ Y: 31536e6
337
+ };
338
+ function calcDuration(t) {
339
+ switch (typeof t) {
340
+ case "number": return t;
341
+ case "string": return calcDurationString(t);
342
+ default: return calcDurationObject(t);
343
+ }
390
344
  }
391
- function makeSelector(selector) {
392
- if (!selector) return identity;
393
- if (selector instanceof Function) return selector;
394
- return (x) => require_propAccess.get(x, selector);
345
+ const plainNumberStyle = /^-?\d+(\.\d+)?$/;
346
+ const golangStyle = /^-?(\d+(\.\d+)?(h|m|s|ms|us|µs|ns))+$/;
347
+ const dotnetStyle = /^(?<sign>-)?((?<D>\d+)\.)?(?<h>\d{1,2}):(?<m>\d{1,2})(:(?<s>\d{1,2}))?(\.(?<ms>\d{1,3}))?$/;
348
+ const iso8601Style = /^(?<sign>-)?P((?<Y>\d+)Y)?((?<M>\d+)M)?((?<D>\d+)D)?T?((?<h>\d+)H)?((?<m>\d+)M)?((?<s>\d+(\.\d+)?)S)?$/;
349
+ function calcDurationString(t) {
350
+ let match;
351
+ if (plainNumberStyle.test(t)) return parseFloat(t);
352
+ if (golangStyle.test(t)) {
353
+ let ms = 0;
354
+ let sign = 1;
355
+ if (t.startsWith("-")) {
356
+ sign = -1;
357
+ t = t.slice(1);
358
+ }
359
+ const parts = t.split(/(\d+(?:\.\d+))|([a-zµ]+)/).filter(Boolean);
360
+ for (let i = 0; i < parts.length; i += 2) {
361
+ const value = parseFloat(parts[i]);
362
+ const unit = parts[i + 1];
363
+ ms += value * unitToMilliseconds[unit];
364
+ }
365
+ return ms * sign;
366
+ }
367
+ if (match = t.match(dotnetStyle) ?? t.match(iso8601Style)) {
368
+ let ms = 0;
369
+ let sign = 1;
370
+ for (const [unit, factor] of Object.entries(match.groups ?? {})) {
371
+ if (!factor) continue;
372
+ if (unit === "sign") {
373
+ sign = -1;
374
+ continue;
375
+ }
376
+ ms += parseFloat(factor) * unitToMilliseconds[unit];
377
+ }
378
+ return ms * sign;
379
+ }
380
+ throw new Error(`Invalid duration string: "${t}"`);
381
+ }
382
+ function calcDurationObject(t) {
383
+ return (t.milliseconds ?? 0) + (t.seconds ?? 0) * unitToMilliseconds.s + (t.minutes ?? 0) * unitToMilliseconds.m + (t.hours ?? 0) * unitToMilliseconds.h + (t.days ?? 0) * unitToMilliseconds.D + (t.months ?? 0) * unitToMilliseconds.M + (t.years ?? 0) * unitToMilliseconds.Y;
395
384
  }
396
385
 
397
386
  //#endregion
@@ -415,7 +404,7 @@ function debounce(action, options) {
415
404
  function isScheduled() {
416
405
  return timeout !== void 0;
417
406
  }
418
- function debounce$1(...args) {
407
+ function debounce(...args) {
419
408
  const now = Date.now();
420
409
  timeoutStarted ??= now;
421
410
  const deadline = Math.min(now + wait, timeoutStarted + (maxWait ?? Number.POSITIVE_INFINITY));
@@ -428,7 +417,7 @@ function debounce(action, options) {
428
417
  };
429
418
  timeout = setTimeout(run, deadline - now);
430
419
  }
431
- return Object.assign(debounce$1, {
420
+ return Object.assign(debounce, {
432
421
  flush,
433
422
  cancel,
434
423
  isScheduled
@@ -449,6 +438,17 @@ function forwardError(error) {
449
438
  });
450
439
  }
451
440
 
441
+ //#endregion
442
+ //#region src/lib/makeSelector.ts
443
+ function identity(x) {
444
+ return x;
445
+ }
446
+ function makeSelector(selector) {
447
+ if (!selector) return identity;
448
+ if (selector instanceof Function) return selector;
449
+ return (x) => require_propAccess.get(x, selector);
450
+ }
451
+
452
452
  //#endregion
453
453
  //#region src/lib/promiseWithCancel.ts
454
454
  var PromiseCancelError = class extends Error {
@@ -749,8 +749,8 @@ var Store = class Store {
749
749
  const n = {};
750
750
  this.notifyId = n;
751
751
  const snapshot = [...this.listeners.entries()];
752
- const active = snapshot.filter(([, active$1]) => active$1);
753
- const passive = snapshot.filter(([, active$1]) => !active$1);
752
+ const active = snapshot.filter(([, active]) => active);
753
+ const passive = snapshot.filter(([, active]) => !active);
754
754
  for (const [listener] of [...active, ...passive]) {
755
755
  listener();
756
756
  if (n !== this.notifyId) break;
@@ -877,4 +877,4 @@ Object.defineProperty(exports, 'throttle', {
877
877
  return throttle;
878
878
  }
879
879
  });
880
- //# sourceMappingURL=store-CPqOf4y5.cjs.map
880
+ //# sourceMappingURL=store-fmAYV5hy.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"store-fmAYV5hy.cjs","names":["deepEqual","get","get","set","deepEqual","isObject"],"sources":["../src/lib/autobind.ts","../src/lib/deferred.ts","../src/lib/isPromise.ts","../src/lib/promiseWithState.ts","../src/lib/queue.ts","../src/lib/calculatedValue.ts","../src/lib/duration.ts","../src/lib/debounce.ts","../src/lib/disposable.ts","../src/lib/forwardError.ts","../src/lib/makeSelector.ts","../src/lib/promiseWithCancel.ts","../src/lib/standardMethods.ts","../src/lib/throttle.ts","../src/core/store.ts"],"sourcesContent":["const marker = Symbol('autobind');\n\nexport const autobind = <\n TClass extends abstract new (...args: any) => any = abstract new (...args: any) => any,\n>(\n _class: TClass,\n): TClass => {\n for (const key of Reflect.ownKeys(_class.prototype)) {\n if (key === 'constructor') {\n continue;\n }\n\n const descriptor = Reflect.getOwnPropertyDescriptor(_class.prototype, key);\n let method = descriptor?.get?.() ?? descriptor?.value;\n let isBinding = false;\n\n if (typeof method !== 'function' || method[marker]) {\n continue;\n }\n\n Reflect.defineProperty(_class.prototype, key, {\n configurable: true,\n get() {\n if (\n isBinding ||\n this === _class.prototype ||\n Object.prototype.hasOwnProperty.call(this, key) ||\n typeof method !== 'function'\n ) {\n return method;\n }\n\n const boundMethod = (...args: any[]) => Reflect.apply(method, this, args);\n boundMethod[marker] = true;\n isBinding = true;\n\n Object.defineProperty(this, key, {\n configurable: true,\n get() {\n return boundMethod;\n },\n });\n\n isBinding = false;\n return boundMethod;\n },\n set(v) {\n method = v;\n },\n });\n }\n\n return _class;\n};\n","export class Deferred<T = void> extends Promise<T> {\n resolve: (value: T | PromiseLike<T>) => void = () => undefined;\n reject: (reason?: any) => void = () => undefined;\n\n constructor() {\n void Object.defineProperty(Deferred, Symbol.species, {\n value: Promise,\n });\n\n const that = {};\n\n super((resolve, reject) => {\n Object.assign(that, { resolve, reject });\n });\n\n void Object.assign(this, that);\n }\n}\n","export default function isPromise(value: unknown): value is Promise<unknown> {\n return (\n typeof value === 'object' &&\n value !== null &&\n 'then' in value &&\n typeof value.then === 'function'\n );\n}\n","import { type ErrorState, type PendingState, type ValueState } from './cacheState';\nimport { type MaybePromise } from './maybePromise';\nimport isPromise from '@lib/isPromise';\n\nexport class PromiseWithState<T> extends Promise<T> {\n static override resolve(): PromiseWithState<void>;\n\n static override resolve<T>(value: MaybePromise<T>): PromiseWithState<T>;\n\n static override resolve<T>(value?: MaybePromise<T>) {\n return new PromiseWithState<T>(value as MaybePromise<T>);\n }\n\n static override reject<T = never>(error: unknown): PromiseWithState<T> {\n return new PromiseWithState<T>(Promise.reject(error), { status: 'error', error });\n }\n\n constructor(\n value: MaybePromise<T>,\n public state: ValueState<T> | ErrorState | PendingState = { status: 'pending' },\n ) {\n super((resolve) => resolve(value));\n\n void Object.defineProperty(PromiseWithState, Symbol.species, {\n value: Promise,\n });\n\n if (isPromise(value)) {\n value\n .then((value) => {\n this.state = { status: 'value', value: value };\n })\n .catch((error) => {\n this.state = { status: 'error', error };\n });\n } else {\n this.state = { status: 'value', value: value };\n }\n }\n}\n","import type { MaybePromise } from './maybePromise';\nimport type { Listener } from '@core';\nimport isPromise from '@lib/isPromise';\n\ntype Action<T> = () => MaybePromise<T>;\n\nexport interface Queue {\n <T>(action: Action<T>, ref?: any): Promise<T>;\n clear: () => void;\n whenDone: () => Promise<void>;\n size: number;\n getRefs: () => any[];\n}\n\nexport function queue(): Queue {\n const q: {\n action: Action<any>;\n resolve: (value: any) => void;\n reject: (error: unknown) => void;\n ref?: any;\n }[] = [];\n const completionListeners = new Set<Listener<void>>();\n let active = false;\n\n const notify = () => {\n for (const listener of completionListeners) {\n listener();\n }\n\n completionListeners.clear();\n };\n\n const run = async () => {\n if (!active) {\n active = true;\n\n let next;\n while ((next = q.shift())) {\n try {\n let result = next.action();\n if (isPromise(result)) {\n result = await result;\n }\n\n next.resolve(result);\n } catch (error) {\n next.reject(error);\n }\n }\n\n active = false;\n notify();\n }\n };\n\n return Object.assign(\n <T>(action: Action<T>, ref?: any) => {\n return new Promise<T>((resolve, reject) => {\n q.push({ action, resolve, reject, ref });\n void run();\n });\n },\n {\n clear() {\n q.length = 0;\n },\n\n whenDone() {\n if (!active) {\n return Promise.resolve();\n }\n\n return new Promise<void>((resolve) => {\n completionListeners.add(resolve);\n });\n },\n\n get size() {\n return q.length;\n },\n\n getRefs() {\n return q.map((item) => item.ref).filter((x) => x !== undefined);\n },\n },\n );\n}\n","import { deepEqual } from './equals';\nimport type { Cache } from '@core';\nimport type { AsyncConnectionActions, Cancel, Connection, StoreLike } from '@core/commonTypes';\nimport type { Store } from '@core/store';\nimport { Deferred } from '@lib/deferred';\nimport isPromise from '@lib/isPromise';\nimport { PromiseWithState } from '@lib/promiseWithState';\nimport { queue } from '@lib/queue';\n\nexport interface CalculatedValue<T> {\n value: T;\n check: () => void;\n stop(): void;\n invalidateDependencies(recursive?: boolean): void;\n}\n\nexport function calculatedValue<T>(store: Store<T>, notify: () => void): CalculatedValue<T> {\n if (!(store.getter instanceof Function)) {\n return staticValue(store.getter);\n }\n\n let active = false;\n const deps = new Array<{ store: StoreLike<any>; value: any; on: () => void; off: () => void }>();\n let value: T | undefined;\n const whenConnected = new Deferred();\n const whenExecuted = new Deferred();\n const ac = new AbortController();\n let connection: { active: boolean; cancel?: Cancel } | undefined;\n const q = queue();\n void q(() => whenExecuted);\n\n const cancelEffect = store.addEffect(() => {\n if (connection) {\n store.invalidate();\n return;\n }\n\n active = true;\n\n for (const dep of deps) {\n dep.on();\n }\n\n return () => {\n active = false;\n\n for (const dep of deps) {\n dep.off();\n }\n\n if (connection) {\n connection.active = false;\n connection.cancel?.();\n q.clear();\n\n if ('state' in store) {\n (store as unknown as Cache<any>).state.set((state) => ({\n ...state,\n isConnected: false,\n isStale: true,\n }));\n }\n }\n };\n });\n\n function use<S>(dep: StoreLike<S>) {\n const value = dep.get();\n let cancel: Cancel | undefined;\n\n const on = () => {\n cancel ||= dep.subscribe(() => store.invalidate(), { runNow: false });\n };\n\n const off = () => {\n cancel?.();\n cancel = undefined;\n };\n\n deps.push({ store: dep, value, on, off });\n\n if (active) {\n on();\n }\n\n return value;\n }\n\n async function connect(createConnection: Connection<T>) {\n if (!active) {\n connection = { active: false };\n return;\n }\n\n const actions: AsyncConnectionActions<any> = {\n set(_value) {\n void q(() => {\n if (!connection?.active) {\n return;\n }\n\n value = _value;\n notify();\n });\n },\n updateValue(update) {\n void q(async () => {\n if (!connection?.active) {\n return;\n }\n\n if (update instanceof Function) {\n const currentValue = await value;\n\n if (!connection?.active) {\n return;\n }\n\n try {\n update = update(currentValue);\n } catch (error) {\n value = PromiseWithState.reject(error) as T;\n notify();\n connection.active = false;\n connection.cancel?.();\n return;\n }\n }\n\n value = PromiseWithState.resolve(update) as T;\n notify();\n });\n },\n updateError(error) {\n void q(() => {\n if (!connection?.active) {\n return;\n }\n\n connection.active = false;\n connection.cancel?.();\n\n if ('state' in store) {\n (store as unknown as Cache<any>).state.set({\n status: 'error',\n error,\n isConnected: false,\n isUpdating: false,\n isStale: false,\n });\n }\n\n value = PromiseWithState.reject(error) as T;\n notify();\n });\n },\n updateIsConnected(isConnected) {\n if (isConnected) {\n whenConnected.resolve();\n }\n\n void q(() => {\n if (!connection?.active) {\n return;\n }\n\n if ('state' in store) {\n (store as unknown as Cache<any>).state.set('isConnected', isConnected);\n }\n });\n },\n close() {\n if (connection?.active) {\n store.invalidate();\n }\n },\n };\n\n connection = { active: true };\n let _cancel: Cancel | undefined = createConnection(actions as any);\n\n connection.cancel = () => {\n _cancel?.();\n _cancel = undefined;\n };\n\n if (!connection.active) {\n connection.cancel();\n }\n\n return whenConnected;\n }\n\n try {\n value = store.getter({ signal: ac.signal, use, connect });\n } catch (error) {\n value = PromiseWithState.reject(error) as T;\n\n if (connection) {\n connection.active = false;\n connection.cancel?.();\n q.clear();\n }\n }\n\n if (isPromise(value)) {\n value.finally(() => whenExecuted.resolve()).catch(() => undefined);\n } else {\n whenExecuted.resolve();\n }\n\n function check() {\n if (store.options.cacheValue === false) {\n return false;\n }\n\n for (const dep of deps) {\n if (!deepEqual(dep.store.get(), dep.value)) {\n return false;\n }\n }\n return true;\n }\n\n function stop() {\n cancelEffect();\n whenExecuted.resolve();\n whenConnected.resolve();\n ac.abort();\n\n if (connection) {\n connection.active = false;\n connection.cancel?.();\n q.clear();\n }\n }\n\n function invalidateDependencies(recursive?: boolean) {\n for (const dep of deps) {\n dep.store.invalidate(recursive);\n }\n }\n\n return {\n get value() {\n return value!;\n },\n check,\n stop,\n invalidateDependencies,\n };\n}\n\nexport function staticValue<T>(value: T): CalculatedValue<T> {\n return {\n value,\n check: () => true,\n stop: () => undefined,\n invalidateDependencies: () => undefined,\n };\n}\n\nexport function staleValue<T>(value: T): CalculatedValue<T> {\n return {\n value,\n check: () => false,\n stop: () => undefined,\n invalidateDependencies: () => undefined,\n };\n}\n","import type { Duration, DurationObject } from '../core/commonTypes';\n\nconst unitToMilliseconds = {\n ns: 1e-6,\n us: 1e-3,\n µs: 1e-3,\n ms: 1,\n s: 1_000,\n m: 60_000,\n h: 3_600_000,\n D: 86_400_000, // approximation - not accounting for DST changes\n M: 2_592_000_000, // approximation - 30 days\n Y: 31_536_000_000, // approximation - 365 days\n} satisfies Record<string, number>;\n\nexport function calcDuration(t: Duration): number {\n switch (typeof t) {\n case 'number':\n return t;\n case 'string':\n return calcDurationString(t);\n default:\n return calcDurationObject(t);\n }\n}\n\nconst plainNumberStyle = /^-?\\d+(\\.\\d+)?$/;\nconst golangStyle = /^-?(\\d+(\\.\\d+)?(h|m|s|ms|us|µs|ns))+$/;\nconst dotnetStyle =\n /^(?<sign>-)?((?<D>\\d+)\\.)?(?<h>\\d{1,2}):(?<m>\\d{1,2})(:(?<s>\\d{1,2}))?(\\.(?<ms>\\d{1,3}))?$/;\nconst iso8601Style =\n /^(?<sign>-)?P((?<Y>\\d+)Y)?((?<M>\\d+)M)?((?<D>\\d+)D)?T?((?<h>\\d+)H)?((?<m>\\d+)M)?((?<s>\\d+(\\.\\d+)?)S)?$/;\n\nexport function calcDurationString(t: string): number {\n let match;\n\n if (plainNumberStyle.test(t)) {\n return parseFloat(t);\n }\n\n if (golangStyle.test(t)) {\n let ms = 0;\n let sign = 1;\n\n if (t.startsWith('-')) {\n sign = -1;\n t = t.slice(1);\n }\n\n const parts = t.split(/(\\d+(?:\\.\\d+))|([a-zµ]+)/).filter(Boolean);\n for (let i = 0; i < parts.length; i += 2) {\n const value = parseFloat(parts[i]!);\n const unit = parts[i + 1] as keyof typeof unitToMilliseconds;\n ms += value * unitToMilliseconds[unit];\n }\n\n return ms * sign;\n }\n\n if ((match = t.match(dotnetStyle) ?? t.match(iso8601Style))) {\n let ms = 0;\n let sign = 1;\n\n for (const [unit, factor] of Object.entries(match.groups ?? {})) {\n if (!factor) {\n continue;\n }\n if (unit === 'sign') {\n sign = -1;\n continue;\n }\n\n ms += parseFloat(factor) * unitToMilliseconds[unit as keyof typeof unitToMilliseconds];\n }\n\n return ms * sign;\n }\n\n throw new Error(`Invalid duration string: \"${t}\"`);\n}\n\nexport function calcDurationObject(t: DurationObject): number {\n return (\n (t.milliseconds ?? 0) +\n (t.seconds ?? 0) * unitToMilliseconds.s +\n (t.minutes ?? 0) * unitToMilliseconds.m +\n (t.hours ?? 0) * unitToMilliseconds.h +\n (t.days ?? 0) * unitToMilliseconds.D +\n (t.months ?? 0) * unitToMilliseconds.M +\n (t.years ?? 0) * unitToMilliseconds.Y\n );\n}\n","import { calcDuration } from './duration';\nimport type { Duration } from '@core';\n\nexport type DebounceOptions =\n | Duration\n | {\n wait: Duration;\n maxWait?: Duration;\n waitOnRunNow?: boolean;\n };\n\nexport function debounce<Args extends any[]>(\n action: (...args: Args) => void,\n options: Duration | DebounceOptions,\n): {\n (...args: Args): void;\n flush(): void;\n cancel(): void;\n isScheduled(): boolean;\n} {\n const wait =\n typeof options === 'object' && 'wait' in options\n ? calcDuration(options.wait)\n : calcDuration(options);\n\n const maxWait =\n typeof options === 'object' && 'maxWait' in options && options.maxWait !== undefined\n ? calcDuration(options.maxWait)\n : undefined;\n\n let run: (() => void) | undefined;\n let timeout: ReturnType<typeof setTimeout> | undefined;\n let timeoutStarted: number | undefined;\n\n function flush() {\n if (timeout !== undefined) {\n clearTimeout(timeout);\n }\n\n run?.();\n }\n\n function cancel() {\n if (timeout !== undefined) {\n clearTimeout(timeout);\n }\n\n run = undefined;\n timeout = undefined;\n timeoutStarted = undefined;\n }\n\n function isScheduled() {\n return timeout !== undefined;\n }\n\n function debounce(...args: Args) {\n const now = Date.now();\n timeoutStarted ??= now;\n\n const deadline = Math.min(\n //\n now + wait,\n timeoutStarted + (maxWait ?? Number.POSITIVE_INFINITY),\n );\n\n if (timeout !== undefined) {\n clearTimeout(timeout);\n }\n\n run = () => {\n run = undefined;\n timeout = undefined;\n timeoutStarted = undefined;\n\n action(...args);\n };\n\n timeout = setTimeout(run, deadline - now);\n }\n\n return Object.assign(debounce, { flush, cancel, isScheduled });\n}\n","import type { Cancel } from '@core';\nimport type { DisposableCancel } from '@core/commonTypes';\n\nexport default function disposable(dispose: Cancel): DisposableCancel {\n return Object.assign(\n dispose,\n Symbol.dispose ? { [Symbol.dispose]: dispose } : {},\n ) as DisposableCancel;\n}\n","export function forwardError(error: unknown): void {\n setTimeout(() => {\n throw error;\n });\n}\n","import type { AnyPath } from './path';\nimport { get } from './propAccess';\n\nfunction identity<T>(x: T): T {\n return x;\n}\n\nexport function makeSelector<T, S>(selector?: ((value: T) => S) | AnyPath): (value: T) => S {\n if (!selector) {\n return identity as (value: T) => S;\n }\n\n if (selector instanceof Function) {\n return selector;\n }\n\n return (x) => get(x, selector as any) as any;\n}\n","import { autobind } from '@lib/autobind';\n\nexport class PromiseCancelError extends Error {\n constructor() {\n super('cancelled');\n }\n}\n\nexport class PromiseWithCancel<T> extends Promise<T> {\n private abortController;\n\n constructor(\n executor: (\n resolve: (value: T) => void,\n reject: (error: unknown) => void,\n signal: AbortSignal,\n ) => void,\n ) {\n void autobind(PromiseWithCancel);\n const abortController = new AbortController();\n\n super((resolve, reject) => {\n executor(resolve, reject, abortController.signal);\n\n abortController.signal.addEventListener('abort', () => {\n reject(abortController.signal.reason);\n });\n });\n\n this.abortController = abortController;\n }\n\n cancel(reason: any = new PromiseCancelError()): void {\n this.abortController.abort(reason);\n }\n}\n","import type { Store } from '../core/store';\nimport type { OptionalProperties, OptionalPropertyOf } from './typeHelpers';\n\ntype Function_ = (...args: any) => any;\n\nfunction createArrayAction<P extends keyof Array<any>>(prop: P) {\n return function arrayAction<T extends Array<any>>(\n this: Store<T>,\n ...args: T[P] extends Function_ ? Parameters<T[P]> : never\n ): T[P] extends Function_ ? ReturnType<T[P]> : never {\n const newArray = this.get().slice() as T;\n const result = (newArray[prop] as Function_)(...(args as any));\n this.set(newArray);\n return result;\n };\n}\nexport const arrayMethods: {\n [P in 'splice' | 'push' | 'pop' | 'shift' | 'unshift' | 'reverse' | 'sort']: <\n T extends Array<any>,\n >(\n this: Store<T>,\n ...args: T[P] extends Function_ ? Parameters<T[P]> : never\n ) => T[P] extends Function_ ? ReturnType<T[P]> : never;\n} = {\n splice: /* @__PURE__ */ createArrayAction('splice'),\n push: /* @__PURE__ */ createArrayAction('push'),\n pop: /* @__PURE__ */ createArrayAction('pop'),\n shift: /* @__PURE__ */ createArrayAction('shift'),\n unshift: /* @__PURE__ */ createArrayAction('unshift'),\n reverse: /* @__PURE__ */ createArrayAction('reverse'),\n sort: /* @__PURE__ */ createArrayAction('sort'),\n};\n\nexport const recordMethods = {\n delete<T extends Record<any, any>, K extends OptionalPropertyOf<T>>(\n this: Store<T>,\n key: K,\n ): void {\n const copy = { ...this.get() };\n delete copy[key];\n this.set(copy);\n },\n\n clear<T extends Record<any, any>>(\n this: OptionalProperties<T> extends T ? Store<T> : never,\n ): void {\n this.set({} as T);\n },\n};\n\nexport const mapMethods = {\n delete<K, V>(this: Store<Map<K, V>>, key: K): boolean {\n const newMap = new Map(this.get());\n const result = newMap.delete(key);\n this.set(newMap);\n return result;\n },\n\n clear<K, V>(this: Store<Map<K, V>>): void {\n this.set(new Map());\n },\n};\n\nexport const setMethods = {\n add<T>(this: Store<Set<T>>, value: T): void {\n const newSet = new Set(this.get());\n newSet.add(value);\n this.set(newSet);\n },\n\n delete<T>(this: Store<Set<T>>, value: T): void {\n const newSet = new Set(this.get());\n newSet.delete(value);\n this.set(newSet);\n },\n\n clear<T>(this: Store<Set<T>>): void {\n this.set(new Set());\n },\n};\n","import { calcDuration } from './duration';\nimport type { Duration } from '@core';\n\nexport function throttle<Args extends any[]>(\n action: (...args: Args) => void,\n duration: Duration,\n): (...args: Args) => void {\n const ms = calcDuration(duration);\n\n let t = 0;\n let timeout: ReturnType<typeof setTimeout> | undefined;\n\n return (...args: Args) => {\n if (timeout !== undefined) {\n clearTimeout(timeout);\n }\n\n const dt = t + ms - Date.now();\n if (dt <= 0) {\n action(...args);\n t = Date.now();\n return;\n }\n\n timeout = setTimeout(() => {\n action(...args);\n t = Date.now();\n }, dt);\n };\n}\n","import type {\n CalculationActions,\n Cancel,\n DisposableCancel,\n Duration,\n Effect,\n EffectOptions,\n Listener,\n Selector,\n SubscribeOptions,\n Update,\n} from './commonTypes';\nimport { autobind } from '@lib/autobind';\nimport { calculatedValue, staticValue, type CalculatedValue } from '@lib/calculatedValue';\nimport type { Constrain } from '@lib/constrain';\nimport { debounce } from '@lib/debounce';\nimport disposable from '@lib/disposable';\nimport { calcDuration } from '@lib/duration';\nimport { deepEqual } from '@lib/equals';\nimport { forwardError } from '@lib/forwardError';\nimport { isObject } from '@lib/helpers';\nimport { makeSelector } from '@lib/makeSelector';\nimport type { AnyPath, Path, SettablePath, Value } from '@lib/path';\nimport { PromiseWithCancel } from '@lib/promiseWithCancel';\nimport { get, set } from '@lib/propAccess';\nimport { arrayMethods, mapMethods, recordMethods, setMethods } from '@lib/standardMethods';\nimport { throttle } from '@lib/throttle';\n\nexport type StoreMethods = Record<string, (...args: any[]) => any>;\n\nexport type BoundStoreMethods<T, Methods extends StoreMethods> = Methods &\n ThisType<Store<T> & Methods>;\n\nexport interface StoreOptions<T> {\n retain?: Duration;\n equals?: SubscribeOptions['equals'];\n effect?: Effect<Store<T>> | { effect: Effect<Store<T>>; retain?: Duration };\n cacheValue?: boolean;\n}\n\nexport interface StoreOptionsWithMethods<T, Methods extends StoreMethods> extends StoreOptions<T> {\n methods?: Methods & ThisType<Store<T> & Methods & StandardMethods<T>>;\n}\n\nexport type Calculate<T> = (helpers: CalculationActions<T>) => T;\n\ntype StandardMethods<T> =\n T extends Map<any, any>\n ? typeof mapMethods\n : T extends Set<any>\n ? typeof setMethods\n : T extends Array<any>\n ? typeof arrayMethods\n : T extends Record<any, any>\n ? typeof recordMethods\n : Record<string, never>;\n\ntype StoreWithMethods<T, Methods extends StoreMethods> = Store<T> &\n Omit<BoundStoreMethods<T, Methods>, keyof Store<T>> &\n StandardMethods<T>;\n\nexport interface OnceOptions {\n signal?: AbortSignal;\n timeout?: Duration;\n}\n\nfunction noop() {\n return undefined;\n}\n\nexport class Store<T> {\n private static hooks?: Set<(this: Store<any>, store: Store<any>) => void>;\n\n static addHook(hook: (store: Store<any>) => void): DisposableCancel {\n this.hooks ??= new Set();\n this.hooks.add(hook);\n return disposable(() => this.hooks?.delete(hook));\n }\n\n version?: string;\n\n protected calculatedValue?: CalculatedValue<T>;\n protected defaultValue?: CalculatedValue<T>;\n\n protected listeners: Map<Listener, boolean> = new Map();\n\n protected effects: Map<\n Effect<Store<T>>,\n { handle?: Cancel; retain?: number; timeout?: ReturnType<typeof setTimeout> }\n > = new Map();\n\n protected notifyId = {};\n\n constructor(\n public readonly getter: T | Calculate<T>,\n public readonly options: StoreOptions<T> = {},\n public readonly derivedFrom?: {\n store: Store<any>;\n selectors: (Selector<any, any> | AnyPath)[];\n updater: (state: any) => void;\n },\n ) {\n autobind(Store);\n\n if (typeof getter !== 'function') {\n this.calculatedValue = this.defaultValue = staticValue(getter);\n }\n\n for (const hook of Store.hooks ?? []) {\n hook.apply(this, [this]);\n }\n\n if (options.effect instanceof Function) {\n this.addEffect(options.effect);\n } else if (options.effect) {\n this.addEffect(options.effect.effect);\n }\n }\n\n get(): T {\n if (!this.calculatedValue?.check()) {\n this.calculatedValue?.stop();\n this.calculatedValue = undefined;\n }\n\n if (!this.calculatedValue) {\n this.calculatedValue = calculatedValue(this, this.notify);\n }\n\n return this.calculatedValue.value;\n }\n\n set(update: Update<T>): void;\n\n set<const P>(path: Constrain<P, Path<T>>, update: Update<Value<T, P>>): void;\n\n set(...args: any[]): void {\n const path: any = args.length > 1 ? args[0] : [];\n let update: Update<any> = args.length > 1 ? args[1] : args[0];\n\n if (update instanceof Function) {\n const before = this.get();\n const valueBefore = get(before, path);\n const valueAfter = update(valueBefore);\n update = set(before, path, valueAfter);\n } else if (path.length > 0) {\n update = set(this.get(), path, update);\n }\n\n if (this.derivedFrom) {\n this.derivedFrom.updater(update);\n return;\n }\n\n this.calculatedValue?.stop();\n this.calculatedValue = staticValue(update);\n this.notify();\n }\n\n invalidate(recursive?: boolean): void {\n if (recursive) {\n this.calculatedValue?.invalidateDependencies(recursive);\n }\n\n this.calculatedValue?.stop();\n this.calculatedValue = this.defaultValue;\n this.notify();\n }\n\n subscribe(\n listener: Listener<T, { cancel: Cancel }>,\n options?: SubscribeOptions,\n ): DisposableCancel {\n const {\n passive,\n runNow = true,\n throttle: throttleOption,\n debounce: debounceOption,\n equals = this.options.equals ?? deepEqual,\n signal,\n } = options ?? {};\n\n if (signal?.aborted) {\n return disposable(() => {});\n }\n\n let isSetup = false;\n let previousValue: { value: T } | undefined;\n\n let innerListener = () => {\n if (!isSetup) {\n return;\n }\n\n const value = passive ? this.calculatedValue : { value: this.get() };\n\n if (!value) {\n return;\n }\n\n if (previousValue && equals(value.value, previousValue.value)) {\n return;\n }\n\n const _previousValue = previousValue?.value;\n previousValue = this.calculatedValue && { value: this.calculatedValue?.value };\n\n try {\n listener.apply({ cancel }, [value.value, _previousValue]);\n } catch (error) {\n forwardError(error);\n }\n };\n\n if (throttleOption) {\n innerListener = throttle(innerListener, throttleOption);\n } else if (debounceOption) {\n innerListener = debounce(innerListener, debounceOption);\n }\n\n this.listeners.set(innerListener, !passive);\n const cancel = () => {\n if (this.listeners.delete(innerListener) && !passive) {\n this.onUnsubscribe();\n }\n };\n\n if (!passive) {\n this.onSubscribe();\n }\n\n isSetup = true;\n\n if (runNow) {\n innerListener();\n\n if (\n !throttleOption &&\n typeof debounceOption === 'object' &&\n 'waitOnRunNow' in debounceOption &&\n debounceOption.waitOnRunNow === false &&\n 'flush' in innerListener\n ) {\n (innerListener as { flush: () => void }).flush();\n }\n } else {\n previousValue = passive\n ? this.calculatedValue && { value: this.calculatedValue.value }\n : { value: this.get() };\n }\n\n signal?.addEventListener('abort', cancel);\n return disposable(cancel);\n }\n\n once<S extends T>(\n condition: (value: T) => value is S,\n options?: OnceOptions,\n ): PromiseWithCancel<S>;\n\n once(condition: (value: T) => boolean, options?: OnceOptions): PromiseWithCancel<T>;\n\n once(options?: OnceOptions): PromiseWithCancel<Exclude<T, undefined>>;\n\n once(\n ...args: [condition: (value: any) => boolean, options?: OnceOptions] | [options?: OnceOptions]\n ): PromiseWithCancel<any> {\n const condition = args[0] instanceof Function ? args[0] : (x: T) => x !== undefined;\n const options = args[0] instanceof Function ? args[1] : args[0];\n\n return new PromiseWithCancel<T>((resolve, reject, signal) => {\n let stopped = false;\n let timer: ReturnType<typeof setTimeout> | undefined;\n\n const cancel = this.subscribe(\n (value) => {\n if (stopped || !condition(value)) {\n return;\n }\n\n resolve(value);\n stopped = true;\n if (timer) {\n clearTimeout(timer);\n }\n setTimeout(() => cancel());\n },\n {\n runNow: !!condition,\n },\n );\n\n if (stopped) {\n return;\n }\n\n signal.addEventListener('abort', cancel);\n\n options?.signal?.addEventListener('abort', () => {\n cancel();\n reject(options.signal?.reason ?? new Error('cancelled'));\n });\n\n if (options?.timeout !== undefined) {\n timer = setTimeout(() => {\n cancel();\n reject(new Error('timeout'));\n }, calcDuration(options.timeout));\n }\n });\n }\n\n map<S>(selector: Selector<T, S>, updater?: (value: S) => Update<T>): Store<S>;\n\n map<const P>(selector: Constrain<P, SettablePath<T>>): Store<Value<T, P>>;\n\n map(_selector: Selector<T, any> | SettablePath<any>, ...args: any[]): Store<any> {\n const updater: ((value: any) => Update<T>) | undefined =\n _selector instanceof Function\n ? args[0]\n : (value) => (state) => set(state, _selector as any, value);\n\n const selector = makeSelector(_selector);\n\n const derivedFrom = {\n store: this.derivedFrom ? this.derivedFrom.store : this,\n selectors: this.derivedFrom ? [...this.derivedFrom.selectors, _selector] : [_selector],\n\n updater: (value: any) => {\n if (!updater) {\n throw new TypeError(\n 'Can only update computed stores that either are derived from other stores using string selectors or have an updater function.',\n );\n }\n\n let update = updater(value);\n\n if (update instanceof Function) {\n update = update(this.get());\n }\n\n if (this.derivedFrom) {\n this.derivedFrom.updater(update);\n } else {\n this.set(update);\n }\n },\n };\n\n return new Store(\n ({ use }) => {\n return selector(use(this));\n },\n undefined,\n derivedFrom,\n );\n }\n\n /** Add an effect that will be executed when the store becomes active, which means when it has at least one subscriber.\n * @param effect\n * If there is already a subscriber, the effect will be executed immediately.\n * Otherweise it will be executed as soon as the first subscription is created.\n * Every time all subscriptions are removed and the first is created again, the effect will be executed again.\n * @param retain\n * If provided, delay tearing down effects when the last subscriber is removed. This is useful if a short gap in subscriber coverage is supposed to be ignored. E.g. when switching pages, the old page might unsubscribe, while the new page subscribes immediately after.\n * @returns\n * The effect can return a teardown callback, which will be executed when the last subscription is removed and potentially the ratain time has passed.\n */\n addEffect(\n effect: Effect<Store<T>>,\n { retain = this.options.retain, signal }: EffectOptions = {},\n ): DisposableCancel {\n if (signal?.aborted) {\n return disposable(() => {});\n }\n\n this.effects.set(effect, {\n handle: this.isActive() ? (effect.apply(this, [this]) ?? noop) : undefined,\n retain: retain !== undefined ? calcDuration(retain) : undefined,\n });\n\n const cancel = () => {\n const { handle, timeout } = this.effects.get(effect) ?? {};\n handle?.();\n\n if (timeout !== undefined) {\n clearTimeout(timeout);\n }\n\n this.effects.delete(effect);\n };\n\n signal?.addEventListener('abort', cancel);\n return disposable(cancel);\n }\n\n /** Return whether the store is currently active, which means whether it has at least one subscriber. */\n isActive(): boolean {\n return [...this.listeners.values()].some(Boolean);\n }\n\n protected onSubscribe(): void {\n if ([...this.listeners.values()].filter(Boolean).length > 1) return;\n\n for (const [effect, { handle, retain, timeout }] of this.effects.entries()) {\n if (timeout !== undefined) {\n clearTimeout(timeout);\n }\n\n this.effects.set(effect, {\n handle: handle ?? effect.apply(this, [this]) ?? noop,\n retain,\n timeout: undefined,\n });\n }\n }\n\n protected onUnsubscribe(): void {\n if ([...this.listeners.values()].some(Boolean)) return;\n\n for (const [effect, { handle, retain, timeout }] of this.effects.entries()) {\n if (!retain) {\n handle?.();\n\n if (timeout !== undefined) {\n clearTimeout(timeout);\n }\n\n this.effects.set(effect, {\n handle: undefined,\n retain,\n timeout: undefined,\n });\n\n continue;\n }\n\n const newTimeout =\n timeout ??\n (handle\n ? setTimeout(() => {\n handle();\n this.effects.set(effect, {\n handle: undefined,\n retain,\n timeout: undefined,\n });\n }, retain)\n : undefined);\n\n this.effects.set(effect, {\n handle,\n retain,\n timeout: newTimeout,\n });\n }\n }\n\n protected notify(): void {\n const n = {};\n this.notifyId = n;\n\n const snapshot = [...this.listeners.entries()];\n const active = snapshot.filter(([, active]) => active);\n const passive = snapshot.filter(([, active]) => !active);\n for (const [listener] of [...active, ...passive]) {\n listener();\n if (n !== this.notifyId) break;\n }\n }\n}\n\nfunction create<T>(calculate: Calculate<T>, options?: StoreOptions<T>): Store<T>;\nfunction create<T, Methods extends StoreMethods = {}>(\n initialState: T,\n options?: StoreOptionsWithMethods<T, Methods>,\n): StoreWithMethods<T, Methods>;\nfunction create<T, Methods extends StoreMethods>(\n initialState: T | Calculate<T>,\n options?: StoreOptionsWithMethods<T, Methods>,\n): StoreWithMethods<T, Methods> | Store<T> {\n options = { ...createStore.defaultOptions, ...options };\n\n const store = new Store(initialState, options);\n\n if (initialState instanceof Function) {\n return store;\n }\n\n let methods: StoreMethods | undefined = options?.methods;\n\n if (initialState instanceof Map) {\n methods = { ...mapMethods, ...methods };\n } else if (initialState instanceof Set) {\n methods = { ...setMethods, ...methods };\n } else if (Array.isArray(initialState)) {\n methods = { ...arrayMethods, ...methods };\n } else if (isObject(initialState)) {\n methods = { ...recordMethods, ...methods };\n }\n\n const boundMethods = Object.fromEntries(\n Object.entries(methods ?? ({} as BoundStoreMethods<T, any>))\n .filter(([name]) => !(name in store))\n .map(([name, action]) => [name, (action as any).bind(store)]),\n ) as BoundStoreMethods<T, any>;\n\n return Object.assign(store, boundMethods);\n}\n\nexport const createStore: typeof create & { defaultOptions: StoreOptions<any> } =\n /* @__PURE__ */ Object.assign(create, {\n defaultOptions: {\n equals: deepEqual,\n } as StoreOptions<any>,\n });\n"],"mappings":";;;AAAA,MAAM,SAAS,OAAO,UAAU;AAEhC,MAAa,YAGX,WACW;CACX,KAAK,MAAM,OAAO,QAAQ,QAAQ,OAAO,SAAS,GAAG;EACnD,IAAI,QAAQ,eACV;EAGF,MAAM,aAAa,QAAQ,yBAAyB,OAAO,WAAW,GAAG;EACzE,IAAI,SAAS,YAAY,MAAM,KAAK,YAAY;EAChD,IAAI,YAAY;EAEhB,IAAI,OAAO,WAAW,cAAc,OAAO,SACzC;EAGF,QAAQ,eAAe,OAAO,WAAW,KAAK;GAC5C,cAAc;GACd,MAAM;IACJ,IACE,aACA,SAAS,OAAO,aAChB,OAAO,UAAU,eAAe,KAAK,MAAM,GAAG,KAC9C,OAAO,WAAW,YAElB,OAAO;IAGT,MAAM,eAAe,GAAG,SAAgB,QAAQ,MAAM,QAAQ,MAAM,IAAI;IACxE,YAAY,UAAU;IACtB,YAAY;IAEZ,OAAO,eAAe,MAAM,KAAK;KAC/B,cAAc;KACd,MAAM;MACJ,OAAO;KACT;IACF,CAAC;IAED,YAAY;IACZ,OAAO;GACT;GACA,IAAI,GAAG;IACL,SAAS;GACX;EACF,CAAC;CACH;CAEA,OAAO;AACT;;;;ACrDA,IAAa,WAAb,MAAa,iBAA2B,QAAW;CAIjD,cAAc;EACZ,AAAK,OAAO,eAAe,UAAU,OAAO,SAAS,EACnD,OAAO,QACT,CAAC;EAED,MAAM,OAAO,CAAC;EAEd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nC,UAAU;EAAE,GAAG;EAAc,GAAG;CAAQ;MACnC,IAAIE,4BAAS,YAAY,GAC9B,UAAU;EAAE,GAAG;EAAe,GAAG;CAAQ;CAG3C,MAAM,eAAe,OAAO,YAC1B,OAAO,QAAQ,WAAY,CAAC,CAA+B,EACxD,QAAQ,CAAC,UAAU,EAAE,QAAQ,MAAM,EACnC,KAAK,CAAC,MAAM,YAAY,CAAC,MAAO,OAAe,KAAK,KAAK,CAAC,CAAC,CAChE;CAEA,OAAO,OAAO,OAAO,OAAO,YAAY;AAC1C;AAEA,MAAa,cACK,uBAAO,OAAO,QAAQ,EACpC,gBAAgB,EACd,QAAQD,6BACV,EACF,CAAC"}
@@ -1,5 +1,5 @@
1
- import { m as CacheState, r as Cache, t as Scope } from "./scope-8uUaV6I8.cjs";
2
- import { B as Value, C as Selector, K as Constrain, N as Path, T as Update, r as Store, w as SubscribeOptions } from "./store-21GsOOLS.cjs";
1
+ import { B as Selector, C as Value, H as Update, O as Constrain, V as SubscribeOptions, g as Path, r as Store } from "./store-dThvqc0k.js";
2
+ import { r as Cache, t as Scope, u as CacheState } from "./scope-BztVo2P8.js";
3
3
  import { Context, ReactNode } from "react";
4
4
 
5
5
  //#region src/react/useStore.d.ts
@@ -79,7 +79,7 @@ type ScopeProps<T> = {
79
79
  store?: Store<T>;
80
80
  children?: ReactNode;
81
81
  };
82
- declare module ".." {
82
+ declare module "@core" {
83
83
  interface Scope<T> {
84
84
  context?: Context<Store<T>>;
85
85
  }
@@ -120,4 +120,4 @@ declare const storeMethods: {
120
120
  };
121
121
  //#endregion
122
122
  export { useScope as a, UseCacheValue as c, useStore as d, ScopeProvider as i, useCache as l, scopeMethods as n, cacheMethods as o, ScopeProps as r, UseCacheArray as s, storeMethods as t, UseStoreOptions as u };
123
- //# sourceMappingURL=storeMethods-BjuI0joo.d.cts.map
123
+ //# sourceMappingURL=storeMethods-CYX3AAnA.d.ts.map
@@ -1,6 +1,6 @@
1
- const require_store = require('./store-CPqOf4y5.cjs');
2
- const require_propAccess = require('./propAccess-udIdjqwY.cjs');
3
- const require_path = require('./path-Il5r4PV4.cjs');
1
+ const require_store = require('./store-fmAYV5hy.cjs');
2
+ const require_propAccess = require('./propAccess-DdLF12Jq.cjs');
3
+ const require_path = require('./path-B9-Z0127.cjs');
4
4
  let react = require("react");
5
5
  let react_jsx_runtime = require("react/jsx-runtime");
6
6
 
@@ -13,10 +13,10 @@ function trackingProxy(value, equals = require_propAccess.deepEqual) {
13
13
  const revokations = new Array();
14
14
  let revoked = false;
15
15
  function trackComplexProp(function_, ...args) {
16
- const [proxiedValue, equals$1, revoke] = trackingProxy(function_(value, ...args));
16
+ const [proxiedValue, equals, revoke] = trackingProxy(function_(value, ...args));
17
17
  deps.push((otherValue) => {
18
18
  if (!require_propAccess.isPlainObject(otherValue) && !Array.isArray(otherValue)) return false;
19
- return equals$1(function_(otherValue, ...args));
19
+ return equals(function_(otherValue, ...args));
20
20
  });
21
21
  if (revoke) revokations.push(revoke);
22
22
  return proxiedValue;
@@ -55,7 +55,7 @@ function trackingProxy(value, equals = require_propAccess.deepEqual) {
55
55
  return trackSimpleProp(Reflect.isExtensible);
56
56
  }
57
57
  }),
58
- (other) => !!other && deps.every((equals$1) => equals$1(other)),
58
+ (other) => !!other && deps.every((equals) => equals(other)),
59
59
  () => {
60
60
  revoked = true;
61
61
  revokations.forEach((revoke) => revoke());
@@ -113,8 +113,8 @@ function useStore(store, ...args) {
113
113
  let stopped = false;
114
114
  if (withViewTransition && document.startViewTransition) {
115
115
  let lastObservedValue;
116
- _listener = (value$1) => {
117
- const observedValue = withViewTransition instanceof Function ? withViewTransition(value$1) : value$1;
116
+ _listener = (value) => {
117
+ const observedValue = withViewTransition instanceof Function ? withViewTransition(value) : value;
118
118
  if (equals(lastObservedValue, observedValue)) {
119
119
  listener();
120
120
  return;
@@ -194,15 +194,15 @@ function useLoadingBoundary(isLoading, label) {
194
194
  function useCache(cache, { passive, disabled, updateOnMount, withViewTransition, suspense, loadingBoundary, ...options } = {}) {
195
195
  if (withViewTransition === true) withViewTransition = (state) => state.value;
196
196
  const { rootCache, selector } = (0, react.useMemo)(() => {
197
- const rootCache$1 = cache.derivedFromCache?.cache ?? cache;
198
- let selector$1 = (x) => x;
199
- if (cache.derivedFromCache) selector$1 = (value) => {
197
+ const rootCache = cache.derivedFromCache?.cache ?? cache;
198
+ let selector = (x) => x;
199
+ if (cache.derivedFromCache) selector = (value) => {
200
200
  for (const s of cache.derivedFromCache.selectors) value = require_store.makeSelector(s)(value);
201
201
  return value;
202
202
  };
203
203
  return {
204
- rootCache: rootCache$1,
205
- selector: selector$1
204
+ rootCache,
205
+ selector
206
206
  };
207
207
  }, [cache]);
208
208
  const hasMounted = (0, react.useRef)(false);
@@ -441,4 +441,4 @@ Object.defineProperty(exports, 'useStore', {
441
441
  return useStore;
442
442
  }
443
443
  });
444
- //# sourceMappingURL=storeMethods-BZb4k7Ma.cjs.map
444
+ //# sourceMappingURL=storeMethods-DYgUGHSk.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"storeMethods-DYgUGHSk.cjs","names":["deepEqual","isPlainObject","deepEqual","isAnyPath","makeSelector","deepEqual","strictEqual","createStore","makeSelector","isAnyPath","createStore"],"sources":["../src/lib/trackingProxy.ts","../src/react/lib/useMemoEquals.ts","../src/react/useStore.ts","../src/react/loadingBoundary.tsx","../src/react/useCache.ts","../src/react/cacheMethods.ts","../src/react/lib/useLatestRef.ts","../src/react/lib/useLatestFunction.ts","../src/react/useProp.ts","../src/react/scope.tsx","../src/react/scopeMethods.ts","../src/react/storeMethods.ts"],"sourcesContent":["import { deepEqual } from './equals';\nimport { isPlainObject } from '@lib/helpers';\n\nconst unwrapProxySymbol = /* @__PURE__ */ Symbol('unwrapProxy');\n\nexport type TrackingProxy<T> = [value: T, equals: (newValue: T) => boolean, revoke?: () => void];\ntype Object_ = Record<string | symbol, unknown>;\n\nexport function trackingProxy<T>(\n value: T,\n equals: (a: any, b: any) => boolean = deepEqual,\n): TrackingProxy<T> {\n if (!isPlainObject(value) && !Array.isArray(value)) {\n return [value, (other) => equals(value, other)];\n }\n\n // Unpack proxies, we don't want to nest them\n value = (value as any)[unwrapProxySymbol] ?? value;\n\n const deps = new Array<TrackingProxy<any>[1]>();\n const revokations = new Array<() => void>();\n let revoked = false;\n\n function trackComplexProp(function_: any, ...args: any[]) {\n const [proxiedValue, equals, revoke] = trackingProxy(function_(value, ...args));\n\n deps.push((otherValue) => {\n if (!isPlainObject(otherValue) && !Array.isArray(otherValue)) {\n return false;\n }\n\n return equals(function_(otherValue, ...args));\n });\n\n if (revoke) {\n revokations.push(revoke);\n }\n\n return proxiedValue;\n }\n\n function trackSimpleProp(function_: any, ...args: any[]) {\n const calculatedValue = function_(value, ...args);\n\n deps.push((otherValue) => {\n return function_(otherValue, ...args) === calculatedValue;\n });\n\n return calculatedValue;\n }\n\n const proxy = new Proxy(value as T & Object_, {\n get(target, p, receiver) {\n if (p === unwrapProxySymbol) {\n return value;\n }\n\n if (revoked) {\n return target[p];\n }\n\n const { writable, configurable } = Object.getOwnPropertyDescriptor(target, p) ?? {};\n if (writable === false && configurable === false) {\n return target[p];\n }\n\n return trackComplexProp(Reflect.get, p, receiver);\n },\n\n getOwnPropertyDescriptor(target, p) {\n const { writable, configurable } = Object.getOwnPropertyDescriptor(target, p) ?? {};\n if (writable === false && configurable === false) {\n return Reflect.getOwnPropertyDescriptor(target, p);\n }\n\n return trackComplexProp(Reflect.getOwnPropertyDescriptor, p);\n },\n\n ownKeys() {\n return trackComplexProp(Reflect.ownKeys);\n },\n\n getPrototypeOf() {\n return trackSimpleProp(Reflect.getPrototypeOf);\n },\n\n has(_target, p) {\n return trackSimpleProp(Reflect.has, p);\n },\n\n isExtensible() {\n return trackSimpleProp(Reflect.isExtensible);\n },\n });\n\n return [\n proxy,\n (other) => !!other && deps.every((equals) => equals(other)),\n () => {\n revoked = true;\n revokations.forEach((revoke) => revoke());\n },\n ];\n}\n","import { deepEqual } from '@lib/equals';\nimport { useEffect, useRef } from 'react';\n\nexport default function useMemoEquals<T>(value: T, equals: (a: T, b: T) => boolean = deepEqual): T {\n const ref = useRef<{ value: T }>(undefined);\n const hasChanged = !ref.current || !equals(ref.current.value, value);\n\n useEffect(() => {\n if (hasChanged) {\n ref.current = { value };\n }\n });\n\n return hasChanged ? value : ref.current!.value;\n}\n","import type { Selector, SubscribeOptions } from '@core/commonTypes';\nimport type { Store } from '@core/store';\nimport type { Constrain } from '@lib/constrain';\nimport { deepEqual, strictEqual } from '@lib/equals';\nimport { makeSelector } from '@lib/makeSelector';\nimport { isAnyPath, type AnyPath, type Path, type Value } from '@lib/path';\nimport { trackingProxy } from '@lib/trackingProxy';\nimport useMemoEquals from '@react/lib/useMemoEquals';\nimport {\n useCallback,\n useDebugValue,\n useLayoutEffect,\n useMemo,\n useRef,\n useSyncExternalStore,\n} from 'react';\n\nexport interface UseStoreOptions<T> extends Omit<SubscribeOptions, 'runNow' | 'passive'> {\n /**\n * If true, the cache content can be consumed but no fetch will be triggered.\n * @default false\n */\n\n passive?: boolean;\n\n /**\n * (experimental) If true, the a rerender will only be triggered when a property of the returned value changes that was\n * actually accessed during the last render.\n * @default false\n */\n enableTrackingProxy?: boolean;\n\n /**\n * (experimental) If provided, a rerender will be wrapped in a browser view transition.\n */\n withViewTransition?: boolean | ((value: T) => unknown);\n}\n\nexport interface UseStoreOptionsWithSelector<T, S> extends UseStoreOptions<S> {\n /**\n * Equality function to compare the raw store values before reevaluating the selector.\n * Can be used to avoid unnecessary selector evaluations.\n * @default strictEqual\n */\n storeValueEquals?: (newValue: T, oldValue: T) => boolean;\n}\n\nexport function useStore<T, S>(\n store: Store<T>,\n selector: Selector<T, S>,\n option?: UseStoreOptionsWithSelector<T, S>,\n): S;\n\nexport function useStore<T, const P>(\n store: Store<T>,\n selector: Constrain<P, Path<T>>,\n option?: UseStoreOptionsWithSelector<T, Value<T, P>>,\n): Value<T, P>;\n\nexport function useStore<T>(store: Store<T>, option?: UseStoreOptions<T>): T;\n\nexport function useStore<T, S>(\n store: Store<T>,\n ...args:\n | [Selector<T, S> | AnyPath, UseStoreOptionsWithSelector<T, S>?]\n | [UseStoreOptionsWithSelector<T, S>?]\n): S {\n let selectorRaw: Selector<T, S> | AnyPath | undefined;\n let allOptions: UseStoreOptionsWithSelector<T, S>;\n\n if (typeof args[0] === 'function' || isAnyPath(args[0])) {\n selectorRaw = args[0];\n allOptions = args[1] ?? {};\n } else {\n allOptions = args[0] ?? {};\n }\n\n const selectorMemoized = useMemoEquals(selectorRaw);\n const selector = useMemo(() => makeSelector<T, S>(selectorMemoized), [selectorMemoized]);\n const lastEqualsRef = useRef<(newValue: S) => boolean | undefined>(undefined);\n\n const {\n enableTrackingProxy,\n equals = store.options.equals ?? deepEqual,\n withViewTransition,\n storeValueEquals = strictEqual,\n ...options\n } = allOptions;\n\n const snapshot = useRef<{ storeValue: T; selector: (value: T) => S; selectedValue: S }>(\n undefined,\n );\n\n const get = useCallback(() => {\n const storeValue = store.get();\n\n if (\n snapshot.current &&\n storeValueEquals(storeValue, snapshot.current.storeValue) &&\n selector === snapshot.current.selector\n ) {\n return snapshot.current.selectedValue;\n }\n\n const selectedValue = selector(storeValue);\n if (!(lastEqualsRef.current?.(selectedValue) ?? false)) {\n snapshot.current = { storeValue, selector, selectedValue };\n }\n\n return snapshot.current!.selectedValue;\n }, [store, storeValueEquals, selector]);\n\n const rootStore = store.derivedFrom?.store ?? store;\n const subOptions = useMemoEquals({ ...options, runNow: false });\n\n const subscribe = useCallback(\n (listener: () => void) => {\n let _listener: (value: any) => void = listener;\n let stopped = false;\n\n if (withViewTransition && (document as any).startViewTransition) {\n let lastObservedValue: any;\n\n _listener = (value: any) => {\n const observedValue =\n withViewTransition instanceof Function ? withViewTransition(value) : value;\n\n if (equals(lastObservedValue, observedValue)) {\n listener();\n return;\n }\n\n lastObservedValue = observedValue;\n\n let hasChanges = false;\n const mutationObserver = new MutationObserver(() => {\n hasChanges = true;\n mutationObserver.disconnect();\n });\n mutationObserver.observe(document.body, { childList: true, subtree: true });\n\n (document as any).startViewTransition(() => {\n mutationObserver.disconnect();\n\n if (!stopped) {\n listener();\n }\n\n if (!hasChanges) {\n throw new Error('no change');\n }\n });\n };\n }\n\n const cancel = rootStore.subscribe(_listener, subOptions);\n return () => {\n stopped = true;\n cancel();\n };\n },\n [rootStore, withViewTransition, equals, subOptions],\n );\n\n let value = useSyncExternalStore<S>(subscribe, get, get);\n let lastEquals = (newValue: S) => equals(newValue, value);\n let revoke: (() => void) | undefined;\n\n if (enableTrackingProxy) {\n [value, lastEquals, revoke] = trackingProxy(value, equals);\n }\n\n useLayoutEffect(() => {\n lastEqualsRef.current = lastEquals;\n revoke?.();\n });\n\n useDebugValue(value);\n return value;\n}\n","import { createStore } from '@core';\nimport { useStore } from '@react/useStore';\nimport { createContext, useContext, useLayoutEffect, useMemo, type ReactNode } from 'react';\n\nexport interface LoadingBoundaryEntry {\n label?: ReactNode;\n}\n\nexport interface LoadingBoundaryProps {\n /**\n * Fallback node to render when there are loading components within the boundary.\n */\n fallback?: ReactNode | ((entries: LoadingBoundaryEntry[]) => ReactNode);\n\n /**\n * Child node to render when there are no loading components within the boundary.\n */\n children?: ReactNode;\n\n /**\n * Add a loading state from outside the boundary. Useful for when you want to\n * show a loading state for a component that is not a child of the boundary.\n */\n isLoading?: boolean;\n}\n\nconst LoadingBoundaryContext = createContext(createStore(new Set<LoadingBoundaryEntry>()));\n\nexport function LoadingBoundary({\n fallback,\n children,\n isLoading: isLoadingExternal,\n}: LoadingBoundaryProps): React.JSX.Element {\n const store = useMemo(() => createStore(new Set<LoadingBoundaryEntry>()), []);\n const entries = useStore(store);\n const isLoading = entries.size > 0 || isLoadingExternal;\n\n const fallbackNode = isLoading\n ? typeof fallback === 'function'\n ? fallback([...entries])\n : fallback\n : undefined;\n\n return (\n <LoadingBoundaryContext.Provider value={store}>\n {fallbackNode !== undefined ? (\n <>\n {fallbackNode}\n <div style={{ display: 'none' }}>{children}</div>\n </>\n ) : (\n children\n )}\n </LoadingBoundaryContext.Provider>\n );\n}\n\nexport function useLoadingBoundary(isLoading: boolean | undefined, label?: ReactNode): void {\n const store = useContext(LoadingBoundaryContext);\n\n useLayoutEffect(() => {\n if (!isLoading) {\n return;\n }\n\n const entry = { label };\n store.set((entries) => new Set(entries).add(entry));\n\n return () => {\n store.set((entries) => {\n const newEntries = new Set(entries);\n newEntries.delete(entry);\n return newEntries;\n });\n };\n // oxlint-disable-next-line exhaustive-deps\n }, [store, isLoading]);\n}\n","import { useStore, type UseStoreOptions } from './useStore';\nimport type { Cache } from '@core';\nimport type { CacheState } from '@lib/cacheState';\nimport { makeSelector } from '@lib/makeSelector';\nimport { useLoadingBoundary } from '@react/loadingBoundary';\nimport { useEffect, useMemo, useRef } from 'react';\n\nexport type UseCacheArray<T> = [\n value: T | undefined,\n error: unknown | undefined,\n isUpdating: boolean,\n isStale: boolean,\n];\n\nexport type UseCacheValue<T> = UseCacheArray<T> & CacheState<T>;\n\nexport interface UseCacheOptions<T> extends UseStoreOptions<UseCacheArray<T> & CacheState<T>> {\n /**\n * If true, will always return undefined as value and no fetch will be triggered.\n * @default false\n */\n disabled?: boolean;\n\n /**\n * If true, the cache will be invalidated when the component mounts.\n * @default false\n */\n updateOnMount?: boolean;\n\n /**\n * If true, `useCache` will throw a promise when the cache is pending. This can be used with React Suspense.\n * @see https://react.dev/reference/react/Suspense\n * @default false\n */\n suspense?: boolean;\n\n /**\n * If true, `useCache` will register its loading state with the nearest `LoadingBoundary`.\n * @default false\n */\n loadingBoundary?: boolean;\n}\n\nexport function useCache<T>(\n cache: Cache<T, any>,\n {\n passive,\n disabled,\n updateOnMount,\n withViewTransition,\n suspense,\n loadingBoundary,\n ...options\n }: UseCacheOptions<T> = {},\n): UseCacheValue<T> {\n if (withViewTransition === true) {\n withViewTransition = (state) => state.value;\n }\n\n const { rootCache, selector } = useMemo(() => {\n const rootCache: Cache<any, any> = cache.derivedFromCache?.cache ?? cache;\n let selector = (x: any) => x;\n\n if (cache.derivedFromCache) {\n selector = (value: any) => {\n for (const s of cache.derivedFromCache!.selectors) {\n value = makeSelector(s)(value);\n }\n return value;\n };\n }\n\n return { rootCache, selector };\n }, [cache]);\n\n const hasMounted = useRef(false);\n\n useEffect(() => {\n hasMounted.current = true;\n\n if (updateOnMount) {\n rootCache.invalidate();\n }\n // oxlint-disable-next-line exhaustive-deps\n }, []);\n\n const result = useStore(\n rootCache.state,\n (state) => {\n if (disabled) {\n return Object.assign<UseCacheArray<T>, CacheState<T>>(\n [undefined, undefined, false, false],\n { status: 'pending', isUpdating: false, isStale: false, isConnected: false },\n );\n }\n\n const isStale = updateOnMount && !hasMounted.current ? true : state.isStale;\n try {\n const value = state.status === 'value' ? selector(state.value) : undefined;\n\n return Object.assign<UseCacheArray<T>, CacheState<T>>(\n [value, state.error, state.isUpdating, isStale],\n { ...state, value, isStale },\n );\n } catch (error) {\n return Object.assign<UseCacheArray<T>, CacheState<T>>(\n [undefined, error, state.isUpdating, isStale],\n {\n status: 'error',\n error,\n isUpdating: state.isUpdating,\n isStale: isStale,\n isConnected: state.isConnected,\n },\n );\n }\n },\n { ...options, withViewTransition, passive: passive || disabled },\n );\n\n useEffect(\n () => rootCache.subscribe(() => undefined, { passive: passive || disabled }),\n [rootCache, passive, disabled],\n );\n\n useLoadingBoundary(loadingBoundary && !disabled && result.status === 'pending');\n\n if (suspense && result.status === 'pending') {\n throw rootCache.get();\n }\n\n return result;\n}\n","import type { Cache } from '@core';\nimport { type UseCacheOptions, type UseCacheValue, useCache } from '@react/useCache';\n\nexport const cacheMethods = {\n useCache<T>(this: Cache<T, any>, options?: UseCacheOptions<T>): UseCacheValue<T> {\n return useCache(this, options);\n },\n};\n","import { useRef } from 'react';\n\nexport default function useLatestRef<T>(value: T): { current: T } {\n const ref = useRef(value);\n ref.current = value;\n return ref;\n}\n","import useLatestRef from '@react/lib/useLatestRef';\nimport { useCallback } from 'react';\n\nexport default function useLatestFunction<Args extends any[], R>(\n fn: (...args: Args) => R,\n): (...args: Args) => R {\n const ref = useLatestRef(fn);\n\n return useCallback(\n (...args: Args) => {\n return ref.current(...args);\n },\n [ref],\n );\n}\n","import { useStore, type UseStoreOptions } from './useStore';\nimport { type Selector, type Update } from '@core/commonTypes';\nimport type { Store } from '@core/store';\nimport type { Constrain } from '@lib/constrain';\nimport { isAnyPath, type AnyPath, type SettablePath, type Value } from '@lib/path';\nimport useLatestFunction from '@react/lib/useLatestFunction';\n\nexport function useProp<T, S>(\n store: Store<T>,\n selector: Selector<T, S>,\n updater: (value: S) => Update<T>,\n options?: UseStoreOptions<S>,\n): [value: S, setValue: Store<S>['set']];\n\nexport function useProp<T, const P>(\n store: Store<T>,\n selector: Constrain<P, SettablePath<T>>,\n options?: UseStoreOptions<Value<T, P>>,\n): [value: Value<T, P>, setValue: Store<Value<T, P>>['set']];\n\nexport function useProp<T>(\n store: Store<T>,\n options?: UseStoreOptions<T>,\n): [value: T, setValue: Store<T>['set']];\n\nexport function useProp<T, S>(\n store: Store<T>,\n ...args:\n | [Selector<T, S>, (value: S) => Update<T>, UseStoreOptions<S>?]\n | [AnyPath, UseStoreOptions<Value<T, any>>?]\n | [UseStoreOptions<S>?]\n): [value: S, setValue: Store<S>['set']] {\n let selector: Selector<T, S> | AnyPath | undefined;\n let updater: ((value: S) => Update<T>) | undefined;\n let options: UseStoreOptions<S> | undefined;\n\n if (typeof args[0] === 'function' || isAnyPath(args[0])) {\n selector = args[0];\n if (typeof args[1] === 'function') {\n updater = args[1];\n options = args[2];\n } else {\n options = args[1];\n }\n } else {\n options = args[0];\n }\n\n const value = useStore(store, (selector ?? ((x) => x)) as Selector<T, S>, options);\n\n const update = useLatestFunction((update) => {\n let _store: Store<any> = store;\n if (selector) {\n _store = _store.map(selector as Selector<any, any>, updater);\n }\n\n _store.set(update);\n });\n\n return [value, update];\n}\n","import { useProp } from './useProp';\nimport { useStore, type UseStoreOptions } from './useStore';\nimport type { Scope, Selector, Update } from '@core';\nimport { createStore, type Store } from '@core/store';\nimport type { Constrain } from '@lib/constrain';\nimport type { Path, Value } from '@lib/path';\nimport { createContext, useContext, useMemo, type Context, type ReactNode } from 'react';\n\nexport type ScopeProps<T> = { scope: Scope<T>; store?: Store<T>; children?: ReactNode };\n\ndeclare module '@core' {\n interface Scope<T> {\n context?: Context<Store<T>>;\n }\n}\n\nfunction getScopeContext<T>(scope: Scope<T>): Context<Store<T>> {\n scope.context ??= createContext<Store<T>>(createStore(scope.defaultValue));\n return scope.context;\n}\n\nexport function ScopeProvider<T>({\n scope,\n store: inputStore,\n children,\n}: ScopeProps<T>): React.JSX.Element {\n const context = getScopeContext(scope);\n const currentStore = useMemo(\n () => inputStore ?? createStore(scope.defaultValue),\n [scope, inputStore],\n );\n\n return <context.Provider value={currentStore}>{children}</context.Provider>;\n}\n\nexport function useScope<T>(scope: Scope<T>): Store<T> {\n const context = getScopeContext(scope);\n return useContext(context);\n}\n\nexport function useScopeStore<T, S>(\n scope: Scope<T>,\n selector: Selector<T, S>,\n option?: UseStoreOptions<S>,\n): S;\n\nexport function useScopeStore<T, const P>(\n scope: Scope<T>,\n selector: Constrain<P, Path<T>>,\n option?: UseStoreOptions<Value<T, P>>,\n): Value<T, P>;\n\nexport function useScopeStore<T>(scope: Scope<T>, option?: UseStoreOptions<T>): T;\n\nexport function useScopeStore<T>(scope: Scope<T>, ...args: any[]): T {\n const store = useScope(scope);\n return useStore(store, ...args);\n}\n\nexport function useScopeProp<T, S>(\n scope: Scope<T>,\n selector: Selector<T, S>,\n updater: (value: S) => Update<T>,\n options?: UseStoreOptions<S>,\n): [value: S, setValue: Store<S>['set']];\n\nexport function useScopeProp<T, const P>(\n scope: Scope<T>,\n selector: Constrain<P, Path<T>>,\n options?: UseStoreOptions<Value<T, P>>,\n): [value: Value<T, P>, setValue: Store<Value<T, P>>['set']];\n\nexport function useScopeProp<T>(\n scope: Scope<T>,\n options?: UseStoreOptions<T>,\n): [value: T, setValue: Store<T>['set']];\n\nexport function useScopeProp<T>(\n scope: Scope<T>,\n ...args: any[]\n): [value: T, setValue: Store<T>['set']] {\n const store = useScope(scope);\n return useProp(store, ...args);\n}\n","import type { Scope, Selector, Store, Update } from '@core';\nimport type { Constrain } from '@lib/constrain';\nimport type { Path, Value } from '@lib/path';\nimport {\n ScopeProvider,\n useScope,\n useScopeProp,\n useScopeStore,\n type ScopeProps,\n} from '@react/scope';\nimport type { UseStoreOptions } from '@react/useStore';\n\nfunction boundUseScope<T>(this: Scope<T>): Store<T> {\n return useScope(this);\n}\n\nfunction boundUseScopeStore<T, S>(\n this: Scope<T>,\n selector: Selector<T, S>,\n option?: UseStoreOptions<S>,\n): S;\n\nfunction boundUseScopeStore<T, const P>(\n this: Scope<T>,\n selector: Constrain<P, Path<T>>,\n option?: UseStoreOptions<Value<T, P>>,\n): Value<T, P>;\n\nfunction boundUseScopeStore<T>(this: Scope<T>, option?: UseStoreOptions<T>): T;\n\nfunction boundUseScopeStore(this: Scope<any>, ...args: any[]) {\n return useScopeStore(this, ...args);\n}\n\nfunction boundUseScopeProp<T, S>(\n this: Scope<T>,\n selector: Selector<T, S>,\n updater: (value: S) => Update<T>,\n options?: UseStoreOptions<S>,\n): [value: S, setValue: Store<S>['set']];\n\nfunction boundUseScopeProp<T, const P>(\n this: Scope<T>,\n selector: Constrain<P, Path<T>>,\n options?: UseStoreOptions<Value<T, P>>,\n): [value: Value<T, P>, setValue: Store<Value<T, P>>['set']];\n\nfunction boundUseScopeProp<T>(\n this: Scope<T>,\n options?: UseStoreOptions<T>,\n): [value: T, setValue: Store<T>['set']];\n\nfunction boundUseScopeProp(this: Scope<any>, ...args: any[]) {\n return useScopeProp(this, ...args);\n}\n\nfunction Provider<T>(this: Scope<T>, props: Omit<ScopeProps<T>, 'scope'>): React.JSX.Element {\n return ScopeProvider({ ...props, scope: this });\n}\n\nexport const scopeMethods: {\n useScope: typeof boundUseScope;\n useStore: typeof boundUseScopeStore;\n useProp: typeof boundUseScopeProp;\n Provider: typeof Provider;\n} = {\n useScope: boundUseScope,\n useStore: boundUseScopeStore,\n useProp: boundUseScopeProp,\n Provider,\n};\n","import type { Selector, Store, Update } from '@core';\nimport type { Constrain } from '@lib/constrain';\nimport type { Path, Value } from '@lib/path';\nimport { useProp } from '@react/useProp';\nimport { type UseStoreOptions, useStore } from '@react/useStore';\n\nfunction boundUseStore<T, S>(\n this: Store<T>,\n selector: Selector<T, S>,\n option?: UseStoreOptions<S>,\n): S;\nfunction boundUseStore<T, const P>(\n this: Store<T>,\n selector: Constrain<P, Path<T>>,\n option?: UseStoreOptions<Value<T, P>>,\n): Value<T, P>;\nfunction boundUseStore<T>(this: Store<T>, option?: UseStoreOptions<T>): T;\nfunction boundUseStore(this: Store<any>, ...args: any[]) {\n return useStore(this, ...args);\n}\n\nfunction boundUseProp<T, S>(\n this: Store<T>,\n selector: Selector<T, S>,\n updater: (value: S) => Update<T>,\n options?: UseStoreOptions<S>,\n): [value: S, setValue: Store<S>['set']];\nfunction boundUseProp<T, const P>(\n this: Store<T>,\n selector: Constrain<P, Path<T>>,\n options?: UseStoreOptions<Value<T, P>>,\n): [value: Value<T, P>, setValue: Store<Value<T, P>>['set']];\nfunction boundUseProp<T>(\n this: Store<T>,\n options?: UseStoreOptions<T>,\n): [value: T, setValue: Store<T>['set']];\nfunction boundUseProp(this: Store<any>, ...args: any[]) {\n return useProp(this, ...args);\n}\n\nexport const storeMethods: {\n useStore: typeof boundUseStore;\n useProp: typeof boundUseProp;\n} = {\n useStore: boundUseStore,\n useProp: boundUseProp,\n};\n"],"mappings":";;;;;;;AAGA,MAAM,oBAAoC,uBAAO,aAAa;AAK9D,SAAgB,cACd,OACA,SAAsCA,8BACpB;CAClB,IAAI,CAACC,iCAAc,KAAK,KAAK,CAAC,MAAM,QAAQ,KAAK,GAC/C,OAAO,CAAC,QAAQ,UAAU,OAAO,OAAO,KAAK,CAAC;CAIhD,QAAS,MAAc,sBAAsB;CAE7C,MAAM,OAAO,IAAI,MAA6B;CAC9C,MAAM,cAAc,IAAI,MAAkB;C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;CAC3F,OAAO,cAAc;EAAE,GAAG;EAAO,OAAO;CAAK,CAAC;AAChD;AAEA,MAAa,eAKT;CACF,UAAU;CACV,UAAU;CACV,SAAS;CACT;AACF;;;;ACrDA,SAAS,cAAgC,GAAG,MAAa;CACvD,OAAO,SAAS,MAAM,GAAG,IAAI;AAC/B;AAiBA,SAAS,aAA+B,GAAG,MAAa;CACtD,OAAO,QAAQ,MAAM,GAAG,IAAI;AAC9B;AAEA,MAAa,eAGT;CACF,UAAU;CACV,SAAS;AACX"}
@@ -1,5 +1,5 @@
1
- import { m as CacheState, r as Cache, t as Scope } from "./scope-qdOAlRWQ.js";
2
- import { B as Value, C as Selector, K as Constrain, N as Path, T as Update, r as Store, w as SubscribeOptions } from "./store-Cq1PqvEo.js";
1
+ import { B as Selector, C as Value, H as Update, O as Constrain, V as SubscribeOptions, g as Path, r as Store } from "./store-dThvqc0k.cjs";
2
+ import { r as Cache, t as Scope, u as CacheState } from "./scope-BQjncWGt.cjs";
3
3
  import { Context, ReactNode } from "react";
4
4
 
5
5
  //#region src/react/useStore.d.ts
@@ -79,7 +79,7 @@ type ScopeProps<T> = {
79
79
  store?: Store<T>;
80
80
  children?: ReactNode;
81
81
  };
82
- declare module ".." {
82
+ declare module "@core" {
83
83
  interface Scope<T> {
84
84
  context?: Context<Store<T>>;
85
85
  }
@@ -120,4 +120,4 @@ declare const storeMethods: {
120
120
  };
121
121
  //#endregion
122
122
  export { useScope as a, UseCacheValue as c, useStore as d, ScopeProvider as i, useCache as l, scopeMethods as n, cacheMethods as o, ScopeProps as r, UseCacheArray as s, storeMethods as t, UseStoreOptions as u };
123
- //# sourceMappingURL=storeMethods-CK9-Q17H.d.ts.map
123
+ //# sourceMappingURL=storeMethods-DrMQ7hqX.d.cts.map
@@ -1,6 +1,6 @@
1
- import { l as makeSelector, n as createStore } from "./store-D4q5zD7q.js";
2
- import { c as deepEqual, s as isPlainObject, u as strictEqual } from "./propAccess-BxCKNeOj.js";
3
- import { t as isAnyPath } from "./path-CCEtQjMB.js";
1
+ import { c as makeSelector, n as createStore } from "./store-BmlnyYal.js";
2
+ import { c as deepEqual, s as isPlainObject, u as strictEqual } from "./propAccess-CsUaG5V_.js";
3
+ import { t as isAnyPath } from "./path-C-5jTZu5.js";
4
4
  import { createContext, useCallback, useContext, useDebugValue, useEffect, useLayoutEffect, useMemo, useRef, useSyncExternalStore } from "react";
5
5
  import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
6
6
 
@@ -13,10 +13,10 @@ function trackingProxy(value, equals = deepEqual) {
13
13
  const revokations = new Array();
14
14
  let revoked = false;
15
15
  function trackComplexProp(function_, ...args) {
16
- const [proxiedValue, equals$1, revoke] = trackingProxy(function_(value, ...args));
16
+ const [proxiedValue, equals, revoke] = trackingProxy(function_(value, ...args));
17
17
  deps.push((otherValue) => {
18
18
  if (!isPlainObject(otherValue) && !Array.isArray(otherValue)) return false;
19
- return equals$1(function_(otherValue, ...args));
19
+ return equals(function_(otherValue, ...args));
20
20
  });
21
21
  if (revoke) revokations.push(revoke);
22
22
  return proxiedValue;
@@ -55,7 +55,7 @@ function trackingProxy(value, equals = deepEqual) {
55
55
  return trackSimpleProp(Reflect.isExtensible);
56
56
  }
57
57
  }),
58
- (other) => !!other && deps.every((equals$1) => equals$1(other)),
58
+ (other) => !!other && deps.every((equals) => equals(other)),
59
59
  () => {
60
60
  revoked = true;
61
61
  revokations.forEach((revoke) => revoke());
@@ -113,8 +113,8 @@ function useStore(store, ...args) {
113
113
  let stopped = false;
114
114
  if (withViewTransition && document.startViewTransition) {
115
115
  let lastObservedValue;
116
- _listener = (value$1) => {
117
- const observedValue = withViewTransition instanceof Function ? withViewTransition(value$1) : value$1;
116
+ _listener = (value) => {
117
+ const observedValue = withViewTransition instanceof Function ? withViewTransition(value) : value;
118
118
  if (equals(lastObservedValue, observedValue)) {
119
119
  listener();
120
120
  return;
@@ -194,15 +194,15 @@ function useLoadingBoundary(isLoading, label) {
194
194
  function useCache(cache, { passive, disabled, updateOnMount, withViewTransition, suspense, loadingBoundary, ...options } = {}) {
195
195
  if (withViewTransition === true) withViewTransition = (state) => state.value;
196
196
  const { rootCache, selector } = useMemo(() => {
197
- const rootCache$1 = cache.derivedFromCache?.cache ?? cache;
198
- let selector$1 = (x) => x;
199
- if (cache.derivedFromCache) selector$1 = (value) => {
197
+ const rootCache = cache.derivedFromCache?.cache ?? cache;
198
+ let selector = (x) => x;
199
+ if (cache.derivedFromCache) selector = (value) => {
200
200
  for (const s of cache.derivedFromCache.selectors) value = makeSelector(s)(value);
201
201
  return value;
202
202
  };
203
203
  return {
204
- rootCache: rootCache$1,
205
- selector: selector$1
204
+ rootCache,
205
+ selector
206
206
  };
207
207
  }, [cache]);
208
208
  const hasMounted = useRef(false);
@@ -370,4 +370,4 @@ const storeMethods = {
370
370
 
371
371
  //#endregion
372
372
  export { useProp as a, useCache as c, useStore as d, useMemoEquals as f, useScope as i, LoadingBoundary as l, scopeMethods as n, useLatestFunction as o, ScopeProvider as r, cacheMethods as s, storeMethods as t, useLoadingBoundary as u };
373
- //# sourceMappingURL=storeMethods-CWeGkXoz.js.map
373
+ //# sourceMappingURL=storeMethods-pGlt0zfb.js.map