fetch-css 4.0.8 → 4.0.10
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/index.js +13 -4
- package/package.json +9 -9
package/index.js
CHANGED
|
@@ -5,10 +5,10 @@ import {parseFragment} from "parse5";
|
|
|
5
5
|
import unzipper from "unzipper";
|
|
6
6
|
import urlToolkit from "url-toolkit";
|
|
7
7
|
import crxToZip from "./crx-to-zip.js";
|
|
8
|
-
import
|
|
8
|
+
import {fetch as undiciFetch} from "undici";
|
|
9
9
|
import fetchEnhanced from "fetch-enhanced";
|
|
10
10
|
|
|
11
|
-
const fetch = fetchEnhanced(
|
|
11
|
+
const fetch = fetchEnhanced(undiciFetch, {undici: true});
|
|
12
12
|
const clone = cloner();
|
|
13
13
|
|
|
14
14
|
async function extract(res) {
|
|
@@ -63,6 +63,15 @@ function isValidCSS(string) {
|
|
|
63
63
|
return false;
|
|
64
64
|
}
|
|
65
65
|
|
|
66
|
+
function arrayBufferToBufferCycle(ab) {
|
|
67
|
+
const buffer = new Buffer(ab.byteLength);
|
|
68
|
+
const view = new Uint8Array(ab);
|
|
69
|
+
for (let i = 0; i < buffer.length; ++i) {
|
|
70
|
+
buffer[i] = view[i];
|
|
71
|
+
}
|
|
72
|
+
return buffer;
|
|
73
|
+
}
|
|
74
|
+
|
|
66
75
|
function extractCssFromJs(js) {
|
|
67
76
|
let css = "";
|
|
68
77
|
|
|
@@ -71,7 +80,7 @@ function extractCssFromJs(js) {
|
|
|
71
80
|
onToken: token => {
|
|
72
81
|
if (token.type.label === "string") {
|
|
73
82
|
const str = token.value.trim()
|
|
74
|
-
.replace(/\n/
|
|
83
|
+
.replace(/\n/g, "")
|
|
75
84
|
.replace(/^\);}/, ""); // this is probably not universal to webpack's css-in-js strings
|
|
76
85
|
|
|
77
86
|
if (str.length > 25 && isValidCSS(str)) { // hackish treshold to ignore short strings that may be valid CSS,
|
|
@@ -100,7 +109,7 @@ async function extensionCss({crx, contentScriptsOnly, strict}) {
|
|
|
100
109
|
const res = await fetch(url);
|
|
101
110
|
validateStatus(res, url, strict);
|
|
102
111
|
|
|
103
|
-
const crxBuffer = await res.
|
|
112
|
+
const crxBuffer = arrayBufferToBufferCycle(await res.arrayBuffer());
|
|
104
113
|
const zipBuffer = Buffer.from(crxToZip(crxBuffer));
|
|
105
114
|
|
|
106
115
|
const files = {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fetch-css",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.10",
|
|
4
4
|
"description": "Extract CSS from websites and browser extensions",
|
|
5
5
|
"author": "silverwind",
|
|
6
6
|
"repository": "silverwind/fetch-css",
|
|
@@ -22,20 +22,20 @@
|
|
|
22
22
|
"crx-to-zip.js"
|
|
23
23
|
],
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"acorn": "8.8.
|
|
25
|
+
"acorn": "8.8.2",
|
|
26
26
|
"crypto-js": "4.1.1",
|
|
27
|
-
"fetch-enhanced": "11.1.
|
|
28
|
-
"node-fetch": "3.3.0",
|
|
27
|
+
"fetch-enhanced": "11.1.1",
|
|
29
28
|
"parse5": "7.1.2",
|
|
30
|
-
"postcss": "8.4.
|
|
29
|
+
"postcss": "8.4.23",
|
|
31
30
|
"rfdc": "1.3.0",
|
|
31
|
+
"undici": "5.22.0",
|
|
32
32
|
"unzipper": "0.10.11",
|
|
33
33
|
"url-toolkit": "2.2.5"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
|
-
"eslint": "8.
|
|
37
|
-
"eslint-config-silverwind": "
|
|
38
|
-
"updates": "
|
|
39
|
-
"versions": "
|
|
36
|
+
"eslint": "8.40.0",
|
|
37
|
+
"eslint-config-silverwind": "69.0.2",
|
|
38
|
+
"updates": "14.1.0",
|
|
39
|
+
"versions": "11.0.0"
|
|
40
40
|
}
|
|
41
41
|
}
|