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.0.1 to 0.1.0

dist/chunk-2YHECPZT.mjs

6

dist/index.d.ts
import { MagicString, SFC } from '@vue-macros/common';
export { MagicString, SFC, parseSFC } from '@vue-macros/common';
import { Node, CallExpression, TSType, LVal, VariableDeclaration, ExpressionStatement, TSCallSignatureDeclaration, TSTypeLiteral, TSIntersectionType, TSInterfaceDeclaration, StringLiteral, TSMethodSignature, TSPropertySignature, ObjectMethod, ObjectProperty, Expression } from '@babel/types';
import { Node, TSModuleBlock, CallExpression, TSType, LVal, VariableDeclaration, ExpressionStatement, TSCallSignatureDeclaration, TSTypeLiteral, TSIntersectionType, TSInterfaceDeclaration, StringLiteral, TSMethodSignature, TSPropertySignature, ObjectMethod, ObjectProperty, Expression } from '@babel/types';
import { TSFile, TSResolvedType } from './ts.js';
export { ResolveTSFileIdImpl, TSDeclaration, TSFile, TSFileExports, TSProperties, TSResolvedType, getTSFile, isTSDeclaration, mergeTSProperties, resolveTSFileExports, resolveTSFileId, resolveTSFileIdNode, resolveTSProperties, resolveTSReferencedType, resolveTypeElements, setResolveTSFileIdImpl, tsFileCache, tsFileExportsCache } from './ts.js';
export { ResolveTSFileIdImpl, TSDeclaration, TSExports, TSFile, TSProperties, TSResolvedType, TSScope, exportsSymbol, getTSFile, isTSDeclaration, isTSExports, mergeTSProperties, resolveTSEntityName, resolveTSExports, resolveTSFileId, resolveTSFileIdNode, resolveTSProperties, resolveTSReferencedType, resolveTSScope, resolveTypeElements, setResolveTSFileIdImpl, tsFileCache, tsFileExportsCache } from './ts.js';
export { keyToString } from './utils.js';

@@ -30,3 +30,3 @@

code: string;
file: TSFile | undefined;
scope: TSFile | TSResolvedType<TSModuleBlock> | undefined;
ast: T;

@@ -33,0 +33,0 @@ }

@@ -14,5 +14,9 @@ "use strict";Object.defineProperty(exports, "__esModule", {value: true});

var _chunkRIALXEE4js = require('./chunk-RIALXEE4.js');
var _chunk6EAABA32js = require('./chunk-6EAABA32.js');
var _chunkNTLGGEMNjs = require('./chunk-NTLGGEMN.js');

@@ -106,7 +110,7 @@

node.type.types.map(async (subType) => {
const resolved = await _chunkRIALXEE4js.resolveTSReferencedType.call(void 0, {
file: node.file,
const resolved = await _chunk6EAABA32js.resolveTSReferencedType.call(void 0, {
scope: node.scope,
type: subType
});
return resolved ? inferRuntimeType(resolved) : void 0;
return resolved && !_chunk6EAABA32js.isTSExports.call(void 0, resolved) ? inferRuntimeType(resolved) : void 0;
})

@@ -143,3 +147,3 @@ )).filter((t) => !!t).flat(1);

type: typeDeclRaw,
file
scope: file
});

@@ -155,5 +159,10 @@ const { defaults, defaultsAst } = resolveDefaults(defaultsDeclRaw);

return false;
if (definitionsAst.file === file)
s.appendLeft(definitionsAst.ast.end + offset - 1, ` ${signature}
if (definitionsAst.scope === file) {
if (definitionsAst.ast.type === "TSIntersectionType") {
s.appendLeft(definitionsAst.ast.end + offset, ` & { ${signature} }`);
} else {
s.appendLeft(definitionsAst.ast.end + offset - 1, ` ${signature}
`);
}
}
definitions[key] = {

@@ -164,3 +173,3 @@ type: "property",

ast: valueAst,
file: void 0
scope: void 0
},

@@ -171,3 +180,3 @@ optional: !!optional,

ast: signatureAst,
file: void 0
scope: void 0
},

@@ -190,6 +199,6 @@ addByAPI: true

attachNodeLoc(def.methods[0].ast, signatureAst);
if (def.methods[0].file === file)
if (def.methods[0].scope === file)
s.overwriteNode(def.methods[0].ast, signature, { offset });
def.methods.slice(1).forEach((method) => {
if (method.file === file) {
if (method.scope === file) {
s.removeNode(method.ast, { offset });

@@ -202,3 +211,3 @@ }

attachNodeLoc(def.signature.ast, signatureAst);
if (def.signature.file === file && !def.addByAPI) {
if (def.signature.scope === file && !def.addByAPI) {
s.overwriteNode(def.signature.ast, signature, { offset });

@@ -214,3 +223,3 @@ }

ast: valueAst,
file: void 0
scope: void 0
},

@@ -221,3 +230,3 @@ optional: !!optional,

ast: signatureAst,
file: void 0
scope: void 0
},

@@ -235,3 +244,3 @@ addByAPI: def.type === "property" && def.addByAPI

case "property": {
if (def.signature.file === file && !def.addByAPI) {
if (def.signature.scope === file && !def.addByAPI) {
s.removeNode(def.signature.ast, { offset });

@@ -243,3 +252,3 @@ }

def.methods.forEach((method) => {
if (method.file === file)
if (method.scope === file)
s.removeNode(method.ast, { offset });

@@ -266,3 +275,3 @@ });

type: await inferRuntimeType({
file: resolvedType.file || file,
scope: resolvedType.scope || file,
type: resolvedType.ast

@@ -312,10 +321,10 @@ }),

async function resolveDefinitions(typeDeclRaw2) {
const resolved = await _chunkRIALXEE4js.resolveTSReferencedType.call(void 0, typeDeclRaw2);
if (!resolved)
const resolved = await _chunk6EAABA32js.resolveTSReferencedType.call(void 0, typeDeclRaw2);
if (!resolved || _chunk6EAABA32js.isTSExports.call(void 0, resolved))
throw new SyntaxError(`Cannot resolve TS definition.`);
const { type: definitionsAst2, file: file2 } = resolved;
const { type: definitionsAst2, scope } = resolved;
if (definitionsAst2.type !== "TSInterfaceDeclaration" && definitionsAst2.type !== "TSTypeLiteral" && definitionsAst2.type !== "TSIntersectionType")
throw new SyntaxError(`Cannot resolve TS definition.`);
const properties = await _chunkRIALXEE4js.resolveTSProperties.call(void 0, {
file: file2,
const properties = await _chunk6EAABA32js.resolveTSProperties.call(void 0, {
scope,
type: definitionsAst2

@@ -331,7 +340,7 @@ });

for (const [key, value] of Object.entries(properties.properties)) {
const referenced = value.value ? await _chunkRIALXEE4js.resolveTSReferencedType.call(void 0, value.value) : void 0;
const referenced = value.value ? await _chunk6EAABA32js.resolveTSReferencedType.call(void 0, value.value) : void 0;
definitions2[key] = {
type: "property",
addByAPI: false,
value: referenced ? buildDefinition(referenced) : void 0,
value: referenced && !_chunk6EAABA32js.isTSExports.call(void 0, referenced) ? buildDefinition(referenced) : void 0,
optional: value.optional,

@@ -343,3 +352,3 @@ signature: buildDefinition(value.signature)

definitions: definitions2,
definitionsAst: buildDefinition({ file: file2, type: definitionsAst2 })
definitionsAst: buildDefinition({ scope, type: definitionsAst2 })
};

@@ -353,4 +362,3 @@ }

object: true,
objectMethod: true,
unary: true
objectMethod: true
});

@@ -373,8 +381,8 @@ if (!isStatic)

type,
file: file2
scope
}) {
return {
code: file2.content.slice(type.start, type.end),
code: _chunk6EAABA32js.resolveTSScope.call(void 0, scope).file.content.slice(type.start, type.end),
ast: type,
file: file2
scope
};

@@ -401,9 +409,14 @@ }

type: typeDeclRaw,
file
scope: file
});
const addEmit = (name, signature) => {
const key = _chunkNTLGGEMNjs.keyToString.call(void 0, name);
if (definitionsAst.file === file)
s.appendLeft(definitionsAst.ast.end + offset - 1, ` ${signature}
if (definitionsAst.scope === file) {
if (definitionsAst.ast.type === "TSIntersectionType") {
s.appendLeft(definitionsAst.ast.end + offset, ` & { ${signature} }`);
} else {
s.appendLeft(definitionsAst.ast.end + offset - 1, ` ${signature}
`);
}
}
if (!definitions[key])

@@ -415,3 +428,3 @@ definitions[key] = [];

ast,
file: void 0
scope: void 0
});

@@ -426,3 +439,3 @@ };

attachNodeLoc(def.ast, ast);
if (def.file === file)
if (def.scope === file)
s.overwriteNode(def.ast, signature, { offset });

@@ -432,3 +445,3 @@ definitions[key][idx] = {

ast,
file: void 0
scope: void 0
};

@@ -442,3 +455,3 @@ return true;

return false;
if (def.file === file)
if (def.scope === file)
s.removeNode(def.ast, { offset });

@@ -464,10 +477,10 @@ delete definitions[key][idx];

var _a;
const resolved = await _chunkRIALXEE4js.resolveTSReferencedType.call(void 0, typeDeclRaw2);
if (!resolved)
const resolved = await _chunk6EAABA32js.resolveTSReferencedType.call(void 0, typeDeclRaw2);
if (!resolved || _chunk6EAABA32js.isTSExports.call(void 0, resolved))
throw new SyntaxError(`Cannot resolve TS definition.`);
const { type: definitionsAst2, file: file2 } = resolved;
const { type: definitionsAst2, scope } = resolved;
if (definitionsAst2.type !== "TSInterfaceDeclaration" && definitionsAst2.type !== "TSTypeLiteral" && definitionsAst2.type !== "TSIntersectionType")
throw new SyntaxError(`Cannot resolve TS definition.`);
const properties = await _chunkRIALXEE4js.resolveTSProperties.call(void 0, {
file: file2,
const properties = await _chunk6EAABA32js.resolveTSProperties.call(void 0, {
scope,
type: definitionsAst2

@@ -480,7 +493,7 @@ });

continue;
const evtType = await _chunkRIALXEE4js.resolveTSReferencedType.call(void 0, {
const evtType = await _chunk6EAABA32js.resolveTSReferencedType.call(void 0, {
type: evtArg.typeAnnotation.typeAnnotation,
file: signature.file
scope: signature.scope
});
if ((evtType == null ? void 0 : evtType.type.type) !== "TSLiteralType")
if (_chunk6EAABA32js.isTSExports.call(void 0, evtType) || (evtType == null ? void 0 : evtType.type.type) !== "TSLiteralType")
continue;

@@ -499,3 +512,3 @@ const literal = evtType.type.literal;

definitions: definitions2,
definitionsAst: buildDefinition({ file: file2, type: definitionsAst2 })
definitionsAst: buildDefinition({ scope, type: definitionsAst2 })
};

@@ -505,8 +518,8 @@ }

type,
file: file2
scope
}) {
return {
code: file2.content.slice(type.start, type.end),
code: _chunk6EAABA32js.resolveTSScope.call(void 0, scope).file.content.slice(type.start, type.end),
ast: type,
file: file2
scope
};

@@ -674,2 +687,6 @@ }

exports.DefinitionKind = DefinitionKind; exports.MagicString = _common.MagicString; exports.analyzeSFC = analyzeSFC; exports.attachNodeLoc = attachNodeLoc; exports.getTSFile = _chunkRIALXEE4js.getTSFile; exports.handleTSEmitsDefinition = handleTSEmitsDefinition; exports.handleTSPropsDefinition = handleTSPropsDefinition; exports.inferRuntimeType = inferRuntimeType; exports.isTSDeclaration = _chunkRIALXEE4js.isTSDeclaration; exports.keyToString = _chunkNTLGGEMNjs.keyToString; exports.mergeTSProperties = _chunkRIALXEE4js.mergeTSProperties; exports.parseSFC = _common.parseSFC; exports.resolveTSFileExports = _chunkRIALXEE4js.resolveTSFileExports; exports.resolveTSFileId = _chunkRIALXEE4js.resolveTSFileId; exports.resolveTSFileIdNode = _chunkRIALXEE4js.resolveTSFileIdNode; exports.resolveTSProperties = _chunkRIALXEE4js.resolveTSProperties; exports.resolveTSReferencedType = _chunkRIALXEE4js.resolveTSReferencedType; exports.resolveTypeElements = _chunkRIALXEE4js.resolveTypeElements; exports.setResolveTSFileIdImpl = _chunkRIALXEE4js.setResolveTSFileIdImpl; exports.tsFileCache = _chunkRIALXEE4js.tsFileCache; exports.tsFileExportsCache = _chunkRIALXEE4js.tsFileExportsCache;
exports.DefinitionKind = DefinitionKind; exports.MagicString = _common.MagicString; exports.analyzeSFC = analyzeSFC; exports.attachNodeLoc = attachNodeLoc; exports.exportsSymbol = _chunk6EAABA32js.exportsSymbol; exports.getTSFile = _chunk6EAABA32js.getTSFile; exports.handleTSEmitsDefinition = handleTSEmitsDefinition; exports.handleTSPropsDefinition = handleTSPropsDefinition; exports.inferRuntimeType = inferRuntimeType; exports.isTSDeclaration = _chunk6EAABA32js.isTSDeclaration; exports.isTSExports = _chunk6EAABA32js.isTSExports; exports.keyToString = _chunkNTLGGEMNjs.keyToString; exports.mergeTSProperties = _chunk6EAABA32js.mergeTSProperties; exports.parseSFC = _common.parseSFC; exports.resolveTSEntityName = _chunk6EAABA32js.resolveTSEntityName; exports.resolveTSExports = _chunk6EAABA32js.resolveTSExports; exports.resolveTSFileId = _chunk6EAABA32js.resolveTSFileId; exports.resolveTSFileIdNode = _chunk6EAABA32js.resolveTSFileIdNode; exports.resolveTSProperties = _chunk6EAABA32js.resolveTSProperties; exports.resolveTSReferencedType = _chunk6EAABA32js.resolveTSReferencedType; exports.resolveTSScope = _chunk6EAABA32js.resolveTSScope; exports.resolveTypeElements = _chunk6EAABA32js.resolveTypeElements; exports.setResolveTSFileIdImpl = _chunk6EAABA32js.setResolveTSFileIdImpl; exports.tsFileCache = _chunk6EAABA32js.tsFileCache; exports.tsFileExportsCache = _chunk6EAABA32js.tsFileExportsCache;

@@ -1,2 +0,2 @@

import { TSDeclareFunction, TSInterfaceDeclaration, TSTypeAliasDeclaration, TSEnumDeclaration, TSModuleDeclaration, Statement, TSCallSignatureDeclaration, TSConstructSignatureDeclaration, TSMethodSignature, TSType, TSPropertySignature, TSInterfaceBody, TSTypeLiteral, TSIntersectionType, TSTypeElement, TSParenthesizedType, Identifier } from '@babel/types';
import { TSDeclareFunction, TSInterfaceDeclaration, TSTypeAliasDeclaration, TSEnumDeclaration, TSModuleDeclaration, Statement, TSModuleBlock, TSCallSignatureDeclaration, TSConstructSignatureDeclaration, TSMethodSignature, TSType, TSPropertySignature, TSInterfaceBody, TSTypeLiteral, TSIntersectionType, TSTypeElement, TSParenthesizedType, Identifier, TSEntityName } from '@babel/types';

@@ -9,25 +9,11 @@ declare type TSDeclaration = TSDeclareFunction | TSInterfaceDeclaration | TSTypeAliasDeclaration | TSEnumDeclaration | TSModuleDeclaration;

}
declare type TSScope = TSFile | TSResolvedType<TSModuleBlock>;
interface TSProperties {
callSignatures: Array<{
type: TSCallSignatureDeclaration;
file: TSFile;
}>;
constructSignatures: Array<{
type: TSConstructSignatureDeclaration;
file: TSFile;
}>;
methods: Record<string | number, Array<{
type: TSMethodSignature;
file: TSFile;
}>>;
callSignatures: Array<TSResolvedType<TSCallSignatureDeclaration>>;
constructSignatures: Array<TSResolvedType<TSConstructSignatureDeclaration>>;
methods: Record<string | number, Array<TSResolvedType<TSMethodSignature>>>;
properties: Record<string | number, {
value: {
type: TSType;
file: TSFile;
} | null;
value: TSResolvedType<TSType> | null;
optional: boolean;
signature: {
type: TSPropertySignature;
file: TSFile;
};
signature: TSResolvedType<TSPropertySignature>;
}>;

@@ -44,9 +30,9 @@ }

*/
declare function resolveTSProperties({ type, file, }: TSResolvedType<TSInterfaceDeclaration | TSInterfaceBody | TSTypeLiteral | TSIntersectionType>): Promise<TSProperties>;
declare function resolveTSProperties({ type, scope, }: TSResolvedType<TSInterfaceDeclaration | TSInterfaceBody | TSTypeLiteral | TSIntersectionType>): Promise<TSProperties>;
/**
* @limitation don't support index signature
*/
declare function resolveTypeElements(file: TSFile, elements: Array<TSTypeElement>): TSProperties;
declare function resolveTypeElements(scope: TSScope, elements: Array<TSTypeElement>): TSProperties;
interface TSResolvedType<T = Exclude<TSType, TSParenthesizedType> | Exclude<TSDeclaration, TSTypeAliasDeclaration>> {
file: TSFile;
scope: TSScope;
type: T;

@@ -61,5 +47,17 @@ }

*/
declare function resolveTSReferencedType({ file, type, }: TSResolvedType<TSType | Identifier | TSDeclaration>): Promise<TSResolvedType | undefined>;
declare type TSFileExports = Record<string, TSResolvedType | undefined>;
declare const tsFileExportsCache: Map<TSFile, TSFileExports>;
declare function resolveTSReferencedType(ref: TSResolvedType<TSType | Identifier | TSDeclaration>, stacks?: TSResolvedType<any>[]): Promise<TSResolvedType | TSExports | undefined>;
declare function resolveTSScope(scope: TSScope): {
isFile: boolean;
file: TSFile;
body: Statement[];
};
declare function resolveTSEntityName(node: TSEntityName): Identifier[];
declare const exportsSymbol: unique symbol;
declare type TSExports = {
[K in string]: TSResolvedType | TSExports | undefined;
} & {
[exportsSymbol]: true;
};
declare const tsFileExportsCache: Map<TSScope, TSExports>;
declare function isTSExports(val: unknown): val is TSExports;
/**

@@ -72,3 +70,3 @@ * Get exports of the TS file.

*/
declare function resolveTSFileExports(file: TSFile): Promise<TSFileExports>;
declare function resolveTSExports(scope: TSScope): Promise<TSExports>;
declare type ResolveTSFileIdImpl = (id: string, importer: string) => Promise<string | undefined> | string | undefined;

@@ -82,2 +80,2 @@ declare function resolveTSFileId(id: string, importer: string): string | Promise<string | undefined> | undefined;

export { ResolveTSFileIdImpl, TSDeclaration, TSFile, TSFileExports, TSProperties, TSResolvedType, getTSFile, isTSDeclaration, mergeTSProperties, resolveTSFileExports, resolveTSFileId, resolveTSFileIdNode, resolveTSProperties, resolveTSReferencedType, resolveTypeElements, setResolveTSFileIdImpl, tsFileCache, tsFileExportsCache };
export { ResolveTSFileIdImpl, TSDeclaration, TSExports, TSFile, TSProperties, TSResolvedType, TSScope, exportsSymbol, getTSFile, isTSDeclaration, isTSExports, mergeTSProperties, resolveTSEntityName, resolveTSExports, resolveTSFileId, resolveTSFileIdNode, resolveTSProperties, resolveTSReferencedType, resolveTSScope, resolveTypeElements, setResolveTSFileIdImpl, tsFileCache, tsFileExportsCache };

@@ -14,3 +14,2 @@ "use strict";Object.defineProperty(exports, "__esModule", {value: true});

var _chunkRIALXEE4js = require('./chunk-RIALXEE4.js');

@@ -20,2 +19,3 @@

var _chunk6EAABA32js = require('./chunk-6EAABA32.js');

@@ -30,3 +30,11 @@

exports.getTSFile = _chunkRIALXEE4js.getTSFile; exports.isTSDeclaration = _chunkRIALXEE4js.isTSDeclaration; exports.mergeTSProperties = _chunkRIALXEE4js.mergeTSProperties; exports.resolveTSFileExports = _chunkRIALXEE4js.resolveTSFileExports; exports.resolveTSFileId = _chunkRIALXEE4js.resolveTSFileId; exports.resolveTSFileIdNode = _chunkRIALXEE4js.resolveTSFileIdNode; exports.resolveTSProperties = _chunkRIALXEE4js.resolveTSProperties; exports.resolveTSReferencedType = _chunkRIALXEE4js.resolveTSReferencedType; exports.resolveTypeElements = _chunkRIALXEE4js.resolveTypeElements; exports.setResolveTSFileIdImpl = _chunkRIALXEE4js.setResolveTSFileIdImpl; exports.tsFileCache = _chunkRIALXEE4js.tsFileCache; exports.tsFileExportsCache = _chunkRIALXEE4js.tsFileExportsCache;
exports.exportsSymbol = _chunk6EAABA32js.exportsSymbol; exports.getTSFile = _chunk6EAABA32js.getTSFile; exports.isTSDeclaration = _chunk6EAABA32js.isTSDeclaration; exports.isTSExports = _chunk6EAABA32js.isTSExports; exports.mergeTSProperties = _chunk6EAABA32js.mergeTSProperties; exports.resolveTSEntityName = _chunk6EAABA32js.resolveTSEntityName; exports.resolveTSExports = _chunk6EAABA32js.resolveTSExports; exports.resolveTSFileId = _chunk6EAABA32js.resolveTSFileId; exports.resolveTSFileIdNode = _chunk6EAABA32js.resolveTSFileIdNode; exports.resolveTSProperties = _chunk6EAABA32js.resolveTSProperties; exports.resolveTSReferencedType = _chunk6EAABA32js.resolveTSReferencedType; exports.resolveTSScope = _chunk6EAABA32js.resolveTSScope; exports.resolveTypeElements = _chunk6EAABA32js.resolveTypeElements; exports.setResolveTSFileIdImpl = _chunk6EAABA32js.setResolveTSFileIdImpl; exports.tsFileCache = _chunk6EAABA32js.tsFileCache; exports.tsFileExportsCache = _chunk6EAABA32js.tsFileExportsCache;
exports.default = module.exports;
{
"name": "@vue-macros/api",
"version": "0.0.1",
"version": "0.1.0",
"packageManager": "pnpm@7.13.5",

@@ -30,3 +30,3 @@ "license": "MIT",

"@babel/types": "^7.19.4",
"@vue-macros/common": "~0.13.0"
"@vue-macros/common": "~0.13.1"
},

@@ -33,0 +33,0 @@ "devDependencies": {},

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc