ast-types 0.11.5 → 0.12.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/.travis.yml +2 -2
- package/def/babel-core.d.ts +2 -0
- package/def/babel-core.js +250 -290
- package/def/babel.d.ts +2 -0
- package/def/babel.js +12 -3
- package/def/core.d.ts +2 -0
- package/def/core.js +57 -126
- package/def/es-proposals.d.ts +2 -0
- package/def/es-proposals.js +34 -32
- package/def/es6.d.ts +2 -0
- package/def/es6.js +210 -253
- package/def/es7.d.ts +2 -0
- package/def/es7.js +35 -41
- package/def/esprima.d.ts +2 -0
- package/def/esprima.js +50 -71
- package/def/flow.d.ts +2 -0
- package/def/flow.js +289 -393
- package/def/jsx.d.ts +2 -0
- package/def/jsx.js +99 -125
- package/def/type-annotations.d.ts +7 -0
- package/def/type-annotations.js +42 -0
- package/def/typescript.d.ts +2 -0
- package/def/typescript.js +326 -444
- package/fork.d.ts +46 -0
- package/fork.js +40 -31
- package/gen/builders.d.ts +2539 -0
- package/gen/builders.js +2 -0
- package/gen/kinds.d.ts +259 -0
- package/gen/kinds.js +2 -0
- package/gen/namedTypes.d.ts +262 -0
- package/gen/namedTypes.js +2 -0
- package/gen/nodes.d.ts +1255 -0
- package/gen/nodes.js +2 -0
- package/gen/visitor.d.ts +263 -0
- package/gen/visitor.js +2 -0
- package/lib/equiv.d.ts +5 -0
- package/lib/equiv.js +19 -49
- package/lib/node-path.d.ts +22 -0
- package/lib/node-path.js +60 -125
- package/lib/path-visitor.d.ts +52 -0
- package/lib/path-visitor.js +117 -194
- package/lib/path.d.ts +25 -0
- package/lib/path.js +71 -107
- package/lib/scope.d.ts +26 -0
- package/lib/scope.js +100 -143
- package/lib/shared.d.ts +13 -0
- package/lib/shared.js +34 -31
- package/lib/types.d.ts +140 -0
- package/lib/types.js +584 -676
- package/main.d.ts +16 -0
- package/main.js +33 -18
- package/package.json +24 -7
- package/tsconfig.json +20 -0
- package/types.d.ts +6 -0
- package/types.js +2 -0
- package/def/e4x.js +0 -86
- package/def/mozilla.js +0 -42
package/fork.d.ts
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { Def, Plugin } from "./types";
|
|
2
|
+
export default function (defs: Def[]): {
|
|
3
|
+
Type: {
|
|
4
|
+
or(...types: any[]): import("./lib/types").Type<any>;
|
|
5
|
+
from<T>(value: any, name?: string | undefined): import("./lib/types").Type<T>;
|
|
6
|
+
def(typeName: string): import("./lib/types").Def<any>;
|
|
7
|
+
hasDef(typeName: string): boolean;
|
|
8
|
+
};
|
|
9
|
+
builtInTypes: {
|
|
10
|
+
string: import("./lib/types").Type<string>;
|
|
11
|
+
function: import("./lib/types").Type<Function>;
|
|
12
|
+
array: import("./lib/types").Type<any[]>;
|
|
13
|
+
object: import("./lib/types").Type<{
|
|
14
|
+
[key: string]: any;
|
|
15
|
+
}>;
|
|
16
|
+
RegExp: import("./lib/types").Type<RegExp>;
|
|
17
|
+
Date: import("./lib/types").Type<Date>;
|
|
18
|
+
number: import("./lib/types").Type<number>;
|
|
19
|
+
boolean: import("./lib/types").Type<boolean>;
|
|
20
|
+
null: import("./lib/types").Type<null>;
|
|
21
|
+
undefined: import("./lib/types").Type<undefined>;
|
|
22
|
+
};
|
|
23
|
+
namedTypes: {
|
|
24
|
+
[name: string]: import("./lib/types").AnyType;
|
|
25
|
+
};
|
|
26
|
+
builders: {
|
|
27
|
+
[name: string]: import("./lib/types").Builder;
|
|
28
|
+
};
|
|
29
|
+
defineMethod: (name: any, func?: Function | undefined) => Function;
|
|
30
|
+
getFieldNames: (object: any) => string[];
|
|
31
|
+
getFieldValue: (object: any, fieldName: any) => any;
|
|
32
|
+
eachField: (object: any, callback: (name: any, value: any) => any, context?: any) => void;
|
|
33
|
+
someField: (object: any, callback: (name: any, value: any) => any, context?: any) => boolean;
|
|
34
|
+
getSupertypeNames: (typeName: string) => string[];
|
|
35
|
+
getBuilderName: (typeName: any) => any;
|
|
36
|
+
astNodesAreEquivalent: {
|
|
37
|
+
(a: any, b: any, problemPath?: any): boolean;
|
|
38
|
+
assert(a: any, b: any): void;
|
|
39
|
+
};
|
|
40
|
+
finalize: () => void;
|
|
41
|
+
Path: import("./lib/path").PathConstructor;
|
|
42
|
+
NodePath: import("./lib/node-path").NodePathConstructor;
|
|
43
|
+
PathVisitor: import("./lib/path-visitor").PathVisitorConstructor;
|
|
44
|
+
use: <T>(plugin: Plugin<T>) => T;
|
|
45
|
+
visit: (node: import("./lib/types").ASTNode, methods?: any) => any;
|
|
46
|
+
};
|
package/fork.js
CHANGED
|
@@ -1,26 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
fork.use = use;
|
|
17
|
-
|
|
18
|
-
var types = use(require('./lib/types'));
|
|
19
|
-
|
|
20
|
-
defs.forEach(use);
|
|
21
|
-
|
|
1
|
+
"use strict";;
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
var types_1 = __importDefault(require("./lib/types"));
|
|
7
|
+
var path_visitor_1 = __importDefault(require("./lib/path-visitor"));
|
|
8
|
+
var equiv_1 = __importDefault(require("./lib/equiv"));
|
|
9
|
+
var path_1 = __importDefault(require("./lib/path"));
|
|
10
|
+
var node_path_1 = __importDefault(require("./lib/node-path"));
|
|
11
|
+
function default_1(defs) {
|
|
12
|
+
var fork = createFork();
|
|
13
|
+
var types = fork.use(types_1.default);
|
|
14
|
+
defs.forEach(fork.use);
|
|
22
15
|
types.finalize();
|
|
23
|
-
|
|
16
|
+
var PathVisitor = fork.use(path_visitor_1.default);
|
|
24
17
|
var exports = {
|
|
25
18
|
Type: types.Type,
|
|
26
19
|
builtInTypes: types.builtInTypes,
|
|
@@ -32,15 +25,31 @@ module.exports = function (defs) {
|
|
|
32
25
|
eachField: types.eachField,
|
|
33
26
|
someField: types.someField,
|
|
34
27
|
getSupertypeNames: types.getSupertypeNames,
|
|
35
|
-
|
|
28
|
+
getBuilderName: types.getBuilderName,
|
|
29
|
+
astNodesAreEquivalent: fork.use(equiv_1.default),
|
|
36
30
|
finalize: types.finalize,
|
|
37
|
-
Path: use(
|
|
38
|
-
NodePath: use(
|
|
39
|
-
PathVisitor:
|
|
40
|
-
use: use
|
|
31
|
+
Path: fork.use(path_1.default),
|
|
32
|
+
NodePath: fork.use(node_path_1.default),
|
|
33
|
+
PathVisitor: PathVisitor,
|
|
34
|
+
use: fork.use,
|
|
35
|
+
visit: PathVisitor.visit,
|
|
41
36
|
};
|
|
42
|
-
|
|
43
|
-
exports.visit = exports.PathVisitor.visit;
|
|
44
|
-
|
|
45
37
|
return exports;
|
|
46
|
-
}
|
|
38
|
+
}
|
|
39
|
+
exports.default = default_1;
|
|
40
|
+
function createFork() {
|
|
41
|
+
var used = [];
|
|
42
|
+
var usedResult = [];
|
|
43
|
+
function use(plugin) {
|
|
44
|
+
var idx = used.indexOf(plugin);
|
|
45
|
+
if (idx === -1) {
|
|
46
|
+
idx = used.length;
|
|
47
|
+
used.push(plugin);
|
|
48
|
+
usedResult[idx] = plugin(fork);
|
|
49
|
+
}
|
|
50
|
+
return usedResult[idx];
|
|
51
|
+
}
|
|
52
|
+
var fork = { use: use };
|
|
53
|
+
return fork;
|
|
54
|
+
}
|
|
55
|
+
module.exports = exports["default"];
|