@katlux/providers 0.1.1-alpha.95 → 0.1.1-alpha.97
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/README.md +1 -1
- package/dist/index.cjs +3292 -2172
- package/dist/index.d.cts +581 -77
- package/dist/index.d.mts +581 -77
- package/dist/index.d.ts +581 -77
- package/dist/index.mjs +3307 -2220
- package/dist/nuxtAppCompat.cjs +10 -30
- package/dist/nuxtAppCompat.d.cts +3 -13
- package/dist/nuxtAppCompat.d.mts +3 -13
- package/dist/nuxtAppCompat.d.ts +3 -13
- package/dist/nuxtAppCompat.mjs +10 -30
- package/dist/nuxtAppCompat.server.cjs +22 -6
- package/dist/nuxtAppCompat.server.d.cts +6 -6
- package/dist/nuxtAppCompat.server.d.mts +6 -6
- package/dist/nuxtAppCompat.server.d.ts +6 -6
- package/dist/nuxtAppCompat.server.mjs +22 -6
- package/dist/shared/providers.C8C1HrDy.mjs +228 -0
- package/dist/shared/providers.CxZeMH3Y.cjs +241 -0
- package/package.json +7 -4
package/dist/nuxtAppCompat.cjs
CHANGED
|
@@ -1,49 +1,29 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const
|
|
3
|
+
const index = require('./shared/providers.CxZeMH3Y.cjs');
|
|
4
4
|
|
|
5
5
|
function getNuxtApp() {
|
|
6
|
-
|
|
7
|
-
return _app.useNuxtApp();
|
|
8
|
-
} catch {
|
|
9
|
-
return null;
|
|
10
|
-
}
|
|
6
|
+
return index.getPlatformApp();
|
|
11
7
|
}
|
|
12
8
|
function getNuxtData(key, nuxtApp) {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
}
|
|
16
|
-
return _app.useNuxtData(key);
|
|
9
|
+
const val = index.getSSRData(key, nuxtApp);
|
|
10
|
+
return { data: { value: val } };
|
|
17
11
|
}
|
|
18
12
|
async function getAsyncData(key, fetcher, nuxtApp) {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
}
|
|
22
|
-
return _app.useAsyncData(key, fetcher);
|
|
13
|
+
const val = await index.fetchWithSSR(key, fetcher, nuxtApp);
|
|
14
|
+
return { data: { value: val } };
|
|
23
15
|
}
|
|
24
16
|
function clearNuxtDataKey(key, nuxtApp) {
|
|
25
|
-
|
|
26
|
-
nuxtApp.runWithContext(() => _app.clearNuxtData(key));
|
|
27
|
-
} else {
|
|
28
|
-
_app.clearNuxtData(key);
|
|
29
|
-
}
|
|
17
|
+
index.clearSSRData(key, nuxtApp);
|
|
30
18
|
}
|
|
31
19
|
function onNuxtReadyCallback(cb) {
|
|
32
|
-
|
|
20
|
+
index.onPlatformReady(cb);
|
|
33
21
|
}
|
|
34
22
|
function getRoute() {
|
|
35
|
-
|
|
36
|
-
return _app.useRoute();
|
|
37
|
-
} catch {
|
|
38
|
-
return null;
|
|
39
|
-
}
|
|
23
|
+
return index.getAppRoute();
|
|
40
24
|
}
|
|
41
25
|
function getRouter() {
|
|
42
|
-
|
|
43
|
-
return _app.useRouter();
|
|
44
|
-
} catch {
|
|
45
|
-
return null;
|
|
46
|
-
}
|
|
26
|
+
return index.getAppRouter();
|
|
47
27
|
}
|
|
48
28
|
|
|
49
29
|
exports.clearNuxtDataKey = clearNuxtDataKey;
|
package/dist/nuxtAppCompat.d.cts
CHANGED
|
@@ -1,29 +1,19 @@
|
|
|
1
|
-
declare function getNuxtApp(): any;
|
|
2
1
|
/**
|
|
3
|
-
*
|
|
4
|
-
*
|
|
2
|
+
* nuxtAppCompat.ts — Backwards-compatibility wrapper mapping legacy Nuxt-named helpers
|
|
3
|
+
* to the framework-agnostic hydration bridge.
|
|
5
4
|
*/
|
|
5
|
+
declare function getNuxtApp(): any;
|
|
6
6
|
declare function getNuxtData(key: string, nuxtApp?: any): {
|
|
7
7
|
data: {
|
|
8
8
|
value: any;
|
|
9
9
|
};
|
|
10
10
|
};
|
|
11
|
-
/**
|
|
12
|
-
* Fetch or reuse data with Nuxt's caching layer.
|
|
13
|
-
* Must be called via runWithContext when outside setup().
|
|
14
|
-
*/
|
|
15
11
|
declare function getAsyncData<T>(key: string, fetcher: () => Promise<T>, nuxtApp?: any): Promise<{
|
|
16
12
|
data: {
|
|
17
13
|
value: T | null;
|
|
18
14
|
};
|
|
19
15
|
}>;
|
|
20
|
-
/**
|
|
21
|
-
* Clear Nuxt's internal SSR payload cache for a key.
|
|
22
|
-
*/
|
|
23
16
|
declare function clearNuxtDataKey(key: string, nuxtApp?: any): void;
|
|
24
|
-
/**
|
|
25
|
-
* Register a callback to run after Nuxt hydration is complete.
|
|
26
|
-
*/
|
|
27
17
|
declare function onNuxtReadyCallback(cb: () => void): void;
|
|
28
18
|
declare function getRoute(): any;
|
|
29
19
|
declare function getRouter(): any;
|
package/dist/nuxtAppCompat.d.mts
CHANGED
|
@@ -1,29 +1,19 @@
|
|
|
1
|
-
declare function getNuxtApp(): any;
|
|
2
1
|
/**
|
|
3
|
-
*
|
|
4
|
-
*
|
|
2
|
+
* nuxtAppCompat.ts — Backwards-compatibility wrapper mapping legacy Nuxt-named helpers
|
|
3
|
+
* to the framework-agnostic hydration bridge.
|
|
5
4
|
*/
|
|
5
|
+
declare function getNuxtApp(): any;
|
|
6
6
|
declare function getNuxtData(key: string, nuxtApp?: any): {
|
|
7
7
|
data: {
|
|
8
8
|
value: any;
|
|
9
9
|
};
|
|
10
10
|
};
|
|
11
|
-
/**
|
|
12
|
-
* Fetch or reuse data with Nuxt's caching layer.
|
|
13
|
-
* Must be called via runWithContext when outside setup().
|
|
14
|
-
*/
|
|
15
11
|
declare function getAsyncData<T>(key: string, fetcher: () => Promise<T>, nuxtApp?: any): Promise<{
|
|
16
12
|
data: {
|
|
17
13
|
value: T | null;
|
|
18
14
|
};
|
|
19
15
|
}>;
|
|
20
|
-
/**
|
|
21
|
-
* Clear Nuxt's internal SSR payload cache for a key.
|
|
22
|
-
*/
|
|
23
16
|
declare function clearNuxtDataKey(key: string, nuxtApp?: any): void;
|
|
24
|
-
/**
|
|
25
|
-
* Register a callback to run after Nuxt hydration is complete.
|
|
26
|
-
*/
|
|
27
17
|
declare function onNuxtReadyCallback(cb: () => void): void;
|
|
28
18
|
declare function getRoute(): any;
|
|
29
19
|
declare function getRouter(): any;
|
package/dist/nuxtAppCompat.d.ts
CHANGED
|
@@ -1,29 +1,19 @@
|
|
|
1
|
-
declare function getNuxtApp(): any;
|
|
2
1
|
/**
|
|
3
|
-
*
|
|
4
|
-
*
|
|
2
|
+
* nuxtAppCompat.ts — Backwards-compatibility wrapper mapping legacy Nuxt-named helpers
|
|
3
|
+
* to the framework-agnostic hydration bridge.
|
|
5
4
|
*/
|
|
5
|
+
declare function getNuxtApp(): any;
|
|
6
6
|
declare function getNuxtData(key: string, nuxtApp?: any): {
|
|
7
7
|
data: {
|
|
8
8
|
value: any;
|
|
9
9
|
};
|
|
10
10
|
};
|
|
11
|
-
/**
|
|
12
|
-
* Fetch or reuse data with Nuxt's caching layer.
|
|
13
|
-
* Must be called via runWithContext when outside setup().
|
|
14
|
-
*/
|
|
15
11
|
declare function getAsyncData<T>(key: string, fetcher: () => Promise<T>, nuxtApp?: any): Promise<{
|
|
16
12
|
data: {
|
|
17
13
|
value: T | null;
|
|
18
14
|
};
|
|
19
15
|
}>;
|
|
20
|
-
/**
|
|
21
|
-
* Clear Nuxt's internal SSR payload cache for a key.
|
|
22
|
-
*/
|
|
23
16
|
declare function clearNuxtDataKey(key: string, nuxtApp?: any): void;
|
|
24
|
-
/**
|
|
25
|
-
* Register a callback to run after Nuxt hydration is complete.
|
|
26
|
-
*/
|
|
27
17
|
declare function onNuxtReadyCallback(cb: () => void): void;
|
|
28
18
|
declare function getRoute(): any;
|
|
29
19
|
declare function getRouter(): any;
|
package/dist/nuxtAppCompat.mjs
CHANGED
|
@@ -1,47 +1,27 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { g as getPlatformApp, c as getSSRData, f as fetchWithSSR, d as clearSSRData, o as onPlatformReady, a as getAppRoute, b as getAppRouter } from './shared/providers.C8C1HrDy.mjs';
|
|
2
2
|
|
|
3
3
|
function getNuxtApp() {
|
|
4
|
-
|
|
5
|
-
return useNuxtApp();
|
|
6
|
-
} catch {
|
|
7
|
-
return null;
|
|
8
|
-
}
|
|
4
|
+
return getPlatformApp();
|
|
9
5
|
}
|
|
10
6
|
function getNuxtData(key, nuxtApp) {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
}
|
|
14
|
-
return useNuxtData(key);
|
|
7
|
+
const val = getSSRData(key, nuxtApp);
|
|
8
|
+
return { data: { value: val } };
|
|
15
9
|
}
|
|
16
10
|
async function getAsyncData(key, fetcher, nuxtApp) {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
}
|
|
20
|
-
return useAsyncData(key, fetcher);
|
|
11
|
+
const val = await fetchWithSSR(key, fetcher, nuxtApp);
|
|
12
|
+
return { data: { value: val } };
|
|
21
13
|
}
|
|
22
14
|
function clearNuxtDataKey(key, nuxtApp) {
|
|
23
|
-
|
|
24
|
-
nuxtApp.runWithContext(() => clearNuxtData(key));
|
|
25
|
-
} else {
|
|
26
|
-
clearNuxtData(key);
|
|
27
|
-
}
|
|
15
|
+
clearSSRData(key, nuxtApp);
|
|
28
16
|
}
|
|
29
17
|
function onNuxtReadyCallback(cb) {
|
|
30
|
-
|
|
18
|
+
onPlatformReady(cb);
|
|
31
19
|
}
|
|
32
20
|
function getRoute() {
|
|
33
|
-
|
|
34
|
-
return useRoute();
|
|
35
|
-
} catch {
|
|
36
|
-
return null;
|
|
37
|
-
}
|
|
21
|
+
return getAppRoute();
|
|
38
22
|
}
|
|
39
23
|
function getRouter() {
|
|
40
|
-
|
|
41
|
-
return useRouter();
|
|
42
|
-
} catch {
|
|
43
|
-
return null;
|
|
44
|
-
}
|
|
24
|
+
return getAppRouter();
|
|
45
25
|
}
|
|
46
26
|
|
|
47
27
|
export { clearNuxtDataKey, getAsyncData, getNuxtApp, getNuxtData, getRoute, getRouter, onNuxtReadyCallback };
|
|
@@ -3,15 +3,31 @@
|
|
|
3
3
|
function getNuxtApp() {
|
|
4
4
|
return null;
|
|
5
5
|
}
|
|
6
|
-
function getNuxtData(
|
|
7
|
-
|
|
6
|
+
function getNuxtData(key, nuxtApp) {
|
|
7
|
+
const val = nuxtApp?.payload?.data?.[key] ?? null;
|
|
8
|
+
return { data: { value: val } };
|
|
8
9
|
}
|
|
9
|
-
async function getAsyncData(
|
|
10
|
-
|
|
10
|
+
async function getAsyncData(key, fetcher, nuxtApp) {
|
|
11
|
+
if (nuxtApp?.payload?.data?.[key] !== void 0) {
|
|
12
|
+
return { data: { value: nuxtApp.payload.data[key] } };
|
|
13
|
+
}
|
|
14
|
+
try {
|
|
15
|
+
const res = await fetcher();
|
|
16
|
+
if (nuxtApp?.payload?.data) {
|
|
17
|
+
nuxtApp.payload.data[key] = res;
|
|
18
|
+
}
|
|
19
|
+
return { data: { value: res } };
|
|
20
|
+
} catch {
|
|
21
|
+
return { data: { value: null } };
|
|
22
|
+
}
|
|
11
23
|
}
|
|
12
|
-
function clearNuxtDataKey(
|
|
24
|
+
function clearNuxtDataKey(key, nuxtApp) {
|
|
25
|
+
if (nuxtApp?.payload?.data) {
|
|
26
|
+
delete nuxtApp.payload.data[key];
|
|
27
|
+
}
|
|
13
28
|
}
|
|
14
|
-
function onNuxtReadyCallback(
|
|
29
|
+
function onNuxtReadyCallback(cb) {
|
|
30
|
+
setTimeout(cb, 0);
|
|
15
31
|
}
|
|
16
32
|
function getRoute() {
|
|
17
33
|
return null;
|
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* nuxtAppCompat.server.ts — Server-side
|
|
3
|
-
* Signatures
|
|
2
|
+
* nuxtAppCompat.server.ts — Server-side environment compatibility.
|
|
3
|
+
* Signatures match nuxtAppCompat.ts exactly.
|
|
4
4
|
*/
|
|
5
5
|
declare function getNuxtApp(): any;
|
|
6
|
-
declare function getNuxtData(
|
|
6
|
+
declare function getNuxtData(key: string, nuxtApp?: any): {
|
|
7
7
|
data: {
|
|
8
8
|
value: any;
|
|
9
9
|
};
|
|
10
10
|
};
|
|
11
|
-
declare function getAsyncData<T>(
|
|
11
|
+
declare function getAsyncData<T>(key: string, fetcher: () => Promise<T>, nuxtApp?: any): Promise<{
|
|
12
12
|
data: {
|
|
13
13
|
value: T | null;
|
|
14
14
|
};
|
|
15
15
|
}>;
|
|
16
|
-
declare function clearNuxtDataKey(
|
|
17
|
-
declare function onNuxtReadyCallback(
|
|
16
|
+
declare function clearNuxtDataKey(key: string, nuxtApp?: any): void;
|
|
17
|
+
declare function onNuxtReadyCallback(cb: () => void): void;
|
|
18
18
|
declare function getRoute(): any;
|
|
19
19
|
declare function getRouter(): any;
|
|
20
20
|
|
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* nuxtAppCompat.server.ts — Server-side
|
|
3
|
-
* Signatures
|
|
2
|
+
* nuxtAppCompat.server.ts — Server-side environment compatibility.
|
|
3
|
+
* Signatures match nuxtAppCompat.ts exactly.
|
|
4
4
|
*/
|
|
5
5
|
declare function getNuxtApp(): any;
|
|
6
|
-
declare function getNuxtData(
|
|
6
|
+
declare function getNuxtData(key: string, nuxtApp?: any): {
|
|
7
7
|
data: {
|
|
8
8
|
value: any;
|
|
9
9
|
};
|
|
10
10
|
};
|
|
11
|
-
declare function getAsyncData<T>(
|
|
11
|
+
declare function getAsyncData<T>(key: string, fetcher: () => Promise<T>, nuxtApp?: any): Promise<{
|
|
12
12
|
data: {
|
|
13
13
|
value: T | null;
|
|
14
14
|
};
|
|
15
15
|
}>;
|
|
16
|
-
declare function clearNuxtDataKey(
|
|
17
|
-
declare function onNuxtReadyCallback(
|
|
16
|
+
declare function clearNuxtDataKey(key: string, nuxtApp?: any): void;
|
|
17
|
+
declare function onNuxtReadyCallback(cb: () => void): void;
|
|
18
18
|
declare function getRoute(): any;
|
|
19
19
|
declare function getRouter(): any;
|
|
20
20
|
|
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* nuxtAppCompat.server.ts — Server-side
|
|
3
|
-
* Signatures
|
|
2
|
+
* nuxtAppCompat.server.ts — Server-side environment compatibility.
|
|
3
|
+
* Signatures match nuxtAppCompat.ts exactly.
|
|
4
4
|
*/
|
|
5
5
|
declare function getNuxtApp(): any;
|
|
6
|
-
declare function getNuxtData(
|
|
6
|
+
declare function getNuxtData(key: string, nuxtApp?: any): {
|
|
7
7
|
data: {
|
|
8
8
|
value: any;
|
|
9
9
|
};
|
|
10
10
|
};
|
|
11
|
-
declare function getAsyncData<T>(
|
|
11
|
+
declare function getAsyncData<T>(key: string, fetcher: () => Promise<T>, nuxtApp?: any): Promise<{
|
|
12
12
|
data: {
|
|
13
13
|
value: T | null;
|
|
14
14
|
};
|
|
15
15
|
}>;
|
|
16
|
-
declare function clearNuxtDataKey(
|
|
17
|
-
declare function onNuxtReadyCallback(
|
|
16
|
+
declare function clearNuxtDataKey(key: string, nuxtApp?: any): void;
|
|
17
|
+
declare function onNuxtReadyCallback(cb: () => void): void;
|
|
18
18
|
declare function getRoute(): any;
|
|
19
19
|
declare function getRouter(): any;
|
|
20
20
|
|
|
@@ -1,15 +1,31 @@
|
|
|
1
1
|
function getNuxtApp() {
|
|
2
2
|
return null;
|
|
3
3
|
}
|
|
4
|
-
function getNuxtData(
|
|
5
|
-
|
|
4
|
+
function getNuxtData(key, nuxtApp) {
|
|
5
|
+
const val = nuxtApp?.payload?.data?.[key] ?? null;
|
|
6
|
+
return { data: { value: val } };
|
|
6
7
|
}
|
|
7
|
-
async function getAsyncData(
|
|
8
|
-
|
|
8
|
+
async function getAsyncData(key, fetcher, nuxtApp) {
|
|
9
|
+
if (nuxtApp?.payload?.data?.[key] !== void 0) {
|
|
10
|
+
return { data: { value: nuxtApp.payload.data[key] } };
|
|
11
|
+
}
|
|
12
|
+
try {
|
|
13
|
+
const res = await fetcher();
|
|
14
|
+
if (nuxtApp?.payload?.data) {
|
|
15
|
+
nuxtApp.payload.data[key] = res;
|
|
16
|
+
}
|
|
17
|
+
return { data: { value: res } };
|
|
18
|
+
} catch {
|
|
19
|
+
return { data: { value: null } };
|
|
20
|
+
}
|
|
9
21
|
}
|
|
10
|
-
function clearNuxtDataKey(
|
|
22
|
+
function clearNuxtDataKey(key, nuxtApp) {
|
|
23
|
+
if (nuxtApp?.payload?.data) {
|
|
24
|
+
delete nuxtApp.payload.data[key];
|
|
25
|
+
}
|
|
11
26
|
}
|
|
12
|
-
function onNuxtReadyCallback(
|
|
27
|
+
function onNuxtReadyCallback(cb) {
|
|
28
|
+
setTimeout(cb, 0);
|
|
13
29
|
}
|
|
14
30
|
function getRoute() {
|
|
15
31
|
return null;
|
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
class DefaultHydrationAdapter {
|
|
2
|
+
getSSRData(key, context) {
|
|
3
|
+
const contextData = context?.payload?.data?.[key] ?? context?.ssrContext?.payload?.data?.[key];
|
|
4
|
+
if (contextData !== void 0 && contextData !== null) {
|
|
5
|
+
return contextData;
|
|
6
|
+
}
|
|
7
|
+
if (typeof window !== "undefined") {
|
|
8
|
+
const win = window;
|
|
9
|
+
const clientData = win.__KATLUX_DATA__?.[key] ?? win.__INITIAL_DATA__?.[key] ?? win.__NEXT_DATA__?.props?.pageProps?.[key] ?? win.__NUXT__?.payload?.data?.[key];
|
|
10
|
+
if (clientData !== void 0 && clientData !== null) {
|
|
11
|
+
return clientData;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
return null;
|
|
15
|
+
}
|
|
16
|
+
async fetchWithSSR(key, fetcher, context) {
|
|
17
|
+
const cached = this.getSSRData(key, context);
|
|
18
|
+
if (cached !== null) {
|
|
19
|
+
return cached;
|
|
20
|
+
}
|
|
21
|
+
try {
|
|
22
|
+
const result = await fetcher();
|
|
23
|
+
if (context?.payload?.data) {
|
|
24
|
+
context.payload.data[key] = result;
|
|
25
|
+
} else if (context?.ssrContext?.payload?.data) {
|
|
26
|
+
context.ssrContext.payload.data[key] = result;
|
|
27
|
+
}
|
|
28
|
+
return result;
|
|
29
|
+
} catch {
|
|
30
|
+
return null;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
clearSSRData(key, context) {
|
|
34
|
+
if (context?.payload?.data) {
|
|
35
|
+
delete context.payload.data[key];
|
|
36
|
+
}
|
|
37
|
+
if (context?.ssrContext?.payload?.data) {
|
|
38
|
+
delete context.ssrContext.payload.data[key];
|
|
39
|
+
}
|
|
40
|
+
if (typeof window !== "undefined") {
|
|
41
|
+
const win = window;
|
|
42
|
+
if (win.__KATLUX_DATA__?.payload?.data) delete win.__KATLUX_DATA__.payload.data[key];
|
|
43
|
+
if (win.__INITIAL_DATA__?.payload?.data) delete win.__INITIAL_DATA__.payload.data[key];
|
|
44
|
+
if (win.__NUXT__?.payload?.data) delete win.__NUXT__.payload.data[key];
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
getSSRPayload(context) {
|
|
48
|
+
if (context?.payload?.data) return context.payload.data;
|
|
49
|
+
if (context?.ssrContext?.payload?.data) return context.ssrContext.payload.data;
|
|
50
|
+
if (typeof window !== "undefined") {
|
|
51
|
+
const win = window;
|
|
52
|
+
return win.__KATLUX_DATA__?.payload?.data || win.__KATLUX_DATA__ || win.__INITIAL_DATA__?.payload?.data || win.__INITIAL_DATA__ || win.__NUXT__?.payload?.data || null;
|
|
53
|
+
}
|
|
54
|
+
return null;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
function getGlobalNuxt() {
|
|
59
|
+
if (typeof globalThis.useNuxtApp === "function") {
|
|
60
|
+
try {
|
|
61
|
+
return globalThis.useNuxtApp();
|
|
62
|
+
} catch {
|
|
63
|
+
return null;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
return null;
|
|
67
|
+
}
|
|
68
|
+
class NuxtHydrationAdapter {
|
|
69
|
+
fallback = new DefaultHydrationAdapter();
|
|
70
|
+
getSSRData(key, context) {
|
|
71
|
+
const app = context || getGlobalNuxt();
|
|
72
|
+
if (app?.runWithContext && typeof globalThis.useNuxtData === "function") {
|
|
73
|
+
try {
|
|
74
|
+
const res = app.runWithContext(() => globalThis.useNuxtData(key));
|
|
75
|
+
const val = res?.data?.value ?? res?.data ?? res;
|
|
76
|
+
if (val !== void 0 && val !== null) return val;
|
|
77
|
+
} catch {
|
|
78
|
+
}
|
|
79
|
+
} else if (typeof globalThis.useNuxtData === "function") {
|
|
80
|
+
try {
|
|
81
|
+
const res = globalThis.useNuxtData(key);
|
|
82
|
+
const val = res?.data?.value ?? res?.data ?? res;
|
|
83
|
+
if (val !== void 0 && val !== null) return val;
|
|
84
|
+
} catch {
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
return this.fallback.getSSRData(key, context);
|
|
88
|
+
}
|
|
89
|
+
async fetchWithSSR(key, fetcher, context) {
|
|
90
|
+
const app = context || getGlobalNuxt();
|
|
91
|
+
if (app?.runWithContext && typeof globalThis.useAsyncData === "function") {
|
|
92
|
+
try {
|
|
93
|
+
const res = await app.runWithContext(() => globalThis.useAsyncData(key, fetcher));
|
|
94
|
+
const val = res?.data?.value ?? res?.data ?? res;
|
|
95
|
+
if (val !== void 0 && val !== null) return val;
|
|
96
|
+
} catch {
|
|
97
|
+
}
|
|
98
|
+
} else if (typeof globalThis.useAsyncData === "function") {
|
|
99
|
+
try {
|
|
100
|
+
const res = await globalThis.useAsyncData(key, fetcher);
|
|
101
|
+
const val = res?.data?.value ?? res?.data ?? res;
|
|
102
|
+
if (val !== void 0 && val !== null) return val;
|
|
103
|
+
} catch {
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
return this.fallback.fetchWithSSR(key, fetcher, context);
|
|
107
|
+
}
|
|
108
|
+
clearSSRData(key, context) {
|
|
109
|
+
const app = context || getGlobalNuxt();
|
|
110
|
+
if (app?.runWithContext && typeof globalThis.clearNuxtData === "function") {
|
|
111
|
+
try {
|
|
112
|
+
app.runWithContext(() => globalThis.clearNuxtData(key));
|
|
113
|
+
} catch {
|
|
114
|
+
}
|
|
115
|
+
} else if (typeof globalThis.clearNuxtData === "function") {
|
|
116
|
+
try {
|
|
117
|
+
globalThis.clearNuxtData(key);
|
|
118
|
+
} catch {
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
this.fallback.clearSSRData(key, context);
|
|
122
|
+
}
|
|
123
|
+
getSSRPayload(context) {
|
|
124
|
+
const app = context || getGlobalNuxt();
|
|
125
|
+
const payload = app?.payload?.data || app?.ssrContext?.payload?.data;
|
|
126
|
+
if (payload) return payload;
|
|
127
|
+
return this.fallback.getSSRPayload(context);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
let currentAdapter = null;
|
|
132
|
+
function getHydrationAdapter() {
|
|
133
|
+
if (!currentAdapter) {
|
|
134
|
+
if (typeof globalThis.useNuxtApp === "function") {
|
|
135
|
+
currentAdapter = new NuxtHydrationAdapter();
|
|
136
|
+
} else {
|
|
137
|
+
currentAdapter = new DefaultHydrationAdapter();
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
return currentAdapter;
|
|
141
|
+
}
|
|
142
|
+
function setHydrationAdapter(adapter) {
|
|
143
|
+
currentAdapter = adapter;
|
|
144
|
+
}
|
|
145
|
+
function getSSRData(key, context) {
|
|
146
|
+
return getHydrationAdapter().getSSRData(key, context);
|
|
147
|
+
}
|
|
148
|
+
async function fetchWithSSR(key, fetcher, context) {
|
|
149
|
+
return await getHydrationAdapter().fetchWithSSR(key, fetcher, context);
|
|
150
|
+
}
|
|
151
|
+
function clearSSRData(key, context) {
|
|
152
|
+
getHydrationAdapter().clearSSRData?.(key, context);
|
|
153
|
+
}
|
|
154
|
+
function getSSRPayload(context) {
|
|
155
|
+
return getHydrationAdapter().getSSRPayload?.(context) ?? null;
|
|
156
|
+
}
|
|
157
|
+
function getPlatformApp() {
|
|
158
|
+
if (typeof globalThis.useNuxtApp === "function") {
|
|
159
|
+
try {
|
|
160
|
+
return globalThis.useNuxtApp();
|
|
161
|
+
} catch {
|
|
162
|
+
return null;
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
return null;
|
|
166
|
+
}
|
|
167
|
+
function getAppRoute() {
|
|
168
|
+
if (typeof globalThis.useRoute === "function") {
|
|
169
|
+
try {
|
|
170
|
+
return globalThis.useRoute();
|
|
171
|
+
} catch {
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
if (typeof window !== "undefined") {
|
|
175
|
+
const searchParams = new URLSearchParams(window.location.search);
|
|
176
|
+
const query = {};
|
|
177
|
+
searchParams.forEach((val, key) => {
|
|
178
|
+
query[key] = val;
|
|
179
|
+
});
|
|
180
|
+
return { query, path: window.location.pathname };
|
|
181
|
+
}
|
|
182
|
+
return null;
|
|
183
|
+
}
|
|
184
|
+
function getAppRouter() {
|
|
185
|
+
if (typeof globalThis.useRouter === "function") {
|
|
186
|
+
try {
|
|
187
|
+
return globalThis.useRouter();
|
|
188
|
+
} catch {
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
if (typeof window !== "undefined") {
|
|
192
|
+
return {
|
|
193
|
+
replace: (options) => {
|
|
194
|
+
const url = new URL(window.location.href);
|
|
195
|
+
url.search = "";
|
|
196
|
+
if (options.query) {
|
|
197
|
+
for (const [k, v] of Object.entries(options.query)) {
|
|
198
|
+
if (v !== void 0 && v !== null) {
|
|
199
|
+
url.searchParams.set(k, String(v));
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
window.history.replaceState({}, "", url.toString());
|
|
204
|
+
}
|
|
205
|
+
};
|
|
206
|
+
}
|
|
207
|
+
return null;
|
|
208
|
+
}
|
|
209
|
+
function onPlatformReady(cb) {
|
|
210
|
+
if (typeof globalThis.onNuxtReady === "function") {
|
|
211
|
+
try {
|
|
212
|
+
globalThis.onNuxtReady(cb);
|
|
213
|
+
return;
|
|
214
|
+
} catch {
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
if (typeof window !== "undefined") {
|
|
218
|
+
if (document.readyState === "complete") {
|
|
219
|
+
setTimeout(cb, 0);
|
|
220
|
+
} else {
|
|
221
|
+
window.addEventListener("DOMContentLoaded", cb, { once: true });
|
|
222
|
+
}
|
|
223
|
+
} else {
|
|
224
|
+
setTimeout(cb, 0);
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
export { DefaultHydrationAdapter as D, NuxtHydrationAdapter as N, getAppRoute as a, getAppRouter as b, getSSRData as c, clearSSRData as d, getSSRPayload as e, fetchWithSSR as f, getPlatformApp as g, getHydrationAdapter as h, onPlatformReady as o, setHydrationAdapter as s };
|