Socket
Socket
Sign inDemoInstall

vue-docgen-api

Package Overview
Dependencies
Maintainers
3
Versions
271
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vue-docgen-api - npm Package Compare versions

Comparing version 4.73.1 to 4.74.0

dist/script-setup-handlers/utils/__fixtures__/types.d.ts

2

dist/script-setup-handlers/setupEventHandler.js

@@ -150,3 +150,3 @@ "use strict";

else if (bt.isTSTypeReference(param.node) && bt.isIdentifier(param.node.typeName)) {
var resolvedType = (0, tsUtils_1.getTypeDefinitionFromIdentifier)(astPath, param.node.typeName.name);
var resolvedType = (0, tsUtils_1.getTypeDefinitionFromIdentifier)(astPath, param.node.typeName.name, opt);
if (resolvedType) {

@@ -153,0 +153,0 @@ readEventsTSTypes(resolvedType);

@@ -98,3 +98,3 @@ "use strict";

// find it's definition in the file
var definitionPath = (0, tsUtils_1.getTypeDefinitionFromIdentifier)(astPath, typeName);
var definitionPath = (0, tsUtils_1.getTypeDefinitionFromIdentifier)(astPath, typeName, opt);
// use the same process to exact info

@@ -101,0 +101,0 @@ if (definitionPath) {

import * as bt from '@babel/types';
import { NodePath } from 'ast-types/lib/node-path';
export declare function getTypeDefinitionFromIdentifier(astPath: bt.File, typeName: string): NodePath | undefined;
import { ParseOptions } from '../../types';
export declare function getTypeDefinitionFromIdentifier(astPath: bt.File, typeName: string, opt: ParseOptions): NodePath | undefined;
declare const _default: {};
export default _default;
"use strict";
var __assign = (this && this.__assign) || function () {
__assign = Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {

@@ -25,12 +36,72 @@ if (k2 === undefined) k2 = k;

};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.getTypeDefinitionFromIdentifier = void 0;
var fs_1 = __importDefault(require("fs"));
var bt = __importStar(require("@babel/types"));
var recast_1 = require("recast");
function getTypeDefinitionFromIdentifier(astPath, typeName) {
var path_1 = require("path");
var babel_parser_1 = __importDefault(require("../../babel-parser"));
var makePathResolver_1 = __importDefault(require("../../utils/makePathResolver"));
var getTypeDefinitionFromIdentifierFromModule = function (module, typeName, opt, pathResolver) {
var parser = (0, babel_parser_1.default)({ plugins: ['typescript'] });
var filePath = pathResolver(module);
if (!filePath) {
return undefined;
}
return getTypeDefinitionFromIdentifier(parser.parse(fs_1.default.readFileSync(filePath, {
encoding: 'utf-8'
})), typeName, __assign(__assign({}, opt), { filePath: filePath }));
};
function getTypeDefinitionFromIdentifier(astPath, typeName, opt) {
var typeBody = undefined;
var pathResolver = (0, makePathResolver_1.default)((0, path_1.dirname)(opt.filePath), opt.alias, opt.modules);
(0, recast_1.visit)(astPath.program, {
visitExportAllDeclaration: function (nodePath) {
typeBody =
typeBody !== null && typeBody !== void 0 ? typeBody : getTypeDefinitionFromIdentifierFromModule(nodePath.value.source.value, typeName, opt, pathResolver);
return false;
},
visitExportSpecifier: function (nodePath) {
if (!typeBody && nodePath.value.exported.name === typeName) {
typeBody = getTypeDefinitionFromIdentifierFromModule(nodePath.parent.value.source.value, nodePath.value.local.name, opt, pathResolver);
}
return false;
},
visitImportSpecifier: function (nodePath) {
if (!typeBody && nodePath.value.imported.name === typeName) {
typeBody = getTypeDefinitionFromIdentifierFromModule(nodePath.parent.value.source.value, typeName, opt, pathResolver);
}
return false;
},
visitTSInterfaceDeclaration: function (nodePath) {
if (bt.isIdentifier(nodePath.node.id) && nodePath.node.id.name === typeName) {
typeBody = nodePath.get('body', 'body');
var interfaceBody_1 = nodePath.get('body', 'body');
if (!interfaceBody_1) {
return;
}
// If the interface extends from other interfaces, look these up and insert their properties
// into the just resolved interface. If the inheriting interface already has such a property
// defined, to not add it, as the inheriting interface overwrites it.
if (nodePath.value.extends) {
var parentInterfaces = nodePath.value.extends;
parentInterfaces.forEach(function (parentInterface) {
if (!bt.isIdentifier(parentInterface.expression)) {
return;
}
var parentInterfaceBody = getTypeDefinitionFromIdentifier(astPath, parentInterface.expression.name, opt);
parentInterfaceBody === null || parentInterfaceBody === void 0 ? void 0 : parentInterfaceBody.value.forEach(function (parentInterfaceProp) {
if (!interfaceBody_1.value.find(function (prop) {
return bt.isIdentifier(prop.key) &&
bt.isIdentifier(parentInterfaceProp.key) &&
prop.key.name === parentInterfaceProp.key.name;
})) {
interfaceBody_1.value.splice(0, 0, parentInterfaceProp);
}
});
});
}
typeBody = interfaceBody_1;
}

@@ -37,0 +108,0 @@ return false;

@@ -34,2 +34,10 @@ "use strict";

function makePathResolver(refDirName, aliases, modules) {
/**
* Emulate the module import logic as much as necessary to resolve a module containing the
* interface or type.
*
* @param base Path to the file that is importing the module
* @param module Relative path to the module
* @returns The absolute path to the file that contains the module to be imported
*/
return function (filePath, originalDirNameOverride) {

@@ -36,0 +44,0 @@ return (0, resolvePathFrom_1.default)((0, resolveAliases_1.default)(filePath, aliases || {}, refDirName), __spreadArray([

{
"name": "vue-docgen-api",
"version": "4.73.1",
"version": "4.74.0",
"description": "Toolbox to extract information from Vue component files for documentation generation purposes.",

@@ -5,0 +5,0 @@ "homepage": "https://vue-styleguidist.github.io",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc