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 CHANGED
@@ -5,5 +5,5 @@
5
5
  "bridge": false
6
6
  },
7
7
  "configKey": "linkChecker",
8
- "version": "2.0.0-beta.5"
8
+ "version": "2.0.0-beta.6"
9
9
  }
@@ -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 startQueueId;
29
- let domUpdateTimer;
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
- startQueueId && cancelIdleCallback(startQueueId);
148
- startQueueId = requestIdleCallback(() => {
147
+ startQueueIdleId && cancelIdleCallback(startQueueIdleId);
148
+ startQueueIdleId = requestIdleCallback(() => {
149
149
  client.stopQueueWorker();
150
- client.scanLinks();
151
- client.startQueueWorker();
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
- domUpdateTimer && clearTimeout(domUpdateTimer);
167
- domUpdateTimer = setTimeout(() => {
168
- client.reset(false);
169
- }, 500);
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");
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "nuxt-link-checker",
3
3
  "type": "module",
4
- "version": "2.0.0-beta.5",
4
+ "version": "2.0.0-beta.6",
5
5
  "packageManager": "pnpm@8.6.10",
6
6
  "license": "MIT",
7
7
  "funding": "https://github.com/sponsors/harlan-zw",