nuxt-seo-utils 8.4.0 → 8.4.1
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/cli.mjs +1 -1
- package/dist/module.d.mts +1 -1
- package/dist/module.d.ts +1 -1
- package/dist/module.json +1 -1
- package/dist/module.mjs +1 -1
- package/dist/runtime/shared/minify.js +47 -34
- package/package.json +17 -17
package/dist/cli.mjs
CHANGED
|
@@ -9,7 +9,7 @@ import { p as pngToIco } from './shared/nuxt-seo-utils.NAV2YNQn.mjs';
|
|
|
9
9
|
import 'node:buffer';
|
|
10
10
|
|
|
11
11
|
const name = "nuxt-seo-utils";
|
|
12
|
-
const version = "8.4.
|
|
12
|
+
const version = "8.4.1";
|
|
13
13
|
const description = "SEO utilities to improve your Nuxt sites discoverability and shareability";
|
|
14
14
|
|
|
15
15
|
const ICON_SIZES = [
|
package/dist/module.d.mts
CHANGED
|
@@ -121,7 +121,7 @@ interface ModuleOptions {
|
|
|
121
121
|
* **Build mode**: Minifies static `app.head` scripts/styles and prerendered route HTML using esbuild (JS) and lightningcss (CSS).
|
|
122
122
|
* **Runtime mode**: Minifies all inline scripts/styles per SSR request via an Unhead `ssr:render` plugin using lightweight pure JS minifiers.
|
|
123
123
|
*
|
|
124
|
-
* @default true
|
|
124
|
+
* @default { build: true, runtime: false }
|
|
125
125
|
*/
|
|
126
126
|
minify: boolean | {
|
|
127
127
|
build?: boolean;
|
package/dist/module.d.ts
CHANGED
|
@@ -121,7 +121,7 @@ interface ModuleOptions {
|
|
|
121
121
|
* **Build mode**: Minifies static `app.head` scripts/styles and prerendered route HTML using esbuild (JS) and lightningcss (CSS).
|
|
122
122
|
* **Runtime mode**: Minifies all inline scripts/styles per SSR request via an Unhead `ssr:render` plugin using lightweight pure JS minifiers.
|
|
123
123
|
*
|
|
124
|
-
* @default true
|
|
124
|
+
* @default { build: true, runtime: false }
|
|
125
125
|
*/
|
|
126
126
|
minify: boolean | {
|
|
127
127
|
build?: boolean;
|
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -615,7 +615,7 @@ const module$1 = defineNuxtModule({
|
|
|
615
615
|
automaticOgAndTwitterTags: true,
|
|
616
616
|
canonicalLowercase: true,
|
|
617
617
|
tagPriority: "low",
|
|
618
|
-
minify: true
|
|
618
|
+
minify: { build: true, runtime: false }
|
|
619
619
|
},
|
|
620
620
|
async setup(config, nuxt) {
|
|
621
621
|
const logger = useModuleLogger("nuxt-seo-utils", config, nuxt);
|
|
@@ -1,23 +1,32 @@
|
|
|
1
1
|
export const JSON_TYPES = /* @__PURE__ */ new Set(["application/json", "application/ld+json"]);
|
|
2
2
|
export const SKIP_JS_TYPES = /* @__PURE__ */ new Set(["application/json", "application/ld+json", "speculationrules", "importmap"]);
|
|
3
|
+
const JS_MINIFY_CANDIDATE_RE = /[\s/]/;
|
|
4
|
+
const CSS_MINIFY_CANDIDATE_RE = /[\s/]|;\}|0\.\d/;
|
|
3
5
|
export function minifyJS(code) {
|
|
6
|
+
if (!JS_MINIFY_CANDIDATE_RE.test(code))
|
|
7
|
+
return code;
|
|
4
8
|
let result = "";
|
|
9
|
+
let last = "";
|
|
5
10
|
let i = 0;
|
|
6
11
|
const len = code.length;
|
|
12
|
+
const append = (value) => {
|
|
13
|
+
result += value;
|
|
14
|
+
last = value;
|
|
15
|
+
};
|
|
7
16
|
while (i < len) {
|
|
8
17
|
const ch = code[i];
|
|
9
18
|
if (ch === "'" || ch === '"' || ch === "`") {
|
|
10
19
|
const quote = ch;
|
|
11
|
-
|
|
20
|
+
append(ch);
|
|
12
21
|
i++;
|
|
13
22
|
while (i < len && code[i] !== quote) {
|
|
14
23
|
if (code[i] === "\\") {
|
|
15
|
-
|
|
24
|
+
append(code[i++]);
|
|
16
25
|
}
|
|
17
|
-
|
|
26
|
+
append(code[i++]);
|
|
18
27
|
}
|
|
19
28
|
if (i < len)
|
|
20
|
-
|
|
29
|
+
append(code[i++]);
|
|
21
30
|
} else if (ch === "/" && code[i + 1] === "/") {
|
|
22
31
|
i += 2;
|
|
23
32
|
while (i < len && code[i] !== "\n")
|
|
@@ -34,65 +43,70 @@ export function minifyJS(code) {
|
|
|
34
43
|
hasNewline = true;
|
|
35
44
|
i++;
|
|
36
45
|
}
|
|
37
|
-
const prev = result.at(-1);
|
|
38
46
|
const next = code[i];
|
|
39
|
-
if (hasNewline &&
|
|
40
|
-
|
|
41
|
-
else if (
|
|
42
|
-
|
|
43
|
-
else if (
|
|
44
|
-
|
|
47
|
+
if (hasNewline && last && next && last !== "{" && last !== "}" && last !== ";" && next !== "}" && next !== ";")
|
|
48
|
+
append("\n");
|
|
49
|
+
else if (last && next && isIdentChar(last) && isIdentChar(next))
|
|
50
|
+
append(" ");
|
|
51
|
+
else if (last && next && (last === "+" && next === "+" || last === "-" && next === "-"))
|
|
52
|
+
append(" ");
|
|
45
53
|
} else {
|
|
46
|
-
|
|
54
|
+
append(ch);
|
|
47
55
|
i++;
|
|
48
56
|
}
|
|
49
57
|
}
|
|
50
58
|
return result.trim();
|
|
51
59
|
}
|
|
52
60
|
export function minifyCSS(code) {
|
|
61
|
+
if (!CSS_MINIFY_CANDIDATE_RE.test(code))
|
|
62
|
+
return code;
|
|
53
63
|
let result = "";
|
|
64
|
+
let last = "";
|
|
54
65
|
let i = 0;
|
|
55
66
|
const parenStack = [];
|
|
56
67
|
const len = code.length;
|
|
68
|
+
const append = (value) => {
|
|
69
|
+
result += value;
|
|
70
|
+
last = value;
|
|
71
|
+
};
|
|
57
72
|
while (i < len) {
|
|
58
73
|
const ch = code[i];
|
|
59
74
|
if (ch === "'" || ch === '"') {
|
|
60
75
|
const quote = ch;
|
|
61
|
-
|
|
76
|
+
append(ch);
|
|
62
77
|
i++;
|
|
63
78
|
while (i < len && code[i] !== quote) {
|
|
64
79
|
if (code[i] === "\\")
|
|
65
|
-
|
|
66
|
-
|
|
80
|
+
append(code[i++]);
|
|
81
|
+
append(code[i++]);
|
|
67
82
|
}
|
|
68
83
|
if (i < len)
|
|
69
|
-
|
|
84
|
+
append(code[i++]);
|
|
70
85
|
} else if (ch === "/" && code[i + 1] === "*") {
|
|
71
86
|
i += 2;
|
|
72
87
|
while (i < len && !(code[i] === "*" && code[i + 1] === "/"))
|
|
73
88
|
i++;
|
|
74
89
|
i += 2;
|
|
75
90
|
} else if (ch === "(") {
|
|
76
|
-
parenStack.push(isSelectorFunctionParen(
|
|
77
|
-
|
|
91
|
+
parenStack.push(isSelectorFunctionParen(code, i));
|
|
92
|
+
append(ch);
|
|
78
93
|
i++;
|
|
79
94
|
} else if (ch === ")") {
|
|
80
95
|
parenStack.pop();
|
|
81
|
-
|
|
96
|
+
append(ch);
|
|
82
97
|
i++;
|
|
83
98
|
} else if (ch === " " || ch === " " || ch === "\n" || ch === "\r") {
|
|
84
99
|
while (i < len && (code[i] === " " || code[i] === " " || code[i] === "\n" || code[i] === "\r"))
|
|
85
100
|
i++;
|
|
86
|
-
const prev = result.at(-1);
|
|
87
101
|
const next = code[i];
|
|
88
102
|
if (next === "!")
|
|
89
103
|
continue;
|
|
90
104
|
if (parenStack.length > 0) {
|
|
91
105
|
const isPunct = parenStack[parenStack.length - 1] ? isCSSPunctuation : isCSSCalcPunctuation;
|
|
92
|
-
if (
|
|
93
|
-
|
|
94
|
-
} else if (
|
|
95
|
-
|
|
106
|
+
if (last && next && !isPunct(last) && !isPunct(next))
|
|
107
|
+
append(" ");
|
|
108
|
+
} else if (last && next && !isCSSPunctuation(last) && !isCSSPunctuation(next)) {
|
|
109
|
+
append(" ");
|
|
96
110
|
}
|
|
97
111
|
} else if (ch === ";") {
|
|
98
112
|
let j = i + 1;
|
|
@@ -101,19 +115,18 @@ export function minifyCSS(code) {
|
|
|
101
115
|
if (code[j] === "}") {
|
|
102
116
|
i++;
|
|
103
117
|
} else {
|
|
104
|
-
|
|
118
|
+
append(ch);
|
|
105
119
|
i++;
|
|
106
120
|
}
|
|
107
121
|
} else if (ch === "0" && code[i + 1] === "." && (code[i + 2] ?? "") >= "0" && (code[i + 2] ?? "") <= "9") {
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
result += ch;
|
|
122
|
+
if (last && last >= "0" && last <= "9") {
|
|
123
|
+
append(ch);
|
|
111
124
|
i++;
|
|
112
125
|
} else {
|
|
113
126
|
i++;
|
|
114
127
|
}
|
|
115
128
|
} else {
|
|
116
|
-
|
|
129
|
+
append(ch);
|
|
117
130
|
i++;
|
|
118
131
|
}
|
|
119
132
|
}
|
|
@@ -134,13 +147,13 @@ function isCSSCalcPunctuation(ch) {
|
|
|
134
147
|
function isCSSNameChar(ch) {
|
|
135
148
|
return ch >= "a" && ch <= "z" || ch >= "A" && ch <= "Z" || ch === "-";
|
|
136
149
|
}
|
|
137
|
-
function isSelectorFunctionParen(
|
|
138
|
-
let j =
|
|
139
|
-
while (j >= 0 && isCSSNameChar(
|
|
150
|
+
function isSelectorFunctionParen(code, parenIndex) {
|
|
151
|
+
let j = parenIndex - 1;
|
|
152
|
+
while (j >= 0 && isCSSNameChar(code[j]))
|
|
140
153
|
j--;
|
|
141
|
-
if (
|
|
154
|
+
if (code[j] !== ":")
|
|
142
155
|
return false;
|
|
143
|
-
const name =
|
|
156
|
+
const name = code.slice(j + 1, parenIndex).toLowerCase();
|
|
144
157
|
return name === "is" || name === "where" || name === "not" || name === "has" || name === "matches" || name === "host" || name === "host-context" || name === "slotted";
|
|
145
158
|
}
|
|
146
159
|
export function minifyJSON(code) {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nuxt-seo-utils",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "8.4.
|
|
4
|
+
"version": "8.4.1",
|
|
5
5
|
"description": "SEO utilities to improve your Nuxt sites discoverability and shareability",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"funding": "https://github.com/sponsors/harlan-zw",
|
|
@@ -62,15 +62,15 @@
|
|
|
62
62
|
}
|
|
63
63
|
},
|
|
64
64
|
"dependencies": {
|
|
65
|
-
"@nuxt/kit": "^4.5.
|
|
65
|
+
"@nuxt/kit": "^4.5.2",
|
|
66
66
|
"citty": "^0.2.2",
|
|
67
67
|
"consola": "^3.4.2",
|
|
68
68
|
"defu": "^6.1.7",
|
|
69
69
|
"escape-string-regexp": "^5.0.0",
|
|
70
70
|
"exsolve": "^1.1.1",
|
|
71
71
|
"image-size": "^2.0.2",
|
|
72
|
-
"nuxt-site-config": "^4.1
|
|
73
|
-
"nuxtseo-shared": "^5.3.
|
|
72
|
+
"nuxt-site-config": "^4.2.1",
|
|
73
|
+
"nuxtseo-shared": "^5.3.12",
|
|
74
74
|
"pathe": "^2.0.3",
|
|
75
75
|
"pkg-types": "^2.3.1",
|
|
76
76
|
"scule": "^1.3.0",
|
|
@@ -81,36 +81,36 @@
|
|
|
81
81
|
"sharp": "^0.35.3"
|
|
82
82
|
},
|
|
83
83
|
"devDependencies": {
|
|
84
|
-
"@antfu/eslint-config": "^9.
|
|
84
|
+
"@antfu/eslint-config": "^9.3.0",
|
|
85
85
|
"@nuxt/devtools-kit": "4.0.0-alpha.9",
|
|
86
86
|
"@nuxt/module-builder": "^1.0.3",
|
|
87
|
-
"@nuxt/schema": "^4.5.
|
|
87
|
+
"@nuxt/schema": "^4.5.2",
|
|
88
88
|
"@nuxt/test-utils": "^4.1.0",
|
|
89
89
|
"@nuxt/ui": "^4.10.0",
|
|
90
|
-
"@nuxtjs/i18n": "^10.
|
|
91
|
-
"@types/node": "^26.
|
|
90
|
+
"@nuxtjs/i18n": "^10.6.0",
|
|
91
|
+
"@types/node": "^26.2.0",
|
|
92
92
|
"@unhead/vue": "3.2.3",
|
|
93
93
|
"@vue/test-utils": "^2.4.11",
|
|
94
|
-
"bumpp": "^12.
|
|
94
|
+
"bumpp": "^12.2.0",
|
|
95
95
|
"case-police": "^2.2.1",
|
|
96
96
|
"cheerio": "^1.2.0",
|
|
97
|
-
"eslint": "^10.8.
|
|
97
|
+
"eslint": "^10.8.1",
|
|
98
98
|
"eslint-plugin-harlanzw": "^0.17.1",
|
|
99
|
-
"happy-dom": "^20.11.
|
|
100
|
-
"lint-staged": "^17.
|
|
99
|
+
"happy-dom": "^20.11.2",
|
|
100
|
+
"lint-staged": "^17.3.0",
|
|
101
101
|
"markdownlint-cli": "^0.49.1",
|
|
102
|
-
"nuxt": "^4.5.
|
|
102
|
+
"nuxt": "^4.5.2",
|
|
103
103
|
"nuxt-security": "^2.6.0",
|
|
104
|
-
"nuxtseo-layer-devtools": "^5.3.
|
|
105
|
-
"playwright-core": "^1.62.
|
|
104
|
+
"nuxtseo-layer-devtools": "^5.3.12",
|
|
105
|
+
"playwright-core": "^1.62.1",
|
|
106
106
|
"sass": "^1.102.0",
|
|
107
107
|
"typescript": "6.0.3",
|
|
108
108
|
"ultrahtml": "^1.7.0",
|
|
109
109
|
"unbuild": "^3.6.1",
|
|
110
110
|
"unhead": "3.2.3",
|
|
111
111
|
"vitest": "^4.1.10",
|
|
112
|
-
"vue": "^3.5.
|
|
113
|
-
"vue-tsc": "^3.3.
|
|
112
|
+
"vue": "^3.5.41",
|
|
113
|
+
"vue-tsc": "^3.3.9"
|
|
114
114
|
},
|
|
115
115
|
"scripts": {
|
|
116
116
|
"client:build": "node -e \"require('fs').cpSync('devtools','dist/devtools',{recursive:true})\"",
|