Socket
Socket
Sign inDemoInstall

vue-docgen-api

Package Overview
Dependencies
92
Maintainers
3
Versions
269
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 4.47.0 to 4.50.0

dist/babel-parser.test.d.ts

31

dist/babel-parser.js
"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 __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
if (ar || !(i in from)) {
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
ar[i] = from[i];
}
}
return to.concat(ar || Array.prototype.slice.call(from));
};
Object.defineProperty(exports, "__esModule", { value: true });
var parser_1 = require("@babel/parser");
var babelParserOptions = {
const parser_1 = require("@babel/parser");
const babelParserOptions = {
sourceType: 'module',

@@ -50,7 +30,6 @@ strictMode: false,

};
function buildParse(options) {
if (options === void 0) { options = {}; }
options = __assign(__assign(__assign({}, babelParserOptions), options), { plugins: __spreadArray(__spreadArray([], (babelParserOptions.plugins || []), true), (options.plugins || []), true) });
function buildParse(options = {}) {
options = Object.assign(Object.assign(Object.assign({}, babelParserOptions), options), { plugins: [...(babelParserOptions.plugins || []), ...(options.plugins || [])] });
return {
parse: function (src) {
parse(src) {
return (0, parser_1.parse)(src, options);

@@ -57,0 +36,0 @@ }

"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 __importDefault = (this && this.__importDefault) || function (mod) {

@@ -18,5 +7,5 @@ return (mod && mod.__esModule) ? mod : { "default": mod };

exports.Documentation = void 0;
var ts_map_1 = __importDefault(require("ts-map"));
var Documentation = /** @class */ (function () {
function Documentation(fullFilePath) {
const ts_map_1 = __importDefault(require("ts-map"));
class Documentation {
constructor(fullFilePath) {
this.componentFullfilePath = fullFilePath;

@@ -31,50 +20,51 @@ this.propsMap = new ts_map_1.default();

}
Documentation.prototype.setOrigin = function (origin) {
setOrigin(origin) {
this.originExtendsMixin = origin.extends ? { extends: origin.extends } : {};
this.originExtendsMixin = origin.mixin ? { mixin: origin.mixin } : {};
};
Documentation.prototype.setDocsBlocks = function (docsBlocks) {
}
setDocsBlocks(docsBlocks) {
this.docsBlocks = docsBlocks;
};
Documentation.prototype.set = function (key, value) {
}
set(key, value) {
this.dataMap.set(key, value);
};
Documentation.prototype.get = function (key) {
}
get(key) {
return this.dataMap.get(key);
};
Documentation.prototype.getPropDescriptor = function (propName) {
var vModelDescriptor = this.propsMap.get('v-model');
}
getPropDescriptor(propName) {
const vModelDescriptor = this.propsMap.get('v-model');
return vModelDescriptor && vModelDescriptor.name === propName
? vModelDescriptor
: this.getDescriptor(propName, this.propsMap, function () { return ({
: this.getDescriptor(propName, this.propsMap, () => ({
name: propName
}); });
};
Documentation.prototype.getEventDescriptor = function (eventName) {
return this.getDescriptor(eventName, this.eventsMap, function () { return ({
}));
}
getEventDescriptor(eventName) {
return this.getDescriptor(eventName, this.eventsMap, () => ({
name: eventName
}); });
};
Documentation.prototype.getSlotDescriptor = function (slotName) {
return this.getDescriptor(slotName, this.slotsMap, function () { return ({
}));
}
getSlotDescriptor(slotName) {
return this.getDescriptor(slotName, this.slotsMap, () => ({
name: slotName
}); });
};
Documentation.prototype.getMethodDescriptor = function (methodName) {
return this.getDescriptor(methodName, this.methodsMap, function () { return ({
}));
}
getMethodDescriptor(methodName) {
return this.getDescriptor(methodName, this.methodsMap, () => ({
name: methodName
}); });
};
Documentation.prototype.getExposedDescriptor = function (exposedName) {
return this.getDescriptor(exposedName, this.exposedMap, function () { return ({
}));
}
getExposedDescriptor(exposedName) {
return this.getDescriptor(exposedName, this.exposedMap, () => ({
name: exposedName
}); });
};
Documentation.prototype.toObject = function () {
var props = this.getObjectFromDescriptor(this.propsMap);
var methods = this.getObjectFromDescriptor(this.methodsMap);
var events = this.getObjectFromDescriptor(this.eventsMap);
var slots = this.getObjectFromDescriptor(this.slotsMap);
var obj = {};
this.dataMap.forEach(function (value, key) {
}));
}
toObject() {
const props = this.getObjectFromDescriptor(this.propsMap);
const methods = this.getObjectFromDescriptor(this.methodsMap);
const events = this.getObjectFromDescriptor(this.eventsMap);
const slots = this.getObjectFromDescriptor(this.slotsMap);
const expose = this.getObjectFromDescriptor(this.exposedMap);
const obj = {};
this.dataMap.forEach((value, key) => {
if (key) {

@@ -87,26 +77,30 @@ obj[key] = value;

}
return __assign(__assign({}, obj), {
return Object.assign(Object.assign({}, obj), {
// initialize non null params
description: obj.description || '', tags: obj.tags || {},
// set all the static properties
exportName: obj.exportName, displayName: obj.displayName, props: props, events: events, methods: methods, slots: slots });
};
Documentation.prototype.getDescriptor = function (name, map, init) {
var descriptor = map.get(name);
exportName: obj.exportName, displayName: obj.displayName, expose,
props,
events,
methods,
slots });
}
getDescriptor(name, map, init) {
let descriptor = map.get(name);
if (!descriptor) {
descriptor = init();
descriptor = __assign(__assign({}, descriptor), this.originExtendsMixin);
descriptor = Object.assign(Object.assign({}, descriptor), this.originExtendsMixin);
map.set(name, descriptor);
}
return descriptor;
};
Documentation.prototype.getObjectFromDescriptor = function (map) {
}
getObjectFromDescriptor(map) {
if (map.size > 0) {
var obj_1 = [];
map.forEach(function (descriptor, name) {
const obj = [];
map.forEach((descriptor, name) => {
if (name && descriptor) {
obj_1.push(descriptor);
obj.push(descriptor);
}
});
return obj_1;
return obj;
}

@@ -116,6 +110,5 @@ else {

}
};
return Documentation;
}());
}
}
exports.default = Documentation;
exports.Documentation = Documentation;
exports.default = Documentation;
"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) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {

@@ -41,29 +34,2 @@ if (k2 === undefined) k2 = k;

};
var __generator = (this && this.__generator) || function (thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (_) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
};
var __importDefault = (this && this.__importDefault) || function (mod) {

@@ -74,8 +40,8 @@ return (mod && mod.__esModule) ? mod : { "default": mod };

exports.parseSource = exports.parseMulti = exports.parse = exports.getDefaultExample = exports.cleanName = exports.Documentation = exports.TemplateHandlers = exports.ScriptHandlers = void 0;
var Documentation_1 = __importDefault(require("./Documentation"));
const Documentation_1 = __importDefault(require("./Documentation"));
exports.Documentation = Documentation_1.default;
var parse_1 = require("./parse");
var ScriptHandlers = __importStar(require("./script-handlers"));
const parse_1 = require("./parse");
const ScriptHandlers = __importStar(require("./script-handlers"));
exports.ScriptHandlers = ScriptHandlers;
var TemplateHandlers = __importStar(require("./template-handlers"));
const TemplateHandlers = __importStar(require("./template-handlers"));
exports.TemplateHandlers = TemplateHandlers;

@@ -91,15 +57,4 @@ var vue_inbrowser_compiler_utils_1 = require("vue-inbrowser-compiler-utils");

function parse(filePath, opts) {
return __awaiter(this, void 0, void 0, function () {
var _this = this;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, parsePrimitive(function (options) { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, (0, parse_1.parseFile)(options)];
case 1: return [2 /*return*/, _a.sent()];
}
}); }); }, filePath, opts)];
case 1: return [2 /*return*/, (_a.sent())[0]];
}
});
return __awaiter(this, void 0, void 0, function* () {
return (yield parsePrimitive((options) => __awaiter(this, void 0, void 0, function* () { return yield (0, parse_1.parseFile)(options); }), filePath, opts))[0];
});

@@ -115,9 +70,3 @@ }

function parseMulti(filePath, opts) {
var _this = this;
return parsePrimitive(function (options) { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, (0, parse_1.parseFile)(options)];
case 1: return [2 /*return*/, _a.sent()];
}
}); }); }, filePath, opts);
return parsePrimitive((options) => __awaiter(this, void 0, void 0, function* () { return yield (0, parse_1.parseFile)(options); }), filePath, opts);
}

@@ -132,15 +81,4 @@ exports.parseMulti = parseMulti;

function parseSource(source, filePath, opts) {
return __awaiter(this, void 0, void 0, function () {
var _this = this;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, parsePrimitive(function (options) { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, (0, parse_1.parseSource)(source, options)];
case 1: return [2 /*return*/, _a.sent()];
}
}); }); }, filePath, opts)];
case 1: return [2 /*return*/, (_a.sent())[0]];
}
});
return __awaiter(this, void 0, void 0, function* () {
return (yield parsePrimitive((options) => __awaiter(this, void 0, void 0, function* () { return yield (0, parse_1.parseSource)(source, options); }), filePath, opts))[0];
});

@@ -157,20 +95,12 @@ }

function parsePrimitive(createDocs, filePath, opts) {
return __awaiter(this, void 0, void 0, function () {
var options, docs;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
options = isOptionsObject(opts)
? __assign(__assign({ validExtends: function (fullFilePath) { return !/[\\/]node_modules[\\/]/.test(fullFilePath); } }, opts), { filePath: filePath }) : {
filePath: filePath,
alias: opts,
validExtends: function (fullFilePath) { return !/[\\/]node_modules[\\/]/.test(fullFilePath); }
};
return [4 /*yield*/, createDocs(options)];
case 1:
docs = _a.sent();
return [2 /*return*/, docs.map(function (d) { return d.toObject(); })];
}
});
return __awaiter(this, void 0, void 0, function* () {
const options = isOptionsObject(opts)
? Object.assign(Object.assign({ validExtends: (fullFilePath) => !/[\\/]node_modules[\\/]/.test(fullFilePath) }, opts), { filePath }) : {
filePath,
alias: opts,
validExtends: (fullFilePath) => !/[\\/]node_modules[\\/]/.test(fullFilePath)
};
const docs = yield createDocs(options);
return docs.map(d => d.toObject());
});
}
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {

@@ -30,38 +34,2 @@ if (k2 === undefined) k2 = k;

};
var __generator = (this && this.__generator) || function (thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (_) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
};
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
if (ar || !(i in from)) {
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
ar[i] = from[i];
}
}
return to.concat(ar || Array.prototype.slice.call(from));
};
var __importDefault = (this && this.__importDefault) || function (mod) {

@@ -72,53 +40,45 @@ return (mod && mod.__esModule) ? mod : { "default": mod };

exports.addDefaultAndExecuteHandlers = void 0;
var recast_1 = require("recast");
var babel_parser_1 = __importDefault(require("./babel-parser"));
var Documentation_1 = __importDefault(require("./Documentation"));
var cacher_1 = __importDefault(require("./utils/cacher"));
var resolveExportedComponent_1 = __importDefault(require("./utils/resolveExportedComponent"));
var documentRequiredComponents_1 = __importDefault(require("./utils/documentRequiredComponents"));
var script_handlers_1 = __importStar(require("./script-handlers"));
var ERROR_MISSING_DEFINITION = 'No suitable component definition found';
function parseScript(source, options, documentation, forceSingleExport, noNeedForExport) {
if (forceSingleExport === void 0) { forceSingleExport = false; }
if (noNeedForExport === void 0) { noNeedForExport = false; }
return __awaiter(this, void 0, void 0, function () {
var plugins, ast, _a, componentDefinitions, ievSet, docs;
return __generator(this, function (_b) {
switch (_b.label) {
case 0:
plugins = options.lang === 'ts' ? ['typescript'] : ['flow'];
if (options.jsx) {
plugins.push('jsx');
}
ast = (0, cacher_1.default)(function () { return (0, recast_1.parse)(source, { parser: (0, babel_parser_1.default)({ plugins: plugins }) }); }, source);
if (!ast) {
throw new Error("Unable to parse empty file \"".concat(options.filePath, "\""));
}
_a = (0, resolveExportedComponent_1.default)(ast), componentDefinitions = _a[0], ievSet = _a[1];
if (componentDefinitions.size === 0 && noNeedForExport) {
componentDefinitions.set('default', ast.program.body[0]);
}
if (!(componentDefinitions.size === 0)) return [3 /*break*/, 2];
return [4 /*yield*/, (0, documentRequiredComponents_1.default)(documentation, ievSet, undefined, options)
// if we do not find any components, throw
];
case 1:
docs = _b.sent();
// if we do not find any components, throw
if (!docs.length) {
throw new Error("".concat(ERROR_MISSING_DEFINITION, " on \"").concat(options.filePath, "\""));
}
else {
return [2 /*return*/, docs];
}
_b.label = 2;
case 2: return [2 /*return*/, addDefaultAndExecuteHandlers(componentDefinitions, ast, options, documentation, forceSingleExport)];
const recast_1 = require("recast");
const babel_parser_1 = __importDefault(require("./babel-parser"));
const Documentation_1 = __importDefault(require("./Documentation"));
const cacher_1 = __importDefault(require("./utils/cacher"));
const resolveExportedComponent_1 = __importDefault(require("./utils/resolveExportedComponent"));
const documentRequiredComponents_1 = __importDefault(require("./utils/documentRequiredComponents"));
const script_handlers_1 = __importStar(require("./script-handlers"));
const ERROR_MISSING_DEFINITION = 'No suitable component definition found';
function parseScript(source, options, documentation, forceSingleExport = false, noNeedForExport = false) {
return __awaiter(this, void 0, void 0, function* () {
const plugins = options.lang === 'ts' ? ['typescript'] : ['flow'];
if (options.jsx) {
plugins.push('jsx');
}
const ast = (0, cacher_1.default)(() => (0, recast_1.parse)(source, { parser: (0, babel_parser_1.default)({ plugins }) }), source);
if (!ast) {
throw new Error(`Unable to parse empty file "${options.filePath}"`);
}
const [componentDefinitions, ievSet] = (0, resolveExportedComponent_1.default)(ast);
if (componentDefinitions.size === 0 && noNeedForExport) {
componentDefinitions.set('default', ast.program.body[0]);
}
if (componentDefinitions.size === 0) {
// if there is any immediately exported variable
// resolve their documentations
const docs = yield (0, documentRequiredComponents_1.default)(documentation, ievSet, undefined, options);
// if we do not find any components, throw
if (!docs.length) {
throw new Error(`${ERROR_MISSING_DEFINITION} on "${options.filePath}"`);
}
});
else {
return docs;
}
}
return addDefaultAndExecuteHandlers(componentDefinitions, ast, options, documentation, forceSingleExport);
});
}
exports.default = parseScript;
function addDefaultAndExecuteHandlers(componentDefinitions, ast, options, documentation, forceSingleExport) {
if (forceSingleExport === void 0) { forceSingleExport = false; }
var handlers = __spreadArray(__spreadArray([], (options.scriptHandlers || script_handlers_1.default), true), (options.addScriptHandlers || []), true);
function addDefaultAndExecuteHandlers(componentDefinitions, ast, options, documentation, forceSingleExport = false) {
const handlers = [
...(options.scriptHandlers || script_handlers_1.default),
...(options.addScriptHandlers || [])
];
return executeHandlers(options.scriptPreHandlers || script_handlers_1.preHandlers, handlers, componentDefinitions, ast, options, forceSingleExport, documentation);

@@ -128,71 +88,34 @@ }

function executeHandlers(preHandlers, localHandlers, componentDefinitions, ast, opt, forceSingleExport, documentation) {
return __awaiter(this, void 0, void 0, function () {
var compDefs, docs;
var _this = this;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
compDefs = componentDefinitions
.keys()
.filter(function (name) { return name && (!opt.nameFilter || opt.nameFilter.indexOf(name) > -1); });
if (forceSingleExport && compDefs.length > 1) {
throw Error('vue-docgen-api: multiple exports in a component file are not handled by docgen.parse, Please use "docgen.parseMulti" instead');
}
return [4 /*yield*/, Promise.all(compDefs.map(function (name) { return __awaiter(_this, void 0, void 0, function () {
var doc, compDef;
var _this = this;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
doc = (compDefs.length > 1 && name !== 'default' ? undefined : documentation) ||
new Documentation_1.default(opt.filePath);
compDef = componentDefinitions.get(name);
// execute all prehandlers in order
return [4 /*yield*/, preHandlers.reduce(function (_, handler) { return __awaiter(_this, void 0, void 0, function () {
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, _];
case 1:
_a.sent();
if (!(typeof handler === 'function')) return [3 /*break*/, 3];
return [4 /*yield*/, handler(doc, compDef, ast, opt)];
case 2: return [2 /*return*/, _a.sent()];
case 3: return [2 /*return*/];
}
});
}); }, Promise.resolve())];
case 1:
// execute all prehandlers in order
_a.sent();
return [4 /*yield*/, Promise.all(localHandlers.map(function (handler) { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, handler(doc, compDef, ast, opt)];
case 1: return [2 /*return*/, _a.sent()];
}
}); }); }))
// end with setting of exportname
// to avoid dependencies names bleeding on the main components,
// do this step at the end of the function
];
case 2:
_a.sent();
// end with setting of exportname
// to avoid dependencies names bleeding on the main components,
// do this step at the end of the function
doc.set('exportName', name);
return [2 /*return*/, doc];
}
});
}); }))
// default component first so in multiple exports in parse it is returned
];
case 1:
docs = _a.sent();
// default component first so in multiple exports in parse it is returned
return [2 /*return*/, docs.sort(function (a, b) {
return a.get('exportName') === 'default' ? -1 : b.get('exportName') === 'default' ? 1 : 0;
})];
}
});
return __awaiter(this, void 0, void 0, function* () {
const compDefs = componentDefinitions
.keys()
.filter(name => name && (!opt.nameFilter || opt.nameFilter.indexOf(name) > -1));
if (forceSingleExport && compDefs.length > 1) {
throw Error('vue-docgen-api: multiple exports in a component file are not handled by docgen.parse, Please use "docgen.parseMulti" instead');
}
const docs = yield Promise.all(compDefs.map((name) => __awaiter(this, void 0, void 0, function* () {
// If there are multiple exports and an initial documentation,
// it means the doc is coming from an SFC template.
// Only enrich the doc attached to the default export
// NOTE: module.exports is normalized to default
const doc = (compDefs.length > 1 && name !== 'default' ? undefined : documentation) ||
new Documentation_1.default(opt.filePath);
const compDef = componentDefinitions.get(name);
// execute all prehandlers in order
yield preHandlers.reduce((_, handler) => __awaiter(this, void 0, void 0, function* () {
yield _;
if (typeof handler === 'function') {
return yield handler(doc, compDef, ast, opt);
}
}), Promise.resolve());
yield Promise.all(localHandlers.map((handler) => __awaiter(this, void 0, void 0, function* () { return yield handler(doc, compDef, ast, opt); })));
// end with setting of exportname
// to avoid dependencies names bleeding on the main components,
// do this step at the end of the function
doc.set('exportName', name);
return doc;
})));
// default component first so in multiple exports in parse it is returned
return docs.sort((a, b) => a.get('exportName') === 'default' ? -1 : b.get('exportName') === 'default' ? 1 : 0);
});
}
"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) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {

@@ -37,22 +30,20 @@ if (k2 === undefined) k2 = k;

exports.traverse = void 0;
var pug = __importStar(require("pug"));
var compiler_dom_1 = require("@vue/compiler-dom");
var cacher_1 = __importDefault(require("./utils/cacher"));
const pug = __importStar(require("pug"));
const compiler_dom_1 = require("@vue/compiler-dom");
const cacher_1 = __importDefault(require("./utils/cacher"));
function parseTemplate(tpl, documentation, handlers, opts) {
var filePath = opts.filePath, pugOptions = opts.pugOptions;
const { filePath, pugOptions } = opts;
if (tpl && tpl.content) {
var source_1 = tpl.attrs && tpl.attrs.lang === 'pug'
? pug.render(tpl.content.trim(), __assign(__assign({ doctype: 'html' }, pugOptions), { filename: filePath }))
const source = tpl.attrs && tpl.attrs.lang === 'pug'
? pug.render(tpl.content.trim(), Object.assign(Object.assign({ doctype: 'html' }, pugOptions), { filename: filePath }))
: tpl.content;
var ast_1 = (0, cacher_1.default)(function () { return (0, compiler_dom_1.parse)(source_1, { comments: true }); }, source_1);
var functional_1 = !!tpl.attrs.functional;
if (functional_1) {
documentation.set('functional', functional_1);
const ast = (0, cacher_1.default)(() => (0, compiler_dom_1.parse)(source, { comments: true }), source);
const functional = !!tpl.attrs.functional;
if (functional) {
documentation.set('functional', functional);
}
if (ast_1) {
ast_1.children.forEach(function (child) {
return traverse(child, documentation, handlers, ast_1.children, {
functional: functional_1
});
});
if (ast) {
ast.children.forEach(child => traverse(child, documentation, handlers, ast.children, {
functional
}));
}

@@ -66,7 +57,6 @@ }

function traverse(templateAst, documentation, handlers, siblings, options) {
var traverseAstChildren = function (ast) {
const traverseAstChildren = (ast) => {
if (hasChildren(ast)) {
var children = ast.children;
for (var _i = 0, children_1 = children; _i < children_1.length; _i++) {
var childNode = children_1[_i];
const { children } = ast;
for (const childNode of children) {
traverse(childNode, documentation, handlers, children, options);

@@ -76,3 +66,3 @@ }

};
handlers.forEach(function (handler) {
handlers.forEach(handler => {
handler(documentation, templateAst, siblings, options);

@@ -79,0 +69,0 @@ });

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {

@@ -30,29 +34,2 @@ if (k2 === undefined) k2 = k;

};
var __generator = (this && this.__generator) || function (thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (_) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
};
var __importDefault = (this && this.__importDefault) || function (mod) {

@@ -63,9 +40,9 @@ return (mod && mod.__esModule) ? mod : { "default": mod };

exports.parseSource = exports.parseFile = void 0;
var fs_1 = require("fs");
var path = __importStar(require("path"));
var util_1 = require("util");
var parse_script_1 = __importDefault(require("./parse-script"));
var parseSFC_1 = __importDefault(require("./parseSFC"));
var read = (0, util_1.promisify)(fs_1.readFile);
var ERROR_EMPTY_DOCUMENT = 'The passed source is empty';
const fs_1 = require("fs");
const path = __importStar(require("path"));
const util_1 = require("util");
const parse_script_1 = __importDefault(require("./parse-script"));
const parseSFC_1 = __importDefault(require("./parseSFC"));
const read = (0, util_1.promisify)(fs_1.readFile);
const ERROR_EMPTY_DOCUMENT = 'The passed source is empty';
/**

@@ -78,20 +55,12 @@ * parses the source at filePath and returns the doc

function parseFile(opt, documentation) {
return __awaiter(this, void 0, void 0, function () {
var source, e_1;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
_a.trys.push([0, 2, , 3]);
return [4 /*yield*/, read(opt.filePath, {
encoding: 'utf-8'
})];
case 1:
source = _a.sent();
return [2 /*return*/, parseSource(source, opt, documentation)];
case 2:
e_1 = _a.sent();
throw Error("Could not read file ".concat(opt.filePath));
case 3: return [2 /*return*/];
}
});
return __awaiter(this, void 0, void 0, function* () {
try {
const source = yield read(opt.filePath, {
encoding: 'utf-8'
});
return parseSource(source, opt, documentation);
}
catch (e) {
throw Error(`Could not read file ${opt.filePath}`);
}
});

@@ -107,42 +76,33 @@ }

function parseSource(source, opt, documentation) {
return __awaiter(this, void 0, void 0, function () {
var singleFileComponent, docs, displayName, dirName;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
// if jsx option is not mentionned, parse jsx in components
opt.jsx = opt.jsx === undefined ? true : opt.jsx;
singleFileComponent = /\.vue$/i.test(path.extname(opt.filePath));
if (source === '') {
throw new Error(ERROR_EMPTY_DOCUMENT);
}
// if the parsed component is the result of a mixin or an extends
if (documentation) {
documentation.setOrigin(opt);
}
if (!singleFileComponent) return [3 /*break*/, 2];
return [4 /*yield*/, (0, parseSFC_1.default)(documentation, source, opt)];
case 1:
docs = _a.sent();
return [3 /*break*/, 4];
case 2:
opt.lang = /\.tsx?$/i.test(path.extname(opt.filePath)) ? 'ts' : 'js';
return [4 /*yield*/, (0, parse_script_1.default)(source, opt, documentation, documentation !== undefined)];
case 3:
docs = (_a.sent()) || [];
if (docs.length === 1 && !docs[0].get('displayName')) {
displayName = path.basename(opt.filePath).replace(/\.\w+$/, '');
dirName = path.basename(path.dirname(opt.filePath));
docs[0].set('displayName', displayName.toLowerCase() === 'index' ? dirName : displayName);
}
_a.label = 4;
case 4:
if (documentation) {
documentation.setOrigin({});
}
return [2 /*return*/, docs];
return __awaiter(this, void 0, void 0, function* () {
// if jsx option is not mentionned, parse jsx in components
opt.jsx = opt.jsx === undefined ? true : opt.jsx;
const singleFileComponent = /\.vue$/i.test(path.extname(opt.filePath));
if (source === '') {
throw new Error(ERROR_EMPTY_DOCUMENT);
}
// if the parsed component is the result of a mixin or an extends
if (documentation) {
documentation.setOrigin(opt);
}
let docs;
if (singleFileComponent) {
docs = yield (0, parseSFC_1.default)(documentation, source, opt);
}
else {
opt.lang = /\.tsx?$/i.test(path.extname(opt.filePath)) ? 'ts' : 'js';
docs = (yield (0, parse_script_1.default)(source, opt, documentation, documentation !== undefined)) || [];
if (docs.length === 1 && !docs[0].get('displayName')) {
// give a component a display name if we can
const displayName = path.basename(opt.filePath).replace(/\.\w+$/, '');
const dirName = path.basename(path.dirname(opt.filePath));
docs[0].set('displayName', displayName.toLowerCase() === 'index' ? dirName : displayName);
}
});
}
if (documentation) {
documentation.setOrigin({});
}
return docs;
});
}
exports.parseSource = parseSource;
"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) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {

@@ -41,38 +34,2 @@ if (k2 === undefined) k2 = k;

};
var __generator = (this && this.__generator) || function (thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (_) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
};
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
if (ar || !(i in from)) {
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
ar[i] = from[i];
}
}
return to.concat(ar || Array.prototype.slice.call(from));
};
var __importDefault = (this && this.__importDefault) || function (mod) {

@@ -82,140 +39,103 @@ return (mod && mod.__esModule) ? mod : { "default": mod };

Object.defineProperty(exports, "__esModule", { value: true });
var compiler_sfc_1 = require("@vue/compiler-sfc");
var path = __importStar(require("path"));
var fs_1 = require("fs");
var util_1 = require("util");
var template_handlers_1 = __importDefault(require("./template-handlers"));
var cacher_1 = __importDefault(require("./utils/cacher"));
var parse_template_1 = __importDefault(require("./parse-template"));
var Documentation_1 = __importDefault(require("./Documentation"));
var parse_script_1 = __importDefault(require("./parse-script"));
var makePathResolver_1 = __importDefault(require("./utils/makePathResolver"));
var script_setup_handlers_1 = __importDefault(require("./script-setup-handlers"));
var read = (0, util_1.promisify)(fs_1.readFile);
const compiler_sfc_1 = require("@vue/compiler-sfc");
const path = __importStar(require("path"));
const fs_1 = require("fs");
const util_1 = require("util");
const template_handlers_1 = __importDefault(require("./template-handlers"));
const cacher_1 = __importDefault(require("./utils/cacher"));
const parse_template_1 = __importDefault(require("./parse-template"));
const Documentation_1 = __importDefault(require("./Documentation"));
const parse_script_1 = __importDefault(require("./parse-script"));
const makePathResolver_1 = __importDefault(require("./utils/makePathResolver"));
const script_setup_handlers_1 = __importDefault(require("./script-setup-handlers"));
const read = (0, util_1.promisify)(fs_1.readFile);
function parseSFC(initialDoc, source, opt) {
var _a, _b;
return __awaiter(this, void 0, void 0, function () {
var documentation, pathResolver, parts, extTemplSrc, extTemplSrcAbs, extTemplSource, _c, addTemplateHandlers, docsBlocks, docs, displayName, dirName;
return __generator(this, function (_d) {
switch (_d.label) {
case 0:
documentation = initialDoc;
pathResolver = (0, makePathResolver_1.default)(path.dirname(opt.filePath), opt.alias, opt.modules);
parts = (0, cacher_1.default)(function () { return (0, compiler_sfc_1.parse)(source, { pad: 'line' }); }, source).descriptor;
if (!parts.template) return [3 /*break*/, 5];
extTemplSrc = (_b = (_a = parts === null || parts === void 0 ? void 0 : parts.template) === null || _a === void 0 ? void 0 : _a.attrs) === null || _b === void 0 ? void 0 : _b.src;
if (!(extTemplSrc && typeof extTemplSrc === 'string')) return [3 /*break*/, 4];
extTemplSrcAbs = pathResolver(extTemplSrc);
if (!extTemplSrcAbs) return [3 /*break*/, 2];
return [4 /*yield*/, read(extTemplSrcAbs, {
encoding: 'utf-8'
})];
case 1:
_c = _d.sent();
return [3 /*break*/, 3];
case 2:
// leave the template alone
_c = false;
_d.label = 3;
case 3:
extTemplSource = _c;
if (extTemplSource) {
parts.template.content = extTemplSource;
}
_d.label = 4;
case 4:
addTemplateHandlers = opt.addTemplateHandlers || [];
documentation = initialDoc || new Documentation_1.default(opt.filePath);
(0, parse_template_1.default)(parts.template, documentation, __spreadArray(__spreadArray([], template_handlers_1.default, true), addTemplateHandlers, true), opt);
_d.label = 5;
case 5:
if (parts.customBlocks) {
documentation = documentation || new Documentation_1.default(opt.filePath);
docsBlocks = parts.customBlocks
.filter(function (block) { return block.type === 'docs' && block.content && block.content.length; })
.map(function (block) { return block.content.trim(); });
if (docsBlocks.length) {
documentation.setDocsBlocks(docsBlocks);
}
}
docs = documentation ? [documentation] : [];
if (!parts.scriptSetup) return [3 /*break*/, 7];
return [4 /*yield*/, parseScriptTag(parts.scriptSetup, pathResolver, opt, documentation, initialDoc !== undefined, true, parts.script ? parts.script.content : '')];
case 6:
docs = _d.sent();
return [3 /*break*/, 9];
case 7:
if (!parts.script) return [3 /*break*/, 9];
return [4 /*yield*/, parseScriptTag(parts.script, pathResolver, opt, documentation, initialDoc !== undefined)];
case 8:
docs = _d.sent();
_d.label = 9;
case 9:
if (documentation && !documentation.get('displayName')) {
displayName = path.basename(opt.filePath).replace(/\.\w+$/, '');
dirName = path.basename(path.dirname(opt.filePath));
documentation.set('displayName', displayName.toLowerCase() === 'index' ? dirName : displayName);
}
return [2 /*return*/, docs];
return __awaiter(this, void 0, void 0, function* () {
let documentation = initialDoc;
// create a custom path resolver to resolve webpack aliases
const pathResolver = (0, makePathResolver_1.default)(path.dirname(opt.filePath), opt.alias, opt.modules);
// use padding so that errors are displayed at the correct line
const { descriptor: parts } = (0, cacher_1.default)(() => (0, compiler_sfc_1.parse)(source, { pad: 'line' }), source);
// get slots and props from template
if (parts.template) {
const extTemplSrc = (_b = (_a = parts === null || parts === void 0 ? void 0 : parts.template) === null || _a === void 0 ? void 0 : _a.attrs) === null || _b === void 0 ? void 0 : _b.src;
if (extTemplSrc && typeof extTemplSrc === 'string') {
const extTemplSrcAbs = pathResolver(extTemplSrc);
const extTemplSource = extTemplSrcAbs
? yield read(extTemplSrcAbs, {
encoding: 'utf-8'
})
: // if we don't have a content to bind
// leave the template alone
false;
if (extTemplSource) {
parts.template.content = extTemplSource;
}
}
});
const addTemplateHandlers = opt.addTemplateHandlers || [];
documentation = initialDoc || new Documentation_1.default(opt.filePath);
(0, parse_template_1.default)(parts.template, documentation, [...template_handlers_1.default, ...addTemplateHandlers], opt);
}
if (parts.customBlocks) {
documentation = documentation || new Documentation_1.default(opt.filePath);
const docsBlocks = parts.customBlocks
.filter(block => block.type === 'docs' && block.content && block.content.length)
.map(block => block.content.trim());
if (docsBlocks.length) {
documentation.setDocsBlocks(docsBlocks);
}
}
let docs = documentation ? [documentation] : [];
if (parts.scriptSetup) {
docs = yield parseScriptTag(parts.scriptSetup, pathResolver, opt, documentation, initialDoc !== undefined, true, parts.script ? parts.script.content : '');
}
else if (parts.script) {
docs = yield parseScriptTag(parts.script, pathResolver, opt, documentation, initialDoc !== undefined);
}
if (documentation && !documentation.get('displayName')) {
// a component should always have a display name
// give a component a display name if we can
const displayName = path.basename(opt.filePath).replace(/\.\w+$/, '');
const dirName = path.basename(path.dirname(opt.filePath));
documentation.set('displayName', displayName.toLowerCase() === 'index' ? dirName : displayName);
}
return docs;
});
}
exports.default = parseSFC;
function parseScriptTag(scriptTag, pathResolver, opt, documentation, forceSingleExport, isSetupScript, isSetupScriptOtherScript) {
if (isSetupScript === void 0) { isSetupScript = false; }
if (isSetupScriptOtherScript === void 0) { isSetupScriptOtherScript = ''; }
return __awaiter(this, void 0, void 0, function () {
var scriptSource, extSrc, extSrcAbs, extSource, _a, docs, _b;
return __generator(this, function (_c) {
switch (_c.label) {
case 0:
scriptSource = scriptTag ? scriptTag.content : undefined;
extSrc = scriptTag && scriptTag.attrs ? scriptTag.attrs.src : false;
if (!(extSrc && typeof extSrc === 'string')) return [3 /*break*/, 4];
extSrcAbs = pathResolver(extSrc);
if (!extSrcAbs) return [3 /*break*/, 2];
return [4 /*yield*/, read(extSrcAbs, {
encoding: 'utf-8'
})];
case 1:
_a = _c.sent();
return [3 /*break*/, 3];
case 2:
_a = '';
_c.label = 3;
case 3:
extSource = _a;
if (extSource.length) {
scriptSource = extSource;
opt.lang =
(scriptTag && scriptTag.attrs && /^tsx?$/.test(scriptTag.attrs.lang)) ||
/\.tsx?$/i.test(extSrc)
? 'ts'
: 'js';
}
_c.label = 4;
case 4:
opt.lang =
(scriptTag && scriptTag.attrs && /^tsx?$/.test(scriptTag.attrs.lang)) ||
(typeof extSrc === 'string' && /\.tsx?$/i.test(extSrc))
? 'ts'
: 'js';
opt = isSetupScript ? __assign(__assign({}, opt), { scriptPreHandlers: [], scriptHandlers: script_setup_handlers_1.default }) : opt;
if (!scriptSource) return [3 /*break*/, 6];
return [4 /*yield*/, (0, parse_script_1.default)(isSetupScriptOtherScript + '\n' + scriptSource, opt, documentation, forceSingleExport, isSetupScript)];
case 5:
_b = (_c.sent()) || [];
return [3 /*break*/, 7];
case 6:
_b = documentation
? [documentation]
: [];
_c.label = 7;
case 7:
docs = _b;
return [2 /*return*/, docs];
function parseScriptTag(scriptTag, pathResolver, opt, documentation, forceSingleExport, isSetupScript = false, isSetupScriptOtherScript = '') {
return __awaiter(this, void 0, void 0, function* () {
let scriptSource = scriptTag ? scriptTag.content : undefined;
const extSrc = scriptTag && scriptTag.attrs ? scriptTag.attrs.src : false;
if (extSrc && typeof extSrc === 'string') {
const extSrcAbs = pathResolver(extSrc);
const extSource = extSrcAbs
? yield read(extSrcAbs, {
encoding: 'utf-8'
})
: '';
if (extSource.length) {
scriptSource = extSource;
opt.lang =
(scriptTag && scriptTag.attrs && /^tsx?$/.test(scriptTag.attrs.lang)) ||
/\.tsx?$/i.test(extSrc)
? 'ts'
: 'js';
}
});
}
opt.lang =
(scriptTag && scriptTag.attrs && /^tsx?$/.test(scriptTag.attrs.lang)) ||
(typeof extSrc === 'string' && /\.tsx?$/i.test(extSrc))
? 'ts'
: 'js';
opt = isSetupScript ? Object.assign(Object.assign({}, opt), { scriptPreHandlers: [], scriptHandlers: script_setup_handlers_1.default }) : opt;
const docs = scriptSource
? (yield (0, parse_script_1.default)(isSetupScriptOtherScript + '\n' + scriptSource, opt, documentation, forceSingleExport, isSetupScript)) || []
: // if there is only a template return the template's doc
documentation
? [documentation]
: [];
return docs;
});
}
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {

@@ -25,5 +29,5 @@ if (k2 === undefined) k2 = k;

Object.defineProperty(exports, "__esModule", { value: true });
var bt = __importStar(require("@babel/types"));
var getArgFromDecorator_1 = __importDefault(require("../utils/getArgFromDecorator"));
var getProperties_1 = __importDefault(require("./utils/getProperties"));
const bt = __importStar(require("@babel/types"));
const getArgFromDecorator_1 = __importDefault(require("../utils/getArgFromDecorator"));
const getProperties_1 = __importDefault(require("./utils/getProperties"));
/**

@@ -36,9 +40,9 @@ * Extracts the name of the component from a class-style component

if (bt.isClassDeclaration(path.node)) {
var config = (0, getArgFromDecorator_1.default)(path.get('decorators'));
var displayName_1;
const config = (0, getArgFromDecorator_1.default)(path.get('decorators'));
let displayName;
if (config && bt.isObjectExpression(config.node)) {
(0, getProperties_1.default)(config, 'name').forEach(function (p) {
var valuePath = p.get('value');
(0, getProperties_1.default)(config, 'name').forEach((p) => {
const valuePath = p.get('value');
if (bt.isStringLiteral(valuePath.node)) {
displayName_1 = valuePath.node.value;
displayName = valuePath.node.value;
}

@@ -48,6 +52,6 @@ });

else {
displayName_1 = path.node.id ? path.node.id.name : undefined;
displayName = path.node.id ? path.node.id.name : undefined;
}
if (displayName_1) {
documentation.set('displayName', displayName_1);
if (displayName) {
documentation.set('displayName', displayName);
}

@@ -54,0 +58,0 @@ }

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {

@@ -25,8 +29,8 @@ if (k2 === undefined) k2 = k;

Object.defineProperty(exports, "__esModule", { value: true });
var bt = __importStar(require("@babel/types"));
var recast_1 = require("recast");
var eventHandler_1 = require("./eventHandler");
var getDocblock_1 = __importDefault(require("../utils/getDocblock"));
var getDoclets_1 = __importDefault(require("../utils/getDoclets"));
var resolveIdentifier_1 = __importDefault(require("../utils/resolveIdentifier"));
const bt = __importStar(require("@babel/types"));
const recast_1 = require("recast");
const eventHandler_1 = require("./eventHandler");
const getDocblock_1 = __importDefault(require("../utils/getDocblock"));
const getDoclets_1 = __importDefault(require("../utils/getDoclets"));
const resolveIdentifier_1 = __importDefault(require("../utils/resolveIdentifier"));
/**

@@ -41,3 +45,3 @@ * Extracts all events from a class-style component code

(0, recast_1.visit)(path.node, {
visitClassMethod: function (nodePath) {
visitClassMethod(nodePath) {
if (nodePath.node.decorators &&

@@ -48,7 +52,7 @@ bt.isCallExpression(nodePath.node.decorators[0].expression) &&

// fetch the leading comments on the wrapping expression
var docblock = (0, getDocblock_1.default)(nodePath);
var doclets = (0, getDoclets_1.default)(docblock || '');
var eventName = void 0;
var eventTags = doclets.tags ? doclets.tags.filter(function (d) { return d.title === 'event'; }) : [];
var exp = nodePath.get('decorators', 0).get('expression');
const docblock = (0, getDocblock_1.default)(nodePath);
const doclets = (0, getDoclets_1.default)(docblock || '');
let eventName;
const eventTags = doclets.tags ? doclets.tags.filter(d => d.title === 'event') : [];
const exp = nodePath.get('decorators', 0).get('expression');
// if someone wants to document it with anything else, they can force it

@@ -59,3 +63,3 @@ if (eventTags.length) {

else if (exp.get('arguments').value.length) {
var firstArg = exp.get('arguments', 0);
let firstArg = exp.get('arguments', 0);
if (bt.isIdentifier(firstArg.node)) {

@@ -75,3 +79,3 @@ firstArg = (0, resolveIdentifier_1.default)(astPath, firstArg);

}
var evtDescriptor = documentation.getEventDescriptor(eventName);
const evtDescriptor = documentation.getEventDescriptor(eventName);
(0, eventHandler_1.setEventDescriptor)(evtDescriptor, doclets);

@@ -78,0 +82,0 @@ return false;

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {

@@ -25,6 +29,6 @@ if (k2 === undefined) k2 = k;

Object.defineProperty(exports, "__esModule", { value: true });
var bt = __importStar(require("@babel/types"));
var getDocblock_1 = __importDefault(require("../utils/getDocblock"));
var getDoclets_1 = __importDefault(require("../utils/getDoclets"));
var methodHandler_1 = require("./methodHandler");
const bt = __importStar(require("@babel/types"));
const getDocblock_1 = __importDefault(require("../utils/getDocblock"));
const getDoclets_1 = __importDefault(require("../utils/getDoclets"));
const methodHandler_1 = require("./methodHandler");
/**

@@ -37,19 +41,19 @@ * Extracts all information about methods in a class-style Component

if (bt.isClassDeclaration(path.node)) {
var methods = documentation.get('methods') || [];
var allMethods = path
const methods = documentation.get('methods') || [];
const allMethods = path
.get('body')
.get('body')
.filter(function (a) { return bt.isClassMethod(a.node); });
allMethods.forEach(function (methodPath) {
var methodName = bt.isIdentifier(methodPath.node.key)
.filter((a) => bt.isClassMethod(a.node));
allMethods.forEach((methodPath) => {
const methodName = bt.isIdentifier(methodPath.node.key)
? methodPath.node.key.name
: '<anonymous>';
var docBlock = (0, getDocblock_1.default)(bt.isClassMethod(methodPath.node) ? methodPath : methodPath.parentPath);
var jsDoc = docBlock ? (0, getDoclets_1.default)(docBlock) : { description: '', tags: [] };
var jsDocTags = jsDoc.tags ? jsDoc.tags : [];
const docBlock = (0, getDocblock_1.default)(bt.isClassMethod(methodPath.node) ? methodPath : methodPath.parentPath);
const jsDoc = docBlock ? (0, getDoclets_1.default)(docBlock) : { description: '', tags: [] };
const jsDocTags = jsDoc.tags ? jsDoc.tags : [];
// ignore the method if there is no public tag
if (!jsDocTags.some(function (t) { return t.title === 'access' && t.content === 'public'; })) {
if (!jsDocTags.some((t) => t.title === 'access' && t.content === 'public')) {
return Promise.resolve();
}
var methodDescriptor = documentation.getMethodDescriptor(methodName);
const methodDescriptor = documentation.getMethodDescriptor(methodName);
if (jsDoc.description) {

@@ -56,0 +60,0 @@ methodDescriptor.description = jsDoc.description;

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {

@@ -30,29 +34,2 @@ if (k2 === undefined) k2 = k;

};
var __generator = (this && this.__generator) || function (thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (_) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
};
var __importDefault = (this && this.__importDefault) || function (mod) {

@@ -62,9 +39,9 @@ return (mod && mod.__esModule) ? mod : { "default": mod };

Object.defineProperty(exports, "__esModule", { value: true });
var bt = __importStar(require("@babel/types"));
var getDocblock_1 = __importDefault(require("../utils/getDocblock"));
var getDoclets_1 = __importDefault(require("../utils/getDoclets"));
var getTypeFromAnnotation_1 = __importDefault(require("../utils/getTypeFromAnnotation"));
var transformTagsIntoObject_1 = __importDefault(require("../utils/transformTagsIntoObject"));
var propHandler_1 = __importStar(require("./propHandler"));
var getArgFromDecorator_1 = __importDefault(require("../utils/getArgFromDecorator"));
const bt = __importStar(require("@babel/types"));
const getDocblock_1 = __importDefault(require("../utils/getDocblock"));
const getDoclets_1 = __importDefault(require("../utils/getDoclets"));
const getTypeFromAnnotation_1 = __importDefault(require("../utils/getTypeFromAnnotation"));
const transformTagsIntoObject_1 = __importDefault(require("../utils/transformTagsIntoObject"));
const propHandler_1 = __importStar(require("./propHandler"));
const getArgFromDecorator_1 = __importDefault(require("../utils/getArgFromDecorator"));
/**

@@ -76,92 +53,81 @@ * Extracts prop information from a class-style VueJs component

function classPropHandler(documentation, path, ast, opt) {
return __awaiter(this, void 0, void 0, function () {
var config;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
if (!bt.isClassDeclaration(path.node)) return [3 /*break*/, 3];
config = (0, getArgFromDecorator_1.default)(path.get('decorators'));
if (!(config && bt.isObjectExpression(config.node))) return [3 /*break*/, 2];
return [4 /*yield*/, (0, propHandler_1.default)(documentation, config, ast, opt)];
case 1:
_a.sent();
_a.label = 2;
case 2:
path
.get('body')
.get('body')
.filter(function (p) { return bt.isClassProperty(p.node) && !!p.node.decorators; })
.forEach(function (propPath) {
var propDeco = (propPath.get('decorators') || []).filter(function (p) {
var exp = bt.isCallExpression(p.node.expression)
? p.node.expression.callee
: p.node.expression;
return bt.isIdentifier(exp) && exp.name === 'Prop';
});
if (!propDeco.length) {
return undefined;
}
var propName = bt.isIdentifier(propPath.node.key) ? propPath.node.key.name : undefined;
if (!propName) {
return undefined;
}
var propDescriptor = documentation.getPropDescriptor(propName);
// description
var docBlock = (0, getDocblock_1.default)(propPath);
var jsDoc = docBlock ? (0, getDoclets_1.default)(docBlock) : { description: '', tags: [] };
var jsDocTags = jsDoc.tags ? jsDoc.tags : [];
if (jsDocTags) {
propDescriptor.tags = (0, transformTagsIntoObject_1.default)(jsDocTags);
}
if (jsDoc.description) {
propDescriptor.description = jsDoc.description;
}
(0, propHandler_1.extractValuesFromTags)(propDescriptor);
var litteralType;
if (propPath.node.typeAnnotation) {
var values = !!bt.isTSTypeAnnotation(propPath.node.typeAnnotation) &&
(0, propHandler_1.getValuesFromTypeAnnotation)(propPath.node.typeAnnotation.typeAnnotation);
if (values) {
propDescriptor.values = values;
propDescriptor.type = { name: 'string' };
litteralType = 'string';
return __awaiter(this, void 0, void 0, function* () {
if (bt.isClassDeclaration(path.node)) {
const config = (0, getArgFromDecorator_1.default)(path.get('decorators'));
if (config && bt.isObjectExpression(config.node)) {
yield (0, propHandler_1.default)(documentation, config, ast, opt);
}
path
.get('body')
.get('body')
.filter((p) => bt.isClassProperty(p.node) && !!p.node.decorators)
.forEach((propPath) => {
const propDeco = (propPath.get('decorators') || []).filter((p) => {
const exp = bt.isCallExpression(p.node.expression)
? p.node.expression.callee
: p.node.expression;
return bt.isIdentifier(exp) && exp.name === 'Prop';
});
if (!propDeco.length) {
return undefined;
}
const propName = bt.isIdentifier(propPath.node.key) ? propPath.node.key.name : undefined;
if (!propName) {
return undefined;
}
const propDescriptor = documentation.getPropDescriptor(propName);
// description
const docBlock = (0, getDocblock_1.default)(propPath);
const jsDoc = docBlock ? (0, getDoclets_1.default)(docBlock) : { description: '', tags: [] };
const jsDocTags = jsDoc.tags ? jsDoc.tags : [];
if (jsDocTags) {
propDescriptor.tags = (0, transformTagsIntoObject_1.default)(jsDocTags);
}
if (jsDoc.description) {
propDescriptor.description = jsDoc.description;
}
(0, propHandler_1.extractValuesFromTags)(propDescriptor);
let litteralType;
if (propPath.node.typeAnnotation) {
const values = !!bt.isTSTypeAnnotation(propPath.node.typeAnnotation) &&
(0, propHandler_1.getValuesFromTypeAnnotation)(propPath.node.typeAnnotation.typeAnnotation);
if (values) {
propDescriptor.values = values;
propDescriptor.type = { name: 'string' };
litteralType = 'string';
}
else {
// type
propDescriptor.type = (0, getTypeFromAnnotation_1.default)(propPath.node.typeAnnotation);
}
}
else if (propPath.node.value) {
propDescriptor.type = getTypeFromInitValue(propPath.node.value);
}
const propDecoratorPath = propDeco[0].get('expression');
if (bt.isCallExpression(propDecoratorPath.node)) {
const propDecoratorArg = propDecoratorPath.get('arguments', 0);
if (propDecoratorArg) {
if (bt.isObjectExpression(propDecoratorArg.node)) {
const propsPath = propDecoratorArg
.get('properties')
.filter((p) => bt.isObjectProperty(p.node));
// if there is no type annotation, get it from the decorators arguments
if (!propPath.node.typeAnnotation) {
litteralType = (0, propHandler_1.describeType)(propsPath, propDescriptor);
}
else {
// type
propDescriptor.type = (0, getTypeFromAnnotation_1.default)(propPath.node.typeAnnotation);
}
(0, propHandler_1.describeDefault)(propsPath, propDescriptor, litteralType || '');
(0, propHandler_1.describeRequired)(propsPath, propDescriptor);
// this compares the node to its supposed args
// if it finds no args it will return itself
}
else if (propPath.node.value) {
propDescriptor.type = getTypeFromInitValue(propPath.node.value);
else if (propDecoratorArg.node !== propDecoratorPath.node) {
propDescriptor.type = (0, propHandler_1.getTypeFromTypePath)(propDecoratorArg);
}
var propDecoratorPath = propDeco[0].get('expression');
if (bt.isCallExpression(propDecoratorPath.node)) {
var propDecoratorArg = propDecoratorPath.get('arguments', 0);
if (propDecoratorArg) {
if (bt.isObjectExpression(propDecoratorArg.node)) {
var propsPath = propDecoratorArg
.get('properties')
.filter(function (p) {
return bt.isObjectProperty(p.node);
});
// if there is no type annotation, get it from the decorators arguments
if (!propPath.node.typeAnnotation) {
litteralType = (0, propHandler_1.describeType)(propsPath, propDescriptor);
}
(0, propHandler_1.describeDefault)(propsPath, propDescriptor, litteralType || '');
(0, propHandler_1.describeRequired)(propsPath, propDescriptor);
// this compares the node to its supposed args
// if it finds no args it will return itself
}
else if (propDecoratorArg.node !== propDecoratorPath.node) {
propDescriptor.type = (0, propHandler_1.getTypeFromTypePath)(propDecoratorArg);
}
}
}
return undefined;
});
_a.label = 3;
case 3: return [2 /*return*/, Promise.resolve()];
}
});
}
}
return undefined;
});
}
return Promise.resolve();
});

@@ -168,0 +134,0 @@ }

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {

@@ -25,7 +29,7 @@ if (k2 === undefined) k2 = k;

Object.defineProperty(exports, "__esModule", { value: true });
var bt = __importStar(require("@babel/types"));
var getDocblock_1 = __importDefault(require("../utils/getDocblock"));
var getDoclets_1 = __importDefault(require("../utils/getDoclets"));
var transformTagsIntoObject_1 = __importDefault(require("../utils/transformTagsIntoObject"));
var getProperties_1 = __importDefault(require("./utils/getProperties"));
const bt = __importStar(require("@babel/types"));
const getDocblock_1 = __importDefault(require("../utils/getDocblock"));
const getDoclets_1 = __importDefault(require("../utils/getDoclets"));
const transformTagsIntoObject_1 = __importDefault(require("../utils/transformTagsIntoObject"));
const getProperties_1 = __importDefault(require("./utils/getProperties"));
/**

@@ -39,5 +43,5 @@ * Extracts prop information from an object-style VueJs component

if (bt.isObjectExpression(path.node)) {
var functionalPath = (0, getProperties_1.default)(path, 'functional');
const functionalPath = (0, getProperties_1.default)(path, 'functional');
if (functionalPath.length) {
var functionalValue = functionalPath[0].get('value').node;
const functionalValue = functionalPath[0].get('value').node;
if (bt.isBooleanLiteral(functionalValue)) {

@@ -48,7 +52,7 @@ documentation.set('functional', functionalValue.value);

}
var componentCommentedPath = path.parentPath;
let componentCommentedPath = path.parentPath;
// in case of Vue.extend() structure
if (bt.isCallExpression(componentCommentedPath.node)) {
// look for leading comments in the parent structures
var i = 5;
let i = 5;
while (i-- &&

@@ -67,3 +71,3 @@ !componentCommentedPath.get('leadingComments').value &&

else if (bt.isDeclaration(componentCommentedPath.node)) {
var classDeclaration = componentCommentedPath.get('declaration');
const classDeclaration = componentCommentedPath.get('declaration');
if (bt.isClassDeclaration(classDeclaration.node)) {

@@ -73,3 +77,3 @@ componentCommentedPath = classDeclaration;

}
var docBlock = (0, getDocblock_1.default)(componentCommentedPath);
const docBlock = (0, getDocblock_1.default)(componentCommentedPath);
// if no prop return

@@ -79,12 +83,12 @@ if (!docBlock || !docBlock.length) {

}
var jsDoc = (0, getDoclets_1.default)(docBlock);
const jsDoc = (0, getDoclets_1.default)(docBlock);
documentation.set('description', jsDoc.description);
if (jsDoc.tags) {
var displayNamesTags = jsDoc.tags.filter(function (t) { return t.title === 'displayName'; });
const displayNamesTags = jsDoc.tags.filter(t => t.title === 'displayName');
if (displayNamesTags.length) {
var displayName = displayNamesTags[0];
const displayName = displayNamesTags[0];
documentation.set('displayName', displayName.content);
}
var tagsAsObject = (0, transformTagsIntoObject_1.default)(jsDoc.tags.filter(function (t) { return t.title !== 'example' && t.title !== 'displayName'; }) || []);
var examples = jsDoc.tags.filter(function (t) { return t.title === 'example'; });
const tagsAsObject = (0, transformTagsIntoObject_1.default)(jsDoc.tags.filter(t => t.title !== 'example' && t.title !== 'displayName') || []);
const examples = jsDoc.tags.filter(t => t.title === 'example');
if (examples.length) {

@@ -91,0 +95,0 @@ tagsAsObject.examples = examples;

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {

@@ -25,4 +29,4 @@ if (k2 === undefined) k2 = k;

Object.defineProperty(exports, "__esModule", { value: true });
var bt = __importStar(require("@babel/types"));
var getProperties_1 = __importDefault(require("./utils/getProperties"));
const bt = __importStar(require("@babel/types"));
const getProperties_1 = __importDefault(require("./utils/getProperties"));
/**

@@ -35,3 +39,3 @@ * Extracts component name from an object-style VueJs component

if (bt.isObjectExpression(compDef.node)) {
var namePath = (0, getProperties_1.default)(compDef, 'name');
const namePath = (0, getProperties_1.default)(compDef, 'name');
// if no prop return

@@ -41,5 +45,5 @@ if (!namePath.length) {

}
var nameValuePath = namePath[0].get('value');
var singleNameValuePath = !Array.isArray(nameValuePath) ? nameValuePath : null;
var displayName = null;
const nameValuePath = namePath[0].get('value');
const singleNameValuePath = !Array.isArray(nameValuePath) ? nameValuePath : null;
let displayName = null;
if (singleNameValuePath) {

@@ -50,4 +54,4 @@ if (bt.isStringLiteral(singleNameValuePath.node)) {

else if (bt.isIdentifier(singleNameValuePath.node)) {
var nameConstId = singleNameValuePath.node.name;
var program = compDef.parentPath.parentPath;
const nameConstId = singleNameValuePath.node.name;
const program = compDef.parentPath.parentPath;
if (program.name === 'body') {

@@ -64,16 +68,12 @@ displayName = getDeclaredConstantValue(program, nameConstId);

function getDeclaredConstantValue(prog, nameConstId) {
var body = prog.node.body;
var globalVariableDeclarations = body.filter(function (node) {
return bt.isVariableDeclaration(node);
});
var globalVariableExports = body
.filter(function (node) {
return bt.isExportNamedDeclaration(node) && bt.isVariableDeclaration(node.declaration);
})
.map(function (node) { return node.declaration; });
var declarations = globalVariableDeclarations
const body = prog.node.body;
const globalVariableDeclarations = body.filter((node) => bt.isVariableDeclaration(node));
const globalVariableExports = body
.filter((node) => bt.isExportNamedDeclaration(node) && bt.isVariableDeclaration(node.declaration))
.map((node) => node.declaration);
const declarations = globalVariableDeclarations
.concat(globalVariableExports)
.reduce(function (a, declPath) { return a.concat(declPath.declarations); }, []);
var nodeDeclaratorArray = declarations.filter(function (d) { return bt.isIdentifier(d.id) && d.id.name === nameConstId; });
var nodeDeclarator = nodeDeclaratorArray.length ? nodeDeclaratorArray[0] : undefined;
.reduce((a, declPath) => a.concat(declPath.declarations), []);
const nodeDeclaratorArray = declarations.filter(d => bt.isIdentifier(d.id) && d.id.name === nameConstId);
const nodeDeclarator = nodeDeclaratorArray.length ? nodeDeclaratorArray[0] : undefined;
return nodeDeclarator && nodeDeclarator.init && bt.isStringLiteral(nodeDeclarator.init)

@@ -80,0 +80,0 @@ ? nodeDeclarator.init.value

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {

@@ -26,11 +30,10 @@ if (k2 === undefined) k2 = k;

exports.setEventDescriptor = exports.eventHandlerMethods = exports.eventHandlerEmits = void 0;
var bt = __importStar(require("@babel/types"));
var recast_1 = require("recast");
var getDocblock_1 = __importDefault(require("../utils/getDocblock"));
var getDoclets_1 = __importDefault(require("../utils/getDoclets"));
var resolveIdentifier_1 = __importDefault(require("../utils/resolveIdentifier"));
var getPropsFilter_1 = __importDefault(require("../utils/getPropsFilter"));
function getCommentBlockAndTags(p, _a) {
var _b = _a === void 0 ? { commentIndex: 1 } : _a, commentIndex = _b.commentIndex;
var docBlock = (0, getDocblock_1.default)(p, { commentIndex: commentIndex });
const bt = __importStar(require("@babel/types"));
const recast_1 = require("recast");
const getDocblock_1 = __importDefault(require("../utils/getDocblock"));
const getDoclets_1 = __importDefault(require("../utils/getDoclets"));
const resolveIdentifier_1 = __importDefault(require("../utils/resolveIdentifier"));
const getPropsFilter_1 = __importDefault(require("../utils/getPropsFilter"));
function getCommentBlockAndTags(p, { commentIndex } = { commentIndex: 1 }) {
const docBlock = (0, getDocblock_1.default)(p, { commentIndex });
return docBlock ? (0, getDoclets_1.default)(docBlock) : null;

@@ -53,3 +56,3 @@ }

(0, recast_1.visit)(path.node, {
visitCallExpression: function (pathExpression) {
visitCallExpression(pathExpression) {
if (bt.isMemberExpression(pathExpression.node.callee) &&

@@ -59,3 +62,3 @@ bt.isThisExpression(pathExpression.node.callee.object) &&

pathExpression.node.callee.property.name === '$emit') {
var args = pathExpression.node.arguments;
const args = pathExpression.node.arguments;
if (!args.length) {

@@ -65,6 +68,6 @@ return false;

// fetch the leading comments on the wrapping expression
var docblock = (0, getDocblock_1.default)(pathExpression.parentPath);
var doclets = (0, getDoclets_1.default)(docblock || '');
var eventName = void 0;
var eventTags = doclets.tags ? doclets.tags.filter(function (d) { return d.title === 'event'; }) : [];
const docblock = (0, getDocblock_1.default)(pathExpression.parentPath);
const doclets = (0, getDoclets_1.default)(docblock || '');
let eventName;
const eventTags = doclets.tags ? doclets.tags.filter(d => d.title === 'event') : [];
// if someone wants to document it with anything else, they can force it

@@ -75,3 +78,3 @@ if (eventTags.length) {

else {
var firstArg = pathExpression.get('arguments', 0);
let firstArg = pathExpression.get('arguments', 0);
if (bt.isIdentifier(firstArg.node)) {

@@ -86,3 +89,3 @@ firstArg = (0, resolveIdentifier_1.default)(astPath, firstArg);

// if this event is documented somewhere else leave it alone
var evtDescriptor = documentation.getEventDescriptor(eventName);
const evtDescriptor = documentation.getEventDescriptor(eventName);
setEventDescriptor(evtDescriptor, doclets);

@@ -98,7 +101,7 @@ if (args.length > 1 && !evtDescriptor.type) {

if (evtDescriptor.properties && evtDescriptor.properties.length < args.length - 2) {
var i = args.length - 2 - evtDescriptor.properties.length;
let i = args.length - 2 - evtDescriptor.properties.length;
while (i--) {
evtDescriptor.properties.push({
type: { names: ['undefined'] },
name: "<anonymous".concat(args.length - i - 2, ">")
name: `<anonymous${args.length - i - 2}>`
});

@@ -124,5 +127,5 @@ }

function eventHandlerEmits(documentation, path) {
var emitsPath = path
const emitsPath = path
.get('properties')
.filter(function (p) { return bt.isObjectProperty(p.node) && (0, getPropsFilter_1.default)('emits')(p); });
.filter((p) => bt.isObjectProperty(p.node) && (0, getPropsFilter_1.default)('emits')(p));
// if no emits member return

@@ -132,10 +135,10 @@ if (!emitsPath.length) {

}
var emitsObject = emitsPath[0].get('value');
const emitsObject = emitsPath[0].get('value');
if (bt.isArrayExpression(emitsObject.node)) {
emitsObject.get('elements').value.forEach(function (event, i) {
emitsObject.get('elements').value.forEach((event, i) => {
if (bt.isStringLiteral(event)) {
var eventDescriptor = documentation.getEventDescriptor(event.value);
var eventPath = emitsObject.get('elements', i);
var docblock = (0, getDocblock_1.default)(eventPath);
var doclets = (0, getDoclets_1.default)(docblock || '');
const eventDescriptor = documentation.getEventDescriptor(event.value);
const eventPath = emitsObject.get('elements', i);
const docblock = (0, getDocblock_1.default)(eventPath);
const doclets = (0, getDoclets_1.default)(docblock || '');
setEventDescriptor(eventDescriptor, doclets);

@@ -146,4 +149,4 @@ }

else if (bt.isObjectExpression(emitsObject.node)) {
emitsObject.get('properties').value.forEach(function (event, i) {
var eventName = bt.isStringLiteral(event.key)
emitsObject.get('properties').value.forEach((event, i) => {
const eventName = bt.isStringLiteral(event.key)
? event.key.value

@@ -154,6 +157,6 @@ : bt.isIdentifier(event.key)

if (eventName) {
var eventDescriptor = documentation.getEventDescriptor(eventName);
var eventPath = emitsObject.get('properties', i);
var docblock = (0, getDocblock_1.default)(eventPath);
var doclets = (0, getDoclets_1.default)(docblock || '');
const eventDescriptor = documentation.getEventDescriptor(eventName);
const eventPath = emitsObject.get('properties', i);
const docblock = (0, getDocblock_1.default)(eventPath);
const doclets = (0, getDoclets_1.default)(docblock || '');
setEventDescriptor(eventDescriptor, doclets);

@@ -173,5 +176,5 @@ }

function eventHandlerMethods(documentation, path) {
var methodsPath = path
const methodsPath = path
.get('properties')
.filter(function (p) { return bt.isObjectProperty(p.node) && (0, getPropsFilter_1.default)('methods')(p); });
.filter((p) => bt.isObjectProperty(p.node) && (0, getPropsFilter_1.default)('methods')(p));
// if no method return

@@ -181,17 +184,17 @@ if (!methodsPath.length) {

}
var methodsObject = methodsPath[0].get('value');
const methodsObject = methodsPath[0].get('value');
if (bt.isObjectExpression(methodsObject.node)) {
methodsObject.get('properties').each(function (p) {
var commentedMethod = bt.isObjectMethod(p.node) ? p : p.parentPath;
var jsDocTags = (getCommentBlockAndTags(commentedMethod) || {}).tags;
methodsObject.get('properties').each((p) => {
const commentedMethod = bt.isObjectMethod(p.node) ? p : p.parentPath;
const { tags: jsDocTags } = getCommentBlockAndTags(commentedMethod) || {};
if (!jsDocTags) {
return;
}
var firesTags = jsDocTags.filter(function (tag) { return tag.title === 'fires'; });
firesTags.forEach(function (tag) {
var eventName = tag.content;
var eventDescriptor = documentation.getEventDescriptor(eventName);
var currentBlock;
var foundEventDescriptor;
var commentIndex = 1;
const firesTags = jsDocTags.filter(tag => tag.title === 'fires');
firesTags.forEach(tag => {
const eventName = tag.content;
const eventDescriptor = documentation.getEventDescriptor(eventName);
let currentBlock;
let foundEventDescriptor;
let commentIndex = 1;
do {

@@ -201,3 +204,3 @@ currentBlock = getCommentBlockAndTags(commentedMethod, { commentIndex: ++commentIndex });

currentBlock.tags &&
currentBlock.tags.some(function (tag) { return tag.title === 'event' && tag.content === eventName; })) {
currentBlock.tags.some((tag) => tag.title === 'event' && tag.content === eventName)) {
foundEventDescriptor = currentBlock;

@@ -217,3 +220,3 @@ }

*/
var PROPERTY_TAGS = ['property', 'arg', 'arguments', 'param'];
const PROPERTY_TAGS = ['property', 'arg', 'arguments', 'param'];
function setEventDescriptor(eventDescriptor, jsDoc) {

@@ -223,10 +226,10 @@ if (jsDoc.description && jsDoc.description.length) {

}
var nonNullTags = jsDoc.tags ? jsDoc.tags : [];
var typeTags = nonNullTags.filter(function (tg) { return tg.title === 'type'; });
const nonNullTags = jsDoc.tags ? jsDoc.tags : [];
const typeTags = nonNullTags.filter(tg => tg.title === 'type');
eventDescriptor.type = typeTags.length
? { names: typeTags.map(function (t) { return t.type.name; }) }
? { names: typeTags.map((t) => t.type.name) }
: eventDescriptor.type;
var propertyTags = nonNullTags.filter(function (tg) { return PROPERTY_TAGS.includes(tg.title); });
const propertyTags = nonNullTags.filter(tg => PROPERTY_TAGS.includes(tg.title));
if (propertyTags.length) {
eventDescriptor.properties = propertyTags.map(function (tg) {
eventDescriptor.properties = propertyTags.map((tg) => {
return { type: { names: [tg.type.name] }, name: tg.name, description: tg.description };

@@ -236,3 +239,3 @@ });

// remove the property an type tags from the tag array
var tags = nonNullTags.filter(function (tg) { return tg.title !== 'type' && tg.title !== 'property' && tg.title !== 'event'; });
const tags = nonNullTags.filter((tg) => tg.title !== 'type' && tg.title !== 'property' && tg.title !== 'event');
if (tags.length) {

@@ -239,0 +242,0 @@ eventDescriptor.tags = tags;

"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) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {

@@ -41,29 +34,2 @@ if (k2 === undefined) k2 = k;

};
var __generator = (this && this.__generator) || function (thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (_) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
};
var __importDefault = (this && this.__importDefault) || function (mod) {

@@ -73,7 +39,7 @@ return (mod && mod.__esModule) ? mod : { "default": mod };

Object.defineProperty(exports, "__esModule", { value: true });
var bt = __importStar(require("@babel/types"));
var resolveRequired_1 = __importDefault(require("../utils/resolveRequired"));
var documentRequiredComponents_1 = __importDefault(require("../utils/documentRequiredComponents"));
var resolveLocal_1 = __importDefault(require("../utils/resolveLocal"));
var parse_script_1 = require("../parse-script");
const bt = __importStar(require("@babel/types"));
const resolveRequired_1 = __importDefault(require("../utils/resolveRequired"));
const documentRequiredComponents_1 = __importDefault(require("../utils/documentRequiredComponents"));
const resolveLocal_1 = __importDefault(require("../utils/resolveLocal"));
const parse_script_1 = require("../parse-script");
/**

@@ -86,29 +52,18 @@ * Returns documentation of the component referenced in the extends property of the component

function extendsHandler(documentation, componentDefinition, astPath, opt) {
return __awaiter(this, void 0, void 0, function () {
var extendsVariableName, variablesResolvedToCurrentFile, extendsFilePath;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
extendsVariableName = getExtendsVariableName(componentDefinition);
// if there is no extends or extends is a direct require
if (!extendsVariableName) {
return [2 /*return*/];
}
variablesResolvedToCurrentFile = (0, resolveLocal_1.default)(astPath, [extendsVariableName]);
if (!variablesResolvedToCurrentFile.get(extendsVariableName)) return [3 /*break*/, 2];
return [4 /*yield*/, (0, parse_script_1.addDefaultAndExecuteHandlers)(variablesResolvedToCurrentFile, astPath, __assign(__assign({}, opt), { nameFilter: [extendsVariableName] }), documentation)];
case 1:
_a.sent();
return [3 /*break*/, 4];
case 2:
extendsFilePath = (0, resolveRequired_1.default)(astPath, [extendsVariableName]);
// get each doc for each mixin using parse
return [4 /*yield*/, (0, documentRequiredComponents_1.default)(documentation, extendsFilePath, 'extends', opt)];
case 3:
// get each doc for each mixin using parse
_a.sent();
_a.label = 4;
case 4: return [2 /*return*/];
}
});
return __awaiter(this, void 0, void 0, function* () {
const extendsVariableName = getExtendsVariableName(componentDefinition);
// if there is no extends or extends is a direct require
if (!extendsVariableName) {
return;
}
const variablesResolvedToCurrentFile = (0, resolveLocal_1.default)(astPath, [extendsVariableName]);
if (variablesResolvedToCurrentFile.get(extendsVariableName)) {
yield (0, parse_script_1.addDefaultAndExecuteHandlers)(variablesResolvedToCurrentFile, astPath, Object.assign(Object.assign({}, opt), { nameFilter: [extendsVariableName] }), documentation);
}
else {
// get all require / import statements
const extendsFilePath = (0, resolveRequired_1.default)(astPath, [extendsVariableName]);
// get each doc for each mixin using parse
yield (0, documentRequiredComponents_1.default)(documentation, extendsFilePath, 'extends', opt);
}
});

@@ -118,3 +73,3 @@ }

function getExtendsVariableName(compDef) {
var extendsVariable = compDef &&
const extendsVariable = compDef &&
bt.isClassDeclaration(compDef.node) &&

@@ -126,3 +81,3 @@ compDef.node.superClass &&

if (extendsVariable) {
var extendsValue = bt.isProperty(extendsVariable.node)
const extendsValue = bt.isProperty(extendsVariable.node)
? extendsVariable.node.value

@@ -138,7 +93,7 @@ : extendsVariable.node;

}
var compDefProperties = compDef.get('properties');
var pathExtends = compDefProperties.value
? compDefProperties.filter(function (p) { return bt.isIdentifier(p.node.key) && p.node.key.name === 'extends'; })
const compDefProperties = compDef.get('properties');
const pathExtends = compDefProperties.value
? compDefProperties.filter((p) => bt.isIdentifier(p.node.key) && p.node.key.name === 'extends')
: [];
return pathExtends.length ? pathExtends[0] : undefined;
}

@@ -7,31 +7,31 @@ "use strict";

exports.preHandlers = exports.slotHandlerLitteral = exports.slotHandlerFunctional = exports.slotHandler = exports.propHandler = exports.mixinsHandler = exports.methodHandler = exports.extendsHandler = exports.eventHandler = exports.displayNameHandler = exports.componentHandler = exports.classEventHandler = exports.classPropHandler = exports.classMethodHandler = exports.classDisplayNameHandler = void 0;
var classDisplayNameHandler_1 = __importDefault(require("./classDisplayNameHandler"));
const classDisplayNameHandler_1 = __importDefault(require("./classDisplayNameHandler"));
exports.classDisplayNameHandler = classDisplayNameHandler_1.default;
var classMethodHandler_1 = __importDefault(require("./classMethodHandler"));
const classMethodHandler_1 = __importDefault(require("./classMethodHandler"));
exports.classMethodHandler = classMethodHandler_1.default;
var classPropHandler_1 = __importDefault(require("./classPropHandler"));
const classPropHandler_1 = __importDefault(require("./classPropHandler"));
exports.classPropHandler = classPropHandler_1.default;
var classEventHandler_1 = __importDefault(require("./classEventHandler"));
const classEventHandler_1 = __importDefault(require("./classEventHandler"));
exports.classEventHandler = classEventHandler_1.default;
var componentHandler_1 = __importDefault(require("./componentHandler"));
const componentHandler_1 = __importDefault(require("./componentHandler"));
exports.componentHandler = componentHandler_1.default;
var displayNameHandler_1 = __importDefault(require("./displayNameHandler"));
const displayNameHandler_1 = __importDefault(require("./displayNameHandler"));
exports.displayNameHandler = displayNameHandler_1.default;
var eventHandler_1 = __importDefault(require("./eventHandler"));
const eventHandler_1 = __importDefault(require("./eventHandler"));
exports.eventHandler = eventHandler_1.default;
var extendsHandler_1 = __importDefault(require("./extendsHandler"));
const extendsHandler_1 = __importDefault(require("./extendsHandler"));
exports.extendsHandler = extendsHandler_1.default;
var methodHandler_1 = __importDefault(require("./methodHandler"));
const methodHandler_1 = __importDefault(require("./methodHandler"));
exports.methodHandler = methodHandler_1.default;
var mixinsHandler_1 = __importDefault(require("./mixinsHandler"));
const mixinsHandler_1 = __importDefault(require("./mixinsHandler"));
exports.mixinsHandler = mixinsHandler_1.default;
var propHandler_1 = __importDefault(require("./propHandler"));
const propHandler_1 = __importDefault(require("./propHandler"));
exports.propHandler = propHandler_1.default;
var slotHandler_1 = __importDefault(require("./slotHandler"));
const slotHandler_1 = __importDefault(require("./slotHandler"));
exports.slotHandler = slotHandler_1.default;
var slotHandlerFunctional_1 = __importDefault(require("./slotHandlerFunctional"));
const slotHandlerFunctional_1 = __importDefault(require("./slotHandlerFunctional"));
exports.slotHandlerFunctional = slotHandlerFunctional_1.default;
var slotHandlerLiteral_1 = __importDefault(require("./slotHandlerLiteral"));
const slotHandlerLiteral_1 = __importDefault(require("./slotHandlerLiteral"));
exports.slotHandlerLitteral = slotHandlerLiteral_1.default;
var defaultHandlers = [
const defaultHandlers = [
displayNameHandler_1.default,

@@ -38,0 +38,0 @@ componentHandler_1.default,

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {

@@ -26,8 +30,8 @@ if (k2 === undefined) k2 = k;

exports.setMethodDescriptor = void 0;
var bt = __importStar(require("@babel/types"));
var getDocblock_1 = __importDefault(require("../utils/getDocblock"));
var getDoclets_1 = __importDefault(require("../utils/getDoclets"));
var getTypeFromAnnotation_1 = __importDefault(require("../utils/getTypeFromAnnotation"));
var transformTagsIntoObject_1 = __importDefault(require("../utils/transformTagsIntoObject"));
var getPropsFilter_1 = __importDefault(require("../utils/getPropsFilter"));
const bt = __importStar(require("@babel/types"));
const getDocblock_1 = __importDefault(require("../utils/getDocblock"));
const getDoclets_1 = __importDefault(require("../utils/getDoclets"));
const getTypeFromAnnotation_1 = __importDefault(require("../utils/getTypeFromAnnotation"));
const transformTagsIntoObject_1 = __importDefault(require("../utils/transformTagsIntoObject"));
const getProperties_1 = __importDefault(require("./utils/getProperties"));
/**

@@ -39,6 +43,7 @@ * Extracts methods information from an object-style VueJs component

function methodHandler(documentation, path) {
var _a;
if (bt.isObjectExpression(path.node)) {
var methodsPath = path
.get('properties')
.filter(function (p) { return bt.isObjectProperty(p.node) && (0, getPropsFilter_1.default)('methods')(p); });
const exposePath = (0, getProperties_1.default)(path, 'expose');
const exposeArray = ((_a = exposePath[0]) === null || _a === void 0 ? void 0 : _a.get('value', 'elements').map((el) => el.value.value)) || [];
const methodsPath = (0, getProperties_1.default)(path, 'methods');
// if no method return

@@ -48,8 +53,8 @@ if (!methodsPath.length) {

}
var methodsObject = methodsPath[0].get('value');
const methodsObject = methodsPath[0].get('value');
if (bt.isObjectExpression(methodsObject.node)) {
methodsObject.get('properties').each(function (p) {
var methodName = '<anonymous>';
methodsObject.get('properties').each((p) => {
let methodName = '<anonymous>';
if (bt.isObjectProperty(p.node) && bt.isIdentifier(p.node.key)) {
var val = p.get('value');
const val = p.get('value');
methodName = p.node.key.name;

@@ -62,10 +67,11 @@ if (!Array.isArray(val)) {

bt.isObjectMethod(p.node) && bt.isIdentifier(p.node.key) ? p.node.key.name : methodName;
var docBlock = (0, getDocblock_1.default)(bt.isObjectMethod(p.node) ? p : p.parentPath);
var jsDoc = docBlock ? (0, getDoclets_1.default)(docBlock) : { description: '', tags: [] };
var jsDocTags = jsDoc.tags ? jsDoc.tags : [];
const docBlock = (0, getDocblock_1.default)(bt.isObjectMethod(p.node) ? p : p.parentPath);
const jsDoc = docBlock ? (0, getDoclets_1.default)(docBlock) : { description: '', tags: [] };
const jsDocTags = jsDoc.tags ? jsDoc.tags : [];
// ignore the method if there is no public tag
if (!jsDocTags.some(function (t) { return t.title === 'access' && t.content === 'public'; })) {
if (!jsDocTags.some((t) => t.title === 'access' && t.content === 'public') &&
!exposeArray.includes(methodName)) {
return;
}
var methodDescriptor = documentation.getMethodDescriptor(methodName);
const methodDescriptor = documentation.getMethodDescriptor(methodName);
if (jsDoc.description) {

@@ -83,5 +89,5 @@ methodDescriptor.description = jsDoc.description;

// params
describeParams(method, methodDescriptor, jsDocTags.filter(function (tag) { return ['param', 'arg', 'argument'].indexOf(tag.title) >= 0; }));
describeParams(method, methodDescriptor, jsDocTags.filter(tag => ['param', 'arg', 'argument'].indexOf(tag.title) >= 0));
// returns
describeReturns(method, methodDescriptor, jsDocTags.filter(function (t) { return t.title === 'returns'; }));
describeReturns(method, methodDescriptor, jsDocTags.filter(t => t.title === 'returns'));
// tags

@@ -94,9 +100,9 @@ methodDescriptor.tags = (0, transformTagsIntoObject_1.default)(jsDocTags);

// if there is no parameter no need to parse them
var fExp = methodPath.node;
const fExp = methodPath.node;
if (!fExp.params || !jsDocParamTags || (!fExp.params.length && !jsDocParamTags.length)) {
return;
}
var params = [];
fExp.params.forEach(function (par, i) {
var name;
const params = [];
fExp.params.forEach((par, i) => {
let name;
if (bt.isIdentifier(par)) {

@@ -114,4 +120,4 @@ // simple params

}
var jsDocTags = jsDocParamTags.filter(function (tag) { return tag.name === name; });
var jsDocTag = jsDocTags.length ? jsDocTags[0] : undefined;
const jsDocTags = jsDocParamTags.filter(tag => tag.name === name);
let jsDocTag = jsDocTags.length ? jsDocTags[0] : undefined;
// if tag is not namely described try finding it by its order

@@ -123,3 +129,3 @@ if (!jsDocTag) {

}
var param = { name: name };
const param = { name };
if (jsDocTag) {

@@ -134,3 +140,3 @@ if (jsDocTag.type) {

if (!param.type && par.typeAnnotation) {
var type = (0, getTypeFromAnnotation_1.default)(par.typeAnnotation);
const type = (0, getTypeFromAnnotation_1.default)(par.typeAnnotation);
if (type) {

@@ -144,3 +150,3 @@ param.type = type;

if (!params.length) {
jsDocParamTags.forEach(function (doc) {
jsDocParamTags.forEach(doc => {
params.push(doc);

@@ -155,5 +161,5 @@ });

if (jsDocReturnTags.length) {
var ret = jsDocReturnTags[0];
const ret = jsDocReturnTags[0];
if (ret.name && ret.description) {
ret.description = "".concat(ret.name, " ").concat(ret.description);
ret.description = `${ret.name} ${ret.description}`;
}

@@ -163,5 +169,5 @@ methodDescriptor.returns = ret;

if (!methodDescriptor.returns || !methodDescriptor.returns.type) {
var methodNode = methodPath.node;
const methodNode = methodPath.node;
if (methodNode.returnType) {
var type = (0, getTypeFromAnnotation_1.default)(methodNode.returnType);
const type = (0, getTypeFromAnnotation_1.default)(methodNode.returnType);
if (type) {

@@ -168,0 +174,0 @@ methodDescriptor.returns = methodDescriptor.returns || {};

"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) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {

@@ -41,29 +34,2 @@ if (k2 === undefined) k2 = k;

};
var __generator = (this && this.__generator) || function (thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (_) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
};
var __importDefault = (this && this.__importDefault) || function (mod) {

@@ -73,8 +39,8 @@ return (mod && mod.__esModule) ? mod : { "default": mod };

Object.defineProperty(exports, "__esModule", { value: true });
var bt = __importStar(require("@babel/types"));
var resolveRequired_1 = __importDefault(require("../utils/resolveRequired"));
var documentRequiredComponents_1 = __importDefault(require("../utils/documentRequiredComponents"));
var getProperties_1 = __importDefault(require("./utils/getProperties"));
var resolveLocal_1 = __importDefault(require("../utils/resolveLocal"));
var parse_script_1 = require("../parse-script");
const bt = __importStar(require("@babel/types"));
const resolveRequired_1 = __importDefault(require("../utils/resolveRequired"));
const documentRequiredComponents_1 = __importDefault(require("../utils/documentRequiredComponents"));
const getProperties_1 = __importDefault(require("./utils/getProperties"));
const resolveLocal_1 = __importDefault(require("../utils/resolveLocal"));
const parse_script_1 = require("../parse-script");
/**

@@ -91,41 +57,22 @@ * Look in the mixin section of a component.

function mixinsHandler(documentation, componentDefinition, astPath, opt) {
return __awaiter(this, void 0, void 0, function () {
var mixinVariableNames, variablesResolvedToCurrentFile, mixinVarToFilePath;
var _this = this;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
mixinVariableNames = getMixinsVariableNames(componentDefinition);
if (!mixinVariableNames || !mixinVariableNames.length) {
return [2 /*return*/];
}
variablesResolvedToCurrentFile = (0, resolveLocal_1.default)(astPath, mixinVariableNames);
mixinVarToFilePath = (0, resolveRequired_1.default)(astPath, mixinVariableNames);
return [4 /*yield*/, mixinVariableNames.reduce(function (_, varName) { return __awaiter(_this, void 0, void 0, function () {
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, _];
case 1:
_a.sent();
if (!variablesResolvedToCurrentFile.get(varName)) return [3 /*break*/, 3];
return [4 /*yield*/, (0, parse_script_1.addDefaultAndExecuteHandlers)(variablesResolvedToCurrentFile, astPath, __assign(__assign({}, opt), { nameFilter: [varName] }), documentation)];
case 2:
_a.sent();
return [3 /*break*/, 5];
case 3:
// get each doc for each mixin using parse
return [4 /*yield*/, (0, documentRequiredComponents_1.default)(documentation, mixinVarToFilePath, 'mixin', __assign(__assign({}, opt), { nameFilter: [varName] }))];
case 4:
// get each doc for each mixin using parse
_a.sent();
_a.label = 5;
case 5: return [2 /*return*/];
}
});
}); }, Promise.resolve())];
case 1:
_a.sent();
return [2 /*return*/];
return __awaiter(this, void 0, void 0, function* () {
// filter only mixins
const mixinVariableNames = getMixinsVariableNames(componentDefinition);
if (!mixinVariableNames || !mixinVariableNames.length) {
return;
}
const variablesResolvedToCurrentFile = (0, resolveLocal_1.default)(astPath, mixinVariableNames);
// get require / import statements for mixins
const mixinVarToFilePath = (0, resolveRequired_1.default)(astPath, mixinVariableNames);
yield mixinVariableNames.reduce((_, varName) => __awaiter(this, void 0, void 0, function* () {
yield _;
if (variablesResolvedToCurrentFile.get(varName)) {
yield (0, parse_script_1.addDefaultAndExecuteHandlers)(variablesResolvedToCurrentFile, astPath, Object.assign(Object.assign({}, opt), { nameFilter: [varName] }), documentation);
}
});
else {
// get each doc for each mixin using parse
yield (0, documentRequiredComponents_1.default)(documentation, mixinVarToFilePath, 'mixin', Object.assign(Object.assign({}, opt), { nameFilter: [varName] }));
}
return;
}), Promise.resolve());
});

@@ -135,11 +82,11 @@ }

function getMixinsVariableNames(compDef) {
var varNames = [];
const varNames = [];
if (bt.isObjectExpression(compDef.node)) {
var mixinProp = (0, getProperties_1.default)(compDef, 'mixins');
var mixinPath = mixinProp.length ? mixinProp[0] : undefined;
const mixinProp = (0, getProperties_1.default)(compDef, 'mixins');
const mixinPath = mixinProp.length ? mixinProp[0] : undefined;
if (mixinPath) {
var mixinPropertyValue = mixinPath.node.value && bt.isArrayExpression(mixinPath.node.value)
const mixinPropertyValue = mixinPath.node.value && bt.isArrayExpression(mixinPath.node.value)
? mixinPath.node.value.elements
: [];
mixinPropertyValue.forEach(function (e) {
mixinPropertyValue.forEach((e) => {
if (!e) {

@@ -162,3 +109,3 @@ return;

compDef.node.superClass.callee.name.toLowerCase() === 'mixins') {
return compDef.node.superClass.arguments.reduce(function (acc, a) {
return compDef.node.superClass.arguments.reduce((acc, a) => {
if (bt.isIdentifier(a)) {

@@ -165,0 +112,0 @@ acc.push(a.name);

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {

@@ -30,29 +34,2 @@ if (k2 === undefined) k2 = k;

};
var __generator = (this && this.__generator) || function (thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (_) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
};
var __importDefault = (this && this.__importDefault) || function (mod) {

@@ -63,12 +40,12 @@ return (mod && mod.__esModule) ? mod : { "default": mod };

exports.extractValuesFromTags = exports.describeDefault = exports.describeRequired = exports.getValuesFromTypeAnnotation = exports.getTypeFromTypePath = exports.describeType = exports.describePropsFromValue = exports.getRawValueParsedFromFunctionsBlockStatementNode = void 0;
var bt = __importStar(require("@babel/types"));
var recast_1 = require("recast");
var getDocblock_1 = __importDefault(require("../utils/getDocblock"));
var getDoclets_1 = __importDefault(require("../utils/getDoclets"));
var transformTagsIntoObject_1 = __importDefault(require("../utils/transformTagsIntoObject"));
var getPropsFilter_1 = __importDefault(require("../utils/getPropsFilter"));
var getTemplateExpressionAST_1 = __importDefault(require("../utils/getTemplateExpressionAST"));
var parseValidator_1 = __importDefault(require("./utils/parseValidator"));
const bt = __importStar(require("@babel/types"));
const recast_1 = require("recast");
const getDocblock_1 = __importDefault(require("../utils/getDocblock"));
const getDoclets_1 = __importDefault(require("../utils/getDoclets"));
const transformTagsIntoObject_1 = __importDefault(require("../utils/transformTagsIntoObject"));
const getPropsFilter_1 = __importDefault(require("../utils/getPropsFilter"));
const getTemplateExpressionAST_1 = __importDefault(require("../utils/getTemplateExpressionAST"));
const parseValidator_1 = __importDefault(require("./utils/parseValidator"));
function getRawValueParsedFromFunctionsBlockStatementNode(blockStatementNode) {
var body = blockStatementNode.body;
const { body } = blockStatementNode;
// if there is more than a return statement in the body,

@@ -79,3 +56,3 @@ // we cannot resolve the new object, we let the function display as a function

}
var ret = body[0];
const [ret] = body;
return ret.argument ? (0, recast_1.print)(ret.argument).code : null;

@@ -90,135 +67,104 @@ }

function propHandler(documentation, path, ast, opt) {
return __awaiter(this, void 0, void 0, function () {
var propsPath, modelPropertyName, propsValuePath;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
if (!bt.isObjectExpression(path.node)) return [3 /*break*/, 2];
propsPath = path
.get('properties')
.filter(function (p) { return bt.isObjectProperty(p.node) && (0, getPropsFilter_1.default)('props')(p); });
// if no prop return
if (!propsPath.length) {
return [2 /*return*/, Promise.resolve()];
}
modelPropertyName = getModelPropName(path);
propsValuePath = propsPath[0].get('value');
return [4 /*yield*/, describePropsFromValue(documentation, propsValuePath, ast, opt, modelPropertyName)];
case 1:
_a.sent();
_a.label = 2;
case 2: return [2 /*return*/];
return __awaiter(this, void 0, void 0, function* () {
if (bt.isObjectExpression(path.node)) {
const propsPath = path
.get('properties')
.filter((p) => bt.isObjectProperty(p.node) && (0, getPropsFilter_1.default)('props')(p));
// if no prop return
if (!propsPath.length) {
return Promise.resolve();
}
});
const modelPropertyName = getModelPropName(path);
const propsValuePath = propsPath[0].get('value');
yield describePropsFromValue(documentation, propsValuePath, ast, opt, modelPropertyName);
}
});
}
exports.default = propHandler;
function describePropsFromValue(documentation, propsValuePath, ast, opt, modelPropertyName) {
if (modelPropertyName === void 0) { modelPropertyName = null; }
return __awaiter(this, void 0, void 0, function () {
var objProp, objPropFiltered;
var _this = this;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
if (!bt.isObjectExpression(propsValuePath.node)) return [3 /*break*/, 2];
objProp = propsValuePath.get('properties');
objPropFiltered = objProp.filter(function (p) {
return bt.isProperty(p.node);
});
return [4 /*yield*/, Promise.all(objPropFiltered.map(function (prop) { return __awaiter(_this, void 0, void 0, function () {
var propNode, docBlock, jsDoc, jsDocTags, propertyName, isPropertyModel, propName, propDescriptor, propValuePath, propPropertiesPath, literalType, propValuePathExpression, propPropertiesPath;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
propNode = prop.node;
docBlock = (0, getDocblock_1.default)(prop);
jsDoc = docBlock ? (0, getDoclets_1.default)(docBlock) : { description: '', tags: [] };
jsDocTags = jsDoc.tags ? jsDoc.tags : [];
propertyName = bt.isIdentifier(propNode.key)
? propNode.key.name
: bt.isStringLiteral(propNode.key)
? propNode.key.value
: null;
if (!propertyName) {
return [2 /*return*/];
}
isPropertyModel = jsDocTags.some(function (t) { return t.title === 'model'; }) || propertyName === modelPropertyName;
propName = isPropertyModel ? 'v-model' : propertyName;
propDescriptor = documentation.getPropDescriptor(propName);
propValuePath = prop.get('value');
if (jsDoc.description) {
propDescriptor.description = jsDoc.description;
}
if (jsDocTags.length) {
propDescriptor.tags = (0, transformTagsIntoObject_1.default)(jsDocTags);
}
extractValuesFromTags(propDescriptor);
if (!(bt.isArrayExpression(propValuePath.node) || bt.isIdentifier(propValuePath.node))) return [3 /*break*/, 1];
// if it's an immediately typed property, resolve its type immediately
propDescriptor.type = getTypeFromTypePath(propValuePath);
return [3 /*break*/, 4];
case 1:
if (!bt.isObjectExpression(propValuePath.node)) return [3 /*break*/, 3];
propPropertiesPath = propValuePath
.get('properties')
.filter(function (p) { return bt.isObjectProperty(p.node) || bt.isObjectMethod(p.node); });
literalType = describeType(propPropertiesPath, propDescriptor);
// required
describeRequired(propPropertiesPath, propDescriptor);
// default
describeDefault(propPropertiesPath, propDescriptor, literalType || '');
// validator => values
return [4 /*yield*/, describeValues(propPropertiesPath, propDescriptor, ast, opt)];
case 2:
// validator => values
_a.sent();
return [3 /*break*/, 4];
case 3:
if (bt.isTSAsExpression(propValuePath.node)) {
propValuePathExpression = propValuePath.get('expression');
if (bt.isObjectExpression(propValuePathExpression.node)) {
propPropertiesPath = propValuePathExpression
.get('properties')
.filter(function (p) { return bt.isObjectProperty(p.node); });
// type and values
describeTypeAndValuesFromPath(propValuePath, propDescriptor);
// required
describeRequired(propPropertiesPath, propDescriptor);
// default
describeDefault(propPropertiesPath, propDescriptor, (propDescriptor.type && propDescriptor.type.name) || '');
}
else if (bt.isIdentifier(propValuePathExpression.node)) {
describeTypeAndValuesFromPath(propValuePath, propDescriptor);
}
}
else {
// in any other case, just display the code for the typing
propDescriptor.type = {
name: (0, recast_1.print)(prop.get('value')).code,
func: true
};
}
_a.label = 4;
case 4: return [2 /*return*/];
}
});
}); }))];
case 1:
_a.sent();
return [3 /*break*/, 3];
case 2:
if (bt.isArrayExpression(propsValuePath.node)) {
propsValuePath
.get('elements')
.filter(function (e) { return bt.isStringLiteral(e.node); })
.forEach(function (e) {
var propDescriptor = documentation.getPropDescriptor(e.node.value);
propDescriptor.type = { name: 'undefined' };
});
function describePropsFromValue(documentation, propsValuePath, ast, opt, modelPropertyName = null) {
return __awaiter(this, void 0, void 0, function* () {
if (bt.isObjectExpression(propsValuePath.node)) {
const objProp = propsValuePath.get('properties');
// filter non object properties
const objPropFiltered = objProp.filter((p) => bt.isProperty(p.node));
yield Promise.all(objPropFiltered.map((prop) => __awaiter(this, void 0, void 0, function* () {
const propNode = prop.node;
// description
const docBlock = (0, getDocblock_1.default)(prop);
const jsDoc = docBlock ? (0, getDoclets_1.default)(docBlock) : { description: '', tags: [] };
const jsDocTags = jsDoc.tags ? jsDoc.tags : [];
// if it's the v-model describe it only as such
const propertyName = bt.isIdentifier(propNode.key)
? propNode.key.name
: bt.isStringLiteral(propNode.key)
? propNode.key.value
: null;
if (!propertyName) {
return;
}
const isPropertyModel = jsDocTags.some(t => t.title === 'model') || propertyName === modelPropertyName;
const propName = isPropertyModel ? 'v-model' : propertyName;
const propDescriptor = documentation.getPropDescriptor(propName);
const propValuePath = prop.get('value');
if (jsDoc.description) {
propDescriptor.description = jsDoc.description;
}
if (jsDocTags.length) {
propDescriptor.tags = (0, transformTagsIntoObject_1.default)(jsDocTags);
}
extractValuesFromTags(propDescriptor);
if (bt.isArrayExpression(propValuePath.node) || bt.isIdentifier(propValuePath.node)) {
// if it's an immediately typed property, resolve its type immediately
propDescriptor.type = getTypeFromTypePath(propValuePath);
}
else if (bt.isObjectExpression(propValuePath.node)) {
// standard default + type + required
const propPropertiesPath = propValuePath
.get('properties')
.filter((p) => bt.isObjectProperty(p.node) || bt.isObjectMethod(p.node));
// type
const literalType = describeType(propPropertiesPath, propDescriptor);
// required
describeRequired(propPropertiesPath, propDescriptor);
// default
describeDefault(propPropertiesPath, propDescriptor, literalType || '');
// validator => values
yield describeValues(propPropertiesPath, propDescriptor, ast, opt);
}
else if (bt.isTSAsExpression(propValuePath.node)) {
const propValuePathExpression = propValuePath.get('expression');
if (bt.isObjectExpression(propValuePathExpression.node)) {
// standard default + type + required with TS as annotation
const propPropertiesPath = propValuePathExpression
.get('properties')
.filter((p) => bt.isObjectProperty(p.node));
// type and values
describeTypeAndValuesFromPath(propValuePath, propDescriptor);
// required
describeRequired(propPropertiesPath, propDescriptor);
// default
describeDefault(propPropertiesPath, propDescriptor, (propDescriptor.type && propDescriptor.type.name) || '');
}
_a.label = 3;
case 3: return [2 /*return*/];
}
});
else if (bt.isIdentifier(propValuePathExpression.node)) {
describeTypeAndValuesFromPath(propValuePath, propDescriptor);
}
}
else {
// in any other case, just display the code for the typing
propDescriptor.type = {
name: (0, recast_1.print)(prop.get('value')).code,
func: true
};
}
})));
}
else if (bt.isArrayExpression(propsValuePath.node)) {
propsValuePath
.get('elements')
.filter((e) => bt.isStringLiteral(e.node))
.forEach((e) => {
const propDescriptor = documentation.getPropDescriptor(e.node.value);
propDescriptor.type = { name: 'undefined' };
});
}
});

@@ -234,16 +180,14 @@ }

function describeType(propPropertiesPath, propDescriptor) {
var typeArray = propPropertiesPath.filter((0, getPropsFilter_1.default)('type'));
const typeArray = propPropertiesPath.filter((0, getPropsFilter_1.default)('type'));
if (propDescriptor.tags && propDescriptor.tags.type) {
var typeDesc = propDescriptor.tags.type[0].type;
const [{ type: typeDesc }] = propDescriptor.tags.type;
if (typeDesc) {
var typedAST = (0, getTemplateExpressionAST_1.default)("let a:".concat(typeDesc.name));
var typeValues_1;
const typedAST = (0, getTemplateExpressionAST_1.default)(`let a:${typeDesc.name}`);
let typeValues;
(0, recast_1.visit)(typedAST.program, {
visitVariableDeclaration: function (path) {
var typeAnnotation = path.get('declarations', 0, 'id', 'typeAnnotation').value.typeAnnotation;
visitVariableDeclaration(path) {
const { typeAnnotation } = path.get('declarations', 0, 'id', 'typeAnnotation').value;
if (bt.isTSUnionType(typeAnnotation) &&
typeAnnotation.types.every(function (t) { return bt.isTSLiteralType(t); })) {
typeValues_1 = typeAnnotation.types.map(function (t) {
return t.literal.value.toString();
});
typeAnnotation.types.every(t => bt.isTSLiteralType(t))) {
typeValues = typeAnnotation.types.map((t) => bt.isUnaryExpression(t.literal) ? t.literal.argument.toString() : t.literal.value.toString());
}

@@ -253,4 +197,4 @@ return false;

});
if (typeValues_1) {
propDescriptor.values = typeValues_1;
if (typeValues) {
propDescriptor.values = typeValues;
}

@@ -268,9 +212,9 @@ else {

// deduce the type from default expression
var defaultArray = propPropertiesPath.filter((0, getPropsFilter_1.default)('default'));
const defaultArray = propPropertiesPath.filter((0, getPropsFilter_1.default)('default'));
if (defaultArray.length) {
var typeNode = defaultArray[0].node;
const typeNode = defaultArray[0].node;
if (bt.isObjectProperty(typeNode)) {
var func = bt.isArrowFunctionExpression(typeNode.value) || bt.isFunctionExpression(typeNode.value);
var typeValueNode = defaultArray[0].get('value').node;
var typeName = typeof typeValueNode.value;
const func = bt.isArrowFunctionExpression(typeNode.value) || bt.isFunctionExpression(typeNode.value);
const typeValueNode = defaultArray[0].get('value').node;
const typeName = typeof typeValueNode.value;
propDescriptor.type = { name: func ? 'func' : typeName };

@@ -283,3 +227,3 @@ }

exports.describeType = describeType;
var VALID_VUE_TYPES = [
const VALID_VUE_TYPES = [
'string',

@@ -295,3 +239,3 @@ 'number',

function resolveParenthesis(typeAnnotation) {
var finalAnno = typeAnnotation;
let finalAnno = typeAnnotation;
while (bt.isTSParenthesizedType(finalAnno)) {

@@ -304,3 +248,3 @@ finalAnno = finalAnno.typeAnnotation;

// values
var values = getValuesFromTypePath(propPropertiesPath.node.typeAnnotation);
const values = getValuesFromTypePath(propPropertiesPath.node.typeAnnotation);
// if it has an "as" annotation defining values

@@ -320,5 +264,5 @@ if (values) {

function getTypeFromTypePath(typePath) {
var typeNode = typePath.node;
var typeAnnotation = typeNode.typeAnnotation;
var typeName = bt.isTSTypeReference(typeAnnotation) && typeAnnotation.typeParameters
const typeNode = typePath.node;
const { typeAnnotation } = typeNode;
const typeName = bt.isTSTypeReference(typeAnnotation) && typeAnnotation.typeParameters
? (0, recast_1.print)(resolveParenthesis(typeAnnotation.typeParameters.params[0])).code

@@ -328,3 +272,3 @@ : bt.isArrayExpression(typeNode)

.get('elements')
.map(function (t) { return getTypeFromTypePath(t).name; })
.map((t) => getTypeFromTypePath(t).name)
.join('|')

@@ -349,3 +293,3 @@ : typeNode &&

if (bt.isTSTypeReference(typeAnnotation) && typeAnnotation.typeParameters) {
var type = resolveParenthesis(typeAnnotation.typeParameters.params[0]);
const type = resolveParenthesis(typeAnnotation.typeParameters.params[0]);
return getValuesFromTypeAnnotation(type);

@@ -356,4 +300,4 @@ }

function getValuesFromTypeAnnotation(type) {
if (bt.isTSUnionType(type) && type.types.every(function (t) { return bt.isTSLiteralType(t); })) {
return type.types.map(function (t) { return (bt.isTSLiteralType(t) ? t.literal.value.toString() : ''); });
if (bt.isTSUnionType(type) && type.types.every(t => bt.isTSLiteralType(t))) {
return type.types.map(t => ((bt.isTSLiteralType(t) && !bt.isUnaryExpression(t.literal)) ? t.literal.value.toString() : ''));
}

@@ -364,5 +308,5 @@ return undefined;

function describeRequired(propPropertiesPath, propDescriptor) {
var requiredArray = propPropertiesPath.filter((0, getPropsFilter_1.default)('required'));
var requiredNode = requiredArray.length ? requiredArray[0].get('value').node : undefined;
var required = requiredNode && bt.isBooleanLiteral(requiredNode) ? requiredNode.value : undefined;
const requiredArray = propPropertiesPath.filter((0, getPropsFilter_1.default)('required'));
const requiredNode = requiredArray.length ? requiredArray[0].get('value').node : undefined;
const required = requiredNode && bt.isBooleanLiteral(requiredNode) ? requiredNode.value : undefined;
if (required !== undefined) {

@@ -375,3 +319,3 @@ propDescriptor.required = required;

var _a;
var defaultArray = propPropertiesPath.filter((0, getPropsFilter_1.default)('default'));
const defaultArray = propPropertiesPath.filter((0, getPropsFilter_1.default)('default'));
if (defaultArray.length) {

@@ -381,7 +325,7 @@ /**

*/
var defaultValueIsProp = bt.isObjectProperty(defaultArray[0].value);
const defaultValueIsProp = bt.isObjectProperty(defaultArray[0].value);
/**
* This means the default value is formatted like so: `default () { return {} }`
*/
var defaultValueIsObjectMethod = bt.isObjectMethod(defaultArray[0].value);
const defaultValueIsObjectMethod = bt.isObjectMethod(defaultArray[0].value);
// objects and arrays should try to extract the body from functions

@@ -391,5 +335,5 @@ if (propType === 'object' || propType === 'array') {

/* TODO: add correct type info here ↓ */
var defaultFunction = defaultArray[0].get('value');
var isArrowFunction = bt.isArrowFunctionExpression(defaultFunction.node);
var isOldSchoolFunction = bt.isFunctionExpression(defaultFunction.node);
const defaultFunction = defaultArray[0].get('value');
const isArrowFunction = bt.isArrowFunctionExpression(defaultFunction.node);
const isOldSchoolFunction = bt.isFunctionExpression(defaultFunction.node);
// if default is undefined or null, literals are allowed

@@ -410,10 +354,10 @@ if (bt.isNullLiteral(defaultFunction.node) ||

if (isArrowFunction) {
var arrowFunctionBody = defaultFunction.get('body');
const arrowFunctionBody = defaultFunction.get('body');
// arrow function looks like `() => { return {} }`
if (bt.isBlockStatement(arrowFunctionBody.node)) {
var rawValueParsed_1 = getRawValueParsedFromFunctionsBlockStatementNode(arrowFunctionBody.node);
if (rawValueParsed_1) {
const rawValueParsed = getRawValueParsedFromFunctionsBlockStatementNode(arrowFunctionBody.node);
if (rawValueParsed) {
propDescriptor.defaultValue = {
func: false,
value: rawValueParsed_1
value: rawValueParsed
};

@@ -425,4 +369,4 @@ return;

bt.isObjectExpression(arrowFunctionBody.node)) {
var rawCode = (0, recast_1.print)(arrowFunctionBody.node).code;
var value = ((_a = arrowFunctionBody.node.extra) === null || _a === void 0 ? void 0 : _a.parenthesized)
const rawCode = (0, recast_1.print)(arrowFunctionBody.node).code;
const value = ((_a = arrowFunctionBody.node.extra) === null || _a === void 0 ? void 0 : _a.parenthesized)
? rawCode.slice(1, rawCode.length - 1)

@@ -432,3 +376,3 @@ : rawCode;

func: false,
value: value
value
};

@@ -448,7 +392,7 @@ return;

/* todo: add correct type info here ↓ */
var defaultBlockStatement = defaultValueIsObjectMethod
const defaultBlockStatement = defaultValueIsObjectMethod
? defaultArray[0].get('body')
: defaultArray[0].get('value').get('body');
var defaultBlockStatementNode = defaultBlockStatement.node;
var rawValueParsed = getRawValueParsedFromFunctionsBlockStatementNode(defaultBlockStatementNode);
const defaultBlockStatementNode = defaultBlockStatement.node;
const rawValueParsed = getRawValueParsedFromFunctionsBlockStatementNode(defaultBlockStatementNode);
if (rawValueParsed) {

@@ -465,7 +409,7 @@ propDescriptor.defaultValue = {

// in this case, just return the rawValue
var defaultPath = defaultArray[0].get('value');
let defaultPath = defaultArray[0].get('value');
if (bt.isTSAsExpression(defaultPath.value)) {
defaultPath = defaultPath.get('expression');
}
var rawValue = (0, recast_1.print)(defaultPath).code;
const rawValue = (0, recast_1.print)(defaultPath).code;
propDescriptor.defaultValue = {

@@ -479,9 +423,9 @@ func: bt.isFunction(defaultPath.node),

// in this case, just the function needs to be reconstructed a bit
var defaultObjectMethod = defaultArray[0].get('value');
var paramNodeArray = defaultObjectMethod.node.params;
var params = paramNodeArray.map(function (p) { return p.name; }).join(', ');
var defaultBlockStatement = defaultArray[0].get('body');
var rawValue = (0, recast_1.print)(defaultBlockStatement).code;
const defaultObjectMethod = defaultArray[0].get('value');
const paramNodeArray = defaultObjectMethod.node.params;
const params = paramNodeArray.map((p) => p.name).join(', ');
const defaultBlockStatement = defaultArray[0].get('body');
const rawValue = (0, recast_1.print)(defaultBlockStatement).code;
// the function should be reconstructed as "old-school" function, because they have the same handling of "this", whereas arrow functions do not.
var rawValueParsed = "function(".concat(params, ") ").concat(rawValue.trim());
const rawValueParsed = `function(${params}) ${rawValue.trim()}`;
propDescriptor.defaultValue = {

@@ -498,37 +442,27 @@ func: true,

function describeValues(propPropertiesPath, propDescriptor, ast, options) {
return __awaiter(this, void 0, void 0, function () {
var validatorArray, validatorNode, values;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
if (propDescriptor.values) {
return [2 /*return*/];
}
validatorArray = propPropertiesPath.filter((0, getPropsFilter_1.default)('validator'));
if (!validatorArray.length) return [3 /*break*/, 2];
validatorNode = validatorArray[0].get('value').node;
return [4 /*yield*/, (0, parseValidator_1.default)(validatorNode, ast, options)];
case 1:
values = _a.sent();
if (values) {
propDescriptor.values = values;
}
_a.label = 2;
case 2: return [2 /*return*/];
return __awaiter(this, void 0, void 0, function* () {
if (propDescriptor.values) {
return;
}
const validatorArray = propPropertiesPath.filter((0, getPropsFilter_1.default)('validator'));
if (validatorArray.length) {
const validatorNode = validatorArray[0].get('value').node;
const values = yield (0, parseValidator_1.default)(validatorNode, ast, options);
if (values) {
propDescriptor.values = values;
}
});
}
});
}
function extractValuesFromTags(propDescriptor) {
var _a;
if (propDescriptor.tags && propDescriptor.tags.values) {
var values = propDescriptor.tags.values.map(function (tag) {
var description = tag.description;
var choices = typeof description === 'string' ? description.split(',') : undefined;
const values = propDescriptor.tags.values.map(tag => {
const description = tag.description;
const choices = typeof description === 'string' ? description.split(',') : undefined;
if (choices) {
return choices.map(function (v) { return v.trim(); });
return choices.map((v) => v.trim());
}
return [];
});
propDescriptor.values = (_a = []).concat.apply(_a, values);
propDescriptor.values = [].concat(...values);
delete propDescriptor.tags.values;

@@ -544,18 +478,18 @@ }

function getModelPropName(path) {
var modelPath = path
const modelPath = path
.get('properties')
.filter(function (p) { return bt.isObjectProperty(p.node) && (0, getPropsFilter_1.default)('model')(p); });
.filter((p) => bt.isObjectProperty(p.node) && (0, getPropsFilter_1.default)('model')(p));
if (!modelPath.length) {
return null;
}
var modelPropertyNamePath = modelPath.length &&
const modelPropertyNamePath = modelPath.length &&
modelPath[0]
.get('value')
.get('properties')
.filter(function (p) { return bt.isObjectProperty(p.node) && (0, getPropsFilter_1.default)('prop')(p); });
.filter((p) => bt.isObjectProperty(p.node) && (0, getPropsFilter_1.default)('prop')(p));
if (!modelPropertyNamePath.length) {
return null;
}
var valuePath = modelPropertyNamePath[0].get('value');
const valuePath = modelPropertyNamePath[0].get('value');
return bt.isStringLiteral(valuePath.node) ? valuePath.node.value : null;
}
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {

@@ -26,8 +30,8 @@ if (k2 === undefined) k2 = k;

exports.parseSlotDocBlock = exports.getSlotComment = void 0;
var bt = __importStar(require("@babel/types"));
var recast_1 = require("recast");
var getDoclets_1 = __importDefault(require("../utils/getDoclets"));
var getDocblock_1 = require("../utils/getDocblock");
var transformTagsIntoObject_1 = __importDefault(require("../utils/transformTagsIntoObject"));
var getProperties_1 = __importDefault(require("./utils/getProperties"));
const bt = __importStar(require("@babel/types"));
const recast_1 = require("recast");
const getDoclets_1 = __importDefault(require("../utils/getDoclets"));
const getDocblock_1 = require("../utils/getDocblock");
const transformTagsIntoObject_1 = __importDefault(require("../utils/transformTagsIntoObject"));
const getProperties_1 = __importDefault(require("./utils/getProperties"));
/**

@@ -40,3 +44,3 @@ * Extract slots information form the render function of an object-style VueJs component

if (bt.isObjectExpression(path.node)) {
var renderPath = (0, getProperties_1.default)(path, 'render');
const renderPath = (0, getProperties_1.default)(path, 'render');
// if no prop return

@@ -46,3 +50,3 @@ if (!renderPath.length) {

}
var renderValuePath = bt.isObjectProperty(renderPath[0].node)
const renderValuePath = bt.isObjectProperty(renderPath[0].node)
? renderPath[0].get('value')

@@ -52,3 +56,3 @@ : renderPath[0];

// this.$slots.default()
visitCallExpression: function (pathCall) {
visitCallExpression(pathCall) {
if (bt.isMemberExpression(pathCall.node.callee) &&

@@ -61,5 +65,5 @@ bt.isMemberExpression(pathCall.node.callee.object) &&

pathCall.node.callee.object.property.name === '$scopedSlots')) {
var doc = documentation.getSlotDescriptor(pathCall.node.callee.property.name);
var comment = getSlotComment(pathCall, doc);
var bindings = pathCall.node.arguments[0];
const doc = documentation.getSlotDescriptor(pathCall.node.callee.property.name);
const comment = getSlotComment(pathCall, doc);
const bindings = pathCall.node.arguments[0];
if (bt.isObjectExpression(bindings) && bindings.properties.length) {

@@ -74,3 +78,3 @@ doc.bindings = getBindings(bindings, comment ? comment.bindings : undefined);

// this.$slots.mySlot
visitMemberExpression: function (pathMember) {
visitMemberExpression(pathMember) {
if (bt.isMemberExpression(pathMember.node.object) &&

@@ -82,3 +86,3 @@ bt.isThisExpression(pathMember.node.object.object) &&

bt.isIdentifier(pathMember.node.property)) {
var doc = documentation.getSlotDescriptor(pathMember.node.property.name);
const doc = documentation.getSlotDescriptor(pathMember.node.property.name);
getSlotComment(pathMember, doc);

@@ -90,17 +94,15 @@ return false;

},
visitJSXElement: function (pathJSX) {
var tagName = pathJSX.node.openingElement.name;
var nodeJSX = pathJSX.node;
visitJSXElement(pathJSX) {
const tagName = pathJSX.node.openingElement.name;
const nodeJSX = pathJSX.node;
if (bt.isJSXIdentifier(tagName) && tagName.name === 'slot') {
var doc = documentation.getSlotDescriptor(getName(nodeJSX));
var parentNode = pathJSX.parentPath.node;
var comment_1;
const doc = documentation.getSlotDescriptor(getName(nodeJSX));
const parentNode = pathJSX.parentPath.node;
let comment;
if (bt.isJSXElement(parentNode)) {
comment_1 = getJSXDescription(nodeJSX, parentNode.children, doc);
comment = getJSXDescription(nodeJSX, parentNode.children, doc);
}
var bindings = nodeJSX.openingElement.attributes;
const bindings = nodeJSX.openingElement.attributes;
if (bindings && bindings.length) {
doc.bindings = bindings.map(function (b) {
return getBindingsFromJSX(b, comment_1 ? comment_1.bindings : undefined);
});
doc.bindings = bindings.map((b) => getBindingsFromJSX(b, comment ? comment.bindings : undefined));
}

@@ -122,12 +124,12 @@ return false;

function getName(nodeJSX) {
var oe = nodeJSX.openingElement;
var names = oe.attributes.filter(function (a) { return bt.isJSXAttribute(a) && a.name.name === 'name'; });
var nameNode = names.length ? names[0].value : null;
const oe = nodeJSX.openingElement;
const names = oe.attributes.filter((a) => bt.isJSXAttribute(a) && a.name.name === 'name');
const nameNode = names.length ? names[0].value : null;
return nameNode && bt.isStringLiteral(nameNode) ? nameNode.value : 'default';
}
function getJSXDescription(nodeJSX, siblings, descriptor) {
var indexInParent = siblings.indexOf(nodeJSX);
var commentExpression = null;
for (var i = indexInParent - 1; i > -1; i--) {
var currentNode = siblings[i];
const indexInParent = siblings.indexOf(nodeJSX);
let commentExpression = null;
for (let i = indexInParent - 1; i > -1; i--) {
const currentNode = siblings[i];
if (bt.isJSXExpressionContainer(currentNode)) {

@@ -141,8 +143,8 @@ commentExpression = currentNode;

}
var cmts = commentExpression.expression.innerComments;
var lastComment = cmts[cmts.length - 1];
const cmts = commentExpression.expression.innerComments;
const lastComment = cmts[cmts.length - 1];
return parseCommentNode(lastComment, descriptor);
}
function getSlotComment(path, descriptor) {
var desc = getExpressionDescription(path, descriptor);
const desc = getExpressionDescription(path, descriptor);
if (desc) {

@@ -154,3 +156,3 @@ return desc;

// 1: find the statement
var i = 10;
let i = 10;
while (i-- && path && !isStatement(path)) {

@@ -164,3 +166,3 @@ path = path.parentPath;

function getExpressionDescription(path, descriptor) {
var node = path.node;
const node = path.node;
if (!node || !node.leadingComments || node.leadingComments.length === 0) {

@@ -179,15 +181,15 @@ return undefined;

var _a;
var docBlock = (0, getDocblock_1.parseDocblock)(str).trim();
var jsDoc = (0, getDoclets_1.default)(docBlock);
const docBlock = (0, getDocblock_1.parseDocblock)(str).trim();
const jsDoc = (0, getDoclets_1.default)(docBlock);
if (!((_a = jsDoc.tags) === null || _a === void 0 ? void 0 : _a.length)) {
return undefined;
}
var slotTags = jsDoc.tags.filter(function (t) { return t.title === 'slot'; });
const slotTags = jsDoc.tags.filter(t => t.title === 'slot');
if (slotTags.length) {
var tagContent = slotTags[0].content;
var description = typeof tagContent === 'string' ? tagContent : undefined;
const tagContent = slotTags[0].content;
const description = typeof tagContent === 'string' ? tagContent : undefined;
if (description && (!descriptor.description || !descriptor.description.length)) {
descriptor.description = description;
}
var tags = jsDoc.tags.filter(function (t) { return t.title !== 'slot' && t.title !== 'binding'; });
const tags = jsDoc.tags.filter(t => t.title !== 'slot' && t.title !== 'binding');
if (tags.length) {

@@ -197,3 +199,3 @@ descriptor.tags = (0, transformTagsIntoObject_1.default)(tags);

return {
bindings: jsDoc.tags.filter(function (t) { return t.title === 'binding'; })
bindings: jsDoc.tags.filter(t => t.title === 'binding')
};

@@ -205,11 +207,11 @@ }

function getBindings(node, bindingsFromComments) {
return node.properties.reduce(function (bindings, prop) {
return node.properties.reduce((bindings, prop) => {
if (bt.isIdentifier(prop.key)) {
var name_1 = prop.key.name;
var description = prop.leadingComments && prop.leadingComments.length
const name = prop.key.name;
const description = prop.leadingComments && prop.leadingComments.length
? (0, getDocblock_1.parseDocblock)(prop.leadingComments[prop.leadingComments.length - 1].value)
: undefined;
if (!description) {
var descbinding = bindingsFromComments
? bindingsFromComments.filter(function (b) { return b.name === name_1; })[0]
const descbinding = bindingsFromComments
? bindingsFromComments.filter(b => b.name === name)[0]
: undefined;

@@ -224,4 +226,4 @@ if (descbinding) {

title: 'binding',
name: name_1,
description: description
name,
description
});

@@ -234,4 +236,4 @@ }

function getBindingsFromJSX(attr, bindings) {
var name = attr.name.name;
var descbinding = bindings ? bindings.filter(function (b) { return b.name === name; })[0] : undefined;
const name = attr.name.name;
const descbinding = bindings ? bindings.filter(b => b.name === name)[0] : undefined;
if (descbinding) {

@@ -242,4 +244,4 @@ return descbinding;

title: 'binding',
name: name
name
};
}
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {

@@ -25,6 +29,6 @@ if (k2 === undefined) k2 = k;

Object.defineProperty(exports, "__esModule", { value: true });
var bt = __importStar(require("@babel/types"));
var recast_1 = require("recast");
var slotHandler_1 = require("./slotHandler");
var getProperties_1 = __importDefault(require("./utils/getProperties"));
const bt = __importStar(require("@babel/types"));
const recast_1 = require("recast");
const slotHandler_1 = require("./slotHandler");
const getProperties_1 = __importDefault(require("./utils/getProperties"));
/**

@@ -38,3 +42,3 @@ * Extract slots information form the render function of an object-style VueJs component

if (bt.isObjectExpression(path.node)) {
var functionalPath = (0, getProperties_1.default)(path, 'functional');
const functionalPath = (0, getProperties_1.default)(path, 'functional');
// if no prop return

@@ -44,21 +48,21 @@ if (!functionalPath.length || !functionalPath[0].get('value')) {

}
var renderPath = (0, getProperties_1.default)(path, 'render');
const renderPath = (0, getProperties_1.default)(path, 'render');
if (!renderPath || !renderPath.length) {
return Promise.resolve();
}
var renderValuePath = bt.isObjectProperty(renderPath[0].node)
const renderValuePath = bt.isObjectProperty(renderPath[0].node)
? renderPath[0].get('value')
: renderPath[0];
var contextVariable = renderValuePath.get('params', 1);
const contextVariable = renderValuePath.get('params', 1);
if (contextVariable.value) {
if (bt.isIdentifier(contextVariable.value)) {
var contextVariableName_1 = contextVariable.value.name;
const contextVariableName = contextVariable.value.name;
(0, recast_1.visit)(renderValuePath.node, {
// context.children
visitMemberExpression: function (pathMember) {
visitMemberExpression(pathMember) {
if (bt.isIdentifier(pathMember.node.object) &&
pathMember.node.object.name === contextVariableName_1 &&
pathMember.node.object.name === contextVariableName &&
bt.isIdentifier(pathMember.node.property) &&
pathMember.node.property.name === 'children') {
var doc = documentation.getSlotDescriptor('default');
const doc = documentation.getSlotDescriptor('default');
(0, slotHandler_1.getSlotComment)(pathMember, doc);

@@ -73,10 +77,10 @@ return false;

else {
var childrenVarValueName_1 = (_a = contextVariable
const childrenVarValueName = (_a = contextVariable
.get('properties')
.value.filter(function (a) { return bt.isIdentifier(a.key) && a.key.name === 'children'; })[0]) === null || _a === void 0 ? void 0 : _a.value.name;
.value.filter((a) => bt.isIdentifier(a.key) && a.key.name === 'children')[0]) === null || _a === void 0 ? void 0 : _a.value.name;
(0, recast_1.visit)(renderValuePath.node, {
// destructured children
visitIdentifier: function (pathMember) {
if (pathMember.node.name === childrenVarValueName_1) {
var doc = documentation.getSlotDescriptor('default');
visitIdentifier(pathMember) {
if (pathMember.node.name === childrenVarValueName) {
const doc = documentation.getSlotDescriptor('default');
(0, slotHandler_1.getSlotComment)(pathMember, doc);

@@ -83,0 +87,0 @@ return false;

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {

@@ -25,6 +29,6 @@ if (k2 === undefined) k2 = k;

Object.defineProperty(exports, "__esModule", { value: true });
var bt = __importStar(require("@babel/types"));
var getDoclets_1 = __importDefault(require("../utils/getDoclets"));
var getProperties_1 = __importDefault(require("./utils/getProperties"));
var getDocblock_1 = __importDefault(require("../utils/getDocblock"));
const bt = __importStar(require("@babel/types"));
const getDoclets_1 = __importDefault(require("../utils/getDoclets"));
const getProperties_1 = __importDefault(require("./utils/getProperties"));
const getDocblock_1 = __importDefault(require("../utils/getDocblock"));
/**

@@ -37,10 +41,10 @@ * Extract slots information from the render or setup function of an object-style VueJs component

if (bt.isObjectExpression(path.node)) {
var renderPath = (0, getProperties_1.default)(path, 'render');
var setupPath = (0, getProperties_1.default)(path, 'setup');
const renderPath = (0, getProperties_1.default)(path, 'render');
const setupPath = (0, getProperties_1.default)(path, 'setup');
if (!renderPath.length && !setupPath.length) {
return Promise.resolve();
}
var functionPath = renderPath.length ? renderPath : setupPath;
var i = 0;
var docBlock = (0, getDocblock_1.default)(functionPath[0], { commentIndex: i });
const functionPath = renderPath.length ? renderPath : setupPath;
let i = 0;
let docBlock = (0, getDocblock_1.default)(functionPath[0], { commentIndex: i });
while (docBlock) {

@@ -51,10 +55,10 @@ // if no doc block return

}
var jsDoc = (0, getDoclets_1.default)(docBlock);
const jsDoc = (0, getDoclets_1.default)(docBlock);
if (jsDoc.tags) {
var slotTag = jsDoc.tags.find(function (a) { return a.title === 'slot'; });
const slotTag = jsDoc.tags.find(a => a.title === 'slot');
if (slotTag) {
var name_1 = typeof slotTag.content === 'string' ? slotTag.content : 'default';
var slotDescriptor = documentation.getSlotDescriptor(name_1);
const name = typeof slotTag.content === 'string' ? slotTag.content : 'default';
const slotDescriptor = documentation.getSlotDescriptor(name);
slotDescriptor.description = jsDoc.description;
var bindingsTag = jsDoc.tags.filter(function (t) { return t.title === 'binding'; });
const bindingsTag = jsDoc.tags.filter(t => t.title === 'binding');
if (bindingsTag) {

@@ -61,0 +65,0 @@ slotDescriptor.bindings = bindingsTag;

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {

@@ -22,12 +26,10 @@ if (k2 === undefined) k2 = k;

Object.defineProperty(exports, "__esModule", { value: true });
var bt = __importStar(require("@babel/types"));
const bt = __importStar(require("@babel/types"));
function getProperties(path, id) {
return path
.get('properties')
.filter(function (p) {
return (bt.isObjectProperty(p.node) || bt.isObjectMethod(p.node)) &&
bt.isIdentifier(p.node.key) &&
p.node.key.name === id;
});
.filter((p) => (bt.isObjectProperty(p.node) || bt.isObjectMethod(p.node)) &&
bt.isIdentifier(p.node.key) &&
p.node.key.name === id);
}
exports.default = getProperties;
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {

@@ -30,29 +34,2 @@ if (k2 === undefined) k2 = k;

};
var __generator = (this && this.__generator) || function (thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (_) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
};
var __importDefault = (this && this.__importDefault) || function (mod) {

@@ -62,9 +39,9 @@ return (mod && mod.__esModule) ? mod : { "default": mod };

Object.defineProperty(exports, "__esModule", { value: true });
var bt = __importStar(require("@babel/types"));
var path = __importStar(require("path"));
var ast_types_1 = require("ast-types");
var makePathResolver_1 = __importDefault(require("../../utils/makePathResolver"));
var resolveRequired_1 = __importDefault(require("../../utils/resolveRequired"));
var recursiveResolveIEV_1 = __importDefault(require("../../utils/recursiveResolveIEV"));
var getPathFromExportedValue_1 = __importDefault(require("../../utils/getPathFromExportedValue"));
const bt = __importStar(require("@babel/types"));
const path = __importStar(require("path"));
const ast_types_1 = require("ast-types");
const makePathResolver_1 = __importDefault(require("../../utils/makePathResolver"));
const resolveRequired_1 = __importDefault(require("../../utils/resolveRequired"));
const recursiveResolveIEV_1 = __importDefault(require("../../utils/recursiveResolveIEV"));
const getPathFromExportedValue_1 = __importDefault(require("../../utils/getPathFromExportedValue"));
/**

@@ -81,3 +58,3 @@ * Determines if node contains the value -1

function parseValidatorForValues(validatorNode, ast, options) {
return __awaiter(this, void 0, void 0, function () {
return __awaiter(this, void 0, void 0, function* () {
/**

@@ -88,134 +65,99 @@ * Resolves a variable value from its identifier (name)

function resolveValueFromIdentifier(identifierName) {
return __awaiter(this, void 0, void 0, function () {
var varPath, varToFilePath, originalDirName, pathResolver, _a, exportName, filePath, p;
return __generator(this, function (_b) {
switch (_b.label) {
case 0:
(0, ast_types_1.visit)(ast, {
visitVariableDeclaration: function (p) {
p.node.declarations.forEach(function (decl, i) {
if (bt.isVariableDeclarator(decl) &&
bt.isIdentifier(decl.id) &&
decl.id.name === identifierName) {
varPath = p.get('declarations', i, 'init');
}
});
return false;
}
});
if (varPath && bt.isArrayExpression(varPath.node)) {
return [2 /*return*/, varPath.node.elements.map(function (e) { return e.value; }).filter(function (e) { return e; })];
return __awaiter(this, void 0, void 0, function* () {
let varPath;
(0, ast_types_1.visit)(ast, {
visitVariableDeclaration(p) {
p.node.declarations.forEach((decl, i) => {
if (bt.isVariableDeclarator(decl) &&
bt.isIdentifier(decl.id) &&
decl.id.name === identifierName) {
varPath = p.get('declarations', i, 'init');
}
varToFilePath = (0, resolveRequired_1.default)(ast, [identifierName]);
originalDirName = path.dirname(options.filePath);
pathResolver = (0, makePathResolver_1.default)(originalDirName, options.alias, options.modules);
// resolve where sources are through immediately exported variables
return [4 /*yield*/, (0, recursiveResolveIEV_1.default)(pathResolver, varToFilePath, options.validExtends)];
case 1:
// resolve where sources are through immediately exported variables
_b.sent();
if (!varToFilePath[identifierName]) return [3 /*break*/, 3];
_a = varToFilePath[identifierName], exportName = _a.exportName, filePath = _a.filePath;
return [4 /*yield*/, (0, getPathFromExportedValue_1.default)(pathResolver, exportName, filePath, options)];
case 2:
p = _b.sent();
if (p && bt.isArrayExpression(p.node)) {
return [2 /*return*/, p.node.elements.map(function (e) { return e.value; }).filter(function (e) { return e; })];
}
_b.label = 3;
case 3: return [2 /*return*/, undefined];
});
return false;
}
});
if (varPath && bt.isArrayExpression(varPath.node)) {
return varPath.node.elements.map((e) => e.value).filter(e => e);
}
const varToFilePath = (0, resolveRequired_1.default)(ast, [identifierName]);
const originalDirName = path.dirname(options.filePath);
const pathResolver = (0, makePathResolver_1.default)(originalDirName, options.alias, options.modules);
// resolve where sources are through immediately exported variables
yield (0, recursiveResolveIEV_1.default)(pathResolver, varToFilePath, options.validExtends);
if (varToFilePath[identifierName]) {
// load value found from read file
const { exportName, filePath } = varToFilePath[identifierName];
const p = yield (0, getPathFromExportedValue_1.default)(pathResolver, exportName, filePath, options);
if (p && bt.isArrayExpression(p.node)) {
return p.node.elements.map((e) => e.value).filter(e => e);
}
}
return undefined;
});
}
function extractStringArray(valuesObjectNode) {
return __awaiter(this, void 0, void 0, function () {
var _a;
return __generator(this, function (_b) {
switch (_b.label) {
case 0:
if (!bt.isIdentifier(valuesObjectNode)) return [3 /*break*/, 2];
return [4 /*yield*/, resolveValueFromIdentifier(valuesObjectNode.name)];
case 1:
_a = _b.sent();
return [3 /*break*/, 3];
case 2:
_a = bt.isArrayExpression(valuesObjectNode)
? valuesObjectNode.elements.map(function (e) { return e.value; }).filter(function (e) { return e; })
: undefined;
_b.label = 3;
case 3: return [2 /*return*/, _a];
}
});
return __awaiter(this, void 0, void 0, function* () {
return bt.isIdentifier(valuesObjectNode)
? yield resolveValueFromIdentifier(valuesObjectNode.name)
: bt.isArrayExpression(valuesObjectNode)
? valuesObjectNode.elements.map((e) => e.value).filter(e => e)
: undefined;
});
}
var returnedExpression, varName, valuesNode, values, _a;
return __generator(this, function (_b) {
switch (_b.label) {
case 0:
returnedExpression = (bt.isMethod(validatorNode) || bt.isFunctionExpression(validatorNode)) &&
validatorNode.body.body.length === 1 &&
bt.isReturnStatement(validatorNode.body.body[0])
? validatorNode.body.body[0].argument
: bt.isArrowFunctionExpression(validatorNode)
? validatorNode.body
: undefined;
varName = validatorNode.params && bt.isIdentifier(validatorNode.params[0])
? validatorNode.params[0].name
: undefined;
if (!bt.isBinaryExpression(returnedExpression)) return [3 /*break*/, 4];
valuesNode = void 0;
switch (returnedExpression.operator) {
case '>':
if (isMinusOne(returnedExpression.right)) {
valuesNode = returnedExpression.left;
}
break;
case '<':
if (bt.isExpression(returnedExpression.left) && isMinusOne(returnedExpression.left)) {
valuesNode = returnedExpression.right;
}
break;
case '!==':
case '!=':
if (bt.isExpression(returnedExpression.left) && isMinusOne(returnedExpression.left)) {
valuesNode = returnedExpression.right;
}
else if (isMinusOne(returnedExpression.right)) {
valuesNode = returnedExpression.left;
}
break;
default:
return [2 /*return*/, undefined];
const returnedExpression = (bt.isMethod(validatorNode) || bt.isFunctionExpression(validatorNode)) &&
validatorNode.body.body.length === 1 &&
bt.isReturnStatement(validatorNode.body.body[0])
? validatorNode.body.body[0].argument
: bt.isArrowFunctionExpression(validatorNode)
? validatorNode.body
: undefined;
const varName = validatorNode.params && bt.isIdentifier(validatorNode.params[0])
? validatorNode.params[0].name
: undefined;
if (bt.isBinaryExpression(returnedExpression)) {
let valuesNode;
switch (returnedExpression.operator) {
case '>':
if (isMinusOne(returnedExpression.right)) {
valuesNode = returnedExpression.left;
}
if (!(bt.isCallExpression(valuesNode) &&
bt.isIdentifier(valuesNode.arguments[0]) &&
varName === valuesNode.arguments[0].name &&
bt.isMemberExpression(valuesNode.callee) &&
bt.isIdentifier(valuesNode.callee.property) &&
valuesNode.callee.property.name === 'indexOf')) return [3 /*break*/, 2];
return [4 /*yield*/, extractStringArray(valuesNode.callee.object)];
case 1:
_a = _b.sent();
return [3 /*break*/, 3];
case 2:
_a = undefined;
_b.label = 3;
case 3:
values = _a;
return [2 /*return*/, values];
case 4:
if (bt.isCallExpression(returnedExpression)) {
if (bt.isMemberExpression(returnedExpression.callee) &&
bt.isIdentifier(returnedExpression.callee.property) &&
returnedExpression.callee.property.name === 'includes') {
return [2 /*return*/, extractStringArray(returnedExpression.callee.object)];
}
break;
case '<':
if (bt.isExpression(returnedExpression.left) && isMinusOne(returnedExpression.left)) {
valuesNode = returnedExpression.right;
}
_b.label = 5;
case 5: return [2 /*return*/, undefined];
break;
case '!==':
case '!=':
if (bt.isExpression(returnedExpression.left) && isMinusOne(returnedExpression.left)) {
valuesNode = returnedExpression.right;
}
else if (isMinusOne(returnedExpression.right)) {
valuesNode = returnedExpression.left;
}
break;
default:
return undefined;
}
});
const values = bt.isCallExpression(valuesNode) &&
bt.isIdentifier(valuesNode.arguments[0]) &&
varName === valuesNode.arguments[0].name &&
bt.isMemberExpression(valuesNode.callee) &&
bt.isIdentifier(valuesNode.callee.property) &&
valuesNode.callee.property.name === 'indexOf'
? yield extractStringArray(valuesNode.callee.object)
: undefined;
return values;
}
else if (bt.isCallExpression(returnedExpression)) {
if (bt.isMemberExpression(returnedExpression.callee) &&
bt.isIdentifier(returnedExpression.callee.property) &&
returnedExpression.callee.property.name === 'includes') {
return extractStringArray(returnedExpression.callee.object);
}
}
return undefined;
});
}
exports.default = parseValidatorForValues;

@@ -6,5 +6,5 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
var setupEventHandler_1 = __importDefault(require("./setupEventHandler"));
var setupPropHandler_1 = __importDefault(require("./setupPropHandler"));
var setupExposedHandler_1 = __importDefault(require("./setupExposedHandler"));
const setupEventHandler_1 = __importDefault(require("./setupEventHandler"));
const setupPropHandler_1 = __importDefault(require("./setupPropHandler"));
const setupExposedHandler_1 = __importDefault(require("./setupExposedHandler"));
exports.default = [setupEventHandler_1.default, setupPropHandler_1.default, setupExposedHandler_1.default];
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {

@@ -30,29 +34,2 @@ if (k2 === undefined) k2 = k;

};
var __generator = (this && this.__generator) || function (thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (_) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
};
var __importDefault = (this && this.__importDefault) || function (mod) {

@@ -62,9 +39,9 @@ return (mod && mod.__esModule) ? mod : { "default": mod };

Object.defineProperty(exports, "__esModule", { value: true });
var bt = __importStar(require("@babel/types"));
var recast_1 = require("recast");
var getDocblock_1 = __importDefault(require("../utils/getDocblock"));
var getDoclets_1 = __importDefault(require("../utils/getDoclets"));
var getTypeFromAnnotation_1 = __importDefault(require("../utils/getTypeFromAnnotation"));
var eventHandler_1 = require("../script-handlers/eventHandler");
var tsUtils_1 = require("./utils/tsUtils");
const bt = __importStar(require("@babel/types"));
const recast_1 = require("recast");
const getDocblock_1 = __importDefault(require("../utils/getDocblock"));
const getDoclets_1 = __importDefault(require("../utils/getDoclets"));
const getTypeFromAnnotation_1 = __importDefault(require("../utils/getTypeFromAnnotation"));
const eventHandler_1 = require("../script-handlers/eventHandler");
const tsUtils_1 = require("./utils/tsUtils");
/**

@@ -78,9 +55,9 @@ * Extract information from an setup-style VueJs 3 component

function setupEventHandler(documentation, componentDefinition, astPath, opt) {
return __awaiter(this, void 0, void 0, function () {
return __awaiter(this, void 0, void 0, function* () {
function buildEventDescriptor(eventName, eventPath) {
var _a;
var eventDescriptor = documentation.getEventDescriptor(eventName);
var typeParam = eventPath.get('parameters', 1, 'typeAnnotation');
const eventDescriptor = documentation.getEventDescriptor(eventName);
const typeParam = eventPath.get('parameters', 1, 'typeAnnotation');
if (bt.isTSTypeAnnotation(typeParam.node)) {
var type = (_a = (0, getTypeFromAnnotation_1.default)(typeParam.node)) === null || _a === void 0 ? void 0 : _a.name;
const type = (_a = (0, getTypeFromAnnotation_1.default)(typeParam.node)) === null || _a === void 0 ? void 0 : _a.name;
if (type) {

@@ -90,5 +67,5 @@ eventDescriptor.type = { names: [type] };

}
var docBlock = (0, getDocblock_1.default)(eventPath);
const docBlock = (0, getDocblock_1.default)(eventPath);
if (docBlock) {
var jsDoc = (0, getDoclets_1.default)(docBlock);
const jsDoc = (0, getDoclets_1.default)(docBlock);
(0, eventHandler_1.setEventDescriptor)(eventDescriptor, jsDoc);

@@ -98,7 +75,8 @@ }

function readEventsTSTypes(refs) {
refs.each(function (member) {
refs.each((member) => {
if (bt.isTSCallSignatureDeclaration(member.node)) {
var firstParam = member.node.parameters[0].typeAnnotation;
const firstParam = member.node.parameters[0].typeAnnotation;
if (bt.isTSTypeAnnotation(firstParam) &&
bt.isTSLiteralType(firstParam.typeAnnotation) &&
!bt.isUnaryExpression(firstParam.typeAnnotation.literal) &&
typeof firstParam.typeAnnotation.literal.value === 'string') {

@@ -110,41 +88,38 @@ buildEventDescriptor(firstParam.typeAnnotation.literal.value, member);

}
return __generator(this, function (_a) {
(0, recast_1.visit)(astPath.program, {
visitCallExpression: function (nodePath) {
if (bt.isIdentifier(nodePath.node.callee) && nodePath.node.callee.name === 'defineEmits') {
// Array of string where no type is specified
if (bt.isArrayExpression(nodePath.get('arguments', 0).node)) {
nodePath.get('arguments', 0, 'elements').each(function (element) {
if (bt.isStringLiteral(element.node)) {
buildEventDescriptor(element.node.value, element);
(0, recast_1.visit)(astPath.program, {
visitCallExpression(nodePath) {
if (bt.isIdentifier(nodePath.node.callee) && nodePath.node.callee.name === 'defineEmits') {
// Array of string where no type is specified
if (bt.isArrayExpression(nodePath.get('arguments', 0).node)) {
nodePath.get('arguments', 0, 'elements').each((element) => {
if (bt.isStringLiteral(element.node)) {
buildEventDescriptor(element.node.value, element);
}
});
}
// Object where the arguments are validated manually
if (bt.isObjectExpression(nodePath.get('arguments', 0).node)) {
nodePath.get('arguments', 0, 'properties').each((element) => {
if (bt.isObjectProperty(element.node) && bt.isIdentifier(element.node.key)) {
buildEventDescriptor(element.node.key.name, element);
}
});
}
// typescript validation of arguments
if (bt.isTSTypeParameterInstantiation(nodePath.get('typeParameters').node)) {
nodePath.get('typeParameters', 'params').each((param) => {
if (bt.isTSTypeLiteral(param.node)) {
readEventsTSTypes(param.get('members'));
}
else if (bt.isTSTypeReference(param.node) && bt.isIdentifier(param.node.typeName)) {
const resolvedType = (0, tsUtils_1.getTypeDefinitionFromIdentifier)(astPath, param.node.typeName.name);
if (resolvedType) {
readEventsTSTypes(resolvedType);
}
});
}
// Object where the arguments are validated manually
if (bt.isObjectExpression(nodePath.get('arguments', 0).node)) {
nodePath.get('arguments', 0, 'properties').each(function (element) {
if (bt.isObjectProperty(element.node) && bt.isIdentifier(element.node.key)) {
buildEventDescriptor(element.node.key.name, element);
}
});
}
// typescript validation of arguments
if (bt.isTSTypeParameterInstantiation(nodePath.get('typeParameters').node)) {
nodePath.get('typeParameters', 'params').each(function (param) {
if (bt.isTSTypeLiteral(param.node)) {
readEventsTSTypes(param.get('members'));
}
else if (bt.isTSTypeReference(param.node) && bt.isIdentifier(param.node.typeName)) {
var resolvedType = (0, tsUtils_1.getTypeDefinitionFromIdentifier)(astPath, param.node.typeName.name);
if (resolvedType) {
readEventsTSTypes(resolvedType);
}
}
});
}
}
});
}
return false;
}
});
return [2 /*return*/];
return false;
}
});

@@ -151,0 +126,0 @@ });

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {

@@ -30,29 +34,2 @@ if (k2 === undefined) k2 = k;

};
var __generator = (this && this.__generator) || function (thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (_) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
};
var __importDefault = (this && this.__importDefault) || function (mod) {

@@ -62,6 +39,6 @@ return (mod && mod.__esModule) ? mod : { "default": mod };

Object.defineProperty(exports, "__esModule", { value: true });
var bt = __importStar(require("@babel/types"));
var recast_1 = require("recast");
var getDocblock_1 = __importDefault(require("../utils/getDocblock"));
var getDoclets_1 = __importDefault(require("../utils/getDoclets"));
const bt = __importStar(require("@babel/types"));
const recast_1 = require("recast");
const getDocblock_1 = __importDefault(require("../utils/getDocblock"));
const getDoclets_1 = __importDefault(require("../utils/getDoclets"));
/**

@@ -75,8 +52,8 @@ * Extract information from an setup-style VueJs 3 component

function setupExposedHandler(documentation, componentDefinition, astPath, opt) {
return __awaiter(this, void 0, void 0, function () {
return __awaiter(this, void 0, void 0, function* () {
function buildExposedDescriptor(exposedName, exposedPath) {
var exposedDescriptor = documentation.getExposedDescriptor(exposedName);
var docBlock = (0, getDocblock_1.default)(exposedPath);
const exposedDescriptor = documentation.getExposedDescriptor(exposedName);
const docBlock = (0, getDocblock_1.default)(exposedPath);
if (docBlock) {
var jsDoc = (0, getDoclets_1.default)(docBlock);
const jsDoc = (0, getDoclets_1.default)(docBlock);
setExposedDescriptor(exposedDescriptor, jsDoc);

@@ -94,21 +71,18 @@ }

}
return __generator(this, function (_a) {
(0, recast_1.visit)(astPath.program, {
visitCallExpression: function (nodePath) {
if (bt.isIdentifier(nodePath.node.callee) && nodePath.node.callee.name === 'defineExposed') {
if (bt.isObjectExpression(nodePath.get('arguments', 0).node)) {
nodePath.get('arguments', 0, 'properties').each(function (prop) {
if (bt.isIdentifier(prop.node.key)) {
buildExposedDescriptor(prop.node.key.name, prop);
}
else if (bt.isStringLiteral(prop.node.key)) {
buildExposedDescriptor(prop.node.key.value, prop);
}
});
}
(0, recast_1.visit)(astPath.program, {
visitCallExpression(nodePath) {
if (bt.isIdentifier(nodePath.node.callee) && nodePath.node.callee.name === 'defineExpose') {
if (bt.isObjectExpression(nodePath.get('arguments', 0).node)) {
nodePath.get('arguments', 0, 'properties').each((prop) => {
if (bt.isIdentifier(prop.node.key)) {
buildExposedDescriptor(prop.node.key.name, prop);
}
else if (bt.isStringLiteral(prop.node.key)) {
buildExposedDescriptor(prop.node.key.value, prop);
}
});
}
return false;
}
});
return [2 /*return*/];
return false;
}
});

@@ -115,0 +89,0 @@ });

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {

@@ -30,36 +34,9 @@ if (k2 === undefined) k2 = k;

};
var __generator = (this && this.__generator) || function (thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (_) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.getPropsFromLiteralType = void 0;
var bt = __importStar(require("@babel/types"));
var recast_1 = require("recast");
var getTypeFromAnnotation_1 = __importStar(require("../utils/getTypeFromAnnotation"));
var propHandler_1 = require("../script-handlers/propHandler");
var tsUtils_1 = require("./utils/tsUtils");
const bt = __importStar(require("@babel/types"));
const recast_1 = require("recast");
const getTypeFromAnnotation_1 = __importStar(require("../utils/getTypeFromAnnotation"));
const propHandler_1 = require("../script-handlers/propHandler");
const tsUtils_1 = require("./utils/tsUtils");
/**

@@ -73,58 +50,51 @@ * Extract information from an setup-style VueJs 3 component

function setupPropHandler(documentation, componentDefinition, astPath, opt) {
return __awaiter(this, void 0, void 0, function () {
var propsDef;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
(0, recast_1.visit)(astPath.program, {
visitCallExpression: function (nodePath) {
var hasDefaults = bt.isIdentifier(nodePath.node.callee) && nodePath.node.callee.name === 'withDefaults';
var normalizedNodePath = hasDefaults ? nodePath.get('arguments', 0) : nodePath;
if (bt.isIdentifier(normalizedNodePath.node.callee) &&
normalizedNodePath.node.callee.name === 'defineProps') {
propsDef = normalizedNodePath.get('arguments', 0);
if (normalizedNodePath.node.typeParameters) {
var typeParamsPath = normalizedNodePath.get('typeParameters', 'params', 0);
if (bt.isTSTypeLiteral(typeParamsPath.node)) {
getPropsFromLiteralType(documentation, typeParamsPath.get('members'));
}
else if (bt.isTSTypeReference(typeParamsPath.node) &&
bt.isIdentifier(typeParamsPath.node.typeName)) {
// its a reference to an interface or type
var typeName = typeParamsPath.node.typeName.name; // extract the identifier
// find it's definition in the file
var definitionPath = (0, tsUtils_1.getTypeDefinitionFromIdentifier)(astPath, typeName);
// use the same process to exact info
if (definitionPath) {
getPropsFromLiteralType(documentation, definitionPath);
}
}
}
// add defaults from withDefaults
if (hasDefaults) {
var defaults = nodePath.get('arguments', 1);
if (bt.isObjectExpression(defaults.node)) {
defaults.get('properties').each(function (propPath) {
var propName = propPath.get('key').node.name;
var propValue = propPath.get('value');
var propDescriptor = documentation.getPropDescriptor(propName);
propDescriptor.defaultValue = {
func: false,
value: (0, recast_1.print)(propValue).code
};
});
}
}
return __awaiter(this, void 0, void 0, function* () {
let propsDef;
(0, recast_1.visit)(astPath.program, {
visitCallExpression(nodePath) {
const hasDefaults = bt.isIdentifier(nodePath.node.callee) && nodePath.node.callee.name === 'withDefaults';
const normalizedNodePath = hasDefaults ? nodePath.get('arguments', 0) : nodePath;
if (bt.isIdentifier(normalizedNodePath.node.callee) &&
normalizedNodePath.node.callee.name === 'defineProps') {
propsDef = normalizedNodePath.get('arguments', 0);
if (normalizedNodePath.node.typeParameters) {
const typeParamsPath = normalizedNodePath.get('typeParameters', 'params', 0);
if (bt.isTSTypeLiteral(typeParamsPath.node)) {
getPropsFromLiteralType(documentation, typeParamsPath.get('members'));
}
else if (bt.isTSTypeReference(typeParamsPath.node) &&
bt.isIdentifier(typeParamsPath.node.typeName)) {
// its a reference to an interface or type
const typeName = typeParamsPath.node.typeName.name; // extract the identifier
// find it's definition in the file
const definitionPath = (0, tsUtils_1.getTypeDefinitionFromIdentifier)(astPath, typeName);
// use the same process to exact info
if (definitionPath) {
getPropsFromLiteralType(documentation, definitionPath);
}
return false;
}
});
if (!propsDef) return [3 /*break*/, 2];
return [4 /*yield*/, (0, propHandler_1.describePropsFromValue)(documentation, propsDef, astPath, opt)];
case 1:
_a.sent();
_a.label = 2;
case 2: return [2 /*return*/];
}
// add defaults from withDefaults
if (hasDefaults) {
const defaults = nodePath.get('arguments', 1);
if (bt.isObjectExpression(defaults.node)) {
defaults.get('properties').each((propPath) => {
const propName = propPath.get('key').node.name;
const propValue = propPath.get('value');
const propDescriptor = documentation.getPropDescriptor(propName);
propDescriptor.defaultValue = {
func: false,
value: (0, recast_1.print)(propValue).code
};
});
}
}
}
return false;
}
});
// this is JavaScript typing
if (propsDef) {
yield (0, propHandler_1.describePropsFromValue)(documentation, propsDef, astPath, opt);
}
});

@@ -134,5 +104,5 @@ }

function getPropsFromLiteralType(documentation, typeParamsPathMembers) {
typeParamsPathMembers.each(function (prop) {
typeParamsPathMembers.each((prop) => {
if (bt.isTSPropertySignature(prop.node) && bt.isIdentifier(prop.node.key)) {
var propDescriptor = documentation.getPropDescriptor(prop.node.key.name);
const propDescriptor = documentation.getPropDescriptor(prop.node.key.name);
(0, getTypeFromAnnotation_1.decorateItem)(prop, propDescriptor);

@@ -139,0 +109,0 @@ propDescriptor.required = !prop.node.optional;

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {

@@ -23,8 +27,8 @@ if (k2 === undefined) k2 = k;

exports.getTypeDefinitionFromIdentifier = void 0;
var bt = __importStar(require("@babel/types"));
var recast_1 = require("recast");
const bt = __importStar(require("@babel/types"));
const recast_1 = require("recast");
function getTypeDefinitionFromIdentifier(astPath, typeName) {
var typeBody = undefined;
let typeBody = undefined;
(0, recast_1.visit)(astPath.program, {
visitTSInterfaceDeclaration: function (nodePath) {
visitTSInterfaceDeclaration(nodePath) {
if (bt.isIdentifier(nodePath.node.id) && nodePath.node.id.name === typeName) {

@@ -31,0 +35,0 @@ typeBody = nodePath.get('body', 'body');

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {

@@ -25,16 +29,16 @@ if (k2 === undefined) k2 = k;

Object.defineProperty(exports, "__esModule", { value: true });
var bt = __importStar(require("@babel/types"));
var recast_1 = require("recast");
var extractLeadingComment_1 = __importDefault(require("../utils/extractLeadingComment"));
var getDoclets_1 = __importDefault(require("../utils/getDoclets"));
var eventHandler_1 = require("../script-handlers/eventHandler");
var getTemplateExpressionAST_1 = __importDefault(require("../utils/getTemplateExpressionAST"));
var guards_1 = require("../utils/guards");
const bt = __importStar(require("@babel/types"));
const recast_1 = require("recast");
const extractLeadingComment_1 = __importDefault(require("../utils/extractLeadingComment"));
const getDoclets_1 = __importDefault(require("../utils/getDoclets"));
const eventHandler_1 = require("../script-handlers/eventHandler");
const getTemplateExpressionAST_1 = __importDefault(require("../utils/getTemplateExpressionAST"));
const guards_1 = require("../utils/guards");
function eventHandler(documentation, templateAst, siblings) {
if ((0, guards_1.isBaseElementNode)(templateAst)) {
templateAst.props.forEach(function (prop) {
templateAst.props.forEach(prop => {
if ((0, guards_1.isDirectiveNode)(prop)) {
if (prop.name === 'on') {
// only look at expressions
var expression = prop.exp;
const expression = prop.exp;
if ((0, guards_1.isSimpleExpressionNode)(expression)) {

@@ -50,10 +54,10 @@ getEventsFromExpression(templateAst, expression.content, documentation, siblings);

function getEventsFromExpression(item, expression, documentation, siblings) {
var ast = (0, getTemplateExpressionAST_1.default)(expression);
var eventsFound = [];
const ast = (0, getTemplateExpressionAST_1.default)(expression);
const eventsFound = [];
(0, recast_1.visit)(ast.program, {
visitCallExpression: function (path) {
var obj = path.node ? path.node.callee : undefined;
var args = path.node ? path.node.arguments : undefined;
visitCallExpression(path) {
const obj = path.node ? path.node.callee : undefined;
const args = path.node ? path.node.arguments : undefined;
if (obj && args && bt.isIdentifier(obj) && obj.name === '$emit' && args.length) {
var evtName = bt.isStringLiteral(args[0]) ? args[0].value : '<undefined>';
const evtName = bt.isStringLiteral(args[0]) ? args[0].value : '<undefined>';
documentation.getEventDescriptor(evtName);

@@ -68,14 +72,14 @@ eventsFound.push(evtName);

if (eventsFound.length) {
var leadingComments_1 = (0, extractLeadingComment_1.default)(siblings, item);
if (leadingComments_1.length) {
eventsFound.forEach(function (evtName) {
leadingComments_1.forEach(function (comment) {
var doclets = (0, getDoclets_1.default)(comment);
var eventTags = doclets.tags && doclets.tags.filter(function (d) { return d.title === 'event'; });
const leadingComments = (0, extractLeadingComment_1.default)(siblings, item);
if (leadingComments.length) {
eventsFound.forEach(evtName => {
leadingComments.forEach(comment => {
const doclets = (0, getDoclets_1.default)(comment);
const eventTags = doclets.tags && doclets.tags.filter(d => d.title === 'event');
if (!(eventTags &&
eventTags.length &&
eventTags.findIndex(function (et) { return et.content === evtName; }) > -1)) {
eventTags.findIndex(et => et.content === evtName) > -1)) {
return;
}
var e = documentation.getEventDescriptor(evtName);
const e = documentation.getEventDescriptor(evtName);
(0, eventHandler_1.setEventDescriptor)(e, doclets);

@@ -82,0 +86,0 @@ });

@@ -6,5 +6,5 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
var propHandler_1 = __importDefault(require("./propHandler"));
var slotHandler_1 = __importDefault(require("./slotHandler"));
var eventHandler_1 = __importDefault(require("./eventHandler"));
const propHandler_1 = __importDefault(require("./propHandler"));
const slotHandler_1 = __importDefault(require("./slotHandler"));
const eventHandler_1 = __importDefault(require("./eventHandler"));
exports.default = [slotHandler_1.default, propHandler_1.default, eventHandler_1.default];
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {

@@ -25,8 +29,8 @@ if (k2 === undefined) k2 = k;

Object.defineProperty(exports, "__esModule", { value: true });
var bt = __importStar(require("@babel/types"));
var recast_1 = require("recast");
var extractLeadingComment_1 = __importDefault(require("../utils/extractLeadingComment"));
var getDoclets_1 = __importDefault(require("../utils/getDoclets"));
var getTemplateExpressionAST_1 = __importDefault(require("../utils/getTemplateExpressionAST"));
var guards_1 = require("../utils/guards");
const bt = __importStar(require("@babel/types"));
const recast_1 = require("recast");
const extractLeadingComment_1 = __importDefault(require("../utils/extractLeadingComment"));
const getDoclets_1 = __importDefault(require("../utils/getDoclets"));
const getTemplateExpressionAST_1 = __importDefault(require("../utils/getTemplateExpressionAST"));
const guards_1 = require("../utils/guards");
function propTemplateHandler(documentation, templateAst, siblings, options) {

@@ -41,3 +45,3 @@ if (options.functional) {

if ((0, guards_1.isBaseElementNode)(templateAst)) {
templateAst.props.forEach(function (prop) {
templateAst.props.forEach(prop => {
if ((0, guards_1.isDirectiveNode)(prop) && (0, guards_1.isSimpleExpressionNode)(prop.exp)) {

@@ -55,9 +59,9 @@ getPropsFromExpression(documentation, templateAst, prop.exp, siblings);

function getPropsFromExpression(documentation, item, exp, siblings) {
var expression = exp.content;
var ast = (0, getTemplateExpressionAST_1.default)(expression);
var propsFound = [];
const expression = exp.content;
const ast = (0, getTemplateExpressionAST_1.default)(expression);
const propsFound = [];
(0, recast_1.visit)(ast.program, {
visitMemberExpression: function (path) {
var obj = path.node ? path.node.object : undefined;
var propName = path.node ? path.node.property : undefined;
visitMemberExpression(path) {
const obj = path.node ? path.node.object : undefined;
const propName = path.node ? path.node.property : undefined;
if (obj &&

@@ -68,4 +72,4 @@ propName &&

bt.isIdentifier(propName)) {
var pName = propName.name;
var p = documentation.getPropDescriptor(pName);
const pName = propName.name;
const p = documentation.getPropDescriptor(pName);
propsFound.push(pName);

@@ -78,11 +82,11 @@ p.type = { name: 'undefined' };

if (propsFound.length) {
var comments = (0, extractLeadingComment_1.default)(siblings, item);
comments.forEach(function (comment) {
var doclets = (0, getDoclets_1.default)(comment);
var propTags = doclets.tags && doclets.tags.filter(function (d) { return d.title === 'prop'; });
const comments = (0, extractLeadingComment_1.default)(siblings, item);
comments.forEach(comment => {
const doclets = (0, getDoclets_1.default)(comment);
const propTags = doclets.tags && doclets.tags.filter(d => d.title === 'prop');
if (propTags && propTags.length) {
propsFound.forEach(function (pName) {
var propTag = propTags.filter(function (pt) { return pt.name === pName; });
propsFound.forEach(pName => {
const propTag = propTags.filter(pt => pt.name === pName);
if (propTag.length) {
var p = documentation.getPropDescriptor(pName);
const p = documentation.getPropDescriptor(pName);
p.type = propTag[0].type;

@@ -89,0 +93,0 @@ if (typeof propTag[0].description === 'string') {

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {

@@ -25,23 +29,23 @@ if (k2 === undefined) k2 = k;

Object.defineProperty(exports, "__esModule", { value: true });
var bt = __importStar(require("@babel/types"));
var recast_1 = require("recast");
var babel_parser_1 = __importDefault(require("../babel-parser"));
var extractLeadingComment_1 = __importDefault(require("../utils/extractLeadingComment"));
var slotHandler_1 = require("../script-handlers/slotHandler");
var guards_1 = require("../utils/guards");
var parser = (0, babel_parser_1.default)({ plugins: ['typescript'] });
const bt = __importStar(require("@babel/types"));
const recast_1 = require("recast");
const babel_parser_1 = __importDefault(require("../babel-parser"));
const extractLeadingComment_1 = __importDefault(require("../utils/extractLeadingComment"));
const slotHandler_1 = require("../script-handlers/slotHandler");
const guards_1 = require("../utils/guards");
const parser = (0, babel_parser_1.default)({ plugins: ['typescript'] });
function slotHandler(documentation, templateAst, siblings) {
if ((0, guards_1.isBaseElementNode)(templateAst) && templateAst.tag === 'slot') {
var nameProp = templateAst.props.filter(guards_1.isAttributeNode).find(function (b) { return b.name === 'name'; });
var slotName = nameProp && nameProp.value && nameProp.value.content ? nameProp.value.content : 'default';
var bindings = templateAst.props.filter(
const nameProp = templateAst.props.filter(guards_1.isAttributeNode).find(b => b.name === 'name');
const slotName = nameProp && nameProp.value && nameProp.value.content ? nameProp.value.content : 'default';
const bindings = templateAst.props.filter(
// only keep simple binds and static attributes
function (b) { return b.name !== 'name' && (b.name === 'bind' || (0, guards_1.isAttributeNode)(b)); });
var slotDescriptor_1 = documentation.getSlotDescriptor(slotName);
b => b.name !== 'name' && (b.name === 'bind' || (0, guards_1.isAttributeNode)(b)));
const slotDescriptor = documentation.getSlotDescriptor(slotName);
if (bindings.length) {
slotDescriptor_1.scoped = true;
slotDescriptor.scoped = true;
}
var comments = (0, extractLeadingComment_1.default)(siblings, templateAst);
var bindingDescriptors_1 = [];
comments.forEach(function (comment) {
const comments = (0, extractLeadingComment_1.default)(siblings, templateAst);
let bindingDescriptors = [];
comments.forEach(comment => {
// if a comment contains @slot,

@@ -51,25 +55,25 @@ // use it to determine bindings and tags

if (comment.length) {
var doclets = (0, slotHandler_1.parseSlotDocBlock)(comment, slotDescriptor_1);
const doclets = (0, slotHandler_1.parseSlotDocBlock)(comment, slotDescriptor);
if (doclets && doclets.bindings) {
bindingDescriptors_1 = doclets.bindings;
bindingDescriptors = doclets.bindings;
}
}
});
var simpleBindings_1 = [];
const simpleBindings = [];
// deal with v-bind="" props
var simpleVBind = bindings.find(function (b) { return (0, guards_1.isDirectiveNode)(b) && !b.arg; });
var rawVBind_1 = false;
const simpleVBind = bindings.find(b => (0, guards_1.isDirectiveNode)(b) && !b.arg);
let rawVBind = false;
if (simpleVBind && (0, guards_1.isSimpleExpressionNode)(simpleVBind.exp)) {
var ast = parser.parse("() => (".concat(simpleVBind.exp.content, ")"));
const ast = parser.parse(`() => (${simpleVBind.exp.content})`);
(0, recast_1.visit)(ast.program, {
visitObjectExpression: function (path) {
path.get('properties').each(function (property) {
var node = property.node;
visitObjectExpression(path) {
path.get('properties').each((property) => {
const node = property.node;
if (bt.isProperty(node) || bt.isObjectProperty(node)) {
var name_1 = (0, recast_1.print)(property.get('key')).code;
var bindingDesc = bindingDescriptors_1.filter(function (t) { return t.name === name_1; })[0];
simpleBindings_1.push(bindingDesc
const name = (0, recast_1.print)(property.get('key')).code;
const bindingDesc = bindingDescriptors.filter(t => t.name === name)[0];
simpleBindings.push(bindingDesc
? bindingDesc
: {
name: name_1,
name,
title: 'binding'

@@ -79,3 +83,3 @@ });

else {
rawVBind_1 = true;
rawVBind = true;
}

@@ -88,12 +92,12 @@ });

if (bindings.length) {
slotDescriptor_1.bindings = simpleBindings_1.concat(bindings.reduce(function (acc, b) {
if (!rawVBind_1 && (0, guards_1.isDirectiveNode)(b) && !b.arg) {
slotDescriptor.bindings = simpleBindings.concat(bindings.reduce((acc, b) => {
if (!rawVBind && (0, guards_1.isDirectiveNode)(b) && !b.arg) {
return acc;
}
// resolve name of binding
var name = (0, guards_1.isDirectiveNode)(b) && b.arg && (0, guards_1.isSimpleExpressionNode)(b.arg)
const name = (0, guards_1.isDirectiveNode)(b) && b.arg && (0, guards_1.isSimpleExpressionNode)(b.arg)
? b.arg.content
: "".concat((0, guards_1.isDirectiveNode)(b) ? 'v-' : '').concat(b.name);
var bindingDesc = bindingDescriptors_1.filter(function (t) { return t.name === name; })[0];
acc.push(bindingDesc ? bindingDesc : { name: name, title: 'binding' });
: `${(0, guards_1.isDirectiveNode)(b) ? 'v-' : ''}${b.name}`;
const bindingDesc = bindingDescriptors.filter(t => t.name === name)[0];
acc.push(bindingDesc ? bindingDesc : { name, title: 'binding' });
return acc;

@@ -100,0 +104,0 @@ }, []));

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
/* eslint-disable @typescript-eslint/no-var-requires */
var LRUCache = require('lru-cache');
var hash = require('hash-sum');
var cache = new LRUCache(250);
function default_1(creator) {
var argsKey = [];
for (var _i = 1; _i < arguments.length; _i++) {
argsKey[_i - 1] = arguments[_i];
}
var cacheKey = hash(argsKey.join(''));
const LRUCache = require('lru-cache');
const hash = require('hash-sum');
const cache = new LRUCache(250);
function default_1(creator, ...argsKey) {
const cacheKey = hash(argsKey.join(''));
// source-map cache busting for hot-reloadded modules
var output = cache.get(cacheKey);
let output = cache.get(cacheKey);
if (output) {

@@ -16,0 +12,0 @@ return output;

"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) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {

@@ -41,29 +34,2 @@ if (k2 === undefined) k2 = k;

};
var __generator = (this && this.__generator) || function (thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (_) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
};
var __importDefault = (this && this.__importDefault) || function (mod) {

@@ -73,7 +39,7 @@ return (mod && mod.__esModule) ? mod : { "default": mod };

Object.defineProperty(exports, "__esModule", { value: true });
var ts_map_1 = __importDefault(require("ts-map"));
var path = __importStar(require("path"));
var recursiveResolveIEV_1 = __importDefault(require("../utils/recursiveResolveIEV"));
var parse_1 = require("../parse");
var makePathResolver_1 = __importDefault(require("./makePathResolver"));
const ts_map_1 = __importDefault(require("ts-map"));
const path = __importStar(require("path"));
const recursiveResolveIEV_1 = __importDefault(require("../utils/recursiveResolveIEV"));
const parse_1 = require("../parse");
const makePathResolver_1 = __importDefault(require("./makePathResolver"));
/**

@@ -89,67 +55,35 @@ * Document all components in varToFilePath in documentation

function documentRequiredComponents(documentation, varToFilePath, originObject, opt) {
return __awaiter(this, void 0, void 0, function () {
var originalDirName, pathResolver, files, _loop_1, _i, _a, varName, docsArray;
var _this = this;
return __generator(this, function (_b) {
switch (_b.label) {
case 0:
originalDirName = path.dirname(opt.filePath);
pathResolver = (0, makePathResolver_1.default)(originalDirName, opt.alias, opt.modules);
// resolve where components are through immediately exported variables
return [4 /*yield*/, (0, recursiveResolveIEV_1.default)(pathResolver, varToFilePath, opt.validExtends)
// if we are in a mixin or an extend we want to add
// all props on the current doc, instead of creating another one
];
case 1:
// resolve where components are through immediately exported variables
_b.sent();
if (!(originObject && documentation)) return [3 /*break*/, 3];
return [4 /*yield*/, enrichDocumentation(documentation, varToFilePath, originObject, opt, pathResolver)];
case 2: return [2 /*return*/, [
_b.sent()
]];
case 3:
files = new ts_map_1.default();
_loop_1 = function (varName) {
var _c = varToFilePath[varName], filePath = _c.filePath, exportName = _c.exportName;
filePath.forEach(function (p) {
var fullFilePath = pathResolver(p);
if (fullFilePath && opt.validExtends(fullFilePath)) {
var vars = files.get(fullFilePath) || [];
vars.push({ exportName: exportName, varName: varName });
files.set(fullFilePath, vars);
}
});
};
for (_i = 0, _a = Object.keys(varToFilePath); _i < _a.length; _i++) {
varName = _a[_i];
_loop_1(varName);
}
return [4 /*yield*/, Promise.all(files.keys().map(function (fullFilePath) { return __awaiter(_this, void 0, void 0, function () {
var vars, temporaryDocs;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
vars = files.get(fullFilePath) || [];
return [4 /*yield*/, (0, parse_1.parseFile)(__assign(__assign({}, opt), { filePath: fullFilePath, nameFilter: vars.map(function (v) { return v.exportName; }) }), documentation)
// update varnames with the original iev names
];
case 1:
temporaryDocs = _a.sent();
// update varnames with the original iev names
temporaryDocs.forEach(function (d) {
return d.set('exportName', (vars.find(function (v) { return v.exportName === d.get('exportName'); }) || {}).varName);
});
return [2 /*return*/, temporaryDocs];
}
});
}); }))
// flatten array of docs
];
case 4:
docsArray = _b.sent();
// flatten array of docs
return [2 /*return*/, docsArray.reduce(function (a, i) { return a.concat(i); }, [])];
}
});
return __awaiter(this, void 0, void 0, function* () {
const originalDirName = path.dirname(opt.filePath);
const pathResolver = (0, makePathResolver_1.default)(originalDirName, opt.alias, opt.modules);
// resolve where components are through immediately exported variables
yield (0, recursiveResolveIEV_1.default)(pathResolver, varToFilePath, opt.validExtends);
// if we are in a mixin or an extend we want to add
// all props on the current doc, instead of creating another one
if (originObject && documentation) {
return [
yield enrichDocumentation(documentation, varToFilePath, originObject, opt, pathResolver)
];
}
const files = new ts_map_1.default();
for (const varName of Object.keys(varToFilePath)) {
const { filePath, exportName } = varToFilePath[varName];
filePath.forEach(p => {
const fullFilePath = pathResolver(p);
if (fullFilePath && opt.validExtends(fullFilePath)) {
const vars = files.get(fullFilePath) || [];
vars.push({ exportName, varName });
files.set(fullFilePath, vars);
}
});
}
const docsArray = yield Promise.all(files.keys().map((fullFilePath) => __awaiter(this, void 0, void 0, function* () {
const vars = files.get(fullFilePath) || [];
const temporaryDocs = yield (0, parse_1.parseFile)(Object.assign(Object.assign({}, opt), { filePath: fullFilePath, nameFilter: vars.map(v => v.exportName) }), documentation);
// update varnames with the original iev names
temporaryDocs.forEach(d => d.set('exportName', (vars.find(v => v.exportName === d.get('exportName')) || {}).varName));
return temporaryDocs;
})));
// flatten array of docs
return docsArray.reduce((a, i) => a.concat(i), []);
});

@@ -159,68 +93,35 @@ }

function enrichDocumentation(documentation, varToFilePath, originObject, opt, pathResolver) {
return __awaiter(this, void 0, void 0, function () {
var _this = this;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, Object.keys(varToFilePath).reduce(function (_, varName) { return __awaiter(_this, void 0, void 0, function () {
var _a, filePath, exportName;
var _this = this;
return __generator(this, function (_b) {
switch (_b.label) {
case 0: return [4 /*yield*/, _];
case 1:
_b.sent();
_a = varToFilePath[varName], filePath = _a.filePath, exportName = _a.exportName;
// If there is more than one filepath for a variable, only one
// will be valid. if not the parser of the browser will shout.
// We therefore do not care in which order the filepath go as
// long as we follow the variables order
return [4 /*yield*/, Promise.all(filePath.map(function (p) { return __awaiter(_this, void 0, void 0, function () {
var fullFilePath, originVar, e_1;
var _a;
return __generator(this, function (_b) {
switch (_b.label) {
case 0:
fullFilePath = pathResolver(p);
if (!(fullFilePath && opt.validExtends(fullFilePath))) return [3 /*break*/, 4];
_b.label = 1;
case 1:
_b.trys.push([1, 3, , 4]);
originVar = (_a = {},
_a[originObject] = {
name: '-',
path: path.relative(path.dirname(documentation.componentFullfilePath), fullFilePath)
},
_a);
return [4 /*yield*/, (0, parse_1.parseFile)(__assign(__assign(__assign({}, opt), { filePath: fullFilePath, nameFilter: [exportName] }), originVar), documentation)];
case 2:
_b.sent();
if (documentation && originVar[originObject]) {
originVar[originObject].name =
documentation.get('displayName') || documentation.get('exportName');
documentation.set('displayName', null);
}
return [3 /*break*/, 4];
case 3:
e_1 = _b.sent();
return [3 /*break*/, 4];
case 4: return [2 /*return*/];
}
});
}); }))];
case 2:
// If there is more than one filepath for a variable, only one
// will be valid. if not the parser of the browser will shout.
// We therefore do not care in which order the filepath go as
// long as we follow the variables order
_b.sent();
return [2 /*return*/];
return __awaiter(this, void 0, void 0, function* () {
yield Object.keys(varToFilePath).reduce((_, varName) => __awaiter(this, void 0, void 0, function* () {
yield _;
const { filePath, exportName } = varToFilePath[varName];
// If there is more than one filepath for a variable, only one
// will be valid. if not the parser of the browser will shout.
// We therefore do not care in which order the filepath go as
// long as we follow the variables order
yield Promise.all(filePath.map((p) => __awaiter(this, void 0, void 0, function* () {
const fullFilePath = pathResolver(p);
if (fullFilePath && opt.validExtends(fullFilePath)) {
try {
const originVar = {
[originObject]: {
name: '-',
path: path.relative(path.dirname(documentation.componentFullfilePath), fullFilePath)
}
});
}); }, Promise.resolve())];
case 1:
_a.sent();
return [2 /*return*/, documentation];
}
});
};
yield (0, parse_1.parseFile)(Object.assign(Object.assign(Object.assign({}, opt), { filePath: fullFilePath, nameFilter: [exportName] }), originVar), documentation);
if (documentation && originVar[originObject]) {
originVar[originObject].name =
documentation.get('displayName') || documentation.get('exportName');
documentation.set('displayName', null);
}
}
catch (e) {
// eat the error
}
}
})));
}), Promise.resolve());
return documentation;
});
}
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var guards_1 = require("./guards");
const guards_1 = require("./guards");
/**

@@ -16,4 +16,4 @@ * Extract leading comments to an html node

// First find the position of the item in the siblings list
var i = siblings.length - 1;
var currentSlotIndex = -1;
let i = siblings.length - 1;
let currentSlotIndex = -1;
do {

@@ -26,31 +26,27 @@ if (siblings[i] === templateAst) {

// get all siblings before the current node
var slotSiblingsBeforeSlot = siblings
const slotSiblingsBeforeSlot = siblings
.slice(0, currentSlotIndex)
.filter(function (s) { return !(0, guards_1.isTextNode)(s); })
.filter(s => !(0, guards_1.isTextNode)(s))
.reverse();
// find the first node that is not a potential comment
var indexLastComment = slotSiblingsBeforeSlot.findIndex(function (sibling) {
return !(0, guards_1.isCommentNode)(sibling) &&
!((0, guards_1.isInterpolationNode)(sibling) &&
(0, guards_1.isSimpleExpressionNode)(sibling.content) &&
isCodeOnlyJSComment(sibling.content.content));
});
const indexLastComment = slotSiblingsBeforeSlot.findIndex(sibling => !(0, guards_1.isCommentNode)(sibling) &&
!((0, guards_1.isInterpolationNode)(sibling) &&
(0, guards_1.isSimpleExpressionNode)(sibling.content) &&
isCodeOnlyJSComment(sibling.content.content)));
// cut the comments array on this index
var slotLeadingComments = (indexLastComment > 0
const slotLeadingComments = (indexLastComment > 0
? slotSiblingsBeforeSlot.slice(0, indexLastComment)
: slotSiblingsBeforeSlot)
.reverse()
.filter(function (s) { return (0, guards_1.isCommentNode)(s) || (0, guards_1.isInterpolationNode)(s); });
.filter(s => (0, guards_1.isCommentNode)(s) || (0, guards_1.isInterpolationNode)(s));
// return each comment text
return slotLeadingComments.map(function (comment) {
return (0, guards_1.isCommentNode)(comment)
? comment.content.trim()
: (0, guards_1.isInterpolationNode)(comment) && (0, guards_1.isSimpleExpressionNode)(comment.content)
? cleanUpComment(comment.content.content.trim())
: '';
});
return slotLeadingComments.map(comment => (0, guards_1.isCommentNode)(comment)
? comment.content.trim()
: (0, guards_1.isInterpolationNode)(comment) && (0, guards_1.isSimpleExpressionNode)(comment.content)
? cleanUpComment(comment.content.content.trim())
: '');
}
exports.default = extractLeadingComment;
function isCodeOnlyJSComment(code) {
var codeTrimmed = code.trim();
const codeTrimmed = code.trim();
return (

@@ -63,3 +59,3 @@ // check single-line comments

function isCodeOnlyJSCommentSingleLine(code) {
return code.split('\n').every(function (line) { return line.startsWith('//'); });
return code.split('\n').every(line => line.startsWith('//'));
}

@@ -66,0 +62,0 @@ function isCodeOnlyJSCommentMultiLine(code) {

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {

@@ -22,8 +26,8 @@ if (k2 === undefined) k2 = k;

Object.defineProperty(exports, "__esModule", { value: true });
var bt = __importStar(require("@babel/types"));
const bt = __importStar(require("@babel/types"));
function getArgFromDecorator(path) {
var expForDecorator = path
.filter(function (p) {
var exp = p.get('expression');
var decoratorIdenifier = bt.isCallExpression(exp.node) ? exp.node.callee : exp.node;
const expForDecorator = path
.filter((p) => {
const exp = p.get('expression');
const decoratorIdenifier = bt.isCallExpression(exp.node) ? exp.node.callee : exp.node;
return (bt.isIdentifier(decoratorIdenifier) ? decoratorIdenifier.name : null) === 'Component';

@@ -30,0 +34,0 @@ }, null)[0]

@@ -13,4 +13,4 @@ "use strict";

function parseDocblock(str) {
var lines = str.split('\n');
for (var i = 0, l = lines.length; i < l; i++) {
const lines = str.split('\n');
for (let i = 0, l = lines.length; i < l; i++) {
lines[i] = lines[i].replace(/^\s*\*\s?/, '').replace(/\r$/, '');

@@ -21,3 +21,3 @@ }

exports.parseDocblock = parseDocblock;
var DOCBLOCK_HEADER = /^\*\s/;
const DOCBLOCK_HEADER = /^\*\s/;
/**

@@ -27,11 +27,8 @@ * Given a path, this function returns the closest preceding docblock if it

*/
function getDocblock(path, _a) {
var _b = _a === void 0 ? { commentIndex: 1 } : _a, _c = _b.commentIndex, commentIndex = _c === void 0 ? 1 : _c;
function getDocblock(path, { commentIndex = 1 } = { commentIndex: 1 }) {
commentIndex = commentIndex || 1;
var comments = [];
var allComments = path.node.leadingComments;
let comments = [];
const allComments = path.node.leadingComments;
if (allComments) {
comments = allComments.filter(function (comment) {
return comment.type === 'CommentBlock' && DOCBLOCK_HEADER.test(comment.value);
});
comments = allComments.filter((comment) => comment.type === 'CommentBlock' && DOCBLOCK_HEADER.test(comment.value));
}

@@ -38,0 +35,0 @@ if (comments.length + 1 - commentIndex > 0) {

"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 __importDefault = (this && this.__importDefault) || function (mod) {

@@ -17,10 +6,10 @@ return (mod && mod.__esModule) ? mod : { "default": mod };

Object.defineProperty(exports, "__esModule", { value: true });
var matchRecursiveRegexp_1 = __importDefault(require("./matchRecursiveRegexp"));
const matchRecursiveRegexp_1 = __importDefault(require("./matchRecursiveRegexp"));
function getParamInfo(content, hasName) {
content = content || '';
var typeSlice = (0, matchRecursiveRegexp_1.default)(content, '{', '}')[0] || '';
var param = hasName || typeSlice.length ? { type: getTypeObjectFromTypeString(typeSlice) } : {};
content = content.replace("{".concat(typeSlice, "}"), '');
const typeSlice = (0, matchRecursiveRegexp_1.default)(content, '{', '}')[0] || '';
const param = hasName || typeSlice.length ? { type: getTypeObjectFromTypeString(typeSlice) } : {};
content = content.replace(`{${typeSlice}}`, '');
if (hasName) {
var nameSliceArray = /^ *(\w[\w-]+)?/.exec(content);
const nameSliceArray = /^ *(\w[\w-]+)?/.exec(content);
if (nameSliceArray) {

@@ -30,3 +19,3 @@ param.name = nameSliceArray[1];

if (param.name) {
content = content.replace(new RegExp("^ *".concat(param.name)), '');
content = content.replace(new RegExp(`^ *${param.name}`), '');
}

@@ -47,3 +36,3 @@ }

name: 'union',
elements: typeSlice.split('|').map(function (type) { return getTypeObjectFromTypeString(type); })
elements: typeSlice.split('|').map(type => getTypeObjectFromTypeString(type))
};

@@ -60,7 +49,7 @@ }

*/
var UNNAMED_TAG_TITLES = ['returns', 'throws', 'type'];
const UNNAMED_TAG_TITLES = ['returns', 'throws', 'type'];
/**
* For those arguments we will try and parse type of the content
*/
var TYPED_TAG_TITLES = [
const TYPED_TAG_TITLES = [
'param',

@@ -80,3 +69,3 @@ 'arg',

*/
var ACCESS_TAG_TITLES = ['private', 'public'];
const ACCESS_TAG_TITLES = ['private', 'public'];
/**

@@ -87,3 +76,3 @@ * If one of these tags is placed above content

*/
var PREFIX_TAG_TITLES = ['slot', 'ignore'];
const PREFIX_TAG_TITLES = ['slot', 'ignore'];
/**

@@ -96,8 +85,8 @@ * Given a string, this functions returns an object with

function getDocblockTags(str) {
var DOCLET_PATTERN = /^(?:\s+)?@(\w+) ?(.+)?/;
var tags = [];
var lines = str.split('\n').reverse();
var accNonTagLines = '';
lines.forEach(function (line) {
var _a = DOCLET_PATTERN.exec(line) || [], title = _a[1], tagContents = _a[2];
const DOCLET_PATTERN = /^(?:\s+)?@(\w+) ?(.+)?/;
const tags = [];
const lines = str.split('\n').reverse();
let accNonTagLines = '';
lines.forEach(line => {
let [, title, tagContents] = DOCLET_PATTERN.exec(line) || [];
if (!title) {

@@ -108,3 +97,3 @@ accNonTagLines = line + '\n' + accNonTagLines;

if (TYPED_TAG_TITLES.includes(title)) {
tags.push(__assign({ title: title }, getParamInfo(tagContents, !UNNAMED_TAG_TITLES.includes(title))));
tags.push(Object.assign({ title }, getParamInfo(tagContents, !UNNAMED_TAG_TITLES.includes(title))));
}

@@ -116,7 +105,7 @@ else if (ACCESS_TAG_TITLES.indexOf(title) > -1) {

else if (PREFIX_TAG_TITLES.indexOf(title) > -1) {
tags.push({ title: title, content: tagContents !== null && tagContents !== void 0 ? tagContents : true });
tags.push({ title, content: tagContents !== null && tagContents !== void 0 ? tagContents : true });
return;
}
else {
var content = tagContents
const content = tagContents
? (tagContents + '\n' + accNonTagLines).trim()

@@ -126,9 +115,9 @@ : accNonTagLines

: true;
tags.push({ title: title, content: content });
tags.push({ title, content });
}
accNonTagLines = '';
});
var description = accNonTagLines.trim().length ? accNonTagLines.trim() : undefined;
return { description: description, tags: tags.reverse() };
const description = accNonTagLines.trim().length ? accNonTagLines.trim() : undefined;
return { description, tags: tags.reverse() };
}
exports.default = getDocblockTags;
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {

@@ -30,29 +34,2 @@ if (k2 === undefined) k2 = k;

};
var __generator = (this && this.__generator) || function (thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (_) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
};
var __importDefault = (this && this.__importDefault) || function (mod) {

@@ -62,87 +39,63 @@ return (mod && mod.__esModule) ? mod : { "default": mod };

Object.defineProperty(exports, "__esModule", { value: true });
var fs_1 = require("fs");
var util_1 = require("util");
var ast_types_1 = require("ast-types");
var bt = __importStar(require("@babel/types"));
var recast_1 = require("recast");
var babel_parser_1 = __importDefault(require("../babel-parser"));
var cacher_1 = __importDefault(require("./cacher"));
var read = (0, util_1.promisify)(fs_1.readFile);
const fs_1 = require("fs");
const util_1 = require("util");
const ast_types_1 = require("ast-types");
const bt = __importStar(require("@babel/types"));
const recast_1 = require("recast");
const babel_parser_1 = __importDefault(require("../babel-parser"));
const cacher_1 = __importDefault(require("./cacher"));
const read = (0, util_1.promisify)(fs_1.readFile);
function getPathOfExportedValue(pathResolver, exportName, filePath, options) {
return __awaiter(this, void 0, void 0, function () {
var plugins, filePathIndex, exportedPath, _loop_1, state_1;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
plugins = options.lang === 'ts' ? ['typescript'] : ['flow'];
if (options.jsx) {
plugins.push('jsx');
}
filePathIndex = filePath.length;
exportedPath = undefined;
_loop_1 = function () {
var currentFilePath, filePlugins, source, ast;
return __generator(this, function (_b) {
switch (_b.label) {
case 0:
currentFilePath = pathResolver(filePath[filePathIndex]);
if (!currentFilePath) {
return [2 /*return*/, { value: undefined }];
}
filePlugins = plugins;
// Fixes SFCs written in JS having their imported modules being assumed to also be JS
if (/.tsx?$/.test(currentFilePath)) {
filePlugins = filePlugins.map(function (plugin) { return plugin === 'flow' ? 'typescript' : plugin; });
}
return [4 /*yield*/, read(currentFilePath, {
encoding: 'utf-8'
})];
case 1:
source = _b.sent();
ast = (0, cacher_1.default)(function () { return (0, recast_1.parse)(source, { parser: (0, babel_parser_1.default)({ plugins: filePlugins }) }); }, source);
(0, ast_types_1.visit)(ast, {
visitExportNamedDeclaration: function (p) {
var masterDeclaration = p.node.declaration;
if (masterDeclaration && bt.isVariableDeclaration(masterDeclaration)) {
masterDeclaration.declarations.forEach(function (declaration, i) {
if (bt.isVariableDeclarator(declaration) &&
bt.isIdentifier(declaration.id) &&
declaration.id.name === exportName) {
exportedPath = p.get('declaration', 'declarations', i, 'init');
}
});
}
return false;
},
visitExportDefaultDeclaration: function (p) {
if (exportName === 'default') {
var masterDeclaration = p.node.declaration;
if (masterDeclaration) {
exportedPath = p.get('declaration');
}
}
return false;
}
});
if (exportedPath) {
return [2 /*return*/, { value: exportedPath }];
}
return [2 /*return*/];
return __awaiter(this, void 0, void 0, function* () {
const plugins = options.lang === 'ts' ? ['typescript'] : ['flow'];
if (options.jsx) {
plugins.push('jsx');
}
let filePathIndex = filePath.length;
let exportedPath = undefined;
while (filePathIndex--) {
const currentFilePath = pathResolver(filePath[filePathIndex]);
if (!currentFilePath) {
return undefined;
}
let filePlugins = plugins;
// Fixes SFCs written in JS having their imported modules being assumed to also be JS
if (/.tsx?$/.test(currentFilePath)) {
filePlugins = filePlugins.map(plugin => plugin === 'flow' ? 'typescript' : plugin);
}
const source = yield read(currentFilePath, {
encoding: 'utf-8'
});
const ast = (0, cacher_1.default)(() => (0, recast_1.parse)(source, { parser: (0, babel_parser_1.default)({ plugins: filePlugins }) }), source);
(0, ast_types_1.visit)(ast, {
visitExportNamedDeclaration(p) {
const masterDeclaration = p.node.declaration;
if (masterDeclaration && bt.isVariableDeclaration(masterDeclaration)) {
masterDeclaration.declarations.forEach((declaration, i) => {
if (bt.isVariableDeclarator(declaration) &&
bt.isIdentifier(declaration.id) &&
declaration.id.name === exportName) {
exportedPath = p.get('declaration', 'declarations', i, 'init');
}
});
};
_a.label = 1;
case 1:
if (!filePathIndex--) return [3 /*break*/, 3];
return [5 /*yield**/, _loop_1()];
case 2:
state_1 = _a.sent();
if (typeof state_1 === "object")
return [2 /*return*/, state_1.value];
return [3 /*break*/, 1];
case 3: return [2 /*return*/, undefined];
}
return false;
},
visitExportDefaultDeclaration(p) {
if (exportName === 'default') {
const masterDeclaration = p.node.declaration;
if (masterDeclaration) {
exportedPath = p.get('declaration');
}
}
return false;
}
});
if (exportedPath) {
return exportedPath;
}
});
}
return undefined;
});
}
exports.default = getPathOfExportedValue;
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {

@@ -22,12 +26,10 @@ if (k2 === undefined) k2 = k;

Object.defineProperty(exports, "__esModule", { value: true });
var bt = __importStar(require("@babel/types"));
const bt = __importStar(require("@babel/types"));
function getMemberFilter(propName) {
return function (p) {
return bt.isIdentifier(p.node.key)
? p.node.key.name === propName
: bt.isStringLiteral(p.node.key)
? p.node.key.value === propName
: false;
};
return p => bt.isIdentifier(p.node.key)
? p.node.key.name === propName
: bt.isStringLiteral(p.node.key)
? p.node.key.value === propName
: false;
}
exports.default = getMemberFilter;

@@ -6,15 +6,15 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
var babel_parser_1 = __importDefault(require("../babel-parser"));
var parser = (0, babel_parser_1.default)({ plugins: ['typescript'] });
const babel_parser_1 = __importDefault(require("../babel-parser"));
const parser = (0, babel_parser_1.default)({ plugins: ['typescript'] });
function getTemplateExpressionAST(expression) {
try {
// this allows for weird expressions like {[t]:val} to be parsed properly
return parser.parse(/^\{/.test(expression.trim()) ? "(() => (".concat(expression, "))()") : expression);
return parser.parse(/^\{/.test(expression.trim()) ? `(() => (${expression}))()` : expression);
}
catch (e) {
throw Error("Could not parse template expression:\n" + //
"".concat(expression, "\n") + //
"Err: ".concat(e.message));
throw Error(`Could not parse template expression:\n` + //
`${expression}\n` + //
`Err: ${e.message}`);
}
}
exports.default = getTemplateExpressionAST;
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {

@@ -26,7 +30,7 @@ if (k2 === undefined) k2 = k;

exports.decorateItem = void 0;
var bt = __importStar(require("@babel/types"));
var recast_1 = require("recast");
var getDocblock_1 = __importDefault(require("./getDocblock"));
var getDoclets_1 = __importDefault(require("./getDoclets"));
var transformTagsIntoObject_1 = __importDefault(require("./transformTagsIntoObject"));
const bt = __importStar(require("@babel/types"));
const recast_1 = require("recast");
const getDocblock_1 = __importDefault(require("./getDocblock"));
const getDoclets_1 = __importDefault(require("./getDoclets"));
const transformTagsIntoObject_1 = __importDefault(require("./transformTagsIntoObject"));
function getTypeFromAnnotation(typeNode) {

@@ -44,3 +48,3 @@ if (typeNode) {

exports.default = getTypeFromAnnotation;
var TS_TYPE_NAME_MAP = {
const TS_TYPE_NAME_MAP = {
TSAnyKeyword: 'any',

@@ -66,3 +70,3 @@ TSUnknownKeyword: 'unknown',

}
if (bt.isTSLiteralType(t)) {
if (bt.isTSLiteralType(t) && !bt.isUnaryExpression(t.literal)) {
return { name: JSON.stringify(t.literal.value) };

@@ -76,3 +80,3 @@ }

if (bt.isTSTypeReference(t) && bt.isIdentifier(t.typeName)) {
var out = { name: t.typeName.name };
const out = { name: t.typeName.name };
if ((_a = t.typeParameters) === null || _a === void 0 ? void 0 : _a.params) {

@@ -95,3 +99,3 @@ out.elements = t.typeParameters.params.map(getTypeObjectFromTSType);

}
var FLOW_TYPE_NAME_MAP = {
const FLOW_TYPE_NAME_MAP = {
AnyTypeAnnotation: 'any',

@@ -110,3 +114,3 @@ UnknownTypeAnnotation: 'unknown',

function getTypeObjectFromFlowType(type) {
var name = FLOW_TYPE_NAME_MAP[type.type]
const name = FLOW_TYPE_NAME_MAP[type.type]
? FLOW_TYPE_NAME_MAP[type.type]

@@ -116,8 +120,8 @@ : bt.isGenericTypeAnnotation(type) && bt.isIdentifier(type.id)

: type.type;
return { name: name };
return { name };
}
function decorateItem(item, propDescriptor) {
var docBlock = (0, getDocblock_1.default)(item);
var jsDoc = docBlock ? (0, getDoclets_1.default)(docBlock) : { description: '', tags: [] };
var jsDocTags = jsDoc.tags ? jsDoc.tags : [];
const docBlock = (0, getDocblock_1.default)(item);
const jsDoc = docBlock ? (0, getDoclets_1.default)(docBlock) : { description: '', tags: [] };
const jsDocTags = jsDoc.tags ? jsDoc.tags : [];
if (jsDoc.description) {

@@ -124,0 +128,0 @@ propDescriptor.description = jsDoc.description;

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.isInterpolationNode = exports.isCompoundExpressionNode = exports.isSimpleExpressionNode = exports.isAttributeNode = exports.isDirectiveNode = exports.isBaseElementNode = exports.isCommentNode = exports.isTextNode = void 0;
const NodeTypesLitteral = {
ELEMENT: 1,
TEXT: 2,
COMMENT: 3,
SIMPLE_EXPRESSION: 4,
INTERPOLATION: 5,
ATTRIBUTE: 6,
DIRECTIVE: 7,
COMPOUND_EXPRESSION: 8
};
function isTextNode(node) {
return !!node && node.type === 2 /* TEXT */;
return !!node && node.type === NodeTypesLitteral.TEXT;
}
exports.isTextNode = isTextNode;
function isCommentNode(node) {
return !!node && node.type === 3 /* COMMENT */;
return !!node && node.type === NodeTypesLitteral.COMMENT;
}
exports.isCommentNode = isCommentNode;
function isBaseElementNode(node) {
return !!node && node.type === 1 /* ELEMENT */;
return !!node && node.type === NodeTypesLitteral.ELEMENT;
}
exports.isBaseElementNode = isBaseElementNode;
function isDirectiveNode(prop) {
return !!prop && prop.type === 7 /* DIRECTIVE */;
return !!prop && prop.type === NodeTypesLitteral.DIRECTIVE;
}
exports.isDirectiveNode = isDirectiveNode;
function isAttributeNode(prop) {
return !!prop && prop.type === 6 /* ATTRIBUTE */;
return !!prop && prop.type === NodeTypesLitteral.ATTRIBUTE;
}
exports.isAttributeNode = isAttributeNode;
function isSimpleExpressionNode(exp) {
return !!exp && exp.type === 4 /* SIMPLE_EXPRESSION */;
return !!exp && exp.type === NodeTypesLitteral.SIMPLE_EXPRESSION;
}
exports.isSimpleExpressionNode = isSimpleExpressionNode;
function isCompoundExpressionNode(exp) {
return !!exp && exp.type === 8 /* COMPOUND_EXPRESSION */;
return !!exp && exp.type === NodeTypesLitteral.COMPOUND_EXPRESSION;
}
exports.isCompoundExpressionNode = isCompoundExpressionNode;
function isInterpolationNode(exp) {
return !!exp && exp.type === 5 /* INTERPOLATION */;
return !!exp && exp.type === NodeTypesLitteral.INTERPOLATION;
}
exports.isInterpolationNode = isInterpolationNode;
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {

@@ -22,3 +26,3 @@ if (k2 === undefined) k2 = k;

Object.defineProperty(exports, "__esModule", { value: true });
var bt = __importStar(require("@babel/types"));
const bt = __importStar(require("@babel/types"));
/**

@@ -35,6 +39,6 @@ * true if the left part of the expression of the NodePath is of form `exports.foo = ...;` or

}
var pathLeft = path.get('left');
var isSimpleExports = bt.isIdentifier(pathLeft.node) && pathLeft.node.name === 'exports';
const pathLeft = path.get('left');
const isSimpleExports = bt.isIdentifier(pathLeft.node) && pathLeft.node.name === 'exports';
// check if we are looking at obj.member = value`
var isModuleExports = false;
let isModuleExports = false;
if (!isSimpleExports && !bt.isMemberExpression(pathLeft.node)) {

@@ -44,4 +48,4 @@ return false;

else if (bt.isMemberExpression(pathLeft.node)) {
var leftObject = pathLeft.get('object');
var leftProp = pathLeft.get('property');
const leftObject = pathLeft.get('object');
const leftProp = pathLeft.get('property');
isModuleExports =

@@ -48,0 +52,0 @@ !Array.isArray(leftProp) &&

"use strict";
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
if (ar || !(i in from)) {
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
ar[i] = from[i];
}
}
return to.concat(ar || Array.prototype.slice.call(from));
};
var __importDefault = (this && this.__importDefault) || function (mod) {

@@ -15,11 +6,10 @@ return (mod && mod.__esModule) ? mod : { "default": mod };

Object.defineProperty(exports, "__esModule", { value: true });
var resolveAliases_1 = __importDefault(require("../utils/resolveAliases"));
var resolvePathFrom_1 = __importDefault(require("../utils/resolvePathFrom"));
const resolveAliases_1 = __importDefault(require("../utils/resolveAliases"));
const resolvePathFrom_1 = __importDefault(require("../utils/resolvePathFrom"));
function makePathResolver(refDirName, aliases, modules) {
return function (filePath, originalDirNameOverride) {
return (0, resolvePathFrom_1.default)((0, resolveAliases_1.default)(filePath, aliases || {}, refDirName), __spreadArray([
originalDirNameOverride || refDirName
], (modules || []), true));
};
return (filePath, originalDirNameOverride) => (0, resolvePathFrom_1.default)((0, resolveAliases_1.default)(filePath, aliases || {}, refDirName), [
originalDirNameOverride || refDirName,
...(modules || [])
]);
}
exports.default = makePathResolver;

@@ -14,13 +14,12 @@ "use strict";

*/
function matchRecursiveRegExp(str, left, right, flags) {
if (flags === void 0) { flags = ''; }
var f = flags;
var g = f.indexOf('g') > -1;
function matchRecursiveRegExp(str, left, right, flags = '') {
let f = flags;
const g = f.indexOf('g') > -1;
f = f.replace('g', '');
var x = new RegExp("".concat(left, "|").concat(right), "g".concat(f));
var l = new RegExp(left, f.replace(/g/g, ''));
var a = [];
var s = -1;
var t;
var m;
const x = new RegExp(`${left}|${right}`, `g${f}`);
const l = new RegExp(left, f.replace(/g/g, ''));
const a = [];
let s = -1;
let t;
let m;
do {

@@ -27,0 +26,0 @@ t = 0;

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {

@@ -30,29 +34,2 @@ if (k2 === undefined) k2 = k;

};
var __generator = (this && this.__generator) || function (thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (_) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
};
var __importDefault = (this && this.__importDefault) || function (mod) {

@@ -63,13 +40,13 @@ return (mod && mod.__esModule) ? mod : { "default": mod };

exports.resolveIEV = void 0;
var fs_1 = require("fs");
var path = __importStar(require("path"));
var util_1 = require("util");
var recast_1 = require("recast");
var ts_map_1 = __importDefault(require("ts-map"));
var babel_parser_1 = __importDefault(require("../babel-parser"));
var cacher_1 = __importDefault(require("./cacher"));
var resolveImmediatelyExported_1 = __importDefault(require("./resolveImmediatelyExported"));
var read = (0, util_1.promisify)(fs_1.readFile);
const fs_1 = require("fs");
const path = __importStar(require("path"));
const util_1 = require("util");
const recast_1 = require("recast");
const ts_map_1 = __importDefault(require("ts-map"));
const babel_parser_1 = __importDefault(require("../babel-parser"));
const cacher_1 = __importDefault(require("./cacher"));
const resolveImmediatelyExported_1 = __importDefault(require("./resolveImmediatelyExported"));
const read = (0, util_1.promisify)(fs_1.readFile);
// eslint-disable-next-line @typescript-eslint/no-var-requires
var hash = require('hash-sum');
const hash = require('hash-sum');
/**

@@ -87,22 +64,11 @@ * Recursively resolves specified variables to their actual files

function recursiveResolveIEV(pathResolver, varToFilePath, validExtends) {
return __awaiter(this, void 0, void 0, function () {
var hashBefore;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
hashBefore = hash(varToFilePath);
// in this case I need to resolve IEV in sequence in case they are defined multiple times
// eslint-disable-next-line no-await-in-loop
return [4 /*yield*/, resolveIEV(pathResolver, varToFilePath, validExtends)];
case 1:
// in this case I need to resolve IEV in sequence in case they are defined multiple times
// eslint-disable-next-line no-await-in-loop
_a.sent();
_a.label = 2;
case 2:
if (hashBefore !== hash(varToFilePath)) return [3 /*break*/, 0];
_a.label = 3;
case 3: return [2 /*return*/];
}
});
return __awaiter(this, void 0, void 0, function* () {
// resolve imediately exported variable as many layers as they are burried
let hashBefore;
do {
hashBefore = hash(varToFilePath);
// in this case I need to resolve IEV in sequence in case they are defined multiple times
// eslint-disable-next-line no-await-in-loop
yield resolveIEV(pathResolver, varToFilePath, validExtends);
} while (hashBefore !== hash(varToFilePath));
});

@@ -123,82 +89,57 @@ }

function resolveIEV(pathResolver, varToFilePath, validExtends) {
return __awaiter(this, void 0, void 0, function () {
var filePathToVars;
var _this = this;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
filePathToVars = new ts_map_1.default();
Object.keys(varToFilePath).forEach(function (k) {
var exportedVariable = varToFilePath[k];
exportedVariable.filePath.forEach(function (filePath) {
var exportToLocalMap = filePathToVars.get(filePath) || new ts_map_1.default();
exportToLocalMap.set(k, exportedVariable.exportName);
filePathToVars.set(filePath, exportToLocalMap);
return __awaiter(this, void 0, void 0, function* () {
// First, create a map from filepath to localName and exportedName
// key: filepath, content: {key: localName, content: exportedName}
const filePathToVars = new ts_map_1.default();
Object.keys(varToFilePath).forEach(k => {
const exportedVariable = varToFilePath[k];
exportedVariable.filePath.forEach(filePath => {
const exportToLocalMap = filePathToVars.get(filePath) || new ts_map_1.default();
exportToLocalMap.set(k, exportedVariable.exportName);
filePathToVars.set(filePath, exportToLocalMap);
});
});
// then roll though this map and replace varToFilePath elements with their final destinations
// {
// nameOfVariable:{filePath:['filesWhereToFindIt'], exportedName:'nameUsedInExportThatCanBeUsedForFiltering'}
// }
yield Promise.all(filePathToVars.entries().map(([filePath, exportToLocal]) => __awaiter(this, void 0, void 0, function* () {
if (filePath && exportToLocal) {
const exportedVariableNames = [];
exportToLocal.forEach(exportedName => {
if (exportedName) {
exportedVariableNames.push(exportedName);
}
});
try {
const fullFilePath = pathResolver(filePath);
if (!fullFilePath || !validExtends(fullFilePath)) {
return;
}
const source = yield read(fullFilePath, {
encoding: 'utf-8'
});
const astRemote = (0, cacher_1.default)(() => (0, recast_1.parse)(source, { parser: (0, babel_parser_1.default)() }), source);
const returnedVariables = (0, resolveImmediatelyExported_1.default)(astRemote, exportedVariableNames);
if (Object.keys(returnedVariables).length) {
exportToLocal.forEach((exported, local) => {
if (exported && local) {
const aliasedVariable = returnedVariables[exported];
if (aliasedVariable) {
aliasedVariable.filePath = aliasedVariable.filePath
.map(p => pathResolver(p, path.dirname(fullFilePath)))
.filter(a => a);
varToFilePath[local] = aliasedVariable;
}
}
});
});
// then roll though this map and replace varToFilePath elements with their final destinations
// {
// nameOfVariable:{filePath:['filesWhereToFindIt'], exportedName:'nameUsedInExportThatCanBeUsedForFiltering'}
// }
return [4 /*yield*/, Promise.all(filePathToVars.entries().map(function (_a) {
var filePath = _a[0], exportToLocal = _a[1];
return __awaiter(_this, void 0, void 0, function () {
var exportedVariableNames_1, fullFilePath_1, source_1, astRemote, returnedVariables_1, e_1;
return __generator(this, function (_b) {
switch (_b.label) {
case 0:
if (!(filePath && exportToLocal)) return [3 /*break*/, 4];
exportedVariableNames_1 = [];
exportToLocal.forEach(function (exportedName) {
if (exportedName) {
exportedVariableNames_1.push(exportedName);
}
});
_b.label = 1;
case 1:
_b.trys.push([1, 3, , 4]);
fullFilePath_1 = pathResolver(filePath);
if (!fullFilePath_1 || !validExtends(fullFilePath_1)) {
return [2 /*return*/];
}
return [4 /*yield*/, read(fullFilePath_1, {
encoding: 'utf-8'
})];
case 2:
source_1 = _b.sent();
astRemote = (0, cacher_1.default)(function () { return (0, recast_1.parse)(source_1, { parser: (0, babel_parser_1.default)() }); }, source_1);
returnedVariables_1 = (0, resolveImmediatelyExported_1.default)(astRemote, exportedVariableNames_1);
if (Object.keys(returnedVariables_1).length) {
exportToLocal.forEach(function (exported, local) {
if (exported && local) {
var aliasedVariable = returnedVariables_1[exported];
if (aliasedVariable) {
aliasedVariable.filePath = aliasedVariable.filePath
.map(function (p) { return pathResolver(p, path.dirname(fullFilePath_1)); })
.filter(function (a) { return a; });
varToFilePath[local] = aliasedVariable;
}
}
});
}
return [3 /*break*/, 4];
case 3:
e_1 = _b.sent();
return [3 /*break*/, 4];
case 4: return [2 /*return*/];
}
});
});
}))];
case 1:
// then roll though this map and replace varToFilePath elements with their final destinations
// {
// nameOfVariable:{filePath:['filesWhereToFindIt'], exportedName:'nameUsedInExportThatCanBeUsedForFiltering'}
// }
_a.sent();
return [2 /*return*/];
}
}
catch (e) {
// ignore load errors
}
}
});
})));
});
}
exports.resolveIEV = resolveIEV;
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {

@@ -22,16 +26,14 @@ if (k2 === undefined) k2 = k;

Object.defineProperty(exports, "__esModule", { value: true });
var path = __importStar(require("path"));
var fs = __importStar(require("fs"));
function resolveAliases(filePath, aliases, refDirName) {
if (refDirName === void 0) { refDirName = ''; }
var aliasKeys = Object.keys(aliases);
var aliasResolved = null;
const path = __importStar(require("path"));
const fs = __importStar(require("fs"));
function resolveAliases(filePath, aliases, refDirName = '') {
const aliasKeys = Object.keys(aliases);
let aliasResolved = null;
if (!aliasKeys.length) {
return filePath;
}
for (var _i = 0, aliasKeys_1 = aliasKeys; _i < aliasKeys_1.length; _i++) {
var aliasKey = aliasKeys_1[_i];
var aliasValueWithSlash = aliasKey + '/';
var aliasMatch = filePath.substring(0, aliasValueWithSlash.length) === aliasValueWithSlash;
var aliasValue = aliases[aliasKey];
for (const aliasKey of aliasKeys) {
const aliasValueWithSlash = aliasKey + '/';
const aliasMatch = filePath.substring(0, aliasValueWithSlash.length) === aliasValueWithSlash;
const aliasValue = aliases[aliasKey];
if (!aliasMatch) {

@@ -44,5 +46,4 @@ continue;

}
for (var _a = 0, aliasValue_1 = aliasValue; _a < aliasValue_1.length; _a++) {
var alias = aliasValue_1[_a];
var absolutePath = path.resolve(refDirName, alias, filePath.substring(aliasKey.length + 1));
for (const alias of aliasValue) {
const absolutePath = path.resolve(refDirName, alias, filePath.substring(aliasKey.length + 1));
if (fs.existsSync(absolutePath)) {

@@ -49,0 +50,0 @@ aliasResolved = absolutePath;

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {

@@ -25,16 +29,16 @@ if (k2 === undefined) k2 = k;

Object.defineProperty(exports, "__esModule", { value: true });
var bt = __importStar(require("@babel/types"));
var ts_map_1 = __importDefault(require("ts-map"));
const bt = __importStar(require("@babel/types"));
const ts_map_1 = __importDefault(require("ts-map"));
function resolveExportDeclaration(path) {
var definitions = new ts_map_1.default();
const definitions = new ts_map_1.default();
if (bt.isExportDefaultDeclaration(path.node)) {
var defaultPath = path;
const defaultPath = path;
definitions.set('default', defaultPath.get('declaration'));
}
else if (bt.isExportNamedDeclaration(path.node)) {
var declaration = path.get('declaration');
const declaration = path.get('declaration');
// export const example = {}
if (declaration && bt.isVariableDeclaration(declaration.node)) {
declaration.get('declarations').each(function (declarator) {
var nodeId = declarator.node.id;
declaration.get('declarations').each((declarator) => {
const nodeId = declarator.node.id;
if (bt.isIdentifier(nodeId)) {

@@ -46,3 +50,3 @@ definitions.set(nodeId.name, declarator);

else if (declaration && bt.isClassDeclaration(declaration.node)) {
var nodeId = declaration.node.id;
const nodeId = declaration.node.id;
if (bt.isIdentifier(nodeId)) {

@@ -65,4 +69,4 @@ definitions.set(nodeId.name, declaration);

function getDefinitionsFromPathSpecifiers(path, defs) {
var specifiersPath = path.get('specifiers');
specifiersPath.each(function (specifier) {
const specifiersPath = path.get('specifiers');
specifiersPath.each((specifier) => {
if (bt.isIdentifier(specifier.node.exported)) {

@@ -69,0 +73,0 @@ defs.set(specifier.node.exported.name, bt.isExportSpecifier(specifier.node) ? specifier.get('local') : specifier.get('exported'));

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {

@@ -25,9 +29,9 @@ if (k2 === undefined) k2 = k;

Object.defineProperty(exports, "__esModule", { value: true });
var bt = __importStar(require("@babel/types"));
var recast_1 = require("recast");
var ts_map_1 = __importDefault(require("ts-map"));
var isExportedAssignment_1 = __importDefault(require("./isExportedAssignment"));
var resolveExportDeclaration_1 = __importDefault(require("./resolveExportDeclaration"));
var resolveIdentifier_1 = __importDefault(require("./resolveIdentifier"));
var resolveRequired_1 = __importDefault(require("./resolveRequired"));
const bt = __importStar(require("@babel/types"));
const recast_1 = require("recast");
const ts_map_1 = __importDefault(require("ts-map"));
const isExportedAssignment_1 = __importDefault(require("./isExportedAssignment"));
const resolveExportDeclaration_1 = __importDefault(require("./resolveExportDeclaration"));
const resolveIdentifier_1 = __importDefault(require("./resolveIdentifier"));
const resolveRequired_1 = __importDefault(require("./resolveRequired"));
function ignore() {

@@ -39,3 +43,3 @@ return false;

*/
var VUE_COMPONENTS_KEYS = ['data', 'props', 'methods', 'computed', 'emits'];
const VUE_COMPONENTS_KEYS = ['data', 'props', 'methods', 'computed', 'emits'];
function isObjectExpressionComponentDefinition(node) {

@@ -46,10 +50,8 @@ return (

// export const compo = {data(){ return {cpm:"Button"}}
node.properties.some(function (p) {
return (bt.isObjectMethod(p) || bt.isObjectProperty(p)) &&
bt.isIdentifier(p.key) &&
VUE_COMPONENTS_KEYS.includes(p.key.name);
}));
node.properties.some(p => (bt.isObjectMethod(p) || bt.isObjectProperty(p)) &&
bt.isIdentifier(p.key) &&
VUE_COMPONENTS_KEYS.includes(p.key.name)));
}
function isComponentDefinition(path) {
var node = path.node;
const { node } = path;
return (

@@ -75,6 +77,6 @@ // export default {} (always exported even when empty)

function getReturnStatementObject(realDef) {
var returnedObjectPath;
let returnedObjectPath;
(0, recast_1.visit)(realDef.get('body'), {
visitReturnStatement: function (rPath) {
var returnArg = rPath.get('argument');
visitReturnStatement(rPath) {
const returnArg = rPath.get('argument');
if (bt.isObjectExpression(returnArg.node)) {

@@ -89,3 +91,3 @@ returnedObjectPath = returnArg;

function getReturnedObject(realDef) {
var node = realDef.node;
const { node } = realDef;
if (bt.isArrowFunctionExpression(node)) {

@@ -114,5 +116,5 @@ if (bt.isObjectExpression(realDef.get('body').node)) {

function resolveExportedComponent(ast) {
var components = new ts_map_1.default();
var ievPureExports = {};
var nonComponentsIdentifiers = [];
const components = new ts_map_1.default();
const ievPureExports = {};
const nonComponentsIdentifiers = [];
function setComponent(exportName, definition) {

@@ -127,6 +129,6 @@ if (definition && !components.get(exportName)) {

var _a;
var definitions = (0, resolveExportDeclaration_1.default)(path);
const definitions = (0, resolveExportDeclaration_1.default)(path);
// if it is a pure export { compo } from "./compo" load the source here
var sourcePath = (_a = path.get('source').value) === null || _a === void 0 ? void 0 : _a.value;
definitions.forEach(function (definition, name) {
const sourcePath = (_a = path.get('source').value) === null || _a === void 0 ? void 0 : _a.value;
definitions.forEach((definition, name) => {
if (sourcePath) {

@@ -144,3 +146,3 @@ ievPureExports[name] = {

}
var realDef = (0, resolveIdentifier_1.default)(ast, definition);
const realDef = (0, resolveIdentifier_1.default)(ast, definition);
if (realDef) {

@@ -151,3 +153,3 @@ if (isComponentDefinition(realDef)) {

else {
var returnedObject = getReturnedObject(realDef);
const returnedObject = getReturnedObject(realDef);
if (returnedObject && isObjectExpressionComponentDefinition(returnedObject.node)) {

@@ -182,3 +184,3 @@ setComponent(name, returnedObject);

visitExportDefaultDeclaration: exportDeclaration,
visitAssignmentExpression: function (path) {
visitAssignmentExpression(path) {
// function run on every assignments (with an =)

@@ -192,6 +194,6 @@ // Ignore anything that is not `exports.X = ...;` or

// expression, something like Vue.extend({})
var pathRight = path.get('right');
var pathLeft = path.get('left');
var realComp = (0, resolveIdentifier_1.default)(ast, pathRight);
var name = bt.isMemberExpression(pathLeft.node) &&
const pathRight = path.get('right');
const pathLeft = path.get('left');
const realComp = (0, resolveIdentifier_1.default)(ast, pathRight);
const name = bt.isMemberExpression(pathLeft.node) &&
bt.isIdentifier(pathLeft.node.property) &&

@@ -206,3 +208,3 @@ pathLeft.node.property.name !== 'exports'

else {
var returnedObject = getReturnedObject(realComp);
const returnedObject = getReturnedObject(realComp);
if (returnedObject && isObjectExpressionComponentDefinition(returnedObject.node)) {

@@ -219,3 +221,3 @@ setComponent(name, returnedObject);

});
var requiredValues = Object.assign(ievPureExports, (0, resolveRequired_1.default)(ast, nonComponentsIdentifiers));
const requiredValues = Object.assign(ievPureExports, (0, resolveRequired_1.default)(ast, nonComponentsIdentifiers));
return [components, requiredValues];

@@ -222,0 +224,0 @@ }

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {

@@ -22,4 +26,4 @@ if (k2 === undefined) k2 = k;

Object.defineProperty(exports, "__esModule", { value: true });
var bt = __importStar(require("@babel/types"));
var recast_1 = require("recast");
const bt = __importStar(require("@babel/types"));
const recast_1 = require("recast");
function ignore() {

@@ -32,4 +36,4 @@ return false;

}
var varName = path.node.name;
var comp = null;
const varName = path.node.name;
let comp = null;
(0, recast_1.visit)(ast.program, {

@@ -47,7 +51,7 @@ // to look only at the root we ignore all traversing

visitForInStatement: ignore,
visitVariableDeclaration: function (variablePath) {
visitVariableDeclaration(variablePath) {
if (!bt.isVariableDeclaration(variablePath.node)) {
return false;
}
var varID = variablePath.node.declarations[0].id;
const varID = variablePath.node.declarations[0].id;
if (!varID || !bt.isIdentifier(varID) || varID.name !== varName) {

@@ -59,4 +63,4 @@ return false;

},
visitClassDeclaration: function (classPath) {
var classID = classPath.node.id;
visitClassDeclaration(classPath) {
const classID = classPath.node.id;
if (!classID || !bt.isIdentifier(classID) || classID.name !== varName) {

@@ -63,0 +67,0 @@ return false;

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {

@@ -22,25 +26,25 @@ if (k2 === undefined) k2 = k;

Object.defineProperty(exports, "__esModule", { value: true });
var bt = __importStar(require("@babel/types"));
var recast_1 = require("recast");
const bt = __importStar(require("@babel/types"));
const recast_1 = require("recast");
function default_1(ast, variableFilter) {
var variables = {};
var importedVariablePaths = {};
var exportAllFiles = [];
const variables = {};
const importedVariablePaths = {};
const exportAllFiles = [];
// get imported variable names and filepath
(0, recast_1.visit)(ast.program, {
visitImportDeclaration: function (astPath) {
visitImportDeclaration(astPath) {
if (!astPath.node.source) {
return false;
}
var filePath = astPath.node.source.value;
const filePath = astPath.node.source.value;
if (typeof filePath !== 'string') {
return false;
}
var specifiers = astPath.get('specifiers');
specifiers.each(function (s) {
var varName = s.node.local.name;
var exportName = bt.isImportSpecifier(s.node) && bt.isIdentifier(s.node.imported)
const specifiers = astPath.get('specifiers');
specifiers.each((s) => {
const varName = s.node.local.name;
const exportName = bt.isImportSpecifier(s.node) && bt.isIdentifier(s.node.imported)
? s.node.imported.name
: 'default';
importedVariablePaths[varName] = { filePath: [filePath], exportName: exportName };
importedVariablePaths[varName] = { filePath: [filePath], exportName };
});

@@ -51,15 +55,15 @@ return false;

(0, recast_1.visit)(ast.program, {
visitExportNamedDeclaration: function (astPath) {
var specifiers = astPath.get('specifiers');
visitExportNamedDeclaration(astPath) {
const specifiers = astPath.get('specifiers');
if (astPath.node.source) {
var filePath_1 = astPath.node.source.value;
if (typeof filePath_1 !== 'string') {
const filePath = astPath.node.source.value;
if (typeof filePath !== 'string') {
return false;
}
specifiers.each(function (s) {
specifiers.each((s) => {
if (bt.isIdentifier(s.node.exported)) {
var varName = s.node.exported.name;
var exportName = s.node.local ? s.node.local.name : varName;
const varName = s.node.exported.name;
const exportName = s.node.local ? s.node.local.name : varName;
if (variableFilter.indexOf(varName) > -1) {
variables[varName] = { filePath: [filePath_1], exportName: exportName };
variables[varName] = { filePath: [filePath], exportName };
}

@@ -70,7 +74,7 @@ }

else {
specifiers.each(function (s) {
specifiers.each((s) => {
if (bt.isIdentifier(s.node.exported)) {
var varName = s.node.exported.name;
var middleName = s.node.local.name;
var importedVar = importedVariablePaths[middleName];
const varName = s.node.exported.name;
const middleName = s.node.local.name;
const importedVar = importedVariablePaths[middleName];
if (importedVar && variableFilter.indexOf(varName) > -1) {

@@ -84,8 +88,8 @@ variables[varName] = importedVar;

},
visitExportDefaultDeclaration: function (astPath) {
visitExportDefaultDeclaration(astPath) {
if (variableFilter.indexOf('default') > -1) {
var middleNameDeclaration = astPath.node.declaration;
const middleNameDeclaration = astPath.node.declaration;
if (bt.isIdentifier(middleNameDeclaration)) {
var middleName = middleNameDeclaration.name;
var importedVar = importedVariablePaths[middleName];
const middleName = middleNameDeclaration.name;
const importedVar = importedVariablePaths[middleName];
if (importedVar) {

@@ -98,4 +102,4 @@ variables.default = importedVar;

},
visitExportAllDeclaration: function (astPath) {
var newFilePath = astPath.get('source').node.value;
visitExportAllDeclaration(astPath) {
const newFilePath = astPath.get('source').node.value;
exportAllFiles.push(newFilePath);

@@ -107,5 +111,5 @@ return false;

variableFilter
.filter(function (v) { return !variables[v]; })
.forEach(function (exportName) {
variables[exportName] = { filePath: exportAllFiles, exportName: exportName };
.filter(v => !variables[v])
.forEach(exportName => {
variables[exportName] = { filePath: exportAllFiles, exportName };
});

@@ -112,0 +116,0 @@ }

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {

@@ -25,5 +29,5 @@ if (k2 === undefined) k2 = k;

Object.defineProperty(exports, "__esModule", { value: true });
var bt = __importStar(require("@babel/types"));
var ts_map_1 = __importDefault(require("ts-map"));
var recast_1 = require("recast");
const bt = __importStar(require("@babel/types"));
const ts_map_1 = __importDefault(require("ts-map"));
const recast_1 = require("recast");
function ignore() {

@@ -33,3 +37,3 @@ return false;

function resolveLocal(ast, variableNames) {
var variablesMap = new ts_map_1.default();
const variablesMap = new ts_map_1.default();
(0, recast_1.visit)(ast, {

@@ -49,7 +53,7 @@ // for perf resons,

visitForInStatement: ignore,
visitVariableDeclaration: function (pathVariable) {
pathVariable.get('declarations').each(function (declaration) {
visitVariableDeclaration(pathVariable) {
pathVariable.get('declarations').each((declaration) => {
if (bt.isVariableDeclarator(declaration.node) && bt.isIdentifier(declaration.node.id)) {
var varName = declaration.node.id.name;
if (variableNames.includes(varName)) {
const varName = declaration.node.id.name;
if (variableNames.includes(varName) && declaration.get('init', 'callee', 'name').value !== 'require') {
variablesMap.set(varName, declaration.get('init'));

@@ -56,0 +60,0 @@ }

@@ -6,11 +6,11 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
var path_1 = require("path");
var missing_files_cache_1 = __importDefault(require("./missing-files-cache"));
var SUFFIXES = ['', '.js', '.ts', '.vue', '.jsx', '.tsx'];
const path_1 = require("path");
const missing_files_cache_1 = __importDefault(require("./missing-files-cache"));
const SUFFIXES = ['', '.js', '.ts', '.vue', '.jsx', '.tsx'];
function resolvePathFrom(path, from) {
var finalPath = null;
SUFFIXES.forEach(function (s) {
let finalPath = null;
SUFFIXES.forEach(s => {
if (!finalPath) {
try {
finalPath = require.resolve("".concat(path).concat(s), {
finalPath = require.resolve(`${path}${s}`, {
paths: from

@@ -25,3 +25,3 @@ });

try {
finalPath = require.resolve((0, path_1.join)(path, "index".concat(s)), {
finalPath = require.resolve((0, path_1.join)(path, `index${s}`), {
paths: from

@@ -35,5 +35,5 @@ });

if (!finalPath) {
for (var i = 0; i < from.length; i++) {
for (let i = 0; i < from.length; i++) {
try {
finalPath = require.resolve((0, path_1.join)(from[i], "".concat(path).concat(s)));
finalPath = require.resolve((0, path_1.join)(from[i], `${path}${s}`));
if (finalPath.length) {

@@ -50,7 +50,7 @@ break;

try {
var packagePath = require.resolve((0, path_1.join)(path, 'package.json'), {
const packagePath = require.resolve((0, path_1.join)(path, 'package.json'), {
paths: from
});
// eslint-disable-next-line @typescript-eslint/no-var-requires
var pkg = require(packagePath);
const pkg = require(packagePath);
// if it is an es6 module use the module instead of commonjs

@@ -65,3 +65,3 @@ finalPath = require.resolve((0, path_1.join)(path, pkg.module || pkg.main));

// eslint-disable-next-line no-console
console.warn("Neither '".concat(path, ".vue' nor '").concat(path, ".js(x)' or '").concat(path, "/index.js(x)' or '").concat(path, "/index.ts(x)' could be found in '").concat(from, "'"));
console.warn(`Neither '${path}.vue' nor '${path}.js(x)' or '${path}/index.js(x)' or '${path}/index.ts(x)' could be found in '${from}'`);
missing_files_cache_1.default[path] = true;

@@ -68,0 +68,0 @@ }

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {

@@ -22,4 +26,4 @@ if (k2 === undefined) k2 = k;

Object.defineProperty(exports, "__esModule", { value: true });
var bt = __importStar(require("@babel/types"));
var recast_1 = require("recast");
const bt = __importStar(require("@babel/types"));
const recast_1 = require("recast");
/**

@@ -31,12 +35,12 @@ *

function resolveRequired(ast, varNameFilter) {
var varToFilePath = {};
const varToFilePath = {};
(0, recast_1.visit)(ast.program, {
visitImportDeclaration: function (astPath) {
var specifiers = astPath.get('specifiers');
visitImportDeclaration(astPath) {
const specifiers = astPath.get('specifiers');
// if `import 'module'` without variable name cannot be a mixin
specifiers.each(function (sp) {
var nodeSpecifier = sp.node;
specifiers.each((sp) => {
const nodeSpecifier = sp.node;
if (bt.isImportDefaultSpecifier(nodeSpecifier) || bt.isImportSpecifier(nodeSpecifier)) {
var localVariableName = nodeSpecifier.local.name;
var exportName = bt.isImportDefaultSpecifier(nodeSpecifier)
const localVariableName = nodeSpecifier.local.name;
const exportName = bt.isImportDefaultSpecifier(nodeSpecifier)
? 'default'

@@ -47,8 +51,8 @@ : bt.isIdentifier(nodeSpecifier.imported)

if (!varNameFilter || varNameFilter.indexOf(localVariableName) > -1) {
var nodeSource = astPath.get('source').node;
const nodeSource = astPath.get('source').node;
if (bt.isStringLiteral(nodeSource)) {
var filePath = [nodeSource.value];
const filePath = [nodeSource.value];
varToFilePath[localVariableName] = {
filePath: filePath,
exportName: exportName
filePath,
exportName
};

@@ -61,3 +65,3 @@ }

},
visitVariableDeclaration: function (astPath) {
visitVariableDeclaration(astPath) {
// only look at variable declarations

@@ -67,6 +71,6 @@ if (!bt.isVariableDeclaration(astPath.node)) {

}
astPath.node.declarations.forEach(function (nodeDeclaration) {
var sourceNode;
var source = '';
var _a = nodeDeclaration.init && bt.isMemberExpression(nodeDeclaration.init)
astPath.node.declarations.forEach(nodeDeclaration => {
let sourceNode;
let source = '';
const { init, exportName } = nodeDeclaration.init && bt.isMemberExpression(nodeDeclaration.init)
? {

@@ -78,3 +82,3 @@ init: nodeDeclaration.init.object,

}
: { init: nodeDeclaration.init, exportName: 'default' }, init = _a.init, exportName = _a.exportName;
: { init: nodeDeclaration.init, exportName: 'default' };
if (!init) {

@@ -97,10 +101,10 @@ return;

if (bt.isIdentifier(nodeDeclaration.id)) {
var varName = nodeDeclaration.id.name;
varToFilePath[varName] = { filePath: [source], exportName: exportName };
const varName = nodeDeclaration.id.name;
varToFilePath[varName] = { filePath: [source], exportName };
}
else if (bt.isObjectPattern(nodeDeclaration.id)) {
nodeDeclaration.id.properties.forEach(function (p) {
nodeDeclaration.id.properties.forEach((p) => {
if (bt.isIdentifier(p.key)) {
var varName = p.key.name;
varToFilePath[varName] = { filePath: [source], exportName: exportName };
const varName = p.key.name;
varToFilePath[varName] = { filePath: [source], exportName };
}

@@ -107,0 +111,0 @@ });

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
function transformTagsIntoObject(tags) {
return tags.reduce(function (acc, tag) {
return tags.reduce((acc, tag) => {
if (isContentTag(tag)) {
var newTag = {
const newTag = {
description: tag.content,

@@ -12,3 +12,3 @@ title: tag.title

}
var title = tag.title === 'param' ? 'params' : tag.title;
const title = tag.title === 'param' ? 'params' : tag.title;
if (acc[title]) {

@@ -15,0 +15,0 @@ acc[title].push(tag);

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

@@ -29,3 +29,3 @@ "homepage": "https://vue-styleguidist.github.io",

"@babel/parser": "^7.13.12",
"@babel/types": "^7.13.12",
"@babel/types": "^7.18.8",
"@vue/compiler-dom": "^3.2.0",

@@ -37,5 +37,5 @@ "@vue/compiler-sfc": "^3.2.0",

"pug": "^3.0.2",
"recast": "0.20.5",
"recast": "0.21.1",
"ts-map": "^1.0.3",
"vue-inbrowser-compiler-utils": "^4.44.23"
"vue-inbrowser-compiler-utils": "^4.50.0"
},

@@ -48,7 +48,7 @@ "devDependencies": {

"globby": "10.0.2",
"vue": "2.6.14",
"vue": "2.7.8",
"vue-class-component": "7.2.6",
"vue-clickaway": "2.2.2",
"vue-property-decorator": "7.3.0",
"vuetify": "2.6.3"
"vuetify": "2.6.8"
},

@@ -58,4 +58,3 @@ "scripts": {

"compile:watch": "pnpm run compile --watch"
},
"readme": "# vue-docgen-api\n\n[Online Documentation](https://vue-styleguidist.github.io/docs/Docgen.html)\n\n`vue-docgen-api` is a toolbox to help extracting information from [Vue](https://vuejs.org/) components, and generate documentation from it.\n\nUse [@babel/parser](https://babeljs.io/docs/en/babel-parser) to parse the code and analyze the contents of the component extracting methods, props events and slots. The output is a JavaScript object.\n\n## Install\n\nInstall the module directly from npm:\n\n```sh\nnpm install vue-docgen-api --save-dev\n```\n\n## API\n\nThe tool can be used programmatically to extract component information and customize the extraction process:\n\n```js\nvar vueDocs = require('vue-docgen-api')\nvar componentInfo\nvueDocs.parse(filePath).then(ci => {\n componentInfo = ci\n})\n```\n\nor with typescript\n\n```ts\nimport { parse } from 'vue-docgen-api'\n\nasync function parseMyComponent(filePath: string) {\n var componentInfoSimple = await parse(filePath)\n var componentInfoConfigured = await parse(filePath, {\n alias: { '@assets': path.resolve(__dirname, 'src/assets') },\n modules: [path.resolve(__dirname, 'src')],\n addScriptHandlers: [\n function(\n documentation: Documentation,\n componentDefinition: NodePath,\n astPath: bt.File,\n opt: ParseOptions\n ) {\n // handle custom code in script\n }\n ],\n addTemplateHandlers: [\n function(\n documentation: Documentation,\n templateAst: ASTElement,\n options: TemplateParserOptions\n ) {\n // handle custom directives here\n }\n ],\n preScriptHandlers: [\n function(\n documentation: Documentation,\n componentDefinition: NodePath,\n astPath: bt.File,\n opt: ParseOptions\n ) {\n // replaces handlers run before the scriptHandlers\n }\n ],\n scriptHandlers: [\n function(\n documentation: Documentation,\n componentDefinition: NodePath,\n astPath: bt.File,\n opt: ParseOptions\n ) {\n // replaces all the scriptHandlers\n }\n ],\n templateHandlers: [\n function(\n documentation: Documentation,\n templateAst: ASTElement,\n options: TemplateParserOptions\n ) {\n // replaces all the templateHandlers\n }\n ],\n validExtends: (fullFilePath: string) =>\n /[\\\\/]@my-component-library[\\\\/]/.test(fullFilePath) ||\n !/[\\\\/]node_modules[\\\\/]/.test(fullFilePath)\n jsx: true,\n nameFilter: ['MyComponent']\n })\n}\n```\n\n### `parse()` vs `parseMulti()`\n\nThe API exports two asynchronous functions `parse` and `parseMulti`. The two functions take the same set of parameters. `parse` returns a pure `ComponentDoc` whereas `parseMulti` returns an array of `ComponentDoc`\n\nWhen using only SFC or components that are the only one in their components, this function returns a `ComponentDoc` object. Using `parse` in most cases is simpler.\n\nIf you are creating a library and your goal is to have it as generic as possible, it might be a good idea to use `parseMulti`. In some cases, developer choose to have **more than one component** exported by a file, which make `parse` throw an error.\n\n### Prototypes\n\n```ts\nparse(filePath: string, options: DocGenOptions): Promise<ComponentDoc>;\nparseSource(source: string, filePath: string, opts?: DocGenOptions): Promise<ComponentDoc>;\nparseMulti(filePath: string, options: DocGenOptions): Promise<ComponentDoc[]>;\n```\n\n### options `DocGenOptions`\n\n#### `alias`\n\nThis is a mirror to the [wepbpack alias](https://webpack.js.org/configuration/resolve/#resolvealias) options. If you are using [alias in Webpack](https://webpack.js.org/configuration/resolve/#resolvealias) or paths in TypeScript, you should reflect this here.\n\nKeep in mind aliases are not resolved adopting the same implementation as webpack, but as simple path replacement. Aliases are resolved as soon as they match in the file path, bailing out of further tests. This means the order in which aliases are defined matters. E.g. an alias `@templates` mapped to `styleguide/templates/` should be defined earlier than the alias `@` (mapped to `src` ) to avoid `@templates/component` being resolved as `srctemplates/component` instead of `styleguide/templates/component`.\n\n#### `modules`\n\n`modules` mirrors the [webpack option](https://webpack.js.org/configuration/resolve/#resolvemodules) too. If you have it in webpack or use `baseDir` in your tsconfig.json, you should probably see how this one works.\n\n#### `addScriptHandlers` and `addTemplateHandlers`\n\nThe custom additional handlers allow you to add custom handlers to the parser. A handler can navigate and see custom objects that the standard parser would ignore.\n\n#### `preScriptHandlers`, `scriptHandlers` and `templateHandlers`\n\nReplaces all of the handlers by those specified. If each of those 3 `handlers` are set to [], the library will only parse the given component. It will not run any standard handlers anymore.\n\n> **NOTE:** Standard handlers are available as namespaces. Import and use them this way:\n>\n> ```js\n> import {\n> parse,\n> ScriptHandlers,\n> TemplateHandlers\n> } from 'vue-docgen-api'\n>\n> parse('myComp', {\n> scriptHandlers: [ScriptHandlers.componentHandler],\n> templateHandlers: [TemplateHandlers.slotHandler]\n> })\n> ```\n\n#### `validExtend`\n\nFunction - Returns true if an extended component should be parsed by docgen.\n\nExample: `filePath => !/node_modules/.text(filePath)`\n\n> **NOTE1:** If docgen fails to parse the targeted component, it will log a warning. This warning does not make the documentation fail.\n\n> **NOTE2:** If you allow all of `node_modules` to try to be parsed, you might kill performance. Use responsibly.\n\n#### `jsx`\n\nDoes your component contain JSX? By default, this is set to false to avoid conflicts with the <> syntax from TypeScript.\n\nIf it does, set this flag to true.\n\n#### `nameFilter`\n\nIf a file exports multiple components and you only want one, use this option to filter the named exports.\n\nIt is noticeably useful when browsing through extended components and mixins. If left blank (undefined), will look at all exports\n\n## Using JSDoc tags\n\nYou can use JSDoc tags when documenting components, props and methods.\n\n## Props\n\n```js\nexport default {\n props: {\n /**\n * Color of the button.\n */\n color: {\n type: String,\n default: '#FCC'\n },\n /**\n * initial value to be passed but undocumented\n * @ignore\n */\n initialvalue: {\n type: Number,\n default: 0\n },\n /**\n * The size of the button allows only some values\n * @values small, medium, large\n */\n size: {\n default: 'normal'\n }\n }\n}\n```\n\n## Events\n\n```js\nexport default {\n methods: {\n emitSuccess() {\n /**\n * Success event.\n *\n * @event success\n * @property {string} content content of the first prop passed to the event\n * @property {object} example the demo example\n */\n this.$emit('success', content, {\n demo: 'example'\n })\n }\n }\n}\n```\n\n## Slots\n\n```html\n<template>\n <div>\n <!-- @slot Use this slot header -->\n <slot name=\"header\"></slot>\n\n <!--\n @slot Modal footer\n @binding item an item passed to the footer\n\t\t-->\n <slot name=\"footer\" :item=\"item\" />\n </div>\n</template>\n```\n\n## Full Example\n\nFor the following component\n\n```vue\n<template>\n <div>\n <!-- @slot Use this slot header -->\n <slot name=\"header\"></slot>\n\n <table class=\"grid\">\n <!-- -->\n </table>\n\n <!--\n @slot Modal footer\n @binding item an item passed to the footer\n\t\t-->\n <slot name=\"footer\" :item=\"item\" />\n </div>\n</template>\n\n<script>\nimport { text } from './utils'\n\n/**\n * This is an example of creating a reusable grid component and using it with external data.\n * @version 1.0.5\n * @author [Rafael](https://github.com/rafaesc92)\n * @since Version 1.0.1\n */\nexport default {\n name: 'grid',\n props: {\n /**\n * object/array defaults should be returned from a factory function\n * @version 1.0.5\n * @since Version 1.0.1\n * @see See [Wikipedia](https://en.wikipedia.org/wiki/Web_colors#HTML_color_names) for a list of color names\n * @link See [Wikipedia](https://en.wikipedia.org/wiki/Web_colors#HTML_color_names) for a list of color names\n */\n msg: {\n type: [String, Number],\n default: text\n },\n /**\n * Model example\n * @model\n */\n value: {\n type: String\n },\n /**\n * describe data\n * @version 1.0.5\n */\n data: [Array],\n /**\n * get columns list\n */\n columns: [Array],\n /**\n * filter key\n * @ignore\n */\n filterKey: {\n type: String,\n default: 'example'\n }\n },\n data() {\n var sortOrders = {}\n this.columns.forEach(function (key) {\n sortOrders[key] = 1\n })\n return {\n sortKey: '',\n sortOrders: sortOrders\n }\n },\n computed: {\n filteredData: function () {\n var sortKey = this.sortKey\n var filterKey = this.filterKey && this.filterKey.toLowerCase()\n var order = this.sortOrders[sortKey] || 1\n var data = this.data\n if (filterKey) {\n data = data.filter(function (row) {\n return Object.keys(row).some(function (key) {\n return (\n String(row[key]).toLowerCase().indexOf(filterKey) > -1\n )\n })\n })\n }\n if (sortKey) {\n data = data.slice().sort(function (a, b) {\n a = a[sortKey]\n b = b[sortKey]\n return (a === b ? 0 : a > b ? 1 : -1) * order\n })\n }\n return data\n }\n },\n filters: {\n capitalize: function (str) {\n return str.charAt(0).toUpperCase() + str.slice(1)\n }\n },\n methods: {\n /**\n * Sets the order\n *\n * @public\n * @version 1.0.5\n * @since Version 1.0.1\n * @param {string} key Key to order\n * @returns {string} Test\n */\n sortBy: function (key) {\n this.sortKey = key\n this.sortOrders[key] = this.sortOrders[key] * -1\n\n /**\n * Success event.\n *\n * @event success\n * @type {object}\n */\n this.$emit('success', {\n demo: 'example'\n })\n },\n\n hiddenMethod: function () {}\n }\n}\n</script>\n```\n\nwe are getting this output:\n\n```js\nconst componentDoc = {\n displayName: 'grid',\n description:\n 'This is an example of creating a reusable grid component and using it with external data.',\n tags: {\n version: [\n {\n description: '1.0.5',\n title: 'version'\n }\n ],\n author: [\n {\n description: '[Rafael](https://github.com/rafaesc92)',\n title: 'author'\n }\n ],\n since: [\n {\n description: 'Version 1.0.1',\n title: 'since'\n }\n ]\n },\n exportName: 'default',\n props: [\n {\n description:\n 'object/array defaults should be returned from a factory function',\n tags: {\n version: [\n {\n description: '1.0.5',\n title: 'version'\n }\n ],\n since: [\n {\n description: 'Version 1.0.1',\n title: 'since'\n }\n ],\n see: [\n {\n description:\n 'See [Wikipedia](https://en.wikipedia.org/wiki/Web_colors#HTML_color_names) for a list of color names',\n title: 'see'\n }\n ],\n link: [\n {\n description:\n 'See [Wikipedia](https://en.wikipedia.org/wiki/Web_colors#HTML_color_names) for a list of color names',\n title: 'link'\n }\n ]\n },\n name: 'msg',\n type: {\n name: 'string|number'\n },\n defaultValue: {\n func: false,\n value: 'text'\n }\n },\n {\n description: 'Model example',\n tags: {\n model: [\n {\n description: true,\n title: 'model'\n }\n ]\n },\n name: 'v-model',\n type: {\n name: 'string'\n }\n },\n {\n description: 'describe data',\n tags: {\n version: [\n {\n description: '1.0.5',\n title: 'version'\n }\n ]\n },\n name: 'data',\n type: {\n name: 'array'\n }\n },\n {\n description: 'get columns list',\n tags: {},\n name: 'columns',\n type: {\n name: 'array'\n }\n },\n {\n description: 'filter key',\n tags: {\n ignore: [\n {\n description: true,\n title: 'ignore'\n }\n ]\n },\n name: 'filterKey',\n type: {\n name: 'string'\n },\n defaultValue: {\n func: false,\n value: \"'example'\"\n }\n }\n ],\n events: [\n {\n name: 'success',\n description: 'Success event.',\n type: {\n names: ['object']\n }\n }\n ],\n methods: [\n {\n name: 'sortBy',\n modifiers: [],\n description: 'Sets the order',\n tags: {\n access: [\n {\n description: 'public',\n title: 'access'\n }\n ],\n version: [\n {\n description: '1.0.5',\n title: 'version'\n }\n ],\n since: [\n {\n description: 'Version 1.0.1',\n title: 'since'\n }\n ],\n params: [\n {\n title: 'param',\n type: {\n name: 'string'\n },\n name: 'key',\n description: 'Key to order'\n }\n ],\n returns: [\n {\n title: 'returns',\n type: {\n name: 'string'\n },\n description: 'Test'\n }\n ]\n },\n params: [\n {\n name: 'key',\n type: {\n name: 'string'\n },\n description: 'Key to order'\n }\n ],\n returns: {\n title: 'returns',\n type: {\n name: 'string'\n },\n description: 'Test'\n }\n }\n ],\n slots: [\n {\n name: 'header',\n description: 'Use this slot header'\n },\n {\n name: 'footer',\n description: 'Modal footer',\n scoped: true,\n bindings: [\n {\n title: 'binding',\n type: {\n name: 'mixed'\n },\n name: 'item',\n description: 'an item passed to the footer'\n }\n ]\n }\n ]\n}\n```\n\n## Change log\n\nThe change log can be found on the [Changelog Page](./CHANGELOG.md).\n\n## Authors and license\n\n[Rafael Escala](https://github.com/rafaesc92)\n\n[Bart Ledoux](https://github.com/elevatebart)\n\nMIT License.\n"
}
}

@@ -159,6 +159,4 @@ # vue-docgen-api

Does your component contain JSX? By default, this is set to false to avoid conflicts with the <> syntax from TypeScript.
Does your component contain JSX? By default, this is set to true. If you do not disable it, babel will fail with typescript syntax like `(<any>window).$`.
If it does, set this flag to true.
#### `nameFilter`

@@ -165,0 +163,0 @@

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc