@tinacms/app 0.0.28 → 1.0.1
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/appFiles/node_modules/.package-lock.json +23 -23
- package/appFiles/node_modules/@babel/generator/lib/generators/base.js.map +1 -1
- package/appFiles/node_modules/@babel/generator/lib/generators/classes.js +1 -1
- package/appFiles/node_modules/@babel/generator/lib/generators/classes.js.map +1 -1
- package/appFiles/node_modules/@babel/generator/lib/generators/expressions.js +9 -15
- package/appFiles/node_modules/@babel/generator/lib/generators/expressions.js.map +1 -1
- package/appFiles/node_modules/@babel/generator/lib/generators/methods.js +12 -25
- package/appFiles/node_modules/@babel/generator/lib/generators/methods.js.map +1 -1
- package/appFiles/node_modules/@babel/generator/lib/generators/modules.js +6 -14
- package/appFiles/node_modules/@babel/generator/lib/generators/modules.js.map +1 -1
- package/appFiles/node_modules/@babel/generator/lib/generators/statements.js +1 -16
- package/appFiles/node_modules/@babel/generator/lib/generators/statements.js.map +1 -1
- package/appFiles/node_modules/@babel/generator/lib/index.js +11 -0
- package/appFiles/node_modules/@babel/generator/lib/index.js.map +1 -1
- package/appFiles/node_modules/@babel/generator/lib/printer.js +112 -86
- package/appFiles/node_modules/@babel/generator/lib/printer.js.map +1 -1
- package/appFiles/node_modules/@babel/generator/package.json +3 -3
- package/appFiles/node_modules/@babel/parser/lib/index.js +165 -99
- package/appFiles/node_modules/@babel/parser/lib/index.js.map +1 -1
- package/appFiles/node_modules/@babel/parser/package.json +2 -2
- package/appFiles/node_modules/@babel/parser/typings/babel-parser.d.ts +92 -80
- package/appFiles/node_modules/@babel/runtime/helpers/checkInRHS.js +6 -0
- package/appFiles/node_modules/@babel/runtime/helpers/createClass.js +2 -1
- package/appFiles/node_modules/@babel/runtime/helpers/defineProperty.js +2 -0
- package/appFiles/node_modules/@babel/runtime/helpers/esm/checkInRHS.js +5 -0
- package/appFiles/node_modules/@babel/runtime/helpers/esm/createClass.js +2 -1
- package/appFiles/node_modules/@babel/runtime/helpers/esm/defineProperty.js +2 -0
- package/appFiles/node_modules/@babel/runtime/helpers/esm/iterableToArrayLimit.js +23 -18
- package/appFiles/node_modules/@babel/runtime/helpers/esm/iterableToArrayLimitLoose.js +8 -7
- package/appFiles/node_modules/@babel/runtime/helpers/esm/regeneratorRuntime.js +3 -8
- package/appFiles/node_modules/@babel/runtime/helpers/iterableToArrayLimit.js +23 -18
- package/appFiles/node_modules/@babel/runtime/helpers/iterableToArrayLimitLoose.js +8 -7
- package/appFiles/node_modules/@babel/runtime/helpers/regeneratorRuntime.js +3 -8
- package/appFiles/node_modules/@babel/runtime/package.json +29 -20
- package/appFiles/node_modules/@babel/traverse/lib/path/context.js +3 -2
- package/appFiles/node_modules/@babel/traverse/lib/path/context.js.map +1 -1
- package/appFiles/node_modules/@babel/traverse/lib/path/conversion.js +8 -4
- package/appFiles/node_modules/@babel/traverse/lib/path/conversion.js.map +1 -1
- package/appFiles/node_modules/@babel/traverse/lib/path/inference/inferer-reference.js +1 -0
- package/appFiles/node_modules/@babel/traverse/lib/path/inference/inferer-reference.js.map +1 -1
- package/appFiles/node_modules/@babel/traverse/lib/scope/index.js +1 -1
- package/appFiles/node_modules/@babel/traverse/lib/scope/index.js.map +1 -1
- package/appFiles/node_modules/@babel/traverse/package.json +4 -4
- package/appFiles/node_modules/@babel/types/lib/asserts/assertNode.js +0 -3
- package/appFiles/node_modules/@babel/types/lib/asserts/assertNode.js.map +1 -1
- package/appFiles/node_modules/@babel/types/lib/asserts/generated/index.js +0 -303
- package/appFiles/node_modules/@babel/types/lib/asserts/generated/index.js.map +1 -1
- package/appFiles/node_modules/@babel/types/lib/builders/flow/createFlowUnionType.js +0 -4
- package/appFiles/node_modules/@babel/types/lib/builders/flow/createFlowUnionType.js.map +1 -1
- package/appFiles/node_modules/@babel/types/lib/builders/flow/createTypeAnnotationBasedOnTypeof.js +0 -11
- package/appFiles/node_modules/@babel/types/lib/builders/flow/createTypeAnnotationBasedOnTypeof.js.map +1 -1
- package/appFiles/node_modules/@babel/types/lib/builders/generated/index.js +0 -253
- package/appFiles/node_modules/@babel/types/lib/builders/generated/index.js.map +1 -1
- package/appFiles/node_modules/@babel/types/lib/builders/generated/uppercase.js +0 -1
- package/appFiles/node_modules/@babel/types/lib/builders/generated/uppercase.js.map +1 -1
- package/appFiles/node_modules/@babel/types/lib/builders/react/buildChildren.js +0 -7
- package/appFiles/node_modules/@babel/types/lib/builders/react/buildChildren.js.map +1 -1
- package/appFiles/node_modules/@babel/types/lib/builders/typescript/createTSUnionType.js +0 -5
- package/appFiles/node_modules/@babel/types/lib/builders/typescript/createTSUnionType.js.map +1 -1
- package/appFiles/node_modules/@babel/types/lib/builders/validateNode.js +0 -5
- package/appFiles/node_modules/@babel/types/lib/builders/validateNode.js.map +1 -1
- package/appFiles/node_modules/@babel/types/lib/clone/clone.js +0 -2
- package/appFiles/node_modules/@babel/types/lib/clone/clone.js.map +1 -1
- package/appFiles/node_modules/@babel/types/lib/clone/cloneDeep.js +0 -2
- package/appFiles/node_modules/@babel/types/lib/clone/cloneDeep.js.map +1 -1
- package/appFiles/node_modules/@babel/types/lib/clone/cloneDeepWithoutLoc.js +0 -2
- package/appFiles/node_modules/@babel/types/lib/clone/cloneDeepWithoutLoc.js.map +1 -1
- package/appFiles/node_modules/@babel/types/lib/clone/cloneNode.js +4 -22
- package/appFiles/node_modules/@babel/types/lib/clone/cloneNode.js.map +1 -1
- package/appFiles/node_modules/@babel/types/lib/clone/cloneWithoutLoc.js +0 -2
- package/appFiles/node_modules/@babel/types/lib/clone/cloneWithoutLoc.js.map +1 -1
- package/appFiles/node_modules/@babel/types/lib/comments/addComment.js +0 -2
- package/appFiles/node_modules/@babel/types/lib/comments/addComment.js.map +1 -1
- package/appFiles/node_modules/@babel/types/lib/comments/addComments.js +0 -3
- package/appFiles/node_modules/@babel/types/lib/comments/addComments.js.map +1 -1
- package/appFiles/node_modules/@babel/types/lib/comments/inheritInnerComments.js +0 -2
- package/appFiles/node_modules/@babel/types/lib/comments/inheritInnerComments.js.map +1 -1
- package/appFiles/node_modules/@babel/types/lib/comments/inheritLeadingComments.js +0 -2
- package/appFiles/node_modules/@babel/types/lib/comments/inheritLeadingComments.js.map +1 -1
- package/appFiles/node_modules/@babel/types/lib/comments/inheritTrailingComments.js +0 -2
- package/appFiles/node_modules/@babel/types/lib/comments/inheritTrailingComments.js.map +1 -1
- package/appFiles/node_modules/@babel/types/lib/comments/inheritsComments.js +0 -4
- package/appFiles/node_modules/@babel/types/lib/comments/inheritsComments.js.map +1 -1
- package/appFiles/node_modules/@babel/types/lib/comments/removeComments.js +0 -3
- package/appFiles/node_modules/@babel/types/lib/comments/removeComments.js.map +1 -1
- package/appFiles/node_modules/@babel/types/lib/constants/generated/index.js +0 -1
- package/appFiles/node_modules/@babel/types/lib/constants/generated/index.js.map +1 -1
- package/appFiles/node_modules/@babel/types/lib/constants/index.js.map +1 -1
- package/appFiles/node_modules/@babel/types/lib/converters/ensureBlock.js +0 -2
- package/appFiles/node_modules/@babel/types/lib/converters/ensureBlock.js.map +1 -1
- package/appFiles/node_modules/@babel/types/lib/converters/gatherSequenceExpressions.js +2 -12
- package/appFiles/node_modules/@babel/types/lib/converters/gatherSequenceExpressions.js.map +1 -1
- package/appFiles/node_modules/@babel/types/lib/converters/toBindingIdentifierName.js +0 -2
- package/appFiles/node_modules/@babel/types/lib/converters/toBindingIdentifierName.js.map +1 -1
- package/appFiles/node_modules/@babel/types/lib/converters/toBlock.js +0 -7
- package/appFiles/node_modules/@babel/types/lib/converters/toBlock.js.map +1 -1
- package/appFiles/node_modules/@babel/types/lib/converters/toComputedKey.js +2 -4
- package/appFiles/node_modules/@babel/types/lib/converters/toComputedKey.js.map +1 -1
- package/appFiles/node_modules/@babel/types/lib/converters/toExpression.js +0 -4
- package/appFiles/node_modules/@babel/types/lib/converters/toExpression.js.map +1 -1
- package/appFiles/node_modules/@babel/types/lib/converters/toIdentifier.js +2 -6
- package/appFiles/node_modules/@babel/types/lib/converters/toIdentifier.js.map +1 -1
- package/appFiles/node_modules/@babel/types/lib/converters/toKeyAlias.js +0 -7
- package/appFiles/node_modules/@babel/types/lib/converters/toKeyAlias.js.map +1 -1
- package/appFiles/node_modules/@babel/types/lib/converters/toSequenceExpression.js +0 -3
- package/appFiles/node_modules/@babel/types/lib/converters/toSequenceExpression.js.map +1 -1
- package/appFiles/node_modules/@babel/types/lib/converters/toStatement.js +1 -7
- package/appFiles/node_modules/@babel/types/lib/converters/toStatement.js.map +1 -1
- package/appFiles/node_modules/@babel/types/lib/converters/valueToNode.js +2 -18
- package/appFiles/node_modules/@babel/types/lib/converters/valueToNode.js.map +1 -1
- package/appFiles/node_modules/@babel/types/lib/definitions/core.js +33 -61
- package/appFiles/node_modules/@babel/types/lib/definitions/core.js.map +1 -1
- package/appFiles/node_modules/@babel/types/lib/definitions/experimental.js +3 -1
- package/appFiles/node_modules/@babel/types/lib/definitions/experimental.js.map +1 -1
- package/appFiles/node_modules/@babel/types/lib/definitions/flow.js +1 -3
- package/appFiles/node_modules/@babel/types/lib/definitions/flow.js.map +1 -1
- package/appFiles/node_modules/@babel/types/lib/definitions/index.js +0 -18
- package/appFiles/node_modules/@babel/types/lib/definitions/index.js.map +1 -1
- package/appFiles/node_modules/@babel/types/lib/definitions/jsx.js +0 -1
- package/appFiles/node_modules/@babel/types/lib/definitions/jsx.js.map +1 -1
- package/appFiles/node_modules/@babel/types/lib/definitions/misc.js +0 -2
- package/appFiles/node_modules/@babel/types/lib/definitions/misc.js.map +1 -1
- package/appFiles/node_modules/@babel/types/lib/definitions/placeholders.js +0 -5
- package/appFiles/node_modules/@babel/types/lib/definitions/placeholders.js.map +1 -1
- package/appFiles/node_modules/@babel/types/lib/definitions/typescript.js +4 -15
- package/appFiles/node_modules/@babel/types/lib/definitions/typescript.js.map +1 -1
- package/appFiles/node_modules/@babel/types/lib/definitions/utils.js +1 -65
- package/appFiles/node_modules/@babel/types/lib/definitions/utils.js.map +1 -1
- package/appFiles/node_modules/@babel/types/lib/index.d.ts +64 -65
- package/appFiles/node_modules/@babel/types/lib/index.js +1 -75
- package/appFiles/node_modules/@babel/types/lib/index.js.map +1 -1
- package/appFiles/node_modules/@babel/types/lib/modifications/appendToMemberExpression.js +0 -2
- package/appFiles/node_modules/@babel/types/lib/modifications/appendToMemberExpression.js.map +1 -1
- package/appFiles/node_modules/@babel/types/lib/modifications/flow/removeTypeDuplicates.js +3 -12
- package/appFiles/node_modules/@babel/types/lib/modifications/flow/removeTypeDuplicates.js.map +1 -1
- package/appFiles/node_modules/@babel/types/lib/modifications/inherits.js +0 -4
- package/appFiles/node_modules/@babel/types/lib/modifications/inherits.js.map +1 -1
- package/appFiles/node_modules/@babel/types/lib/modifications/prependToMemberExpression.js +0 -4
- package/appFiles/node_modules/@babel/types/lib/modifications/prependToMemberExpression.js.map +1 -1
- package/appFiles/node_modules/@babel/types/lib/modifications/removeProperties.js +3 -8
- package/appFiles/node_modules/@babel/types/lib/modifications/removeProperties.js.map +1 -1
- package/appFiles/node_modules/@babel/types/lib/modifications/removePropertiesDeep.js +0 -3
- package/appFiles/node_modules/@babel/types/lib/modifications/removePropertiesDeep.js.map +1 -1
- package/appFiles/node_modules/@babel/types/lib/modifications/typescript/removeTypeDuplicates.js +1 -10
- package/appFiles/node_modules/@babel/types/lib/modifications/typescript/removeTypeDuplicates.js.map +1 -1
- package/appFiles/node_modules/@babel/types/lib/retrievers/getBindingIdentifiers.js +4 -14
- package/appFiles/node_modules/@babel/types/lib/retrievers/getBindingIdentifiers.js.map +1 -1
- package/appFiles/node_modules/@babel/types/lib/retrievers/getOuterBindingIdentifiers.js +0 -3
- package/appFiles/node_modules/@babel/types/lib/retrievers/getOuterBindingIdentifiers.js.map +1 -1
- package/appFiles/node_modules/@babel/types/lib/traverse/traverse.js +0 -7
- package/appFiles/node_modules/@babel/types/lib/traverse/traverse.js.map +1 -1
- package/appFiles/node_modules/@babel/types/lib/traverse/traverseFast.js +2 -5
- package/appFiles/node_modules/@babel/types/lib/traverse/traverseFast.js.map +1 -1
- package/appFiles/node_modules/@babel/types/lib/utils/inherit.js +0 -1
- package/appFiles/node_modules/@babel/types/lib/utils/inherit.js.map +1 -1
- package/appFiles/node_modules/@babel/types/lib/utils/react/cleanJSXElementLiteralChild.js +1 -8
- package/appFiles/node_modules/@babel/types/lib/utils/react/cleanJSXElementLiteralChild.js.map +1 -1
- package/appFiles/node_modules/@babel/types/lib/utils/shallowEqual.js +2 -4
- package/appFiles/node_modules/@babel/types/lib/utils/shallowEqual.js.map +1 -1
- package/appFiles/node_modules/@babel/types/lib/validators/buildMatchMemberExpression.js +0 -2
- package/appFiles/node_modules/@babel/types/lib/validators/buildMatchMemberExpression.js.map +1 -1
- package/appFiles/node_modules/@babel/types/lib/validators/generated/index.js +0 -906
- package/appFiles/node_modules/@babel/types/lib/validators/generated/index.js.map +1 -1
- package/appFiles/node_modules/@babel/types/lib/validators/is.js +0 -8
- package/appFiles/node_modules/@babel/types/lib/validators/is.js.map +1 -1
- package/appFiles/node_modules/@babel/types/lib/validators/isBinding.js +4 -8
- package/appFiles/node_modules/@babel/types/lib/validators/isBinding.js.map +1 -1
- package/appFiles/node_modules/@babel/types/lib/validators/isBlockScoped.js +0 -3
- package/appFiles/node_modules/@babel/types/lib/validators/isBlockScoped.js.map +1 -1
- package/appFiles/node_modules/@babel/types/lib/validators/isImmutable.js +0 -5
- package/appFiles/node_modules/@babel/types/lib/validators/isImmutable.js.map +1 -1
- package/appFiles/node_modules/@babel/types/lib/validators/isLet.js +2 -4
- package/appFiles/node_modules/@babel/types/lib/validators/isLet.js.map +1 -1
- package/appFiles/node_modules/@babel/types/lib/validators/isNode.js +0 -2
- package/appFiles/node_modules/@babel/types/lib/validators/isNode.js.map +1 -1
- package/appFiles/node_modules/@babel/types/lib/validators/isNodesEquivalent.js +2 -16
- package/appFiles/node_modules/@babel/types/lib/validators/isNodesEquivalent.js.map +1 -1
- package/appFiles/node_modules/@babel/types/lib/validators/isPlaceholderType.js +0 -4
- package/appFiles/node_modules/@babel/types/lib/validators/isPlaceholderType.js.map +1 -1
- package/appFiles/node_modules/@babel/types/lib/validators/isReferenced.js +0 -13
- package/appFiles/node_modules/@babel/types/lib/validators/isReferenced.js.map +1 -1
- package/appFiles/node_modules/@babel/types/lib/validators/isScope.js +0 -3
- package/appFiles/node_modules/@babel/types/lib/validators/isScope.js.map +1 -1
- package/appFiles/node_modules/@babel/types/lib/validators/isSpecifierDefault.js +2 -3
- package/appFiles/node_modules/@babel/types/lib/validators/isSpecifierDefault.js.map +1 -1
- package/appFiles/node_modules/@babel/types/lib/validators/isType.js +1 -5
- package/appFiles/node_modules/@babel/types/lib/validators/isType.js.map +1 -1
- package/appFiles/node_modules/@babel/types/lib/validators/isValidES3Identifier.js +0 -2
- package/appFiles/node_modules/@babel/types/lib/validators/isValidES3Identifier.js.map +1 -1
- package/appFiles/node_modules/@babel/types/lib/validators/isValidIdentifier.js +0 -4
- package/appFiles/node_modules/@babel/types/lib/validators/isValidIdentifier.js.map +1 -1
- package/appFiles/node_modules/@babel/types/lib/validators/isVar.js +2 -4
- package/appFiles/node_modules/@babel/types/lib/validators/isVar.js.map +1 -1
- package/appFiles/node_modules/@babel/types/lib/validators/matchesPattern.js +0 -8
- package/appFiles/node_modules/@babel/types/lib/validators/matchesPattern.js.map +1 -1
- package/appFiles/node_modules/@babel/types/lib/validators/react/isCompatTag.js +0 -1
- package/appFiles/node_modules/@babel/types/lib/validators/react/isCompatTag.js.map +1 -1
- package/appFiles/node_modules/@babel/types/lib/validators/react/isReactComponent.js +0 -2
- package/appFiles/node_modules/@babel/types/lib/validators/react/isReactComponent.js.map +1 -1
- package/appFiles/node_modules/@babel/types/lib/validators/validate.js +0 -4
- package/appFiles/node_modules/@babel/types/lib/validators/validate.js.map +1 -1
- package/appFiles/node_modules/@babel/types/package.json +3 -3
- package/appFiles/node_modules/regenerator-runtime/package.json +2 -2
- package/appFiles/node_modules/regenerator-runtime/runtime.js +18 -17
- package/appFiles/src/App.tsx +0 -12
- package/appFiles/src/fields/rich-text/monaco/mdx.js +0 -46
- package/appFiles/src/lib/machines/query-machine.ts +130 -2
- package/appFiles/src/preview.tsx +9 -15
- package/dist/index.js +1 -1
- package/package.json +4 -4
- package/appFiles/node_modules/@babel/types/lib/index.d.ts.map +0 -1
|
@@ -4,19 +4,18 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = removeTypeDuplicates;
|
|
7
|
-
|
|
8
7
|
var _generated = require("../../validators/generated");
|
|
9
|
-
|
|
10
8
|
function getQualifiedName(node) {
|
|
11
9
|
return (0, _generated.isIdentifier)(node) ? node.name : `${node.id.name}.${getQualifiedName(node.qualification)}`;
|
|
12
10
|
}
|
|
13
11
|
|
|
14
|
-
function removeTypeDuplicates(
|
|
12
|
+
function removeTypeDuplicates(
|
|
13
|
+
nodes) {
|
|
15
14
|
const generics = new Map();
|
|
16
15
|
const bases = new Map();
|
|
16
|
+
|
|
17
17
|
const typeGroups = new Set();
|
|
18
18
|
const types = [];
|
|
19
|
-
|
|
20
19
|
for (let i = 0; i < nodes.length; i++) {
|
|
21
20
|
const node = nodes[i];
|
|
22
21
|
if (!node) continue;
|
|
@@ -28,27 +27,22 @@ function removeTypeDuplicates(nodes) {
|
|
|
28
27
|
if ((0, _generated.isAnyTypeAnnotation)(node)) {
|
|
29
28
|
return [node];
|
|
30
29
|
}
|
|
31
|
-
|
|
32
30
|
if ((0, _generated.isFlowBaseAnnotation)(node)) {
|
|
33
31
|
bases.set(node.type, node);
|
|
34
32
|
continue;
|
|
35
33
|
}
|
|
36
|
-
|
|
37
34
|
if ((0, _generated.isUnionTypeAnnotation)(node)) {
|
|
38
35
|
if (!typeGroups.has(node.types)) {
|
|
39
36
|
nodes = nodes.concat(node.types);
|
|
40
37
|
typeGroups.add(node.types);
|
|
41
38
|
}
|
|
42
|
-
|
|
43
39
|
continue;
|
|
44
40
|
}
|
|
45
41
|
|
|
46
42
|
if ((0, _generated.isGenericTypeAnnotation)(node)) {
|
|
47
43
|
const name = getQualifiedName(node.id);
|
|
48
|
-
|
|
49
44
|
if (generics.has(name)) {
|
|
50
45
|
let existing = generics.get(name);
|
|
51
|
-
|
|
52
46
|
if (existing.typeParameters) {
|
|
53
47
|
if (node.typeParameters) {
|
|
54
48
|
existing.typeParameters.params = removeTypeDuplicates(existing.typeParameters.params.concat(node.typeParameters.params));
|
|
@@ -59,10 +53,8 @@ function removeTypeDuplicates(nodes) {
|
|
|
59
53
|
} else {
|
|
60
54
|
generics.set(name, node);
|
|
61
55
|
}
|
|
62
|
-
|
|
63
56
|
continue;
|
|
64
57
|
}
|
|
65
|
-
|
|
66
58
|
types.push(node);
|
|
67
59
|
}
|
|
68
60
|
|
|
@@ -73,7 +65,6 @@ function removeTypeDuplicates(nodes) {
|
|
|
73
65
|
for (const [, genericName] of generics) {
|
|
74
66
|
types.push(genericName);
|
|
75
67
|
}
|
|
76
|
-
|
|
77
68
|
return types;
|
|
78
69
|
}
|
|
79
70
|
|
package/appFiles/node_modules/@babel/types/lib/modifications/flow/removeTypeDuplicates.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["getQualifiedName","node","isIdentifier","name","id","qualification","removeTypeDuplicates","nodes","generics","Map","bases","typeGroups","Set","types","i","length","indexOf","isAnyTypeAnnotation","isFlowBaseAnnotation","set","type","isUnionTypeAnnotation","has","concat","add","isGenericTypeAnnotation","existing","get","typeParameters","params","push","baseType","genericName"],"sources":["../../../src/modifications/flow/removeTypeDuplicates.ts"],"sourcesContent":["import {\n isAnyTypeAnnotation,\n isGenericTypeAnnotation,\n isUnionTypeAnnotation,\n isFlowBaseAnnotation,\n isIdentifier,\n} from \"../../validators/generated\";\nimport type * as t from \"../..\";\n\nfunction getQualifiedName(node: t.GenericTypeAnnotation[\"id\"]): string {\n return isIdentifier(node)\n ? node.name\n : `${node.id.name}.${getQualifiedName(node.qualification)}`;\n}\n\n/**\n * Dedupe type annotations.\n */\nexport default function removeTypeDuplicates(\n // todo(babel-8): change type to Array<...>\n nodes: ReadonlyArray<t.FlowType | false | null | undefined>,\n): t.FlowType[] {\n const generics = new Map<string, t.GenericTypeAnnotation>();\n const bases = new Map<t.FlowBaseAnnotation[\"type\"], t.FlowBaseAnnotation>();\n\n // store union type groups to circular references\n const typeGroups = new Set<t.FlowType[]>();\n\n const types: t.FlowType[] = [];\n\n for (let i = 0; i < nodes.length; i++) {\n const node = nodes[i];\n if (!node) continue;\n\n // detect duplicates\n if (types.indexOf(node) >= 0) {\n continue;\n }\n\n // this type matches anything\n if (isAnyTypeAnnotation(node)) {\n return [node];\n }\n\n if (isFlowBaseAnnotation(node)) {\n bases.set(node.type, node);\n continue;\n }\n\n if (isUnionTypeAnnotation(node)) {\n if (!typeGroups.has(node.types)) {\n // todo(babel-8): use .push when nodes is mutable\n nodes = nodes.concat(node.types);\n typeGroups.add(node.types);\n }\n continue;\n }\n\n // find a matching generic type and merge and deduplicate the type parameters\n if (isGenericTypeAnnotation(node)) {\n const name = getQualifiedName(node.id);\n\n if (generics.has(name)) {\n let existing: t.Flow = generics.get(name);\n if (existing.typeParameters) {\n if (node.typeParameters) {\n existing.typeParameters.params = removeTypeDuplicates(\n existing.typeParameters.params.concat(node.typeParameters.params),\n );\n }\n } else {\n existing = node.typeParameters;\n }\n } else {\n generics.set(name, node);\n }\n\n continue;\n }\n\n types.push(node);\n }\n\n // add back in bases\n for (const [, baseType] of bases) {\n types.push(baseType);\n }\n\n // add back in generics\n for (const [, genericName] of generics) {\n types.push(genericName);\n }\n\n return types;\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"names":["getQualifiedName","node","isIdentifier","name","id","qualification","removeTypeDuplicates","nodes","generics","Map","bases","typeGroups","Set","types","i","length","indexOf","isAnyTypeAnnotation","isFlowBaseAnnotation","set","type","isUnionTypeAnnotation","has","concat","add","isGenericTypeAnnotation","existing","get","typeParameters","params","push","baseType","genericName"],"sources":["../../../src/modifications/flow/removeTypeDuplicates.ts"],"sourcesContent":["import {\n isAnyTypeAnnotation,\n isGenericTypeAnnotation,\n isUnionTypeAnnotation,\n isFlowBaseAnnotation,\n isIdentifier,\n} from \"../../validators/generated\";\nimport type * as t from \"../..\";\n\nfunction getQualifiedName(node: t.GenericTypeAnnotation[\"id\"]): string {\n return isIdentifier(node)\n ? node.name\n : `${node.id.name}.${getQualifiedName(node.qualification)}`;\n}\n\n/**\n * Dedupe type annotations.\n */\nexport default function removeTypeDuplicates(\n // todo(babel-8): change type to Array<...>\n nodes: ReadonlyArray<t.FlowType | false | null | undefined>,\n): t.FlowType[] {\n const generics = new Map<string, t.GenericTypeAnnotation>();\n const bases = new Map<t.FlowBaseAnnotation[\"type\"], t.FlowBaseAnnotation>();\n\n // store union type groups to circular references\n const typeGroups = new Set<t.FlowType[]>();\n\n const types: t.FlowType[] = [];\n\n for (let i = 0; i < nodes.length; i++) {\n const node = nodes[i];\n if (!node) continue;\n\n // detect duplicates\n if (types.indexOf(node) >= 0) {\n continue;\n }\n\n // this type matches anything\n if (isAnyTypeAnnotation(node)) {\n return [node];\n }\n\n if (isFlowBaseAnnotation(node)) {\n bases.set(node.type, node);\n continue;\n }\n\n if (isUnionTypeAnnotation(node)) {\n if (!typeGroups.has(node.types)) {\n // todo(babel-8): use .push when nodes is mutable\n nodes = nodes.concat(node.types);\n typeGroups.add(node.types);\n }\n continue;\n }\n\n // find a matching generic type and merge and deduplicate the type parameters\n if (isGenericTypeAnnotation(node)) {\n const name = getQualifiedName(node.id);\n\n if (generics.has(name)) {\n let existing: t.Flow = generics.get(name);\n if (existing.typeParameters) {\n if (node.typeParameters) {\n existing.typeParameters.params = removeTypeDuplicates(\n existing.typeParameters.params.concat(node.typeParameters.params),\n );\n }\n } else {\n existing = node.typeParameters;\n }\n } else {\n generics.set(name, node);\n }\n\n continue;\n }\n\n types.push(node);\n }\n\n // add back in bases\n for (const [, baseType] of bases) {\n types.push(baseType);\n }\n\n // add back in generics\n for (const [, genericName] of generics) {\n types.push(genericName);\n }\n\n return types;\n}\n"],"mappings":";;;;;;AAAA;AASA,SAASA,gBAAgB,CAACC,IAAmC,EAAU;EACrE,OAAO,IAAAC,uBAAY,EAACD,IAAI,CAAC,GACrBA,IAAI,CAACE,IAAI,GACR,GAAEF,IAAI,CAACG,EAAE,CAACD,IAAK,IAAGH,gBAAgB,CAACC,IAAI,CAACI,aAAa,CAAE,EAAC;AAC/D;;AAKe,SAASC,oBAAoB;AAE1CC,KAA2D,EAC7C;EACd,MAAMC,QAAQ,GAAG,IAAIC,GAAG,EAAmC;EAC3D,MAAMC,KAAK,GAAG,IAAID,GAAG,EAAsD;;EAG3E,MAAME,UAAU,GAAG,IAAIC,GAAG,EAAgB;EAE1C,MAAMC,KAAmB,GAAG,EAAE;EAE9B,KAAK,IAAIC,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGP,KAAK,CAACQ,MAAM,EAAED,CAAC,EAAE,EAAE;IACrC,MAAMb,IAAI,GAAGM,KAAK,CAACO,CAAC,CAAC;IACrB,IAAI,CAACb,IAAI,EAAE;;IAGX,IAAIY,KAAK,CAACG,OAAO,CAACf,IAAI,CAAC,IAAI,CAAC,EAAE;MAC5B;IACF;;IAGA,IAAI,IAAAgB,8BAAmB,EAAChB,IAAI,CAAC,EAAE;MAC7B,OAAO,CAACA,IAAI,CAAC;IACf;IAEA,IAAI,IAAAiB,+BAAoB,EAACjB,IAAI,CAAC,EAAE;MAC9BS,KAAK,CAACS,GAAG,CAAClB,IAAI,CAACmB,IAAI,EAAEnB,IAAI,CAAC;MAC1B;IACF;IAEA,IAAI,IAAAoB,gCAAqB,EAACpB,IAAI,CAAC,EAAE;MAC/B,IAAI,CAACU,UAAU,CAACW,GAAG,CAACrB,IAAI,CAACY,KAAK,CAAC,EAAE;QAE/BN,KAAK,GAAGA,KAAK,CAACgB,MAAM,CAACtB,IAAI,CAACY,KAAK,CAAC;QAChCF,UAAU,CAACa,GAAG,CAACvB,IAAI,CAACY,KAAK,CAAC;MAC5B;MACA;IACF;;IAGA,IAAI,IAAAY,kCAAuB,EAACxB,IAAI,CAAC,EAAE;MACjC,MAAME,IAAI,GAAGH,gBAAgB,CAACC,IAAI,CAACG,EAAE,CAAC;MAEtC,IAAII,QAAQ,CAACc,GAAG,CAACnB,IAAI,CAAC,EAAE;QACtB,IAAIuB,QAAgB,GAAGlB,QAAQ,CAACmB,GAAG,CAACxB,IAAI,CAAC;QACzC,IAAIuB,QAAQ,CAACE,cAAc,EAAE;UAC3B,IAAI3B,IAAI,CAAC2B,cAAc,EAAE;YACvBF,QAAQ,CAACE,cAAc,CAACC,MAAM,GAAGvB,oBAAoB,CACnDoB,QAAQ,CAACE,cAAc,CAACC,MAAM,CAACN,MAAM,CAACtB,IAAI,CAAC2B,cAAc,CAACC,MAAM,CAAC,CAClE;UACH;QACF,CAAC,MAAM;UACLH,QAAQ,GAAGzB,IAAI,CAAC2B,cAAc;QAChC;MACF,CAAC,MAAM;QACLpB,QAAQ,CAACW,GAAG,CAAChB,IAAI,EAAEF,IAAI,CAAC;MAC1B;MAEA;IACF;IAEAY,KAAK,CAACiB,IAAI,CAAC7B,IAAI,CAAC;EAClB;;EAGA,KAAK,MAAM,GAAG8B,QAAQ,CAAC,IAAIrB,KAAK,EAAE;IAChCG,KAAK,CAACiB,IAAI,CAACC,QAAQ,CAAC;EACtB;;EAGA,KAAK,MAAM,GAAGC,WAAW,CAAC,IAAIxB,QAAQ,EAAE;IACtCK,KAAK,CAACiB,IAAI,CAACE,WAAW,CAAC;EACzB;EAEA,OAAOnB,KAAK;AACd"}
|
|
@@ -4,11 +4,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = inherits;
|
|
7
|
-
|
|
8
7
|
var _constants = require("../constants");
|
|
9
|
-
|
|
10
8
|
var _inheritsComments = require("../comments/inheritsComments");
|
|
11
|
-
|
|
12
9
|
function inherits(child, parent) {
|
|
13
10
|
if (!child || !parent) return child;
|
|
14
11
|
|
|
@@ -27,7 +24,6 @@ function inherits(child, parent) {
|
|
|
27
24
|
for (const key of _constants.INHERIT_KEYS.force) {
|
|
28
25
|
child[key] = parent[key];
|
|
29
26
|
}
|
|
30
|
-
|
|
31
27
|
(0, _inheritsComments.default)(child, parent);
|
|
32
28
|
return child;
|
|
33
29
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["inherits","child","parent","key","INHERIT_KEYS","optional","Object","keys","force","inheritsComments"],"sources":["../../src/modifications/inherits.ts"],"sourcesContent":["import { INHERIT_KEYS } from \"../constants\";\nimport inheritsComments from \"../comments/inheritsComments\";\nimport type * as t from \"..\";\n\n/**\n * Inherit all contextual properties from `parent` node to `child` node.\n */\nexport default function inherits<T extends t.Node | null | undefined>(\n child: T,\n parent: t.Node | null | undefined,\n): T {\n if (!child || !parent) return child;\n\n // optionally inherit specific properties if not null\n for (const key of INHERIT_KEYS.optional) {\n // @ts-expect-error Fixme: refine parent types\n if (child[key] == null) {\n // @ts-expect-error Fixme: refine parent types\n child[key] = parent[key];\n }\n }\n\n // force inherit \"private\" properties\n for (const key of Object.keys(parent)) {\n if (key[0] === \"_\" && key !== \"__clone\") {\n // @ts-expect-error Fixme: refine parent types\n child[key] = parent[key];\n }\n }\n\n // force inherit select properties\n for (const key of INHERIT_KEYS.force) {\n // @ts-expect-error Fixme: refine parent types\n child[key] = parent[key];\n }\n\n inheritsComments(child, parent);\n\n return child;\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"names":["inherits","child","parent","key","INHERIT_KEYS","optional","Object","keys","force","inheritsComments"],"sources":["../../src/modifications/inherits.ts"],"sourcesContent":["import { INHERIT_KEYS } from \"../constants\";\nimport inheritsComments from \"../comments/inheritsComments\";\nimport type * as t from \"..\";\n\n/**\n * Inherit all contextual properties from `parent` node to `child` node.\n */\nexport default function inherits<T extends t.Node | null | undefined>(\n child: T,\n parent: t.Node | null | undefined,\n): T {\n if (!child || !parent) return child;\n\n // optionally inherit specific properties if not null\n for (const key of INHERIT_KEYS.optional) {\n // @ts-expect-error Fixme: refine parent types\n if (child[key] == null) {\n // @ts-expect-error Fixme: refine parent types\n child[key] = parent[key];\n }\n }\n\n // force inherit \"private\" properties\n for (const key of Object.keys(parent)) {\n if (key[0] === \"_\" && key !== \"__clone\") {\n // @ts-expect-error Fixme: refine parent types\n child[key] = parent[key];\n }\n }\n\n // force inherit select properties\n for (const key of INHERIT_KEYS.force) {\n // @ts-expect-error Fixme: refine parent types\n child[key] = parent[key];\n }\n\n inheritsComments(child, parent);\n\n return child;\n}\n"],"mappings":";;;;;;AAAA;AACA;AAMe,SAASA,QAAQ,CAC9BC,KAAQ,EACRC,MAAiC,EAC9B;EACH,IAAI,CAACD,KAAK,IAAI,CAACC,MAAM,EAAE,OAAOD,KAAK;;EAGnC,KAAK,MAAME,GAAG,IAAIC,uBAAY,CAACC,QAAQ,EAAE;IAEvC,IAAIJ,KAAK,CAACE,GAAG,CAAC,IAAI,IAAI,EAAE;MAEtBF,KAAK,CAACE,GAAG,CAAC,GAAGD,MAAM,CAACC,GAAG,CAAC;IAC1B;EACF;;EAGA,KAAK,MAAMA,GAAG,IAAIG,MAAM,CAACC,IAAI,CAACL,MAAM,CAAC,EAAE;IACrC,IAAIC,GAAG,CAAC,CAAC,CAAC,KAAK,GAAG,IAAIA,GAAG,KAAK,SAAS,EAAE;MAEvCF,KAAK,CAACE,GAAG,CAAC,GAAGD,MAAM,CAACC,GAAG,CAAC;IAC1B;EACF;;EAGA,KAAK,MAAMA,GAAG,IAAIC,uBAAY,CAACI,KAAK,EAAE;IAEpCP,KAAK,CAACE,GAAG,CAAC,GAAGD,MAAM,CAACC,GAAG,CAAC;EAC1B;EAEA,IAAAM,yBAAgB,EAACR,KAAK,EAAEC,MAAM,CAAC;EAE/B,OAAOD,KAAK;AACd"}
|
|
@@ -4,16 +4,12 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = prependToMemberExpression;
|
|
7
|
-
|
|
8
7
|
var _generated = require("../builders/generated");
|
|
9
|
-
|
|
10
8
|
var _ = require("..");
|
|
11
|
-
|
|
12
9
|
function prependToMemberExpression(member, prepend) {
|
|
13
10
|
if ((0, _.isSuper)(member.object)) {
|
|
14
11
|
throw new Error("Cannot prepend node to super property access (`super.foo`).");
|
|
15
12
|
}
|
|
16
|
-
|
|
17
13
|
member.object = (0, _generated.memberExpression)(prepend, member.object);
|
|
18
14
|
return member;
|
|
19
15
|
}
|
package/appFiles/node_modules/@babel/types/lib/modifications/prependToMemberExpression.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["prependToMemberExpression","member","prepend","isSuper","object","Error","memberExpression"],"sources":["../../src/modifications/prependToMemberExpression.ts"],"sourcesContent":["import { memberExpression } from \"../builders/generated\";\nimport { isSuper } from \"..\";\nimport type * as t from \"..\";\n\n/**\n * Prepend a node to a member expression.\n */\nexport default function prependToMemberExpression<\n T extends Pick<t.MemberExpression, \"object\" | \"property\">,\n>(member: T, prepend: t.MemberExpression[\"object\"]): T {\n if (isSuper(member.object)) {\n throw new Error(\n \"Cannot prepend node to super property access (`super.foo`).\",\n );\n }\n member.object = memberExpression(prepend, member.object);\n\n return member;\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"names":["prependToMemberExpression","member","prepend","isSuper","object","Error","memberExpression"],"sources":["../../src/modifications/prependToMemberExpression.ts"],"sourcesContent":["import { memberExpression } from \"../builders/generated\";\nimport { isSuper } from \"..\";\nimport type * as t from \"..\";\n\n/**\n * Prepend a node to a member expression.\n */\nexport default function prependToMemberExpression<\n T extends Pick<t.MemberExpression, \"object\" | \"property\">,\n>(member: T, prepend: t.MemberExpression[\"object\"]): T {\n if (isSuper(member.object)) {\n throw new Error(\n \"Cannot prepend node to super property access (`super.foo`).\",\n );\n }\n member.object = memberExpression(prepend, member.object);\n\n return member;\n}\n"],"mappings":";;;;;;AAAA;AACA;AAMe,SAASA,yBAAyB,CAE/CC,MAAS,EAAEC,OAAqC,EAAK;EACrD,IAAI,IAAAC,SAAO,EAACF,MAAM,CAACG,MAAM,CAAC,EAAE;IAC1B,MAAM,IAAIC,KAAK,CACb,6DAA6D,CAC9D;EACH;EACAJ,MAAM,CAACG,MAAM,GAAG,IAAAE,2BAAgB,EAACJ,OAAO,EAAED,MAAM,CAACG,MAAM,CAAC;EAExD,OAAOH,MAAM;AACf"}
|
|
@@ -4,25 +4,20 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = removeProperties;
|
|
7
|
-
|
|
8
7
|
var _constants = require("../constants");
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
const CLEAR_KEYS = ["tokens",
|
|
9
|
+
"start", "end", "loc",
|
|
10
|
+
"raw", "rawValue"];
|
|
11
11
|
const CLEAR_KEYS_PLUS_COMMENTS = [..._constants.COMMENT_KEYS, "comments", ...CLEAR_KEYS];
|
|
12
|
-
|
|
13
12
|
function removeProperties(node, opts = {}) {
|
|
14
13
|
const map = opts.preserveComments ? CLEAR_KEYS : CLEAR_KEYS_PLUS_COMMENTS;
|
|
15
|
-
|
|
16
14
|
for (const key of map) {
|
|
17
15
|
if (node[key] != null) node[key] = undefined;
|
|
18
16
|
}
|
|
19
|
-
|
|
20
17
|
for (const key of Object.keys(node)) {
|
|
21
18
|
if (key[0] === "_" && node[key] != null) node[key] = undefined;
|
|
22
19
|
}
|
|
23
|
-
|
|
24
20
|
const symbols = Object.getOwnPropertySymbols(node);
|
|
25
|
-
|
|
26
21
|
for (const sym of symbols) {
|
|
27
22
|
node[sym] = null;
|
|
28
23
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["CLEAR_KEYS","CLEAR_KEYS_PLUS_COMMENTS","COMMENT_KEYS","removeProperties","node","opts","map","preserveComments","key","undefined","Object","keys","symbols","getOwnPropertySymbols","sym"],"sources":["../../src/modifications/removeProperties.ts"],"sourcesContent":["import { COMMENT_KEYS } from \"../constants\";\nimport type * as t from \"..\";\n\nconst CLEAR_KEYS = [\n \"tokens\", // only exist in t.File\n \"start\",\n \"end\",\n \"loc\",\n // Fixme: should be extra.raw / extra.rawValue?\n \"raw\",\n \"rawValue\",\n] as const;\n\nconst CLEAR_KEYS_PLUS_COMMENTS = [\n ...COMMENT_KEYS,\n \"comments\",\n ...CLEAR_KEYS,\n] as const;\n\nexport type Options = { preserveComments?: boolean };\n/**\n * Remove all of the _* properties from a node along with the additional metadata\n * properties like location data and raw token data.\n */\nexport default function removeProperties(\n node: t.Node,\n opts: Options = {},\n): void {\n const map = opts.preserveComments ? CLEAR_KEYS : CLEAR_KEYS_PLUS_COMMENTS;\n for (const key of map) {\n // @ts-expect-error tokens only exist in t.File\n if (node[key] != null) node[key] = undefined;\n }\n\n for (const key of Object.keys(node)) {\n // @ts-expect-error string can not index node\n if (key[0] === \"_\" && node[key] != null) node[key] = undefined;\n }\n\n const symbols: Array<symbol> = Object.getOwnPropertySymbols(node);\n for (const sym of symbols) {\n // @ts-expect-error Fixme: document symbol properties\n node[sym] = null;\n }\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"names":["CLEAR_KEYS","CLEAR_KEYS_PLUS_COMMENTS","COMMENT_KEYS","removeProperties","node","opts","map","preserveComments","key","undefined","Object","keys","symbols","getOwnPropertySymbols","sym"],"sources":["../../src/modifications/removeProperties.ts"],"sourcesContent":["import { COMMENT_KEYS } from \"../constants\";\nimport type * as t from \"..\";\n\nconst CLEAR_KEYS = [\n \"tokens\", // only exist in t.File\n \"start\",\n \"end\",\n \"loc\",\n // Fixme: should be extra.raw / extra.rawValue?\n \"raw\",\n \"rawValue\",\n] as const;\n\nconst CLEAR_KEYS_PLUS_COMMENTS = [\n ...COMMENT_KEYS,\n \"comments\",\n ...CLEAR_KEYS,\n] as const;\n\nexport type Options = { preserveComments?: boolean };\n/**\n * Remove all of the _* properties from a node along with the additional metadata\n * properties like location data and raw token data.\n */\nexport default function removeProperties(\n node: t.Node,\n opts: Options = {},\n): void {\n const map = opts.preserveComments ? CLEAR_KEYS : CLEAR_KEYS_PLUS_COMMENTS;\n for (const key of map) {\n // @ts-expect-error tokens only exist in t.File\n if (node[key] != null) node[key] = undefined;\n }\n\n for (const key of Object.keys(node)) {\n // @ts-expect-error string can not index node\n if (key[0] === \"_\" && node[key] != null) node[key] = undefined;\n }\n\n const symbols: Array<symbol> = Object.getOwnPropertySymbols(node);\n for (const sym of symbols) {\n // @ts-expect-error Fixme: document symbol properties\n node[sym] = null;\n }\n}\n"],"mappings":";;;;;;AAAA;AAGA,MAAMA,UAAU,GAAG,CACjB,QAAQ;AACR,OAAO,EACP,KAAK,EACL,KAAK;AAEL,KAAK,EACL,UAAU,CACF;AAEV,MAAMC,wBAAwB,GAAG,CAC/B,GAAGC,uBAAY,EACf,UAAU,EACV,GAAGF,UAAU,CACL;AAOK,SAASG,gBAAgB,CACtCC,IAAY,EACZC,IAAa,GAAG,CAAC,CAAC,EACZ;EACN,MAAMC,GAAG,GAAGD,IAAI,CAACE,gBAAgB,GAAGP,UAAU,GAAGC,wBAAwB;EACzE,KAAK,MAAMO,GAAG,IAAIF,GAAG,EAAE;IAErB,IAAIF,IAAI,CAACI,GAAG,CAAC,IAAI,IAAI,EAAEJ,IAAI,CAACI,GAAG,CAAC,GAAGC,SAAS;EAC9C;EAEA,KAAK,MAAMD,GAAG,IAAIE,MAAM,CAACC,IAAI,CAACP,IAAI,CAAC,EAAE;IAEnC,IAAII,GAAG,CAAC,CAAC,CAAC,KAAK,GAAG,IAAIJ,IAAI,CAACI,GAAG,CAAC,IAAI,IAAI,EAAEJ,IAAI,CAACI,GAAG,CAAC,GAAGC,SAAS;EAChE;EAEA,MAAMG,OAAsB,GAAGF,MAAM,CAACG,qBAAqB,CAACT,IAAI,CAAC;EACjE,KAAK,MAAMU,GAAG,IAAIF,OAAO,EAAE;IAEzBR,IAAI,CAACU,GAAG,CAAC,GAAG,IAAI;EAClB;AACF"}
|
|
@@ -4,11 +4,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = removePropertiesDeep;
|
|
7
|
-
|
|
8
7
|
var _traverseFast = require("../traverse/traverseFast");
|
|
9
|
-
|
|
10
8
|
var _removeProperties = require("./removeProperties");
|
|
11
|
-
|
|
12
9
|
function removePropertiesDeep(tree, opts) {
|
|
13
10
|
(0, _traverseFast.default)(tree, _removeProperties.default, opts);
|
|
14
11
|
return tree;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["removePropertiesDeep","tree","opts","traverseFast","removeProperties"],"sources":["../../src/modifications/removePropertiesDeep.ts"],"sourcesContent":["import traverseFast from \"../traverse/traverseFast\";\nimport removeProperties from \"./removeProperties\";\nimport type * as t from \"..\";\n\nexport default function removePropertiesDeep<T extends t.Node>(\n tree: T,\n opts?: { preserveComments: boolean } | null,\n): T {\n traverseFast(tree, removeProperties, opts);\n\n return tree;\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"names":["removePropertiesDeep","tree","opts","traverseFast","removeProperties"],"sources":["../../src/modifications/removePropertiesDeep.ts"],"sourcesContent":["import traverseFast from \"../traverse/traverseFast\";\nimport removeProperties from \"./removeProperties\";\nimport type * as t from \"..\";\n\nexport default function removePropertiesDeep<T extends t.Node>(\n tree: T,\n opts?: { preserveComments: boolean } | null,\n): T {\n traverseFast(tree, removeProperties, opts);\n\n return tree;\n}\n"],"mappings":";;;;;;AAAA;AACA;AAGe,SAASA,oBAAoB,CAC1CC,IAAO,EACPC,IAA2C,EACxC;EACH,IAAAC,qBAAY,EAACF,IAAI,EAAEG,yBAAgB,EAAEF,IAAI,CAAC;EAE1C,OAAOD,IAAI;AACb"}
|
package/appFiles/node_modules/@babel/types/lib/modifications/typescript/removeTypeDuplicates.js
CHANGED
|
@@ -4,9 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = removeTypeDuplicates;
|
|
7
|
-
|
|
8
7
|
var _generated = require("../../validators/generated");
|
|
9
|
-
|
|
10
8
|
function getQualifiedName(node) {
|
|
11
9
|
return (0, _generated.isIdentifier)(node) ? node.name : `${node.right.name}.${getQualifiedName(node.left)}`;
|
|
12
10
|
}
|
|
@@ -14,9 +12,9 @@ function getQualifiedName(node) {
|
|
|
14
12
|
function removeTypeDuplicates(nodes) {
|
|
15
13
|
const generics = new Map();
|
|
16
14
|
const bases = new Map();
|
|
15
|
+
|
|
17
16
|
const typeGroups = new Set();
|
|
18
17
|
const types = [];
|
|
19
|
-
|
|
20
18
|
for (let i = 0; i < nodes.length; i++) {
|
|
21
19
|
const node = nodes[i];
|
|
22
20
|
if (!node) continue;
|
|
@@ -33,22 +31,18 @@ function removeTypeDuplicates(nodes) {
|
|
|
33
31
|
bases.set(node.type, node);
|
|
34
32
|
continue;
|
|
35
33
|
}
|
|
36
|
-
|
|
37
34
|
if ((0, _generated.isTSUnionType)(node)) {
|
|
38
35
|
if (!typeGroups.has(node.types)) {
|
|
39
36
|
nodes.push(...node.types);
|
|
40
37
|
typeGroups.add(node.types);
|
|
41
38
|
}
|
|
42
|
-
|
|
43
39
|
continue;
|
|
44
40
|
}
|
|
45
41
|
|
|
46
42
|
if ((0, _generated.isTSTypeReference)(node) && node.typeParameters) {
|
|
47
43
|
const name = getQualifiedName(node.typeName);
|
|
48
|
-
|
|
49
44
|
if (generics.has(name)) {
|
|
50
45
|
let existing = generics.get(name);
|
|
51
|
-
|
|
52
46
|
if (existing.typeParameters) {
|
|
53
47
|
if (node.typeParameters) {
|
|
54
48
|
existing.typeParameters.params = removeTypeDuplicates(existing.typeParameters.params.concat(node.typeParameters.params));
|
|
@@ -59,10 +53,8 @@ function removeTypeDuplicates(nodes) {
|
|
|
59
53
|
} else {
|
|
60
54
|
generics.set(name, node);
|
|
61
55
|
}
|
|
62
|
-
|
|
63
56
|
continue;
|
|
64
57
|
}
|
|
65
|
-
|
|
66
58
|
types.push(node);
|
|
67
59
|
}
|
|
68
60
|
|
|
@@ -73,7 +65,6 @@ function removeTypeDuplicates(nodes) {
|
|
|
73
65
|
for (const [, genericName] of generics) {
|
|
74
66
|
types.push(genericName);
|
|
75
67
|
}
|
|
76
|
-
|
|
77
68
|
return types;
|
|
78
69
|
}
|
|
79
70
|
|
package/appFiles/node_modules/@babel/types/lib/modifications/typescript/removeTypeDuplicates.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["getQualifiedName","node","isIdentifier","name","right","left","removeTypeDuplicates","nodes","generics","Map","bases","typeGroups","Set","types","i","length","indexOf","isTSAnyKeyword","isTSBaseType","set","type","isTSUnionType","has","push","add","isTSTypeReference","typeParameters","typeName","existing","get","params","concat","baseType","genericName"],"sources":["../../../src/modifications/typescript/removeTypeDuplicates.ts"],"sourcesContent":["import {\n isIdentifier,\n isTSAnyKeyword,\n isTSTypeReference,\n isTSUnionType,\n isTSBaseType,\n} from \"../../validators/generated\";\nimport type * as t from \"../..\";\n\nfunction getQualifiedName(node: t.TSTypeReference[\"typeName\"]): string {\n return isIdentifier(node)\n ? node.name\n : `${node.right.name}.${getQualifiedName(node.left)}`;\n}\n\n/**\n * Dedupe type annotations.\n */\nexport default function removeTypeDuplicates(\n nodes: Array<t.TSType>,\n): Array<t.TSType> {\n const generics = new Map<string, t.TSTypeReference>();\n const bases = new Map<t.TSBaseType[\"type\"], t.TSBaseType>();\n\n // store union type groups to circular references\n const typeGroups = new Set<t.TSType[]>();\n\n const types: t.TSType[] = [];\n\n for (let i = 0; i < nodes.length; i++) {\n const node = nodes[i];\n if (!node) continue;\n\n // detect duplicates\n if (types.indexOf(node) >= 0) {\n continue;\n }\n\n // this type matches anything\n if (isTSAnyKeyword(node)) {\n return [node];\n }\n\n // Analogue of FlowBaseAnnotation\n if (isTSBaseType(node)) {\n bases.set(node.type, node);\n continue;\n }\n\n if (isTSUnionType(node)) {\n if (!typeGroups.has(node.types)) {\n nodes.push(...node.types);\n typeGroups.add(node.types);\n }\n continue;\n }\n\n // todo: support merging tuples: number[]\n if (isTSTypeReference(node) && node.typeParameters) {\n const name = getQualifiedName(node.typeName);\n\n if (generics.has(name)) {\n let existing: t.TypeScript = generics.get(name);\n if (existing.typeParameters) {\n if (node.typeParameters) {\n existing.typeParameters.params = removeTypeDuplicates(\n existing.typeParameters.params.concat(node.typeParameters.params),\n );\n }\n } else {\n existing = node.typeParameters;\n }\n } else {\n generics.set(name, node);\n }\n\n continue;\n }\n\n types.push(node);\n }\n\n // add back in bases\n for (const [, baseType] of bases) {\n types.push(baseType);\n }\n\n // add back in generics\n for (const [, genericName] of generics) {\n types.push(genericName);\n }\n\n return types;\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"names":["getQualifiedName","node","isIdentifier","name","right","left","removeTypeDuplicates","nodes","generics","Map","bases","typeGroups","Set","types","i","length","indexOf","isTSAnyKeyword","isTSBaseType","set","type","isTSUnionType","has","push","add","isTSTypeReference","typeParameters","typeName","existing","get","params","concat","baseType","genericName"],"sources":["../../../src/modifications/typescript/removeTypeDuplicates.ts"],"sourcesContent":["import {\n isIdentifier,\n isTSAnyKeyword,\n isTSTypeReference,\n isTSUnionType,\n isTSBaseType,\n} from \"../../validators/generated\";\nimport type * as t from \"../..\";\n\nfunction getQualifiedName(node: t.TSTypeReference[\"typeName\"]): string {\n return isIdentifier(node)\n ? node.name\n : `${node.right.name}.${getQualifiedName(node.left)}`;\n}\n\n/**\n * Dedupe type annotations.\n */\nexport default function removeTypeDuplicates(\n nodes: Array<t.TSType>,\n): Array<t.TSType> {\n const generics = new Map<string, t.TSTypeReference>();\n const bases = new Map<t.TSBaseType[\"type\"], t.TSBaseType>();\n\n // store union type groups to circular references\n const typeGroups = new Set<t.TSType[]>();\n\n const types: t.TSType[] = [];\n\n for (let i = 0; i < nodes.length; i++) {\n const node = nodes[i];\n if (!node) continue;\n\n // detect duplicates\n if (types.indexOf(node) >= 0) {\n continue;\n }\n\n // this type matches anything\n if (isTSAnyKeyword(node)) {\n return [node];\n }\n\n // Analogue of FlowBaseAnnotation\n if (isTSBaseType(node)) {\n bases.set(node.type, node);\n continue;\n }\n\n if (isTSUnionType(node)) {\n if (!typeGroups.has(node.types)) {\n nodes.push(...node.types);\n typeGroups.add(node.types);\n }\n continue;\n }\n\n // todo: support merging tuples: number[]\n if (isTSTypeReference(node) && node.typeParameters) {\n const name = getQualifiedName(node.typeName);\n\n if (generics.has(name)) {\n let existing: t.TypeScript = generics.get(name);\n if (existing.typeParameters) {\n if (node.typeParameters) {\n existing.typeParameters.params = removeTypeDuplicates(\n existing.typeParameters.params.concat(node.typeParameters.params),\n );\n }\n } else {\n existing = node.typeParameters;\n }\n } else {\n generics.set(name, node);\n }\n\n continue;\n }\n\n types.push(node);\n }\n\n // add back in bases\n for (const [, baseType] of bases) {\n types.push(baseType);\n }\n\n // add back in generics\n for (const [, genericName] of generics) {\n types.push(genericName);\n }\n\n return types;\n}\n"],"mappings":";;;;;;AAAA;AASA,SAASA,gBAAgB,CAACC,IAAmC,EAAU;EACrE,OAAO,IAAAC,uBAAY,EAACD,IAAI,CAAC,GACrBA,IAAI,CAACE,IAAI,GACR,GAAEF,IAAI,CAACG,KAAK,CAACD,IAAK,IAAGH,gBAAgB,CAACC,IAAI,CAACI,IAAI,CAAE,EAAC;AACzD;;AAKe,SAASC,oBAAoB,CAC1CC,KAAsB,EACL;EACjB,MAAMC,QAAQ,GAAG,IAAIC,GAAG,EAA6B;EACrD,MAAMC,KAAK,GAAG,IAAID,GAAG,EAAsC;;EAG3D,MAAME,UAAU,GAAG,IAAIC,GAAG,EAAc;EAExC,MAAMC,KAAiB,GAAG,EAAE;EAE5B,KAAK,IAAIC,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGP,KAAK,CAACQ,MAAM,EAAED,CAAC,EAAE,EAAE;IACrC,MAAMb,IAAI,GAAGM,KAAK,CAACO,CAAC,CAAC;IACrB,IAAI,CAACb,IAAI,EAAE;;IAGX,IAAIY,KAAK,CAACG,OAAO,CAACf,IAAI,CAAC,IAAI,CAAC,EAAE;MAC5B;IACF;;IAGA,IAAI,IAAAgB,yBAAc,EAAChB,IAAI,CAAC,EAAE;MACxB,OAAO,CAACA,IAAI,CAAC;IACf;;IAGA,IAAI,IAAAiB,uBAAY,EAACjB,IAAI,CAAC,EAAE;MACtBS,KAAK,CAACS,GAAG,CAAClB,IAAI,CAACmB,IAAI,EAAEnB,IAAI,CAAC;MAC1B;IACF;IAEA,IAAI,IAAAoB,wBAAa,EAACpB,IAAI,CAAC,EAAE;MACvB,IAAI,CAACU,UAAU,CAACW,GAAG,CAACrB,IAAI,CAACY,KAAK,CAAC,EAAE;QAC/BN,KAAK,CAACgB,IAAI,CAAC,GAAGtB,IAAI,CAACY,KAAK,CAAC;QACzBF,UAAU,CAACa,GAAG,CAACvB,IAAI,CAACY,KAAK,CAAC;MAC5B;MACA;IACF;;IAGA,IAAI,IAAAY,4BAAiB,EAACxB,IAAI,CAAC,IAAIA,IAAI,CAACyB,cAAc,EAAE;MAClD,MAAMvB,IAAI,GAAGH,gBAAgB,CAACC,IAAI,CAAC0B,QAAQ,CAAC;MAE5C,IAAInB,QAAQ,CAACc,GAAG,CAACnB,IAAI,CAAC,EAAE;QACtB,IAAIyB,QAAsB,GAAGpB,QAAQ,CAACqB,GAAG,CAAC1B,IAAI,CAAC;QAC/C,IAAIyB,QAAQ,CAACF,cAAc,EAAE;UAC3B,IAAIzB,IAAI,CAACyB,cAAc,EAAE;YACvBE,QAAQ,CAACF,cAAc,CAACI,MAAM,GAAGxB,oBAAoB,CACnDsB,QAAQ,CAACF,cAAc,CAACI,MAAM,CAACC,MAAM,CAAC9B,IAAI,CAACyB,cAAc,CAACI,MAAM,CAAC,CAClE;UACH;QACF,CAAC,MAAM;UACLF,QAAQ,GAAG3B,IAAI,CAACyB,cAAc;QAChC;MACF,CAAC,MAAM;QACLlB,QAAQ,CAACW,GAAG,CAAChB,IAAI,EAAEF,IAAI,CAAC;MAC1B;MAEA;IACF;IAEAY,KAAK,CAACU,IAAI,CAACtB,IAAI,CAAC;EAClB;;EAGA,KAAK,MAAM,GAAG+B,QAAQ,CAAC,IAAItB,KAAK,EAAE;IAChCG,KAAK,CAACU,IAAI,CAACS,QAAQ,CAAC;EACtB;;EAGA,KAAK,MAAM,GAAGC,WAAW,CAAC,IAAIzB,QAAQ,EAAE;IACtCK,KAAK,CAACU,IAAI,CAACU,WAAW,CAAC;EACzB;EAEA,OAAOpB,KAAK;AACd"}
|
|
@@ -4,54 +4,44 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = getBindingIdentifiers;
|
|
7
|
-
|
|
8
7
|
var _generated = require("../validators/generated");
|
|
9
|
-
|
|
10
8
|
function getBindingIdentifiers(node, duplicates, outerOnly) {
|
|
11
9
|
const search = [].concat(node);
|
|
12
10
|
const ids = Object.create(null);
|
|
13
|
-
|
|
14
11
|
while (search.length) {
|
|
15
12
|
const id = search.shift();
|
|
16
13
|
if (!id) continue;
|
|
17
|
-
const keys =
|
|
18
|
-
|
|
14
|
+
const keys =
|
|
15
|
+
getBindingIdentifiers.keys[id.type];
|
|
19
16
|
if ((0, _generated.isIdentifier)(id)) {
|
|
20
17
|
if (duplicates) {
|
|
21
18
|
const _ids = ids[id.name] = ids[id.name] || [];
|
|
22
|
-
|
|
23
19
|
_ids.push(id);
|
|
24
20
|
} else {
|
|
25
21
|
ids[id.name] = id;
|
|
26
22
|
}
|
|
27
|
-
|
|
28
23
|
continue;
|
|
29
24
|
}
|
|
30
|
-
|
|
31
25
|
if ((0, _generated.isExportDeclaration)(id) && !(0, _generated.isExportAllDeclaration)(id)) {
|
|
32
26
|
if ((0, _generated.isDeclaration)(id.declaration)) {
|
|
33
27
|
search.push(id.declaration);
|
|
34
28
|
}
|
|
35
|
-
|
|
36
29
|
continue;
|
|
37
30
|
}
|
|
38
|
-
|
|
39
31
|
if (outerOnly) {
|
|
40
32
|
if ((0, _generated.isFunctionDeclaration)(id)) {
|
|
41
33
|
search.push(id.id);
|
|
42
34
|
continue;
|
|
43
35
|
}
|
|
44
|
-
|
|
45
36
|
if ((0, _generated.isFunctionExpression)(id)) {
|
|
46
37
|
continue;
|
|
47
38
|
}
|
|
48
39
|
}
|
|
49
|
-
|
|
50
40
|
if (keys) {
|
|
51
41
|
for (let i = 0; i < keys.length; i++) {
|
|
52
42
|
const key = keys[i];
|
|
53
|
-
const nodes =
|
|
54
|
-
|
|
43
|
+
const nodes =
|
|
44
|
+
id[key];
|
|
55
45
|
if (nodes) {
|
|
56
46
|
Array.isArray(nodes) ? search.push(...nodes) : search.push(nodes);
|
|
57
47
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["getBindingIdentifiers","node","duplicates","outerOnly","search","concat","ids","Object","create","length","id","shift","keys","type","isIdentifier","_ids","name","push","isExportDeclaration","isExportAllDeclaration","isDeclaration","declaration","isFunctionDeclaration","isFunctionExpression","i","key","nodes","Array","isArray","DeclareClass","DeclareFunction","DeclareModule","DeclareVariable","DeclareInterface","DeclareTypeAlias","DeclareOpaqueType","InterfaceDeclaration","TypeAlias","OpaqueType","CatchClause","LabeledStatement","UnaryExpression","AssignmentExpression","ImportSpecifier","ImportNamespaceSpecifier","ImportDefaultSpecifier","ImportDeclaration","ExportSpecifier","ExportNamespaceSpecifier","ExportDefaultSpecifier","FunctionDeclaration","FunctionExpression","ArrowFunctionExpression","ObjectMethod","ClassMethod","ClassPrivateMethod","ForInStatement","ForOfStatement","ClassDeclaration","ClassExpression","RestElement","UpdateExpression","ObjectProperty","AssignmentPattern","ArrayPattern","ObjectPattern","VariableDeclaration","VariableDeclarator"],"sources":["../../src/retrievers/getBindingIdentifiers.ts"],"sourcesContent":["import {\n isExportDeclaration,\n isIdentifier,\n isDeclaration,\n isFunctionDeclaration,\n isFunctionExpression,\n isExportAllDeclaration,\n} from \"../validators/generated\";\nimport type * as t from \"..\";\n\nexport { getBindingIdentifiers as default };\n\nfunction getBindingIdentifiers(\n node: t.Node,\n duplicates: true,\n outerOnly?: boolean,\n): Record<string, Array<t.Identifier>>;\n\nfunction getBindingIdentifiers(\n node: t.Node,\n duplicates?: false,\n outerOnly?: boolean,\n): Record<string, t.Identifier>;\n\nfunction getBindingIdentifiers(\n node: t.Node,\n duplicates?: boolean,\n outerOnly?: boolean,\n): Record<string, t.Identifier> | Record<string, Array<t.Identifier>>;\n\n/**\n * Return a list of binding identifiers associated with the input `node`.\n */\nfunction getBindingIdentifiers(\n node: t.Node,\n duplicates?: boolean,\n outerOnly?: boolean,\n): Record<string, t.Identifier> | Record<string, Array<t.Identifier>> {\n const search: t.Node[] = [].concat(node);\n const ids = Object.create(null);\n\n while (search.length) {\n const id = search.shift();\n if (!id) continue;\n\n const keys =\n // @ts-expect-error getBindingIdentifiers.keys do not cover all AST types\n getBindingIdentifiers.keys[id.type];\n\n if (isIdentifier(id)) {\n if (duplicates) {\n const _ids = (ids[id.name] = ids[id.name] || []);\n _ids.push(id);\n } else {\n ids[id.name] = id;\n }\n continue;\n }\n\n if (isExportDeclaration(id) && !isExportAllDeclaration(id)) {\n if (isDeclaration(id.declaration)) {\n search.push(id.declaration);\n }\n continue;\n }\n\n if (outerOnly) {\n if (isFunctionDeclaration(id)) {\n search.push(id.id);\n continue;\n }\n\n if (isFunctionExpression(id)) {\n continue;\n }\n }\n\n if (keys) {\n for (let i = 0; i < keys.length; i++) {\n const key = keys[i];\n const nodes =\n // @ts-expect-error key must present in id\n id[key] as t.Node[] | t.Node | undefined | null;\n if (nodes) {\n Array.isArray(nodes) ? search.push(...nodes) : search.push(nodes);\n }\n }\n }\n }\n\n // $FlowIssue Object.create() seems broken\n return ids;\n}\n\n/**\n * Mapping of types to their identifier keys.\n */\ngetBindingIdentifiers.keys = {\n DeclareClass: [\"id\"],\n DeclareFunction: [\"id\"],\n DeclareModule: [\"id\"],\n DeclareVariable: [\"id\"],\n DeclareInterface: [\"id\"],\n DeclareTypeAlias: [\"id\"],\n DeclareOpaqueType: [\"id\"],\n InterfaceDeclaration: [\"id\"],\n TypeAlias: [\"id\"],\n OpaqueType: [\"id\"],\n\n CatchClause: [\"param\"],\n LabeledStatement: [\"label\"],\n UnaryExpression: [\"argument\"],\n AssignmentExpression: [\"left\"],\n\n ImportSpecifier: [\"local\"],\n ImportNamespaceSpecifier: [\"local\"],\n ImportDefaultSpecifier: [\"local\"],\n ImportDeclaration: [\"specifiers\"],\n\n ExportSpecifier: [\"exported\"],\n ExportNamespaceSpecifier: [\"exported\"],\n ExportDefaultSpecifier: [\"exported\"],\n\n FunctionDeclaration: [\"id\", \"params\"],\n FunctionExpression: [\"id\", \"params\"],\n ArrowFunctionExpression: [\"params\"],\n ObjectMethod: [\"params\"],\n ClassMethod: [\"params\"],\n ClassPrivateMethod: [\"params\"],\n\n ForInStatement: [\"left\"],\n ForOfStatement: [\"left\"],\n\n ClassDeclaration: [\"id\"],\n ClassExpression: [\"id\"],\n\n RestElement: [\"argument\"],\n UpdateExpression: [\"argument\"],\n\n ObjectProperty: [\"value\"],\n\n AssignmentPattern: [\"left\"],\n ArrayPattern: [\"elements\"],\n ObjectPattern: [\"properties\"],\n\n VariableDeclaration: [\"declarations\"],\n VariableDeclarator: [\"id\"],\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"names":["getBindingIdentifiers","node","duplicates","outerOnly","search","concat","ids","Object","create","length","id","shift","keys","type","isIdentifier","_ids","name","push","isExportDeclaration","isExportAllDeclaration","isDeclaration","declaration","isFunctionDeclaration","isFunctionExpression","i","key","nodes","Array","isArray","DeclareClass","DeclareFunction","DeclareModule","DeclareVariable","DeclareInterface","DeclareTypeAlias","DeclareOpaqueType","InterfaceDeclaration","TypeAlias","OpaqueType","CatchClause","LabeledStatement","UnaryExpression","AssignmentExpression","ImportSpecifier","ImportNamespaceSpecifier","ImportDefaultSpecifier","ImportDeclaration","ExportSpecifier","ExportNamespaceSpecifier","ExportDefaultSpecifier","FunctionDeclaration","FunctionExpression","ArrowFunctionExpression","ObjectMethod","ClassMethod","ClassPrivateMethod","ForInStatement","ForOfStatement","ClassDeclaration","ClassExpression","RestElement","UpdateExpression","ObjectProperty","AssignmentPattern","ArrayPattern","ObjectPattern","VariableDeclaration","VariableDeclarator"],"sources":["../../src/retrievers/getBindingIdentifiers.ts"],"sourcesContent":["import {\n isExportDeclaration,\n isIdentifier,\n isDeclaration,\n isFunctionDeclaration,\n isFunctionExpression,\n isExportAllDeclaration,\n} from \"../validators/generated\";\nimport type * as t from \"..\";\n\nexport { getBindingIdentifiers as default };\n\nfunction getBindingIdentifiers(\n node: t.Node,\n duplicates: true,\n outerOnly?: boolean,\n): Record<string, Array<t.Identifier>>;\n\nfunction getBindingIdentifiers(\n node: t.Node,\n duplicates?: false,\n outerOnly?: boolean,\n): Record<string, t.Identifier>;\n\nfunction getBindingIdentifiers(\n node: t.Node,\n duplicates?: boolean,\n outerOnly?: boolean,\n): Record<string, t.Identifier> | Record<string, Array<t.Identifier>>;\n\n/**\n * Return a list of binding identifiers associated with the input `node`.\n */\nfunction getBindingIdentifiers(\n node: t.Node,\n duplicates?: boolean,\n outerOnly?: boolean,\n): Record<string, t.Identifier> | Record<string, Array<t.Identifier>> {\n const search: t.Node[] = [].concat(node);\n const ids = Object.create(null);\n\n while (search.length) {\n const id = search.shift();\n if (!id) continue;\n\n const keys =\n // @ts-expect-error getBindingIdentifiers.keys do not cover all AST types\n getBindingIdentifiers.keys[id.type];\n\n if (isIdentifier(id)) {\n if (duplicates) {\n const _ids = (ids[id.name] = ids[id.name] || []);\n _ids.push(id);\n } else {\n ids[id.name] = id;\n }\n continue;\n }\n\n if (isExportDeclaration(id) && !isExportAllDeclaration(id)) {\n if (isDeclaration(id.declaration)) {\n search.push(id.declaration);\n }\n continue;\n }\n\n if (outerOnly) {\n if (isFunctionDeclaration(id)) {\n search.push(id.id);\n continue;\n }\n\n if (isFunctionExpression(id)) {\n continue;\n }\n }\n\n if (keys) {\n for (let i = 0; i < keys.length; i++) {\n const key = keys[i];\n const nodes =\n // @ts-expect-error key must present in id\n id[key] as t.Node[] | t.Node | undefined | null;\n if (nodes) {\n Array.isArray(nodes) ? search.push(...nodes) : search.push(nodes);\n }\n }\n }\n }\n\n // $FlowIssue Object.create() seems broken\n return ids;\n}\n\n/**\n * Mapping of types to their identifier keys.\n */\ngetBindingIdentifiers.keys = {\n DeclareClass: [\"id\"],\n DeclareFunction: [\"id\"],\n DeclareModule: [\"id\"],\n DeclareVariable: [\"id\"],\n DeclareInterface: [\"id\"],\n DeclareTypeAlias: [\"id\"],\n DeclareOpaqueType: [\"id\"],\n InterfaceDeclaration: [\"id\"],\n TypeAlias: [\"id\"],\n OpaqueType: [\"id\"],\n\n CatchClause: [\"param\"],\n LabeledStatement: [\"label\"],\n UnaryExpression: [\"argument\"],\n AssignmentExpression: [\"left\"],\n\n ImportSpecifier: [\"local\"],\n ImportNamespaceSpecifier: [\"local\"],\n ImportDefaultSpecifier: [\"local\"],\n ImportDeclaration: [\"specifiers\"],\n\n ExportSpecifier: [\"exported\"],\n ExportNamespaceSpecifier: [\"exported\"],\n ExportDefaultSpecifier: [\"exported\"],\n\n FunctionDeclaration: [\"id\", \"params\"],\n FunctionExpression: [\"id\", \"params\"],\n ArrowFunctionExpression: [\"params\"],\n ObjectMethod: [\"params\"],\n ClassMethod: [\"params\"],\n ClassPrivateMethod: [\"params\"],\n\n ForInStatement: [\"left\"],\n ForOfStatement: [\"left\"],\n\n ClassDeclaration: [\"id\"],\n ClassExpression: [\"id\"],\n\n RestElement: [\"argument\"],\n UpdateExpression: [\"argument\"],\n\n ObjectProperty: [\"value\"],\n\n AssignmentPattern: [\"left\"],\n ArrayPattern: [\"elements\"],\n ObjectPattern: [\"properties\"],\n\n VariableDeclaration: [\"declarations\"],\n VariableDeclarator: [\"id\"],\n};\n"],"mappings":";;;;;;AAAA;AAiCA,SAASA,qBAAqB,CAC5BC,IAAY,EACZC,UAAoB,EACpBC,SAAmB,EACiD;EACpE,MAAMC,MAAgB,GAAG,EAAE,CAACC,MAAM,CAACJ,IAAI,CAAC;EACxC,MAAMK,GAAG,GAAGC,MAAM,CAACC,MAAM,CAAC,IAAI,CAAC;EAE/B,OAAOJ,MAAM,CAACK,MAAM,EAAE;IACpB,MAAMC,EAAE,GAAGN,MAAM,CAACO,KAAK,EAAE;IACzB,IAAI,CAACD,EAAE,EAAE;IAET,MAAME,IAAI;IAERZ,qBAAqB,CAACY,IAAI,CAACF,EAAE,CAACG,IAAI,CAAC;IAErC,IAAI,IAAAC,uBAAY,EAACJ,EAAE,CAAC,EAAE;MACpB,IAAIR,UAAU,EAAE;QACd,MAAMa,IAAI,GAAIT,GAAG,CAACI,EAAE,CAACM,IAAI,CAAC,GAAGV,GAAG,CAACI,EAAE,CAACM,IAAI,CAAC,IAAI,EAAG;QAChDD,IAAI,CAACE,IAAI,CAACP,EAAE,CAAC;MACf,CAAC,MAAM;QACLJ,GAAG,CAACI,EAAE,CAACM,IAAI,CAAC,GAAGN,EAAE;MACnB;MACA;IACF;IAEA,IAAI,IAAAQ,8BAAmB,EAACR,EAAE,CAAC,IAAI,CAAC,IAAAS,iCAAsB,EAACT,EAAE,CAAC,EAAE;MAC1D,IAAI,IAAAU,wBAAa,EAACV,EAAE,CAACW,WAAW,CAAC,EAAE;QACjCjB,MAAM,CAACa,IAAI,CAACP,EAAE,CAACW,WAAW,CAAC;MAC7B;MACA;IACF;IAEA,IAAIlB,SAAS,EAAE;MACb,IAAI,IAAAmB,gCAAqB,EAACZ,EAAE,CAAC,EAAE;QAC7BN,MAAM,CAACa,IAAI,CAACP,EAAE,CAACA,EAAE,CAAC;QAClB;MACF;MAEA,IAAI,IAAAa,+BAAoB,EAACb,EAAE,CAAC,EAAE;QAC5B;MACF;IACF;IAEA,IAAIE,IAAI,EAAE;MACR,KAAK,IAAIY,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGZ,IAAI,CAACH,MAAM,EAAEe,CAAC,EAAE,EAAE;QACpC,MAAMC,GAAG,GAAGb,IAAI,CAACY,CAAC,CAAC;QACnB,MAAME,KAAK;QAEThB,EAAE,CAACe,GAAG,CAAyC;QACjD,IAAIC,KAAK,EAAE;UACTC,KAAK,CAACC,OAAO,CAACF,KAAK,CAAC,GAAGtB,MAAM,CAACa,IAAI,CAAC,GAAGS,KAAK,CAAC,GAAGtB,MAAM,CAACa,IAAI,CAACS,KAAK,CAAC;QACnE;MACF;IACF;EACF;;EAGA,OAAOpB,GAAG;AACZ;;AAKAN,qBAAqB,CAACY,IAAI,GAAG;EAC3BiB,YAAY,EAAE,CAAC,IAAI,CAAC;EACpBC,eAAe,EAAE,CAAC,IAAI,CAAC;EACvBC,aAAa,EAAE,CAAC,IAAI,CAAC;EACrBC,eAAe,EAAE,CAAC,IAAI,CAAC;EACvBC,gBAAgB,EAAE,CAAC,IAAI,CAAC;EACxBC,gBAAgB,EAAE,CAAC,IAAI,CAAC;EACxBC,iBAAiB,EAAE,CAAC,IAAI,CAAC;EACzBC,oBAAoB,EAAE,CAAC,IAAI,CAAC;EAC5BC,SAAS,EAAE,CAAC,IAAI,CAAC;EACjBC,UAAU,EAAE,CAAC,IAAI,CAAC;EAElBC,WAAW,EAAE,CAAC,OAAO,CAAC;EACtBC,gBAAgB,EAAE,CAAC,OAAO,CAAC;EAC3BC,eAAe,EAAE,CAAC,UAAU,CAAC;EAC7BC,oBAAoB,EAAE,CAAC,MAAM,CAAC;EAE9BC,eAAe,EAAE,CAAC,OAAO,CAAC;EAC1BC,wBAAwB,EAAE,CAAC,OAAO,CAAC;EACnCC,sBAAsB,EAAE,CAAC,OAAO,CAAC;EACjCC,iBAAiB,EAAE,CAAC,YAAY,CAAC;EAEjCC,eAAe,EAAE,CAAC,UAAU,CAAC;EAC7BC,wBAAwB,EAAE,CAAC,UAAU,CAAC;EACtCC,sBAAsB,EAAE,CAAC,UAAU,CAAC;EAEpCC,mBAAmB,EAAE,CAAC,IAAI,EAAE,QAAQ,CAAC;EACrCC,kBAAkB,EAAE,CAAC,IAAI,EAAE,QAAQ,CAAC;EACpCC,uBAAuB,EAAE,CAAC,QAAQ,CAAC;EACnCC,YAAY,EAAE,CAAC,QAAQ,CAAC;EACxBC,WAAW,EAAE,CAAC,QAAQ,CAAC;EACvBC,kBAAkB,EAAE,CAAC,QAAQ,CAAC;EAE9BC,cAAc,EAAE,CAAC,MAAM,CAAC;EACxBC,cAAc,EAAE,CAAC,MAAM,CAAC;EAExBC,gBAAgB,EAAE,CAAC,IAAI,CAAC;EACxBC,eAAe,EAAE,CAAC,IAAI,CAAC;EAEvBC,WAAW,EAAE,CAAC,UAAU,CAAC;EACzBC,gBAAgB,EAAE,CAAC,UAAU,CAAC;EAE9BC,cAAc,EAAE,CAAC,OAAO,CAAC;EAEzBC,iBAAiB,EAAE,CAAC,MAAM,CAAC;EAC3BC,YAAY,EAAE,CAAC,UAAU,CAAC;EAC1BC,aAAa,EAAE,CAAC,YAAY,CAAC;EAE7BC,mBAAmB,EAAE,CAAC,cAAc,CAAC;EACrCC,kBAAkB,EAAE,CAAC,IAAI;AAC3B,CAAC"}
|
|
@@ -4,12 +4,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
|
|
8
7
|
var _getBindingIdentifiers = require("./getBindingIdentifiers");
|
|
9
|
-
|
|
10
8
|
var _default = getOuterBindingIdentifiers;
|
|
11
9
|
exports.default = _default;
|
|
12
|
-
|
|
13
10
|
function getOuterBindingIdentifiers(node, duplicates) {
|
|
14
11
|
return (0, _getBindingIdentifiers.default)(node, duplicates, true);
|
|
15
12
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["getOuterBindingIdentifiers","node","duplicates","getBindingIdentifiers"],"sources":["../../src/retrievers/getOuterBindingIdentifiers.ts"],"sourcesContent":["import getBindingIdentifiers from \"./getBindingIdentifiers\";\nimport type * as t from \"..\";\n\nexport default getOuterBindingIdentifiers as {\n (node: t.Node, duplicates: true): Record<string, Array<t.Identifier>>;\n (node: t.Node, duplicates?: false): Record<string, t.Identifier>;\n (node: t.Node, duplicates?: boolean):\n | Record<string, t.Identifier>\n | Record<string, Array<t.Identifier>>;\n};\n\nfunction getOuterBindingIdentifiers(\n node: t.Node,\n duplicates: boolean,\n): Record<string, t.Identifier> | Record<string, Array<t.Identifier>> {\n return getBindingIdentifiers(node, duplicates, true);\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"names":["getOuterBindingIdentifiers","node","duplicates","getBindingIdentifiers"],"sources":["../../src/retrievers/getOuterBindingIdentifiers.ts"],"sourcesContent":["import getBindingIdentifiers from \"./getBindingIdentifiers\";\nimport type * as t from \"..\";\n\nexport default getOuterBindingIdentifiers as {\n (node: t.Node, duplicates: true): Record<string, Array<t.Identifier>>;\n (node: t.Node, duplicates?: false): Record<string, t.Identifier>;\n (node: t.Node, duplicates?: boolean):\n | Record<string, t.Identifier>\n | Record<string, Array<t.Identifier>>;\n};\n\nfunction getOuterBindingIdentifiers(\n node: t.Node,\n duplicates: boolean,\n): Record<string, t.Identifier> | Record<string, Array<t.Identifier>> {\n return getBindingIdentifiers(node, duplicates, true);\n}\n"],"mappings":";;;;;;AAAA;AAA4D,eAG7CA,0BAA0B;AAAA;AAQzC,SAASA,0BAA0B,CACjCC,IAAY,EACZC,UAAmB,EACiD;EACpE,OAAO,IAAAC,8BAAqB,EAACF,IAAI,EAAEC,UAAU,EAAE,IAAI,CAAC;AACtD"}
|
|
@@ -4,31 +4,25 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = traverse;
|
|
7
|
-
|
|
8
7
|
var _definitions = require("../definitions");
|
|
9
|
-
|
|
10
8
|
function traverse(node, handlers, state) {
|
|
11
9
|
if (typeof handlers === "function") {
|
|
12
10
|
handlers = {
|
|
13
11
|
enter: handlers
|
|
14
12
|
};
|
|
15
13
|
}
|
|
16
|
-
|
|
17
14
|
const {
|
|
18
15
|
enter,
|
|
19
16
|
exit
|
|
20
17
|
} = handlers;
|
|
21
18
|
traverseSimpleImpl(node, enter, exit, state, []);
|
|
22
19
|
}
|
|
23
|
-
|
|
24
20
|
function traverseSimpleImpl(node, enter, exit, state, ancestors) {
|
|
25
21
|
const keys = _definitions.VISITOR_KEYS[node.type];
|
|
26
22
|
if (!keys) return;
|
|
27
23
|
if (enter) enter(node, ancestors, state);
|
|
28
|
-
|
|
29
24
|
for (const key of keys) {
|
|
30
25
|
const subNode = node[key];
|
|
31
|
-
|
|
32
26
|
if (Array.isArray(subNode)) {
|
|
33
27
|
for (let i = 0; i < subNode.length; i++) {
|
|
34
28
|
const child = subNode[i];
|
|
@@ -50,7 +44,6 @@ function traverseSimpleImpl(node, enter, exit, state, ancestors) {
|
|
|
50
44
|
ancestors.pop();
|
|
51
45
|
}
|
|
52
46
|
}
|
|
53
|
-
|
|
54
47
|
if (exit) exit(node, ancestors, state);
|
|
55
48
|
}
|
|
56
49
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["traverse","node","handlers","state","enter","exit","traverseSimpleImpl","ancestors","keys","VISITOR_KEYS","type","key","subNode","Array","isArray","i","length","child","push","index","pop"],"sources":["../../src/traverse/traverse.ts"],"sourcesContent":["import { VISITOR_KEYS } from \"../definitions\";\nimport type * as t from \"..\";\n\nexport type TraversalAncestors = Array<{\n node: t.Node;\n key: string;\n index?: number;\n}>;\n\nexport type TraversalHandler<T> = (\n this: undefined,\n node: t.Node,\n parent: TraversalAncestors,\n state: T,\n) => void;\n\nexport type TraversalHandlers<T> = {\n enter?: TraversalHandler<T>;\n exit?: TraversalHandler<T>;\n};\n\n/**\n * A general AST traversal with both prefix and postfix handlers, and a\n * state object. Exposes ancestry data to each handler so that more complex\n * AST data can be taken into account.\n */\nexport default function traverse<T>(\n node: t.Node,\n handlers: TraversalHandler<T> | TraversalHandlers<T>,\n state?: T,\n): void {\n if (typeof handlers === \"function\") {\n handlers = { enter: handlers };\n }\n\n const { enter, exit } = handlers as TraversalHandlers<T>;\n\n traverseSimpleImpl(node, enter, exit, state, []);\n}\n\nfunction traverseSimpleImpl<T>(\n node: any,\n enter: Function | undefined,\n exit: Function | undefined,\n state: T | undefined,\n ancestors: TraversalAncestors,\n) {\n const keys = VISITOR_KEYS[node.type];\n if (!keys) return;\n\n if (enter) enter(node, ancestors, state);\n\n for (const key of keys) {\n const subNode = node[key];\n\n if (Array.isArray(subNode)) {\n for (let i = 0; i < subNode.length; i++) {\n const child = subNode[i];\n if (!child) continue;\n\n ancestors.push({\n node,\n key,\n index: i,\n });\n\n traverseSimpleImpl(child, enter, exit, state, ancestors);\n\n ancestors.pop();\n }\n } else if (subNode) {\n ancestors.push({\n node,\n key,\n });\n\n traverseSimpleImpl(subNode, enter, exit, state, ancestors);\n\n ancestors.pop();\n }\n }\n\n if (exit) exit(node, ancestors, state);\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"names":["traverse","node","handlers","state","enter","exit","traverseSimpleImpl","ancestors","keys","VISITOR_KEYS","type","key","subNode","Array","isArray","i","length","child","push","index","pop"],"sources":["../../src/traverse/traverse.ts"],"sourcesContent":["import { VISITOR_KEYS } from \"../definitions\";\nimport type * as t from \"..\";\n\nexport type TraversalAncestors = Array<{\n node: t.Node;\n key: string;\n index?: number;\n}>;\n\nexport type TraversalHandler<T> = (\n this: undefined,\n node: t.Node,\n parent: TraversalAncestors,\n state: T,\n) => void;\n\nexport type TraversalHandlers<T> = {\n enter?: TraversalHandler<T>;\n exit?: TraversalHandler<T>;\n};\n\n/**\n * A general AST traversal with both prefix and postfix handlers, and a\n * state object. Exposes ancestry data to each handler so that more complex\n * AST data can be taken into account.\n */\nexport default function traverse<T>(\n node: t.Node,\n handlers: TraversalHandler<T> | TraversalHandlers<T>,\n state?: T,\n): void {\n if (typeof handlers === \"function\") {\n handlers = { enter: handlers };\n }\n\n const { enter, exit } = handlers as TraversalHandlers<T>;\n\n traverseSimpleImpl(node, enter, exit, state, []);\n}\n\nfunction traverseSimpleImpl<T>(\n node: any,\n enter: Function | undefined,\n exit: Function | undefined,\n state: T | undefined,\n ancestors: TraversalAncestors,\n) {\n const keys = VISITOR_KEYS[node.type];\n if (!keys) return;\n\n if (enter) enter(node, ancestors, state);\n\n for (const key of keys) {\n const subNode = node[key];\n\n if (Array.isArray(subNode)) {\n for (let i = 0; i < subNode.length; i++) {\n const child = subNode[i];\n if (!child) continue;\n\n ancestors.push({\n node,\n key,\n index: i,\n });\n\n traverseSimpleImpl(child, enter, exit, state, ancestors);\n\n ancestors.pop();\n }\n } else if (subNode) {\n ancestors.push({\n node,\n key,\n });\n\n traverseSimpleImpl(subNode, enter, exit, state, ancestors);\n\n ancestors.pop();\n }\n }\n\n if (exit) exit(node, ancestors, state);\n}\n"],"mappings":";;;;;;AAAA;AA0Be,SAASA,QAAQ,CAC9BC,IAAY,EACZC,QAAoD,EACpDC,KAAS,EACH;EACN,IAAI,OAAOD,QAAQ,KAAK,UAAU,EAAE;IAClCA,QAAQ,GAAG;MAAEE,KAAK,EAAEF;IAAS,CAAC;EAChC;EAEA,MAAM;IAAEE,KAAK;IAAEC;EAAK,CAAC,GAAGH,QAAgC;EAExDI,kBAAkB,CAACL,IAAI,EAAEG,KAAK,EAAEC,IAAI,EAAEF,KAAK,EAAE,EAAE,CAAC;AAClD;AAEA,SAASG,kBAAkB,CACzBL,IAAS,EACTG,KAA2B,EAC3BC,IAA0B,EAC1BF,KAAoB,EACpBI,SAA6B,EAC7B;EACA,MAAMC,IAAI,GAAGC,yBAAY,CAACR,IAAI,CAACS,IAAI,CAAC;EACpC,IAAI,CAACF,IAAI,EAAE;EAEX,IAAIJ,KAAK,EAAEA,KAAK,CAACH,IAAI,EAAEM,SAAS,EAAEJ,KAAK,CAAC;EAExC,KAAK,MAAMQ,GAAG,IAAIH,IAAI,EAAE;IACtB,MAAMI,OAAO,GAAGX,IAAI,CAACU,GAAG,CAAC;IAEzB,IAAIE,KAAK,CAACC,OAAO,CAACF,OAAO,CAAC,EAAE;MAC1B,KAAK,IAAIG,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGH,OAAO,CAACI,MAAM,EAAED,CAAC,EAAE,EAAE;QACvC,MAAME,KAAK,GAAGL,OAAO,CAACG,CAAC,CAAC;QACxB,IAAI,CAACE,KAAK,EAAE;QAEZV,SAAS,CAACW,IAAI,CAAC;UACbjB,IAAI;UACJU,GAAG;UACHQ,KAAK,EAAEJ;QACT,CAAC,CAAC;QAEFT,kBAAkB,CAACW,KAAK,EAAEb,KAAK,EAAEC,IAAI,EAAEF,KAAK,EAAEI,SAAS,CAAC;QAExDA,SAAS,CAACa,GAAG,EAAE;MACjB;IACF,CAAC,MAAM,IAAIR,OAAO,EAAE;MAClBL,SAAS,CAACW,IAAI,CAAC;QACbjB,IAAI;QACJU;MACF,CAAC,CAAC;MAEFL,kBAAkB,CAACM,OAAO,EAAER,KAAK,EAAEC,IAAI,EAAEF,KAAK,EAAEI,SAAS,CAAC;MAE1DA,SAAS,CAACa,GAAG,EAAE;IACjB;EACF;EAEA,IAAIf,IAAI,EAAEA,IAAI,CAACJ,IAAI,EAAEM,SAAS,EAAEJ,KAAK,CAAC;AACxC"}
|
|
@@ -4,19 +4,16 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = traverseFast;
|
|
7
|
-
|
|
8
7
|
var _definitions = require("../definitions");
|
|
9
|
-
|
|
10
8
|
function traverseFast(node, enter, opts) {
|
|
11
9
|
if (!node) return;
|
|
12
10
|
const keys = _definitions.VISITOR_KEYS[node.type];
|
|
13
11
|
if (!keys) return;
|
|
14
12
|
opts = opts || {};
|
|
15
13
|
enter(node, opts);
|
|
16
|
-
|
|
17
14
|
for (const key of keys) {
|
|
18
|
-
const subNode =
|
|
19
|
-
|
|
15
|
+
const subNode =
|
|
16
|
+
node[key];
|
|
20
17
|
if (Array.isArray(subNode)) {
|
|
21
18
|
for (const node of subNode) {
|
|
22
19
|
traverseFast(node, enter, opts);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["traverseFast","node","enter","opts","keys","VISITOR_KEYS","type","key","subNode","Array","isArray"],"sources":["../../src/traverse/traverseFast.ts"],"sourcesContent":["import { VISITOR_KEYS } from \"../definitions\";\nimport type * as t from \"..\";\n\n/**\n * A prefix AST traversal implementation meant for simple searching\n * and processing.\n */\nexport default function traverseFast<Options = {}>(\n node: t.Node | null | undefined,\n enter: (node: t.Node, opts?: Options) => void,\n opts?: Options,\n): void {\n if (!node) return;\n\n const keys = VISITOR_KEYS[node.type];\n if (!keys) return;\n\n opts = opts || ({} as Options);\n enter(node, opts);\n\n for (const key of keys) {\n const subNode: t.Node | undefined | null =\n // @ts-expect-error key must present in node\n node[key];\n\n if (Array.isArray(subNode)) {\n for (const node of subNode) {\n traverseFast(node, enter, opts);\n }\n } else {\n traverseFast(subNode, enter, opts);\n }\n }\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"names":["traverseFast","node","enter","opts","keys","VISITOR_KEYS","type","key","subNode","Array","isArray"],"sources":["../../src/traverse/traverseFast.ts"],"sourcesContent":["import { VISITOR_KEYS } from \"../definitions\";\nimport type * as t from \"..\";\n\n/**\n * A prefix AST traversal implementation meant for simple searching\n * and processing.\n */\nexport default function traverseFast<Options = {}>(\n node: t.Node | null | undefined,\n enter: (node: t.Node, opts?: Options) => void,\n opts?: Options,\n): void {\n if (!node) return;\n\n const keys = VISITOR_KEYS[node.type];\n if (!keys) return;\n\n opts = opts || ({} as Options);\n enter(node, opts);\n\n for (const key of keys) {\n const subNode: t.Node | undefined | null =\n // @ts-expect-error key must present in node\n node[key];\n\n if (Array.isArray(subNode)) {\n for (const node of subNode) {\n traverseFast(node, enter, opts);\n }\n } else {\n traverseFast(subNode, enter, opts);\n }\n }\n}\n"],"mappings":";;;;;;AAAA;AAOe,SAASA,YAAY,CAClCC,IAA+B,EAC/BC,KAA6C,EAC7CC,IAAc,EACR;EACN,IAAI,CAACF,IAAI,EAAE;EAEX,MAAMG,IAAI,GAAGC,yBAAY,CAACJ,IAAI,CAACK,IAAI,CAAC;EACpC,IAAI,CAACF,IAAI,EAAE;EAEXD,IAAI,GAAGA,IAAI,IAAK,CAAC,CAAa;EAC9BD,KAAK,CAACD,IAAI,EAAEE,IAAI,CAAC;EAEjB,KAAK,MAAMI,GAAG,IAAIH,IAAI,EAAE;IACtB,MAAMI,OAAkC;IAEtCP,IAAI,CAACM,GAAG,CAAC;IAEX,IAAIE,KAAK,CAACC,OAAO,CAACF,OAAO,CAAC,EAAE;MAC1B,KAAK,MAAMP,IAAI,IAAIO,OAAO,EAAE;QAC1BR,YAAY,CAACC,IAAI,EAAEC,KAAK,EAAEC,IAAI,CAAC;MACjC;IACF,CAAC,MAAM;MACLH,YAAY,CAACQ,OAAO,EAAEN,KAAK,EAAEC,IAAI,CAAC;IACpC;EACF;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["inherit","key","child","parent","Array","from","Set","concat","filter","Boolean"],"sources":["../../src/utils/inherit.ts"],"sourcesContent":["import type * as t from \"..\";\n\nexport default function inherit<\n C extends t.Node | undefined,\n P extends t.Node | undefined,\n>(key: keyof C & keyof P, child: C, parent: P): void {\n if (child && parent) {\n // @ts-expect-error Could further refine key definitions\n child[key] = Array.from(\n new Set([].concat(child[key], parent[key]).filter(Boolean)),\n );\n }\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"names":["inherit","key","child","parent","Array","from","Set","concat","filter","Boolean"],"sources":["../../src/utils/inherit.ts"],"sourcesContent":["import type * as t from \"..\";\n\nexport default function inherit<\n C extends t.Node | undefined,\n P extends t.Node | undefined,\n>(key: keyof C & keyof P, child: C, parent: P): void {\n if (child && parent) {\n // @ts-expect-error Could further refine key definitions\n child[key] = Array.from(\n new Set([].concat(child[key], parent[key]).filter(Boolean)),\n );\n }\n}\n"],"mappings":";;;;;;AAEe,SAASA,OAAO,CAG7BC,GAAsB,EAAEC,KAAQ,EAAEC,MAAS,EAAQ;EACnD,IAAID,KAAK,IAAIC,MAAM,EAAE;IAEnBD,KAAK,CAACD,GAAG,CAAC,GAAGG,KAAK,CAACC,IAAI,CACrB,IAAIC,GAAG,CAAC,EAAE,CAACC,MAAM,CAACL,KAAK,CAACD,GAAG,CAAC,EAAEE,MAAM,CAACF,GAAG,CAAC,CAAC,CAACO,MAAM,CAACC,OAAO,CAAC,CAAC,CAC5D;EACH;AACF"}
|