@tanstack/vue-query 4.24.9 → 5.0.0-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (112) hide show
  1. package/build/lib/__mocks__/useBaseQuery.d.ts +2 -2
  2. package/build/lib/__mocks__/useQueryClient.d.ts +1 -1
  3. package/build/lib/devtools/devtools.esm.js +6 -12
  4. package/build/lib/devtools/devtools.esm.js.map +1 -1
  5. package/build/lib/devtools/devtools.js +6 -14
  6. package/build/lib/devtools/devtools.js.map +1 -1
  7. package/build/lib/devtools/devtools.mjs +6 -12
  8. package/build/lib/devtools/devtools.mjs.map +1 -1
  9. package/build/lib/devtools/utils.esm.js +0 -23
  10. package/build/lib/devtools/utils.esm.js.map +1 -1
  11. package/build/lib/devtools/utils.js +0 -25
  12. package/build/lib/devtools/utils.js.map +1 -1
  13. package/build/lib/devtools/utils.mjs +0 -23
  14. package/build/lib/devtools/utils.mjs.map +1 -1
  15. package/build/lib/index.js +0 -2
  16. package/build/lib/index.js.map +1 -1
  17. package/build/lib/mutationCache.d.ts +3 -3
  18. package/build/lib/mutationCache.esm.js +1 -3
  19. package/build/lib/mutationCache.esm.js.map +1 -1
  20. package/build/lib/mutationCache.js +1 -5
  21. package/build/lib/mutationCache.js.map +1 -1
  22. package/build/lib/mutationCache.mjs +1 -3
  23. package/build/lib/mutationCache.mjs.map +1 -1
  24. package/build/lib/queryCache.d.ts +2 -4
  25. package/build/lib/queryCache.esm.js +5 -16
  26. package/build/lib/queryCache.esm.js.map +1 -1
  27. package/build/lib/queryCache.js +4 -17
  28. package/build/lib/queryCache.js.map +1 -1
  29. package/build/lib/queryCache.mjs +5 -16
  30. package/build/lib/queryCache.mjs.map +1 -1
  31. package/build/lib/queryClient.d.ts +13 -29
  32. package/build/lib/queryClient.esm.js +33 -124
  33. package/build/lib/queryClient.esm.js.map +1 -1
  34. package/build/lib/queryClient.js +32 -125
  35. package/build/lib/queryClient.js.map +1 -1
  36. package/build/lib/queryClient.mjs +33 -124
  37. package/build/lib/queryClient.mjs.map +1 -1
  38. package/build/lib/types.d.ts +1 -13
  39. package/build/lib/useBaseQuery.d.ts +6 -7
  40. package/build/lib/useBaseQuery.esm.js +15 -41
  41. package/build/lib/useBaseQuery.esm.js.map +1 -1
  42. package/build/lib/useBaseQuery.js +12 -41
  43. package/build/lib/useBaseQuery.js.map +1 -1
  44. package/build/lib/useBaseQuery.mjs +15 -41
  45. package/build/lib/useBaseQuery.mjs.map +1 -1
  46. package/build/lib/useInfiniteQuery.d.ts +10 -10
  47. package/build/lib/useInfiniteQuery.esm.js +5 -5
  48. package/build/lib/useInfiniteQuery.esm.js.map +1 -1
  49. package/build/lib/useInfiniteQuery.js +5 -7
  50. package/build/lib/useInfiniteQuery.js.map +1 -1
  51. package/build/lib/useInfiniteQuery.mjs +5 -5
  52. package/build/lib/useInfiniteQuery.mjs.map +1 -1
  53. package/build/lib/useIsFetching.d.ts +5 -6
  54. package/build/lib/useIsFetching.esm.js +10 -28
  55. package/build/lib/useIsFetching.esm.js.map +1 -1
  56. package/build/lib/useIsFetching.js +7 -28
  57. package/build/lib/useIsFetching.js.map +1 -1
  58. package/build/lib/useIsFetching.mjs +10 -28
  59. package/build/lib/useIsFetching.mjs.map +1 -1
  60. package/build/lib/useIsMutating.d.ts +5 -6
  61. package/build/lib/useIsMutating.esm.js +10 -28
  62. package/build/lib/useIsMutating.esm.js.map +1 -1
  63. package/build/lib/useIsMutating.js +7 -28
  64. package/build/lib/useIsMutating.js.map +1 -1
  65. package/build/lib/useIsMutating.mjs +10 -28
  66. package/build/lib/useIsMutating.mjs.map +1 -1
  67. package/build/lib/useMutation.d.ts +6 -12
  68. package/build/lib/useMutation.esm.js +12 -41
  69. package/build/lib/useMutation.esm.js.map +1 -1
  70. package/build/lib/useMutation.js +9 -41
  71. package/build/lib/useMutation.js.map +1 -1
  72. package/build/lib/useMutation.mjs +12 -41
  73. package/build/lib/useMutation.mjs.map +1 -1
  74. package/build/lib/useQueries.d.ts +15 -10
  75. package/build/lib/useQueries.esm.js +17 -26
  76. package/build/lib/useQueries.esm.js.map +1 -1
  77. package/build/lib/useQueries.js +16 -27
  78. package/build/lib/useQueries.js.map +1 -1
  79. package/build/lib/useQueries.mjs +17 -26
  80. package/build/lib/useQueries.mjs.map +1 -1
  81. package/build/lib/useQuery.d.ts +14 -28
  82. package/build/lib/useQuery.esm.js +5 -5
  83. package/build/lib/useQuery.esm.js.map +1 -1
  84. package/build/lib/useQuery.js +5 -7
  85. package/build/lib/useQuery.js.map +1 -1
  86. package/build/lib/useQuery.mjs +5 -5
  87. package/build/lib/useQuery.mjs.map +1 -1
  88. package/build/lib/useQueryClient.esm.js +1 -7
  89. package/build/lib/useQueryClient.esm.js.map +1 -1
  90. package/build/lib/useQueryClient.js +1 -9
  91. package/build/lib/useQueryClient.js.map +1 -1
  92. package/build/lib/useQueryClient.mjs +1 -7
  93. package/build/lib/useQueryClient.mjs.map +1 -1
  94. package/build/lib/utils.d.ts +3 -6
  95. package/build/lib/utils.esm.js +9 -17
  96. package/build/lib/utils.esm.js.map +1 -1
  97. package/build/lib/utils.js +8 -20
  98. package/build/lib/utils.js.map +1 -1
  99. package/build/lib/utils.mjs +9 -17
  100. package/build/lib/utils.mjs.map +1 -1
  101. package/build/lib/vueQueryPlugin.d.ts +0 -6
  102. package/build/lib/vueQueryPlugin.esm.js +9 -31
  103. package/build/lib/vueQueryPlugin.esm.js.map +1 -1
  104. package/build/lib/vueQueryPlugin.js +9 -33
  105. package/build/lib/vueQueryPlugin.js.map +1 -1
  106. package/build/lib/vueQueryPlugin.mjs +9 -31
  107. package/build/lib/vueQueryPlugin.mjs.map +1 -1
  108. package/build/umd/index.development.js +1033 -1858
  109. package/build/umd/index.development.js.map +1 -1
  110. package/build/umd/index.production.js +1 -1
  111. package/build/umd/index.production.js.map +1 -1
  112. package/package.json +11 -7
@@ -1 +1 @@
1
- {"version":3,"file":"vueQueryPlugin.esm.js","sources":["../../src/vueQueryPlugin.ts"],"sourcesContent":["import { isVue2 } from 'vue-demi'\nimport type { QueryClientConfig } from '@tanstack/query-core'\n\nimport { QueryClient } from './queryClient'\nimport { getClientKey } from './utils'\nimport { setupDevtools } from './devtools/devtools'\nimport type { MaybeRefDeep } from './types'\n\ndeclare global {\n interface Window {\n __VUE_QUERY_CONTEXT__?: QueryClient\n }\n}\n\ntype ClientPersister = (client: QueryClient) => [() => void, Promise<void>]\n\ninterface CommonOptions {\n queryClientKey?: string\n contextSharing?: boolean\n clientPersister?: ClientPersister\n}\n\ninterface ConfigOptions extends CommonOptions {\n queryClientConfig?: MaybeRefDeep<QueryClientConfig>\n}\n\ninterface ClientOptions extends CommonOptions {\n queryClient?: QueryClient\n}\n\nexport type VueQueryPluginOptions = ConfigOptions | ClientOptions\n\nexport const VueQueryPlugin = {\n install: (app: any, options: VueQueryPluginOptions = {}) => {\n const clientKey = getClientKey(options.queryClientKey)\n let client: QueryClient\n\n if ('queryClient' in options && options.queryClient) {\n client = options.queryClient\n } else {\n if (options.contextSharing && typeof window !== 'undefined') {\n if (!window.__VUE_QUERY_CONTEXT__) {\n const clientConfig =\n 'queryClientConfig' in options\n ? options.queryClientConfig\n : undefined\n client = new QueryClient(clientConfig)\n window.__VUE_QUERY_CONTEXT__ = client\n } else {\n client = window.__VUE_QUERY_CONTEXT__\n }\n } else {\n const clientConfig =\n 'queryClientConfig' in options ? options.queryClientConfig : undefined\n client = new QueryClient(clientConfig)\n }\n }\n\n client.mount()\n let persisterUnmount = () => {\n // noop\n }\n\n if (options.clientPersister) {\n client.isRestoring.value = true\n const [unmount, promise] = options.clientPersister(client)\n persisterUnmount = unmount\n promise.then(() => {\n client.isRestoring.value = false\n })\n }\n\n if (process.env.NODE_ENV !== 'production' && options.contextSharing) {\n client\n .getLogger()\n .error(\n `The contextSharing option has been deprecated and will be removed in the next major version`,\n )\n }\n\n const cleanup = () => {\n client.unmount()\n persisterUnmount()\n }\n\n if (app.onUnmount) {\n app.onUnmount(cleanup)\n } else {\n const originalUnmount = app.unmount\n app.unmount = function vueQueryUnmount() {\n cleanup()\n originalUnmount()\n }\n }\n\n /* istanbul ignore next */\n if (isVue2) {\n app.mixin({\n beforeCreate() {\n // HACK: taken from provide(): https://github.com/vuejs/composition-api/blob/master/src/apis/inject.ts#L30\n if (!this._provided) {\n const provideCache = {}\n Object.defineProperty(this, '_provided', {\n get: () => provideCache,\n set: (v) => Object.assign(provideCache, v),\n })\n }\n\n this._provided[clientKey] = client\n\n if (process.env.NODE_ENV === 'development') {\n if (this === this.$root) {\n setupDevtools(this, client)\n }\n }\n },\n })\n } else {\n app.provide(clientKey, client)\n\n if (process.env.NODE_ENV === 'development') {\n setupDevtools(app, client)\n }\n }\n },\n}\n"],"names":["VueQueryPlugin","install","app","options","clientKey","getClientKey","queryClientKey","client","queryClient","contextSharing","window","__VUE_QUERY_CONTEXT__","clientConfig","queryClientConfig","undefined","QueryClient","mount","persisterUnmount","clientPersister","isRestoring","value","unmount","promise","then","process","env","NODE_ENV","getLogger","error","cleanup","onUnmount","originalUnmount","vueQueryUnmount","isVue2","mixin","beforeCreate","_provided","provideCache","Object","defineProperty","get","set","v","assign","$root","setupDevtools","provide"],"mappings":";;;;;AAgCO,MAAMA,cAAc,GAAG;AAC5BC,EAAAA,OAAO,EAAE,CAACC,GAAD,EAAWC,OAA8B,GAAG,EAA5C,KAAmD;AAC1D,IAAA,MAAMC,SAAS,GAAGC,YAAY,CAACF,OAAO,CAACG,cAAT,CAA9B,CAAA;AACA,IAAA,IAAIC,MAAJ,CAAA;;AAEA,IAAA,IAAI,iBAAiBJ,OAAjB,IAA4BA,OAAO,CAACK,WAAxC,EAAqD;MACnDD,MAAM,GAAGJ,OAAO,CAACK,WAAjB,CAAA;AACD,KAFD,MAEO;MACL,IAAIL,OAAO,CAACM,cAAR,IAA0B,OAAOC,MAAP,KAAkB,WAAhD,EAA6D;AAC3D,QAAA,IAAI,CAACA,MAAM,CAACC,qBAAZ,EAAmC;UACjC,MAAMC,YA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aAAa,CAAC3C,GAAD,EAAMK,MAAN,CAAb,CAAA;AACD,OAAA;AACF,KAAA;AACF,GAAA;AA5F2B;;;;"}
1
+ {"version":3,"file":"vueQueryPlugin.esm.js","sources":["../../src/vueQueryPlugin.ts"],"sourcesContent":["import { isVue2 } from 'vue-demi'\nimport { isServer } from '@tanstack/query-core'\nimport type { QueryClientConfig } from '@tanstack/query-core'\n\nimport { QueryClient } from './queryClient'\nimport { getClientKey } from './utils'\nimport { setupDevtools } from './devtools/devtools'\nimport type { MaybeRefDeep } from './types'\n\ntype ClientPersister = (client: QueryClient) => [() => void, Promise<void>]\n\ninterface CommonOptions {\n queryClientKey?: string\n clientPersister?: ClientPersister\n}\n\ninterface ConfigOptions extends CommonOptions {\n queryClientConfig?: MaybeRefDeep<QueryClientConfig>\n}\n\ninterface ClientOptions extends CommonOptions {\n queryClient?: QueryClient\n}\n\nexport type VueQueryPluginOptions = ConfigOptions | ClientOptions\n\nexport const VueQueryPlugin = {\n install: (app: any, options: VueQueryPluginOptions = {}) => {\n const clientKey = getClientKey(options.queryClientKey)\n let client: QueryClient\n\n if ('queryClient' in options && options.queryClient) {\n client = options.queryClient\n } else {\n const clientConfig =\n 'queryClientConfig' in options ? options.queryClientConfig : undefined\n client = new QueryClient(clientConfig)\n }\n\n if (!isServer) {\n client.mount()\n }\n\n let persisterUnmount = () => {\n // noop\n }\n\n if (options.clientPersister) {\n client.isRestoring.value = true\n const [unmount, promise] = options.clientPersister(client)\n persisterUnmount = unmount\n promise.then(() => {\n client.isRestoring.value = false\n })\n }\n\n const cleanup = () => {\n client.unmount()\n persisterUnmount()\n }\n\n if (app.onUnmount) {\n app.onUnmount(cleanup)\n } else {\n const originalUnmount = app.unmount\n app.unmount = function vueQueryUnmount() {\n cleanup()\n originalUnmount()\n }\n }\n\n /* istanbul ignore next */\n if (isVue2) {\n app.mixin({\n beforeCreate() {\n // HACK: taken from provide(): https://github.com/vuejs/composition-api/blob/master/src/apis/inject.ts#L30\n if (!this._provided) {\n const provideCache = {}\n Object.defineProperty(this, '_provided', {\n get: () => provideCache,\n set: (v) => Object.assign(provideCache, v),\n })\n }\n\n this._provided[clientKey] = client\n\n if (process.env.NODE_ENV === 'development') {\n if (this === this.$root) {\n setupDevtools(this, client)\n }\n }\n },\n })\n } else {\n app.provide(clientKey, client)\n\n if (process.env.NODE_ENV === 'development') {\n setupDevtools(app, client)\n }\n }\n },\n}\n"],"names":["VueQueryPlugin","install","app","options","clientKey","getClientKey","queryClientKey","client","queryClient","clientConfig","queryClientConfig","undefined","QueryClient","isServer","mount","persisterUnmount","clientPersister","isRestoring","value","unmount","promise","then","cleanup","onUnmount","originalUnmount","vueQueryUnmount","isVue2","mixin","beforeCreate","_provided","provideCache","Object","defineProperty","get","set","v","assign","process","env","NODE_ENV","$root","setupDevtools","provide"],"mappings":";;;;;;AA0BO,MAAMA,cAAc,GAAG;EAC5BC,OAAO,EAAE,CAACC,GAAQ,EAAEC,OAA8B,GAAG,EAAE,KAAK;AAC1D,IAAA,MAAMC,SAAS,GAAGC,YAAY,CAACF,OAAO,CAACG,cAAc,CAAC,CAAA;AACtD,IAAA,IAAIC,MAAmB,CAAA;AAEvB,IAAA,IAAI,aAAa,IAAIJ,OAAO,IAAIA,OAAO,CAACK,WAAW,EAAE;MACnDD,MAAM,GAAGJ,OAAO,CAACK,WAAW,CAAA;AAC9B,KAAC,MAAM;MACL,MAAMC,YAAY,GAChB,mBAAmB,IAAIN,OAAO,GAAGA,OAAO,CAACO,iBAAiB,GAAGC,SAAS,CAAA;AACxEJ,MAAAA,MAAM,GAAG,IAAIK,WAAW,CAACH,YAAY,CAAC,CAAA;AACxC,KAAA;IAEA,IAAI,CAACI,QAAQ,EAAE;MACbN,MAAM,CAACO,KAAK,EAAE,CAAA;AAChB,KAAA;IAEA,IAAIC,gBAAgB,GAAG,MAAM;AAC3B;KACD,CAAA;IAED,IAAIZ,OAAO,CAACa,eAAe,EAAE;AAC3BT,MAAAA,MAAM,CAACU,WAAW,CAAC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CAACC,GAAG,CAACC,QAAQ,KAAK,aAAa,EAAE;AAC1C,YAAA,IAAI,IAAI,KAAK,IAAI,CAACC,KAAK,EAAE;AACvBC,cAAAA,aAAa,CAAC,IAAI,EAAElC,MAAM,CAAC,CAAA;AAC7B,aAAA;AACF,WAAA;AACF,SAAA;AACF,OAAC,CAAC,CAAA;AACJ,KAAC,MAAM;AACLL,MAAAA,GAAG,CAACwC,OAAO,CAACtC,SAAS,EAAEG,MAAM,CAAC,CAAA;AAE9B,MAAA,IAAI8B,OAAO,CAACC,GAAG,CAACC,QAAQ,KAAK,aAAa,EAAE;AAC1CE,QAAAA,aAAa,CAACvC,GAAG,EAAEK,MAAM,CAAC,CAAA;AAC5B,OAAA;AACF,KAAA;AACF,GAAA;AACF;;;;"}
@@ -1,8 +1,7 @@
1
1
  'use strict';
2
2
 
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
3
  var vueDemi = require('vue-demi');
4
+ var queryCore = require('@tanstack/query-core');
6
5
  var queryClient = require('./queryClient.js');
7
6
  var utils = require('./utils.js');
8
7
  var devtools = require('./devtools/devtools.js');
@@ -11,29 +10,18 @@ const VueQueryPlugin = {
11
10
  install: (app, options = {}) => {
12
11
  const clientKey = utils.getClientKey(options.queryClientKey);
13
12
  let client;
14
-
15
13
  if ('queryClient' in options && options.queryClient) {
16
14
  client = options.queryClient;
17
15
  } else {
18
- if (options.contextSharing && typeof window !== 'undefined') {
19
- if (!window.__VUE_QUERY_CONTEXT__) {
20
- const clientConfig = 'queryClientConfig' in options ? options.queryClientConfig : undefined;
21
- client = new queryClient.QueryClient(clientConfig);
22
- window.__VUE_QUERY_CONTEXT__ = client;
23
- } else {
24
- client = window.__VUE_QUERY_CONTEXT__;
25
- }
26
- } else {
27
- const clientConfig = 'queryClientConfig' in options ? options.queryClientConfig : undefined;
28
- client = new queryClient.QueryClient(clientConfig);
29
- }
16
+ const clientConfig = 'queryClientConfig' in options ? options.queryClientConfig : undefined;
17
+ client = new queryClient.QueryClient(clientConfig);
30
18
  }
31
-
32
- client.mount();
33
-
34
- let persisterUnmount = () => {// noop
19
+ if (!queryCore.isServer) {
20
+ client.mount();
21
+ }
22
+ let persisterUnmount = () => {
23
+ // noop
35
24
  };
36
-
37
25
  if (options.clientPersister) {
38
26
  client.isRestoring.value = true;
39
27
  const [unmount, promise] = options.clientPersister(client);
@@ -42,29 +30,21 @@ const VueQueryPlugin = {
42
30
  client.isRestoring.value = false;
43
31
  });
44
32
  }
45
-
46
- if (process.env.NODE_ENV !== 'production' && options.contextSharing) {
47
- client.getLogger().error("The contextSharing option has been deprecated and will be removed in the next major version");
48
- }
49
-
50
33
  const cleanup = () => {
51
34
  client.unmount();
52
35
  persisterUnmount();
53
36
  };
54
-
55
37
  if (app.onUnmount) {
56
38
  app.onUnmount(cleanup);
57
39
  } else {
58
40
  const originalUnmount = app.unmount;
59
-
60
41
  app.unmount = function vueQueryUnmount() {
61
42
  cleanup();
62
43
  originalUnmount();
63
44
  };
64
45
  }
65
- /* istanbul ignore next */
66
-
67
46
 
47
+ /* istanbul ignore next */
68
48
  if (vueDemi.isVue2) {
69
49
  app.mixin({
70
50
  beforeCreate() {
@@ -76,20 +56,16 @@ const VueQueryPlugin = {
76
56
  set: v => Object.assign(provideCache, v)
77
57
  });
78
58
  }
79
-
80
59
  this._provided[clientKey] = client;
81
-
82
60
  if (process.env.NODE_ENV === 'development') {
83
61
  if (this === this.$root) {
84
62
  devtools.setupDevtools(this, client);
85
63
  }
86
64
  }
87
65
  }
88
-
89
66
  });
90
67
  } else {
91
68
  app.provide(clientKey, client);
92
-
93
69
  if (process.env.NODE_ENV === 'development') {
94
70
  devtools.setupDevtools(app, client);
95
71
  }
@@ -1 +1 @@
1
- {"version":3,"file":"vueQueryPlugin.js","sources":["../../src/vueQueryPlugin.ts"],"sourcesContent":["import { isVue2 } from 'vue-demi'\nimport type { QueryClientConfig } from '@tanstack/query-core'\n\nimport { QueryClient } from './queryClient'\nimport { getClientKey } from './utils'\nimport { setupDevtools } from './devtools/devtools'\nimport type { MaybeRefDeep } from './types'\n\ndeclare global {\n interface Window {\n __VUE_QUERY_CONTEXT__?: QueryClient\n }\n}\n\ntype ClientPersister = (client: QueryClient) => [() => void, Promise<void>]\n\ninterface CommonOptions {\n queryClientKey?: string\n contextSharing?: boolean\n clientPersister?: ClientPersister\n}\n\ninterface ConfigOptions extends CommonOptions {\n queryClientConfig?: MaybeRefDeep<QueryClientConfig>\n}\n\ninterface ClientOptions extends CommonOptions {\n queryClient?: QueryClient\n}\n\nexport type VueQueryPluginOptions = ConfigOptions | ClientOptions\n\nexport const VueQueryPlugin = {\n install: (app: any, options: VueQueryPluginOptions = {}) => {\n const clientKey = getClientKey(options.queryClientKey)\n let client: QueryClient\n\n if ('queryClient' in options && options.queryClient) {\n client = options.queryClient\n } else {\n if (options.contextSharing && typeof window !== 'undefined') {\n if (!window.__VUE_QUERY_CONTEXT__) {\n const clientConfig =\n 'queryClientConfig' in options\n ? options.queryClientConfig\n : undefined\n client = new QueryClient(clientConfig)\n window.__VUE_QUERY_CONTEXT__ = client\n } else {\n client = window.__VUE_QUERY_CONTEXT__\n }\n } else {\n const clientConfig =\n 'queryClientConfig' in options ? options.queryClientConfig : undefined\n client = new QueryClient(clientConfig)\n }\n }\n\n client.mount()\n let persisterUnmount = () => {\n // noop\n }\n\n if (options.clientPersister) {\n client.isRestoring.value = true\n const [unmount, promise] = options.clientPersister(client)\n persisterUnmount = unmount\n promise.then(() => {\n client.isRestoring.value = false\n })\n }\n\n if (process.env.NODE_ENV !== 'production' && options.contextSharing) {\n client\n .getLogger()\n .error(\n `The contextSharing option has been deprecated and will be removed in the next major version`,\n )\n }\n\n const cleanup = () => {\n client.unmount()\n persisterUnmount()\n }\n\n if (app.onUnmount) {\n app.onUnmount(cleanup)\n } else {\n const originalUnmount = app.unmount\n app.unmount = function vueQueryUnmount() {\n cleanup()\n originalUnmount()\n }\n }\n\n /* istanbul ignore next */\n if (isVue2) {\n app.mixin({\n beforeCreate() {\n // HACK: taken from provide(): https://github.com/vuejs/composition-api/blob/master/src/apis/inject.ts#L30\n if (!this._provided) {\n const provideCache = {}\n Object.defineProperty(this, '_provided', {\n get: () => provideCache,\n set: (v) => Object.assign(provideCache, v),\n })\n }\n\n this._provided[clientKey] = client\n\n if (process.env.NODE_ENV === 'development') {\n if (this === this.$root) {\n setupDevtools(this, client)\n }\n }\n },\n })\n } else {\n app.provide(clientKey, client)\n\n if (process.env.NODE_ENV === 'development') {\n setupDevtools(app, client)\n }\n }\n },\n}\n"],"names":["VueQueryPlugin","install","app","options","clientKey","getClientKey","queryClientKey","client","queryClient","contextSharing","window","__VUE_QUERY_CONTEXT__","clientConfig","queryClientConfig","undefined","QueryClient","mount","persisterUnmount","clientPersister","isRestoring","value","unmount","promise","then","process","env","NODE_ENV","getLogger","error","cleanup","onUnmount","originalUnmount","vueQueryUnmount","isVue2","mixin","beforeCreate","_provided","provideCache","Object","defineProperty","get","set","v","assign","$root","setupDevtools","provide"],"mappings":";;;;;;;;;AAgCO,MAAMA,cAAc,GAAG;AAC5BC,EAAAA,OAAO,EAAE,CAACC,GAAD,EAAWC,OAA8B,GAAG,EAA5C,KAAmD;AAC1D,IAAA,MAAMC,SAAS,GAAGC,kBAAY,CAACF,OAAO,CAACG,cAAT,CAA9B,CAAA;AACA,IAAA,IAAIC,MAAJ,CAAA;;AAEA,IAAA,IAAI,iBAAiBJ,OAAjB,IAA4BA,OAAO,CAACK,WAAxC,EAAqD;MACnDD,MAAM,GAAGJ,OAAO,CAACK,WAAjB,CAAA;AACD,KAFD,MAEO;MACL,IAAIL,OAAO,CAACM,cAAR,IAA0B,OAAOC,MAAP,KAAkB,WAAhD,EAA6D;AAC3D,QAAA,IAAI,CAACA,MAAM,CAACC,qBAAZ,EAAmC;UACjC,MAAMC,YAAY,GAChB,mBAAuBT,IAAAA,OAAvB,GACIA,OAAO,CAACU,iBADZ,GAEIC,SAHN,CAAA;AAIAP,UAAAA,MAAM,GAAG,IAAIQ,uBAAJ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ueryPlugin.js","sources":["../../src/vueQueryPlugin.ts"],"sourcesContent":["import { isVue2 } from 'vue-demi'\nimport { isServer } from '@tanstack/query-core'\nimport type { QueryClientConfig } from '@tanstack/query-core'\n\nimport { QueryClient } from './queryClient'\nimport { getClientKey } from './utils'\nimport { setupDevtools } from './devtools/devtools'\nimport type { MaybeRefDeep } from './types'\n\ntype ClientPersister = (client: QueryClient) => [() => void, Promise<void>]\n\ninterface CommonOptions {\n queryClientKey?: string\n clientPersister?: ClientPersister\n}\n\ninterface ConfigOptions extends CommonOptions {\n queryClientConfig?: MaybeRefDeep<QueryClientConfig>\n}\n\ninterface ClientOptions extends CommonOptions {\n queryClient?: QueryClient\n}\n\nexport type VueQueryPluginOptions = ConfigOptions | ClientOptions\n\nexport const VueQueryPlugin = {\n install: (app: any, options: VueQueryPluginOptions = {}) => {\n const clientKey = getClientKey(options.queryClientKey)\n let client: QueryClient\n\n if ('queryClient' in options && options.queryClient) {\n client = options.queryClient\n } else {\n const clientConfig =\n 'queryClientConfig' in options ? options.queryClientConfig : undefined\n client = new QueryClient(clientConfig)\n }\n\n if (!isServer) {\n client.mount()\n }\n\n let persisterUnmount = () => {\n // noop\n }\n\n if (options.clientPersister) {\n client.isRestoring.value = true\n const [unmount, promise] = options.clientPersister(client)\n persisterUnmount = unmount\n promise.then(() => {\n client.isRestoring.value = false\n })\n }\n\n const cleanup = () => {\n client.unmount()\n persisterUnmount()\n }\n\n if (app.onUnmount) {\n app.onUnmount(cleanup)\n } else {\n const originalUnmount = app.unmount\n app.unmount = function vueQueryUnmount() {\n cleanup()\n originalUnmount()\n }\n }\n\n /* istanbul ignore next */\n if (isVue2) {\n app.mixin({\n beforeCreate() {\n // HACK: taken from provide(): https://github.com/vuejs/composition-api/blob/master/src/apis/inject.ts#L30\n if (!this._provided) {\n const provideCache = {}\n Object.defineProperty(this, '_provided', {\n get: () => provideCache,\n set: (v) => Object.assign(provideCache, v),\n })\n }\n\n this._provided[clientKey] = client\n\n if (process.env.NODE_ENV === 'development') {\n if (this === this.$root) {\n setupDevtools(this, client)\n }\n }\n },\n })\n } else {\n app.provide(clientKey, client)\n\n if (process.env.NODE_ENV === 'development') {\n setupDevtools(app, client)\n }\n }\n },\n}\n"],"names":["VueQueryPlugin","install","app","options","clientKey","getClientKey","queryClientKey","client","queryClient","clientConfig","queryClientConfig","undefined","QueryClient","isServer","mount","persisterUnmount","clientPersister","isRestoring","value","unmount","promise","then","cleanup","onUnmount","originalUnmount","vueQueryUnmount","isVue2","mixin","beforeCreate","_provided","provideCache","Object","defineProperty","get","set","v","assign","process","env","NODE_ENV","$root","setupDevtools","provide"],"mappings":";;;;;;;;AA0BO,MAAMA,cAAc,GAAG;EAC5BC,OAAO,EAAE,CAACC,GAAQ,EAAEC,OAA8B,GAAG,EAAE,KAAK;AAC1D,IAAA,MAAMC,SAAS,GAAGC,kBAAY,CAACF,OAAO,CAACG,cAAc,CAAC,CAAA;AACtD,IAAA,IAAIC,MAAmB,CAAA;AAEvB,IAAA,IAAI,aAAa,IAAIJ,OAAO,IAAIA,OAAO,CAACK,WAAW,EAAE;MACnDD,MAAM,GAAGJ,OAAO,CAACK,WAAW,CAAA;AAC9B,KAAC,MAAM;MACL,MAAMC,YAAY,GAChB,mBAAmB,IAAIN,OAAO,GAAGA,OAAO,CAACO,iBAAiB,GAAGC,SAAS,CAAA;AACxEJ,MAAAA,MAAM,GAAG,IAAIK,uBAAW,CAACH,YAAY,CAAC,CAAA;AACxC,KAAA;IAEA,IAAI,CAACI,kBAAQ,EAAE;MACbN,MAAM,CAACO,KAAK,EAAE,CAAA;AAChB,KAAA;IAEA,IAAIC,gBAAgB,GAAG,MAAM;AAC3B;KACD,CAAA;IAED,IAAIZ,OAAO,CAACa,eAAe,EAAE;AAC3BT,MAAAA,MAAM,CAACU,WAAW,CAACC,KAAK,GAAG,IAAI,CAAA;MAC/B,MAAM,CAACC,OAAO,EAAEC,OAAO,CAAC,GAAGjB,OAAO,CAACa,eAAe,CAACT,MAAM,CA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,sBAAa,CAAC,IAAI,EAAElC,MAAM,CAAC,CAAA;AAC7B,aAAA;AACF,WAAA;AACF,SAAA;AACF,OAAC,CAAC,CAAA;AACJ,KAAC,MAAM;AACLL,MAAAA,GAAG,CAACwC,OAAO,CAACtC,SAAS,EAAEG,MAAM,CAAC,CAAA;AAE9B,MAAA,IAAI8B,OAAO,CAACC,GAAG,CAACC,QAAQ,KAAK,aAAa,EAAE;AAC1CE,QAAAA,sBAAa,CAACvC,GAAG,EAAEK,MAAM,CAAC,CAAA;AAC5B,OAAA;AACF,KAAA;AACF,GAAA;AACF;;;;"}
@@ -1,4 +1,5 @@
1
1
  import { isVue2 } from 'vue-demi';
2
+ import { isServer } from '@tanstack/query-core';
2
3
  import { QueryClient } from './queryClient.mjs';
3
4
  import { getClientKey } from './utils.mjs';
4
5
  import { setupDevtools } from './devtools/devtools.mjs';
@@ -7,29 +8,18 @@ const VueQueryPlugin = {
7
8
  install: (app, options = {}) => {
8
9
  const clientKey = getClientKey(options.queryClientKey);
9
10
  let client;
10
-
11
11
  if ('queryClient' in options && options.queryClient) {
12
12
  client = options.queryClient;
13
13
  } else {
14
- if (options.contextSharing && typeof window !== 'undefined') {
15
- if (!window.__VUE_QUERY_CONTEXT__) {
16
- const clientConfig = 'queryClientConfig' in options ? options.queryClientConfig : undefined;
17
- client = new QueryClient(clientConfig);
18
- window.__VUE_QUERY_CONTEXT__ = client;
19
- } else {
20
- client = window.__VUE_QUERY_CONTEXT__;
21
- }
22
- } else {
23
- const clientConfig = 'queryClientConfig' in options ? options.queryClientConfig : undefined;
24
- client = new QueryClient(clientConfig);
25
- }
14
+ const clientConfig = 'queryClientConfig' in options ? options.queryClientConfig : undefined;
15
+ client = new QueryClient(clientConfig);
26
16
  }
27
-
28
- client.mount();
29
-
30
- let persisterUnmount = () => {// noop
17
+ if (!isServer) {
18
+ client.mount();
19
+ }
20
+ let persisterUnmount = () => {
21
+ // noop
31
22
  };
32
-
33
23
  if (options.clientPersister) {
34
24
  client.isRestoring.value = true;
35
25
  const [unmount, promise] = options.clientPersister(client);
@@ -38,29 +28,21 @@ const VueQueryPlugin = {
38
28
  client.isRestoring.value = false;
39
29
  });
40
30
  }
41
-
42
- if (process.env.NODE_ENV !== 'production' && options.contextSharing) {
43
- client.getLogger().error("The contextSharing option has been deprecated and will be removed in the next major version");
44
- }
45
-
46
31
  const cleanup = () => {
47
32
  client.unmount();
48
33
  persisterUnmount();
49
34
  };
50
-
51
35
  if (app.onUnmount) {
52
36
  app.onUnmount(cleanup);
53
37
  } else {
54
38
  const originalUnmount = app.unmount;
55
-
56
39
  app.unmount = function vueQueryUnmount() {
57
40
  cleanup();
58
41
  originalUnmount();
59
42
  };
60
43
  }
61
- /* istanbul ignore next */
62
-
63
44
 
45
+ /* istanbul ignore next */
64
46
  if (isVue2) {
65
47
  app.mixin({
66
48
  beforeCreate() {
@@ -72,20 +54,16 @@ const VueQueryPlugin = {
72
54
  set: v => Object.assign(provideCache, v)
73
55
  });
74
56
  }
75
-
76
57
  this._provided[clientKey] = client;
77
-
78
58
  if (process.env.NODE_ENV === 'development') {
79
59
  if (this === this.$root) {
80
60
  setupDevtools(this, client);
81
61
  }
82
62
  }
83
63
  }
84
-
85
64
  });
86
65
  } else {
87
66
  app.provide(clientKey, client);
88
-
89
67
  if (process.env.NODE_ENV === 'development') {
90
68
  setupDevtools(app, client);
91
69
  }
@@ -1 +1 @@
1
- {"version":3,"file":"vueQueryPlugin.mjs","sources":["../../src/vueQueryPlugin.ts"],"sourcesContent":["import { isVue2 } from 'vue-demi'\nimport type { QueryClientConfig } from '@tanstack/query-core'\n\nimport { QueryClient } from './queryClient'\nimport { getClientKey } from './utils'\nimport { setupDevtools } from './devtools/devtools'\nimport type { MaybeRefDeep } from './types'\n\ndeclare global {\n interface Window {\n __VUE_QUERY_CONTEXT__?: QueryClient\n }\n}\n\ntype ClientPersister = (client: QueryClient) => [() => void, Promise<void>]\n\ninterface CommonOptions {\n queryClientKey?: string\n contextSharing?: boolean\n clientPersister?: ClientPersister\n}\n\ninterface ConfigOptions extends CommonOptions {\n queryClientConfig?: MaybeRefDeep<QueryClientConfig>\n}\n\ninterface ClientOptions extends CommonOptions {\n queryClient?: QueryClient\n}\n\nexport type VueQueryPluginOptions = ConfigOptions | ClientOptions\n\nexport const VueQueryPlugin = {\n install: (app: any, options: VueQueryPluginOptions = {}) => {\n const clientKey = getClientKey(options.queryClientKey)\n let client: QueryClient\n\n if ('queryClient' in options && options.queryClient) {\n client = options.queryClient\n } else {\n if (options.contextSharing && typeof window !== 'undefined') {\n if (!window.__VUE_QUERY_CONTEXT__) {\n const clientConfig =\n 'queryClientConfig' in options\n ? options.queryClientConfig\n : undefined\n client = new QueryClient(clientConfig)\n window.__VUE_QUERY_CONTEXT__ = client\n } else {\n client = window.__VUE_QUERY_CONTEXT__\n }\n } else {\n const clientConfig =\n 'queryClientConfig' in options ? options.queryClientConfig : undefined\n client = new QueryClient(clientConfig)\n }\n }\n\n client.mount()\n let persisterUnmount = () => {\n // noop\n }\n\n if (options.clientPersister) {\n client.isRestoring.value = true\n const [unmount, promise] = options.clientPersister(client)\n persisterUnmount = unmount\n promise.then(() => {\n client.isRestoring.value = false\n })\n }\n\n if (process.env.NODE_ENV !== 'production' && options.contextSharing) {\n client\n .getLogger()\n .error(\n `The contextSharing option has been deprecated and will be removed in the next major version`,\n )\n }\n\n const cleanup = () => {\n client.unmount()\n persisterUnmount()\n }\n\n if (app.onUnmount) {\n app.onUnmount(cleanup)\n } else {\n const originalUnmount = app.unmount\n app.unmount = function vueQueryUnmount() {\n cleanup()\n originalUnmount()\n }\n }\n\n /* istanbul ignore next */\n if (isVue2) {\n app.mixin({\n beforeCreate() {\n // HACK: taken from provide(): https://github.com/vuejs/composition-api/blob/master/src/apis/inject.ts#L30\n if (!this._provided) {\n const provideCache = {}\n Object.defineProperty(this, '_provided', {\n get: () => provideCache,\n set: (v) => Object.assign(provideCache, v),\n })\n }\n\n this._provided[clientKey] = client\n\n if (process.env.NODE_ENV === 'development') {\n if (this === this.$root) {\n setupDevtools(this, client)\n }\n }\n },\n })\n } else {\n app.provide(clientKey, client)\n\n if (process.env.NODE_ENV === 'development') {\n setupDevtools(app, client)\n }\n }\n },\n}\n"],"names":["VueQueryPlugin","install","app","options","clientKey","getClientKey","queryClientKey","client","queryClient","contextSharing","window","__VUE_QUERY_CONTEXT__","clientConfig","queryClientConfig","undefined","QueryClient","mount","persisterUnmount","clientPersister","isRestoring","value","unmount","promise","then","process","env","NODE_ENV","getLogger","error","cleanup","onUnmount","originalUnmount","vueQueryUnmount","isVue2","mixin","beforeCreate","_provided","provideCache","Object","defineProperty","get","set","v","assign","$root","setupDevtools","provide"],"mappings":";;;;;AAgCO,MAAMA,cAAc,GAAG;AAC5BC,EAAAA,OAAO,EAAE,CAACC,GAAD,EAAWC,OAA8B,GAAG,EAA5C,KAAmD;AAC1D,IAAA,MAAMC,SAAS,GAAGC,YAAY,CAACF,OAAO,CAACG,cAAT,CAA9B,CAAA;AACA,IAAA,IAAIC,MAAJ,CAAA;;AAEA,IAAA,IAAI,iBAAiBJ,OAAjB,IAA4BA,OAAO,CAACK,WAAxC,EAAqD;MACnDD,MAAM,GAAGJ,OAAO,CAACK,WAAjB,CAAA;AACD,KAFD,MAEO;MACL,IAAIL,OAAO,CAACM,cAAR,IAA0B,OAAOC,MAAP,KAAkB,WAAhD,EAA6D;AAC3D,QAAA,IAAI,CAACA,MAAM,CAACC,qBAAZ,EAAmC;UACjC,MAAMC,YAAY,GAChB,mBAAuBT,IAAAA,OAAvB,GACIA,OAAO,CAACU,iBADZ,GAEIC,SAHN,CAAA;AAIAP,UAAAA,MAAM,GAAG,IAAIQ,WAAJ,CAAgBH,YAAhB,CAAT,CAAA;UACAF,MAAM,CAACC,qBAAP,GAA+BJ,MAA/B,CAAA;AACD,SAPD,MAOO;UACLA,MAAM,GAAGG,MAAM,CAACC,qBAAhB,CAAA;AACD,SAAA;AACF,OAXD,MAWO;QACL,MAAMC,YAAY,GAChB,mBAAu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KAAA;AAED;;;AACA,IAAA,IAAIE,MAAJ,EAAY;MACV/B,GAAG,CAACgC,KAAJ,CAAU;AACRC,QAAAA,YAAY,GAAG;AACb;UACA,IAAI,CAAC,IAAKC,CAAAA,SAAV,EAAqB;YACnB,MAAMC,YAAY,GAAG,EAArB,CAAA;AACAC,YAAAA,MAAM,CAACC,cAAP,CAAsB,IAAtB,EAA4B,WAA5B,EAAyC;cACvCC,GAAG,EAAE,MAAMH,YAD4B;cAEvCI,GAAG,EAAGC,CAAD,IAAOJ,MAAM,CAACK,MAAP,CAAcN,YAAd,EAA4BK,CAA5B,CAAA;aAFd,CAAA,CAAA;AAID,WAAA;;AAED,UAAA,IAAA,CAAKN,SAAL,CAAehC,SAAf,CAAA,GAA4BG,MAA5B,CAAA;;AAEA,UAAA,IAAIiB,OAAO,CAACC,GAAR,CAAYC,QAAZ,KAAyB,aAA7B,EAA4C;YAC1C,IAAI,IAAA,KAAS,IAAKkB,CAAAA,KAAlB,EAAyB;AACvBC,cAAAA,aAAa,CAAC,IAAD,EAAOtC,MAAP,CAAb,CAAA;AACD,aAAA;AACF,WAAA;AACF,SAAA;;OAlBH,CAAA,CAAA;AAoBD,KArBD,MAqBO;AACLL,MAAAA,GAAG,CAAC4C,OAAJ,CAAY1C,SAAZ,EAAuBG,MAAvB,CAAA,CAAA;;AAEA,MAAA,IAAIiB,OAAO,CAACC,GAAR,CAAYC,QAAZ,KAAyB,aAA7B,EAA4C;AAC1CmB,QAAAA,aAAa,CAAC3C,GAAD,EAAMK,MAAN,CAAb,CAAA;AACD,OAAA;AACF,KAAA;AACF,GAAA;AA5F2B;;;;"}
1
+ {"version":3,"file":"vueQueryPlugin.mjs","sources":["../../src/vueQueryPlugin.ts"],"sourcesContent":["import { isVue2 } from 'vue-demi'\nimport { isServer } from '@tanstack/query-core'\nimport type { QueryClientConfig } from '@tanstack/query-core'\n\nimport { QueryClient } from './queryClient'\nimport { getClientKey } from './utils'\nimport { setupDevtools } from './devtools/devtools'\nimport type { MaybeRefDeep } from './types'\n\ntype ClientPersister = (client: QueryClient) => [() => void, Promise<void>]\n\ninterface CommonOptions {\n queryClientKey?: string\n clientPersister?: ClientPersister\n}\n\ninterface ConfigOptions extends CommonOptions {\n queryClientConfig?: MaybeRefDeep<QueryClientConfig>\n}\n\ninterface ClientOptions extends CommonOptions {\n queryClient?: QueryClient\n}\n\nexport type VueQueryPluginOptions = ConfigOptions | ClientOptions\n\nexport const VueQueryPlugin = {\n install: (app: any, options: VueQueryPluginOptions = {}) => {\n const clientKey = getClientKey(options.queryClientKey)\n let client: QueryClient\n\n if ('queryClient' in options && options.queryClient) {\n client = options.queryClient\n } else {\n const clientConfig =\n 'queryClientConfig' in options ? options.queryClientConfig : undefined\n client = new QueryClient(clientConfig)\n }\n\n if (!isServer) {\n client.mount()\n }\n\n let persisterUnmount = () => {\n // noop\n }\n\n if (options.clientPersister) {\n client.isRestoring.value = true\n const [unmount, promise] = options.clientPersister(client)\n persisterUnmount = unmount\n promise.then(() => {\n client.isRestoring.value = false\n })\n }\n\n const cleanup = () => {\n client.unmount()\n persisterUnmount()\n }\n\n if (app.onUnmount) {\n app.onUnmount(cleanup)\n } else {\n const originalUnmount = app.unmount\n app.unmount = function vueQueryUnmount() {\n cleanup()\n originalUnmount()\n }\n }\n\n /* istanbul ignore next */\n if (isVue2) {\n app.mixin({\n beforeCreate() {\n // HACK: taken from provide(): https://github.com/vuejs/composition-api/blob/master/src/apis/inject.ts#L30\n if (!this._provided) {\n const provideCache = {}\n Object.defineProperty(this, '_provided', {\n get: () => provideCache,\n set: (v) => Object.assign(provideCache, v),\n })\n }\n\n this._provided[clientKey] = client\n\n if (process.env.NODE_ENV === 'development') {\n if (this === this.$root) {\n setupDevtools(this, client)\n }\n }\n },\n })\n } else {\n app.provide(clientKey, client)\n\n if (process.env.NODE_ENV === 'development') {\n setupDevtools(app, client)\n }\n }\n },\n}\n"],"names":["VueQueryPlugin","install","app","options","clientKey","getClientKey","queryClientKey","client","queryClient","clientConfig","queryClientConfig","undefined","QueryClient","isServer","mount","persisterUnmount","clientPersister","isRestoring","value","unmount","promise","then","cleanup","onUnmount","originalUnmount","vueQueryUnmount","isVue2","mixin","beforeCreate","_provided","provideCache","Object","defineProperty","get","set","v","assign","process","env","NODE_ENV","$root","setupDevtools","provide"],"mappings":";;;;;;AA0BO,MAAMA,cAAc,GAAG;EAC5BC,OAAO,EAAE,CAACC,GAAQ,EAAEC,OAA8B,GAAG,EAAE,KAAK;AAC1D,IAAA,MAAMC,SAAS,GAAGC,YAAY,CAACF,OAAO,CAACG,cAAc,CAAC,CAAA;AACtD,IAAA,IAAIC,MAAmB,CAAA;AAEvB,IAAA,IAAI,aAAa,IAAIJ,OAAO,IAAIA,OAAO,CAACK,WAAW,EAAE;MACnDD,MAAM,GAAGJ,OAAO,CAACK,WAAW,CAAA;AAC9B,KAAC,MAAM;MACL,MAAMC,YAAY,GAChB,mBAAmB,IAAIN,OAAO,GAAGA,OAAO,CAACO,iBAAiB,GAAGC,SAAS,CAAA;AACxEJ,MAAAA,MAAM,GAAG,IAAIK,WAAW,CAACH,YAAY,CAAC,CAAA;AACxC,KAAA;IAEA,IAAI,CAACI,QAAQ,EAAE;MACbN,MAAM,CAACO,KAAK,EAAE,CAAA;AAChB,KAAA;IAEA,IAAIC,gBAAgB,GAAG,MAAM;AAC3B;KACD,CAAA;IAED,IAAIZ,OAAO,CAACa,eAAe,EAAE;AAC3BT,MAAAA,MAAM,CAACU,WAAW,CAACC,KAAK,GAAG,IAAI,CAAA;MAC/B,MAAM,CAACC,OAAO,EAAEC,OAAO,CAAC,GAAGjB,OAAO,CAACa,eAAe,CAACT,MAAM,CAAC,CAAA;AAC1DQ,MAAAA,gBAAgB,GAAGI,OAAO,CAAA;MAC1BC,OAAO,CAACC,IAAI,CAAC,MAAM;AACjBd,QAAAA,MAAM,CAACU,WAAW,CAACC,KAAK,GAAG,KAAK,CAAA;AAClC,OAAC,CAAC,CAAA;AACJ,KAAA;IAEA,MAAMI,O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