nuxt-loaders 1.1.0 → 1.1.2
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
|
@@ -76,20 +76,29 @@ export const getDefaultLoader = (routeRules, defaultLoaderName = "DefaultLoader"
|
|
|
76
76
|
};
|
|
77
77
|
export const getActiveLoader = (routeRules, path) => {
|
|
78
78
|
if (path.endsWith("/")) {
|
|
79
|
-
path = path.
|
|
79
|
+
path = path.slice(0, -1);
|
|
80
80
|
}
|
|
81
81
|
const rules = Object.keys(routeRules).filter((rule2) => {
|
|
82
82
|
if (rule2.endsWith("/")) {
|
|
83
|
-
rule2 = rule2.
|
|
83
|
+
rule2 = rule2.slice(0, -1);
|
|
84
84
|
}
|
|
85
|
-
if (!path.startsWith(rule2)) return false;
|
|
86
85
|
if (!rule2.endsWith("/*") && path != rule2) return false;
|
|
86
|
+
if (rule2.endsWith("/*")) {
|
|
87
|
+
rule2 = rule2.slice(0, -2);
|
|
88
|
+
}
|
|
89
|
+
if (!path.startsWith(rule2)) return false;
|
|
87
90
|
return true;
|
|
88
91
|
});
|
|
89
92
|
if (rules.length <= 0) {
|
|
90
93
|
return "";
|
|
91
94
|
}
|
|
92
95
|
const rule = rules.reduce((prev, curr) => {
|
|
96
|
+
if (curr.endsWith("/*")) {
|
|
97
|
+
curr = curr.slice(0, -2);
|
|
98
|
+
}
|
|
99
|
+
if (prev.endsWith("/*")) {
|
|
100
|
+
prev = prev.slice(0, -2);
|
|
101
|
+
}
|
|
93
102
|
if (curr.split("/").length > prev.split("/").length) return curr;
|
|
94
103
|
return prev;
|
|
95
104
|
});
|
package/dist/runtime/plugin.js
CHANGED
|
@@ -2,8 +2,14 @@ import { defineNuxtPlugin } from "#app";
|
|
|
2
2
|
import { getActiveLoader } from "./lib/utils/route-rules.js";
|
|
3
3
|
import { useLoader } from "./composables/useLoader.js";
|
|
4
4
|
export default defineNuxtPlugin((nuxt) => {
|
|
5
|
-
const pageLoadingStartHooks = [
|
|
6
|
-
|
|
5
|
+
const pageLoadingStartHooks = [
|
|
6
|
+
"page:loading:start",
|
|
7
|
+
"app:created"
|
|
8
|
+
];
|
|
9
|
+
const pageLoadingEndHooks = [
|
|
10
|
+
"page:loading:end",
|
|
11
|
+
"app:mounted"
|
|
12
|
+
];
|
|
7
13
|
const states = useLoader();
|
|
8
14
|
const { isLoading } = states;
|
|
9
15
|
const ctx = nuxt.$config.public.loaders;
|
|
@@ -12,8 +18,8 @@ export default defineNuxtPlugin((nuxt) => {
|
|
|
12
18
|
nuxt.hooks.beforeEach((e) => {
|
|
13
19
|
if (pageLoadingStartHooks.includes(e.name)) {
|
|
14
20
|
const newActive = getActiveLoader(routeRules, nuxt._route.fullPath);
|
|
15
|
-
if (newActive
|
|
16
|
-
ctx._activeLoader = newActive;
|
|
21
|
+
if (newActive !== ctx._activeLoader) {
|
|
22
|
+
ctx._activeLoader = newActive ?? "";
|
|
17
23
|
}
|
|
18
24
|
isLoading.value = true;
|
|
19
25
|
} else if (pageLoadingEndHooks.includes(e.name)) {
|
package/package.json
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nuxt-loaders",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.2",
|
|
4
4
|
"description": "Simple loading screen engine for Nuxt 4+",
|
|
5
5
|
"repository": "haileabt/nuxt-loaders",
|
|
6
6
|
"license": "MIT",
|
|
7
|
+
"homepage": "https://nuxt-loaders.vercel.app",
|
|
7
8
|
"type": "module",
|
|
8
9
|
"exports": {
|
|
9
10
|
".": {
|