You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Extracts `makeEvasiveTransformVisitor ` from `transformAst` and exports it via a new `./visitor.js` subpath.
`transformAst` is reimplemented as a thin wrapper that calls `makeEvasiveTransformVisitor ` and traverses — no logic change, just inversion of control.
Additional tidy-ups in the same diff:
- `SourceType` now includes `commonjs`, and `parseAst` passes `allowReturnOutsideFunction: true` for that source type (which it does by default, if we didn't have it being set for `script` as well)
- `SourceMapOption` type removed; its usages are replaced with `object | string` (actual referenced type does not exist)
- Inline `import()` type references in JSDoc replaced with `@import` declarations at the top of each file.
- `stripInternal: true` added to `tsconfig.json` so `@internal` items are excluded from generated `.d.ts` output.
- `@types/babel__generator` and `@types/babel__traverse` (prod) added as dependencies (they were missing)
Copy file name to clipboardExpand all lines: packages/evasive-transform/src/index.js
+2-3Lines changed: 2 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -6,7 +6,6 @@
6
6
7
7
/**
8
8
* @import {TransformedResult, TransformedResultWithSourceMap} from './generate.js'
9
-
* @import {SourceMapOption} from './generate.js'
10
9
*/
11
10
12
11
import{transformAst}from'./transform-ast.js';
@@ -17,13 +16,13 @@ import { generate } from './generate.js';
17
16
* Options for {@link evadeCensorSync}
18
17
*
19
18
* @typedef EvadeCensorOptions
20
-
* @property {SourceMapOption | undefined} [sourceMap] - Original source map in JSON string or object form
19
+
* @property {object | string | undefined} [sourceMap] - Original source map in JSON string or object form
21
20
* @property {string | undefined} [sourceUrl] - URL or filepath of the original source in `code`
22
21
* @property {boolean | undefined} [elideComments] - Empties the comments but preserves interior newlines.
23
22
* @property {import('./parse-ast.js').SourceType | undefined} [sourceType] - Module source type
24
23
* @property {boolean | undefined} [onlyComments] - if true, will limit transformation to
25
24
comment contents, preserving code positions within each line
26
-
* @property {(path: import('@babel/traverse').NodePath) => void} [customVisitor] - A visitor function to be called on each node, in addition to the standard transforms. Receives the same path argument as a normal Babel visitor.
25
+
* @property {(path: import('@babel/traverse').NodePath) => void} [customVisitor] - A visitor function to be called on each node, in addition to the standard transforms. Receives the same path argument as a normal Babel visitor.
* @property {(path: import('@babel/traverse').NodePath) => void} [customVisitor] - A visitor function to be called on each node, in addition to the standard transforms. Receives the same path argument as a normal Babel visitor.
37
+
* @property {(path: NodePath) => void} [customVisitor] - A visitor function to be called on each node, in addition to the standard transforms. Receives the same path argument as a normal Babel visitor.
41
38
*/
42
39
43
40
/**
44
-
* Performs transformations on the given AST
45
-
*
46
-
* This function mutates `ast`.
41
+
* Factory for a Babel {@link Visitor} which performs evasive transformations on the AST.
47
42
*
48
-
* @internal
49
-
* @param {import('@babel/types').File} ast - AST, as generated by Babel
Copy file name to clipboardExpand all lines: packages/evasive-transform/src/transform-code.js
+28-19Lines changed: 28 additions & 19 deletions
Original file line number
Diff line number
Diff line change
@@ -1,3 +1,8 @@
1
+
/**
2
+
* @import {BinaryExpression, Expression, Node, TemplateElement} from '@babel/types'
3
+
* @import {NodePath} from '@babel/traverse'
4
+
*/
5
+
1
6
constevadeRegexp=/import\s*\(|<!--|-->/g;
2
7
// The replacement collection for regexp patterns matching the evadeRegexp is only applied to the first matched character, so it is necessary for the regexpReplacements to be maintained together with the evadeRegexp.
3
8
constregexpReplacements={
@@ -11,8 +16,8 @@ const regexpReplacements = {
11
16
* to sever references), updating the target's end position as if it had zero
0 commit comments