@jsenv/ast 6.2.3 → 6.2.5
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 +3 -3
- package/src/css/postcss_plugin_url_visitor.js +1 -1
- package/src/html/html_inline_content_url.js +2 -2
- package/src/html/html_node.js +3 -3
- package/src/html/html_node_attributes.js +17 -4
- package/src/html/html_parse.js +4 -8
- package/src/inline_content_url.js +1 -1
- package/src/js/js_static_analysis/new_blob.js +2 -2
- package/src/js/js_static_analysis/new_inline_content.js +2 -2
- package/src/js/js_static_analysis/web_worker_entry_point.js +2 -2
- package/src/js/parse_js_urls.js +29 -29
- package/src/main.js +3 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jsenv/ast",
|
|
3
|
-
"version": "6.2.
|
|
3
|
+
"version": "6.2.5",
|
|
4
4
|
"description": "Parse and transform HTML, CSS and JS",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -33,8 +33,8 @@
|
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
35
|
"@babel/parser": "7.24.8",
|
|
36
|
-
"@jsenv/humanize": "1.2.
|
|
37
|
-
"@jsenv/urls": "2.3.
|
|
36
|
+
"@jsenv/humanize": "1.2.5",
|
|
37
|
+
"@jsenv/urls": "2.3.1",
|
|
38
38
|
"acorn": "8.12.1",
|
|
39
39
|
"acorn-import-attributes": "1.9.5",
|
|
40
40
|
"acorn-walk": "8.3.3",
|
|
@@ -11,8 +11,8 @@ hence sourcemap cannot point the original source location
|
|
|
11
11
|
|
|
12
12
|
*/
|
|
13
13
|
|
|
14
|
-
import { pathToFileURL } from "node:url";
|
|
15
14
|
import { createRequire } from "node:module";
|
|
15
|
+
import { pathToFileURL } from "node:url";
|
|
16
16
|
|
|
17
17
|
const require = createRequire(import.meta.url);
|
|
18
18
|
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { injectQueryParams,
|
|
1
|
+
import { injectQueryParams, urlToBasename, urlToExtension } from "@jsenv/urls";
|
|
2
2
|
|
|
3
3
|
import { generateUrlForInlineContent } from "../inline_content_url.js";
|
|
4
|
+
import { analyzeScriptNode } from "./html_analysis.js";
|
|
4
5
|
import { getHtmlNodeAttribute } from "./html_node_attributes.js";
|
|
5
6
|
import { getHtmlNodePosition } from "./html_node_position.js";
|
|
6
|
-
import { analyzeScriptNode } from "./html_analysis.js";
|
|
7
7
|
|
|
8
8
|
export const getUrlForContentInsideHtml = (node, { htmlUrl, url }) => {
|
|
9
9
|
let externalSpecifierAttributeName;
|
package/src/html/html_node.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import { parseFragment } from "parse5";
|
|
2
2
|
|
|
3
|
+
import { analyzeScriptNode } from "./html_analysis.js";
|
|
3
4
|
import {
|
|
4
5
|
getHtmlNodeAttribute,
|
|
5
6
|
setHtmlNodeAttributes,
|
|
6
7
|
} from "./html_node_attributes.js";
|
|
7
|
-
import { findHtmlNode } from "./html_search.js";
|
|
8
|
-
import { analyzeScriptNode } from "./html_analysis.js";
|
|
9
8
|
import {
|
|
9
|
+
getHtmlNodeText,
|
|
10
10
|
getIndentation,
|
|
11
11
|
increaseIndentation,
|
|
12
|
-
getHtmlNodeText,
|
|
13
12
|
setHtmlNodeText,
|
|
14
13
|
} from "./html_node_text.js";
|
|
14
|
+
import { findHtmlNode } from "./html_search.js";
|
|
15
15
|
|
|
16
16
|
export const removeHtmlNode = (htmlNode) => {
|
|
17
17
|
const { childNodes } = htmlNode.parentNode;
|
|
@@ -3,6 +3,18 @@ export const getHtmlNodeAttribute = (htmlNode, attributeName) => {
|
|
|
3
3
|
return attribute ? attribute.value || "" : undefined;
|
|
4
4
|
};
|
|
5
5
|
|
|
6
|
+
export const getHtmlNodeAttributes = (htmlNode) => {
|
|
7
|
+
const { attrs } = htmlNode;
|
|
8
|
+
if (!attrs) {
|
|
9
|
+
return {};
|
|
10
|
+
}
|
|
11
|
+
const attributes = {};
|
|
12
|
+
for (const attr of attrs) {
|
|
13
|
+
attributes[attr.name] = attr.value;
|
|
14
|
+
}
|
|
15
|
+
return attributes;
|
|
16
|
+
};
|
|
17
|
+
|
|
6
18
|
export const setHtmlNodeAttributes = (htmlNode, attributesToAssign) => {
|
|
7
19
|
if (typeof attributesToAssign !== "object") {
|
|
8
20
|
throw new TypeError(`attributesToAssign must be an object`);
|
|
@@ -35,9 +47,10 @@ export const setHtmlNodeAttributes = (htmlNode, attributesToAssign) => {
|
|
|
35
47
|
};
|
|
36
48
|
|
|
37
49
|
const getHtmlAttributeByName = (htmlNode, attributeName) => {
|
|
38
|
-
const attrs = htmlNode
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
50
|
+
const { attrs } = htmlNode;
|
|
51
|
+
if (!attrs) {
|
|
52
|
+
return null;
|
|
53
|
+
}
|
|
54
|
+
const attribute = attrs.find((attr) => attr.name === attributeName);
|
|
42
55
|
return attribute;
|
|
43
56
|
};
|
package/src/html/html_parse.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { parse, serialize, parseFragment } from "parse5";
|
|
2
1
|
import { generateContentFrame } from "@jsenv/humanize";
|
|
2
|
+
import { parse, parseFragment, serialize } from "parse5";
|
|
3
3
|
|
|
4
4
|
import { insertHtmlNodeAfter, insertHtmlNodeBefore } from "./html_node.js";
|
|
5
5
|
import {
|
|
@@ -7,17 +7,13 @@ import {
|
|
|
7
7
|
setHtmlNodeAttributes,
|
|
8
8
|
} from "./html_node_attributes.js";
|
|
9
9
|
import {
|
|
10
|
-
storeHtmlNodePosition,
|
|
11
10
|
storeHtmlNodeAttributePosition,
|
|
11
|
+
storeHtmlNodePosition,
|
|
12
12
|
} from "./html_node_position.js";
|
|
13
|
-
import { findHtmlChildNode, visitHtmlNodes } from "./html_search.js";
|
|
14
13
|
import { getHtmlNodeText } from "./html_node_text.js";
|
|
14
|
+
import { findHtmlChildNode, visitHtmlNodes } from "./html_search.js";
|
|
15
15
|
|
|
16
|
-
export const parseHtml = ({
|
|
17
|
-
html,
|
|
18
|
-
url,
|
|
19
|
-
storeOriginalPositions = true,
|
|
20
|
-
} = {}) => {
|
|
16
|
+
export const parseHtml = ({ html, url, storeOriginalPositions = true }) => {
|
|
21
17
|
const htmlAst = parse(html, {
|
|
22
18
|
sourceCodeLocationInfo: true,
|
|
23
19
|
onParseError: (parse5Error) => {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { findPropertyNodeByName, isStringLiteralNode } from "./helpers.js";
|
|
2
|
-
import { isNewUrlCall, analyzeNewUrlCall } from "./new_url.js";
|
|
3
2
|
import {
|
|
4
|
-
isImportMetaResolveCall,
|
|
5
3
|
analyzeImportMetaResolveCall,
|
|
4
|
+
isImportMetaResolveCall,
|
|
6
5
|
} from "./import_meta_resolve.js";
|
|
6
|
+
import { analyzeNewUrlCall, isNewUrlCall } from "./new_url.js";
|
|
7
7
|
|
|
8
8
|
export const isNewWorkerCall = (node) => {
|
|
9
9
|
return (
|
package/src/js/parse_js_urls.js
CHANGED
|
@@ -1,52 +1,52 @@
|
|
|
1
1
|
import { ancestor } from "acorn-walk";
|
|
2
2
|
|
|
3
|
-
import { parseJsWithAcorn } from "./parse_js_with_acorn.js";
|
|
4
3
|
import {
|
|
5
|
-
analyzeImportExpression,
|
|
6
|
-
analyzeImportDeclaration,
|
|
7
|
-
analyzeExportNamedDeclaration,
|
|
8
4
|
analyzeExportAllDeclaration,
|
|
5
|
+
analyzeExportNamedDeclaration,
|
|
6
|
+
analyzeImportDeclaration,
|
|
7
|
+
analyzeImportExpression,
|
|
9
8
|
} from "./js_static_analysis/import_export.js";
|
|
10
9
|
import {
|
|
11
|
-
isImportMetaResolveCall,
|
|
12
10
|
analyzeImportMetaResolveCall,
|
|
11
|
+
isImportMetaResolveCall,
|
|
13
12
|
} from "./js_static_analysis/import_meta_resolve.js";
|
|
14
13
|
import {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
analyzeNewSharedWorkerCall,
|
|
19
|
-
isServiceWorkerRegisterCall,
|
|
20
|
-
analyzeServiceWorkerRegisterCall,
|
|
21
|
-
} from "./js_static_analysis/web_worker_entry_point.js";
|
|
14
|
+
analyzeJSONParseCall,
|
|
15
|
+
isJSONParseCall,
|
|
16
|
+
} from "./js_static_analysis/json_parse.js";
|
|
22
17
|
import {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
} from "./js_static_analysis/
|
|
18
|
+
analyzeNewBlobCall,
|
|
19
|
+
isNewBlobCall,
|
|
20
|
+
} from "./js_static_analysis/new_blob.js";
|
|
21
|
+
import {
|
|
22
|
+
analyzeNewInlineContentCall,
|
|
23
|
+
isNewInlineContentCall,
|
|
24
|
+
} from "./js_static_analysis/new_inline_content.js";
|
|
26
25
|
import {
|
|
27
|
-
isNewUrlCall,
|
|
28
26
|
analyzeNewUrlCall,
|
|
27
|
+
isNewUrlCall,
|
|
29
28
|
} from "./js_static_analysis/new_url.js";
|
|
30
29
|
import {
|
|
31
|
-
|
|
30
|
+
analyzeSystemImportCall,
|
|
32
31
|
analyzeSystemRegisterCall,
|
|
32
|
+
analyzeSystemResolveCall,
|
|
33
33
|
isSystemImportCall,
|
|
34
|
-
|
|
34
|
+
isSystemRegisterCall,
|
|
35
35
|
isSystemResolveCall,
|
|
36
|
-
analyzeSystemResolveCall,
|
|
37
36
|
} from "./js_static_analysis/system.js";
|
|
38
37
|
import {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
} from "./js_static_analysis/
|
|
42
|
-
import {
|
|
43
|
-
isNewInlineContentCall,
|
|
44
|
-
analyzeNewInlineContentCall,
|
|
45
|
-
} from "./js_static_analysis/new_inline_content.js";
|
|
38
|
+
analyzeImportScriptCalls,
|
|
39
|
+
isImportScriptsCall,
|
|
40
|
+
} from "./js_static_analysis/web_worker.js";
|
|
46
41
|
import {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
42
|
+
analyzeNewSharedWorkerCall,
|
|
43
|
+
analyzeNewWorkerCall,
|
|
44
|
+
analyzeServiceWorkerRegisterCall,
|
|
45
|
+
isNewSharedWorkerCall,
|
|
46
|
+
isNewWorkerCall,
|
|
47
|
+
isServiceWorkerRegisterCall,
|
|
48
|
+
} from "./js_static_analysis/web_worker_entry_point.js";
|
|
49
|
+
import { parseJsWithAcorn } from "./parse_js_with_acorn.js";
|
|
50
50
|
|
|
51
51
|
export const parseJsUrls = ({
|
|
52
52
|
js,
|
package/src/main.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
// tslint:disable:ordered-imports
|
|
2
|
+
|
|
1
3
|
// html
|
|
2
4
|
export {
|
|
3
5
|
parseHtml,
|
|
@@ -15,6 +17,7 @@ export {
|
|
|
15
17
|
export { parseSrcSet, stringifySrcSet } from "./html/html_src_set.js";
|
|
16
18
|
export {
|
|
17
19
|
getHtmlNodeAttribute,
|
|
20
|
+
getHtmlNodeAttributes,
|
|
18
21
|
setHtmlNodeAttributes,
|
|
19
22
|
} from "./html/html_node_attributes.js";
|
|
20
23
|
export {
|