single-file-core 1.0.17 → 1.0.18
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/package.json +1 -1
- package/single-file-core.js +27 -25
package/package.json
CHANGED
package/single-file-core.js
CHANGED
|
@@ -1620,33 +1620,35 @@ class ProcessorHelper {
|
|
|
1620
1620
|
const imports = getImportFunctions(stylesheet);
|
|
1621
1621
|
await Promise.all(imports.map(async node => {
|
|
1622
1622
|
const urlNode = cssTree.find(node, node => node.type == "Url") || cssTree.find(node, node => node.type == "String");
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
if (testValidURL(resourceURL) && !importedStyleSheets.has(resourceURL)) {
|
|
1632
|
-
const content = await getStylesheetContent(resourceURL);
|
|
1633
|
-
resourceURL = content.resourceURL;
|
|
1634
|
-
content.data = getUpdatedResourceContent(resourceURL, content, options);
|
|
1635
|
-
if (content.data && content.data.match(/^<!doctype /i)) {
|
|
1636
|
-
content.data = "";
|
|
1637
|
-
}
|
|
1638
|
-
const mediaQueryListNode = cssTree.find(node, node => node.type == "MediaQueryList");
|
|
1639
|
-
if (mediaQueryListNode) {
|
|
1640
|
-
content.data = wrapMediaQuery(content.data, cssTree.generate(mediaQueryListNode));
|
|
1623
|
+
if (urlNode) {
|
|
1624
|
+
let resourceURL = normalizeURL(urlNode.value);
|
|
1625
|
+
if (!testIgnoredPath(resourceURL) && testValidPath(resourceURL)) {
|
|
1626
|
+
urlNode.value = util.EMPTY_RESOURCE;
|
|
1627
|
+
try {
|
|
1628
|
+
resourceURL = util.resolveURL(resourceURL, baseURI);
|
|
1629
|
+
} catch (error) {
|
|
1630
|
+
// ignored
|
|
1641
1631
|
}
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
1632
|
+
if (testValidURL(resourceURL) && !importedStyleSheets.has(resourceURL)) {
|
|
1633
|
+
const content = await getStylesheetContent(resourceURL);
|
|
1634
|
+
resourceURL = content.resourceURL;
|
|
1635
|
+
content.data = getUpdatedResourceContent(resourceURL, content, options);
|
|
1636
|
+
if (content.data && content.data.match(/^<!doctype /i)) {
|
|
1637
|
+
content.data = "";
|
|
1638
|
+
}
|
|
1639
|
+
const mediaQueryListNode = cssTree.find(node, node => node.type == "MediaQueryList");
|
|
1640
|
+
if (mediaQueryListNode) {
|
|
1641
|
+
content.data = wrapMediaQuery(content.data, cssTree.generate(mediaQueryListNode));
|
|
1642
|
+
}
|
|
1643
|
+
const importedStylesheet = cssTree.parse(content.data, { context: "stylesheet", parseCustomProperty: true });
|
|
1644
|
+
const ancestorStyleSheets = new Set(importedStyleSheets);
|
|
1645
|
+
ancestorStyleSheets.add(resourceURL);
|
|
1646
|
+
await ProcessorHelper.resolveImportURLs(importedStylesheet, resourceURL, options, workStylesheet, ancestorStyleSheets);
|
|
1647
|
+
for (let keyName of Object.keys(importedStylesheet)) {
|
|
1648
|
+
node[keyName] = importedStylesheet[keyName];
|
|
1649
|
+
}
|
|
1650
|
+
importFound = true;
|
|
1648
1651
|
}
|
|
1649
|
-
importFound = true;
|
|
1650
1652
|
}
|
|
1651
1653
|
}
|
|
1652
1654
|
}));
|