@wpnuxt/core 2.3.0 → 2.3.2
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.
|
@@ -18,11 +18,13 @@ export default defineGraphqlClientOptions<{
|
|
|
18
18
|
}>({
|
|
19
19
|
buildClientContext() {
|
|
20
20
|
const route = useRoute()
|
|
21
|
+
const query = route?.query ?? {}
|
|
22
|
+
const token = query.token
|
|
21
23
|
|
|
22
24
|
return {
|
|
23
25
|
// Context values must be strings - use 'true'/'false' instead of boolean
|
|
24
|
-
preview:
|
|
25
|
-
previewToken:
|
|
26
|
+
preview: query.preview === 'true' ? 'true' : undefined,
|
|
27
|
+
previewToken: typeof token === 'string' ? token : undefined
|
|
26
28
|
}
|
|
27
29
|
}
|
|
28
30
|
})
|
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -9,7 +9,7 @@ import ts from 'typescript';
|
|
|
9
9
|
import { execSync } from 'node:child_process';
|
|
10
10
|
import { consola } from 'consola';
|
|
11
11
|
|
|
12
|
-
const version = "2.3.
|
|
12
|
+
const version = "2.3.2";
|
|
13
13
|
|
|
14
14
|
const DEFAULT_CPT_EXCLUSIONS = [
|
|
15
15
|
"Post",
|
|
@@ -826,7 +826,25 @@ async function checkWPGraphQLVersion(fullUrl, headers) {
|
|
|
826
826
|
clearTimeout(timeout);
|
|
827
827
|
if (!response.ok) return;
|
|
828
828
|
const data = await response.json();
|
|
829
|
-
const
|
|
829
|
+
const errorMessage = data?.errors?.[0]?.message || "";
|
|
830
|
+
if (/introspection/i.test(errorMessage)) {
|
|
831
|
+
throw new Error(
|
|
832
|
+
`[wpnuxt:core] WPGraphQL Public Introspection is disabled on this endpoint.
|
|
833
|
+
|
|
834
|
+
URL: ${fullUrl}
|
|
835
|
+
|
|
836
|
+
WPNuxt needs introspection to validate the schema and generate types.
|
|
837
|
+
|
|
838
|
+
To fix:
|
|
839
|
+
- Enable "Enable Public Introspection" under WPGraphQL \u2192 Settings in the WordPress admin.
|
|
840
|
+
- Or provide authenticated credentials that are permitted to introspect the schema.
|
|
841
|
+
|
|
842
|
+
WPGraphQL error: ${errorMessage}`
|
|
843
|
+
);
|
|
844
|
+
}
|
|
845
|
+
const type = data?.data?.__type;
|
|
846
|
+
if (!type) return;
|
|
847
|
+
const fields = type.fields || [];
|
|
830
848
|
const hasFilePath = fields.some((f) => f.name === "filePath");
|
|
831
849
|
if (!hasFilePath) {
|
|
832
850
|
throw new Error(
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { useWPContent } from "./useWPContent.js";
|
|
2
2
|
export async function usePrevNextPost(currentSlug, limit = 1e3) {
|
|
3
|
-
const { data
|
|
4
|
-
await execute();
|
|
3
|
+
const { data } = await useWPContent("Posts", ["posts", "nodes"], false, { limit });
|
|
5
4
|
const allPosts = data.value || [];
|
|
6
5
|
if (!allPosts.length) {
|
|
7
6
|
return { prev: null, next: null };
|
|
@@ -29,17 +29,6 @@ export const useWPContent = (queryName, nodes, fixImagePaths, params, options) =
|
|
|
29
29
|
const retryCount = ref(0);
|
|
30
30
|
const isRetrying = ref(false);
|
|
31
31
|
const timeoutMs = timeoutOption ?? 0;
|
|
32
|
-
let abortController;
|
|
33
|
-
let timeoutId;
|
|
34
|
-
if (timeoutMs > 0) {
|
|
35
|
-
abortController = new AbortController();
|
|
36
|
-
timeoutId = setTimeout(() => {
|
|
37
|
-
abortController?.abort();
|
|
38
|
-
if (import.meta.dev) {
|
|
39
|
-
console.warn(`[wpnuxt] Query "${String(queryName)}" timed out after ${timeoutMs}ms`);
|
|
40
|
-
}
|
|
41
|
-
}, timeoutMs);
|
|
42
|
-
}
|
|
43
32
|
const getCachedDataFn = userGetCachedData ?? (clientCache === false ? noCacheGetCachedData : defaultGetCachedData);
|
|
44
33
|
const watchSources = restOptions.watch;
|
|
45
34
|
const autoWatch = isReactiveParams ? [...watchSources ?? [], resolvedParams] : watchSources;
|
|
@@ -51,11 +40,13 @@ export const useWPContent = (queryName, nodes, fixImagePaths, params, options) =
|
|
|
51
40
|
getCachedData: getCachedDataFn,
|
|
52
41
|
// Enable graphql caching so the LRU cache is populated for subsequent navigations
|
|
53
42
|
graphqlCaching: { client: clientCache !== false },
|
|
54
|
-
//
|
|
55
|
-
|
|
43
|
+
// Per-request timeout: ofetch creates and tears down a fresh AbortController
|
|
44
|
+
// + timer for each request, so re-fetches stay protected and a fired timeout
|
|
45
|
+
// never poisons subsequent requests.
|
|
46
|
+
...timeoutMs > 0 && {
|
|
56
47
|
fetchOptions: {
|
|
57
48
|
...restOptions.fetchOptions ?? {},
|
|
58
|
-
|
|
49
|
+
timeout: timeoutMs
|
|
59
50
|
}
|
|
60
51
|
}
|
|
61
52
|
};
|
|
@@ -66,14 +57,6 @@ export const useWPContent = (queryName, nodes, fixImagePaths, params, options) =
|
|
|
66
57
|
);
|
|
67
58
|
const { data, pending, refresh, execute, clear, error, status } = asyncResult;
|
|
68
59
|
const transformError = ref(null);
|
|
69
|
-
if (timeoutId !== void 0) {
|
|
70
|
-
vueWatch(pending, (isPending) => {
|
|
71
|
-
if (!isPending && timeoutId !== void 0) {
|
|
72
|
-
clearTimeout(timeoutId);
|
|
73
|
-
timeoutId = void 0;
|
|
74
|
-
}
|
|
75
|
-
}, { immediate: true });
|
|
76
|
-
}
|
|
77
60
|
if (maxRetries > 0) {
|
|
78
61
|
vueWatch(error, async (newError) => {
|
|
79
62
|
if (newError && !isRetrying.value && retryCount.value < maxRetries && import.meta.client) {
|
|
@@ -16,7 +16,7 @@ function isInternalLink(url, wordpressUrl) {
|
|
|
16
16
|
const fullUrl = trimmed.startsWith("//") ? `https:${trimmed}` : trimmed;
|
|
17
17
|
const parsedUrl = new URL(fullUrl);
|
|
18
18
|
const parsedWp = new URL(wordpressUrl);
|
|
19
|
-
return parsedUrl.
|
|
19
|
+
return parsedUrl.host === parsedWp.host;
|
|
20
20
|
} catch {
|
|
21
21
|
return false;
|
|
22
22
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wpnuxt/core",
|
|
3
|
-
"version": "2.3.
|
|
3
|
+
"version": "2.3.2",
|
|
4
4
|
"description": "Nuxt module for WordPress integration via GraphQL (WPGraphQL)",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"nuxt",
|
|
@@ -48,27 +48,27 @@
|
|
|
48
48
|
"access": "public"
|
|
49
49
|
},
|
|
50
50
|
"dependencies": {
|
|
51
|
-
"@nuxt/kit": "4.4.
|
|
51
|
+
"@nuxt/kit": "^4.4.6",
|
|
52
52
|
"consola": "^3.4.2",
|
|
53
53
|
"defu": "^6.1.7",
|
|
54
|
-
"dompurify": "^3.4.
|
|
55
|
-
"graphql": "^16.
|
|
54
|
+
"dompurify": "^3.4.7",
|
|
55
|
+
"graphql": "^16.14.0",
|
|
56
56
|
"nuxt-graphql-middleware": "5.4.0",
|
|
57
57
|
"scule": "^1.3.0",
|
|
58
58
|
"typescript": "^5.9.3"
|
|
59
59
|
},
|
|
60
60
|
"devDependencies": {
|
|
61
|
-
"@nuxt/devtools": "
|
|
61
|
+
"@nuxt/devtools": "4.0.0-alpha.6",
|
|
62
62
|
"@nuxt/module-builder": "^1.0.2",
|
|
63
|
-
"@nuxt/schema": "4.4.
|
|
64
|
-
"@nuxt/test-utils": "^4.0.
|
|
65
|
-
"@types/node": "^25.
|
|
66
|
-
"nuxt": "^4.4.
|
|
67
|
-
"vitest": "^4.1.
|
|
68
|
-
"vue-tsc": "^3.2
|
|
63
|
+
"@nuxt/schema": "^4.4.6",
|
|
64
|
+
"@nuxt/test-utils": "^4.0.3",
|
|
65
|
+
"@types/node": "^25.9.1",
|
|
66
|
+
"nuxt": "^4.4.6",
|
|
67
|
+
"vitest": "^4.1.7",
|
|
68
|
+
"vue-tsc": "^3.3.2"
|
|
69
69
|
},
|
|
70
70
|
"peerDependencies": {
|
|
71
|
-
"nuxt": "
|
|
71
|
+
"nuxt": "^4.1.0"
|
|
72
72
|
},
|
|
73
73
|
"scripts": {
|
|
74
74
|
"build": "nuxt-module-build build",
|