@wpnuxt/core 2.3.1 → 2.3.3

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.
@@ -1,4 +1,9 @@
1
1
  import { defineGraphqlClientOptions } from 'nuxt-graphql-middleware/client-options'
2
+ // IMPORTANT: import useRoute from 'vue-router', NOT '#imports'.
3
+ // nuxt-graphql-middleware loads this file via its client-options loader, which
4
+ // pulls it into the server (Nitro) typecheck context where '#imports' resolves
5
+ // to nitro-imports and does NOT export useRoute -> TS2305 at typecheck.
6
+ // This has regressed twice already (see #269/#271). Do not "simplify" back to '#imports'.
2
7
  import { useRoute } from 'vue-router'
3
8
 
4
9
  /**
@@ -18,11 +23,13 @@ export default defineGraphqlClientOptions<{
18
23
  }>({
19
24
  buildClientContext() {
20
25
  const route = useRoute()
26
+ const query = route?.query ?? {}
27
+ const token = query.token
21
28
 
22
29
  return {
23
30
  // Context values must be strings - use 'true'/'false' instead of boolean
24
- preview: route.query.preview === 'true' ? 'true' : undefined,
25
- previewToken: route.query.token as string | undefined
31
+ preview: query.preview === 'true' ? 'true' : undefined,
32
+ previewToken: typeof token === 'string' ? token : undefined
26
33
  }
27
34
  }
28
35
  })
package/dist/module.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wpnuxt/core",
3
- "version": "2.3.1",
3
+ "version": "2.3.3",
4
4
  "configKey": "wpNuxt",
5
5
  "compatibility": {
6
6
  "nuxt": ">=4.0.0"
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.1";
12
+ const version = "2.3.3";
13
13
 
14
14
  const DEFAULT_CPT_EXCLUSIONS = [
15
15
  "Post",
@@ -1,7 +1,6 @@
1
1
  import { useWPContent } from "./useWPContent.js";
2
2
  export async function usePrevNextPost(currentSlug, limit = 1e3) {
3
- const { data, execute } = useWPContent("Posts", ["posts", "nodes"], false, { limit });
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
- // Pass abort signal for timeout support
55
- ...abortController && {
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
- signal: abortController.signal
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.hostname === parsedWp.hostname;
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.1",
3
+ "version": "2.3.3",
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.2",
51
+ "@nuxt/kit": "^4.4.7",
52
52
  "consola": "^3.4.2",
53
53
  "defu": "^6.1.7",
54
- "dompurify": "^3.4.0",
55
- "graphql": "^16.13.2",
54
+ "dompurify": "^3.4.7",
55
+ "graphql": "^16.14.1",
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": "^3.2.3",
61
+ "@nuxt/devtools": "4.0.0-alpha.7",
62
62
  "@nuxt/module-builder": "^1.0.2",
63
- "@nuxt/schema": "4.4.2",
64
- "@nuxt/test-utils": "^4.0.2",
65
- "@types/node": "^25.6.0",
66
- "nuxt": "^4.4.2",
67
- "vitest": "^4.1.4",
68
- "vue-tsc": "^3.2.6"
63
+ "@nuxt/schema": "^4.4.7",
64
+ "@nuxt/test-utils": "^4.0.3",
65
+ "@types/node": "^25.9.1",
66
+ "nuxt": "^4.4.7",
67
+ "vitest": "^4.1.8",
68
+ "vue-tsc": "^3.3.3"
69
69
  },
70
70
  "peerDependencies": {
71
- "nuxt": ">=4.0.0"
71
+ "nuxt": "^4.1.0"
72
72
  },
73
73
  "scripts": {
74
74
  "build": "nuxt-module-build build",