PageSourceSearch

https://app.docuopia.com/_nuxt/nuxt-link.83fb2e27.js

js docuopia.com collected 2026-09-30 12:12:25 UTC 9,834 bytes, 306 lines download raw bytes

1import { g as useRouter, f as defineComponent, z as computed, cW as hasProtocol, A as ref, F as onMounted, cX as onNuxtReady, cY as requestIdleCallback, al as onBeforeUnmount, cZ as cancelIdleCallback, aI as h, b7 as resolveComponent, c_ as parseURL, c$ as parseQuery, d0 as nuxtLinkDefaults, d1 as withTrailingSlash, d2 as withoutTrailingSlash, aM as useNuxtApp, d3 as navigateTo } from "./entry.bb9e2e36.js";
2async function preloadRouteComponents(to, router = useRouter()) {
3  const { path, matched } = router.resolve(to);
4  if (!matched.length) {
5    return;
6  }
7  if (!router._routePreloaded) {
8    router._routePreloaded = /* @__PURE__ */ new Set();
9  }
10  if (router._routePreloaded.has(path)) {
11    return;
12  }
13  const promises = router._preloadPromises = router._preloadPromises || [];
14  if (promises.length > 4) {
15    return Promise.all(promises).then(() => preloadRouteComponents(to, router));
16  }
17  router._routePreloaded.add(path);
18  const components = matched.map((component) => {
19    var _a;
20    return (_a = component.components) == null ? void 0 : _a.default;
21  }).filter((component) => typeof component === "function");
22  for (const component of components) {
23    const promise = Promise.resolve(component()).catch(() => {
24    }).finally(() => promises.splice(promises.indexOf(promise)));
25    promises.push(promise);
26  }
27  await Promise.all(promises);
28}
29const firstNonUndefined = (...args) => args.find((arg) => arg !== void 0);
30const DEFAULT_EXTERNAL_REL_ATTRIBUTE = "noopener noreferrer";
31/*! @__NO_SIDE_EFFECTS__ */
32// @__NO_SIDE_EFFECTS__
33function defineNuxtLink(options) {
34  const componentName = options.componentName || "NuxtLink";
35  const resolveTrailingSlashBehavior = (to, resolve) => {
36    if (!to || options.trailingSlash !== "append" && options.trailingSlash !== "remove") {
37      return to;
38    }
39    const normalizeTrailingSlash = options.trailingSlash === "append" ? withTrailingSlash : withoutTrailingSlash;
40    if (typeof to === "string") {
41      return normalizeTrailingSlash(to, true);
42    }
43    const path = "path" in to ? to.path : resolve(to).path;
44    return {
45      ...to,
46      name: void 0,
47      // named routes would otherwise always override trailing slash behavior
48      path: normalizeTrailingSlash(path, true)
49    };
50  };
51  return /* @__PURE__ */ defineComponent({
52    name: componentName,
53    props: {
54      // Routing
55      to: {
56        type: [String, Object],
57        default: void 0,
58        required: false
59      },
60      href: {
61        type: [String, Object],
62        default: void 0,
63        required: false
64      },
65      // Attributes
66      target: {
67        type: String,
68        default: void 0,
69        required: false
70      },
71      rel: {
72        type: String,
73        default: void 0,
74        required: false
75      },
76      noRel: {
77        type: Boolean,
78        default: void 0,
79        required: false
80      },
81      // Prefetching
82      prefetch: {
83        type: Boolean,
84        default: void 0,
85        required: false
86      },
87      noPrefetch: {
88        type: Boolean,
89        default: void 0,
90        required: false
91      },
92      // Styling
93      activeClass: {
94        type: String,
95        default: void 0,
96        required: false
97      },
98      exactActiveClass: {
99        type: String,
100        default: void 0,
101        required: false
102      },
103      prefetchedClass: {
104        type: String,
105        default: void 0,
106        required: false
107      },
108      // Vue Router's `<RouterLink>` additional props
109      replace: {
110        type: Boolean,
111        default: void 0,
112        required: false
113      },
114      ariaCurrentValue: {
115        type: String,
116        default: void 0,
117        required: false
118      },
119      // Edge cases handling
120      external: {
121        type: Boolean,
122        default: void 0,
123        required: false
124      },
125      // Slot API
126      custom: {
127        type: Boolean,
128        default: void 0,
129        required: false
130      }
131    },
132    setup(props, { slots }) {
133      const router = useRouter();
134      const to = computed(() => {
135        const path = props.to || props.href || "";
136        return resolveTrailingSlashBehavior(path, router.resolve);
137      });
138      const isExternal = computed(() => {
139        if (props.external) {
140          return true;
141        }
142        if (props.target && props.target !== "_self") {
143          return true;
144        }
145        if (typeof to.value === "object") {
146          return false;
147        }
148        return to.value === "" || hasProtocol(to.value, { acceptRelative: true });
149      });
150      const prefetched = ref(false);
151      const el = ref(null);
152      const elRef = (ref2) => {
153        var _a;
154        el.value = props.custom ? (_a = ref2 == null ? void 0 : ref2.$el) == null ? void 0 : _a.nextElementSibling : ref2 == null ? void 0 : ref2.$el;
155      };
156      {
157        const shouldPrefetch = props.prefetch !== false && props.noPrefetch !== true && props.target !== "_blank" && !isSlowConnection();
158        if (shouldPrefetch) {
159          const nuxtApp = useNuxtApp();
160          let idleId;
161          let unobserve = null;
162          onMounted(() => {
163            const observer = useObserver();
164            onNuxtReady(() => {
165              idleId = requestIdleCallback(() => {
166                var _a;
167                if ((_a = el == null ? void 0 : el.value) == null ? void 0 : _a.tagName) {
168                  unobserve = observer.observe(el.value, async () => {
169                    unobserve == null ? void 0 : unobserve();
170                    unobserve = null;
171                    const path = typeof to.value === "string" ? to.value : router.resolve(to.value).fullPath;
172                    await Promise.all([
173                      nuxtApp.hooks.callHook("link:prefetch", path).catch(() => {
174                      }),
175                      !isExternal.value && preloadRouteComponents(to.value, router).catch(() => {
176                      })
177                    ]);
178                    prefetched.value = true;
179                  });
180                }
181              });
182            });
183          });
184          onBeforeUnmount(() => {
185            if (idleId) {
186              cancelIdleCallback(idleId);
187            }
188            unobserve == null ? void 0 : unobserve();
189            unobserve = null;
190          });
191        }
192      }
193      return () => {
194        var _a, _b;
195        if (!isExternal.value) {
196          const routerLinkProps = {
197            ref: elRef,
198            to: to.value,
199            activeClass: props.activeClass || options.activeClass,
200            exactActiveClass: props.exactActiveClass || options.exactActiveClass,
201            replace: props.replace,
202            ariaCurrentValue: props.ariaCurrentValue,
203            custom: props.custom
204          };
205          if (!props.custom) {
206            if (prefetched.value) {
207              routerLinkProps.class = props.prefetchedClass || options.prefetchedClass;
208            }
209            routerLinkProps.rel = props.rel;
210          }
211          return h(
212            resolveComponent("RouterLink"),
213            routerLinkProps,
214            slots.default
215          );
216        }
217        const href = typeof to.value === "object" ? ((_a = router.resolve(to.value)) == null ? void 0 : _a.href) ?? null : to.value || null;
218        const target = props.target || null;
219        const rel = props.noRel ? null : firstNonUndefined(props.rel, options.externalRelAttribute, href ? DEFAULT_EXTERNAL_REL_ATTRIBUTE : "") || null;
220        const navigate = () => navigateTo(href, { replace: props.replace });
221        if (props.custom) {
222          if (!slots.default) {
223            return null;
224          }
225          return slots.default({
226            href,
227            navigate,
228            get route() {
229              if (!href) {
230                return void 0;
231              }
232              const url = parseURL(href);
233              return {
234                path: url.pathname,
235                fullPath: url.pathname,
236                get query() {
237                  return parseQuery(url.search);
238                },
239                hash: url.hash,
240                // stub properties for compat with vue-router
241                params: {},
242                name: void 0,
243                matched: [],
244                redirectedFrom: void 0,
245                meta: {},
246                href
247              };
248            },
249            rel,
250            target,
251            isExternal: isExternal.value,
252            isActive: false,
253            isExactActive: false
254          });
255        }
256        return h("a", { ref: el, href, rel, target }, (_b = slots.default) == null ? void 0 : _b.call(slots));
257      };
258    }
259  });
260}
261const __nuxt_component_0 = /* @__PURE__ */ defineNuxtLink(nuxtLinkDefaults);
262function useObserver() {
263  const nuxtApp = useNuxtApp();
264  if (nuxtApp._observer) {
265    return nuxtApp._observer;
266  }
267  let observer = null;
268  const callbacks = /* @__PURE__ */ new Map();
269  const observe = (element, callback) => {
270    if (!observer) {
271      observer = new IntersectionObserver((entries) => {
272        for (const entry of entries) {
273          const callback2 = callbacks.get(entry.target);
274          const isVisible = entry.isIntersecting || entry.intersectionRatio > 0;
275          if (isVisible && callback2) {
276            callback2();
277          }
278        }
279      });
280    }
281    callbacks.set(element, callback);
282    observer.observe(element);
283    return () => {
284      callbacks.delete(element);
285      observer.unobserve(element);
286      if (callbacks.size === 0) {
287        observer.disconnect();
288        observer = null;
289      }
290    };
291  };
292  const _observer = nuxtApp._observer = {
293    observe
294  };
295  return _observer;
296}
297function isSlowConnection() {
298  const cn = navigator.connection;
299  if (cn && (cn.saveData || /2g/.test(cn.effectiveType))) {
300    return true;
301  }
302  return false;
303}
304export {
305  __nuxt_component_0 as _
306};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.