mhz-helpers 1.4.15 → 1.4.16

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.
@@ -443,7 +443,7 @@ var fe = class {
443
443
  }
444
444
  setData(e, t) {
445
445
  let n = E(this.state.data, e, this.options);
446
- return this.#s({
446
+ return this.#c({
447
447
  data: n,
448
448
  type: "success",
449
449
  dataUpdatedAt: t?.updatedAt,
@@ -451,7 +451,7 @@ var fe = class {
451
451
  }), n;
452
452
  }
453
453
  setState(e, t) {
454
- this.#s({
454
+ this.#c({
455
455
  type: "setState",
456
456
  state: e,
457
457
  setStateOptions: t
@@ -464,14 +464,20 @@ var fe = class {
464
464
  destroy() {
465
465
  super.destroy(), this.cancel({ silent: !0 });
466
466
  }
467
+ get resetState() {
468
+ return this.#e;
469
+ }
467
470
  reset() {
468
- this.destroy(), this.setState(this.#e);
471
+ this.destroy(), this.setState(this.resetState);
469
472
  }
470
473
  isActive() {
471
474
  return this.observers.some((e) => _(e.options.enabled, this) !== !1);
472
475
  }
473
476
  isDisabled() {
474
- return this.getObserversCount() > 0 ? !this.isActive() : this.options.queryFn === D || this.state.dataUpdateCount + this.state.errorUpdateCount === 0;
477
+ return this.getObserversCount() > 0 ? !this.isActive() : this.options.queryFn === D || !this.isFetched();
478
+ }
479
+ isFetched() {
480
+ return this.state.dataUpdateCount + this.state.errorUpdateCount > 0;
475
481
  }
476
482
  isStatic() {
477
483
  return this.getObserversCount() > 0 ? this.observers.some((e) => g(e.options.staleTime, this) === "static") : !1;
@@ -496,7 +502,7 @@ var fe = class {
496
502
  }));
497
503
  }
498
504
  removeObserver(e) {
499
- this.observers.includes(e) && (this.observers = this.observers.filter((t) => t !== e), this.observers.length || (this.#i && (this.#o ? this.#i.cancel({ revert: !0 }) : this.#i.cancelRetry()), this.scheduleGc()), this.#n.notify({
505
+ this.observers.includes(e) && (this.observers = this.observers.filter((t) => t !== e), this.observers.length || (this.#i && (this.#o || this.#s() ? this.#i.cancel({ revert: !0 }) : this.#i.cancelRetry()), this.scheduleGc()), this.#n.notify({
500
506
  type: "observerRemoved",
501
507
  query: this,
502
508
  observer: e
@@ -505,8 +511,11 @@ var fe = class {
505
511
  getObserversCount() {
506
512
  return this.observers.length;
507
513
  }
514
+ #s() {
515
+ return this.state.fetchStatus === "paused" && this.state.status === "pending";
516
+ }
508
517
  invalidate() {
509
- this.state.isInvalidated || this.#s({ type: "invalidate" });
518
+ this.state.isInvalidated || this.#c({ type: "invalidate" });
510
519
  }
511
520
  async fetch(e, t) {
512
521
  if (this.state.fetchStatus !== "idle" && this.#i?.status() !== "rejected") {
@@ -544,7 +553,7 @@ var fe = class {
544
553
  };
545
554
  return r(e), e;
546
555
  })();
547
- this.options.behavior?.onFetch(a, this), this.#t = this.state, (this.state.fetchStatus === "idle" || this.state.fetchMeta !== a.fetchOptions?.meta) && this.#s({
556
+ this.options.behavior?.onFetch(a, this), this.#t = this.state, (this.state.fetchStatus === "idle" || this.state.fetchMeta !== a.fetchOptions?.meta) && this.#c({
548
557
  type: "fetch",
549
558
  meta: a.fetchOptions?.meta
550
559
  }), this.#i = de({
@@ -557,17 +566,17 @@ var fe = class {
557
566
  }), n.abort();
558
567
  },
559
568
  onFail: (e, t) => {
560
- this.#s({
569
+ this.#c({
561
570
  type: "failed",
562
571
  failureCount: e,
563
572
  error: t
564
573
  });
565
574
  },
566
575
  onPause: () => {
567
- this.#s({ type: "pause" });
576
+ this.#c({ type: "pause" });
568
577
  },
569
578
  onContinue: () => {
570
- this.#s({ type: "continue" });
579
+ this.#c({ type: "continue" });
571
580
  },
572
581
  retry: a.options.retry,
573
582
  retryDelay: a.options.retryDelay,
@@ -586,7 +595,7 @@ var fe = class {
586
595
  return this.state.data;
587
596
  }
588
597
  }
589
- throw this.#s({
598
+ throw this.#c({
590
599
  type: "error",
591
600
  error: e
592
601
  }), this.#n.config.onError?.(e, this), this.#n.config.onSettled?.(this.state.data, e, this), e;
@@ -594,7 +603,7 @@ var fe = class {
594
603
  this.scheduleGc();
595
604
  }
596
605
  }
597
- #s(e) {
606
+ #c(e) {
598
607
  this.state = ((t) => {
599
608
  switch (e.type) {
600
609
  case "failed": return {
@@ -847,7 +856,7 @@ var ge = class extends o {
847
856
  failureCount: l.fetchFailureCount,
848
857
  failureReason: l.fetchFailureReason,
849
858
  errorUpdateCount: l.errorUpdateCount,
850
- isFetched: l.dataUpdateCount > 0 || l.errorUpdateCount > 0,
859
+ isFetched: e.isFetched(),
851
860
  isFetchedAfterMount: l.dataUpdateCount > s.dataUpdateCount || l.errorUpdateCount > s.errorUpdateCount,
852
861
  isFetching: g,
853
862
  isRefetching: g && !v,
@@ -12,7 +12,7 @@ function f(...e) {
12
12
  }
13
13
  function p(e, t = !1, n = "Timeout") {
14
14
  return new Promise((r, i) => {
15
- t ? setTimeout(() => i(n), e) : setTimeout(r, e);
15
+ setTimeout(t ? () => i(n) : r, e);
16
16
  });
17
17
  }
18
18
  function m(e, t = !1) {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "mhz-helpers",
3
3
  "description": "Mhz helpers and composables",
4
- "version": "1.4.15",
4
+ "version": "1.4.16",
5
5
  "author": "Alexandr Dergunov <dergunovs@mail.ru> (https://github.com/dergunovs)",
6
6
  "license": "MIT",
7
7
  "type": "module",
@@ -24,13 +24,13 @@
24
24
  "test:cov": "vitest run --coverage"
25
25
  },
26
26
  "dependencies": {
27
- "@tanstack/vue-query": "5.92.10",
27
+ "@tanstack/vue-query": "5.92.12",
28
28
  "@vueuse/core": "14.2.1",
29
29
  "@vueuse/integrations": "14.2.1",
30
30
  "async-validator": "4.2.5",
31
31
  "axios": "1.13.6",
32
32
  "vue": "3.6.0-beta.8",
33
- "vue-router": "5.0.3"
33
+ "vue-router": "5.0.4"
34
34
  },
35
35
  "devDependencies": {
36
36
  "@eslint/js": "10.0.1",
@@ -49,7 +49,7 @@
49
49
  "happy-dom": "20.8.4",
50
50
  "postcss-html": "1.8.1",
51
51
  "prettier": "3.8.1",
52
- "stylelint": "17.4.0",
52
+ "stylelint": "17.5.0",
53
53
  "stylelint-config-recess-order": "7.7.0",
54
54
  "stylelint-config-recommended-scss": "17.0.0",
55
55
  "stylelint-config-recommended-vue": "1.6.1",
@@ -57,7 +57,7 @@
57
57
  "stylelint-prettier": "5.0.3",
58
58
  "typescript": "5.9.3",
59
59
  "typescript-eslint": "8.57.1",
60
- "vite": "8.0.0",
60
+ "vite": "8.0.1",
61
61
  "vite-plugin-dts": "4.5.4",
62
62
  "vitest": "4.1.0",
63
63
  "vue-eslint-parser": "10.4.0",
@@ -66,7 +66,7 @@
66
66
  },
67
67
  "peerDependencies": {
68
68
  "vue": "3.6.0-beta.8",
69
- "vue-router": "5.0.3"
69
+ "vue-router": "5.0.4"
70
70
  },
71
71
  "engines": {
72
72
  "npm": ">=11.7.0",