Files
NapCatQQ/.pnpm-store/v3/files/bc/a867fe538fd99b9841be280f22358c5d64c90c208cd11f5775bedb8525091173de47e03d584b3b3e7eec62634d8a2d5fe711d195ffca7e5d2a687f02d85f2a
T
TanTan e311ca3275
Build NapCat Artifacts / Type Check & Test (push) Waiting to run
docs: 仓库链接指向本镜像仓库
2026-11-13 09:25:58 +08:00

35 lines
1.3 KiB
Plaintext

"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.extractASTNodes = extractASTNodes;
var traverse_1 = __importDefault(require("@babel/traverse"));
function extractASTNodes(ast) {
var importNodes = [];
var directives = [];
(0, traverse_1.default)(ast, {
Directive: function (path) {
// Only capture directives if they are at the top scope of the source
// and their previous siblings are all directives
if (path.parent.type === 'Program' &&
path.getAllPrevSiblings().every(function (s) {
return s.type === 'Directive';
})) {
directives.push(path.node);
// Trailing comments probably shouldn't be attached to the directive
path.node.trailingComments = null;
}
},
ImportDeclaration: function (path) {
var tsModuleParent = path.findParent(function (p) {
return p.isTSModuleDeclaration();
});
if (!tsModuleParent) {
importNodes.push(path.node);
}
},
});
return { importNodes: importNodes, directives: directives };
}