@vuedx/analyze
Advanced tools
Comparing version 0.2.1 to 0.2.2
@@ -44,2 +44,4 @@ import { parse } from '@babel/parser'; | ||
ranges: true, | ||
// @ts-ignore | ||
errorRecovery: true, | ||
}); | ||
@@ -55,2 +57,9 @@ return { | ||
function processScript(context) { | ||
var _a; | ||
// @ts-ignore | ||
if ((_a = context.ast.errors) === null || _a === void 0 ? void 0 : _a.length) { | ||
// @ts-ignore | ||
context.ast.errors.forEach((error) => context.component.addError(error.message, { ...error.loc, offset: error.pos })); | ||
return; | ||
} | ||
const enterHandlers = context.plugins | ||
@@ -174,2 +183,3 @@ .map((plugin) => { | ||
else if (options$.isArrowFunctionExpression() || options$.isFunctionExpression()) { | ||
context.component.addSetup('', { loc: createSourceRange(context, options$.node) }); | ||
/** | ||
@@ -340,8 +350,9 @@ * Matches: | ||
components: [], | ||
options: { | ||
loc: {}, | ||
properties: {}, | ||
}, | ||
errors: [], | ||
}; | ||
const factory = { | ||
addError(message, loc) { | ||
component.errors.push({ message, loc }); | ||
return factory; | ||
}, | ||
addProp(name, options = {}) { | ||
@@ -374,5 +385,10 @@ const index = component.props.findIndex((prop) => prop.name === name); | ||
if (!name) { | ||
component.options.loc = address.loc; | ||
component.options = { | ||
...address, | ||
properties: {}, | ||
}; | ||
} | ||
else { | ||
if (!component.options) | ||
throw new Error('Cannot set option location without setting options'); | ||
component.options.properties[name] = address; | ||
@@ -382,2 +398,15 @@ } | ||
}, | ||
addSetup(name, address) { | ||
if (!name) { | ||
component.setup = { | ||
...address, | ||
}; | ||
} | ||
else { | ||
if (!component.setup) | ||
throw new Error('Cannot set setup params location without setting setup'); | ||
component.setup[name] = address; | ||
} | ||
return factory; | ||
}, | ||
info() { | ||
@@ -384,0 +413,0 @@ return component; |
@@ -50,2 +50,4 @@ 'use strict'; | ||
ranges: true, | ||
// @ts-ignore | ||
errorRecovery: true, | ||
}); | ||
@@ -61,2 +63,9 @@ return { | ||
function processScript(context) { | ||
var _a; | ||
// @ts-ignore | ||
if ((_a = context.ast.errors) === null || _a === void 0 ? void 0 : _a.length) { | ||
// @ts-ignore | ||
context.ast.errors.forEach((error) => context.component.addError(error.message, { ...error.loc, offset: error.pos })); | ||
return; | ||
} | ||
const enterHandlers = context.plugins | ||
@@ -180,2 +189,3 @@ .map((plugin) => { | ||
else if (options$.isArrowFunctionExpression() || options$.isFunctionExpression()) { | ||
context.component.addSetup('', { loc: createSourceRange(context, options$.node) }); | ||
/** | ||
@@ -346,8 +356,9 @@ * Matches: | ||
components: [], | ||
options: { | ||
loc: {}, | ||
properties: {}, | ||
}, | ||
errors: [], | ||
}; | ||
const factory = { | ||
addError(message, loc) { | ||
component.errors.push({ message, loc }); | ||
return factory; | ||
}, | ||
addProp(name, options = {}) { | ||
@@ -380,5 +391,10 @@ const index = component.props.findIndex((prop) => prop.name === name); | ||
if (!name) { | ||
component.options.loc = address.loc; | ||
component.options = { | ||
...address, | ||
properties: {}, | ||
}; | ||
} | ||
else { | ||
if (!component.options) | ||
throw new Error('Cannot set option location without setting options'); | ||
component.options.properties[name] = address; | ||
@@ -388,2 +404,15 @@ } | ||
}, | ||
addSetup(name, address) { | ||
if (!name) { | ||
component.setup = { | ||
...address, | ||
}; | ||
} | ||
else { | ||
if (!component.setup) | ||
throw new Error('Cannot set setup params location without setting setup'); | ||
component.setup[name] = address; | ||
} | ||
return factory; | ||
}, | ||
info() { | ||
@@ -390,0 +419,0 @@ return component; |
{ | ||
"name": "@vuedx/analyze", | ||
"version": "0.2.1", | ||
"version": "0.2.2", | ||
"description": "Extracts public API information from Vue component.", | ||
@@ -5,0 +5,0 @@ "main": "dist/analyze.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
109046
1025