Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@vue-macros/api

Package Overview
Dependencies
Maintainers
1
Versions
64
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@vue-macros/api - npm Package Compare versions

Comparing version 0.8.4 to 0.8.5

339

./dist/index.js

@@ -1,44 +0,92 @@

"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _createStarExport(obj) { Object.keys(obj) .filter((key) => key !== "default" && key !== "__esModule") .forEach((key) => { if (exports.hasOwnProperty(key)) { return; } Object.defineProperty(exports, key, {enumerable: true, configurable: true, get: () => obj[key]}); }); } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } async function _asyncOptionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = await fn(value); } else if (op === 'call' || op === 'optionalCall') { value = await fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }// src/index.ts
var _common = require('@vue-macros/common'); _createStarExport(_common);
"use strict";
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
// If the importer is in node compatibility mode or this is not an ESM
// file that has been converted to a CommonJS file using a Babel-
// compatible transform (i.e. "__esModule" has not been set), then set
// "default" to the CommonJS "module.exports" for node compatibility.
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
// src/index.ts
var src_exports = {};
__export(src_exports, {
DefinitionKind: () => DefinitionKind,
RollupResolve: () => RollupResolve,
UNKNOWN_TYPE: () => UNKNOWN_TYPE,
analyzeSFC: () => analyzeSFC,
attachNodeLoc: () => attachNodeLoc,
checkForTSProperties: () => checkForTSProperties,
deepImportRE: () => deepImportRE,
genRuntimePropDefinition: () => genRuntimePropDefinition,
getTSFile: () => getTSFile,
getTSPropertiesKeys: () => getTSPropertiesKeys,
handleTSEmitsDefinition: () => handleTSEmitsDefinition,
handleTSPropsDefinition: () => handleTSPropsDefinition,
inferRuntimeType: () => inferRuntimeType,
isSupportedForTSReferencedType: () => isSupportedForTSReferencedType,
isTSDeclaration: () => isTSDeclaration,
isTSNamespace: () => isTSNamespace,
mergeTSProperties: () => mergeTSProperties,
namespaceSymbol: () => namespaceSymbol,
parseSFC: () => import_common8.parseSFC,
resolveMaybeTSUnion: () => resolveMaybeTSUnion,
resolveTSFileId: () => resolveTSFileId,
resolveTSFileIdNode: () => resolveTSFileIdNode,
resolveTSIndexedAccessType: () => resolveTSIndexedAccessType,
resolveTSLiteralType: () => resolveTSLiteralType,
resolveTSNamespace: () => resolveTSNamespace,
resolveTSProperties: () => resolveTSProperties,
resolveTSReferencedType: () => resolveTSReferencedType,
resolveTSScope: () => resolveTSScope,
resolveTSTemplateLiteral: () => resolveTSTemplateLiteral,
resolveTSTypeOperator: () => resolveTSTypeOperator,
resolveTypeElements: () => resolveTypeElements,
setResolveTSFileIdImpl: () => setResolveTSFileIdImpl,
tsFileCache: () => tsFileCache
});
module.exports = __toCommonJS(src_exports);
__reExport(src_exports, require("@vue-macros/common"), module.exports);
// src/vue/analyze.ts
var import_common7 = require("@vue-macros/common");
// src/vue/props.ts
var import_common5 = require("@vue-macros/common");
// src/ts/is.ts
var _types = require('@babel/types');
var import_types = require("@babel/types");
function isTSDeclaration(node) {
return _types.isDeclaration.call(void 0, node) && node.type.startsWith("TS");
return (0, import_types.isDeclaration)(node) && node.type.startsWith("TS");
}
// src/ts/resolve-reference.ts
var import_common4 = require("@vue-macros/common");
var import_types2 = require("@babel/types");
// src/ts/resolve.ts
var import_common2 = require("@vue-macros/common");
// src/ts/property.ts
var import_common = require("@vue-macros/common");
function mergeTSProperties(a, b) {

@@ -138,3 +186,3 @@ return {

const keys = resolveMaybeTSUnion(literal).map(
(literal2) => String(_common.resolveLiteral.call(void 0, literal2))
(literal2) => String((0, import_common.resolveLiteral)(literal2))
);

@@ -161,6 +209,6 @@ for (const key of keys) {

default:
throw new Error(`unknown node: ${_optionalChain([type, 'optionalAccess', _ => _.type])}`);
throw new Error(`unknown node: ${type?.type}`);
}
function filterValidExtends(node) {
return !isTSNamespace(node) && checkForTSProperties(_optionalChain([node, 'optionalAccess', _2 => _2.type]));
return !isTSNamespace(node) && checkForTSProperties(node?.type);
}

@@ -183,3 +231,3 @@ }

const types = (await resolveKeys("", type.quasis, type.expressions)).map(
(k) => _common.createStringLiteral.call(void 0, k)
(k) => (0, import_common2.createStringLiteral)(k)
);

@@ -189,3 +237,3 @@ return types;

if (expressions.length === 0) {
return [prefix + (_nullishCoalesce(_optionalChain([quasis, 'access', _3 => _3[0], 'optionalAccess', _4 => _4.value, 'access', _5 => _5.cooked]), () => ( "")))];
return [prefix + (quasis[0]?.value.cooked ?? "")];
}

@@ -213,3 +261,3 @@ const [expr, ...restExpr] = expressions;

const subKeys = resolveMaybeTSUnion(literal).map(
(literal2) => String(_common.resolveLiteral.call(void 0, literal2))
(literal2) => String((0, import_common2.resolveLiteral)(literal2))
);

@@ -246,4 +294,4 @@ for (const key of subKeys) {

try {
return _common.resolveObjectKey.call(void 0, element);
} catch (e) {
return (0, import_common2.resolveObjectKey)(element);
} catch {
}

@@ -277,3 +325,3 @@ };

if (!properties.properties[key] && !properties.methods[key]) {
const type = _optionalChain([element, 'access', _6 => _6.typeAnnotation, 'optionalAccess', _7 => _7.typeAnnotation]);
const type = element.typeAnnotation?.typeAnnotation;
properties.properties[key] = {

@@ -314,3 +362,3 @@ value: type ? { type, scope } : null,

}
return { type: _common.createTSUnionType.call(void 0, types), scope };
return { type: (0, import_common2.createTSUnionType)(types), scope };
} else if (objectType.type !== "TSInterfaceDeclaration" && objectType.type !== "TSTypeLiteral" && objectType.type !== "TSIntersectionType" && objectType.type !== "TSMappedType" && objectType.type !== "TSFunctionType")

@@ -335,3 +383,3 @@ return void 0;

keys = resolveMaybeTSUnion(literal).map(
(literal2) => String(_common.resolveLiteral.call(void 0, literal2))
(literal2) => String((0, import_common2.resolveLiteral)(literal2))
);

@@ -346,3 +394,3 @@ } else if (index.type === "TSTypeOperator") {

keys = resolveMaybeTSUnion(keysStrings).map(
(literal) => String(_common.resolveLiteral.call(void 0, literal))
(literal) => String((0, import_common2.resolveLiteral)(literal))
);

@@ -377,3 +425,3 @@ } else

indexes.push({ type: "TSUndefinedKeyword" });
return { type: _common.createTSUnionType.call(void 0, indexes), scope };
return { type: (0, import_common2.createTSUnionType)(indexes), scope };
}

@@ -399,3 +447,3 @@ async function resolveTSTypeOperator({ scope, type }, stacks = []) {

});
return getTSPropertiesKeys(properties).map((k) => _common.createStringLiteral.call(void 0, k));
return getTSPropertiesKeys(properties).map((k) => (0, import_common2.createStringLiteral)(k));
}

@@ -411,8 +459,4 @@ function resolveMaybeTSUnion(node) {

// src/ts/scope.ts
var _promises = require('fs/promises');
var import_promises = require("fs/promises");
var import_common3 = require("@vue-macros/common");
var tsFileCache = /* @__PURE__ */ Object.create(null);

@@ -422,4 +466,4 @@ async function getTSFile(filePath) {

return tsFileCache[filePath];
const content = await _promises.readFile.call(void 0, filePath, "utf-8");
const { code, lang } = _common.getFileCodeAndLang.call(void 0, content, filePath);
const content = await (0, import_promises.readFile)(filePath, "utf-8");
const { code, lang } = (0, import_common3.getFileCodeAndLang)(content, filePath);
return tsFileCache[filePath] = {

@@ -429,3 +473,3 @@ kind: "file",

content,
ast: _common.REGEX_SUPPORTED_EXT.test(filePath) ? _common.babelParse.call(void 0, code, lang).body : void 0
ast: import_common3.REGEX_SUPPORTED_EXT.test(filePath) ? (0, import_common3.babelParse)(code, lang).body : void 0
};

@@ -453,3 +497,3 @@ }

function isSupportedForTSReferencedType(node) {
return _types.isTSType.call(void 0, node) || node.type === "Identifier" || isTSDeclaration(node);
return (0, import_types2.isTSType)(node) || node.type === "Identifier" || isTSDeclaration(node);
}

@@ -487,3 +531,3 @@ async function resolveTSReferencedType(ref, stacks = []) {

await resolveTSNamespace(scope);
const refNames = _common.resolveIdentifier.call(void 0,
const refNames = (0, import_common4.resolveIdentifier)(
type.type === "TSTypeReference" ? type.typeName : type

@@ -503,4 +547,4 @@ );

// src/ts/resolve-file.ts
var _fs = require('fs');
var _path = require('path'); var _path2 = _interopRequireDefault(_path);
var import_node_fs = require("fs");
var import_node_path = __toESM(require("path"));
var resolveTSFileIdImpl = resolveTSFileIdNode;

@@ -512,4 +556,4 @@ function resolveTSFileId(id, importer) {

function tryResolve(id2, importer2) {
const filePath = _path2.default.resolve(importer2, "..", id2);
if (!_fs.existsSync.call(void 0, filePath))
const filePath = import_node_path.default.resolve(importer2, "..", id2);
if (!(0, import_node_fs.existsSync)(filePath))
return;

@@ -583,3 +627,3 @@ return filePath;

const decl = stmt.declaration;
if (_optionalChain([decl, 'access', _8 => _8.id, 'optionalAccess', _9 => _9.type]) === "Identifier") {
if (decl.id?.type === "Identifier") {
const exportedName = decl.id.name;

@@ -593,3 +637,3 @@ declarations[exportedName] = exports2[exportedName] = await resolveTSReferencedType({

} else if (isTSDeclaration(stmt)) {
if (_optionalChain([stmt, 'access', _10 => _10.id, 'optionalAccess', _11 => _11.type]) !== "Identifier")
if (stmt.id?.type !== "Identifier")
continue;

@@ -780,3 +824,3 @@ declarations[stmt.id.name] = await resolveTSReferencedType({

handleType(resolved) {
return _optionalChain([resolved, 'access', _12 => _12.typeParameters, 'optionalAccess', _13 => _13.params, 'access', _14 => _14[0]]);
return resolved.typeParameters?.params[0];
},

@@ -792,3 +836,3 @@ handleTSProperties(properties) {

handleType(resolved) {
return _optionalChain([resolved, 'access', _15 => _15.typeParameters, 'optionalAccess', _16 => _16.params, 'access', _17 => _17[0]]);
return resolved.typeParameters?.params[0];
},

@@ -804,3 +848,3 @@ handleTSProperties(properties) {

handleType(resolved) {
return _optionalChain([resolved, 'access', _18 => _18.typeParameters, 'optionalAccess', _19 => _19.params, 'access', _20 => _20[0]]);
return resolved.typeParameters?.params[0];
}

@@ -906,3 +950,3 @@ }

const removeProp = (name) => {
const key = _common.resolveString.call(void 0, name);
const key = (0, import_common5.resolveString)(name);
if (!definitions[key])

@@ -952,3 +996,3 @@ return false;

}
const defaultValue = _optionalChain([defaults, 'optionalAccess', _21 => _21[propName]]);
const defaultValue = defaults?.[propName];
if (defaultValue) {

@@ -1129,3 +1173,3 @@ prop.default = (key = "default") => {

throw new SyntaxError(
`Cannot resolve TS type: ${_common.resolveIdentifier.call(void 0,
`Cannot resolve TS type: ${(0, import_common5.resolveIdentifier)(
definitionsAst2.typeName

@@ -1144,3 +1188,3 @@ ).join(".")}`

});
if (_optionalChain([builtInTypesHandler, 'optionalAccess', _22 => _22.handleTSProperties]))
if (builtInTypesHandler?.handleTSProperties)
properties = builtInTypesHandler.handleTSProperties(properties);

@@ -1155,6 +1199,6 @@ return {

return {};
const isStatic = defaultsAst2.type === "ObjectExpression" && _common.isStaticObjectKey.call(void 0, defaultsAst2);
const isStatic = defaultsAst2.type === "ObjectExpression" && (0, import_common5.isStaticObjectKey)(defaultsAst2);
if (!isStatic)
return { defaultsAst: defaultsAst2 };
const defaults2 = _common.resolveObjectExpression.call(void 0, defaultsAst2);
const defaults2 = (0, import_common5.resolveObjectExpression)(defaultsAst2);
if (!defaults2)

@@ -1165,6 +1209,6 @@ return { defaultsAst: defaultsAst2 };

function buildNewProp(name, value, optional) {
const key = _common.resolveString.call(void 0, name);
const key = (0, import_common5.resolveString)(name);
const signature = `${name}${optional ? "?" : ""}: ${value}`;
const valueAst = _common.babelParse.call(void 0, `type T = (${value})`, "ts").body[0].typeAnnotation.typeAnnotation;
const signatureAst = _common.babelParse.call(void 0, `interface T {${signature}}`, "ts").body[0].body.body[0];
const valueAst = (0, import_common5.babelParse)(`type T = (${value})`, "ts").body[0].typeAnnotation.typeAnnotation;
const signatureAst = (0, import_common5.babelParse)(`interface T {${signature}}`, "ts").body[0].body.body[0];
return { key, signature, signatureAst, valueAst };

@@ -1185,8 +1229,3 @@ }

// src/vue/emits.ts
var import_common6 = require("@vue-macros/common");
async function handleTSEmitsDefinition({

@@ -1206,3 +1245,3 @@ s,

const addEmit = (name, signature) => {
const key = _common.resolveString.call(void 0, name);
const key = (0, import_common6.resolveString)(name);
if (definitionsAst.scope === file) {

@@ -1226,3 +1265,3 @@ if (definitionsAst.ast.type === "TSIntersectionType") {

const setEmit = (name, idx, signature) => {
const key = _common.resolveString.call(void 0, name);
const key = (0, import_common6.resolveString)(name);
const def = definitions[key][idx];

@@ -1243,3 +1282,3 @@ if (!def)

const removeEmit = (name, idx) => {
const key = _common.resolveString.call(void 0, name);
const key = (0, import_common6.resolveString)(name);
const def = definitions[key][idx];

@@ -1265,3 +1304,3 @@ if (!def)

function parseSignature(signature) {
return _common.babelParse.call(void 0, `interface T {${signature}}`, "ts").body[0].body.body[0];
return (0, import_common6.babelParse)(`interface T {${signature}}`, "ts").body[0].body.body[0];
}

@@ -1284,3 +1323,3 @@ async function resolveDefinitions(typeDeclRaw2) {

const evtArg = signature.type.parameters[0];
if (!evtArg || evtArg.type !== "Identifier" || _optionalChain([evtArg, 'access', _23 => _23.typeAnnotation, 'optionalAccess', _24 => _24.type]) !== "TSTypeAnnotation")
if (!evtArg || evtArg.type !== "Identifier" || evtArg.typeAnnotation?.type !== "TSTypeAnnotation")
continue;

@@ -1291,3 +1330,3 @@ const evtType = await resolveTSReferencedType({

});
if (isTSNamespace(evtType) || !_optionalChain([evtType, 'optionalAccess', _25 => _25.type]))
if (isTSNamespace(evtType) || !evtType?.type)
continue;

@@ -1299,6 +1338,6 @@ const types = evtType.type.type === "TSUnionType" ? evtType.type.types : [evtType.type];

const literal = type.literal;
if (!_common.isStaticExpression.call(void 0, literal))
if (!(0, import_common6.isStaticExpression)(literal))
continue;
const evt = String(
_common.resolveLiteral.call(void 0, literal)
(0, import_common6.resolveLiteral)(literal)
);

@@ -1328,3 +1367,3 @@ if (!definitions2[evt])

// src/vue/analyze.ts
var import_common8 = require("@vue-macros/common");
async function analyzeSFC(s, sfc) {

@@ -1334,3 +1373,3 @@ if (!sfc.scriptSetup)

const { scriptSetup } = sfc;
const body = _common.babelParse.call(void 0,
const body = (0, import_common7.babelParse)(
scriptSetup.content,

@@ -1395,5 +1434,5 @@ sfc.scriptSetup.lang || "js"

}) {
if (!_common.isCallOf.call(void 0, defineProps, _common.DEFINE_PROPS) || props)
if (!(0, import_common7.isCallOf)(defineProps, import_common7.DEFINE_PROPS) || props)
return false;
const typeDeclRaw = _optionalChain([defineProps, 'access', _26 => _26.typeParameters, 'optionalAccess', _27 => _27.params, 'access', _28 => _28[0]]);
const typeDeclRaw = defineProps.typeParameters?.params[0];
if (typeDeclRaw) {

@@ -1422,7 +1461,7 @@ props = await handleTSPropsDefinition({

}) {
if (!_common.isCallOf.call(void 0, withDefaults, _common.WITH_DEFAULTS))
if (!(0, import_common7.isCallOf)(withDefaults, import_common7.WITH_DEFAULTS))
return false;
if (!_common.isCallOf.call(void 0, withDefaults.arguments[0], _common.DEFINE_PROPS)) {
if (!(0, import_common7.isCallOf)(withDefaults.arguments[0], import_common7.DEFINE_PROPS)) {
throw new SyntaxError(
`${_common.WITH_DEFAULTS}: first argument must be a ${_common.DEFINE_PROPS} call.`
`${import_common7.WITH_DEFAULTS}: first argument must be a ${import_common7.DEFINE_PROPS} call.`
);

@@ -1446,5 +1485,5 @@ }

}) {
if (!_common.isCallOf.call(void 0, defineEmits, _common.DEFINE_EMITS) || emits)
if (!(0, import_common7.isCallOf)(defineEmits, import_common7.DEFINE_EMITS) || emits)
return false;
const typeDeclRaw = _optionalChain([defineEmits, 'access', _29 => _29.typeParameters, 'optionalAccess', _30 => _30.params, 'access', _31 => _31[0]]);
const typeDeclRaw = defineEmits.typeParameters?.params[0];
if (typeDeclRaw) {

@@ -1469,6 +1508,6 @@ emits = await handleTSEmitsDefinition({

// src/resolve.ts
var _resolveexports = require('resolve.exports');
var import_node_fs2 = require("fs");
var import_promises2 = require("fs/promises");
var import_node_path2 = __toESM(require("path"));
var import_resolve3 = require("resolve.exports");
var deepImportRE = /^([^@][^/]*)\/|^(@[^/]+\/[^/]+)\//;

@@ -1503,7 +1542,7 @@ function isDts(id) {

try {
const pkgPath = await _asyncOptionalChain([(await ctx.resolve(`${pkgId}/package.json`, importer)), 'optionalAccess', async _32 => _32.id]);
const pkgPath = (await ctx.resolve(`${pkgId}/package.json`, importer))?.id;
if (!pkgPath)
return;
const pkg = JSON.parse(await _promises.readFile.call(void 0, pkgPath, "utf-8"));
const pkgRoot = _path2.default.resolve(pkgPath, "..");
const pkg = JSON.parse(await (0, import_promises2.readFile)(pkgPath, "utf-8"));
const pkgRoot = import_node_path2.default.resolve(pkgPath, "..");
if (deepMatch) {

@@ -1519,7 +1558,7 @@ if (pkg.typesVersions) {

for (const subpath of subpaths) {
const resolved2 = _path2.default.resolve(
const resolved2 = import_node_path2.default.resolve(
pkgRoot,
subpath.replace("*", pkgPath2)
);
if (isDts(resolved2) && _fs.existsSync.call(void 0, resolved2))
if (isDts(resolved2) && (0, import_node_fs2.existsSync)(resolved2))
return resolved2;

@@ -1530,6 +1569,6 @@ }

}
const resolvedIds = _resolveexports.exports.call(void 0, pkg, id, { conditions: ["types"] });
const resolvedIds = (0, import_resolve3.exports)(pkg, id, { conditions: ["types"] });
if (!resolvedIds)
return;
const resolved = resolvedIds.find((id2) => isDts(id2) && _fs.existsSync.call(void 0, id2));
const resolved = resolvedIds.find((id2) => isDts(id2) && (0, import_node_fs2.existsSync)(id2));
if (resolved)

@@ -1541,7 +1580,7 @@ return resolved;

return;
const entry = _path2.default.resolve(pkgRoot, types);
if (_fs.existsSync.call(void 0, entry))
const entry = import_node_path2.default.resolve(pkgRoot, types);
if ((0, import_node_fs2.existsSync)(entry))
return entry;
}
} catch (e2) {
} catch {
}

@@ -1551,4 +1590,4 @@ }

try {
return await _asyncOptionalChain([(await ctx.resolve(id, importer)), 'optionalAccess', async _33 => _33.id]) || await _asyncOptionalChain([(await ctx.resolve(`${id}.d`, importer)), 'optionalAccess', async _34 => _34.id]);
} catch (e3) {
return (await ctx.resolve(id, importer))?.id || (await ctx.resolve(`${id}.d`, importer))?.id;
} catch {
}

@@ -1558,3 +1597,3 @@ return;

return async (id, importer) => {
const cached = _optionalChain([resolveCache, 'access', _35 => _35.get, 'call', _36 => _36(importer), 'optionalAccess', _37 => _37.get, 'call', _38 => _38(id)]);
const cached = resolveCache.get(importer)?.get(id);
if (cached)

@@ -1570,3 +1609,3 @@ return cached;

return;
if (_fs.existsSync.call(void 0, resolved)) {
if ((0, import_node_fs2.existsSync)(resolved)) {
collectReferencedFile(importer, resolved);

@@ -1576,3 +1615,3 @@ return withResolveCache(id, importer, resolved);

resolved = await tryResolve(resolved, importer);
if (resolved && _fs.existsSync.call(void 0, resolved)) {
if (resolved && (0, import_node_fs2.existsSync)(resolved)) {
collectReferencedFile(importer, resolved);

@@ -1614,36 +1653,38 @@ return withResolveCache(id, importer, resolved);

};
exports.DefinitionKind = DefinitionKind; exports.RollupResolve = RollupResolve; exports.UNKNOWN_TYPE = UNKNOWN_TYPE; exports.analyzeSFC = analyzeSFC; exports.attachNodeLoc = attachNodeLoc; exports.checkForTSProperties = checkForTSProperties; exports.deepImportRE = deepImportRE; exports.genRuntimePropDefinition = genRuntimePropDefinition; exports.getTSFile = getTSFile; exports.getTSPropertiesKeys = getTSPropertiesKeys; exports.handleTSEmitsDefinition = handleTSEmitsDefinition; exports.handleTSPropsDefinition = handleTSPropsDefinition; exports.inferRuntimeType = inferRuntimeType; exports.isSupportedForTSReferencedType = isSupportedForTSReferencedType; exports.isTSDeclaration = isTSDeclaration; exports.isTSNamespace = isTSNamespace; exports.mergeTSProperties = mergeTSProperties; exports.namespaceSymbol = namespaceSymbol; exports.parseSFC = _common.parseSFC; exports.resolveMaybeTSUnion = resolveMaybeTSUnion; exports.resolveTSFileId = resolveTSFileId; exports.resolveTSFileIdNode = resolveTSFileIdNode; exports.resolveTSIndexedAccessType = resolveTSIndexedAccessType; exports.resolveTSLiteralType = resolveTSLiteralType; exports.resolveTSNamespace = resolveTSNamespace; exports.resolveTSProperties = resolveTSProperties; exports.resolveTSReferencedType = resolveTSReferencedType; exports.resolveTSScope = resolveTSScope; exports.resolveTSTemplateLiteral = resolveTSTemplateLiteral; exports.resolveTSTypeOperator = resolveTSTypeOperator; exports.resolveTypeElements = resolveTypeElements; exports.setResolveTSFileIdImpl = setResolveTSFileIdImpl; exports.tsFileCache = tsFileCache;
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
DefinitionKind,
RollupResolve,
UNKNOWN_TYPE,
analyzeSFC,
attachNodeLoc,
checkForTSProperties,
deepImportRE,
genRuntimePropDefinition,
getTSFile,
getTSPropertiesKeys,
handleTSEmitsDefinition,
handleTSPropsDefinition,
inferRuntimeType,
isSupportedForTSReferencedType,
isTSDeclaration,
isTSNamespace,
mergeTSProperties,
namespaceSymbol,
parseSFC,
resolveMaybeTSUnion,
resolveTSFileId,
resolveTSFileIdNode,
resolveTSIndexedAccessType,
resolveTSLiteralType,
resolveTSNamespace,
resolveTSProperties,
resolveTSReferencedType,
resolveTSScope,
resolveTSTemplateLiteral,
resolveTSTypeOperator,
resolveTypeElements,
setResolveTSFileIdImpl,
tsFileCache,
...require("@vue-macros/common")
});

@@ -1,44 +0,92 @@

"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _createStarExport(obj) { Object.keys(obj) .filter((key) => key !== "default" && key !== "__esModule") .forEach((key) => { if (exports.hasOwnProperty(key)) { return; } Object.defineProperty(exports, key, {enumerable: true, configurable: true, get: () => obj[key]}); }); } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } async function _asyncOptionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = await fn(value); } else if (op === 'call' || op === 'optionalCall') { value = await fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }// src/index.ts
var _common = require('@vue-macros/common'); _createStarExport(_common);
"use strict";
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
// If the importer is in node compatibility mode or this is not an ESM
// file that has been converted to a CommonJS file using a Babel-
// compatible transform (i.e. "__esModule" has not been set), then set
// "default" to the CommonJS "module.exports" for node compatibility.
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
// src/index.ts
var src_exports = {};
__export(src_exports, {
DefinitionKind: () => DefinitionKind,
RollupResolve: () => RollupResolve,
UNKNOWN_TYPE: () => UNKNOWN_TYPE,
analyzeSFC: () => analyzeSFC,
attachNodeLoc: () => attachNodeLoc,
checkForTSProperties: () => checkForTSProperties,
deepImportRE: () => deepImportRE,
genRuntimePropDefinition: () => genRuntimePropDefinition,
getTSFile: () => getTSFile,
getTSPropertiesKeys: () => getTSPropertiesKeys,
handleTSEmitsDefinition: () => handleTSEmitsDefinition,
handleTSPropsDefinition: () => handleTSPropsDefinition,
inferRuntimeType: () => inferRuntimeType,
isSupportedForTSReferencedType: () => isSupportedForTSReferencedType,
isTSDeclaration: () => isTSDeclaration,
isTSNamespace: () => isTSNamespace,
mergeTSProperties: () => mergeTSProperties,
namespaceSymbol: () => namespaceSymbol,
parseSFC: () => import_common8.parseSFC,
resolveMaybeTSUnion: () => resolveMaybeTSUnion,
resolveTSFileId: () => resolveTSFileId,
resolveTSFileIdNode: () => resolveTSFileIdNode,
resolveTSIndexedAccessType: () => resolveTSIndexedAccessType,
resolveTSLiteralType: () => resolveTSLiteralType,
resolveTSNamespace: () => resolveTSNamespace,
resolveTSProperties: () => resolveTSProperties,
resolveTSReferencedType: () => resolveTSReferencedType,
resolveTSScope: () => resolveTSScope,
resolveTSTemplateLiteral: () => resolveTSTemplateLiteral,
resolveTSTypeOperator: () => resolveTSTypeOperator,
resolveTypeElements: () => resolveTypeElements,
setResolveTSFileIdImpl: () => setResolveTSFileIdImpl,
tsFileCache: () => tsFileCache
});
module.exports = __toCommonJS(src_exports);
__reExport(src_exports, require("@vue-macros/common"), module.exports);
// src/vue/analyze.ts
var import_common7 = require("@vue-macros/common");
// src/vue/props.ts
var import_common5 = require("@vue-macros/common");
// src/ts/is.ts
var _types = require('@babel/types');
var import_types = require("@babel/types");
function isTSDeclaration(node) {
return _types.isDeclaration.call(void 0, node) && node.type.startsWith("TS");
return (0, import_types.isDeclaration)(node) && node.type.startsWith("TS");
}
// src/ts/resolve-reference.ts
var import_common4 = require("@vue-macros/common");
var import_types2 = require("@babel/types");
// src/ts/resolve.ts
var import_common2 = require("@vue-macros/common");
// src/ts/property.ts
var import_common = require("@vue-macros/common");
function mergeTSProperties(a, b) {

@@ -138,3 +186,3 @@ return {

const keys = resolveMaybeTSUnion(literal).map(
(literal2) => String(_common.resolveLiteral.call(void 0, literal2))
(literal2) => String((0, import_common.resolveLiteral)(literal2))
);

@@ -161,6 +209,6 @@ for (const key of keys) {

default:
throw new Error(`unknown node: ${_optionalChain([type, 'optionalAccess', _ => _.type])}`);
throw new Error(`unknown node: ${type?.type}`);
}
function filterValidExtends(node) {
return !isTSNamespace(node) && checkForTSProperties(_optionalChain([node, 'optionalAccess', _2 => _2.type]));
return !isTSNamespace(node) && checkForTSProperties(node?.type);
}

@@ -183,3 +231,3 @@ }

const types = (await resolveKeys("", type.quasis, type.expressions)).map(
(k) => _common.createStringLiteral.call(void 0, k)
(k) => (0, import_common2.createStringLiteral)(k)
);

@@ -189,3 +237,3 @@ return types;

if (expressions.length === 0) {
return [prefix + (_nullishCoalesce(_optionalChain([quasis, 'access', _3 => _3[0], 'optionalAccess', _4 => _4.value, 'access', _5 => _5.cooked]), () => ( "")))];
return [prefix + (quasis[0]?.value.cooked ?? "")];
}

@@ -213,3 +261,3 @@ const [expr, ...restExpr] = expressions;

const subKeys = resolveMaybeTSUnion(literal).map(
(literal2) => String(_common.resolveLiteral.call(void 0, literal2))
(literal2) => String((0, import_common2.resolveLiteral)(literal2))
);

@@ -246,4 +294,4 @@ for (const key of subKeys) {

try {
return _common.resolveObjectKey.call(void 0, element);
} catch (e) {
return (0, import_common2.resolveObjectKey)(element);
} catch {
}

@@ -277,3 +325,3 @@ };

if (!properties.properties[key] && !properties.methods[key]) {
const type = _optionalChain([element, 'access', _6 => _6.typeAnnotation, 'optionalAccess', _7 => _7.typeAnnotation]);
const type = element.typeAnnotation?.typeAnnotation;
properties.properties[key] = {

@@ -314,3 +362,3 @@ value: type ? { type, scope } : null,

}
return { type: _common.createTSUnionType.call(void 0, types), scope };
return { type: (0, import_common2.createTSUnionType)(types), scope };
} else if (objectType.type !== "TSInterfaceDeclaration" && objectType.type !== "TSTypeLiteral" && objectType.type !== "TSIntersectionType" && objectType.type !== "TSMappedType" && objectType.type !== "TSFunctionType")

@@ -335,3 +383,3 @@ return void 0;

keys = resolveMaybeTSUnion(literal).map(
(literal2) => String(_common.resolveLiteral.call(void 0, literal2))
(literal2) => String((0, import_common2.resolveLiteral)(literal2))
);

@@ -346,3 +394,3 @@ } else if (index.type === "TSTypeOperator") {

keys = resolveMaybeTSUnion(keysStrings).map(
(literal) => String(_common.resolveLiteral.call(void 0, literal))
(literal) => String((0, import_common2.resolveLiteral)(literal))
);

@@ -377,3 +425,3 @@ } else

indexes.push({ type: "TSUndefinedKeyword" });
return { type: _common.createTSUnionType.call(void 0, indexes), scope };
return { type: (0, import_common2.createTSUnionType)(indexes), scope };
}

@@ -399,3 +447,3 @@ async function resolveTSTypeOperator({ scope, type }, stacks = []) {

});
return getTSPropertiesKeys(properties).map((k) => _common.createStringLiteral.call(void 0, k));
return getTSPropertiesKeys(properties).map((k) => (0, import_common2.createStringLiteral)(k));
}

@@ -411,8 +459,4 @@ function resolveMaybeTSUnion(node) {

// src/ts/scope.ts
var _promises = require('fs/promises');
var import_promises = require("fs/promises");
var import_common3 = require("@vue-macros/common");
var tsFileCache = /* @__PURE__ */ Object.create(null);

@@ -422,4 +466,4 @@ async function getTSFile(filePath) {

return tsFileCache[filePath];
const content = await _promises.readFile.call(void 0, filePath, "utf-8");
const { code, lang } = _common.getFileCodeAndLang.call(void 0, content, filePath);
const content = await (0, import_promises.readFile)(filePath, "utf-8");
const { code, lang } = (0, import_common3.getFileCodeAndLang)(content, filePath);
return tsFileCache[filePath] = {

@@ -429,3 +473,3 @@ kind: "file",

content,
ast: _common.REGEX_SUPPORTED_EXT.test(filePath) ? _common.babelParse.call(void 0, code, lang).body : void 0
ast: import_common3.REGEX_SUPPORTED_EXT.test(filePath) ? (0, import_common3.babelParse)(code, lang).body : void 0
};

@@ -453,3 +497,3 @@ }

function isSupportedForTSReferencedType(node) {
return _types.isTSType.call(void 0, node) || node.type === "Identifier" || isTSDeclaration(node);
return (0, import_types2.isTSType)(node) || node.type === "Identifier" || isTSDeclaration(node);
}

@@ -487,3 +531,3 @@ async function resolveTSReferencedType(ref, stacks = []) {

await resolveTSNamespace(scope);
const refNames = _common.resolveIdentifier.call(void 0,
const refNames = (0, import_common4.resolveIdentifier)(
type.type === "TSTypeReference" ? type.typeName : type

@@ -503,4 +547,4 @@ );

// src/ts/resolve-file.ts
var _fs = require('fs');
var _path = require('path'); var _path2 = _interopRequireDefault(_path);
var import_node_fs = require("fs");
var import_node_path = __toESM(require("path"));
var resolveTSFileIdImpl = resolveTSFileIdNode;

@@ -512,4 +556,4 @@ function resolveTSFileId(id, importer) {

function tryResolve(id2, importer2) {
const filePath = _path2.default.resolve(importer2, "..", id2);
if (!_fs.existsSync.call(void 0, filePath))
const filePath = import_node_path.default.resolve(importer2, "..", id2);
if (!(0, import_node_fs.existsSync)(filePath))
return;

@@ -583,3 +627,3 @@ return filePath;

const decl = stmt.declaration;
if (_optionalChain([decl, 'access', _8 => _8.id, 'optionalAccess', _9 => _9.type]) === "Identifier") {
if (decl.id?.type === "Identifier") {
const exportedName = decl.id.name;

@@ -593,3 +637,3 @@ declarations[exportedName] = exports2[exportedName] = await resolveTSReferencedType({

} else if (isTSDeclaration(stmt)) {
if (_optionalChain([stmt, 'access', _10 => _10.id, 'optionalAccess', _11 => _11.type]) !== "Identifier")
if (stmt.id?.type !== "Identifier")
continue;

@@ -780,3 +824,3 @@ declarations[stmt.id.name] = await resolveTSReferencedType({

handleType(resolved) {
return _optionalChain([resolved, 'access', _12 => _12.typeParameters, 'optionalAccess', _13 => _13.params, 'access', _14 => _14[0]]);
return resolved.typeParameters?.params[0];
},

@@ -792,3 +836,3 @@ handleTSProperties(properties) {

handleType(resolved) {
return _optionalChain([resolved, 'access', _15 => _15.typeParameters, 'optionalAccess', _16 => _16.params, 'access', _17 => _17[0]]);
return resolved.typeParameters?.params[0];
},

@@ -804,3 +848,3 @@ handleTSProperties(properties) {

handleType(resolved) {
return _optionalChain([resolved, 'access', _18 => _18.typeParameters, 'optionalAccess', _19 => _19.params, 'access', _20 => _20[0]]);
return resolved.typeParameters?.params[0];
}

@@ -906,3 +950,3 @@ }

const removeProp = (name) => {
const key = _common.resolveString.call(void 0, name);
const key = (0, import_common5.resolveString)(name);
if (!definitions[key])

@@ -952,3 +996,3 @@ return false;

}
const defaultValue = _optionalChain([defaults, 'optionalAccess', _21 => _21[propName]]);
const defaultValue = defaults?.[propName];
if (defaultValue) {

@@ -1129,3 +1173,3 @@ prop.default = (key = "default") => {

throw new SyntaxError(
`Cannot resolve TS type: ${_common.resolveIdentifier.call(void 0,
`Cannot resolve TS type: ${(0, import_common5.resolveIdentifier)(
definitionsAst2.typeName

@@ -1144,3 +1188,3 @@ ).join(".")}`

});
if (_optionalChain([builtInTypesHandler, 'optionalAccess', _22 => _22.handleTSProperties]))
if (builtInTypesHandler?.handleTSProperties)
properties = builtInTypesHandler.handleTSProperties(properties);

@@ -1155,6 +1199,6 @@ return {

return {};
const isStatic = defaultsAst2.type === "ObjectExpression" && _common.isStaticObjectKey.call(void 0, defaultsAst2);
const isStatic = defaultsAst2.type === "ObjectExpression" && (0, import_common5.isStaticObjectKey)(defaultsAst2);
if (!isStatic)
return { defaultsAst: defaultsAst2 };
const defaults2 = _common.resolveObjectExpression.call(void 0, defaultsAst2);
const defaults2 = (0, import_common5.resolveObjectExpression)(defaultsAst2);
if (!defaults2)

@@ -1165,6 +1209,6 @@ return { defaultsAst: defaultsAst2 };

function buildNewProp(name, value, optional) {
const key = _common.resolveString.call(void 0, name);
const key = (0, import_common5.resolveString)(name);
const signature = `${name}${optional ? "?" : ""}: ${value}`;
const valueAst = _common.babelParse.call(void 0, `type T = (${value})`, "ts").body[0].typeAnnotation.typeAnnotation;
const signatureAst = _common.babelParse.call(void 0, `interface T {${signature}}`, "ts").body[0].body.body[0];
const valueAst = (0, import_common5.babelParse)(`type T = (${value})`, "ts").body[0].typeAnnotation.typeAnnotation;
const signatureAst = (0, import_common5.babelParse)(`interface T {${signature}}`, "ts").body[0].body.body[0];
return { key, signature, signatureAst, valueAst };

@@ -1185,8 +1229,3 @@ }

// src/vue/emits.ts
var import_common6 = require("@vue-macros/common");
async function handleTSEmitsDefinition({

@@ -1206,3 +1245,3 @@ s,

const addEmit = (name, signature) => {
const key = _common.resolveString.call(void 0, name);
const key = (0, import_common6.resolveString)(name);
if (definitionsAst.scope === file) {

@@ -1226,3 +1265,3 @@ if (definitionsAst.ast.type === "TSIntersectionType") {

const setEmit = (name, idx, signature) => {
const key = _common.resolveString.call(void 0, name);
const key = (0, import_common6.resolveString)(name);
const def = definitions[key][idx];

@@ -1243,3 +1282,3 @@ if (!def)

const removeEmit = (name, idx) => {
const key = _common.resolveString.call(void 0, name);
const key = (0, import_common6.resolveString)(name);
const def = definitions[key][idx];

@@ -1265,3 +1304,3 @@ if (!def)

function parseSignature(signature) {
return _common.babelParse.call(void 0, `interface T {${signature}}`, "ts").body[0].body.body[0];
return (0, import_common6.babelParse)(`interface T {${signature}}`, "ts").body[0].body.body[0];
}

@@ -1284,3 +1323,3 @@ async function resolveDefinitions(typeDeclRaw2) {

const evtArg = signature.type.parameters[0];
if (!evtArg || evtArg.type !== "Identifier" || _optionalChain([evtArg, 'access', _23 => _23.typeAnnotation, 'optionalAccess', _24 => _24.type]) !== "TSTypeAnnotation")
if (!evtArg || evtArg.type !== "Identifier" || evtArg.typeAnnotation?.type !== "TSTypeAnnotation")
continue;

@@ -1291,3 +1330,3 @@ const evtType = await resolveTSReferencedType({

});
if (isTSNamespace(evtType) || !_optionalChain([evtType, 'optionalAccess', _25 => _25.type]))
if (isTSNamespace(evtType) || !evtType?.type)
continue;

@@ -1299,6 +1338,6 @@ const types = evtType.type.type === "TSUnionType" ? evtType.type.types : [evtType.type];

const literal = type.literal;
if (!_common.isStaticExpression.call(void 0, literal))
if (!(0, import_common6.isStaticExpression)(literal))
continue;
const evt = String(
_common.resolveLiteral.call(void 0, literal)
(0, import_common6.resolveLiteral)(literal)
);

@@ -1328,3 +1367,3 @@ if (!definitions2[evt])

// src/vue/analyze.ts
var import_common8 = require("@vue-macros/common");
async function analyzeSFC(s, sfc) {

@@ -1334,3 +1373,3 @@ if (!sfc.scriptSetup)

const { scriptSetup } = sfc;
const body = _common.babelParse.call(void 0,
const body = (0, import_common7.babelParse)(
scriptSetup.content,

@@ -1395,5 +1434,5 @@ sfc.scriptSetup.lang || "js"

}) {
if (!_common.isCallOf.call(void 0, defineProps, _common.DEFINE_PROPS) || props)
if (!(0, import_common7.isCallOf)(defineProps, import_common7.DEFINE_PROPS) || props)
return false;
const typeDeclRaw = _optionalChain([defineProps, 'access', _26 => _26.typeParameters, 'optionalAccess', _27 => _27.params, 'access', _28 => _28[0]]);
const typeDeclRaw = defineProps.typeParameters?.params[0];
if (typeDeclRaw) {

@@ -1422,7 +1461,7 @@ props = await handleTSPropsDefinition({

}) {
if (!_common.isCallOf.call(void 0, withDefaults, _common.WITH_DEFAULTS))
if (!(0, import_common7.isCallOf)(withDefaults, import_common7.WITH_DEFAULTS))
return false;
if (!_common.isCallOf.call(void 0, withDefaults.arguments[0], _common.DEFINE_PROPS)) {
if (!(0, import_common7.isCallOf)(withDefaults.arguments[0], import_common7.DEFINE_PROPS)) {
throw new SyntaxError(
`${_common.WITH_DEFAULTS}: first argument must be a ${_common.DEFINE_PROPS} call.`
`${import_common7.WITH_DEFAULTS}: first argument must be a ${import_common7.DEFINE_PROPS} call.`
);

@@ -1446,5 +1485,5 @@ }

}) {
if (!_common.isCallOf.call(void 0, defineEmits, _common.DEFINE_EMITS) || emits)
if (!(0, import_common7.isCallOf)(defineEmits, import_common7.DEFINE_EMITS) || emits)
return false;
const typeDeclRaw = _optionalChain([defineEmits, 'access', _29 => _29.typeParameters, 'optionalAccess', _30 => _30.params, 'access', _31 => _31[0]]);
const typeDeclRaw = defineEmits.typeParameters?.params[0];
if (typeDeclRaw) {

@@ -1469,6 +1508,6 @@ emits = await handleTSEmitsDefinition({

// src/resolve.ts
var _resolveexports = require('resolve.exports');
var import_node_fs2 = require("fs");
var import_promises2 = require("fs/promises");
var import_node_path2 = __toESM(require("path"));
var import_resolve3 = require("resolve.exports");
var deepImportRE = /^([^@][^/]*)\/|^(@[^/]+\/[^/]+)\//;

@@ -1503,7 +1542,7 @@ function isDts(id) {

try {
const pkgPath = await _asyncOptionalChain([(await ctx.resolve(`${pkgId}/package.json`, importer)), 'optionalAccess', async _32 => _32.id]);
const pkgPath = (await ctx.resolve(`${pkgId}/package.json`, importer))?.id;
if (!pkgPath)
return;
const pkg = JSON.parse(await _promises.readFile.call(void 0, pkgPath, "utf-8"));
const pkgRoot = _path2.default.resolve(pkgPath, "..");
const pkg = JSON.parse(await (0, import_promises2.readFile)(pkgPath, "utf-8"));
const pkgRoot = import_node_path2.default.resolve(pkgPath, "..");
if (deepMatch) {

@@ -1519,7 +1558,7 @@ if (pkg.typesVersions) {

for (const subpath of subpaths) {
const resolved2 = _path2.default.resolve(
const resolved2 = import_node_path2.default.resolve(
pkgRoot,
subpath.replace("*", pkgPath2)
);
if (isDts(resolved2) && _fs.existsSync.call(void 0, resolved2))
if (isDts(resolved2) && (0, import_node_fs2.existsSync)(resolved2))
return resolved2;

@@ -1530,6 +1569,6 @@ }

}
const resolvedIds = _resolveexports.exports.call(void 0, pkg, id, { conditions: ["types"] });
const resolvedIds = (0, import_resolve3.exports)(pkg, id, { conditions: ["types"] });
if (!resolvedIds)
return;
const resolved = resolvedIds.find((id2) => isDts(id2) && _fs.existsSync.call(void 0, id2));
const resolved = resolvedIds.find((id2) => isDts(id2) && (0, import_node_fs2.existsSync)(id2));
if (resolved)

@@ -1541,7 +1580,7 @@ return resolved;

return;
const entry = _path2.default.resolve(pkgRoot, types);
if (_fs.existsSync.call(void 0, entry))
const entry = import_node_path2.default.resolve(pkgRoot, types);
if ((0, import_node_fs2.existsSync)(entry))
return entry;
}
} catch (e2) {
} catch {
}

@@ -1551,4 +1590,4 @@ }

try {
return await _asyncOptionalChain([(await ctx.resolve(id, importer)), 'optionalAccess', async _33 => _33.id]) || await _asyncOptionalChain([(await ctx.resolve(`${id}.d`, importer)), 'optionalAccess', async _34 => _34.id]);
} catch (e3) {
return (await ctx.resolve(id, importer))?.id || (await ctx.resolve(`${id}.d`, importer))?.id;
} catch {
}

@@ -1558,3 +1597,3 @@ return;

return async (id, importer) => {
const cached = _optionalChain([resolveCache, 'access', _35 => _35.get, 'call', _36 => _36(importer), 'optionalAccess', _37 => _37.get, 'call', _38 => _38(id)]);
const cached = resolveCache.get(importer)?.get(id);
if (cached)

@@ -1570,3 +1609,3 @@ return cached;

return;
if (_fs.existsSync.call(void 0, resolved)) {
if ((0, import_node_fs2.existsSync)(resolved)) {
collectReferencedFile(importer, resolved);

@@ -1576,3 +1615,3 @@ return withResolveCache(id, importer, resolved);

resolved = await tryResolve(resolved, importer);
if (resolved && _fs.existsSync.call(void 0, resolved)) {
if (resolved && (0, import_node_fs2.existsSync)(resolved)) {
collectReferencedFile(importer, resolved);

@@ -1614,36 +1653,38 @@ return withResolveCache(id, importer, resolved);

};
exports.DefinitionKind = DefinitionKind; exports.RollupResolve = RollupResolve; exports.UNKNOWN_TYPE = UNKNOWN_TYPE; exports.analyzeSFC = analyzeSFC; exports.attachNodeLoc = attachNodeLoc; exports.checkForTSProperties = checkForTSProperties; exports.deepImportRE = deepImportRE; exports.genRuntimePropDefinition = genRuntimePropDefinition; exports.getTSFile = getTSFile; exports.getTSPropertiesKeys = getTSPropertiesKeys; exports.handleTSEmitsDefinition = handleTSEmitsDefinition; exports.handleTSPropsDefinition = handleTSPropsDefinition; exports.inferRuntimeType = inferRuntimeType; exports.isSupportedForTSReferencedType = isSupportedForTSReferencedType; exports.isTSDeclaration = isTSDeclaration; exports.isTSNamespace = isTSNamespace; exports.mergeTSProperties = mergeTSProperties; exports.namespaceSymbol = namespaceSymbol; exports.parseSFC = _common.parseSFC; exports.resolveMaybeTSUnion = resolveMaybeTSUnion; exports.resolveTSFileId = resolveTSFileId; exports.resolveTSFileIdNode = resolveTSFileIdNode; exports.resolveTSIndexedAccessType = resolveTSIndexedAccessType; exports.resolveTSLiteralType = resolveTSLiteralType; exports.resolveTSNamespace = resolveTSNamespace; exports.resolveTSProperties = resolveTSProperties; exports.resolveTSReferencedType = resolveTSReferencedType; exports.resolveTSScope = resolveTSScope; exports.resolveTSTemplateLiteral = resolveTSTemplateLiteral; exports.resolveTSTypeOperator = resolveTSTypeOperator; exports.resolveTypeElements = resolveTypeElements; exports.setResolveTSFileIdImpl = setResolveTSFileIdImpl; exports.tsFileCache = tsFileCache;
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
DefinitionKind,
RollupResolve,
UNKNOWN_TYPE,
analyzeSFC,
attachNodeLoc,
checkForTSProperties,
deepImportRE,
genRuntimePropDefinition,
getTSFile,
getTSPropertiesKeys,
handleTSEmitsDefinition,
handleTSPropsDefinition,
inferRuntimeType,
isSupportedForTSReferencedType,
isTSDeclaration,
isTSNamespace,
mergeTSProperties,
namespaceSymbol,
parseSFC,
resolveMaybeTSUnion,
resolveTSFileId,
resolveTSFileIdNode,
resolveTSIndexedAccessType,
resolveTSLiteralType,
resolveTSNamespace,
resolveTSProperties,
resolveTSReferencedType,
resolveTSScope,
resolveTSTemplateLiteral,
resolveTSTypeOperator,
resolveTypeElements,
setResolveTSFileIdImpl,
tsFileCache,
...require("@vue-macros/common")
});
{
"name": "@vue-macros/api",
"version": "0.8.4",
"version": "0.8.5",
"packageManager": "pnpm@8.6.12",

@@ -46,3 +46,3 @@ "description": "General API for Vue Macros.",

"resolve.exports": "^2.0.2",
"@vue-macros/common": "1.7.1"
"@vue-macros/common": "1.7.2"
},

@@ -49,0 +49,0 @@ "devDependencies": {

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc