@pinia/colada-plugin-retry 0.2.1 → 0.2.3

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.
package/dist/index.d.mts CHANGED
@@ -1,7 +1,7 @@
1
+ import { ShallowRef } from "vue";
1
2
  import { PiniaColadaPluginContext } from "@pinia/colada";
2
3
 
3
4
  //#region src/retry.d.ts
4
-
5
5
  /**
6
6
  * Options for the Pinia Colada Retry plugin.
7
7
  */
@@ -40,6 +40,30 @@ declare module '@pinia/colada' {
40
40
  */
41
41
  retry?: RetryOptions | Exclude<RetryOptions['retry'], undefined>;
42
42
  }
43
+ interface UseQueryEntryExtensions<TData, TError, TDataInitial> {
44
+ /**
45
+ * Whether the query is currently retrying. Requires the `@pinia/colada-plugin-retry` plugin.
46
+ */
47
+ isRetrying: ShallowRef<boolean>;
48
+ /**
49
+ * The number of retries that have been scheduled so far. Resets on success or manual refetch.
50
+ * Requires the `@pinia/colada-plugin-retry` plugin.
51
+ */
52
+ retryCount: ShallowRef<number>;
53
+ /**
54
+ * The error that triggered the current retry. `null` when not retrying or when retries are exhausted.
55
+ * Requires the `@pinia/colada-plugin-retry` plugin.
56
+ */
57
+ retryError: ShallowRef<TError | null>;
58
+ /**
59
+ * Plain object with retry state for devtools. Only present in development mode.
60
+ */
61
+ retry?: {
62
+ isRetrying: boolean;
63
+ retryCount: number;
64
+ retryError: unknown;
65
+ };
66
+ }
43
67
  }
44
68
  //#endregion
45
69
  export { PiniaColadaRetry, RetryEntry, RetryOptions };
package/dist/index.mjs CHANGED
@@ -1,14 +1,14 @@
1
- import { toValue } from "vue";
1
+ import { shallowRef, toValue } from "vue";
2
2
 
3
3
  //#region src/retry.ts
4
4
  const RETRY_OPTIONS_DEFAULTS = {
5
5
  delay: (attempt) => {
6
6
  const time = Math.min(2 ** attempt * 1e3, 3e4);
7
- if (process.env.NODE_ENV === "development") console.log(`⏲️ delaying attempt #${attempt + 1} by ${time}ms`);
7
+ if (process.env.NODE_ENV === "development") console.debug(`⏲️ delaying attempt #${attempt + 1} by ${time}ms`);
8
8
  return time;
9
9
  },
10
10
  retry: (count) => {
11
- if (process.env.NODE_ENV === "development") console.log(`🔄 Retrying ${"🟨".repeat(count + 1)}${"⬜️".repeat(2 - count)}`);
11
+ if (process.env.NODE_ENV === "development") console.debug(`🔄 Retrying ${"🟨".repeat(count + 1)}${"⬜️".repeat(2 - count)}`);
12
12
  return count < 2;
13
13
  }
14
14
  };
@@ -22,17 +22,31 @@ function PiniaColadaRetry(globalOptions) {
22
22
  ...RETRY_OPTIONS_DEFAULTS,
23
23
  ...globalOptions
24
24
  };
25
- return ({ queryCache }) => {
25
+ return ({ queryCache, scope }) => {
26
26
  const retryMap = /* @__PURE__ */ new Map();
27
27
  let isInternalCall = false;
28
28
  queryCache.$onAction(({ name, args, after, onError }) => {
29
+ if (name === "extend") {
30
+ const [entry] = args;
31
+ scope.run(() => {
32
+ entry.ext.isRetrying = shallowRef(false);
33
+ entry.ext.retryCount = shallowRef(0);
34
+ entry.ext.retryError = shallowRef(null);
35
+ });
36
+ if (process.env.NODE_ENV === "development") entry.ext.retry = {
37
+ isRetrying: false,
38
+ retryCount: 0,
39
+ retryError: null
40
+ };
41
+ return;
42
+ }
29
43
  if (name === "remove") {
30
44
  const [cacheEntry] = args;
31
- const key$1 = cacheEntry.key.join("/");
32
- const entry = retryMap.get(key$1);
45
+ const key = cacheEntry.key.join("/");
46
+ const entry = retryMap.get(key);
33
47
  if (entry) {
34
48
  clearTimeout(entry.timeoutId);
35
- retryMap.delete(key$1);
49
+ retryMap.delete(key);
36
50
  }
37
51
  }
38
52
  if (name !== "fetch") return;
@@ -44,7 +58,18 @@ function PiniaColadaRetry(globalOptions) {
44
58
  if (retry === 0) return;
45
59
  const key = queryEntry.key.join("/");
46
60
  clearTimeout(retryMap.get(key)?.timeoutId);
47
- if (!isInternalCall) retryMap.delete(key);
61
+ if (!isInternalCall) {
62
+ retryMap.delete(key);
63
+ queryEntry.ext.isRetrying.value = false;
64
+ queryEntry.ext.retryCount.value = 0;
65
+ queryEntry.ext.retryError.value = null;
66
+ if (process.env.NODE_ENV === "development" && queryEntry.ext.retry) {
67
+ queryEntry.ext.retry.isRetrying = false;
68
+ queryEntry.ext.retry.retryCount = 0;
69
+ queryEntry.ext.retry.retryError = null;
70
+ }
71
+ }
72
+ const previousState = queryEntry.state.value;
48
73
  const retryFetch = () => {
49
74
  if (queryEntry.state.value.status === "error") {
50
75
  const error = queryEntry.state.value.error;
@@ -54,10 +79,27 @@ function PiniaColadaRetry(globalOptions) {
54
79
  retryMap.set(key, entry);
55
80
  }
56
81
  if (typeof retry === "number" ? retry > entry.retryCount : retry(entry.retryCount, error)) {
82
+ queryEntry.ext.isRetrying.value = true;
83
+ queryEntry.ext.retryCount.value = entry.retryCount + 1;
84
+ queryEntry.ext.retryError.value = error;
85
+ if (process.env.NODE_ENV === "development" && queryEntry.ext.retry) {
86
+ queryEntry.ext.retry.isRetrying = true;
87
+ queryEntry.ext.retry.retryCount = entry.retryCount + 1;
88
+ queryEntry.ext.retry.retryError = error;
89
+ }
90
+ queryEntry.state.value = previousState;
57
91
  const delayTime = typeof delay === "function" ? delay(entry.retryCount) : delay;
58
92
  entry.timeoutId = setTimeout(() => {
59
93
  if (!queryEntry.active || toValue(queryEntry.options?.enabled) === false) {
60
94
  retryMap.delete(key);
95
+ queryEntry.ext.isRetrying.value = false;
96
+ queryEntry.ext.retryCount.value = 0;
97
+ queryEntry.ext.retryError.value = null;
98
+ if (process.env.NODE_ENV === "development" && queryEntry.ext.retry) {
99
+ queryEntry.ext.retry.isRetrying = false;
100
+ queryEntry.ext.retry.retryCount = 0;
101
+ queryEntry.ext.retry.retryError = null;
102
+ }
61
103
  return;
62
104
  }
63
105
  isInternalCall = true;
@@ -65,8 +107,26 @@ function PiniaColadaRetry(globalOptions) {
65
107
  isInternalCall = false;
66
108
  if (entry) entry.retryCount++;
67
109
  }, delayTime);
68
- } else retryMap.delete(key);
69
- } else retryMap.delete(key);
110
+ } else {
111
+ queryEntry.ext.isRetrying.value = false;
112
+ queryEntry.ext.retryError.value = null;
113
+ retryMap.delete(key);
114
+ if (process.env.NODE_ENV === "development" && queryEntry.ext.retry) {
115
+ queryEntry.ext.retry.isRetrying = false;
116
+ queryEntry.ext.retry.retryError = null;
117
+ }
118
+ }
119
+ } else {
120
+ queryEntry.ext.isRetrying.value = false;
121
+ queryEntry.ext.retryCount.value = 0;
122
+ queryEntry.ext.retryError.value = null;
123
+ retryMap.delete(key);
124
+ if (process.env.NODE_ENV === "development" && queryEntry.ext.retry) {
125
+ queryEntry.ext.retry.isRetrying = false;
126
+ queryEntry.ext.retry.retryCount = 0;
127
+ queryEntry.ext.retry.retryError = null;
128
+ }
129
+ }
70
130
  };
71
131
  onError(retryFetch);
72
132
  after(retryFetch);
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":["key"],"sources":["../src/retry.ts"],"sourcesContent":["/**\n * Pinia Colada Retry plugin.\n *\n * Adds the ability to retry failed queries.\n *\n * @module @pinia/colada-plugin-retry\n */\nimport type { PiniaColadaPluginContext } from '@pinia/colada'\nimport { toValue } from 'vue'\n\n/**\n * Options for the Pinia Colada Retry plugin.\n */\nexport interface RetryOptions {\n /**\n * The delay between retries. Can be a duration in ms or a function that\n * receives the attempt number (starts at 0) and returns a duration in ms. By\n * default, it will wait 2^attempt * 1000 ms, but never more than 30 seconds.\n *\n * @param attempt -\n * @returns\n */\n delay?: number | ((attempt: number) => number)\n\n /**\n * The maximum number of times to retry the operation. Set to 0 to disable or\n * to Infinity to retry forever. It can also be a function that receives the\n * failure count and the error and returns if it should retry. Defaults to 3.\n * **Must be a positive number**.\n */\n retry?: number | ((failureCount: number, error: unknown) => boolean)\n}\n\nexport interface RetryEntry {\n retryCount: number\n timeoutId?: ReturnType<typeof setTimeout>\n}\n\nconst RETRY_OPTIONS_DEFAULTS = {\n delay: (attempt: number) => {\n const time = Math.min(\n 2 ** attempt * 1000,\n // never more than 30 seconds\n 30_000,\n )\n if (process.env.NODE_ENV === 'development') {\n // oxlint-disable-next-line no-console\n console.log(`⏲️ delaying attempt #${attempt + 1} by ${time}ms`)\n }\n return time\n },\n retry: (count) => {\n if (process.env.NODE_ENV === 'development') {\n // oxlint-disable-next-line no-console\n console.log(`🔄 Retrying ${'🟨'.repeat(count + 1)}${'⬜️'.repeat(2 - count)}`)\n }\n return count < 2\n },\n} satisfies Required<RetryOptions>\n\n/**\n * Plugin that adds the ability to retry failed queries.\n *\n * @param globalOptions - global options for the retries\n */\nexport function PiniaColadaRetry(\n globalOptions?: RetryOptions,\n): (context: PiniaColadaPluginContext) => void {\n const defaults = { ...RETRY_OPTIONS_DEFAULTS, ...globalOptions }\n\n return ({ queryCache }) => {\n const retryMap = new Map<string, RetryEntry>()\n\n let isInternalCall = false\n queryCache.$onAction(({ name, args, after, onError }) => {\n // cleanup all pending retries when data is deleted (means the data is not needed anymore)\n if (name === 'remove') {\n const [cacheEntry] = args\n const key = cacheEntry.key.join('/')\n const entry = retryMap.get(key)\n if (entry) {\n clearTimeout(entry.timeoutId)\n retryMap.delete(key)\n }\n }\n\n if (name !== 'fetch') return\n const [queryEntry] = args\n const localOptions = queryEntry.options?.retry\n\n const options = {\n ...(typeof localOptions === 'object'\n ? localOptions\n : {\n retry: localOptions,\n }),\n } satisfies RetryOptions\n\n const retry = options.retry ?? defaults.retry\n const delay = options.delay ?? defaults.delay\n // avoid setting up anything at all\n if (retry === 0) return\n\n const key = queryEntry.key.join('/')\n\n // clear any pending retry\n clearTimeout(retryMap.get(key)?.timeoutId)\n // if the user manually calls the action, reset the retry count\n if (!isInternalCall) {\n retryMap.delete(key)\n }\n\n const retryFetch = () => {\n if (queryEntry.state.value.status === 'error') {\n const error = queryEntry.state.value.error\n // ensure the entry exists\n let entry = retryMap.get(key)\n if (!entry) {\n entry = { retryCount: 0 }\n retryMap.set(key, entry)\n }\n\n const shouldRetry =\n typeof retry === 'number' ? retry > entry.retryCount : retry(entry.retryCount, error)\n\n if (shouldRetry) {\n const delayTime = typeof delay === 'function' ? delay(entry.retryCount) : delay\n entry.timeoutId = setTimeout(() => {\n if (!queryEntry.active || toValue(queryEntry.options?.enabled) === false) {\n retryMap.delete(key)\n return\n }\n // NOTE: we could add some default error handler\n isInternalCall = true\n Promise.resolve(queryCache.fetch(queryEntry)).catch(\n process.env.NODE_ENV !== 'test' ? console.error : () => {},\n )\n isInternalCall = false\n if (entry) {\n entry.retryCount++\n }\n }, delayTime)\n } else {\n // remove the entry if we are not going to retry\n retryMap.delete(key)\n }\n } else {\n // remove the entry if it worked out to reset it\n retryMap.delete(key)\n }\n }\n onError(retryFetch)\n after(retryFetch)\n })\n }\n}\n\ndeclare module '@pinia/colada' {\n // eslint-disable-next-line unused-imports/no-unused-vars\n export interface UseQueryOptions<TData, TError, TDataInitial> {\n /**\n * Options for the retries of this query added by `@pinia/colada-plugin-retry`.\n */\n retry?: RetryOptions | Exclude<RetryOptions['retry'], undefined>\n }\n}\n"],"mappings":";;;AAsCA,MAAM,yBAAyB;CAC7B,QAAQ,YAAoB;EAC1B,MAAM,OAAO,KAAK,IAChB,KAAK,UAAU,KAEf,IACD;AACD,MAAI,QAAQ,IAAI,aAAa,cAE3B,SAAQ,IAAI,wBAAwB,UAAU,EAAE,MAAM,KAAK,IAAI;AAEjE,SAAO;;CAET,QAAQ,UAAU;AAChB,MAAI,QAAQ,IAAI,aAAa,cAE3B,SAAQ,IAAI,eAAe,KAAK,OAAO,QAAQ,EAAE,GAAG,KAAK,OAAO,IAAI,MAAM,GAAG;AAE/E,SAAO,QAAQ;;CAElB;;;;;;AAOD,SAAgB,iBACd,eAC6C;CAC7C,MAAM,WAAW;EAAE,GAAG;EAAwB,GAAG;EAAe;AAEhE,SAAQ,EAAE,iBAAiB;EACzB,MAAM,2BAAW,IAAI,KAAyB;EAE9C,IAAI,iBAAiB;AACrB,aAAW,WAAW,EAAE,MAAM,MAAM,OAAO,cAAc;AAEvD,OAAI,SAAS,UAAU;IACrB,MAA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IAAI;UAItB,UAAS,OAAO,IAAI;;AAGxB,WAAQ,WAAW;AACnB,SAAM,WAAW;IACjB"}
1
+ {"version":3,"file":"index.mjs","names":[],"sources":["../src/retry.ts"],"sourcesContent":["/**\n * Pinia Colada Retry plugin.\n *\n * Adds the ability to retry failed queries.\n *\n * @module @pinia/colada-plugin-retry\n */\nimport type { PiniaColadaPluginContext } from '@pinia/colada'\nimport type { ShallowRef } from 'vue'\nimport { shallowRef, toValue } from 'vue'\n\n/**\n * Options for the Pinia Colada Retry plugin.\n */\nexport interface RetryOptions {\n /**\n * The delay between retries. Can be a duration in ms or a function that\n * receives the attempt number (starts at 0) and returns a duration in ms. By\n * default, it will wait 2^attempt * 1000 ms, but never more than 30 seconds.\n *\n * @param attempt -\n * @returns\n */\n delay?: number | ((attempt: number) => number)\n\n /**\n * The maximum number of times to retry the operation. Set to 0 to disable or\n * to Infinity to retry forever. It can also be a function that receives the\n * failure count and the error and returns if it should retry. Defaults to 3.\n * **Must be a positive number**.\n */\n retry?: number | ((failureCount: number, error: unknown) => boolean)\n}\n\nexport interface RetryEntry {\n retryCount: number\n timeoutId?: ReturnType<typeof setTimeout>\n}\n\nconst RETRY_OPTIONS_DEFAULTS = {\n delay: (attempt: number) => {\n const time = Math.min(\n 2 ** attempt * 1000,\n // never more than 30 seconds\n 30_000,\n )\n if (process.env.NODE_ENV === 'development') {\n // oxlint-disable-next-line no-console\n console.debug(`⏲️ delaying attempt #${attempt + 1} by ${time}ms`)\n }\n return time\n },\n retry: (count) => {\n if (process.env.NODE_ENV === 'development') {\n // oxlint-disable-next-line no-console\n console.debug(`🔄 Retrying ${'🟨'.repeat(count + 1)}${'⬜️'.repeat(2 - count)}`)\n }\n return count < 2\n },\n} satisfies Required<RetryOptions>\n\n/**\n * Plugin that adds the ability to retry failed queries.\n *\n * @param globalOptions - global options for the retries\n */\nexport function PiniaColadaRetry(\n globalOptions?: RetryOptions,\n): (context: PiniaColadaPluginContext) => void {\n const defaults = { ...RETRY_OPTIONS_DEFAULTS, ...globalOptions }\n\n return ({ queryCache, scope }) => {\n const retryMap = new Map<string, RetryEntry>()\n\n let isInternalCall = false\n queryCache.$onAction(({ name, args, after, onError }) => {\n if (name === 'extend') {\n const [entry] = args\n scope.run(() => {\n entry.ext.isRetrying = shallowRef(false)\n entry.ext.retryCount = shallowRef(0)\n entry.ext.retryError = shallowRef(null)\n })\n if (process.env.NODE_ENV === 'development') {\n entry.ext.retry = { isRetrying: false, retryCount: 0, retryError: null as unknown }\n }\n return\n }\n\n // cleanup all pending retries when data is deleted (means the data is not needed anymore)\n if (name === 'remove') {\n const [cacheEntry] = args\n const key = cacheEntry.key.join('/')\n const entry = retryMap.get(key)\n if (entry) {\n clearTimeout(entry.timeoutId)\n retryMap.delete(key)\n }\n }\n\n if (name !== 'fetch') return\n const [queryEntry] = args\n const localOptions = queryEntry.options?.retry\n\n const options = {\n ...(typeof localOptions === 'object'\n ? localOptions\n : {\n retry: localOptions,\n }),\n } satisfies RetryOptions\n\n const retry = options.retry ?? defaults.retry\n const delay = options.delay ?? defaults.delay\n // avoid setting up anything at all\n if (retry === 0) return\n\n const key = queryEntry.key.join('/')\n\n // clear any pending retry\n clearTimeout(retryMap.get(key)?.timeoutId)\n // if the user manually calls the action, reset the retry count\n if (!isInternalCall) {\n retryMap.delete(key)\n queryEntry.ext.isRetrying.value = false\n queryEntry.ext.retryCount.value = 0\n queryEntry.ext.retryError.value = null\n if (process.env.NODE_ENV === 'development' && queryEntry.ext.retry) {\n queryEntry.ext.retry.isRetrying = false\n queryEntry.ext.retry.retryCount = 0\n queryEntry.ext.retry.retryError = null\n }\n }\n\n // capture state before the fetch runs so we can revert during retries\n const previousState = queryEntry.state.value\n\n const retryFetch = () => {\n if (queryEntry.state.value.status === 'error') {\n const error = queryEntry.state.value.error\n // ensure the entry exists\n let entry = retryMap.get(key)\n if (!entry) {\n entry = { retryCount: 0 }\n retryMap.set(key, entry)\n }\n\n const shouldRetry =\n typeof retry === 'number' ? retry > entry.retryCount : retry(entry.retryCount, error)\n\n if (shouldRetry) {\n queryEntry.ext.isRetrying.value = true\n queryEntry.ext.retryCount.value = entry.retryCount + 1\n queryEntry.ext.retryError.value = error\n if (process.env.NODE_ENV === 'development' && queryEntry.ext.retry) {\n queryEntry.ext.retry.isRetrying = true\n queryEntry.ext.retry.retryCount = entry.retryCount + 1\n queryEntry.ext.retry.retryError = error\n }\n // revert to pre-fetch state so the error is only visible via retryError\n queryEntry.state.value = previousState\n const delayTime = typeof delay === 'function' ? delay(entry.retryCount) : delay\n entry.timeoutId = setTimeout(() => {\n if (!queryEntry.active || toValue(queryEntry.options?.enabled) === false) {\n retryMap.delete(key)\n queryEntry.ext.isRetrying.value = false\n queryEntry.ext.retryCount.value = 0\n queryEntry.ext.retryError.value = null\n if (process.env.NODE_ENV === 'development' && queryEntry.ext.retry) {\n queryEntry.ext.retry.isRetrying = false\n queryEntry.ext.retry.retryCount = 0\n queryEntry.ext.retry.retryError = null\n }\n return\n }\n // NOTE: we could add some default error handler\n isInternalCall = true\n Promise.resolve(queryCache.fetch(queryEntry)).catch(\n process.env.NODE_ENV !== 'test' ? console.error : () => {},\n )\n isInternalCall = false\n if (entry) {\n entry.retryCount++\n }\n }, delayTime)\n } else {\n // remove the entry if we are not going to retry\n queryEntry.ext.isRetrying.value = false\n queryEntry.ext.retryError.value = null\n retryMap.delete(key)\n if (process.env.NODE_ENV === 'development' && queryEntry.ext.retry) {\n queryEntry.ext.retry.isRetrying = false\n queryEntry.ext.retry.retryError = null\n }\n }\n } else {\n // remove the entry if it worked out to reset it\n queryEntry.ext.isRetrying.value = false\n queryEntry.ext.retryCount.value = 0\n queryEntry.ext.retryError.value = null\n retryMap.delete(key)\n if (process.env.NODE_ENV === 'development' && queryEntry.ext.retry) {\n queryEntry.ext.retry.isRetrying = false\n queryEntry.ext.retry.retryCount = 0\n queryEntry.ext.retry.retryError = null\n }\n }\n }\n onError(retryFetch)\n after(retryFetch)\n })\n }\n}\n\ndeclare module '@pinia/colada' {\n // eslint-disable-next-line unused-imports/no-unused-vars\n export interface UseQueryOptions<TData, TError, TDataInitial> {\n /**\n * Options for the retries of this query added by `@pinia/colada-plugin-retry`.\n */\n retry?: RetryOptions | Exclude<RetryOptions['retry'], undefined>\n }\n\n // eslint-disable-next-line unused-imports/no-unused-vars\n interface UseQueryEntryExtensions<TData, TError, TDataInitial> {\n /**\n * Whether the query is currently retrying. Requires the `@pinia/colada-plugin-retry` plugin.\n */\n isRetrying: ShallowRef<boolean>\n /**\n * The number of retries that have been scheduled so far. Resets on success or manual refetch.\n * Requires the `@pinia/colada-plugin-retry` plugin.\n */\n retryCount: ShallowRef<number>\n /**\n * The error that triggered the current retry. `null` when not retrying or when retries are exhausted.\n * Requires the `@pinia/colada-plugin-retry` plugin.\n */\n retryError: ShallowRef<TError | null>\n /**\n * Plain object with retry state for devtools. Only present in development mode.\n */\n retry?: { isRetrying: boolean; retryCount: number; retryError: unknown }\n }\n}\n"],"mappings":";;;AAuCA,MAAM,yBAAyB;CAC7B,QAAQ,YAAoB;EAC1B,MAAM,OAAO,KAAK,IAChB,KAAK,UAAU,KAEf,IACD;AACD,MAAI,QAAQ,IAAI,aAAa,cAE3B,SAAQ,MAAM,wBAAwB,UAAU,EAAE,MAAM,KAAK,IAAI;AAEnE,SAAO;;CAET,QAAQ,UAAU;AAChB,MAAI,QAAQ,IAAI,aAAa,cAE3B,SAAQ,MAAM,eAAe,KAAK,OAAO,QAAQ,EAAE,GAAG,KAAK,OAAO,IAAI,MAAM,GAAG;AAEjF,SAAO,QAAQ;;CAElB;;;;;;AAOD,SAAgB,iBACd,eAC6C;CAC7C,MAAM,WAAW;EAAE,GAAG;EAAwB,GAAG;EAAe;AAEhE,SAAQ,EAAE,YAAY,YAAY;EAChC,MAAM,2BAAW,IAAI,KAAyB;EAE9C,IAAI,iBAAiB;AACrB,aAAW,WAAW,EAAE,MAAM,MAAM,OAAO,cAAc;AACvD,OAAI,SAAS,UAAU;IACrB,MAAM,CAAC,SAA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AAW,IAAI,OAAO;AAClE,kBAAW,IAAI,MAAM,aAAa;AAClC,kBAAW,IAAI,MAAM,aAAa;;;WAGjC;AAEL,gBAAW,IAAI,WAAW,QAAQ;AAClC,gBAAW,IAAI,WAAW,QAAQ;AAClC,gBAAW,IAAI,WAAW,QAAQ;AAClC,cAAS,OAAO,IAAI;AACpB,SAAI,QAAQ,IAAI,aAAa,iBAAiB,WAAW,IAAI,OAAO;AAClE,iBAAW,IAAI,MAAM,aAAa;AAClC,iBAAW,IAAI,MAAM,aAAa;AAClC,iBAAW,IAAI,MAAM,aAAa;;;;AAIxC,WAAQ,WAAW;AACnB,SAAM,WAAW;IACjB"}
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
7
- "version": "0.2.1",
7
+ "version": "0.2.3",
8
8
  "description": "Retry failed requests with Pinia Colada",
9
9
  "author": {
10
10
  "name": "Eduardo San Martin Morote",
@@ -12,7 +12,7 @@
12
12
  },
13
13
  "license": "MIT",
14
14
  "funding": "https://github.com/sponsors/posva",
15
- "homepage": "https://github.com/posva/pinia-colada/plugins/retry#readme",
15
+ "homepage": "https://github.com/posva/pinia-colada/blob/main/plugins/retry/README.md",
16
16
  "repository": "posva/pinia-colada",
17
17
  "bugs": {
18
18
  "url": "https://github.com/posva/pinia-colada/issues"
@@ -45,10 +45,10 @@
45
45
  "dist"
46
46
  ],
47
47
  "peerDependencies": {
48
- "@pinia/colada": ">=0.21.1"
48
+ "@pinia/colada": ">=0.21.6"
49
49
  },
50
50
  "devDependencies": {
51
- "@pinia/colada": "^0.21.1"
51
+ "@pinia/colada": "^0.21.6"
52
52
  },
53
53
  "scripts": {
54
54
  "build": "tsdown",