nuxt-link-checker 3.1.2 → 3.1.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.
- package/dist/client/200.html +9 -9
- package/dist/client/404.html +9 -9
- package/dist/client/_nuxt/{DTlJ9n0s.js → 3sscvOTR.js} +1 -1
- package/dist/client/_nuxt/{CE38B3OF.js → D4-7YDmO.js} +1 -1
- package/dist/client/_nuxt/builds/latest.json +1 -1
- package/dist/client/_nuxt/builds/meta/a7c8a30a-3ea4-4de2-86d6-222b22c319d7.json +1 -0
- package/dist/client/_nuxt/entry.BbNPsueF.css +1 -0
- package/dist/client/_nuxt/error-404.Duvxb_5r.css +1 -0
- package/dist/client/_nuxt/error-500.Z382q3xB.css +1 -0
- package/dist/client/_nuxt/{ZBuUynGX.js → qPKfeiLE.js} +1 -1
- package/dist/client/_nuxt/r6G1lJlc.js +40 -0
- package/dist/client/index.html +9 -9
- package/dist/module.json +1 -1
- package/dist/module.mjs +153 -150
- package/dist/runtime/nitro/routes/__link-checker__/debug.js +1 -1
- package/dist/runtime/nitro/routes/__link-checker__/inspect.js +3 -3
- package/dist/runtime/nitro/routes/__link-checker__/links.js +1 -1
- package/dist/runtime/nuxt/plugin/view/Main.vue +1 -1
- package/dist/runtime/nuxt/plugin/view/client.d.ts +1 -1
- package/dist/runtime/nuxt/plugin/view/client.js +2 -2
- package/dist/runtime/pure/index.d.ts +3 -3
- package/dist/runtime/pure/index.js +5 -5
- package/dist/runtime/pure/inspect.js +5 -5
- package/dist/runtime/pure/inspections/descriptive-link-text.js +2 -2
- package/dist/runtime/types.d.ts +2 -2
- package/package.json +18 -18
- package/dist/client/_nuxt/BGXXrhfN.js +0 -40
- package/dist/client/_nuxt/builds/meta/cd536571-8901-45d4-b5c2-149b2eb2ef0c.json +0 -1
- package/dist/client/_nuxt/entry.BPVwhKGg.css +0 -1
- package/dist/client/_nuxt/error-404.CcgDkxt2.css +0 -1
- package/dist/client/_nuxt/error-500.CcBgumSp.css +0 -1
package/dist/client/index.html
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<!DOCTYPE html><html data-capo=""><head><meta charset="utf-8">
|
|
2
2
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
3
|
-
<link rel="stylesheet" href="/__nuxt-link-checker/_nuxt/entry.
|
|
4
|
-
<link rel="modulepreload" as="script" crossorigin href="/__nuxt-link-checker/_nuxt/
|
|
3
|
+
<link rel="stylesheet" href="/__nuxt-link-checker/_nuxt/entry.BbNPsueF.css">
|
|
4
|
+
<link rel="modulepreload" as="script" crossorigin href="/__nuxt-link-checker/_nuxt/r6G1lJlc.js">
|
|
5
5
|
<link rel="prefetch" as="script" crossorigin href="/__nuxt-link-checker/_nuxt/35JD59R_.js">
|
|
6
6
|
<link rel="prefetch" as="script" crossorigin href="/__nuxt-link-checker/_nuxt/Ci-La1BS.js">
|
|
7
7
|
<link rel="prefetch" as="script" crossorigin href="/__nuxt-link-checker/_nuxt/DOAn35dn.js">
|
|
@@ -266,10 +266,10 @@
|
|
|
266
266
|
<link rel="prefetch" as="script" crossorigin href="/__nuxt-link-checker/_nuxt/D0r3Knsf.js">
|
|
267
267
|
<link rel="prefetch" as="script" crossorigin href="/__nuxt-link-checker/_nuxt/CVO1_9PV.js">
|
|
268
268
|
<link rel="prefetch" as="script" crossorigin href="/__nuxt-link-checker/_nuxt/CG6Dc4jp.js">
|
|
269
|
-
<link rel="prefetch" as="style" crossorigin href="/__nuxt-link-checker/_nuxt/error-404.
|
|
270
|
-
<link rel="prefetch" as="script" crossorigin href="/__nuxt-link-checker/_nuxt/
|
|
271
|
-
<link rel="prefetch" as="script" crossorigin href="/__nuxt-link-checker/_nuxt/
|
|
272
|
-
<link rel="prefetch" as="style" crossorigin href="/__nuxt-link-checker/_nuxt/error-500.
|
|
273
|
-
<link rel="prefetch" as="script" crossorigin href="/__nuxt-link-checker/_nuxt/
|
|
274
|
-
<script type="module" src="/__nuxt-link-checker/_nuxt/
|
|
275
|
-
<script>window.__NUXT__={};window.__NUXT__.config={public:{},app:{baseURL:"/__nuxt-link-checker",buildId:"
|
|
269
|
+
<link rel="prefetch" as="style" crossorigin href="/__nuxt-link-checker/_nuxt/error-404.Duvxb_5r.css">
|
|
270
|
+
<link rel="prefetch" as="script" crossorigin href="/__nuxt-link-checker/_nuxt/3sscvOTR.js">
|
|
271
|
+
<link rel="prefetch" as="script" crossorigin href="/__nuxt-link-checker/_nuxt/D4-7YDmO.js">
|
|
272
|
+
<link rel="prefetch" as="style" crossorigin href="/__nuxt-link-checker/_nuxt/error-500.Z382q3xB.css">
|
|
273
|
+
<link rel="prefetch" as="script" crossorigin href="/__nuxt-link-checker/_nuxt/qPKfeiLE.js">
|
|
274
|
+
<script type="module" src="/__nuxt-link-checker/_nuxt/r6G1lJlc.js" crossorigin></script></head><body><div id="__nuxt"></div><div id="teleports"></div><script type="application/json" data-nuxt-data="nuxt-app" data-ssr="false" id="__NUXT_DATA__">[{"prerenderedAt":1,"serverRendered":2},1730212957745,false]</script>
|
|
275
|
+
<script>window.__NUXT__={};window.__NUXT__.config={public:{},app:{baseURL:"/__nuxt-link-checker",buildId:"a7c8a30a-3ea4-4de2-86d6-222b22c319d7",buildAssetsDir:"/_nuxt/",cdnURL:""}}</script></body></html>
|
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -2,27 +2,168 @@ import { useNuxt, extendPages, defineNuxtModule, createResolver, useLogger, addP
|
|
|
2
2
|
import { useSiteConfig, installNuxtSiteConfig } from 'nuxt-site-config-kit';
|
|
3
3
|
import { readPackageJSON } from 'pkg-types';
|
|
4
4
|
import { existsSync } from 'node:fs';
|
|
5
|
-
import
|
|
6
|
-
import
|
|
5
|
+
import { readFile, writeFile } from 'node:fs/promises';
|
|
6
|
+
import { onDevToolsInitialized, extendServerRpc } from '@nuxt/devtools-kit';
|
|
7
|
+
import { diffArrays } from 'diff';
|
|
7
8
|
import { resolve, relative } from 'pathe';
|
|
9
|
+
import { generateLinkDiff } from '../dist/runtime/pure/diff.js';
|
|
10
|
+
import { joinURL, withoutLeadingSlash } from 'ufo';
|
|
11
|
+
import chalk from 'chalk';
|
|
8
12
|
import { load } from 'cheerio';
|
|
9
|
-
import
|
|
13
|
+
import Fuse from 'fuse.js';
|
|
10
14
|
import { createStorage } from 'unstorage';
|
|
11
15
|
import fsDriver from 'unstorage/drivers/fs';
|
|
16
|
+
import { setLinkResponse, getLinkResponse, crawlFetch } from '../dist/runtime/pure/crawl.js';
|
|
12
17
|
import { inspect } from '../dist/runtime/pure/inspect.js';
|
|
13
18
|
import { createFilter } from '../dist/runtime/pure/sharedUtils.js';
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
+
|
|
20
|
+
function convertNuxtPagesToPaths(pages) {
|
|
21
|
+
return pages.map((page) => {
|
|
22
|
+
return page.children?.length ? page.children.map((child) => {
|
|
23
|
+
return {
|
|
24
|
+
path: joinURL(page.path, child.path),
|
|
25
|
+
page: child
|
|
26
|
+
};
|
|
27
|
+
}) : { page, path: page.path };
|
|
28
|
+
}).flat().filter((p) => !p.path.includes(":")).map((p) => ({
|
|
29
|
+
title: p.page?.meta?.title || "",
|
|
30
|
+
link: p.path
|
|
31
|
+
}));
|
|
32
|
+
}
|
|
33
|
+
function useViteWebSocket(nuxt = useNuxt()) {
|
|
34
|
+
return new Promise((_resolve) => {
|
|
35
|
+
nuxt.hooks.hook("vite:serverCreated", (viteServer) => {
|
|
36
|
+
_resolve(viteServer.ws);
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const DEVTOOLS_UI_ROUTE = "/__nuxt-link-checker";
|
|
42
|
+
const DEVTOOLS_UI_LOCAL_PORT = 3030;
|
|
43
|
+
const RPC_NAMESPACE = "nuxt-link-checker-rpc";
|
|
44
|
+
function setupDevToolsUI(options, moduleResolve, nuxt = useNuxt()) {
|
|
45
|
+
const clientPath = moduleResolve("./client");
|
|
46
|
+
const isProductionBuild = existsSync(clientPath);
|
|
47
|
+
if (isProductionBuild) {
|
|
48
|
+
nuxt.hook("vite:serverCreated", async (server) => {
|
|
49
|
+
const sirv = await import('sirv').then((r) => r.default || r);
|
|
50
|
+
server.middlewares.use(
|
|
51
|
+
DEVTOOLS_UI_ROUTE,
|
|
52
|
+
sirv(clientPath, { dev: true, single: true })
|
|
53
|
+
);
|
|
54
|
+
});
|
|
55
|
+
} else {
|
|
56
|
+
nuxt.hook("vite:extendConfig", (config) => {
|
|
57
|
+
config.server = config.server || {};
|
|
58
|
+
config.server.proxy = config.server.proxy || {};
|
|
59
|
+
config.server.proxy[DEVTOOLS_UI_ROUTE] = {
|
|
60
|
+
target: `http://localhost:${DEVTOOLS_UI_LOCAL_PORT}${DEVTOOLS_UI_ROUTE}`,
|
|
61
|
+
changeOrigin: true,
|
|
62
|
+
followRedirects: true,
|
|
63
|
+
rewrite: (path) => path.replace(DEVTOOLS_UI_ROUTE, "")
|
|
64
|
+
};
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
nuxt.hook("devtools:customTabs", (tabs) => {
|
|
68
|
+
tabs.push({
|
|
69
|
+
// unique identifier
|
|
70
|
+
name: "nuxt-link-checker",
|
|
71
|
+
// title to display in the tab
|
|
72
|
+
title: "Link Checker",
|
|
73
|
+
// any icon from Iconify, or a URL to an image
|
|
74
|
+
icon: "carbon:cloud-satellite-link",
|
|
75
|
+
// iframe view
|
|
76
|
+
view: {
|
|
77
|
+
type: "iframe",
|
|
78
|
+
src: DEVTOOLS_UI_ROUTE
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
});
|
|
82
|
+
let isConnected = false;
|
|
83
|
+
const viteServerWs = useViteWebSocket();
|
|
84
|
+
const rpc = new Promise((promiseResolve) => {
|
|
85
|
+
onDevToolsInitialized(async () => {
|
|
86
|
+
const rpc2 = extendServerRpc(RPC_NAMESPACE, {
|
|
87
|
+
getOptions() {
|
|
88
|
+
return options;
|
|
89
|
+
},
|
|
90
|
+
async reset() {
|
|
91
|
+
const ws = await viteServerWs;
|
|
92
|
+
ws.send("nuxt-link-checker:reset");
|
|
93
|
+
},
|
|
94
|
+
async scrollToLink(link) {
|
|
95
|
+
const ws = await viteServerWs;
|
|
96
|
+
ws.send("nuxt-link-checker:scroll-to-link", link);
|
|
97
|
+
},
|
|
98
|
+
async applyLinkFixes(diff, original, replacement) {
|
|
99
|
+
for (const { filepath } of diff) {
|
|
100
|
+
const rootDirFolderName = nuxt.options.rootDir.split("/").pop();
|
|
101
|
+
const filepathWithoutRoot = filepath.replace(new RegExp(`^${nuxt.options.rootDir}/`), "").replace(new RegExp(`^${rootDirFolderName}/`), "");
|
|
102
|
+
const fp = resolve(nuxt.options.rootDir, filepathWithoutRoot);
|
|
103
|
+
const contents = await readFile(fp, "utf8");
|
|
104
|
+
const diff2 = generateLinkDiff(contents, original, replacement);
|
|
105
|
+
await writeFile(fp, diff2.code, "utf8");
|
|
106
|
+
}
|
|
107
|
+
const ws = await viteServerWs;
|
|
108
|
+
ws.send("nuxt-link-checker:reset");
|
|
109
|
+
},
|
|
110
|
+
async toggleLiveInspections(enabled) {
|
|
111
|
+
const ws = await viteServerWs;
|
|
112
|
+
ws.send("nuxt-link-checker:live-inspections", { enabled });
|
|
113
|
+
},
|
|
114
|
+
async connected() {
|
|
115
|
+
const ws = await viteServerWs;
|
|
116
|
+
ws.send("nuxt-link-checker:connected");
|
|
117
|
+
isConnected = true;
|
|
118
|
+
}
|
|
119
|
+
});
|
|
120
|
+
promiseResolve(rpc2);
|
|
121
|
+
});
|
|
122
|
+
});
|
|
123
|
+
viteServerWs.then((ws) => {
|
|
124
|
+
ws.on("nuxt-link-checker:queueWorking", async (payload) => {
|
|
125
|
+
if (isConnected) {
|
|
126
|
+
const _rpc = await rpc;
|
|
127
|
+
_rpc.broadcast.queueWorking(payload).catch(() => {
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
});
|
|
131
|
+
ws.on("nuxt-link-checker:updated", async () => {
|
|
132
|
+
if (isConnected) {
|
|
133
|
+
const _rpc = await rpc;
|
|
134
|
+
_rpc.broadcast.updated().catch(() => {
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
});
|
|
138
|
+
ws.on("nuxt-link-checker:filter", async (payload) => {
|
|
139
|
+
if (isConnected) {
|
|
140
|
+
const _rpc = await rpc;
|
|
141
|
+
_rpc.broadcast.filter(payload).catch(() => {
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
});
|
|
145
|
+
let lastRoutes = [];
|
|
146
|
+
extendPages(async (pages) => {
|
|
147
|
+
const routes = convertNuxtPagesToPaths(pages);
|
|
148
|
+
if (lastRoutes.length) {
|
|
149
|
+
const routeDiff = diffArrays(lastRoutes, routes);
|
|
150
|
+
if (routeDiff.some((diff) => diff.added || diff.removed))
|
|
151
|
+
ws.send("nuxt-link-checker:reset");
|
|
152
|
+
}
|
|
153
|
+
lastRoutes = routes;
|
|
154
|
+
});
|
|
155
|
+
});
|
|
156
|
+
}
|
|
19
157
|
|
|
20
158
|
const linkMap = {};
|
|
21
|
-
function extractPayload(html) {
|
|
159
|
+
function extractPayload(html, rootNodeId = "#__nuxt") {
|
|
160
|
+
if (String(rootNodeId).length) {
|
|
161
|
+
rootNodeId = rootNodeId[0] === "#" ? rootNodeId : `#${rootNodeId}`;
|
|
162
|
+
}
|
|
22
163
|
const $ = load(html);
|
|
23
|
-
const ids = $(
|
|
164
|
+
const ids = $(`${rootNodeId} [id]`.trim()).map((i, el) => $(el).attr("id")).get();
|
|
24
165
|
const title = $("title").text();
|
|
25
|
-
const links = $(
|
|
166
|
+
const links = $(`${rootNodeId} a[href]`.trim()).map((i, el) => {
|
|
26
167
|
return {
|
|
27
168
|
link: $(el).attr("href") || "",
|
|
28
169
|
textContent: ($(el).attr("aria-label") || $(el).attr("title") || $(el).text()).trim() || ""
|
|
@@ -42,7 +183,7 @@ function prerender(config, nuxt = useNuxt()) {
|
|
|
42
183
|
nitro.hooks.hook("prerender:generate", async (ctx) => {
|
|
43
184
|
const route = decodeURI(ctx.route);
|
|
44
185
|
if (ctx.contents && !ctx.error && ctx.fileName?.endsWith(".html") && !route.endsWith(".html") && urlFilter(route))
|
|
45
|
-
linkMap[route] = extractPayload(ctx.contents);
|
|
186
|
+
linkMap[route] = extractPayload(ctx.contents, nuxt.options.app.rootAttrs?.id || "");
|
|
46
187
|
setLinkResponse(route, Promise.resolve({ status: Number(ctx.error?.statusCode) || 200, statusText: ctx.error?.statusMessage || "", headers: {} }));
|
|
47
188
|
});
|
|
48
189
|
nitro.hooks.hook("prerender:done", async () => {
|
|
@@ -230,144 +371,6 @@ function prerender(config, nuxt = useNuxt()) {
|
|
|
230
371
|
});
|
|
231
372
|
}
|
|
232
373
|
|
|
233
|
-
function convertNuxtPagesToPaths(pages) {
|
|
234
|
-
return pages.map((page) => {
|
|
235
|
-
return page.children?.length ? page.children.map((child) => {
|
|
236
|
-
return {
|
|
237
|
-
path: joinURL(page.path, child.path),
|
|
238
|
-
page: child
|
|
239
|
-
};
|
|
240
|
-
}) : { page, path: page.path };
|
|
241
|
-
}).flat().filter((p) => !p.path.includes(":")).map((p) => ({
|
|
242
|
-
title: p.page?.meta?.title || "",
|
|
243
|
-
link: p.path
|
|
244
|
-
}));
|
|
245
|
-
}
|
|
246
|
-
function useViteWebSocket(nuxt = useNuxt()) {
|
|
247
|
-
return new Promise((_resolve) => {
|
|
248
|
-
nuxt.hooks.hook("vite:serverCreated", (viteServer) => {
|
|
249
|
-
_resolve(viteServer.ws);
|
|
250
|
-
});
|
|
251
|
-
});
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
const DEVTOOLS_UI_ROUTE = "/__nuxt-link-checker";
|
|
255
|
-
const DEVTOOLS_UI_LOCAL_PORT = 3030;
|
|
256
|
-
const RPC_NAMESPACE = "nuxt-link-checker-rpc";
|
|
257
|
-
function setupDevToolsUI(options, moduleResolve, nuxt = useNuxt()) {
|
|
258
|
-
const clientPath = moduleResolve("./client");
|
|
259
|
-
const isProductionBuild = existsSync(clientPath);
|
|
260
|
-
if (isProductionBuild) {
|
|
261
|
-
nuxt.hook("vite:serverCreated", async (server) => {
|
|
262
|
-
const sirv = await import('sirv').then((r) => r.default || r);
|
|
263
|
-
server.middlewares.use(
|
|
264
|
-
DEVTOOLS_UI_ROUTE,
|
|
265
|
-
sirv(clientPath, { dev: true, single: true })
|
|
266
|
-
);
|
|
267
|
-
});
|
|
268
|
-
} else {
|
|
269
|
-
nuxt.hook("vite:extendConfig", (config) => {
|
|
270
|
-
config.server = config.server || {};
|
|
271
|
-
config.server.proxy = config.server.proxy || {};
|
|
272
|
-
config.server.proxy[DEVTOOLS_UI_ROUTE] = {
|
|
273
|
-
target: `http://localhost:${DEVTOOLS_UI_LOCAL_PORT}${DEVTOOLS_UI_ROUTE}`,
|
|
274
|
-
changeOrigin: true,
|
|
275
|
-
followRedirects: true,
|
|
276
|
-
rewrite: (path) => path.replace(DEVTOOLS_UI_ROUTE, "")
|
|
277
|
-
};
|
|
278
|
-
});
|
|
279
|
-
}
|
|
280
|
-
nuxt.hook("devtools:customTabs", (tabs) => {
|
|
281
|
-
tabs.push({
|
|
282
|
-
// unique identifier
|
|
283
|
-
name: "nuxt-link-checker",
|
|
284
|
-
// title to display in the tab
|
|
285
|
-
title: "Link Checker",
|
|
286
|
-
// any icon from Iconify, or a URL to an image
|
|
287
|
-
icon: "carbon:cloud-satellite-link",
|
|
288
|
-
// iframe view
|
|
289
|
-
view: {
|
|
290
|
-
type: "iframe",
|
|
291
|
-
src: DEVTOOLS_UI_ROUTE
|
|
292
|
-
}
|
|
293
|
-
});
|
|
294
|
-
});
|
|
295
|
-
let isConnected = false;
|
|
296
|
-
const viteServerWs = useViteWebSocket();
|
|
297
|
-
const rpc = new Promise((promiseResolve) => {
|
|
298
|
-
onDevToolsInitialized(async () => {
|
|
299
|
-
const rpc2 = extendServerRpc(RPC_NAMESPACE, {
|
|
300
|
-
getOptions() {
|
|
301
|
-
return options;
|
|
302
|
-
},
|
|
303
|
-
async reset() {
|
|
304
|
-
const ws = await viteServerWs;
|
|
305
|
-
ws.send("nuxt-link-checker:reset");
|
|
306
|
-
},
|
|
307
|
-
async scrollToLink(link) {
|
|
308
|
-
const ws = await viteServerWs;
|
|
309
|
-
ws.send("nuxt-link-checker:scroll-to-link", link);
|
|
310
|
-
},
|
|
311
|
-
async applyLinkFixes(diff, original, replacement) {
|
|
312
|
-
for (const { filepath } of diff) {
|
|
313
|
-
const rootDirFolderName = nuxt.options.rootDir.split("/").pop();
|
|
314
|
-
const filepathWithoutRoot = filepath.replace(new RegExp(`^${nuxt.options.rootDir}/`), "").replace(new RegExp(`^${rootDirFolderName}/`), "");
|
|
315
|
-
const fp = resolve(nuxt.options.rootDir, filepathWithoutRoot);
|
|
316
|
-
const contents = await readFile(fp, "utf8");
|
|
317
|
-
const diff2 = generateLinkDiff(contents, original, replacement);
|
|
318
|
-
await writeFile(fp, diff2.code, "utf8");
|
|
319
|
-
}
|
|
320
|
-
const ws = await viteServerWs;
|
|
321
|
-
ws.send("nuxt-link-checker:reset");
|
|
322
|
-
},
|
|
323
|
-
async toggleLiveInspections(enabled) {
|
|
324
|
-
const ws = await viteServerWs;
|
|
325
|
-
ws.send("nuxt-link-checker:live-inspections", { enabled });
|
|
326
|
-
},
|
|
327
|
-
async connected() {
|
|
328
|
-
const ws = await viteServerWs;
|
|
329
|
-
ws.send("nuxt-link-checker:connected");
|
|
330
|
-
isConnected = true;
|
|
331
|
-
}
|
|
332
|
-
});
|
|
333
|
-
promiseResolve(rpc2);
|
|
334
|
-
});
|
|
335
|
-
});
|
|
336
|
-
viteServerWs.then((ws) => {
|
|
337
|
-
ws.on("nuxt-link-checker:queueWorking", async (payload) => {
|
|
338
|
-
if (isConnected) {
|
|
339
|
-
const _rpc = await rpc;
|
|
340
|
-
_rpc.broadcast.queueWorking(payload).catch(() => {
|
|
341
|
-
});
|
|
342
|
-
}
|
|
343
|
-
});
|
|
344
|
-
ws.on("nuxt-link-checker:updated", async () => {
|
|
345
|
-
if (isConnected) {
|
|
346
|
-
const _rpc = await rpc;
|
|
347
|
-
_rpc.broadcast.updated().catch(() => {
|
|
348
|
-
});
|
|
349
|
-
}
|
|
350
|
-
});
|
|
351
|
-
ws.on("nuxt-link-checker:filter", async (payload) => {
|
|
352
|
-
if (isConnected) {
|
|
353
|
-
const _rpc = await rpc;
|
|
354
|
-
_rpc.broadcast.filter(payload).catch(() => {
|
|
355
|
-
});
|
|
356
|
-
}
|
|
357
|
-
});
|
|
358
|
-
let lastRoutes = [];
|
|
359
|
-
extendPages(async (pages) => {
|
|
360
|
-
const routes = convertNuxtPagesToPaths(pages);
|
|
361
|
-
if (lastRoutes.length) {
|
|
362
|
-
const routeDiff = diffArrays(lastRoutes, routes);
|
|
363
|
-
if (routeDiff.some((diff) => diff.added || diff.removed))
|
|
364
|
-
ws.send("nuxt-link-checker:reset");
|
|
365
|
-
}
|
|
366
|
-
lastRoutes = routes;
|
|
367
|
-
});
|
|
368
|
-
});
|
|
369
|
-
}
|
|
370
|
-
|
|
371
374
|
const module = defineNuxtModule({
|
|
372
375
|
meta: {
|
|
373
376
|
name: "nuxt-link-checker",
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
+
import { useNitroOrigin, useRuntimeConfig, useSiteConfig } from "#imports";
|
|
2
|
+
import Fuse from "fuse.js";
|
|
1
3
|
import { defineEventHandler, getHeader, readBody } from "h3";
|
|
4
|
+
import { resolve } from "pathe";
|
|
2
5
|
import { fixSlashes } from "site-config-stack/urls";
|
|
3
6
|
import { parseURL } from "ufo";
|
|
4
|
-
import { resolve } from "pathe";
|
|
5
|
-
import Fuse from "fuse.js";
|
|
6
7
|
import { generateFileLinkDiff, generateFileLinkPreviews, getLinkResponse, inspect, isNonFetchableLink, lruFsCache } from "#link-checker/pure";
|
|
7
|
-
import { useNitroOrigin, useRuntimeConfig, useSiteConfig } from "#imports";
|
|
8
8
|
import { serverQueryContent } from "#content/server";
|
|
9
9
|
function isInternalRoute(path) {
|
|
10
10
|
const lastSegment = path.split("/").pop() || path;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { createDefu } from "defu";
|
|
2
1
|
import { defineCachedEventHandler, useRuntimeConfig } from "#imports";
|
|
2
|
+
import { createDefu } from "defu";
|
|
3
3
|
import pagePaths from "#nuxt-link-checker-sitemap/pages.mjs";
|
|
4
4
|
import { serverQueryContent } from "#content/server";
|
|
5
5
|
const merger = createDefu((obj, key, value) => {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
-
import { type Ref, computed, ref } from 'vue'
|
|
3
2
|
import type { NuxtLinkCheckerClient } from '../../../types'
|
|
3
|
+
import { computed, type Ref, ref } from 'vue'
|
|
4
4
|
import Squiggle from './Squiggle.vue'
|
|
5
5
|
import { useEventListener } from './utils'
|
|
6
6
|
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { useRuntimeConfig } from "#imports";
|
|
2
2
|
import { useLocalStorage } from "@vueuse/core";
|
|
3
|
+
import { computed, createApp, h, ref, shallowReactive, unref } from "vue";
|
|
3
4
|
import { createFilter } from "../../../pure/sharedUtils.js";
|
|
4
5
|
import Main from "./Main.vue";
|
|
5
6
|
import { linkDb } from "./state.js";
|
|
6
|
-
import { useRuntimeConfig } from "#imports";
|
|
7
7
|
function resolveDevtoolsIframe() {
|
|
8
8
|
const iframe = document.querySelector("#nuxt-devtools-iframe");
|
|
9
9
|
if (!iframe)
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { inspect } from './inspect.js';
|
|
2
|
-
import { generateFileLinkDiff, generateFileLinkPreviews, lruFsCache } from './diff.js';
|
|
3
1
|
import { getLinkResponse } from './crawl.js';
|
|
2
|
+
import { generateFileLinkDiff, generateFileLinkPreviews, lruFsCache } from './diff.js';
|
|
3
|
+
import { inspect } from './inspect.js';
|
|
4
4
|
import { isNonFetchableLink } from './inspections/util.js';
|
|
5
|
-
export {
|
|
5
|
+
export { generateFileLinkDiff, generateFileLinkPreviews, getLinkResponse, inspect, isNonFetchableLink, lruFsCache, };
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { inspect } from "./inspect.js";
|
|
2
|
-
import { generateFileLinkDiff, generateFileLinkPreviews, lruFsCache } from "./diff.js";
|
|
3
1
|
import { getLinkResponse } from "./crawl.js";
|
|
2
|
+
import { generateFileLinkDiff, generateFileLinkPreviews, lruFsCache } from "./diff.js";
|
|
3
|
+
import { inspect } from "./inspect.js";
|
|
4
4
|
import { isNonFetchableLink } from "./inspections/util.js";
|
|
5
5
|
export {
|
|
6
|
-
inspect,
|
|
7
6
|
generateFileLinkDiff,
|
|
8
7
|
generateFileLinkPreviews,
|
|
9
|
-
lruFsCache,
|
|
10
8
|
getLinkResponse,
|
|
11
|
-
|
|
9
|
+
inspect,
|
|
10
|
+
isNonFetchableLink,
|
|
11
|
+
lruFsCache
|
|
12
12
|
};
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { parseURL } from "ufo";
|
|
2
|
-
import
|
|
2
|
+
import RuleAbsoluteSiteUrls from "./inspections/absolute-site-urls.js";
|
|
3
|
+
import RuleDescriptiveLinkText from "./inspections/descriptive-link-text.js";
|
|
3
4
|
import RuleMissingHash from "./inspections/missing-hash.js";
|
|
4
5
|
import RuleNoBaseLess from "./inspections/no-baseless.js";
|
|
5
|
-
import RuleNoJavascript from "./inspections/no-javascript.js";
|
|
6
|
-
import RuleAbsoluteSiteUrls from "./inspections/absolute-site-urls.js";
|
|
7
|
-
import RuleRedirects from "./redirects.js";
|
|
8
6
|
import RuleNoErrorResponse from "./inspections/no-error-response-status.js";
|
|
9
|
-
import
|
|
7
|
+
import RuleNoJavascript from "./inspections/no-javascript.js";
|
|
8
|
+
import RuleTrailingSlash from "./inspections/trailing-slash.js";
|
|
10
9
|
import { isNonFetchableLink } from "./inspections/util.js";
|
|
10
|
+
import RuleRedirects from "./redirects.js";
|
|
11
11
|
export const AllInspections = [
|
|
12
12
|
RuleMissingHash(),
|
|
13
13
|
RuleNoErrorResponse(),
|
|
@@ -9,7 +9,7 @@ export default function RuleDescriptiveLinkText() {
|
|
|
9
9
|
report({
|
|
10
10
|
name: "link-text",
|
|
11
11
|
scope: "warning",
|
|
12
|
-
message: "
|
|
12
|
+
message: "Missing link textContent, title or aria-label.",
|
|
13
13
|
tip: "Links with descriptive text are easier to understand for screen readers and search engines."
|
|
14
14
|
});
|
|
15
15
|
}
|
|
@@ -29,7 +29,7 @@ export default function RuleDescriptiveLinkText() {
|
|
|
29
29
|
report({
|
|
30
30
|
name: "link-text",
|
|
31
31
|
scope: "warning",
|
|
32
|
-
message: "
|
|
32
|
+
message: `Link text "${textContent}" should be more descriptive.`,
|
|
33
33
|
tip: `The ${textContent} descriptive text does not provide any context to the link.`
|
|
34
34
|
});
|
|
35
35
|
}
|
package/dist/runtime/types.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { SiteConfigResolved } from 'site-config-stack';
|
|
2
1
|
import type Fuse from 'fuse.js';
|
|
3
|
-
import type {
|
|
2
|
+
import type { SiteConfigResolved } from 'site-config-stack';
|
|
4
3
|
import type { ParsedURL } from 'ufo';
|
|
4
|
+
import type { ComputedRef, Ref } from 'vue';
|
|
5
5
|
export interface Rule {
|
|
6
6
|
id: string;
|
|
7
7
|
test: (ctx: RuleTestContext) => void;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nuxt-link-checker",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "3.1.
|
|
4
|
+
"version": "3.1.3",
|
|
5
5
|
"description": "Find and magically fix links that may be negatively effecting your Nuxt sites SEO.",
|
|
6
6
|
"author": {
|
|
7
7
|
"name": "Harlan Wilton",
|
|
@@ -39,42 +39,42 @@
|
|
|
39
39
|
"dist"
|
|
40
40
|
],
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@nuxt/devtools-kit": "^1.
|
|
42
|
+
"@nuxt/devtools-kit": "^1.6.0",
|
|
43
43
|
"@nuxt/kit": "^3.13.2",
|
|
44
44
|
"@vueuse/core": "^11.1.0",
|
|
45
45
|
"chalk": "^5.3.0",
|
|
46
46
|
"cheerio": "1.0.0",
|
|
47
47
|
"diff": "^7.0.0",
|
|
48
48
|
"fuse.js": "^7.0.0",
|
|
49
|
-
"magic-string": "^0.30.
|
|
49
|
+
"magic-string": "^0.30.12",
|
|
50
50
|
"nuxt-site-config": "2.2.18",
|
|
51
51
|
"nuxt-site-config-kit": "2.2.18",
|
|
52
52
|
"pathe": "^1.1.2",
|
|
53
|
-
"pkg-types": "^1.2.
|
|
53
|
+
"pkg-types": "^1.2.1",
|
|
54
54
|
"radix3": "^1.1.2",
|
|
55
|
-
"sirv": "^
|
|
55
|
+
"sirv": "^3.0.0",
|
|
56
56
|
"site-config-stack": "^2.2.18",
|
|
57
57
|
"ufo": "^1.5.4"
|
|
58
58
|
},
|
|
59
59
|
"devDependencies": {
|
|
60
|
-
"@antfu/eslint-config": "^3.
|
|
61
|
-
"@nuxt/content": "^2.13.
|
|
62
|
-
"@nuxt/devtools": "^1.
|
|
60
|
+
"@antfu/eslint-config": "^3.8.0",
|
|
61
|
+
"@nuxt/content": "^2.13.4",
|
|
62
|
+
"@nuxt/devtools": "^1.6.0",
|
|
63
63
|
"@nuxt/module-builder": "0.8.4",
|
|
64
|
-
"@nuxt/test-utils": "^3.14.
|
|
65
|
-
"@nuxt/ui": "^2.18.
|
|
64
|
+
"@nuxt/test-utils": "^3.14.4",
|
|
65
|
+
"@nuxt/ui": "^2.18.7",
|
|
66
66
|
"@nuxtjs/eslint-config-typescript": "^12.1.0",
|
|
67
|
-
"@nuxtjs/sitemap": "6.1.
|
|
68
|
-
"@types/diff": "^5.2.
|
|
69
|
-
"bumpp": "^9.
|
|
70
|
-
"eslint": "9.
|
|
71
|
-
"execa": "^9.
|
|
67
|
+
"@nuxtjs/sitemap": "6.1.2",
|
|
68
|
+
"@types/diff": "^5.2.3",
|
|
69
|
+
"bumpp": "^9.8.0",
|
|
70
|
+
"eslint": "9.13.0",
|
|
71
|
+
"execa": "^9.5.1",
|
|
72
72
|
"nuxt": "^3.13.2",
|
|
73
|
-
"vitest": "^2.1.
|
|
73
|
+
"vitest": "^2.1.4"
|
|
74
74
|
},
|
|
75
75
|
"resolutions": {
|
|
76
|
-
"
|
|
77
|
-
"
|
|
76
|
+
"nuxt-link-checker": "workspace:*",
|
|
77
|
+
"vue": "3.5.10"
|
|
78
78
|
},
|
|
79
79
|
"scripts": {
|
|
80
80
|
"build": "nuxt-module-build build --stub && nuxt-module-build prepare && nuxt-module-build build && npm run client:build",
|