fetch-css 4.0.11 → 4.0.13

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.
Files changed (3) hide show
  1. package/README.md +1 -1
  2. package/index.js +13 -5
  3. package/package.json +10 -10
package/README.md CHANGED
@@ -22,7 +22,7 @@ const [{css}] = await fetchCss([{crx: "hlepfoohegkhhmjieoechaddaejaokhf"}]);
22
22
 
23
23
  - `sources`: *Array* Array of source objects
24
24
  - `source`: *Object*
25
- - `url`: *string* An absolute URL pointing to either a website or directly to a CSS or JS file (to extract inlined CSS strings from)
25
+ - `url`: *string* or *Array* An absolute URL pointing to either a website or directly to a CSS or JS file (to extract inlined CSS strings from)
26
26
  - `fetchOpts`: *Object* Options passed to [fetch](https://github.com/npm/make-fetch-happen#fetch)
27
27
  - `crx`: *string* A Chrome extension id
28
28
  - `contentScriptsOnly`: *boolean* Whether to pull only content scripts from a extension. Default: `false`
package/index.js CHANGED
@@ -185,16 +185,24 @@ export default async function fetchCss(sources) { // eslint-disable-line import/
185
185
  const sourceResponses = await Promise.all(sources.map(source => {
186
186
  if (!source.url) return null;
187
187
  const {pathname} = new URL(source.url);
188
- return pathname.endsWith(".css") || pathname.endsWith(".js") ? null : doFetch(source.url, source.fetchOpts);
188
+ if (pathname.endsWith(".css") || pathname.endsWith(".js")) return null;
189
+
190
+ if (Array.isArray(source.url)) {
191
+ return source.url.map(url => doFetch(url, source.fetchOpts));
192
+ } else {
193
+ return doFetch(source.url, source.fetchOpts);
194
+ }
189
195
  }));
190
196
 
191
197
  for (const [index, res] of Object.entries(sourceResponses)) {
192
198
  const source = sources[index];
193
199
  if (res) {
194
- validateStatus(res, source.url, source.strict);
195
- const [styleUrls, styleTags] = await extract(res);
196
- source.urls = styleUrls;
197
- source.styleTags = styleTags;
200
+ for (const r of Array.isArray(res) ? res : [res]) {
201
+ validateStatus(r, source.url, source.strict);
202
+ const [styleUrls, styleTags] = await extract(r);
203
+ source.urls.push(...styleUrls);
204
+ source.styleTags.push(...styleTags);
205
+ }
198
206
  } else if (source.url) {
199
207
  source.urls = [source.url];
200
208
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fetch-css",
3
- "version": "4.0.11",
3
+ "version": "4.0.13",
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.2",
25
+ "acorn": "8.10.0",
26
26
  "crypto-js": "4.1.1",
27
- "fetch-enhanced": "11.1.1",
27
+ "fetch-enhanced": "11.1.2",
28
28
  "parse5": "7.1.2",
29
- "postcss": "8.4.23",
29
+ "postcss": "8.4.25",
30
30
  "rfdc": "1.3.0",
31
- "undici": "5.22.0",
32
- "unzipper": "0.10.11",
31
+ "undici": "5.22.1",
32
+ "unzipper": "0.10.14",
33
33
  "url-toolkit": "2.2.5"
34
34
  },
35
35
  "devDependencies": {
36
- "eslint": "8.40.0",
37
- "eslint-config-silverwind": "69.0.2",
38
- "updates": "14.1.0",
39
- "versions": "11.0.0"
36
+ "eslint": "8.44.0",
37
+ "eslint-config-silverwind": "73.1.2",
38
+ "updates": "14.3.2",
39
+ "versions": "11.0.1"
40
40
  }
41
41
  }