@katlux/providers 0.1.0-beta.61 → 0.1.0-beta.63

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.
@@ -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 };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@katlux/providers",
3
- "version": "0.1.0-beta.61",
3
+ "version": "0.1.0-beta.63",
4
4
  "description": "Core data calculation and caching providers for the Katlux ecosystem",
5
5
  "author": "Katlux",
6
6
  "license": "MIT",