nuxt-link-checker 2.0.0-beta.5 → 2.0.0-beta.6
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/module.json +1 -1
- package/dist/runtime/plugin/view/client.mjs +19 -12
- package/package.json +1 -1
package/dist/module.json
CHANGED
|
@@ -25,8 +25,8 @@ export async function setupLinkCheckerClient({ nuxt }) {
|
|
|
25
25
|
let devtoolsClient;
|
|
26
26
|
let isOpeningDevtools = false;
|
|
27
27
|
const route = useRoute();
|
|
28
|
-
let
|
|
29
|
-
let
|
|
28
|
+
let startQueueIdleId;
|
|
29
|
+
let startQueueTimeoutId;
|
|
30
30
|
const client = shallowReactive({
|
|
31
31
|
isWorkingQueue: false,
|
|
32
32
|
scanLinks() {
|
|
@@ -144,11 +144,17 @@ export async function setupLinkCheckerClient({ nuxt }) {
|
|
|
144
144
|
client.restart();
|
|
145
145
|
},
|
|
146
146
|
restart() {
|
|
147
|
-
|
|
148
|
-
|
|
147
|
+
startQueueIdleId && cancelIdleCallback(startQueueIdleId);
|
|
148
|
+
startQueueIdleId = requestIdleCallback(() => {
|
|
149
149
|
client.stopQueueWorker();
|
|
150
|
-
|
|
151
|
-
|
|
150
|
+
if (!startQueueTimeoutId) {
|
|
151
|
+
startQueueTimeoutId = setTimeout(() => {
|
|
152
|
+
client.scanLinks();
|
|
153
|
+
client.startQueueWorker();
|
|
154
|
+
client.reset(false);
|
|
155
|
+
startQueueTimeoutId = false;
|
|
156
|
+
}, 250);
|
|
157
|
+
}
|
|
152
158
|
});
|
|
153
159
|
},
|
|
154
160
|
start() {
|
|
@@ -157,18 +163,19 @@ export async function setupLinkCheckerClient({ nuxt }) {
|
|
|
157
163
|
client.reset(true);
|
|
158
164
|
});
|
|
159
165
|
import.meta.hot.on("vite:afterUpdate", (ctx) => {
|
|
160
|
-
console.log("vite after update", ctx.type, ctx.updates);
|
|
161
166
|
if (ctx.updates.some((c) => c.type === "js-update"))
|
|
162
167
|
client.reset(true);
|
|
163
168
|
});
|
|
164
169
|
}
|
|
165
170
|
const observer = new MutationObserver(() => {
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
171
|
+
client.reset(false);
|
|
172
|
+
});
|
|
173
|
+
observer.observe(document.querySelector("#__nuxt"), {
|
|
174
|
+
childList: true,
|
|
175
|
+
subtree: true,
|
|
176
|
+
// we only care if links are added, removed or updated
|
|
177
|
+
attributeFilter: ["href"]
|
|
170
178
|
});
|
|
171
|
-
observer.observe(document.querySelector("#__nuxt"), { childList: true, subtree: true });
|
|
172
179
|
if (nuxt.vueApp._instance)
|
|
173
180
|
nuxt.vueApp._instance.appContext.provides.linkChecker = client;
|
|
174
181
|
const holder = document.createElement("div");
|