@katlux/providers 0.1.0-beta.62 → 0.1.0-beta.64

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.cjs CHANGED
@@ -1,7 +1,11 @@
1
1
  'use strict';
2
2
 
3
3
  const vue = require('vue');
4
+ const nuxtAppCompat = require('./nuxtAppCompat.cjs');
4
5
  const providers = require('@katlux/providers');
6
+ const h3 = require('h3');
7
+ const ofetch = require('ofetch');
8
+
5
9
 
6
10
  var EDataFilterOperator = /* @__PURE__ */ ((EDataFilterOperator2) => {
7
11
  EDataFilterOperator2["Equal"] = "==";
@@ -40,7 +44,6 @@ const useDebounce = (callback, delay) => {
40
44
  };
41
45
  };
42
46
 
43
- const APP_MODULE = "#app";
44
47
  class ADataProvider {
45
48
  filter = vue.ref(null);
46
49
  sortList = vue.ref([]);
@@ -60,14 +63,8 @@ class ADataProvider {
60
63
  this.nuxtApp = options.nuxtApp;
61
64
  } else if (undefined) {
62
65
  try {
63
- import(
64
- /* @vite-ignore */
65
- APP_MODULE
66
- ).then((appModule) => {
67
- this.nuxtApp = appModule.useNuxtApp();
68
- }).catch(() => {
69
- });
70
- } catch (e) {
66
+ this.nuxtApp = nuxtAppCompat.getNuxtApp();
67
+ } catch {
71
68
  }
72
69
  }
73
70
  if (options?.filter) {
@@ -90,33 +87,28 @@ class ADataProvider {
90
87
  }
91
88
  if (options?.urlPageParam) {
92
89
  this.urlPageParam.value = options.urlPageParam;
93
- try {
94
- import(
95
- /* @vite-ignore */
96
- APP_MODULE
97
- ).then((appModule) => {
98
- const route = appModule.useRoute();
99
- const pageFromUrl = route.query[options.urlPageParam];
100
- if (pageFromUrl) {
101
- const parsedPage = parseInt(pageFromUrl, 10);
102
- if (!isNaN(parsedPage) && parsedPage > 0) {
103
- this.currentPage.value = parsedPage;
90
+ if (undefined) {
91
+ try {
92
+ const route = nuxtAppCompat.getRoute();
93
+ if (route) {
94
+ const pageFromUrl = route.query[options.urlPageParam];
95
+ if (pageFromUrl) {
96
+ const parsedPage = parseInt(pageFromUrl, 10);
97
+ if (!isNaN(parsedPage) && parsedPage > 0) {
98
+ this.currentPage.value = parsedPage;
99
+ }
104
100
  }
105
101
  }
106
- }).catch(() => {
107
- });
108
- } catch (e) {
102
+ } catch (e) {
103
+ }
109
104
  }
110
105
  }
111
106
  vue.watch(this.currentPage, (newPage) => {
112
107
  this.loadPageData();
113
108
  if (undefined && this.urlPageParam.value) {
114
109
  try {
115
- import(
116
- /* @vite-ignore */
117
- APP_MODULE
118
- ).then((appModule) => {
119
- const router = appModule.useRouter();
110
+ const router = nuxtAppCompat.getRouter();
111
+ if (router) {
120
112
  const currentQuery = { ...router.currentRoute.value.query };
121
113
  if (newPage === 1) {
122
114
  delete currentQuery[this.urlPageParam.value];
@@ -124,8 +116,7 @@ class ADataProvider {
124
116
  currentQuery[this.urlPageParam.value] = String(newPage);
125
117
  }
126
118
  router.replace({ query: currentQuery });
127
- }).catch(() => {
128
- });
119
+ }
129
120
  } catch (e) {
130
121
  }
131
122
  }
@@ -544,9 +535,9 @@ class CMemoryCache extends ACacheProvider {
544
535
  this._hydrateFromPayload();
545
536
  }
546
537
  }
547
- _hydrateFromPayload() {
538
+ async _hydrateFromPayload() {
548
539
  try {
549
- const nuxtApp = typeof useNuxtApp === "function" ? useNuxtApp() : null;
540
+ const nuxtApp = await nuxtAppCompat.getNuxtApp();
550
541
  const payloadData = nuxtApp?.payload?.data || globalThis.__NUXT__?.payload?.data;
551
542
  if (!payloadData) return;
552
543
  for (const key in payloadData) {
@@ -692,9 +683,9 @@ class CLocalStorageCache extends ACacheProvider {
692
683
  this._hydrateFromPayload();
693
684
  }
694
685
  }
695
- _hydrateFromPayload() {
686
+ async _hydrateFromPayload() {
696
687
  try {
697
- const nuxtApp = typeof useNuxtApp === "function" ? useNuxtApp() : null;
688
+ const nuxtApp = await nuxtAppCompat.getNuxtApp();
698
689
  const payloadData = nuxtApp?.payload?.data || window.__NUXT__?.payload?.data;
699
690
  if (!payloadData) return;
700
691
  const prefix = "cache:";
@@ -894,9 +885,9 @@ class CIndexedDBCache extends ACacheProvider {
894
885
  super();
895
886
  this.setStore();
896
887
  }
897
- _hydrateFromPayload() {
888
+ async _hydrateFromPayload() {
898
889
  try {
899
- const nuxtApp = typeof useNuxtApp === "function" ? useNuxtApp() : null;
890
+ const nuxtApp = await nuxtAppCompat.getNuxtApp();
900
891
  const payloadData = nuxtApp?.payload?.data || globalThis.__NUXT__?.payload?.data;
901
892
  if (!payloadData) return;
902
893
  const prefix = "cache:";
@@ -1156,8 +1147,11 @@ class CCookieCache extends ACacheProvider {
1156
1147
  if (undefined) {
1157
1148
  cookieStr = document.cookie;
1158
1149
  } else if (nuxtApp) {
1159
- const headers = nuxtApp.node?.req?.headers || nuxtApp.ssrContext?.event?.node?.req?.headers;
1160
- cookieStr = headers?.["cookie"] || "";
1150
+ const event = nuxtApp.ssrContext?.event;
1151
+ if (event) {
1152
+ const cookies2 = h3.parseCookies(event);
1153
+ return Object.keys(cookies2).filter((k) => k.startsWith(prefix)).map((k) => k.substring(prefix.length));
1154
+ }
1161
1155
  }
1162
1156
  if (!cookieStr) return [];
1163
1157
  const keys = [];
@@ -1188,21 +1182,14 @@ class CCookieCache extends ACacheProvider {
1188
1182
  }
1189
1183
  }
1190
1184
  } else if (nuxtApp) {
1191
- const headers = nuxtApp.node?.req?.headers || nuxtApp.ssrContext?.event?.node?.req?.headers;
1192
- const cookieStr = headers?.["cookie"] || "";
1193
- const name = prefixedKey + "=";
1194
- const ca = cookieStr.split(";");
1195
- for (let i = 0; i < ca.length; i++) {
1196
- let c = ca[i].trim();
1197
- if (c.indexOf(name) === 0) {
1198
- cookieValue = c.substring(name.length, c.length);
1199
- break;
1200
- }
1185
+ const event = nuxtApp.ssrContext?.event;
1186
+ if (event) {
1187
+ cookieValue = h3.getCookie(event, prefixedKey) ?? null;
1201
1188
  }
1202
1189
  }
1203
1190
  if (!cookieValue) return null;
1204
1191
  try {
1205
- const val = JSON.parse(decodeURIComponent(cookieValue));
1192
+ const val = JSON.parse(cookieValue);
1206
1193
  if (val && val.timestamp && val.lifetime) {
1207
1194
  if (Date.now() - val.timestamp <= val.lifetime) {
1208
1195
  return val.data;
@@ -1222,42 +1209,30 @@ class CCookieCache extends ACacheProvider {
1222
1209
  timestamp: Date.now(),
1223
1210
  lifetime
1224
1211
  };
1225
- const cookieValue = encodeURIComponent(JSON.stringify(entry));
1226
1212
  const maxAge = Math.floor(lifetime / 1e3);
1227
- new Date(Date.now() + lifetime).toUTCString();
1228
- const cookieStr = `${prefixedKey}=${cookieValue}; Max-Age=${maxAge}; Path=/; SameSite=Lax${undefined ? "; HttpOnly" : ""}`;
1229
1213
  if (undefined) {
1230
- document.cookie = cookieStr;
1214
+ const cookieValue = encodeURIComponent(JSON.stringify(entry));
1215
+ document.cookie = `${prefixedKey}=${cookieValue}; Max-Age=${maxAge}; Path=/; SameSite=Lax`;
1231
1216
  } else if (nuxtApp) {
1232
- const res = nuxtApp.node?.res || nuxtApp.ssrContext?.event?.node?.res;
1233
- if (res) {
1234
- const existing = res.getHeader("Set-Cookie");
1235
- if (!existing) {
1236
- res.setHeader("Set-Cookie", cookieStr);
1237
- } else if (Array.isArray(existing)) {
1238
- res.setHeader("Set-Cookie", [...existing, cookieStr]);
1239
- } else {
1240
- res.setHeader("Set-Cookie", [existing, cookieStr]);
1241
- }
1217
+ const event = nuxtApp.ssrContext?.event;
1218
+ if (event) {
1219
+ h3.setCookie(event, prefixedKey, JSON.stringify(entry), {
1220
+ maxAge,
1221
+ path: "/",
1222
+ sameSite: "lax",
1223
+ httpOnly: true
1224
+ });
1242
1225
  }
1243
1226
  }
1244
1227
  }
1245
1228
  async remove(key, nuxtApp) {
1246
1229
  const prefixedKey = "cache:" + key;
1247
- const cookieStr = `${prefixedKey}=; Max-Age=0; Path=/; SameSite=Lax${undefined ? "; HttpOnly" : ""}`;
1248
1230
  if (undefined) {
1249
- document.cookie = cookieStr;
1231
+ document.cookie = `${prefixedKey}=; Max-Age=0; Path=/; SameSite=Lax`;
1250
1232
  } else if (nuxtApp) {
1251
- const res = nuxtApp.node?.res || nuxtApp.ssrContext?.event?.node?.res;
1252
- if (res) {
1253
- const existing = res.getHeader("Set-Cookie");
1254
- if (!existing) {
1255
- res.setHeader("Set-Cookie", cookieStr);
1256
- } else if (Array.isArray(existing)) {
1257
- res.setHeader("Set-Cookie", [...existing, cookieStr]);
1258
- } else {
1259
- res.setHeader("Set-Cookie", [existing, cookieStr]);
1260
- }
1233
+ const event = nuxtApp.ssrContext?.event;
1234
+ if (event) {
1235
+ h3.deleteCookie(event, prefixedKey, { path: "/", sameSite: "lax", httpOnly: true });
1261
1236
  }
1262
1237
  }
1263
1238
  }
@@ -1275,21 +1250,14 @@ class CCookieCache extends ACacheProvider {
1275
1250
  }
1276
1251
  }
1277
1252
  } else if (nuxtApp) {
1278
- const headers = nuxtApp.node?.req?.headers || nuxtApp.ssrContext?.event?.node?.req?.headers;
1279
- const cookieStr = headers?.["cookie"] || "";
1280
- const name = prefixedKey + "=";
1281
- const ca = cookieStr.split(";");
1282
- for (let i = 0; i < ca.length; i++) {
1283
- let c = ca[i].trim();
1284
- if (c.indexOf(name) === 0) {
1285
- cookieValue = c.substring(name.length, c.length);
1286
- break;
1287
- }
1253
+ const event = nuxtApp.ssrContext?.event;
1254
+ if (event) {
1255
+ cookieValue = h3.getCookie(event, prefixedKey) ?? null;
1288
1256
  }
1289
1257
  }
1290
1258
  if (!cookieValue) return null;
1291
1259
  try {
1292
- const val = JSON.parse(decodeURIComponent(cookieValue));
1260
+ const val = JSON.parse(cookieValue);
1293
1261
  if (val && val.timestamp && val.lifetime) {
1294
1262
  return Math.max(0, val.timestamp + val.lifetime - Date.now());
1295
1263
  }
@@ -1718,9 +1686,13 @@ class RequestProvider {
1718
1686
  const nuxtApp = options?.nuxtApp;
1719
1687
  let serverHeaders = {};
1720
1688
  if (nuxtApp && undefined) {
1721
- const req = nuxtApp.node?.req || nuxtApp.ssrContext?.event?.node?.req;
1722
- if (req?.headers?.cookie) {
1723
- serverHeaders = { cookie: req.headers.cookie };
1689
+ const event = nuxtApp.ssrContext?.event;
1690
+ if (event) {
1691
+ const { getRequestHeader } = await import('h3');
1692
+ const cookieHeader = getRequestHeader(event, "cookie");
1693
+ if (cookieHeader) {
1694
+ serverHeaders = { cookie: cookieHeader };
1695
+ }
1724
1696
  }
1725
1697
  }
1726
1698
  const provider = cacheStrategy ? CacheProviderFactory.getProvider(cacheStrategy) : this.cacheProvider;
@@ -1741,7 +1713,7 @@ class RequestProvider {
1741
1713
  headers: { ...headers, ...serverHeaders },
1742
1714
  query
1743
1715
  };
1744
- const responseData = await $fetch(url, fetchOptions);
1716
+ const responseData = await ofetch.$fetch(url, fetchOptions);
1745
1717
  if (provider && cacheLifetime && responseData && isGetRequest) {
1746
1718
  await provider.set(uniqueKey, responseData, cacheLifetime, nuxtApp);
1747
1719
  }
@@ -1784,7 +1756,7 @@ class CAPIFlatClientDataProvider extends CFlatClientDataProvider {
1784
1756
  };
1785
1757
  const key = `${this.contextKey.value}`;
1786
1758
  if (this.contextKey.value && this.initialLoad.value) {
1787
- const { data } = useNuxtData(key);
1759
+ const { data } = nuxtAppCompat.getNuxtData(key, this.nuxtApp);
1788
1760
  if (data.value) {
1789
1761
  const result = data.value;
1790
1762
  this.setData(result.rows);
@@ -1794,7 +1766,7 @@ class CAPIFlatClientDataProvider extends CFlatClientDataProvider {
1794
1766
  }
1795
1767
  }
1796
1768
  if (undefined && this.contextKey.value) {
1797
- const { data } = await useAsyncData(key, fetcher);
1769
+ const { data } = await nuxtAppCompat.getAsyncData(key, fetcher, this.nuxtApp);
1798
1770
  if (data.value) {
1799
1771
  const result = data.value;
1800
1772
  this.setData(result.rows);
@@ -1851,7 +1823,7 @@ class CAPIFlatClientDataProvider extends CFlatClientDataProvider {
1851
1823
  await this.requestProvider.cacheProvider.removeByPrefix(this.apiUrl.value);
1852
1824
  }
1853
1825
  if (this.contextKey.value) {
1854
- clearNuxtData(this.contextKey.value);
1826
+ nuxtAppCompat.clearNuxtDataKey(this.contextKey.value, this.nuxtApp);
1855
1827
  }
1856
1828
  }
1857
1829
  }
@@ -1878,7 +1850,7 @@ class CAPIFlatClientDataProvider extends CFlatClientDataProvider {
1878
1850
  await this.requestProvider.cacheProvider.removeByPrefix(this.apiUrl.value);
1879
1851
  }
1880
1852
  if (this.contextKey.value) {
1881
- clearNuxtData(this.contextKey.value);
1853
+ nuxtAppCompat.clearNuxtDataKey(this.contextKey.value, this.nuxtApp);
1882
1854
  }
1883
1855
  }
1884
1856
  }
@@ -1900,7 +1872,7 @@ class CAPIFlatClientDataProvider extends CFlatClientDataProvider {
1900
1872
  await this.requestProvider.cacheProvider.removeByPrefix(this.apiUrl.value);
1901
1873
  }
1902
1874
  if (this.contextKey.value) {
1903
- clearNuxtData(this.contextKey.value);
1875
+ nuxtAppCompat.clearNuxtDataKey(this.contextKey.value, this.nuxtApp);
1904
1876
  }
1905
1877
  }
1906
1878
  }
@@ -1937,7 +1909,7 @@ class CFlatServerDataProvider extends ADataProvider {
1937
1909
  ].join("-");
1938
1910
  const fetcher = async () => await this.pageDataHandler.value(this.currentPage.value, this.pageSize.value, this.filter.value, this.sortList.value, options);
1939
1911
  if (!options?.disableCache && this.SSR.value && this.contextKey.value && this.initialLoad.value) {
1940
- const { data } = useNuxtData(key);
1912
+ const { data } = nuxtAppCompat.getNuxtData(key, this.nuxtApp);
1941
1913
  if (data.value) {
1942
1914
  const result = data.value;
1943
1915
  this.pageData.value = result.rows;
@@ -1949,7 +1921,7 @@ class CFlatServerDataProvider extends ADataProvider {
1949
1921
  }
1950
1922
  if (this.SSR.value && this.contextKey.value) {
1951
1923
  this.loading.value = true;
1952
- const { data } = await useAsyncData(key, fetcher);
1924
+ const { data } = await nuxtAppCompat.getAsyncData(key, fetcher, this.nuxtApp);
1953
1925
  if (data.value) {
1954
1926
  const result = data.value;
1955
1927
  this.pageData.value = result.rows;
@@ -1960,7 +1932,7 @@ class CFlatServerDataProvider extends ADataProvider {
1960
1932
  }
1961
1933
  }
1962
1934
  if (!this.SSR.value) {
1963
- onNuxtReady(() => {
1935
+ nuxtAppCompat.onNuxtReadyCallback(() => {
1964
1936
  this.loading.value = true;
1965
1937
  fetcher().then((returnedData2) => {
1966
1938
  this.pageData.value = returnedData2.rows;
@@ -2327,7 +2299,7 @@ class CAPITreeClientDataProvider extends CTreeClientDataProvider {
2327
2299
  };
2328
2300
  const key = `${this.contextKey.value}`;
2329
2301
  if (this.contextKey.value && this.initialLoad.value) {
2330
- const { data } = useNuxtData(key);
2302
+ const { data } = nuxtAppCompat.getNuxtData(key, this.nuxtApp);
2331
2303
  if (data.value) {
2332
2304
  const result = data.value;
2333
2305
  this.setData(result.rows);
@@ -2337,7 +2309,7 @@ class CAPITreeClientDataProvider extends CTreeClientDataProvider {
2337
2309
  }
2338
2310
  }
2339
2311
  if (undefined && this.contextKey.value) {
2340
- const { data } = await useAsyncData(key, fetcher);
2312
+ const { data } = await nuxtAppCompat.getAsyncData(key, fetcher, this.nuxtApp);
2341
2313
  if (data.value) {
2342
2314
  const result = data.value;
2343
2315
  this.setData(result.rows);
@@ -2393,7 +2365,7 @@ class CAPITreeClientDataProvider extends CTreeClientDataProvider {
2393
2365
  await this.requestProvider.cacheProvider.removeByPrefix(this.apiUrl.value);
2394
2366
  }
2395
2367
  if (this.contextKey.value) {
2396
- clearNuxtData(this.contextKey.value);
2368
+ nuxtAppCompat.clearNuxtDataKey(this.contextKey.value, this.nuxtApp);
2397
2369
  }
2398
2370
  }
2399
2371
  }
@@ -2420,7 +2392,7 @@ class CAPITreeClientDataProvider extends CTreeClientDataProvider {
2420
2392
  await this.requestProvider.cacheProvider.removeByPrefix(this.apiUrl.value);
2421
2393
  }
2422
2394
  if (this.contextKey.value) {
2423
- clearNuxtData(this.contextKey.value);
2395
+ nuxtAppCompat.clearNuxtDataKey(this.contextKey.value, this.nuxtApp);
2424
2396
  }
2425
2397
  }
2426
2398
  }
@@ -2442,7 +2414,7 @@ class CAPITreeClientDataProvider extends CTreeClientDataProvider {
2442
2414
  await this.requestProvider.cacheProvider.removeByPrefix(this.apiUrl.value);
2443
2415
  }
2444
2416
  if (this.contextKey.value) {
2445
- clearNuxtData(this.contextKey.value);
2417
+ nuxtAppCompat.clearNuxtDataKey(this.contextKey.value, this.nuxtApp);
2446
2418
  }
2447
2419
  }
2448
2420
  }
@@ -2511,7 +2483,7 @@ class CTreeServerDataProvider extends ADataProvider {
2511
2483
  options
2512
2484
  );
2513
2485
  if (!options?.disableCache && this.SSR.value && this.contextKey.value && this.initialLoad.value) {
2514
- const { data } = useNuxtData(key);
2486
+ const { data } = nuxtAppCompat.getNuxtData(key, this.nuxtApp);
2515
2487
  if (data.value) {
2516
2488
  const result = data.value;
2517
2489
  this.pageData.value = result.rows;
@@ -2523,7 +2495,7 @@ class CTreeServerDataProvider extends ADataProvider {
2523
2495
  }
2524
2496
  if (this.SSR.value && this.contextKey.value) {
2525
2497
  this.loading.value = true;
2526
- const { data } = await useAsyncData(key, fetcher);
2498
+ const { data } = await nuxtAppCompat.getAsyncData(key, fetcher, this.nuxtApp);
2527
2499
  if (data.value) {
2528
2500
  const result = data.value;
2529
2501
  this.pageData.value = result.rows;
@@ -2534,7 +2506,7 @@ class CTreeServerDataProvider extends ADataProvider {
2534
2506
  }
2535
2507
  }
2536
2508
  if (!this.SSR.value) {
2537
- onNuxtReady(() => {
2509
+ nuxtAppCompat.onNuxtReadyCallback(() => {
2538
2510
  this.loading.value = true;
2539
2511
  fetcher().then((returnedData2) => {
2540
2512
  this.pageData.value = returnedData2.rows;
package/dist/index.mjs CHANGED
@@ -1,5 +1,9 @@
1
1
  import { ref, watch, computed } from 'vue';
2
+ import { getNuxtApp, getRoute, getRouter, getNuxtData, getAsyncData, clearNuxtDataKey, onNuxtReadyCallback } from './nuxtAppCompat.mjs';
2
3
  import { EDataFilterOperator as EDataFilterOperator$1 } from '@katlux/providers';
4
+ import { parseCookies, getCookie, setCookie, deleteCookie } from 'h3';
5
+ import { $fetch } from 'ofetch';
6
+
3
7
 
4
8
  var EDataFilterOperator = /* @__PURE__ */ ((EDataFilterOperator2) => {
5
9
  EDataFilterOperator2["Equal"] = "==";
@@ -38,7 +42,6 @@ const useDebounce = (callback, delay) => {
38
42
  };
39
43
  };
40
44
 
41
- const APP_MODULE = "#app";
42
45
  class ADataProvider {
43
46
  filter = ref(null);
44
47
  sortList = ref([]);
@@ -56,16 +59,10 @@ class ADataProvider {
56
59
  constructor(options) {
57
60
  if (options?.nuxtApp) {
58
61
  this.nuxtApp = options.nuxtApp;
59
- } else if (import.meta.server) {
62
+ } else if (import.meta.client) {
60
63
  try {
61
- import(
62
- /* @vite-ignore */
63
- APP_MODULE
64
- ).then((appModule) => {
65
- this.nuxtApp = appModule.useNuxtApp();
66
- }).catch(() => {
67
- });
68
- } catch (e) {
64
+ this.nuxtApp = getNuxtApp();
65
+ } catch {
69
66
  }
70
67
  }
71
68
  if (options?.filter) {
@@ -88,33 +85,28 @@ class ADataProvider {
88
85
  }
89
86
  if (options?.urlPageParam) {
90
87
  this.urlPageParam.value = options.urlPageParam;
91
- try {
92
- import(
93
- /* @vite-ignore */
94
- APP_MODULE
95
- ).then((appModule) => {
96
- const route = appModule.useRoute();
97
- const pageFromUrl = route.query[options.urlPageParam];
98
- if (pageFromUrl) {
99
- const parsedPage = parseInt(pageFromUrl, 10);
100
- if (!isNaN(parsedPage) && parsedPage > 0) {
101
- this.currentPage.value = parsedPage;
88
+ if (import.meta.client) {
89
+ try {
90
+ const route = getRoute();
91
+ if (route) {
92
+ const pageFromUrl = route.query[options.urlPageParam];
93
+ if (pageFromUrl) {
94
+ const parsedPage = parseInt(pageFromUrl, 10);
95
+ if (!isNaN(parsedPage) && parsedPage > 0) {
96
+ this.currentPage.value = parsedPage;
97
+ }
102
98
  }
103
99
  }
104
- }).catch(() => {
105
- });
106
- } catch (e) {
100
+ } catch (e) {
101
+ }
107
102
  }
108
103
  }
109
104
  watch(this.currentPage, (newPage) => {
110
105
  this.loadPageData();
111
106
  if (import.meta.client && this.urlPageParam.value) {
112
107
  try {
113
- import(
114
- /* @vite-ignore */
115
- APP_MODULE
116
- ).then((appModule) => {
117
- const router = appModule.useRouter();
108
+ const router = getRouter();
109
+ if (router) {
118
110
  const currentQuery = { ...router.currentRoute.value.query };
119
111
  if (newPage === 1) {
120
112
  delete currentQuery[this.urlPageParam.value];
@@ -122,8 +114,7 @@ class ADataProvider {
122
114
  currentQuery[this.urlPageParam.value] = String(newPage);
123
115
  }
124
116
  router.replace({ query: currentQuery });
125
- }).catch(() => {
126
- });
117
+ }
127
118
  } catch (e) {
128
119
  }
129
120
  }
@@ -542,9 +533,9 @@ class CMemoryCache extends ACacheProvider {
542
533
  this._hydrateFromPayload();
543
534
  }
544
535
  }
545
- _hydrateFromPayload() {
536
+ async _hydrateFromPayload() {
546
537
  try {
547
- const nuxtApp = typeof useNuxtApp === "function" ? useNuxtApp() : null;
538
+ const nuxtApp = await getNuxtApp();
548
539
  const payloadData = nuxtApp?.payload?.data || globalThis.__NUXT__?.payload?.data;
549
540
  if (!payloadData) return;
550
541
  for (const key in payloadData) {
@@ -690,9 +681,9 @@ class CLocalStorageCache extends ACacheProvider {
690
681
  this._hydrateFromPayload();
691
682
  }
692
683
  }
693
- _hydrateFromPayload() {
684
+ async _hydrateFromPayload() {
694
685
  try {
695
- const nuxtApp = typeof useNuxtApp === "function" ? useNuxtApp() : null;
686
+ const nuxtApp = await getNuxtApp();
696
687
  const payloadData = nuxtApp?.payload?.data || window.__NUXT__?.payload?.data;
697
688
  if (!payloadData) return;
698
689
  const prefix = "cache:";
@@ -892,9 +883,9 @@ class CIndexedDBCache extends ACacheProvider {
892
883
  super();
893
884
  this.setStore();
894
885
  }
895
- _hydrateFromPayload() {
886
+ async _hydrateFromPayload() {
896
887
  try {
897
- const nuxtApp = typeof useNuxtApp === "function" ? useNuxtApp() : null;
888
+ const nuxtApp = await getNuxtApp();
898
889
  const payloadData = nuxtApp?.payload?.data || globalThis.__NUXT__?.payload?.data;
899
890
  if (!payloadData) return;
900
891
  const prefix = "cache:";
@@ -1154,8 +1145,11 @@ class CCookieCache extends ACacheProvider {
1154
1145
  if (import.meta.client) {
1155
1146
  cookieStr = document.cookie;
1156
1147
  } else if (nuxtApp) {
1157
- const headers = nuxtApp.node?.req?.headers || nuxtApp.ssrContext?.event?.node?.req?.headers;
1158
- cookieStr = headers?.["cookie"] || "";
1148
+ const event = nuxtApp.ssrContext?.event;
1149
+ if (event) {
1150
+ const cookies2 = parseCookies(event);
1151
+ return Object.keys(cookies2).filter((k) => k.startsWith(prefix)).map((k) => k.substring(prefix.length));
1152
+ }
1159
1153
  }
1160
1154
  if (!cookieStr) return [];
1161
1155
  const keys = [];
@@ -1186,21 +1180,14 @@ class CCookieCache extends ACacheProvider {
1186
1180
  }
1187
1181
  }
1188
1182
  } else if (nuxtApp) {
1189
- const headers = nuxtApp.node?.req?.headers || nuxtApp.ssrContext?.event?.node?.req?.headers;
1190
- const cookieStr = headers?.["cookie"] || "";
1191
- const name = prefixedKey + "=";
1192
- const ca = cookieStr.split(";");
1193
- for (let i = 0; i < ca.length; i++) {
1194
- let c = ca[i].trim();
1195
- if (c.indexOf(name) === 0) {
1196
- cookieValue = c.substring(name.length, c.length);
1197
- break;
1198
- }
1183
+ const event = nuxtApp.ssrContext?.event;
1184
+ if (event) {
1185
+ cookieValue = getCookie(event, prefixedKey) ?? null;
1199
1186
  }
1200
1187
  }
1201
1188
  if (!cookieValue) return null;
1202
1189
  try {
1203
- const val = JSON.parse(decodeURIComponent(cookieValue));
1190
+ const val = JSON.parse(cookieValue);
1204
1191
  if (val && val.timestamp && val.lifetime) {
1205
1192
  if (Date.now() - val.timestamp <= val.lifetime) {
1206
1193
  return val.data;
@@ -1220,42 +1207,30 @@ class CCookieCache extends ACacheProvider {
1220
1207
  timestamp: Date.now(),
1221
1208
  lifetime
1222
1209
  };
1223
- const cookieValue = encodeURIComponent(JSON.stringify(entry));
1224
1210
  const maxAge = Math.floor(lifetime / 1e3);
1225
- new Date(Date.now() + lifetime).toUTCString();
1226
- const cookieStr = `${prefixedKey}=${cookieValue}; Max-Age=${maxAge}; Path=/; SameSite=Lax${import.meta.server ? "; HttpOnly" : ""}`;
1227
1211
  if (import.meta.client) {
1228
- document.cookie = cookieStr;
1212
+ const cookieValue = encodeURIComponent(JSON.stringify(entry));
1213
+ document.cookie = `${prefixedKey}=${cookieValue}; Max-Age=${maxAge}; Path=/; SameSite=Lax`;
1229
1214
  } else if (nuxtApp) {
1230
- const res = nuxtApp.node?.res || nuxtApp.ssrContext?.event?.node?.res;
1231
- if (res) {
1232
- const existing = res.getHeader("Set-Cookie");
1233
- if (!existing) {
1234
- res.setHeader("Set-Cookie", cookieStr);
1235
- } else if (Array.isArray(existing)) {
1236
- res.setHeader("Set-Cookie", [...existing, cookieStr]);
1237
- } else {
1238
- res.setHeader("Set-Cookie", [existing, cookieStr]);
1239
- }
1215
+ const event = nuxtApp.ssrContext?.event;
1216
+ if (event) {
1217
+ setCookie(event, prefixedKey, JSON.stringify(entry), {
1218
+ maxAge,
1219
+ path: "/",
1220
+ sameSite: "lax",
1221
+ httpOnly: true
1222
+ });
1240
1223
  }
1241
1224
  }
1242
1225
  }
1243
1226
  async remove(key, nuxtApp) {
1244
1227
  const prefixedKey = "cache:" + key;
1245
- const cookieStr = `${prefixedKey}=; Max-Age=0; Path=/; SameSite=Lax${import.meta.server ? "; HttpOnly" : ""}`;
1246
1228
  if (import.meta.client) {
1247
- document.cookie = cookieStr;
1229
+ document.cookie = `${prefixedKey}=; Max-Age=0; Path=/; SameSite=Lax`;
1248
1230
  } else if (nuxtApp) {
1249
- const res = nuxtApp.node?.res || nuxtApp.ssrContext?.event?.node?.res;
1250
- if (res) {
1251
- const existing = res.getHeader("Set-Cookie");
1252
- if (!existing) {
1253
- res.setHeader("Set-Cookie", cookieStr);
1254
- } else if (Array.isArray(existing)) {
1255
- res.setHeader("Set-Cookie", [...existing, cookieStr]);
1256
- } else {
1257
- res.setHeader("Set-Cookie", [existing, cookieStr]);
1258
- }
1231
+ const event = nuxtApp.ssrContext?.event;
1232
+ if (event) {
1233
+ deleteCookie(event, prefixedKey, { path: "/", sameSite: "lax", httpOnly: true });
1259
1234
  }
1260
1235
  }
1261
1236
  }
@@ -1273,21 +1248,14 @@ class CCookieCache extends ACacheProvider {
1273
1248
  }
1274
1249
  }
1275
1250
  } else if (nuxtApp) {
1276
- const headers = nuxtApp.node?.req?.headers || nuxtApp.ssrContext?.event?.node?.req?.headers;
1277
- const cookieStr = headers?.["cookie"] || "";
1278
- const name = prefixedKey + "=";
1279
- const ca = cookieStr.split(";");
1280
- for (let i = 0; i < ca.length; i++) {
1281
- let c = ca[i].trim();
1282
- if (c.indexOf(name) === 0) {
1283
- cookieValue = c.substring(name.length, c.length);
1284
- break;
1285
- }
1251
+ const event = nuxtApp.ssrContext?.event;
1252
+ if (event) {
1253
+ cookieValue = getCookie(event, prefixedKey) ?? null;
1286
1254
  }
1287
1255
  }
1288
1256
  if (!cookieValue) return null;
1289
1257
  try {
1290
- const val = JSON.parse(decodeURIComponent(cookieValue));
1258
+ const val = JSON.parse(cookieValue);
1291
1259
  if (val && val.timestamp && val.lifetime) {
1292
1260
  return Math.max(0, val.timestamp + val.lifetime - Date.now());
1293
1261
  }
@@ -1716,9 +1684,13 @@ class RequestProvider {
1716
1684
  const nuxtApp = options?.nuxtApp;
1717
1685
  let serverHeaders = {};
1718
1686
  if (nuxtApp && import.meta.server) {
1719
- const req = nuxtApp.node?.req || nuxtApp.ssrContext?.event?.node?.req;
1720
- if (req?.headers?.cookie) {
1721
- serverHeaders = { cookie: req.headers.cookie };
1687
+ const event = nuxtApp.ssrContext?.event;
1688
+ if (event) {
1689
+ const { getRequestHeader } = await import('h3');
1690
+ const cookieHeader = getRequestHeader(event, "cookie");
1691
+ if (cookieHeader) {
1692
+ serverHeaders = { cookie: cookieHeader };
1693
+ }
1722
1694
  }
1723
1695
  }
1724
1696
  const provider = cacheStrategy ? CacheProviderFactory.getProvider(cacheStrategy) : this.cacheProvider;
@@ -1782,7 +1754,7 @@ class CAPIFlatClientDataProvider extends CFlatClientDataProvider {
1782
1754
  };
1783
1755
  const key = `${this.contextKey.value}`;
1784
1756
  if (this.contextKey.value && this.initialLoad.value) {
1785
- const { data } = useNuxtData(key);
1757
+ const { data } = getNuxtData(key, this.nuxtApp);
1786
1758
  if (data.value) {
1787
1759
  const result = data.value;
1788
1760
  this.setData(result.rows);
@@ -1792,7 +1764,7 @@ class CAPIFlatClientDataProvider extends CFlatClientDataProvider {
1792
1764
  }
1793
1765
  }
1794
1766
  if (import.meta.server && this.contextKey.value) {
1795
- const { data } = await useAsyncData(key, fetcher);
1767
+ const { data } = await getAsyncData(key, fetcher, this.nuxtApp);
1796
1768
  if (data.value) {
1797
1769
  const result = data.value;
1798
1770
  this.setData(result.rows);
@@ -1849,7 +1821,7 @@ class CAPIFlatClientDataProvider extends CFlatClientDataProvider {
1849
1821
  await this.requestProvider.cacheProvider.removeByPrefix(this.apiUrl.value);
1850
1822
  }
1851
1823
  if (this.contextKey.value) {
1852
- clearNuxtData(this.contextKey.value);
1824
+ clearNuxtDataKey(this.contextKey.value, this.nuxtApp);
1853
1825
  }
1854
1826
  }
1855
1827
  }
@@ -1876,7 +1848,7 @@ class CAPIFlatClientDataProvider extends CFlatClientDataProvider {
1876
1848
  await this.requestProvider.cacheProvider.removeByPrefix(this.apiUrl.value);
1877
1849
  }
1878
1850
  if (this.contextKey.value) {
1879
- clearNuxtData(this.contextKey.value);
1851
+ clearNuxtDataKey(this.contextKey.value, this.nuxtApp);
1880
1852
  }
1881
1853
  }
1882
1854
  }
@@ -1898,7 +1870,7 @@ class CAPIFlatClientDataProvider extends CFlatClientDataProvider {
1898
1870
  await this.requestProvider.cacheProvider.removeByPrefix(this.apiUrl.value);
1899
1871
  }
1900
1872
  if (this.contextKey.value) {
1901
- clearNuxtData(this.contextKey.value);
1873
+ clearNuxtDataKey(this.contextKey.value, this.nuxtApp);
1902
1874
  }
1903
1875
  }
1904
1876
  }
@@ -1935,7 +1907,7 @@ class CFlatServerDataProvider extends ADataProvider {
1935
1907
  ].join("-");
1936
1908
  const fetcher = async () => await this.pageDataHandler.value(this.currentPage.value, this.pageSize.value, this.filter.value, this.sortList.value, options);
1937
1909
  if (!options?.disableCache && this.SSR.value && this.contextKey.value && this.initialLoad.value) {
1938
- const { data } = useNuxtData(key);
1910
+ const { data } = getNuxtData(key, this.nuxtApp);
1939
1911
  if (data.value) {
1940
1912
  const result = data.value;
1941
1913
  this.pageData.value = result.rows;
@@ -1947,7 +1919,7 @@ class CFlatServerDataProvider extends ADataProvider {
1947
1919
  }
1948
1920
  if (this.SSR.value && this.contextKey.value) {
1949
1921
  this.loading.value = true;
1950
- const { data } = await useAsyncData(key, fetcher);
1922
+ const { data } = await getAsyncData(key, fetcher, this.nuxtApp);
1951
1923
  if (data.value) {
1952
1924
  const result = data.value;
1953
1925
  this.pageData.value = result.rows;
@@ -1958,7 +1930,7 @@ class CFlatServerDataProvider extends ADataProvider {
1958
1930
  }
1959
1931
  }
1960
1932
  if (!this.SSR.value) {
1961
- onNuxtReady(() => {
1933
+ onNuxtReadyCallback(() => {
1962
1934
  this.loading.value = true;
1963
1935
  fetcher().then((returnedData2) => {
1964
1936
  this.pageData.value = returnedData2.rows;
@@ -2325,7 +2297,7 @@ class CAPITreeClientDataProvider extends CTreeClientDataProvider {
2325
2297
  };
2326
2298
  const key = `${this.contextKey.value}`;
2327
2299
  if (this.contextKey.value && this.initialLoad.value) {
2328
- const { data } = useNuxtData(key);
2300
+ const { data } = getNuxtData(key, this.nuxtApp);
2329
2301
  if (data.value) {
2330
2302
  const result = data.value;
2331
2303
  this.setData(result.rows);
@@ -2335,7 +2307,7 @@ class CAPITreeClientDataProvider extends CTreeClientDataProvider {
2335
2307
  }
2336
2308
  }
2337
2309
  if (import.meta.server && this.contextKey.value) {
2338
- const { data } = await useAsyncData(key, fetcher);
2310
+ const { data } = await getAsyncData(key, fetcher, this.nuxtApp);
2339
2311
  if (data.value) {
2340
2312
  const result = data.value;
2341
2313
  this.setData(result.rows);
@@ -2391,7 +2363,7 @@ class CAPITreeClientDataProvider extends CTreeClientDataProvider {
2391
2363
  await this.requestProvider.cacheProvider.removeByPrefix(this.apiUrl.value);
2392
2364
  }
2393
2365
  if (this.contextKey.value) {
2394
- clearNuxtData(this.contextKey.value);
2366
+ clearNuxtDataKey(this.contextKey.value, this.nuxtApp);
2395
2367
  }
2396
2368
  }
2397
2369
  }
@@ -2418,7 +2390,7 @@ class CAPITreeClientDataProvider extends CTreeClientDataProvider {
2418
2390
  await this.requestProvider.cacheProvider.removeByPrefix(this.apiUrl.value);
2419
2391
  }
2420
2392
  if (this.contextKey.value) {
2421
- clearNuxtData(this.contextKey.value);
2393
+ clearNuxtDataKey(this.contextKey.value, this.nuxtApp);
2422
2394
  }
2423
2395
  }
2424
2396
  }
@@ -2440,7 +2412,7 @@ class CAPITreeClientDataProvider extends CTreeClientDataProvider {
2440
2412
  await this.requestProvider.cacheProvider.removeByPrefix(this.apiUrl.value);
2441
2413
  }
2442
2414
  if (this.contextKey.value) {
2443
- clearNuxtData(this.contextKey.value);
2415
+ clearNuxtDataKey(this.contextKey.value, this.nuxtApp);
2444
2416
  }
2445
2417
  }
2446
2418
  }
@@ -2509,7 +2481,7 @@ class CTreeServerDataProvider extends ADataProvider {
2509
2481
  options
2510
2482
  );
2511
2483
  if (!options?.disableCache && this.SSR.value && this.contextKey.value && this.initialLoad.value) {
2512
- const { data } = useNuxtData(key);
2484
+ const { data } = getNuxtData(key, this.nuxtApp);
2513
2485
  if (data.value) {
2514
2486
  const result = data.value;
2515
2487
  this.pageData.value = result.rows;
@@ -2521,7 +2493,7 @@ class CTreeServerDataProvider extends ADataProvider {
2521
2493
  }
2522
2494
  if (this.SSR.value && this.contextKey.value) {
2523
2495
  this.loading.value = true;
2524
- const { data } = await useAsyncData(key, fetcher);
2496
+ const { data } = await getAsyncData(key, fetcher, this.nuxtApp);
2525
2497
  if (data.value) {
2526
2498
  const result = data.value;
2527
2499
  this.pageData.value = result.rows;
@@ -2532,7 +2504,7 @@ class CTreeServerDataProvider extends ADataProvider {
2532
2504
  }
2533
2505
  }
2534
2506
  if (!this.SSR.value) {
2535
- onNuxtReady(() => {
2507
+ onNuxtReadyCallback(() => {
2536
2508
  this.loading.value = true;
2537
2509
  fetcher().then((returnedData2) => {
2538
2510
  this.pageData.value = returnedData2.rows;
@@ -0,0 +1,55 @@
1
+ 'use strict';
2
+
3
+ const _app = require('#app');
4
+
5
+ function getNuxtApp() {
6
+ try {
7
+ return _app.useNuxtApp();
8
+ } catch {
9
+ return null;
10
+ }
11
+ }
12
+ function getNuxtData(key, nuxtApp) {
13
+ if (nuxtApp?.runWithContext) {
14
+ return nuxtApp.runWithContext(() => _app.useNuxtData(key));
15
+ }
16
+ return _app.useNuxtData(key);
17
+ }
18
+ async function getAsyncData(key, fetcher, nuxtApp) {
19
+ if (nuxtApp?.runWithContext) {
20
+ return nuxtApp.runWithContext(() => _app.useAsyncData(key, fetcher));
21
+ }
22
+ return _app.useAsyncData(key, fetcher);
23
+ }
24
+ function clearNuxtDataKey(key, nuxtApp) {
25
+ if (nuxtApp?.runWithContext) {
26
+ nuxtApp.runWithContext(() => _app.clearNuxtData(key));
27
+ } else {
28
+ _app.clearNuxtData(key);
29
+ }
30
+ }
31
+ function onNuxtReadyCallback(cb) {
32
+ _app.onNuxtReady(cb);
33
+ }
34
+ function getRoute() {
35
+ try {
36
+ return _app.useRoute();
37
+ } catch {
38
+ return null;
39
+ }
40
+ }
41
+ function getRouter() {
42
+ try {
43
+ return _app.useRouter();
44
+ } catch {
45
+ return null;
46
+ }
47
+ }
48
+
49
+ exports.clearNuxtDataKey = clearNuxtDataKey;
50
+ exports.getAsyncData = getAsyncData;
51
+ exports.getNuxtApp = getNuxtApp;
52
+ exports.getNuxtData = getNuxtData;
53
+ exports.getRoute = getRoute;
54
+ exports.getRouter = getRouter;
55
+ exports.onNuxtReadyCallback = onNuxtReadyCallback;
@@ -0,0 +1,31 @@
1
+ declare function getNuxtApp(): any;
2
+ /**
3
+ * Read SSR payload data for a given key.
4
+ * Must be called via runWithContext when outside setup().
5
+ */
6
+ declare function getNuxtData(key: string, nuxtApp?: any): {
7
+ data: {
8
+ value: any;
9
+ };
10
+ };
11
+ /**
12
+ * Fetch or reuse data with Nuxt's caching layer.
13
+ * Must be called via runWithContext when outside setup().
14
+ */
15
+ declare function getAsyncData<T>(key: string, fetcher: () => Promise<T>, nuxtApp?: any): Promise<{
16
+ data: {
17
+ value: T | null;
18
+ };
19
+ }>;
20
+ /**
21
+ * Clear Nuxt's internal SSR payload cache for a key.
22
+ */
23
+ declare function clearNuxtDataKey(key: string, nuxtApp?: any): void;
24
+ /**
25
+ * Register a callback to run after Nuxt hydration is complete.
26
+ */
27
+ declare function onNuxtReadyCallback(cb: () => void): void;
28
+ declare function getRoute(): any;
29
+ declare function getRouter(): any;
30
+
31
+ export { clearNuxtDataKey, getAsyncData, getNuxtApp, getNuxtData, getRoute, getRouter, onNuxtReadyCallback };
@@ -0,0 +1,31 @@
1
+ declare function getNuxtApp(): any;
2
+ /**
3
+ * Read SSR payload data for a given key.
4
+ * Must be called via runWithContext when outside setup().
5
+ */
6
+ declare function getNuxtData(key: string, nuxtApp?: any): {
7
+ data: {
8
+ value: any;
9
+ };
10
+ };
11
+ /**
12
+ * Fetch or reuse data with Nuxt's caching layer.
13
+ * Must be called via runWithContext when outside setup().
14
+ */
15
+ declare function getAsyncData<T>(key: string, fetcher: () => Promise<T>, nuxtApp?: any): Promise<{
16
+ data: {
17
+ value: T | null;
18
+ };
19
+ }>;
20
+ /**
21
+ * Clear Nuxt's internal SSR payload cache for a key.
22
+ */
23
+ declare function clearNuxtDataKey(key: string, nuxtApp?: any): void;
24
+ /**
25
+ * Register a callback to run after Nuxt hydration is complete.
26
+ */
27
+ declare function onNuxtReadyCallback(cb: () => void): void;
28
+ declare function getRoute(): any;
29
+ declare function getRouter(): any;
30
+
31
+ export { clearNuxtDataKey, getAsyncData, getNuxtApp, getNuxtData, getRoute, getRouter, onNuxtReadyCallback };
@@ -0,0 +1,31 @@
1
+ declare function getNuxtApp(): any;
2
+ /**
3
+ * Read SSR payload data for a given key.
4
+ * Must be called via runWithContext when outside setup().
5
+ */
6
+ declare function getNuxtData(key: string, nuxtApp?: any): {
7
+ data: {
8
+ value: any;
9
+ };
10
+ };
11
+ /**
12
+ * Fetch or reuse data with Nuxt's caching layer.
13
+ * Must be called via runWithContext when outside setup().
14
+ */
15
+ declare function getAsyncData<T>(key: string, fetcher: () => Promise<T>, nuxtApp?: any): Promise<{
16
+ data: {
17
+ value: T | null;
18
+ };
19
+ }>;
20
+ /**
21
+ * Clear Nuxt's internal SSR payload cache for a key.
22
+ */
23
+ declare function clearNuxtDataKey(key: string, nuxtApp?: any): void;
24
+ /**
25
+ * Register a callback to run after Nuxt hydration is complete.
26
+ */
27
+ declare function onNuxtReadyCallback(cb: () => void): void;
28
+ declare function getRoute(): any;
29
+ declare function getRouter(): any;
30
+
31
+ export { clearNuxtDataKey, getAsyncData, getNuxtApp, getNuxtData, getRoute, getRouter, onNuxtReadyCallback };
@@ -0,0 +1,47 @@
1
+ import { useNuxtApp, useNuxtData, useAsyncData, clearNuxtData, onNuxtReady, useRoute, useRouter } from '#app';
2
+
3
+ function getNuxtApp() {
4
+ try {
5
+ return useNuxtApp();
6
+ } catch {
7
+ return null;
8
+ }
9
+ }
10
+ function getNuxtData(key, nuxtApp) {
11
+ if (nuxtApp?.runWithContext) {
12
+ return nuxtApp.runWithContext(() => useNuxtData(key));
13
+ }
14
+ return useNuxtData(key);
15
+ }
16
+ async function getAsyncData(key, fetcher, nuxtApp) {
17
+ if (nuxtApp?.runWithContext) {
18
+ return nuxtApp.runWithContext(() => useAsyncData(key, fetcher));
19
+ }
20
+ return useAsyncData(key, fetcher);
21
+ }
22
+ function clearNuxtDataKey(key, nuxtApp) {
23
+ if (nuxtApp?.runWithContext) {
24
+ nuxtApp.runWithContext(() => clearNuxtData(key));
25
+ } else {
26
+ clearNuxtData(key);
27
+ }
28
+ }
29
+ function onNuxtReadyCallback(cb) {
30
+ onNuxtReady(cb);
31
+ }
32
+ function getRoute() {
33
+ try {
34
+ return useRoute();
35
+ } catch {
36
+ return null;
37
+ }
38
+ }
39
+ function getRouter() {
40
+ try {
41
+ return useRouter();
42
+ } catch {
43
+ return null;
44
+ }
45
+ }
46
+
47
+ export { clearNuxtDataKey, getAsyncData, getNuxtApp, getNuxtData, getRoute, getRouter, onNuxtReadyCallback };
@@ -0,0 +1,29 @@
1
+ 'use strict';
2
+
3
+ function getNuxtApp() {
4
+ return null;
5
+ }
6
+ function getNuxtData(_key, _nuxtApp) {
7
+ return { data: { value: null } };
8
+ }
9
+ async function getAsyncData(_key, _fetcher, _nuxtApp) {
10
+ return { data: { value: null } };
11
+ }
12
+ function clearNuxtDataKey(_key, _nuxtApp) {
13
+ }
14
+ function onNuxtReadyCallback(_cb) {
15
+ }
16
+ function getRoute() {
17
+ return null;
18
+ }
19
+ function getRouter() {
20
+ return null;
21
+ }
22
+
23
+ exports.clearNuxtDataKey = clearNuxtDataKey;
24
+ exports.getAsyncData = getAsyncData;
25
+ exports.getNuxtApp = getNuxtApp;
26
+ exports.getNuxtData = getNuxtData;
27
+ exports.getRoute = getRoute;
28
+ exports.getRouter = getRouter;
29
+ exports.onNuxtReadyCallback = onNuxtReadyCallback;
@@ -0,0 +1,21 @@
1
+ /**
2
+ * nuxtAppCompat.server.ts — Server-side no-op stubs.
3
+ * Signatures must match nuxtAppCompat.ts exactly.
4
+ */
5
+ declare function getNuxtApp(): any;
6
+ declare function getNuxtData(_key: string, _nuxtApp?: any): {
7
+ data: {
8
+ value: any;
9
+ };
10
+ };
11
+ declare function getAsyncData<T>(_key: string, _fetcher: () => Promise<T>, _nuxtApp?: any): Promise<{
12
+ data: {
13
+ value: T | null;
14
+ };
15
+ }>;
16
+ declare function clearNuxtDataKey(_key: string, _nuxtApp?: any): void;
17
+ declare function onNuxtReadyCallback(_cb: () => void): void;
18
+ declare function getRoute(): any;
19
+ declare function getRouter(): any;
20
+
21
+ export { clearNuxtDataKey, getAsyncData, getNuxtApp, getNuxtData, getRoute, getRouter, onNuxtReadyCallback };
@@ -0,0 +1,21 @@
1
+ /**
2
+ * nuxtAppCompat.server.ts — Server-side no-op stubs.
3
+ * Signatures must match nuxtAppCompat.ts exactly.
4
+ */
5
+ declare function getNuxtApp(): any;
6
+ declare function getNuxtData(_key: string, _nuxtApp?: any): {
7
+ data: {
8
+ value: any;
9
+ };
10
+ };
11
+ declare function getAsyncData<T>(_key: string, _fetcher: () => Promise<T>, _nuxtApp?: any): Promise<{
12
+ data: {
13
+ value: T | null;
14
+ };
15
+ }>;
16
+ declare function clearNuxtDataKey(_key: string, _nuxtApp?: any): void;
17
+ declare function onNuxtReadyCallback(_cb: () => void): void;
18
+ declare function getRoute(): any;
19
+ declare function getRouter(): any;
20
+
21
+ export { clearNuxtDataKey, getAsyncData, getNuxtApp, getNuxtData, getRoute, getRouter, onNuxtReadyCallback };
@@ -0,0 +1,21 @@
1
+ /**
2
+ * nuxtAppCompat.server.ts — Server-side no-op stubs.
3
+ * Signatures must match nuxtAppCompat.ts exactly.
4
+ */
5
+ declare function getNuxtApp(): any;
6
+ declare function getNuxtData(_key: string, _nuxtApp?: any): {
7
+ data: {
8
+ value: any;
9
+ };
10
+ };
11
+ declare function getAsyncData<T>(_key: string, _fetcher: () => Promise<T>, _nuxtApp?: any): Promise<{
12
+ data: {
13
+ value: T | null;
14
+ };
15
+ }>;
16
+ declare function clearNuxtDataKey(_key: string, _nuxtApp?: any): void;
17
+ declare function onNuxtReadyCallback(_cb: () => void): void;
18
+ declare function getRoute(): any;
19
+ declare function getRouter(): any;
20
+
21
+ export { clearNuxtDataKey, getAsyncData, getNuxtApp, getNuxtData, getRoute, getRouter, onNuxtReadyCallback };
@@ -0,0 +1,21 @@
1
+ function getNuxtApp() {
2
+ return null;
3
+ }
4
+ function getNuxtData(_key, _nuxtApp) {
5
+ return { data: { value: null } };
6
+ }
7
+ async function getAsyncData(_key, _fetcher, _nuxtApp) {
8
+ return { data: { value: null } };
9
+ }
10
+ function clearNuxtDataKey(_key, _nuxtApp) {
11
+ }
12
+ function onNuxtReadyCallback(_cb) {
13
+ }
14
+ function getRoute() {
15
+ return null;
16
+ }
17
+ function getRouter() {
18
+ return null;
19
+ }
20
+
21
+ export { clearNuxtDataKey, getAsyncData, getNuxtApp, getNuxtData, getRoute, getRouter, onNuxtReadyCallback };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@katlux/providers",
3
- "version": "0.1.0-beta.62",
3
+ "version": "0.1.0-beta.64",
4
4
  "description": "Core data calculation and caching providers for the Katlux ecosystem",
5
5
  "author": "Katlux",
6
6
  "license": "MIT",