ipx 2.0.1 → 2.0.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/cli.cjs +2 -2
- package/dist/cli.mjs +2 -2
- package/dist/index.cjs +1 -1
- package/dist/index.mjs +1 -1
- package/dist/shared/{ipx.4d79c6c9.mjs → ipx.8dfec2f9.mjs} +4 -5
- package/dist/shared/{ipx.ebaf2d0c.cjs → ipx.cf456174.cjs} +4 -5
- package/package.json +2 -2
- package/dist/chunks/svgo-xss.cjs +0 -116
- package/dist/chunks/svgo-xss.mjs +0 -114
package/dist/cli.cjs
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
const listhen = require('listhen');
|
|
4
4
|
const citty = require('citty');
|
|
5
5
|
const cli = require('listhen/cli');
|
|
6
|
-
const nodeFs = require('./shared/ipx.
|
|
6
|
+
const nodeFs = require('./shared/ipx.cf456174.cjs');
|
|
7
7
|
require('defu');
|
|
8
8
|
require('ufo');
|
|
9
9
|
require('h3');
|
|
@@ -15,7 +15,7 @@ require('ofetch');
|
|
|
15
15
|
require('pathe');
|
|
16
16
|
|
|
17
17
|
const name = "ipx";
|
|
18
|
-
const version = "2.0.
|
|
18
|
+
const version = "2.0.2";
|
|
19
19
|
const description = "High performance, secure and easy-to-use image optimizer.";
|
|
20
20
|
|
|
21
21
|
const serve = citty.defineCommand({
|
package/dist/cli.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { listen } from 'listhen';
|
|
2
2
|
import { defineCommand, runMain } from 'citty';
|
|
3
3
|
import { getArgs, parseArgs } from 'listhen/cli';
|
|
4
|
-
import { c as createIPX, g as ipxFSStorage, i as ipxHttpStorage, e as createIPXNodeServer } from './shared/ipx.
|
|
4
|
+
import { c as createIPX, g as ipxFSStorage, i as ipxHttpStorage, e as createIPXNodeServer } from './shared/ipx.8dfec2f9.mjs';
|
|
5
5
|
import 'defu';
|
|
6
6
|
import 'ufo';
|
|
7
7
|
import 'h3';
|
|
@@ -13,7 +13,7 @@ import 'ofetch';
|
|
|
13
13
|
import 'pathe';
|
|
14
14
|
|
|
15
15
|
const name = "ipx";
|
|
16
|
-
const version = "2.0.
|
|
16
|
+
const version = "2.0.2";
|
|
17
17
|
const description = "High performance, secure and easy-to-use image optimizer.";
|
|
18
18
|
|
|
19
19
|
const serve = defineCommand({
|
package/dist/index.cjs
CHANGED
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { c as createIPX, b as createIPXH3App, a as createIPXH3Handler, e as createIPXNodeServer, f as createIPXPlainServer, d as createIPXWebServer, g as ipxFSStorage, i as ipxHttpStorage } from './shared/ipx.
|
|
1
|
+
export { c as createIPX, b as createIPXH3App, a as createIPXH3Handler, e as createIPXNodeServer, f as createIPXPlainServer, d as createIPXWebServer, g as ipxFSStorage, i as ipxHttpStorage } from './shared/ipx.8dfec2f9.mjs';
|
|
2
2
|
import 'defu';
|
|
3
3
|
import 'ufo';
|
|
4
4
|
import 'h3';
|
|
@@ -333,8 +333,7 @@ function createIPX(userOptions) {
|
|
|
333
333
|
});
|
|
334
334
|
const getSVGO = cachedPromise(async () => {
|
|
335
335
|
const { optimize } = await import('svgo');
|
|
336
|
-
|
|
337
|
-
return { optimize, xss };
|
|
336
|
+
return { optimize };
|
|
338
337
|
});
|
|
339
338
|
return function ipx(id, modifiers = {}, opts = {}) {
|
|
340
339
|
if (!id) {
|
|
@@ -409,10 +408,10 @@ function createIPX(userOptions) {
|
|
|
409
408
|
meta: imageMeta$1
|
|
410
409
|
};
|
|
411
410
|
} else {
|
|
412
|
-
const { optimize
|
|
411
|
+
const { optimize } = await getSVGO();
|
|
413
412
|
const svg = optimize(sourceData.toString("utf8"), {
|
|
414
413
|
...options.svgo,
|
|
415
|
-
plugins: [
|
|
414
|
+
plugins: ["removeScriptElement", ...options.svgo?.plugins || []]
|
|
416
415
|
}).data;
|
|
417
416
|
return {
|
|
418
417
|
data: svg,
|
|
@@ -598,7 +597,7 @@ function safeString(input) {
|
|
|
598
597
|
|
|
599
598
|
const HTTP_RE = /^https?:\/\//;
|
|
600
599
|
function ipxHttpStorage(_options = {}) {
|
|
601
|
-
const allowAllDomains = getEnv("IPX_HTTP_ALLOW_ALL_DOMAINS") ?? false;
|
|
600
|
+
const allowAllDomains = _options.allowAllDomains ?? getEnv("IPX_HTTP_ALLOW_ALL_DOMAINS") ?? false;
|
|
602
601
|
let _domains = _options.domains || getEnv("IPX_HTTP_DOMAINS") || [];
|
|
603
602
|
const defaultMaxAge = _options.maxAge || getEnv("IPX_HTTP_MAX_AGE");
|
|
604
603
|
const fetchOptions = _options.fetchOptions || getEnv("IPX_HTTP_FETCH_OPTIONS") || {};
|
|
@@ -340,8 +340,7 @@ function createIPX(userOptions) {
|
|
|
340
340
|
});
|
|
341
341
|
const getSVGO = cachedPromise(async () => {
|
|
342
342
|
const { optimize } = await import('svgo');
|
|
343
|
-
|
|
344
|
-
return { optimize, xss };
|
|
343
|
+
return { optimize };
|
|
345
344
|
});
|
|
346
345
|
return function ipx(id, modifiers = {}, opts = {}) {
|
|
347
346
|
if (!id) {
|
|
@@ -416,10 +415,10 @@ function createIPX(userOptions) {
|
|
|
416
415
|
meta: imageMeta$1
|
|
417
416
|
};
|
|
418
417
|
} else {
|
|
419
|
-
const { optimize
|
|
418
|
+
const { optimize } = await getSVGO();
|
|
420
419
|
const svg = optimize(sourceData.toString("utf8"), {
|
|
421
420
|
...options.svgo,
|
|
422
|
-
plugins: [
|
|
421
|
+
plugins: ["removeScriptElement", ...options.svgo?.plugins || []]
|
|
423
422
|
}).data;
|
|
424
423
|
return {
|
|
425
424
|
data: svg,
|
|
@@ -605,7 +604,7 @@ function safeString(input) {
|
|
|
605
604
|
|
|
606
605
|
const HTTP_RE = /^https?:\/\//;
|
|
607
606
|
function ipxHttpStorage(_options = {}) {
|
|
608
|
-
const allowAllDomains = getEnv("IPX_HTTP_ALLOW_ALL_DOMAINS") ?? false;
|
|
607
|
+
const allowAllDomains = _options.allowAllDomains ?? getEnv("IPX_HTTP_ALLOW_ALL_DOMAINS") ?? false;
|
|
609
608
|
let _domains = _options.domains || getEnv("IPX_HTTP_DOMAINS") || [];
|
|
610
609
|
const defaultMaxAge = _options.maxAge || getEnv("IPX_HTTP_MAX_AGE");
|
|
611
610
|
const fetchOptions = _options.fetchOptions || getEnv("IPX_HTTP_FETCH_OPTIONS") || {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ipx",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.2",
|
|
4
4
|
"repository": "unjs/ipx",
|
|
5
5
|
"description": "High performance, secure and easy-to-use image optimizer.",
|
|
6
6
|
"license": "MIT",
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
"ofetch": "^1.3.3",
|
|
50
50
|
"pathe": "^1.1.1",
|
|
51
51
|
"sharp": "^0.32.6",
|
|
52
|
-
"svgo": "^3.0.
|
|
52
|
+
"svgo": "^3.0.3",
|
|
53
53
|
"ufo": "^1.3.1",
|
|
54
54
|
"unstorage": "^1.9.0",
|
|
55
55
|
"xss": "^1.0.14"
|
package/dist/chunks/svgo-xss.cjs
DELETED
|
@@ -1,116 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const xss = {
|
|
4
|
-
name: "removeXSS",
|
|
5
|
-
fn() {
|
|
6
|
-
return {
|
|
7
|
-
element: {
|
|
8
|
-
enter: (node, parentNode) => {
|
|
9
|
-
if (node.name === "script") {
|
|
10
|
-
parentNode.children = parentNode.children.filter(
|
|
11
|
-
(child) => child !== node
|
|
12
|
-
);
|
|
13
|
-
return;
|
|
14
|
-
}
|
|
15
|
-
for (const event of ALL_EVENTS) {
|
|
16
|
-
if (node.attributes[event] != null) {
|
|
17
|
-
delete node.attributes[event];
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
},
|
|
21
|
-
exit: (node, parentNode) => {
|
|
22
|
-
if (node.name !== "a") {
|
|
23
|
-
return;
|
|
24
|
-
}
|
|
25
|
-
for (const attr of Object.keys(node.attributes)) {
|
|
26
|
-
if (attr === "href" || attr.endsWith(":href")) {
|
|
27
|
-
if (node.attributes[attr] == null || !node.attributes[attr].trimStart().startsWith("javascript:")) {
|
|
28
|
-
continue;
|
|
29
|
-
}
|
|
30
|
-
const index = parentNode.children.indexOf(node);
|
|
31
|
-
parentNode.children.splice(index, 1, ...node.children);
|
|
32
|
-
for (const child of node.children) {
|
|
33
|
-
Object.defineProperty(child, "parentNode", {
|
|
34
|
-
writable: true,
|
|
35
|
-
value: parentNode
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
|
-
};
|
|
45
|
-
const ALL_EVENTS = [
|
|
46
|
-
"onabort",
|
|
47
|
-
"onactivate",
|
|
48
|
-
"onbegin",
|
|
49
|
-
"oncancel",
|
|
50
|
-
"oncanplay",
|
|
51
|
-
"oncanplaythrough",
|
|
52
|
-
"onchange",
|
|
53
|
-
"onclick",
|
|
54
|
-
"onclose",
|
|
55
|
-
"oncopy",
|
|
56
|
-
"oncuechange",
|
|
57
|
-
"oncut",
|
|
58
|
-
"ondblclick",
|
|
59
|
-
"ondrag",
|
|
60
|
-
"ondragend",
|
|
61
|
-
"ondragenter",
|
|
62
|
-
"ondragleave",
|
|
63
|
-
"ondragover",
|
|
64
|
-
"ondragstart",
|
|
65
|
-
"ondrop",
|
|
66
|
-
"ondurationchange",
|
|
67
|
-
"onemptied",
|
|
68
|
-
"onend",
|
|
69
|
-
"onended",
|
|
70
|
-
"onerror",
|
|
71
|
-
"onfocus",
|
|
72
|
-
"onfocusin",
|
|
73
|
-
"onfocusout",
|
|
74
|
-
"oninput",
|
|
75
|
-
"oninvalid",
|
|
76
|
-
"onkeydown",
|
|
77
|
-
"onkeypress",
|
|
78
|
-
"onkeyup",
|
|
79
|
-
"onload",
|
|
80
|
-
"onloadeddata",
|
|
81
|
-
"onloadedmetadata",
|
|
82
|
-
"onloadstart",
|
|
83
|
-
"onmousedown",
|
|
84
|
-
"onmouseenter",
|
|
85
|
-
"onmouseleave",
|
|
86
|
-
"onmousemove",
|
|
87
|
-
"onmouseout",
|
|
88
|
-
"onmouseover",
|
|
89
|
-
"onmouseup",
|
|
90
|
-
"onmousewheel",
|
|
91
|
-
"onpaste",
|
|
92
|
-
"onpause",
|
|
93
|
-
"onplay",
|
|
94
|
-
"onplaying",
|
|
95
|
-
"onprogress",
|
|
96
|
-
"onratechange",
|
|
97
|
-
"onrepeat",
|
|
98
|
-
"onreset",
|
|
99
|
-
"onresize",
|
|
100
|
-
"onscroll",
|
|
101
|
-
"onseeked",
|
|
102
|
-
"onseeking",
|
|
103
|
-
"onselect",
|
|
104
|
-
"onshow",
|
|
105
|
-
"onstalled",
|
|
106
|
-
"onsubmit",
|
|
107
|
-
"onsuspend",
|
|
108
|
-
"ontimeupdate",
|
|
109
|
-
"ontoggle",
|
|
110
|
-
"onunload",
|
|
111
|
-
"onvolumechange",
|
|
112
|
-
"onwaiting",
|
|
113
|
-
"onzoom"
|
|
114
|
-
];
|
|
115
|
-
|
|
116
|
-
exports.xss = xss;
|
package/dist/chunks/svgo-xss.mjs
DELETED
|
@@ -1,114 +0,0 @@
|
|
|
1
|
-
const xss = {
|
|
2
|
-
name: "removeXSS",
|
|
3
|
-
fn() {
|
|
4
|
-
return {
|
|
5
|
-
element: {
|
|
6
|
-
enter: (node, parentNode) => {
|
|
7
|
-
if (node.name === "script") {
|
|
8
|
-
parentNode.children = parentNode.children.filter(
|
|
9
|
-
(child) => child !== node
|
|
10
|
-
);
|
|
11
|
-
return;
|
|
12
|
-
}
|
|
13
|
-
for (const event of ALL_EVENTS) {
|
|
14
|
-
if (node.attributes[event] != null) {
|
|
15
|
-
delete node.attributes[event];
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
},
|
|
19
|
-
exit: (node, parentNode) => {
|
|
20
|
-
if (node.name !== "a") {
|
|
21
|
-
return;
|
|
22
|
-
}
|
|
23
|
-
for (const attr of Object.keys(node.attributes)) {
|
|
24
|
-
if (attr === "href" || attr.endsWith(":href")) {
|
|
25
|
-
if (node.attributes[attr] == null || !node.attributes[attr].trimStart().startsWith("javascript:")) {
|
|
26
|
-
continue;
|
|
27
|
-
}
|
|
28
|
-
const index = parentNode.children.indexOf(node);
|
|
29
|
-
parentNode.children.splice(index, 1, ...node.children);
|
|
30
|
-
for (const child of node.children) {
|
|
31
|
-
Object.defineProperty(child, "parentNode", {
|
|
32
|
-
writable: true,
|
|
33
|
-
value: parentNode
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
};
|
|
41
|
-
}
|
|
42
|
-
};
|
|
43
|
-
const ALL_EVENTS = [
|
|
44
|
-
"onabort",
|
|
45
|
-
"onactivate",
|
|
46
|
-
"onbegin",
|
|
47
|
-
"oncancel",
|
|
48
|
-
"oncanplay",
|
|
49
|
-
"oncanplaythrough",
|
|
50
|
-
"onchange",
|
|
51
|
-
"onclick",
|
|
52
|
-
"onclose",
|
|
53
|
-
"oncopy",
|
|
54
|
-
"oncuechange",
|
|
55
|
-
"oncut",
|
|
56
|
-
"ondblclick",
|
|
57
|
-
"ondrag",
|
|
58
|
-
"ondragend",
|
|
59
|
-
"ondragenter",
|
|
60
|
-
"ondragleave",
|
|
61
|
-
"ondragover",
|
|
62
|
-
"ondragstart",
|
|
63
|
-
"ondrop",
|
|
64
|
-
"ondurationchange",
|
|
65
|
-
"onemptied",
|
|
66
|
-
"onend",
|
|
67
|
-
"onended",
|
|
68
|
-
"onerror",
|
|
69
|
-
"onfocus",
|
|
70
|
-
"onfocusin",
|
|
71
|
-
"onfocusout",
|
|
72
|
-
"oninput",
|
|
73
|
-
"oninvalid",
|
|
74
|
-
"onkeydown",
|
|
75
|
-
"onkeypress",
|
|
76
|
-
"onkeyup",
|
|
77
|
-
"onload",
|
|
78
|
-
"onloadeddata",
|
|
79
|
-
"onloadedmetadata",
|
|
80
|
-
"onloadstart",
|
|
81
|
-
"onmousedown",
|
|
82
|
-
"onmouseenter",
|
|
83
|
-
"onmouseleave",
|
|
84
|
-
"onmousemove",
|
|
85
|
-
"onmouseout",
|
|
86
|
-
"onmouseover",
|
|
87
|
-
"onmouseup",
|
|
88
|
-
"onmousewheel",
|
|
89
|
-
"onpaste",
|
|
90
|
-
"onpause",
|
|
91
|
-
"onplay",
|
|
92
|
-
"onplaying",
|
|
93
|
-
"onprogress",
|
|
94
|
-
"onratechange",
|
|
95
|
-
"onrepeat",
|
|
96
|
-
"onreset",
|
|
97
|
-
"onresize",
|
|
98
|
-
"onscroll",
|
|
99
|
-
"onseeked",
|
|
100
|
-
"onseeking",
|
|
101
|
-
"onselect",
|
|
102
|
-
"onshow",
|
|
103
|
-
"onstalled",
|
|
104
|
-
"onsubmit",
|
|
105
|
-
"onsuspend",
|
|
106
|
-
"ontimeupdate",
|
|
107
|
-
"ontoggle",
|
|
108
|
-
"onunload",
|
|
109
|
-
"onvolumechange",
|
|
110
|
-
"onwaiting",
|
|
111
|
-
"onzoom"
|
|
112
|
-
];
|
|
113
|
-
|
|
114
|
-
export { xss };
|