first commit

This commit is contained in:
monjack
2025-06-20 18:01:48 +08:00
commit 6daa6d65c1
24611 changed files with 2512443 additions and 0 deletions

View File

@ -0,0 +1,325 @@
"use strict";
function _classPrivateFieldInitSpec(e, t, a) { _checkPrivateRedeclaration(e, t), t.set(e, a); }
function _checkPrivateRedeclaration(e, t) { if (t.has(e)) throw new TypeError("Cannot initialize the same private elements twice on an object"); }
function _classPrivateFieldGet(s, a) { return s.get(_assertClassBrand(s, a)); }
function _classPrivateFieldSet(s, a, r) { return s.set(_assertClassBrand(s, a), r), r; }
function _assertClassBrand(e, t, n) { if ("function" == typeof e ? e === t : e.has(t)) return arguments.length < 3 ? t : n; throw new TypeError("Private element is not present on this object"); }
const {
Definition,
PatternVisitor: OriginalPatternVisitor,
Referencer: OriginalReferencer,
Scope,
ScopeManager
} = require("@nicolo-ribaudo/eslint-scope-5-internals");
const {
getKeys: fallback
} = require("eslint-visitor-keys");
let visitorKeysMap;
function getVisitorValues(nodeType, client) {
if (visitorKeysMap) return visitorKeysMap[nodeType];
const {
FLOW_FLIPPED_ALIAS_KEYS,
VISITOR_KEYS
} = client.getTypesInfo();
const flowFlippedAliasKeys = new Set(FLOW_FLIPPED_ALIAS_KEYS.concat(["ArrayPattern", "ClassDeclaration", "ClassExpression", "FunctionDeclaration", "FunctionExpression", "Identifier", "ObjectPattern", "RestElement"]));
visitorKeysMap = (Object.entries || (o => Object.keys(o).map(k => [k, o[k]])))(VISITOR_KEYS).reduce((acc, [key, value]) => {
if (!flowFlippedAliasKeys.has(value)) {
acc[key] = value;
}
return acc;
}, {});
return visitorKeysMap[nodeType];
}
const propertyTypes = {
callProperties: {
type: "loop",
values: ["value"]
},
indexers: {
type: "loop",
values: ["key", "value"]
},
properties: {
type: "loop",
values: ["argument", "value"]
},
types: {
type: "loop"
},
params: {
type: "loop"
},
argument: {
type: "single"
},
elementType: {
type: "single"
},
qualification: {
type: "single"
},
rest: {
type: "single"
},
returnType: {
type: "single"
},
typeAnnotation: {
type: "typeAnnotation"
},
typeParameters: {
type: "typeParameters"
},
id: {
type: "id"
}
};
class PatternVisitor extends OriginalPatternVisitor {
ArrayPattern(node) {
node.elements.forEach(this.visit, this);
}
ObjectPattern(node) {
node.properties.forEach(this.visit, this);
}
}
var _client = new WeakMap();
class Referencer extends OriginalReferencer {
constructor(options, scopeManager, client) {
super(options, scopeManager);
_classPrivateFieldInitSpec(this, _client, void 0);
_classPrivateFieldSet(_client, this, client);
}
visitPattern(node, options, callback) {
if (!node) {
return;
}
this._checkIdentifierOrVisit(node.typeAnnotation);
if (node.type === "AssignmentPattern") {
this._checkIdentifierOrVisit(node.left.typeAnnotation);
}
if (typeof options === "function") {
callback = options;
options = {
processRightHandNodes: false
};
}
const visitor = new PatternVisitor(this.options, node, callback);
visitor.visit(node);
if (options.processRightHandNodes) {
visitor.rightHandNodes.forEach(this.visit, this);
}
}
visitClass(node) {
var _ref;
this._visitArray(node.decorators);
const typeParamScope = this._nestTypeParamScope(node);
this._visitTypeAnnotation(node.implements);
this._visitTypeAnnotation((_ref = node.superTypeParameters) == null ? void 0 : _ref.params);
super.visitClass(node);
if (typeParamScope) {
this.close(node);
}
}
visitFunction(node) {
const typeParamScope = this._nestTypeParamScope(node);
this._checkIdentifierOrVisit(node.returnType);
super.visitFunction(node);
if (typeParamScope) {
this.close(node);
}
}
visitProperty(node) {
var _node$value;
if (((_node$value = node.value) == null ? void 0 : _node$value.type) === "TypeCastExpression") {
this._visitTypeAnnotation(node.value);
}
this._visitArray(node.decorators);
super.visitProperty(node);
}
InterfaceDeclaration(node) {
this._createScopeVariable(node, node.id);
const typeParamScope = this._nestTypeParamScope(node);
this._visitArray(node.extends);
this.visit(node.body);
if (typeParamScope) {
this.close(node);
}
}
TypeAlias(node) {
this._createScopeVariable(node, node.id);
const typeParamScope = this._nestTypeParamScope(node);
this.visit(node.right);
if (typeParamScope) {
this.close(node);
}
}
ClassProperty(node) {
this._visitClassProperty(node);
}
ClassPrivateProperty(node) {
this._visitClassProperty(node);
}
AccessorProperty(node) {
this._visitClassProperty(node);
}
ClassAccessorProperty(node) {
this._visitClassProperty(node);
}
PropertyDefinition(node) {
this._visitClassProperty(node);
}
ClassPrivateMethod(node) {
super.MethodDefinition(node);
}
DeclareModule(node) {
this._visitDeclareX(node);
}
DeclareFunction(node) {
this._visitDeclareX(node);
}
DeclareVariable(node) {
this._visitDeclareX(node);
}
DeclareClass(node) {
this._visitDeclareX(node);
}
OptionalMemberExpression(node) {
super.MemberExpression(node);
}
_visitClassProperty(node) {
const {
computed,
key,
typeAnnotation,
decorators,
value
} = node;
this._visitArray(decorators);
if (computed) this.visit(key);
this._visitTypeAnnotation(typeAnnotation);
if (value) {
if (this.scopeManager.__nestClassFieldInitializerScope) {
this.scopeManager.__nestClassFieldInitializerScope(value);
} else {
this.scopeManager.__nestScope(new Scope(this.scopeManager, "function", this.scopeManager.__currentScope, value, true));
}
this.visit(value);
this.close(value);
}
}
_visitDeclareX(node) {
if (node.id) {
this._createScopeVariable(node, node.id);
}
const typeParamScope = this._nestTypeParamScope(node);
if (typeParamScope) {
this.close(node);
}
}
_createScopeVariable(node, name) {
this.currentScope().variableScope.__define(name, new Definition("Variable", name, node, null, null, null));
}
_nestTypeParamScope(node) {
if (!node.typeParameters) {
return null;
}
const parentScope = this.scopeManager.__currentScope;
const scope = new Scope(this.scopeManager, "type-parameters", parentScope, node, false);
this.scopeManager.__nestScope(scope);
for (let j = 0; j < node.typeParameters.params.length; j++) {
const name = node.typeParameters.params[j];
scope.__define(name, new Definition("TypeParameter", name, name));
if (name.typeAnnotation) {
this._checkIdentifierOrVisit(name);
}
}
scope.__define = parentScope.__define.bind(parentScope);
return scope;
}
_visitTypeAnnotation(node) {
if (!node) {
return;
}
if (Array.isArray(node)) {
node.forEach(this._visitTypeAnnotation, this);
return;
}
const visitorValues = getVisitorValues(node.type, _classPrivateFieldGet(_client, this));
if (!visitorValues) {
return;
}
for (let i = 0; i < visitorValues.length; i++) {
const visitorValue = visitorValues[i];
const propertyType = propertyTypes[visitorValue];
const nodeProperty = node[visitorValue];
if (propertyType == null || nodeProperty == null) {
continue;
}
if (propertyType.type === "loop") {
for (let j = 0; j < nodeProperty.length; j++) {
if (Array.isArray(propertyType.values)) {
for (let k = 0; k < propertyType.values.length; k++) {
const loopPropertyNode = nodeProperty[j][propertyType.values[k]];
if (loopPropertyNode) {
this._checkIdentifierOrVisit(loopPropertyNode);
}
}
} else {
this._checkIdentifierOrVisit(nodeProperty[j]);
}
}
} else if (propertyType.type === "single") {
this._checkIdentifierOrVisit(nodeProperty);
} else if (propertyType.type === "typeAnnotation") {
this._visitTypeAnnotation(node.typeAnnotation);
} else if (propertyType.type === "typeParameters") {
for (let l = 0; l < node.typeParameters.params.length; l++) {
this._checkIdentifierOrVisit(node.typeParameters.params[l]);
}
} else if (propertyType.type === "id") {
if (node.id.type === "Identifier") {
this._checkIdentifierOrVisit(node.id);
} else {
this._visitTypeAnnotation(node.id);
}
}
}
}
_checkIdentifierOrVisit(node) {
if (node != null && node.typeAnnotation) {
this._visitTypeAnnotation(node.typeAnnotation);
} else if ((node == null ? void 0 : node.type) === "Identifier") {
this.visit(node);
} else {
this._visitTypeAnnotation(node);
}
}
_visitArray(nodeList) {
if (nodeList) {
for (const node of nodeList) {
this.visit(node);
}
}
}
}
module.exports = function analyzeScope(ast, parserOptions, client) {
var _parserOptions$ecmaFe;
const options = {
ignoreEval: true,
optimistic: false,
directive: false,
nodejsScope: ast.sourceType === "script" && ((_parserOptions$ecmaFe = parserOptions.ecmaFeatures) == null ? void 0 : _parserOptions$ecmaFe.globalReturn) === true,
impliedStrict: false,
sourceType: ast.sourceType,
ecmaVersion: parserOptions.ecmaVersion,
fallback,
childVisitorKeys: client.getVisitorKeys()
};
const scopeManager = new ScopeManager(options);
const referencer = new Referencer(options, scopeManager, client);
referencer.visit(ast);
return scopeManager;
};
//# sourceMappingURL=analyze-scope.cjs.map

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,106 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.WorkerClient = exports.Client = exports.ACTIONS = void 0;
function _classPrivateFieldInitSpec(e, t, a) { _checkPrivateRedeclaration(e, t), t.set(e, a); }
function _checkPrivateRedeclaration(e, t) { if (t.has(e)) throw new TypeError("Cannot initialize the same private elements twice on an object"); }
function _classPrivateFieldGet(s, a) { return s.get(_assertClassBrand(s, a)); }
function _classPrivateFieldSet(s, a, r) { return s.set(_assertClassBrand(s, a), r), r; }
function _assertClassBrand(e, t, n) { if ("function" == typeof e ? e === t : e.has(t)) return arguments.length < 3 ? t : n; throw new TypeError("Private element is not present on this object"); }
const path = require("path");
const ACTIONS = exports.ACTIONS = {
GET_VERSION: "GET_VERSION",
GET_TYPES_INFO: "GET_TYPES_INFO",
GET_VISITOR_KEYS: "GET_VISITOR_KEYS",
GET_TOKEN_LABELS: "GET_TOKEN_LABELS",
MAYBE_PARSE: "MAYBE_PARSE",
MAYBE_PARSE_SYNC: "MAYBE_PARSE_SYNC"
};
var _send = new WeakMap();
var _vCache = new WeakMap();
var _tiCache = new WeakMap();
var _vkCache = new WeakMap();
var _tlCache = new WeakMap();
class Client {
constructor(send) {
_classPrivateFieldInitSpec(this, _send, void 0);
_classPrivateFieldInitSpec(this, _vCache, void 0);
_classPrivateFieldInitSpec(this, _tiCache, void 0);
_classPrivateFieldInitSpec(this, _vkCache, void 0);
_classPrivateFieldInitSpec(this, _tlCache, void 0);
_classPrivateFieldSet(_send, this, send);
}
getVersion() {
var _classPrivateFieldGet2;
return (_classPrivateFieldGet2 = _classPrivateFieldGet(_vCache, this)) != null ? _classPrivateFieldGet2 : _classPrivateFieldSet(_vCache, this, _classPrivateFieldGet(_send, this).call(this, ACTIONS.GET_VERSION, undefined));
}
getTypesInfo() {
var _classPrivateFieldGet3;
return (_classPrivateFieldGet3 = _classPrivateFieldGet(_tiCache, this)) != null ? _classPrivateFieldGet3 : _classPrivateFieldSet(_tiCache, this, _classPrivateFieldGet(_send, this).call(this, ACTIONS.GET_TYPES_INFO, undefined));
}
getVisitorKeys() {
var _classPrivateFieldGet4;
return (_classPrivateFieldGet4 = _classPrivateFieldGet(_vkCache, this)) != null ? _classPrivateFieldGet4 : _classPrivateFieldSet(_vkCache, this, _classPrivateFieldGet(_send, this).call(this, ACTIONS.GET_VISITOR_KEYS, undefined));
}
getTokLabels() {
var _classPrivateFieldGet5;
return (_classPrivateFieldGet5 = _classPrivateFieldGet(_tlCache, this)) != null ? _classPrivateFieldGet5 : _classPrivateFieldSet(_tlCache, this, _classPrivateFieldGet(_send, this).call(this, ACTIONS.GET_TOKEN_LABELS, undefined));
}
maybeParse(code, options) {
return _classPrivateFieldGet(_send, this).call(this, ACTIONS.MAYBE_PARSE, {
code,
options
});
}
}
exports.Client = Client;
var _worker = new WeakMap();
class WorkerClient extends Client {
constructor() {
super((action, payload) => {
const signal = new Int32Array(new SharedArrayBuffer(8));
const subChannel = new (_get_worker_threads(WorkerClient).MessageChannel)();
_classPrivateFieldGet(_worker, this).postMessage({
signal,
port: subChannel.port1,
action,
payload
}, [subChannel.port1]);
Atomics.wait(signal, 0, 0);
const {
message
} = _get_worker_threads(WorkerClient).receiveMessageOnPort(subChannel.port2);
if (message.error) throw Object.assign(message.error, message.errorData);else return message.result;
});
_classPrivateFieldInitSpec(this, _worker, new (_get_worker_threads(WorkerClient).Worker)(path.resolve(__dirname, "../lib/worker/index.cjs"), {
env: _get_worker_threads(WorkerClient).SHARE_ENV
}));
_classPrivateFieldGet(_worker, this).unref();
}
}
exports.WorkerClient = WorkerClient;
function _get_worker_threads(_this) {
var _worker_threads_cache2;
return (_worker_threads_cache2 = _worker_threads_cache._) != null ? _worker_threads_cache2 : _worker_threads_cache._ = require("worker_threads");
}
var _worker_threads_cache = {
_: void 0
};
{
var _LocalClient, _handleMessage;
exports.LocalClient = (_LocalClient = class LocalClient extends Client {
constructor() {
var _assertClassBrand$_;
(_assertClassBrand$_ = _assertClassBrand(_LocalClient, LocalClient, _handleMessage)._) != null ? _assertClassBrand$_ : _handleMessage._ = _assertClassBrand(_LocalClient, LocalClient, require("./worker/handle-message.cjs"));
super((action, payload) => {
return _assertClassBrand(_LocalClient, LocalClient, _handleMessage)._.call(LocalClient, action === ACTIONS.MAYBE_PARSE ? ACTIONS.MAYBE_PARSE_SYNC : action, payload);
});
}
}, _handleMessage = {
_: void 0
}, _LocalClient);
}
//# sourceMappingURL=client.cjs.map

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,23 @@
"use strict";
const _excluded = ["babelOptions", "ecmaVersion", "sourceType", "requireConfigFile"];
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
module.exports = function normalizeESLintConfig(options) {
const {
babelOptions = {},
ecmaVersion = 2020,
sourceType = "module",
requireConfigFile = true
} = options,
otherOptions = _objectWithoutPropertiesLoose(options, _excluded);
return Object.assign({
babelOptions: Object.assign({
cwd: process.cwd()
}, babelOptions),
ecmaVersion: ecmaVersion === "latest" ? 1e8 : ecmaVersion,
sourceType: sourceType === "commonjs" ? "script" : sourceType,
requireConfigFile
}, otherOptions);
};
//# sourceMappingURL=configuration.cjs.map

View File

@ -0,0 +1 @@
{"version":3,"names":["normalizeESLintConfig","options","babelOptions","ecmaVersion","sourceType","requireConfigFile","otherOptions","_objectWithoutPropertiesLoose","_excluded","Object","assign","cwd","process"],"sources":["../src/configuration.cts"],"sourcesContent":["import type { Options } from \"./types.cts\";\n\nexport = function normalizeESLintConfig(options: any) {\n const {\n babelOptions = {},\n // ESLint sets ecmaVersion: undefined when ecmaVersion is not set in the config.\n ecmaVersion = 2020,\n sourceType = \"module\",\n requireConfigFile = true,\n ...otherOptions\n } = options;\n\n return {\n babelOptions: { cwd: process.cwd(), ...babelOptions },\n ecmaVersion: ecmaVersion === \"latest\" ? 1e8 : ecmaVersion,\n // https://eslint.org/docs/latest/use/configure/language-options#specifying-javascript-options\n // ESLint supports \"commonjs\" but Babel parser does not.\n sourceType: sourceType === \"commonjs\" ? \"script\" : sourceType,\n requireConfigFile,\n ...otherOptions,\n } as Options;\n};\n"],"mappings":";;;;iBAES,SAASA,qBAAqBA,CAACC,OAAY,EAAE;EACpD,MAAM;MACJC,YAAY,GAAG,CAAC,CAAC;MAEjBC,WAAW,GAAG,IAAI;MAClBC,UAAU,GAAG,QAAQ;MACrBC,iBAAiB,GAAG;IAEtB,CAAC,GAAGJ,OAAO;IADNK,YAAY,GAAAC,6BAAA,CACbN,OAAO,EAAAO,SAAA;EAEX,OAAAC,MAAA,CAAAC,MAAA;IACER,YAAY,EAAAO,MAAA,CAAAC,MAAA;MAAIC,GAAG,EAAEC,OAAO,CAACD,GAAG,CAAC;IAAC,GAAKT,YAAY,CAAE;IACrDC,WAAW,EAAEA,WAAW,KAAK,QAAQ,GAAG,GAAG,GAAGA,WAAW;IAGzDC,UAAU,EAAEA,UAAU,KAAK,UAAU,GAAG,QAAQ,GAAGA,UAAU;IAC7DC;EAAiB,GACdC,YAAY;AAEnB,CAAC","ignoreList":[]}

View File

@ -0,0 +1,136 @@
"use strict";
const ESLINT_VERSION = require("../utils/eslint-version.cjs");
function* it(children) {
if (Array.isArray(children)) yield* children;else yield children;
}
function traverse(node, visitorKeys, visitor) {
const {
type
} = node;
if (!type) return;
const keys = visitorKeys[type];
if (!keys) return;
for (const key of keys) {
for (const child of it(node[key])) {
if (child && typeof child === "object") {
visitor.enter(child);
traverse(child, visitorKeys, visitor);
visitor.exit(child);
}
}
}
}
const convertNodesVisitor = {
enter(node) {
if (node.innerComments) {
delete node.innerComments;
}
if (node.trailingComments) {
delete node.trailingComments;
}
if (node.leadingComments) {
delete node.leadingComments;
}
},
exit(node) {
if (node.extra) {
delete node.extra;
}
{
if (node.loc.identifierName) {
delete node.loc.identifierName;
}
}
if (node.type === "TypeParameter") {
node.type = "Identifier";
node.typeAnnotation = node.bound;
delete node.bound;
}
if (node.type === "QualifiedTypeIdentifier") {
delete node.id;
}
if (node.type === "ObjectTypeProperty") {
delete node.key;
}
if (node.type === "ObjectTypeIndexer") {
delete node.id;
}
if (node.type === "FunctionTypeParam") {
delete node.name;
}
if (node.type === "ImportDeclaration") {
delete node.isType;
}
if (node.type === "TemplateLiteral" || node.type === "TSTemplateLiteralType") {
for (let i = 0; i < node.quasis.length; i++) {
const q = node.quasis[i];
q.range[0] -= 1;
if (q.tail) {
q.range[1] += 1;
} else {
q.range[1] += 2;
}
q.loc.start.column -= 1;
if (q.tail) {
q.loc.end.column += 1;
} else {
q.loc.end.column += 2;
}
if (ESLINT_VERSION >= 8) {
q.start -= 1;
if (q.tail) {
q.end += 1;
} else {
q.end += 2;
}
}
}
}
}
};
function convertNodes(ast, visitorKeys) {
traverse(ast, visitorKeys, convertNodesVisitor);
}
function convertProgramNode(ast) {
const body = ast.program.body;
Object.assign(ast, {
type: "Program",
sourceType: ast.program.sourceType,
body
});
delete ast.program;
delete ast.errors;
if (ast.comments.length) {
const lastComment = ast.comments[ast.comments.length - 1];
if (ast.tokens.length) {
const lastToken = ast.tokens[ast.tokens.length - 1];
if (lastComment.end > lastToken.end) {
ast.range[1] = lastToken.end;
ast.loc.end.line = lastToken.loc.end.line;
ast.loc.end.column = lastToken.loc.end.column;
if (ESLINT_VERSION >= 8) {
ast.end = lastToken.end;
}
}
}
} else {
if (!ast.tokens.length) {
ast.loc.start.line = 1;
ast.loc.end.line = 1;
}
}
if (body != null && body.length) {
ast.loc.start.line = body[0].loc.start.line;
ast.range[0] = body[0].start;
if (ESLINT_VERSION >= 8) {
ast.start = body[0].start;
}
}
}
module.exports = function convertAST(ast, visitorKeys) {
convertNodes(ast, visitorKeys);
convertProgramNode(ast);
};
//# sourceMappingURL=convertAST.cjs.map

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,10 @@
"use strict";
module.exports = function convertComments(comments) {
for (const comment of comments) {
comment.type = comment.type === "CommentBlock" ? "Block" : "Line";
comment.range || (comment.range = [comment.start, comment.end]);
}
};
//# sourceMappingURL=convertComments.cjs.map

View File

@ -0,0 +1 @@
{"version":3,"names":["convertComments","comments","comment","type","range","start","end"],"sources":["../../src/convert/convertComments.cts"],"sourcesContent":["import type { Comment } from \"@babel/types\";\n\nexport = function convertComments(comments: Comment[]) {\n for (const comment of comments) {\n // @ts-expect-error eslint\n comment.type = comment.type === \"CommentBlock\" ? \"Block\" : \"Line\";\n\n // sometimes comments don't get ranges computed,\n // even with options.ranges === true\n\n // @ts-expect-error eslint\n comment.range ||= [comment.start, comment.end];\n }\n};\n"],"mappings":";;iBAES,SAASA,eAAeA,CAACC,QAAmB,EAAE;EACrD,KAAK,MAAMC,OAAO,IAAID,QAAQ,EAAE;IAE9BC,OAAO,CAACC,IAAI,GAAGD,OAAO,CAACC,IAAI,KAAK,cAAc,GAAG,OAAO,GAAG,MAAM;IAMjED,OAAO,CAACE,KAAK,KAAbF,OAAO,CAACE,KAAK,GAAK,CAACF,OAAO,CAACG,KAAK,EAAEH,OAAO,CAACI,GAAG,CAAC;EAChD;AACF,CAAC","ignoreList":[]}

View File

@ -0,0 +1,161 @@
"use strict";
const ESLINT_VERSION = require("../utils/eslint-version.cjs");
function convertTemplateType(tokens, tl) {
let curlyBrace = null;
let templateTokens = [];
const result = [];
function addTemplateType() {
const start = templateTokens[0];
const end = templateTokens[templateTokens.length - 1];
const value = templateTokens.reduce((result, token) => {
if (token.value) {
result += token.value;
} else if (token.type.label !== tl.template) {
result += token.type.label;
}
return result;
}, "");
result.push({
type: "Template",
value: value,
start: start.start,
end: end.end,
loc: {
start: start.loc.start,
end: end.loc.end
}
});
templateTokens = [];
}
tokens.forEach(token => {
switch (token.type.label) {
case tl.backQuote:
if (curlyBrace) {
result.push(curlyBrace);
curlyBrace = null;
}
templateTokens.push(token);
if (templateTokens.length > 1) {
addTemplateType();
}
break;
case tl.dollarBraceL:
templateTokens.push(token);
addTemplateType();
break;
case tl.braceR:
if (curlyBrace) {
result.push(curlyBrace);
}
curlyBrace = token;
break;
case tl.template:
if (curlyBrace) {
templateTokens.push(curlyBrace);
curlyBrace = null;
}
templateTokens.push(token);
break;
default:
if (curlyBrace) {
result.push(curlyBrace);
curlyBrace = null;
}
result.push(token);
}
});
return result;
}
function convertToken(token, source, tl) {
const {
type
} = token;
const {
label
} = type;
const newToken = token;
newToken.range = [token.start, token.end];
if (label === tl.name) {
const tokenValue = token.value;
if (tokenValue === "let" || tokenValue === "static" || tokenValue === "yield") {
newToken.type = "Keyword";
} else {
newToken.type = "Identifier";
}
} else if (label === tl.semi || label === tl.comma || label === tl.parenL || label === tl.parenR || label === tl.braceL || label === tl.braceR || label === tl.slash || label === tl.dot || label === tl.bracketL || label === tl.bracketR || label === tl.ellipsis || label === tl.arrow || label === tl.pipeline || label === tl.star || label === tl.incDec || label === tl.colon || label === tl.question || label === tl.template || label === tl.backQuote || label === tl.dollarBraceL || label === tl.at || label === tl.logicalOR || label === tl.logicalAND || label === tl.nullishCoalescing || label === tl.bitwiseOR || label === tl.bitwiseXOR || label === tl.bitwiseAND || label === tl.equality || label === tl.relational || label === tl.bitShift || label === tl.plusMin || label === tl.modulo || label === tl.exponent || label === tl.bang || label === tl.tilde || label === tl.doubleColon || label === tl.hash || label === tl.questionDot || label === tl.braceHashL || label === tl.braceBarL || label === tl.braceBarR || label === tl.bracketHashL || label === tl.bracketBarL || label === tl.bracketBarR || label === tl.doubleCaret || label === tl.doubleAt || type.isAssign) {
var _newToken$value;
newToken.type = "Punctuator";
(_newToken$value = newToken.value) != null ? _newToken$value : newToken.value = label;
} else if (label === tl.jsxTagStart) {
newToken.type = "Punctuator";
newToken.value = "<";
} else if (label === tl.jsxTagEnd) {
newToken.type = "Punctuator";
newToken.value = ">";
} else if (label === tl.jsxName) {
newToken.type = "JSXIdentifier";
} else if (label === tl.jsxText) {
newToken.type = "JSXText";
} else if (type.keyword === "null") {
newToken.type = "Null";
} else if (type.keyword === "false" || type.keyword === "true") {
newToken.type = "Boolean";
} else if (type.keyword) {
newToken.type = "Keyword";
} else if (label === tl.num) {
newToken.type = "Numeric";
newToken.value = source.slice(token.start, token.end);
} else if (label === tl.string) {
newToken.type = "String";
newToken.value = source.slice(token.start, token.end);
} else if (label === tl.regexp) {
newToken.type = "RegularExpression";
const value = token.value;
newToken.regex = {
pattern: value.pattern,
flags: value.flags
};
newToken.value = `/${value.pattern}/${value.flags}`;
} else if (label === tl.bigint) {
newToken.type = "Numeric";
newToken.value = `${token.value}n`;
} else if (label === tl.privateName) {
newToken.type = "PrivateIdentifier";
} else if (label === tl.templateNonTail || label === tl.templateTail || label === tl.Template) {
newToken.type = "Template";
}
;
return newToken;
}
module.exports = function convertTokens(tokens, code, tokLabels) {
const result = [];
const templateTypeMergedTokens = convertTemplateType(tokens, tokLabels);
for (let i = 0, {
length
} = templateTypeMergedTokens; i < length - 1; i++) {
const token = templateTypeMergedTokens[i];
const tokenType = token.type;
if (tokenType === "CommentLine" || tokenType === "CommentBlock") {
continue;
}
{
if (ESLINT_VERSION >= 8 && i + 1 < length && tokenType.label === tokLabels.hash) {
const nextToken = templateTypeMergedTokens[i + 1];
if (nextToken.type.label === tokLabels.name && token.end === nextToken.start) {
i++;
nextToken.type = "PrivateIdentifier";
nextToken.start -= 1;
nextToken.loc.start.column -= 1;
nextToken.range = [nextToken.start, nextToken.end];
result.push(nextToken);
continue;
}
}
}
result.push(convertToken(token, code, tokLabels));
}
return result;
};
//# sourceMappingURL=convertTokens.cjs.map

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,25 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.convertError = convertError;
exports.convertFile = convertFile;
const convertTokens = require("./convertTokens.cjs");
const convertComments = require("./convertComments.cjs");
const convertAST = require("./convertAST.cjs");
function convertFile(ast, code, tokLabels, visitorKeys) {
ast.tokens = convertTokens(ast.tokens, code, tokLabels);
convertComments(ast.comments);
convertAST(ast, visitorKeys);
return ast;
}
function convertError(err) {
if (err instanceof SyntaxError) {
err.lineNumber = err.loc.line;
err.column = err.loc.column;
}
return err;
}
//# sourceMappingURL=index.cjs.map

View File

@ -0,0 +1 @@
{"version":3,"names":["convertTokens","require","convertComments","convertAST","convertFile","ast","code","tokLabels","visitorKeys","tokens","comments","convertError","err","SyntaxError","lineNumber","loc","line","column"],"sources":["../../src/convert/index.cts"],"sourcesContent":["import convertTokens = require(\"./convertTokens.cts\");\nimport convertComments = require(\"./convertComments.cts\");\nimport convertAST = require(\"./convertAST.cts\");\nimport type { AST, ParseResult } from \"../types.cts\";\n\nexport function convertFile(\n ast: ParseResult,\n code: string,\n tokLabels: Record<string, any>,\n visitorKeys: Record<string, string[]>,\n) {\n ast.tokens = convertTokens(ast.tokens as any, code, tokLabels);\n convertComments(ast.comments);\n convertAST(ast, visitorKeys);\n return ast as unknown as AST.Program;\n}\n\nexport function convertError(err: Error) {\n if (err instanceof SyntaxError) {\n // @ts-expect-error eslint\n err.lineNumber = err.loc.line;\n // @ts-expect-error eslint\n err.column = err.loc.column;\n }\n return err;\n}\n"],"mappings":";;;;;;;MAAOA,aAAa,GAAAC,OAAA,CAAW,qBAAqB;AAAA,MAC7CC,eAAe,GAAAD,OAAA,CAAW,uBAAuB;AAAA,MACjDE,UAAU,GAAAF,OAAA,CAAW,kBAAkB;AAGvC,SAASG,WAAWA,CACzBC,GAAgB,EAChBC,IAAY,EACZC,SAA8B,EAC9BC,WAAqC,EACrC;EACAH,GAAG,CAACI,MAAM,GAAGT,aAAa,CAACK,GAAG,CAACI,MAAM,EAASH,IAAI,EAAEC,SAAS,CAAC;EAC9DL,eAAe,CAACG,GAAG,CAACK,QAAQ,CAAC;EAC7BP,UAAU,CAACE,GAAG,EAAEG,WAAW,CAAC;EAC5B,OAAOH,GAAG;AACZ;AAEO,SAASM,YAAYA,CAACC,GAAU,EAAE;EACvC,IAAIA,GAAG,YAAYC,WAAW,EAAE;IAE9BD,GAAG,CAACE,UAAU,GAAGF,GAAG,CAACG,GAAG,CAACC,IAAI;IAE7BJ,GAAG,CAACK,MAAM,GAAGL,GAAG,CAACG,GAAG,CAACE,MAAM;EAC7B;EACA,OAAOL,GAAG;AACZ","ignoreList":[]}

View File

@ -0,0 +1,32 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.meta = void 0;
exports.parseForESLint = parseForESLint;
const [major, minor] = process.versions.node.split(".").map(Number);
if (major < 12 || major === 12 && minor < 3) {
throw new Error("@babel/eslint-parser/experimental-worker requires Node.js >= 12.3.0");
}
const normalizeESLintConfig = require("./configuration.cjs");
const analyzeScope = require("./analyze-scope.cjs");
const baseParse = require("./parse.cjs");
const Clients = require("./client.cjs");
const client = new Clients.WorkerClient();
const meta = exports.meta = {
name: "@babel/eslint-parser/experimental-worker",
version: "7.27.5"
};
function parseForESLint(code, options = {}) {
const normalizedOptions = normalizeESLintConfig(options);
const ast = baseParse(code, normalizedOptions, client);
const scopeManager = analyzeScope(ast, normalizedOptions, client);
return {
ast,
scopeManager,
visitorKeys: client.getVisitorKeys()
};
}
//# sourceMappingURL=experimental-worker.cjs.map

View File

@ -0,0 +1 @@
{"version":3,"names":["major","minor","process","versions","node","split","map","Number","Error","normalizeESLintConfig","require","analyzeScope","baseParse","Clients","client","WorkerClient","meta","exports","name","version","parseForESLint","code","options","normalizedOptions","ast","scopeManager","visitorKeys","getVisitorKeys"],"sources":["../src/experimental-worker.cts"],"sourcesContent":["const [major, minor] = process.versions.node.split(\".\").map(Number);\n\nif (major < 12 || (major === 12 && minor < 3)) {\n throw new Error(\n \"@babel/eslint-parser/experimental-worker requires Node.js >= 12.3.0\",\n );\n}\n\nimport normalizeESLintConfig = require(\"./configuration.cts\");\nimport analyzeScope = require(\"./analyze-scope.cts\");\nimport baseParse = require(\"./parse.cts\");\n\nimport Clients = require(\"./client.cts\");\n\nconst client = new Clients.WorkerClient();\n\nexport const meta = {\n name: \"@babel/eslint-parser/experimental-worker\",\n version: PACKAGE_JSON.version,\n};\n\nexport function parseForESLint(code: string, options = {}) {\n const normalizedOptions = normalizeESLintConfig(options);\n const ast = baseParse(code, normalizedOptions, client);\n const scopeManager = analyzeScope(ast, normalizedOptions, client);\n\n return { ast, scopeManager, visitorKeys: client.getVisitorKeys() };\n}\n"],"mappings":";;;;;;;AAAA,MAAM,CAACA,KAAK,EAAEC,KAAK,CAAC,GAAGC,OAAO,CAACC,QAAQ,CAACC,IAAI,CAACC,KAAK,CAAC,GAAG,CAAC,CAACC,GAAG,CAACC,MAAM,CAAC;AAEnE,IAAIP,KAAK,GAAG,EAAE,IAAKA,KAAK,KAAK,EAAE,IAAIC,KAAK,GAAG,CAAE,EAAE;EAC7C,MAAM,IAAIO,KAAK,CACb,qEACF,CAAC;AACH;AAAC,MAEMC,qBAAqB,GAAAC,OAAA,CAAW,qBAAqB;AAAA,MACrDC,YAAY,GAAAD,OAAA,CAAW,qBAAqB;AAAA,MAC5CE,SAAS,GAAAF,OAAA,CAAW,aAAa;AAAA,MAEjCG,OAAO,GAAAH,OAAA,CAAW,cAAc;AAEvC,MAAMI,MAAM,GAAG,IAAID,OAAO,CAACE,YAAY,CAAC,CAAC;AAElC,MAAMC,IAAI,GAAAC,OAAA,CAAAD,IAAA,GAAG;EAClBE,IAAI,EAAE,0CAA0C;EAChDC,OAAO;AACT,CAAC;AAEM,SAASC,cAAcA,CAACC,IAAY,EAAEC,OAAO,GAAG,CAAC,CAAC,EAAE;EACzD,MAAMC,iBAAiB,GAAGd,qBAAqB,CAACa,OAAO,CAAC;EACxD,MAAME,GAAG,GAAGZ,SAAS,CAACS,IAAI,EAAEE,iBAAiB,EAAET,MAAM,CAAC;EACtD,MAAMW,YAAY,GAAGd,YAAY,CAACa,GAAG,EAAED,iBAAiB,EAAET,MAAM,CAAC;EAEjE,OAAO;IAAEU,GAAG;IAAEC,YAAY;IAAEC,WAAW,EAAEZ,MAAM,CAACa,cAAc,CAAC;EAAE,CAAC;AACpE","ignoreList":[]}

View File

@ -0,0 +1,32 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.meta = void 0;
exports.parse = parse;
exports.parseForESLint = parseForESLint;
var _client = require("./client.cjs");
const normalizeESLintConfig = require("./configuration.cjs");
const analyzeScope = require("./analyze-scope.cjs");
const baseParse = require("./parse.cjs");
const client = new _client.LocalClient();
const meta = exports.meta = {
name: "@babel/eslint-parser",
version: "7.27.5"
};
function parse(code, options = {}) {
return baseParse(code, normalizeESLintConfig(options), client);
}
function parseForESLint(code, options = {}) {
const normalizedOptions = normalizeESLintConfig(options);
const ast = baseParse(code, normalizedOptions, client);
const scopeManager = analyzeScope(ast, normalizedOptions, client);
return {
ast,
scopeManager,
visitorKeys: client.getVisitorKeys()
};
}
//# sourceMappingURL=index.cjs.map

View File

@ -0,0 +1 @@
{"version":3,"names":["_client","require","normalizeESLintConfig","analyzeScope","baseParse","client","LocalClient","meta","exports","name","version","parse","code","options","parseForESLint","normalizedOptions","ast","scopeManager","visitorKeys","getVisitorKeys"],"sources":["../src/index.cts"],"sourcesContent":["import normalizeESLintConfig = require(\"./configuration.cts\");\nimport analyzeScope = require(\"./analyze-scope.cts\");\nimport baseParse = require(\"./parse.cts\");\n\n// @ts-expect-error LocalClient only exists in the cjs build\nimport { LocalClient, WorkerClient } from \"./client.cts\";\nconst client = new (USE_ESM ? WorkerClient : LocalClient)();\n\nexport const meta = {\n name: PACKAGE_JSON.name,\n version: PACKAGE_JSON.version,\n};\n\nexport function parse(code: string, options = {}) {\n return baseParse(code, normalizeESLintConfig(options), client);\n}\n\nexport function parseForESLint(code: string, options = {}) {\n const normalizedOptions = normalizeESLintConfig(options);\n const ast = baseParse(code, normalizedOptions, client);\n const scopeManager = analyzeScope(ast, normalizedOptions, client);\n\n return { ast, scopeManager, visitorKeys: client.getVisitorKeys() };\n}\n"],"mappings":";;;;;;;;AAKA,IAAAA,OAAA,GAAAC,OAAA;AAAyD,MALlDC,qBAAqB,GAAAD,OAAA,CAAW,qBAAqB;AAAA,MACrDE,YAAY,GAAAF,OAAA,CAAW,qBAAqB;AAAA,MAC5CG,SAAS,GAAAH,OAAA,CAAW,aAAa;AAIxC,MAAMI,MAAM,GAAG,IAA8BC,mBAAW,CAAE,CAAC;AAEpD,MAAMC,IAAI,GAAAC,OAAA,CAAAD,IAAA,GAAG;EAClBE,IAAI,wBAAmB;EACvBC,OAAO;AACT,CAAC;AAEM,SAASC,KAAKA,CAACC,IAAY,EAAEC,OAAO,GAAG,CAAC,CAAC,EAAE;EAChD,OAAOT,SAAS,CAACQ,IAAI,EAAEV,qBAAqB,CAACW,OAAO,CAAC,EAAER,MAAM,CAAC;AAChE;AAEO,SAASS,cAAcA,CAACF,IAAY,EAAEC,OAAO,GAAG,CAAC,CAAC,EAAE;EACzD,MAAME,iBAAiB,GAAGb,qBAAqB,CAACW,OAAO,CAAC;EACxD,MAAMG,GAAG,GAAGZ,SAAS,CAACQ,IAAI,EAAEG,iBAAiB,EAAEV,MAAM,CAAC;EACtD,MAAMY,YAAY,GAAGd,YAAY,CAACa,GAAG,EAAED,iBAAiB,EAAEV,MAAM,CAAC;EAEjE,OAAO;IAAEW,GAAG;IAAEC,YAAY;IAAEC,WAAW,EAAEb,MAAM,CAACc,cAAc,CAAC;EAAE,CAAC;AACpE","ignoreList":[]}

View File

@ -0,0 +1,37 @@
"use strict";
const semver = require("semver");
const convert = require("./convert/index.cjs");
const babelParser = require((((v, w) => (v = v.split("."), w = w.split("."), +v[0] > +w[0] || v[0] == w[0] && +v[1] >= +w[1]))(process.versions.node, "8.9") ? require.resolve : (r, {
paths: [b]
}, M = require("module")) => {
let f = M._findPath(r, M._nodeModulePaths(b).concat(b));
if (f) return f;
f = new Error(`Cannot resolve module '${r}'`);
f.code = "MODULE_NOT_FOUND";
throw f;
})("@babel/parser", {
paths: [require.resolve("@babel/core/package.json")]
}));
let isRunningMinSupportedCoreVersion = null;
module.exports = function parse(code, options, client) {
const minSupportedCoreVersion = ">=7.2.0";
if (typeof isRunningMinSupportedCoreVersion !== "boolean") {
isRunningMinSupportedCoreVersion = semver.satisfies(client.getVersion(), minSupportedCoreVersion);
}
if (!isRunningMinSupportedCoreVersion) {
throw new Error(`@babel/eslint-parser@${"7.27.5"} does not support @babel/core@${client.getVersion()}. Please upgrade to @babel/core@${minSupportedCoreVersion}.`);
}
const {
ast,
parserOptions
} = client.maybeParse(code, options);
if (ast) return ast;
try {
return convert.convertFile(babelParser.parse(code, parserOptions), code, client.getTokLabels(), client.getVisitorKeys());
} catch (err) {
throw convert.convertError(err);
}
};
//# sourceMappingURL=parse.cjs.map

View File

@ -0,0 +1 @@
{"version":3,"names":["semver","require","convert","babelParser","v","w","split","process","versions","node","resolve","r","paths","b","M","f","_findPath","_nodeModulePaths","concat","Error","code","isRunningMinSupportedCoreVersion","module","exports","parse","options","client","minSupportedCoreVersion","satisfies","getVersion","ast","parserOptions","maybeParse","convertFile","getTokLabels","getVisitorKeys","err","convertError"],"sources":["../src/parse.cts"],"sourcesContent":["\"use strict\";\n\nimport semver = require(\"semver\");\nimport convert = require(\"./convert/index.cts\");\nimport type { Options } from \"./types.cts\";\nimport type { Client } from \"./client.cts\";\n\nconst babelParser = require(\n require.resolve(\"@babel/parser\", {\n paths: [require.resolve(\"@babel/core/package.json\")],\n }),\n);\n\nlet isRunningMinSupportedCoreVersion: boolean = null;\n\nexport = function parse(code: string, options: Options, client: Client) {\n // Ensure we're using a version of `@babel/core` that includes `parse()` and `tokTypes`.\n const minSupportedCoreVersion = REQUIRED_VERSION(\">=7.2.0\");\n\n if (typeof isRunningMinSupportedCoreVersion !== \"boolean\") {\n isRunningMinSupportedCoreVersion = semver.satisfies(\n client.getVersion(),\n minSupportedCoreVersion,\n );\n }\n\n if (!isRunningMinSupportedCoreVersion) {\n throw new Error(\n `@babel/eslint-parser@${\n PACKAGE_JSON.version\n } does not support @babel/core@${client.getVersion()}. Please upgrade to @babel/core@${minSupportedCoreVersion}.`,\n );\n }\n\n const { ast, parserOptions } = client.maybeParse(code, options);\n\n if (ast) return ast;\n\n try {\n return convert.convertFile(\n babelParser.parse(code, parserOptions),\n code,\n client.getTokLabels(),\n client.getVisitorKeys(),\n );\n } catch (err) {\n throw convert.convertError(err);\n }\n};\n"],"mappings":"AAAA,YAAY;;AAAC,MAENA,MAAM,GAAAC,OAAA,CAAW,QAAQ;AAAA,MACzBC,OAAO,GAAAD,OAAA,CAAW,qBAAqB;AAI9C,MAAME,WAAW,GAAGF,OAAO,CACzB,GAAAG,CAAA,EAAAC,CAAA,MAAAD,CAAA,GAAAA,CAAA,CAAAE,KAAA,OAAAD,CAAA,GAAAA,CAAA,CAAAC,KAAA,QAAAF,CAAA,OAAAC,CAAA,OAAAD,CAAA,OAAAC,CAAA,QAAAD,CAAA,QAAAC,CAAA,MAAAE,OAAA,CAAAC,QAAA,CAAAC,IAAA,WAAAR,OAAA,CAAAS,OAAA,IAAAC,CAAA;EAAAC,KAAA,GAAAC,CAAA;AAAA,GAAAC,CAAA,GAAAb,OAAA;EAAA,IAAAc,CAAA,GAAAD,CAAA,CAAAE,SAAA,CAAAL,CAAA,EAAAG,CAAA,CAAAG,gBAAA,CAAAJ,CAAA,EAAAK,MAAA,CAAAL,CAAA;EAAA,IAAAE,CAAA,SAAAA,CAAA;EAAAA,CAAA,OAAAI,KAAA,2BAAAR,CAAA;EAAAI,CAAA,CAAAK,IAAA;EAAA,MAAAL,CAAA;AAAA,GAAgB,eAAe,EAAE;EAC/BH,KAAK,EAAE,CAACX,OAAO,CAACS,OAAO,CAAC,0BAA0B,CAAC;AACrD,CAAC,CACH,CAAC;AAED,IAAIW,gCAAyC,GAAG,IAAI;AAACC,MAAA,CAAAC,OAAA,GAE5C,SAASC,KAAKA,CAACJ,IAAY,EAAEK,OAAgB,EAAEC,MAAc,EAAE;EAEtE,MAAMC,uBAAuB,GAAoB,SAAU;EAE3D,IAAI,OAAON,gCAAgC,KAAK,SAAS,EAAE;IACzDA,gCAAgC,GAAGrB,MAAM,CAAC4B,SAAS,CACjDF,MAAM,CAACG,UAAU,CAAC,CAAC,EACnBF,uBACF,CAAC;EACH;EAEA,IAAI,CAACN,gCAAgC,EAAE;IACrC,MAAM,IAAIF,KAAK,CACb,iEAEiCO,MAAM,CAACG,UAAU,CAAC,CAAC,mCAAmCF,uBAAuB,GAChH,CAAC;EACH;EAEA,MAAM;IAAEG,GAAG;IAAEC;EAAc,CAAC,GAAGL,MAAM,CAACM,UAAU,CAACZ,IAAI,EAAEK,OAAO,CAAC;EAE/D,IAAIK,GAAG,EAAE,OAAOA,GAAG;EAEnB,IAAI;IACF,OAAO5B,OAAO,CAAC+B,WAAW,CACxB9B,WAAW,CAACqB,KAAK,CAACJ,IAAI,EAAEW,aAAa,CAAC,EACtCX,IAAI,EACJM,MAAM,CAACQ,YAAY,CAAC,CAAC,EACrBR,MAAM,CAACS,cAAc,CAAC,CACxB,CAAC;EACH,CAAC,CAAC,OAAOC,GAAG,EAAE;IACZ,MAAMlC,OAAO,CAACmC,YAAY,CAACD,GAAG,CAAC;EACjC;AACF,CAAC","ignoreList":[]}

View File

@ -0,0 +1,5 @@
"use strict";
module.exports = parseInt(require("eslint/package.json").version, 10);
//# sourceMappingURL=eslint-version.cjs.map

View File

@ -0,0 +1 @@
{"version":3,"names":["parseInt","require","version"],"sources":["../../src/utils/eslint-version.cts"],"sourcesContent":["export = parseInt(require(\"eslint/package.json\").version, 10);\n"],"mappings":";;iBAASA,QAAQ,CAACC,OAAO,CAAC,qBAAqB,CAAC,CAACC,OAAO,EAAE,EAAE,CAAC","ignoreList":[]}

View File

@ -0,0 +1,38 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.getTokLabels = getTokLabels;
exports.getVisitorKeys = getVisitorKeys;
const _ESLINT_VISITOR_KEYS = require("eslint-visitor-keys");
const babel = require("./babel-core.cjs");
const ESLINT_VISITOR_KEYS = _ESLINT_VISITOR_KEYS.KEYS;
let visitorKeys;
function getVisitorKeys() {
if (!visitorKeys) {
const newTypes = {
ChainExpression: ESLINT_VISITOR_KEYS.ChainExpression,
ImportExpression: ESLINT_VISITOR_KEYS.ImportExpression,
Literal: ESLINT_VISITOR_KEYS.Literal,
MethodDefinition: ["decorators"].concat(ESLINT_VISITOR_KEYS.MethodDefinition),
Property: ["decorators"].concat(ESLINT_VISITOR_KEYS.Property),
PropertyDefinition: ["decorators", "typeAnnotation"].concat(ESLINT_VISITOR_KEYS.PropertyDefinition)
};
const conflictTypes = {
ExportAllDeclaration: ESLINT_VISITOR_KEYS.ExportAllDeclaration
};
visitorKeys = Object.assign({}, newTypes, babel.types.VISITOR_KEYS, conflictTypes, {
ClassPrivateMethod: ["decorators"].concat(ESLINT_VISITOR_KEYS.MethodDefinition)
});
}
return visitorKeys;
}
let tokLabels;
function getTokLabels() {
return tokLabels || (tokLabels = (p => p.reduce((o, [k, v]) => Object.assign({}, o, {
[k]: v
}), {}))((Object.entries || (o => Object.keys(o).map(k => [k, o[k]])))(babel.tokTypes).map(([key, tok]) => [key, tok.label])));
}
//# sourceMappingURL=ast-info.cjs.map

View File

@ -0,0 +1 @@
{"version":3,"names":["_ESLINT_VISITOR_KEYS","require","babel","ESLINT_VISITOR_KEYS","KEYS","visitorKeys","getVisitorKeys","newTypes","ChainExpression","ImportExpression","Literal","MethodDefinition","concat","Property","PropertyDefinition","conflictTypes","ExportAllDeclaration","Object","assign","types","VISITOR_KEYS","ClassPrivateMethod","tokLabels","getTokLabels","p","reduce","o","k","v","entries","keys","map","tokTypes","key","tok","label"],"sources":["../../src/worker/ast-info.cts"],"sourcesContent":["// @ts-expect-error no types\nimport _ESLINT_VISITOR_KEYS = require(\"eslint-visitor-keys\");\nimport babel = require(\"./babel-core.cts\");\n\nconst ESLINT_VISITOR_KEYS = _ESLINT_VISITOR_KEYS.KEYS;\n\nlet visitorKeys: Record<string, string[]>;\nexport function getVisitorKeys() {\n if (!visitorKeys) {\n // AST Types that are not presented in Babel AST\n const newTypes = {\n ChainExpression: ESLINT_VISITOR_KEYS.ChainExpression,\n ImportExpression: ESLINT_VISITOR_KEYS.ImportExpression,\n Literal: ESLINT_VISITOR_KEYS.Literal,\n MethodDefinition: [\"decorators\"].concat(\n ESLINT_VISITOR_KEYS.MethodDefinition,\n ),\n Property: [\"decorators\"].concat(ESLINT_VISITOR_KEYS.Property),\n PropertyDefinition: [\"decorators\", \"typeAnnotation\"].concat(\n ESLINT_VISITOR_KEYS.PropertyDefinition,\n ),\n };\n\n // AST Types that shares `\"type\"` property with Babel but have different shape\n const conflictTypes = {\n ExportAllDeclaration: ESLINT_VISITOR_KEYS.ExportAllDeclaration,\n };\n\n visitorKeys = {\n ...newTypes,\n ...babel.types.VISITOR_KEYS,\n ...conflictTypes,\n ...(process.env.BABEL_8_BREAKING\n ? {}\n : {\n ClassPrivateMethod: [\"decorators\"].concat(\n ESLINT_VISITOR_KEYS.MethodDefinition,\n ),\n }),\n };\n }\n return visitorKeys;\n}\n\nlet tokLabels;\nexport function getTokLabels() {\n return (tokLabels ||= (\n process.env.BABEL_8_BREAKING\n ? Object.fromEntries\n : (p: any[]) => p.reduce((o, [k, v]) => ({ ...o, [k]: v }), {})\n )(Object.entries(babel.tokTypes).map(([key, tok]) => [key, tok.label])));\n}\n"],"mappings":";;;;;;;MACOA,oBAAoB,GAAAC,OAAA,CAAW,qBAAqB;AAAA,MACpDC,KAAK,GAAAD,OAAA,CAAW,kBAAkB;AAEzC,MAAME,mBAAmB,GAAGH,oBAAoB,CAACI,IAAI;AAErD,IAAIC,WAAqC;AAClC,SAASC,cAAcA,CAAA,EAAG;EAC/B,IAAI,CAACD,WAAW,EAAE;IAEhB,MAAME,QAAQ,GAAG;MACfC,eAAe,EAAEL,mBAAmB,CAACK,eAAe;MACpDC,gBAAgB,EAAEN,mBAAmB,CAACM,gBAAgB;MACtDC,OAAO,EAAEP,mBAAmB,CAACO,OAAO;MACpCC,gBAAgB,EAAE,CAAC,YAAY,CAAC,CAACC,MAAM,CACrCT,mBAAmB,CAACQ,gBACtB,CAAC;MACDE,QAAQ,EAAE,CAAC,YAAY,CAAC,CAACD,MAAM,CAACT,mBAAmB,CAACU,QAAQ,CAAC;MAC7DC,kBAAkB,EAAE,CAAC,YAAY,EAAE,gBAAgB,CAAC,CAACF,MAAM,CACzDT,mBAAmB,CAACW,kBACtB;IACF,CAAC;IAGD,MAAMC,aAAa,GAAG;MACpBC,oBAAoB,EAAEb,mBAAmB,CAACa;IAC5C,CAAC;IAEDX,WAAW,GAAAY,MAAA,CAAAC,MAAA,KACNX,QAAQ,EACRL,KAAK,CAACiB,KAAK,CAACC,YAAY,EACxBL,aAAa,EAGZ;MACEM,kBAAkB,EAAE,CAAC,YAAY,CAAC,CAACT,MAAM,CACvCT,mBAAmB,CAACQ,gBACtB;IACF,CAAC,CACN;EACH;EACA,OAAON,WAAW;AACpB;AAEA,IAAIiB,SAAS;AACN,SAASC,YAAYA,CAAA,EAAG;EAC7B,OAAQD,SAAS,KAATA,SAAS,GAAK,CAGfE,CAAQ,IAAKA,CAAC,CAACC,MAAM,CAAC,CAACC,CAAC,EAAE,CAACC,CAAC,EAAEC,CAAC,CAAC,KAAAX,MAAA,CAAAC,MAAA,KAAWQ,CAAC;IAAE,CAACC,CAAC,GAAGC;EAAC,EAAG,EAAE,CAAC,CAAC,CAAC,EACjE,CAAAX,MAAA,CAAAY,OAAA,KAAAH,CAAA,IAAAT,MAAA,CAAAa,IAAA,CAAAJ,CAAA,EAAAK,GAAA,CAAAJ,CAAA,KAAAA,CAAA,EAAAD,CAAA,CAAAC,CAAA,MAAezB,KAAK,CAAC8B,QAAQ,CAAC,CAACD,GAAG,CAAC,CAAC,CAACE,GAAG,EAAEC,GAAG,CAAC,KAAK,CAACD,GAAG,EAAEC,GAAG,CAACC,KAAK,CAAC,CAAC,CAAC;AACzE","ignoreList":[]}

View File

@ -0,0 +1,23 @@
"use strict";
module.exports = exports;
function initialize(babel) {
exports.init = null;
exports.version = babel.version;
exports.traverse = babel.traverse;
exports.types = babel.types;
exports.tokTypes = babel.tokTypes;
exports.parseSync = babel.parseSync;
exports.parseAsync = babel.parseAsync;
exports.loadPartialConfigSync = babel.loadPartialConfigSync;
exports.loadPartialConfigAsync = babel.loadPartialConfigAsync;
exports.createConfigItemAsync = babel.createConfigItemAsync;
{
exports.createConfigItemSync = babel.createConfigItemSync || babel.createConfigItem;
}
}
{
initialize(require("@babel/core"));
}
//# sourceMappingURL=babel-core.cjs.map

View File

@ -0,0 +1 @@
{"version":3,"names":["exports","initialize","babel","init","version","traverse","types","tokTypes","parseSync","parseAsync","loadPartialConfigSync","loadPartialConfigAsync","createConfigItemAsync","createConfigItemSync","createConfigItem","require"],"sources":["../../src/worker/babel-core.cts"],"sourcesContent":["export = exports as typeof import(\"@babel/core\") & {\n init: Promise<void> | null;\n};\n\nfunction initialize(babel: typeof import(\"@babel/core\")) {\n exports.init = null;\n exports.version = babel.version;\n exports.traverse = babel.traverse;\n exports.types = babel.types;\n exports.tokTypes = babel.tokTypes;\n exports.parseSync = babel.parseSync;\n exports.parseAsync = babel.parseAsync;\n exports.loadPartialConfigSync = babel.loadPartialConfigSync;\n exports.loadPartialConfigAsync = babel.loadPartialConfigAsync;\n exports.createConfigItemAsync = babel.createConfigItemAsync;\n\n if (process.env.BABEL_8_BREAKING) {\n exports.createConfigItemSync = babel.createConfigItemSync;\n } else {\n // babel.createConfigItemSync is available on 7.13+\n // we support Babel 7.11+\n exports.createConfigItemSync =\n babel.createConfigItemSync || babel.createConfigItem;\n }\n}\n\nif (USE_ESM) {\n exports.init = import(\"@babel/core\").then(initialize);\n} else {\n initialize(require(\"@babel/core\"));\n}\n"],"mappings":";;iBAASA,OAAO;AAIhB,SAASC,UAAUA,CAACC,KAAmC,EAAE;EACvDF,OAAO,CAACG,IAAI,GAAG,IAAI;EACnBH,OAAO,CAACI,OAAO,GAAGF,KAAK,CAACE,OAAO;EAC/BJ,OAAO,CAACK,QAAQ,GAAGH,KAAK,CAACG,QAAQ;EACjCL,OAAO,CAACM,KAAK,GAAGJ,KAAK,CAACI,KAAK;EAC3BN,OAAO,CAACO,QAAQ,GAAGL,KAAK,CAACK,QAAQ;EACjCP,OAAO,CAACQ,SAAS,GAAGN,KAAK,CAACM,SAAS;EACnCR,OAAO,CAACS,UAAU,GAAGP,KAAK,CAACO,UAAU;EACrCT,OAAO,CAACU,qBAAqB,GAAGR,KAAK,CAACQ,qBAAqB;EAC3DV,OAAO,CAACW,sBAAsB,GAAGT,KAAK,CAACS,sBAAsB;EAC7DX,OAAO,CAACY,qBAAqB,GAAGV,KAAK,CAACU,qBAAqB;EAIpD;IAGLZ,OAAO,CAACa,oBAAoB,GAC1BX,KAAK,CAACW,oBAAoB,IAAIX,KAAK,CAACY,gBAAgB;EACxD;AACF;AAIO;EACLb,UAAU,CAACc,OAAO,CAAC,aAAa,CAAC,CAAC;AACpC","ignoreList":[]}

View File

@ -0,0 +1,91 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.normalizeBabelParseConfig = normalizeBabelParseConfig;
exports.normalizeBabelParseConfigSync = normalizeBabelParseConfigSync;
function asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); }
function _asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { asyncGeneratorStep(a, r, o, _next, _throw, "next", n); } function _throw(n) { asyncGeneratorStep(a, r, o, _next, _throw, "throw", n); } _next(void 0); }); }; }
const babel = require("./babel-core.cjs");
const ESLINT_VERSION = require("../utils/eslint-version.cjs");
function getParserPlugins(babelOptions) {
var _babelOptions$parserO, _babelOptions$parserO2;
const babelParserPlugins = (_babelOptions$parserO = (_babelOptions$parserO2 = babelOptions.parserOpts) == null ? void 0 : _babelOptions$parserO2.plugins) != null ? _babelOptions$parserO : [];
const estreeOptions = {
classFeatures: ESLINT_VERSION >= 8
};
for (const plugin of babelParserPlugins) {
if (Array.isArray(plugin) && plugin[0] === "estree") {
Object.assign(estreeOptions, plugin[1]);
break;
}
}
return [["estree", estreeOptions], ...babelParserPlugins];
}
function normalizeParserOptions(options) {
var _options$allowImportE, _options$ecmaFeatures, _options$ecmaFeatures2;
return Object.assign({
sourceType: options.sourceType,
filename: options.filePath
}, options.babelOptions, {
parserOpts: Object.assign({}, {
allowImportExportEverywhere: (_options$allowImportE = options.allowImportExportEverywhere) != null ? _options$allowImportE : false,
allowSuperOutsideMethod: true
}, {
allowReturnOutsideFunction: (_options$ecmaFeatures = (_options$ecmaFeatures2 = options.ecmaFeatures) == null ? void 0 : _options$ecmaFeatures2.globalReturn) != null ? _options$ecmaFeatures : true
}, options.babelOptions.parserOpts, {
plugins: getParserPlugins(options.babelOptions),
attachComment: false,
ranges: true,
tokens: true
}),
caller: Object.assign({
name: "@babel/eslint-parser"
}, options.babelOptions.caller)
});
}
function validateResolvedConfig(config, options, parseOptions) {
if (config !== null) {
if (options.requireConfigFile !== false) {
if (!config.hasFilesystemConfig()) {
let error = `No Babel config file detected for ${config.options.filename}. Either disable config file checking with requireConfigFile: false, or configure Babel so that it can find the config files.`;
if (config.options.filename.includes("node_modules")) {
error += `\nIf you have a .babelrc.js file or use package.json#babel, keep in mind that it's not used when parsing dependencies. If you want your config to be applied to your whole app, consider using babel.config.js or babel.config.json instead.`;
}
throw new Error(error);
}
}
if (config.options) return config.options;
}
return getDefaultParserOptions(parseOptions);
}
function getDefaultParserOptions(options) {
return Object.assign({
plugins: []
}, options, {
babelrc: false,
configFile: false,
browserslistConfigFile: false,
ignore: null,
only: null
});
}
function normalizeBabelParseConfig(_x) {
return _normalizeBabelParseConfig.apply(this, arguments);
}
function _normalizeBabelParseConfig() {
_normalizeBabelParseConfig = _asyncToGenerator(function* (options) {
const parseOptions = normalizeParserOptions(options);
const config = yield babel.loadPartialConfigAsync(parseOptions);
return validateResolvedConfig(config, options, parseOptions);
});
return _normalizeBabelParseConfig.apply(this, arguments);
}
function normalizeBabelParseConfigSync(options) {
const parseOptions = normalizeParserOptions(options);
const config = babel.loadPartialConfigSync(parseOptions);
return validateResolvedConfig(config, options, parseOptions);
}
//# sourceMappingURL=configuration.cjs.map

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,11 @@
"use strict";
module.exports = function extractParserOptionsPlugin() {
return {
parserOverride(code, opts) {
return opts;
}
};
};
//# sourceMappingURL=extract-parser-options-plugin.cjs.map

View File

@ -0,0 +1 @@
{"version":3,"names":["extractParserOptionsPlugin","parserOverride","code","opts"],"sources":["../../src/worker/extract-parser-options-plugin.cts"],"sourcesContent":["export = function extractParserOptionsPlugin() {\n return {\n parserOverride(code: string, opts: any) {\n return opts;\n },\n };\n};\n"],"mappings":";;iBAAS,SAASA,0BAA0BA,CAAA,EAAG;EAC7C,OAAO;IACLC,cAAcA,CAACC,IAAY,EAAEC,IAAS,EAAE;MACtC,OAAOA,IAAI;IACb;EACF,CAAC;AACH,CAAC","ignoreList":[]}

View File

@ -0,0 +1,33 @@
"use strict";
const babel = require("./babel-core.cjs");
const maybeParse = require("./maybeParse.cjs");
const maybeParseSync = require("./maybeParseSync.cjs");
const astInfo = require("./ast-info.cjs");
const config = require("./configuration.cjs");
const Clients = require("../client.cjs");
var ACTIONS = Clients.ACTIONS;
module.exports = function handleMessage(action, payload) {
switch (action) {
case ACTIONS.GET_VERSION:
return babel.version;
case ACTIONS.GET_TYPES_INFO:
return {
FLOW_FLIPPED_ALIAS_KEYS: babel.types.FLIPPED_ALIAS_KEYS.Flow,
VISITOR_KEYS: babel.types.VISITOR_KEYS
};
case ACTIONS.GET_TOKEN_LABELS:
return astInfo.getTokLabels();
case ACTIONS.GET_VISITOR_KEYS:
return astInfo.getVisitorKeys();
case ACTIONS.MAYBE_PARSE:
return config.normalizeBabelParseConfig(payload.options).then(options => maybeParse(payload.code, options));
case ACTIONS.MAYBE_PARSE_SYNC:
{
return maybeParseSync(payload.code, config.normalizeBabelParseConfigSync(payload.options));
}
}
throw new Error(`Unknown internal parser worker action: ${action}`);
};
//# sourceMappingURL=handle-message.cjs.map

View File

@ -0,0 +1 @@
{"version":3,"names":["babel","require","maybeParse","maybeParseSync","astInfo","config","Clients","ACTIONS","module","exports","handleMessage","action","payload","GET_VERSION","version","GET_TYPES_INFO","FLOW_FLIPPED_ALIAS_KEYS","types","FLIPPED_ALIAS_KEYS","Flow","VISITOR_KEYS","GET_TOKEN_LABELS","getTokLabels","GET_VISITOR_KEYS","getVisitorKeys","MAYBE_PARSE","normalizeBabelParseConfig","options","then","code","MAYBE_PARSE_SYNC","normalizeBabelParseConfigSync","Error"],"sources":["../../src/worker/handle-message.cts"],"sourcesContent":["import babel = require(\"./babel-core.cts\");\nimport maybeParse = require(\"./maybeParse.cts\");\nimport maybeParseSync = require(\"./maybeParseSync.cts\");\nimport astInfo = require(\"./ast-info.cts\");\nimport config = require(\"./configuration.cts\");\n\nimport Clients = require(\"../client.cts\");\nimport ACTIONS = Clients.ACTIONS;\n\nexport = function handleMessage(action: ACTIONS, payload: any) {\n switch (action) {\n case ACTIONS.GET_VERSION:\n return babel.version;\n case ACTIONS.GET_TYPES_INFO:\n return {\n FLOW_FLIPPED_ALIAS_KEYS: babel.types.FLIPPED_ALIAS_KEYS.Flow,\n VISITOR_KEYS: babel.types.VISITOR_KEYS,\n };\n case ACTIONS.GET_TOKEN_LABELS:\n return astInfo.getTokLabels();\n case ACTIONS.GET_VISITOR_KEYS:\n return astInfo.getVisitorKeys();\n case ACTIONS.MAYBE_PARSE:\n return config\n .normalizeBabelParseConfig(payload.options)\n .then(options => maybeParse(payload.code, options));\n case ACTIONS.MAYBE_PARSE_SYNC:\n if (!USE_ESM) {\n return maybeParseSync(\n payload.code,\n config.normalizeBabelParseConfigSync(payload.options),\n );\n }\n }\n\n throw new Error(`Unknown internal parser worker action: ${action}`);\n};\n"],"mappings":";;MAAOA,KAAK,GAAAC,OAAA,CAAW,kBAAkB;AAAA,MAClCC,UAAU,GAAAD,OAAA,CAAW,kBAAkB;AAAA,MACvCE,cAAc,GAAAF,OAAA,CAAW,sBAAsB;AAAA,MAC/CG,OAAO,GAAAH,OAAA,CAAW,gBAAgB;AAAA,MAClCI,MAAM,GAAAJ,OAAA,CAAW,qBAAqB;AAAA,MAEtCK,OAAO,GAAAL,OAAA,CAAW,eAAe;AAAA,IACjCM,OAAO,GAAGD,OAAO,CAACC,OAAO;AAAAC,MAAA,CAAAC,OAAA,GAEvB,SAASC,aAAaA,CAACC,MAAe,EAAEC,OAAY,EAAE;EAC7D,QAAQD,MAAM;IACZ,KAAKJ,OAAO,CAACM,WAAW;MACtB,OAAOb,KAAK,CAACc,OAAO;IACtB,KAAKP,OAAO,CAACQ,cAAc;MACzB,OAAO;QACLC,uBAAuB,EAAEhB,KAAK,CAACiB,KAAK,CAACC,kBAAkB,CAACC,IAAI;QAC5DC,YAAY,EAAEpB,KAAK,CAACiB,KAAK,CAACG;MAC5B,CAAC;IACH,KAAKb,OAAO,CAACc,gBAAgB;MAC3B,OAAOjB,OAAO,CAACkB,YAAY,CAAC,CAAC;IAC/B,KAAKf,OAAO,CAACgB,gBAAgB;MAC3B,OAAOnB,OAAO,CAACoB,cAAc,CAAC,CAAC;IACjC,KAAKjB,OAAO,CAACkB,WAAW;MACtB,OAAOpB,MAAM,CACVqB,yBAAyB,CAACd,OAAO,CAACe,OAAO,CAAC,CAC1CC,IAAI,CAACD,OAAO,IAAIzB,UAAU,CAACU,OAAO,CAACiB,IAAI,EAAEF,OAAO,CAAC,CAAC;IACvD,KAAKpB,OAAO,CAACuB,gBAAgB;MACb;QACZ,OAAO3B,cAAc,CACnBS,OAAO,CAACiB,IAAI,EACZxB,MAAM,CAAC0B,6BAA6B,CAACnB,OAAO,CAACe,OAAO,CACtD,CAAC;MACH;EACJ;EAEA,MAAM,IAAIK,KAAK,CAAC,0CAA0CrB,MAAM,EAAE,CAAC;AACrE,CAAC","ignoreList":[]}

View File

@ -0,0 +1,39 @@
"use strict";
function asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); }
function _asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { asyncGeneratorStep(a, r, o, _next, _throw, "next", n); } function _throw(n) { asyncGeneratorStep(a, r, o, _next, _throw, "throw", n); } _next(void 0); }); }; }
const babel = require("./babel-core.cjs");
const handleMessage = require("./handle-message.cjs");
const worker_threads = require("worker_threads");
worker_threads.parentPort.addListener("message", _asyncToGenerator(function* ({
signal,
port,
action,
payload
}) {
let response;
try {
if (babel.init) yield babel.init;
response = {
result: yield handleMessage(action, payload)
};
} catch (error) {
response = {
error,
errorData: Object.assign({}, error)
};
}
try {
port.postMessage(response);
} catch (_unused) {
port.postMessage({
error: new Error("Cannot serialize worker response")
});
} finally {
port.close();
Atomics.store(signal, 0, 1);
Atomics.notify(signal, 0);
}
}));
//# sourceMappingURL=index.cjs.map

View File

@ -0,0 +1 @@
{"version":3,"names":["babel","require","handleMessage","worker_threads","parentPort","addListener","_asyncToGenerator","signal","port","action","payload","response","init","result","error","errorData","Object","assign","postMessage","_unused","Error","close","Atomics","store","notify"],"sources":["../../src/worker/index.cts"],"sourcesContent":["import babel = require(\"./babel-core.cts\");\nimport handleMessage = require(\"./handle-message.cts\");\n\nimport worker_threads = require(\"worker_threads\");\n\nworker_threads.parentPort.addListener(\n \"message\",\n // eslint-disable-next-line @typescript-eslint/no-misused-promises\n async ({ signal, port, action, payload }) => {\n let response;\n\n try {\n if (babel.init) await babel.init;\n\n response = { result: await handleMessage(action, payload) };\n } catch (error) {\n response = { error, errorData: { ...error } };\n }\n\n try {\n port.postMessage(response);\n } catch {\n port.postMessage({\n error: new Error(\"Cannot serialize worker response\"),\n });\n } finally {\n port.close();\n Atomics.store(signal, 0, 1);\n Atomics.notify(signal, 0);\n }\n },\n);\n"],"mappings":";;;;MAAOA,KAAK,GAAAC,OAAA,CAAW,kBAAkB;AAAA,MAClCC,aAAa,GAAAD,OAAA,CAAW,sBAAsB;AAAA,MAE9CE,cAAc,GAAAF,OAAA,CAAW,gBAAgB;AAEhDE,cAAc,CAACC,UAAU,CAACC,WAAW,CACnC,SAAS,EAAAC,iBAAA,CAET,WAAO;EAAEC,MAAM;EAAEC,IAAI;EAAEC,MAAM;EAAEC;AAAQ,CAAC,EAAK;EAC3C,IAAIC,QAAQ;EAEZ,IAAI;IACF,IAAIX,KAAK,CAACY,IAAI,EAAE,MAAMZ,KAAK,CAACY,IAAI;IAEhCD,QAAQ,GAAG;MAAEE,MAAM,QAAQX,aAAa,CAACO,MAAM,EAAEC,OAAO;IAAE,CAAC;EAC7D,CAAC,CAAC,OAAOI,KAAK,EAAE;IACdH,QAAQ,GAAG;MAAEG,KAAK;MAAEC,SAAS,EAAAC,MAAA,CAAAC,MAAA,KAAOH,KAAK;IAAG,CAAC;EAC/C;EAEA,IAAI;IACFN,IAAI,CAACU,WAAW,CAACP,QAAQ,CAAC;EAC5B,CAAC,CAAC,OAAAQ,OAAA,EAAM;IACNX,IAAI,CAACU,WAAW,CAAC;MACfJ,KAAK,EAAE,IAAIM,KAAK,CAAC,kCAAkC;IACrD,CAAC,CAAC;EACJ,CAAC,SAAS;IACRZ,IAAI,CAACa,KAAK,CAAC,CAAC;IACZC,OAAO,CAACC,KAAK,CAAChB,MAAM,EAAE,CAAC,EAAE,CAAC,CAAC;IAC3Be,OAAO,CAACE,MAAM,CAACjB,MAAM,EAAE,CAAC,CAAC;EAC3B;AACF,CAAC,CACH,CAAC","ignoreList":[]}

View File

@ -0,0 +1,56 @@
"use strict";
function asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); }
function _asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { asyncGeneratorStep(a, r, o, _next, _throw, "next", n); } function _throw(n) { asyncGeneratorStep(a, r, o, _next, _throw, "throw", n); } _next(void 0); }); }; }
const babel = require("./babel-core.cjs");
const convert = require("../convert/index.cjs");
const astInfo = require("./ast-info.cjs");
const extractParserOptionsPlugin = require("./extract-parser-options-plugin.cjs");
const {
getVisitorKeys,
getTokLabels
} = astInfo;
const ref = {};
let extractParserOptionsConfigItem;
const MULTIPLE_OVERRIDES = /More than one plugin attempted to override parsing/;
module.exports = function () {
var _asyncMaybeParse = _asyncToGenerator(function* (code, options) {
if (!extractParserOptionsConfigItem) {
extractParserOptionsConfigItem = yield babel.createConfigItemAsync([extractParserOptionsPlugin, ref], {
dirname: __dirname,
type: "plugin"
});
}
const {
plugins
} = options;
options.plugins = plugins.concat(extractParserOptionsConfigItem);
let ast;
try {
return {
parserOptions: yield babel.parseAsync(code, options),
ast: null
};
} catch (err) {
if (!MULTIPLE_OVERRIDES.test(err.message)) {
throw err;
}
}
options.plugins = plugins;
try {
ast = yield babel.parseAsync(code, options);
} catch (err) {
throw convert.convertError(err);
}
return {
ast: convert.convertFile(ast, code, getTokLabels(), getVisitorKeys()),
parserOptions: null
};
});
function asyncMaybeParse(_x, _x2) {
return _asyncMaybeParse.apply(this, arguments);
}
return asyncMaybeParse;
}();
//# sourceMappingURL=maybeParse.cjs.map

View File

@ -0,0 +1 @@
{"version":3,"names":["babel","require","convert","astInfo","extractParserOptionsPlugin","getVisitorKeys","getTokLabels","ref","extractParserOptionsConfigItem","MULTIPLE_OVERRIDES","module","exports","_asyncMaybeParse","_asyncToGenerator","code","options","createConfigItemAsync","dirname","__dirname","type","plugins","concat","ast","parserOptions","parseAsync","err","test","message","convertError","convertFile","asyncMaybeParse","_x","_x2","apply","arguments"],"sources":["../../src/worker/maybeParse.cts"],"sourcesContent":["import babel = require(\"./babel-core.cts\");\nimport convert = require(\"../convert/index.cts\");\nimport astInfo = require(\"./ast-info.cts\");\nimport extractParserOptionsPlugin = require(\"./extract-parser-options-plugin.cjs\");\n\nimport type { InputOptions, ConfigItem } from \"@babel/core\";\nimport type { AST, ParseResult } from \"../types.cts\";\n\nconst { getVisitorKeys, getTokLabels } = astInfo;\n\nconst ref = {};\nlet extractParserOptionsConfigItem: ConfigItem<any>;\n\nconst MULTIPLE_OVERRIDES = /More than one plugin attempted to override parsing/;\n\nexport = async function asyncMaybeParse(\n code: string,\n options: InputOptions,\n): Promise<{\n ast: AST.Program | null;\n parserOptions: ParseResult | null;\n}> {\n if (!extractParserOptionsConfigItem) {\n extractParserOptionsConfigItem = await babel.createConfigItemAsync(\n [extractParserOptionsPlugin, ref],\n { dirname: __dirname, type: \"plugin\" },\n );\n }\n const { plugins } = options;\n options.plugins = plugins.concat(extractParserOptionsConfigItem);\n\n let ast;\n\n try {\n return {\n parserOptions: await babel.parseAsync(code, options),\n ast: null,\n };\n } catch (err) {\n if (!MULTIPLE_OVERRIDES.test(err.message)) {\n throw err;\n }\n }\n\n // There was already a parserOverride, so remove our plugin.\n options.plugins = plugins;\n\n try {\n ast = await babel.parseAsync(code, options);\n } catch (err) {\n throw convert.convertError(err);\n }\n\n return {\n ast: convert.convertFile(ast, code, getTokLabels(), getVisitorKeys()),\n parserOptions: null,\n };\n};\n"],"mappings":";;;;MAAOA,KAAK,GAAAC,OAAA,CAAW,kBAAkB;AAAA,MAClCC,OAAO,GAAAD,OAAA,CAAW,sBAAsB;AAAA,MACxCE,OAAO,GAAAF,OAAA,CAAW,gBAAgB;AAAA,MAClCG,0BAA0B,GAAAH,OAAA,CAAW,qCAAqC;AAKjF,MAAM;EAAEI,cAAc;EAAEC;AAAa,CAAC,GAAGH,OAAO;AAEhD,MAAMI,GAAG,GAAG,CAAC,CAAC;AACd,IAAIC,8BAA+C;AAEnD,MAAMC,kBAAkB,GAAG,oDAAoD;AAACC,MAAA,CAAAC,OAAA;EAAA,IAAAC,gBAAA,GAAAC,iBAAA,CAEvE,WACPC,IAAY,EACZC,OAAqB,EAIpB;IACD,IAAI,CAACP,8BAA8B,EAAE;MACnCA,8BAA8B,SAASR,KAAK,CAACgB,qBAAqB,CAChE,CAACZ,0BAA0B,EAAEG,GAAG,CAAC,EACjC;QAAEU,OAAO,EAAEC,SAAS;QAAEC,IAAI,EAAE;MAAS,CACvC,CAAC;IACH;IACA,MAAM;MAAEC;IAAQ,CAAC,GAAGL,OAAO;IAC3BA,OAAO,CAACK,OAAO,GAAGA,OAAO,CAACC,MAAM,CAACb,8BAA8B,CAAC;IAEhE,IAAIc,GAAG;IAEP,IAAI;MACF,OAAO;QACLC,aAAa,QAAQvB,KAAK,CAACwB,UAAU,CAACV,IAAI,EAAEC,OAAO,CAAC;QACpDO,GAAG,EAAE;MACP,CAAC;IACH,CAAC,CAAC,OAAOG,GAAG,EAAE;MACZ,IAAI,CAAChB,kBAAkB,CAACiB,IAAI,CAACD,GAAG,CAACE,OAAO,CAAC,EAAE;QACzC,MAAMF,GAAG;MACX;IACF;IAGAV,OAAO,CAACK,OAAO,GAAGA,OAAO;IAEzB,IAAI;MACFE,GAAG,SAAStB,KAAK,CAACwB,UAAU,CAACV,IAAI,EAAEC,OAAO,CAAC;IAC7C,CAAC,CAAC,OAAOU,GAAG,EAAE;MACZ,MAAMvB,OAAO,CAAC0B,YAAY,CAACH,GAAG,CAAC;IACjC;IAEA,OAAO;MACLH,GAAG,EAAEpB,OAAO,CAAC2B,WAAW,CAACP,GAAG,EAAER,IAAI,EAAER,YAAY,CAAC,CAAC,EAAED,cAAc,CAAC,CAAC,CAAC;MACrEkB,aAAa,EAAE;IACjB,CAAC;EACH,CAAC;EAAA,SA1CuBO,eAAeA,CAAAC,EAAA,EAAAC,GAAA;IAAA,OAAApB,gBAAA,CAAAqB,KAAA,OAAAC,SAAA;EAAA;EAAA,OAAfJ,eAAe;AAAA","ignoreList":[]}

View File

@ -0,0 +1,48 @@
"use strict";
const babel = require("./babel-core.cjs");
const convert = require("../convert/index.cjs");
const astInfo = require("./ast-info.cjs");
const extractParserOptionsPlugin = require("./extract-parser-options-plugin.cjs");
const {
getVisitorKeys,
getTokLabels
} = astInfo;
const ref = {};
let extractParserOptionsConfigItem;
const MULTIPLE_OVERRIDES = /More than one plugin attempted to override parsing/;
module.exports = function maybeParseSync(code, options) {
if (!extractParserOptionsConfigItem) {
extractParserOptionsConfigItem = babel.createConfigItemSync([extractParserOptionsPlugin, ref], {
dirname: __dirname,
type: "plugin"
});
}
const {
plugins
} = options;
options.plugins = plugins.concat(extractParserOptionsConfigItem);
let ast;
try {
return {
parserOptions: babel.parseSync(code, options),
ast: null
};
} catch (err) {
if (!MULTIPLE_OVERRIDES.test(err.message)) {
throw err;
}
}
options.plugins = plugins;
try {
ast = babel.parseSync(code, options);
} catch (err) {
throw convert.convertError(err);
}
return {
ast: convert.convertFile(ast, code, getTokLabels(), getVisitorKeys()),
parserOptions: null
};
};
//# sourceMappingURL=maybeParseSync.cjs.map

View File

@ -0,0 +1 @@
{"version":3,"names":["babel","require","convert","astInfo","extractParserOptionsPlugin","getVisitorKeys","getTokLabels","ref","extractParserOptionsConfigItem","MULTIPLE_OVERRIDES","module","exports","maybeParseSync","code","options","createConfigItemSync","dirname","__dirname","type","plugins","concat","ast","parserOptions","parseSync","err","test","message","convertError","convertFile"],"sources":["../../src/worker/maybeParseSync.cts"],"sourcesContent":["import babel = require(\"./babel-core.cts\");\nimport convert = require(\"../convert/index.cts\");\nimport astInfo = require(\"./ast-info.cts\");\nimport extractParserOptionsPlugin = require(\"./extract-parser-options-plugin.cjs\");\n\nimport type { InputOptions, ConfigItem } from \"@babel/core\";\nimport type { AST, ParseResult } from \"../types.cts\";\n\nconst { getVisitorKeys, getTokLabels } = astInfo;\n\nconst ref = {};\nlet extractParserOptionsConfigItem: ConfigItem<any>;\n\nconst MULTIPLE_OVERRIDES = /More than one plugin attempted to override parsing/;\n\nexport = function maybeParseSync(\n code: string,\n options: InputOptions,\n): {\n ast: AST.Program | null;\n parserOptions: ParseResult | null;\n} {\n if (!extractParserOptionsConfigItem) {\n extractParserOptionsConfigItem = babel.createConfigItemSync(\n [extractParserOptionsPlugin, ref],\n { dirname: __dirname, type: \"plugin\" },\n );\n }\n const { plugins } = options;\n options.plugins = plugins.concat(extractParserOptionsConfigItem);\n\n let ast;\n\n try {\n return {\n parserOptions: babel.parseSync(code, options),\n ast: null,\n };\n } catch (err) {\n if (!MULTIPLE_OVERRIDES.test(err.message)) {\n throw err;\n }\n }\n\n // There was already a parserOverride, so remove our plugin.\n options.plugins = plugins;\n\n try {\n ast = babel.parseSync(code, options);\n } catch (err) {\n throw convert.convertError(err);\n }\n\n return {\n ast: convert.convertFile(ast, code, getTokLabels(), getVisitorKeys()),\n parserOptions: null,\n };\n};\n"],"mappings":";;MAAOA,KAAK,GAAAC,OAAA,CAAW,kBAAkB;AAAA,MAClCC,OAAO,GAAAD,OAAA,CAAW,sBAAsB;AAAA,MACxCE,OAAO,GAAAF,OAAA,CAAW,gBAAgB;AAAA,MAClCG,0BAA0B,GAAAH,OAAA,CAAW,qCAAqC;AAKjF,MAAM;EAAEI,cAAc;EAAEC;AAAa,CAAC,GAAGH,OAAO;AAEhD,MAAMI,GAAG,GAAG,CAAC,CAAC;AACd,IAAIC,8BAA+C;AAEnD,MAAMC,kBAAkB,GAAG,oDAAoD;AAACC,MAAA,CAAAC,OAAA,GAEvE,SAASC,cAAcA,CAC9BC,IAAY,EACZC,OAAqB,EAIrB;EACA,IAAI,CAACN,8BAA8B,EAAE;IACnCA,8BAA8B,GAAGR,KAAK,CAACe,oBAAoB,CACzD,CAACX,0BAA0B,EAAEG,GAAG,CAAC,EACjC;MAAES,OAAO,EAAEC,SAAS;MAAEC,IAAI,EAAE;IAAS,CACvC,CAAC;EACH;EACA,MAAM;IAAEC;EAAQ,CAAC,GAAGL,OAAO;EAC3BA,OAAO,CAACK,OAAO,GAAGA,OAAO,CAACC,MAAM,CAACZ,8BAA8B,CAAC;EAEhE,IAAIa,GAAG;EAEP,IAAI;IACF,OAAO;MACLC,aAAa,EAAEtB,KAAK,CAACuB,SAAS,CAACV,IAAI,EAAEC,OAAO,CAAC;MAC7CO,GAAG,EAAE;IACP,CAAC;EACH,CAAC,CAAC,OAAOG,GAAG,EAAE;IACZ,IAAI,CAACf,kBAAkB,CAACgB,IAAI,CAACD,GAAG,CAACE,OAAO,CAAC,EAAE;MACzC,MAAMF,GAAG;IACX;EACF;EAGAV,OAAO,CAACK,OAAO,GAAGA,OAAO;EAEzB,IAAI;IACFE,GAAG,GAAGrB,KAAK,CAACuB,SAAS,CAACV,IAAI,EAAEC,OAAO,CAAC;EACtC,CAAC,CAAC,OAAOU,GAAG,EAAE;IACZ,MAAMtB,OAAO,CAACyB,YAAY,CAACH,GAAG,CAAC;EACjC;EAEA,OAAO;IACLH,GAAG,EAAEnB,OAAO,CAAC0B,WAAW,CAACP,GAAG,EAAER,IAAI,EAAEP,YAAY,CAAC,CAAC,EAAED,cAAc,CAAC,CAAC,CAAC;IACrEiB,aAAa,EAAE;EACjB,CAAC;AACH,CAAC","ignoreList":[]}