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

@volar/vue-language-core

Package Overview
Dependencies
Maintainers
1
Versions
112
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@volar/vue-language-core - npm Package Compare versions

Comparing version 1.5.0 to 1.5.1

2

out/generators/script.js

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

codes.push(`let __VLS_otherComponents!: typeof __VLS_localComponents & import('./__VLS_types').GlobalComponents;\n`);
codes.push(`let __VLS_own!: import('./__VLS_types').SelfComponent<typeof __VLS_name, typeof __VLS_internalComponent & typeof __VLS_publicComponent & (new () => { ${(0, shared_2.getSlotsPropertyName)(vueCompilerOptions.target ?? 3)}: typeof __VLS_slots })>;\n`);
codes.push(`let __VLS_own!: import('./__VLS_types').SelfComponent<typeof __VLS_name, typeof __VLS_internalComponent & typeof __VLS_publicComponent & (new () => { ${(0, shared_2.getSlotsPropertyName)(vueCompilerOptions.target)}: typeof __VLS_slots })>;\n`);
codes.push(`let __VLS_components!: typeof __VLS_otherComponents & Omit<typeof __VLS_own, keyof typeof __VLS_otherComponents>;\n`);

@@ -722,0 +722,0 @@ /* Style Scoped */

@@ -49,3 +49,2 @@ "use strict";

function generate(ts, vueCompilerOptions, sourceTemplate, sourceLang, templateAst, hasScriptSetupSlots, cssScopedClasses = []) {
const nativeTags = new Set(vueCompilerOptions.nativeTags);
const codes = [];

@@ -124,15 +123,9 @@ const formatCodes = [];

for (const tagName in tagNames) {
if (nativeTags.has(tagName))
continue;
const isNamespacedTag = tagName.indexOf('.') >= 0;
if (isNamespacedTag)
continue;
const names = new Set([
// order is important: https://github.com/johnsoncodehk/volar/issues/2010
(0, shared_1.capitalize)((0, shared_1.camelize)(tagName)),
(0, shared_1.camelize)(tagName),
tagName,
]);
const varName = validTsVar.test(tagName) ? tagName : (0, shared_1.capitalize)((0, shared_1.camelize)(tagName.replace(/:/g, '-')));
codes.push('& import("./__VLS_types").WithComponent<"', varName, '", typeof __VLS_components, ', [...names].map(name => `'${name}'`).join(', '), '>\n');
codes.push('& import("./__VLS_types").WithComponent<typeof __VLS_components, ',
// order is important: https://github.com/johnsoncodehk/volar/issues/2010
`"${(0, shared_1.capitalize)((0, shared_1.camelize)(tagName))}", `, `"${(0, shared_1.camelize)(tagName)}", `, `"${tagName}"`, '>\n');
data[tagName] = varName;

@@ -155,3 +148,3 @@ }

for (const tagRange of tagRanges) {
codes.push('__VLS_components', ...createPropertyAccessCode([
codes.push(name === tagName ? '__VLS_templateComponents' : '__VLS_components', ...createPropertyAccessCode([
name,

@@ -348,15 +341,6 @@ 'template',

const tagOffsets = endTagOffset !== undefined ? [startTagOffset, endTagOffset] : [startTagOffset];
const isIntrinsicElement = nativeTags.has(node.tag);
const isNamespacedTag = node.tag.indexOf('.') >= 0;
const componentVar = `__VLS_${elementIndex++}`;
const componentInstanceVar = `__VLS_${elementIndex++}`;
if (isIntrinsicElement) {
codes.push('const ', componentVar, ` = (await import('./__VLS_types')).asFunctionalComponent(({} as import('./__VLS_types').IntrinsicElements)[`, ...createStringLiteralKeyCode([
node.tag,
'template',
tagOffsets[0],
capabilitiesPresets.diagnosticOnly,
]), ']);\n');
}
else if (isNamespacedTag) {
if (isNamespacedTag) {
codes.push(`const ${componentVar} = (await import('./__VLS_types')).asFunctionalComponent(${node.tag}, new ${node.tag}({`, ...createPropsCode(node, 'slots'), '}));\n');

@@ -368,14 +352,3 @@ }

for (const offset of tagOffsets) {
if (isIntrinsicElement) {
codes.push(`({} as import('./__VLS_types').IntrinsicElements)`, ...createPropertyAccessCode([
node.tag,
'template',
offset,
{
...capabilitiesPresets.tagReference,
...capabilitiesPresets.tagHover,
},
]), ';\n');
}
else if (isNamespacedTag) {
if (isNamespacedTag) {
codes.push([node.tag, 'template', [offset, offset + node.tag.length], capabilitiesPresets.all], ';\n');

@@ -400,3 +373,3 @@ }

'{ ', ...createPropsCode(node, 'props', propsFailedExps), '}', ['', 'template', startTagOffset + node.tag.length, capabilitiesPresets.diagnosticOnly], // diagnostic end
', {} as any);\n');
`, ...(await import('./__VLS_types')).functionalComponentArgsRest(${componentVar}));\n`);
if (node.tag !== 'template') {

@@ -916,3 +889,3 @@ componentCtxVar = `__VLS_${elementIndex++}`;

identifiers.add((0, shared_1.camelize)('v-' + prop.name));
if (prop.arg?.type === 4 /* CompilerDOM.NodeTypes.SIMPLE_EXPRESSION */) {
if (prop.arg?.type === 4 /* CompilerDOM.NodeTypes.SIMPLE_EXPRESSION */ && !prop.arg.isStatic) {
codes.push(...createInterpolationCode(prop.arg.content, prop.arg.loc, prop.arg.loc.start.offset + prop.arg.loc.source.indexOf(prop.arg.content), capabilitiesPresets.all, '(', ')'), ';\n');

@@ -919,0 +892,0 @@ formatCodes.push(...createFormatCode(prop.arg.content, prop.arg.loc.start.offset, formatBrackets.normal));

@@ -19,3 +19,2 @@ import * as embedded from '@volar/language-core';

skipTemplateCodegen: boolean;
nativeTags: string[];
dataAttributes: string[];

@@ -22,0 +21,0 @@ htmlAttributes: string[];

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

const shared_1 = require("./shared");
const shared_2 = require("./shared");
exports.typesFileName = '__VLS_types.d.ts';
function getTypesCode(vueVersion, vueCompilerOptions) {
const libName = (0, shared_1.getVueLibraryName)(vueVersion);
const libName = (0, shared_2.getVueLibraryName)(vueVersion);
return `

@@ -15,6 +16,5 @@ // @ts-nocheck

} from '${libName}';
${vueCompilerOptions.target >= 3.3 ? `import { JSX } from 'vue/jsx-runtime';` : ''}
export type IntrinsicElements = JSX.IntrinsicElements;
export type Element = JSX.Element;
export type IntrinsicElements = PickNotAny<import('vue/jsx-runtime').JSX, PickNotAny<JSX.IntrinsicElements, Record<string, any>>>;
export type Element = PickNotAny<import('vue/jsx-runtime').JSX, JSX.Element>;

@@ -60,7 +60,9 @@ type IsAny<T> = boolean extends (T extends never ? true : false) ? true : false;

export type SelfComponent<N, C> = string extends N ? {} : N extends string ? { [P in N]: C } : {};
export type WithComponent<N0 extends string, Components, N1, N2 = unknown, N3 = unknown> =
N1 extends keyof Components ? { [K in N0]: Components[N1] } :
N2 extends keyof Components ? { [K in N0]: Components[N2] } :
N3 extends keyof Components ? { [K in N0]: Components[N3] } :
${vueCompilerOptions.strictTemplates ? '{}' : '{ [K in N0]: any }'};
export type WithComponent<Components, N1 extends string, N2 extends string, N0 extends string> =
IsAny<IntrinsicElements[N0]> extends true ? (
N1 extends keyof Components ? N1 extends N0 ? Pick<Components, N0> : { [K in N0]: Components[N1] } :
N2 extends keyof Components ? N2 extends N0 ? Pick<Components, N0> : { [K in N0]: Components[N2] } :
N0 extends keyof Components ? Pick<Components, N0> :
${vueCompilerOptions.strictTemplates ? '{}' : '{ [K in N0]: any }'}
) : Pick<IntrinsicElements, N0>;

@@ -90,9 +92,13 @@ export type FillingEventArg_ParametersLength<E extends (...args: any) => any> = IsAny<Parameters<E>> extends true ? -1 : Parameters<E>['length'];

export declare function asFunctionalComponent<T, K = T extends new (...args: any) => any ? InstanceType<T> : unknown>(t: T, instance?: K):
T extends new (...args: any) => any ?
K extends { $props?: infer Props, $slots?: infer Slots, $emit?: infer Emit }
? (props: Props ${vueCompilerOptions.strictTemplates ? '' : '& Record<string, unknown>'}, ctx?: { attrs?: any, expose?(exposed: K): void, slots?: Slots, emit?: Emit }) => JSX.Element & { __ctx?: typeof ctx, __props?: typeof props }
: never
T extends new (...args: any) => any
? (props: (K extends { $props: infer Props } ? Props : any)${vueCompilerOptions.strictTemplates ? '' : ' & Record<string, unknown>'}, ctx?: {
attrs?: any,
expose?(exposed: K): void,
slots?: K extends { ${(0, shared_1.getSlotsPropertyName)(vueCompilerOptions.target)}: infer Slots } ? Slots : any,
emit?: K extends { $emit: infer Emit } ? Emit : any
}) => JSX.Element & { __ctx?: typeof ctx, __props?: typeof props }
: T extends () => any ? (props: {}, ctx?: any) => ReturnType<T>
: T extends (...args: any) => any ? T
: (_: T & Record<string, unknown>, ctx?: any) => { __ctx?: { attrs?: unknown, expose?: unknown, slots?: unknown, emit?: unknown }, __props?: T & Record<string, unknown> }; // IntrinsicElement
declare function functionalComponentArgsRest<T extends (...args: any) => any>(t: T): Parameters<T>['length'] extends 2 ? [any] : [];
export declare function pickEvent<Emit, K, E>(emit: Emit, emitKey: K, event: E): FillingEventArg<

@@ -99,0 +105,0 @@ PickNotAny<

@@ -143,23 +143,2 @@ "use strict";

}
// https://developer.mozilla.org/en-US/docs/Web/HTML/Element
const HTML_TAGS = 'html,body,base,head,link,meta,style,title,address,article,aside,footer,' +
'header,hgroup,h1,h2,h3,h4,h5,h6,nav,section,div,dd,dl,dt,figcaption,' +
'figure,picture,hr,img,li,main,ol,p,pre,ul,a,b,abbr,bdi,bdo,br,cite,code,' +
'data,dfn,em,i,kbd,mark,q,rp,rt,ruby,s,samp,small,span,strong,sub,sup,' +
'time,u,var,wbr,area,audio,map,track,video,embed,object,param,source,' +
'canvas,script,noscript,del,ins,caption,col,colgroup,table,thead,tbody,td,' +
'th,tr,button,datalist,fieldset,form,input,label,legend,meter,optgroup,' +
'option,output,progress,select,textarea,details,dialog,menu,' +
'summary,template,blockquote,iframe,tfoot';
// https://developer.mozilla.org/en-US/docs/Web/SVG/Element
const SVG_TAGS = 'svg,animate,animateMotion,animateTransform,circle,clipPath,color-profile,' +
'defs,desc,discard,ellipse,feBlend,feColorMatrix,feComponentTransfer,' +
'feComposite,feConvolveMatrix,feDiffuseLighting,feDisplacementMap,' +
'feDistanceLight,feDropShadow,feFlood,feFuncA,feFuncB,feFuncG,feFuncR,' +
'feGaussianBlur,feImage,feMerge,feMergeNode,feMorphology,feOffset,' +
'fePointLight,feSpecularLighting,feSpotLight,feTile,feTurbulence,filter,' +
'foreignObject,g,hatch,hatchpath,image,line,linearGradient,marker,mask,' +
'mesh,meshgradient,meshpatch,meshrow,metadata,mpath,path,pattern,' +
'polygon,polyline,radialGradient,rect,set,solidcolor,stop,switch,symbol,' +
'text,textPath,title,tspan,unknown,use,view';
function resolveVueCompilerOptions(vueOptions) {

@@ -173,10 +152,2 @@ const target = vueOptions.target ?? 3.3;

skipTemplateCodegen: vueOptions.skipTemplateCodegen ?? false,
nativeTags: vueOptions.nativeTags ?? [...new Set([
...HTML_TAGS.split(','),
...SVG_TAGS.split(','),
// fix https://github.com/johnsoncodehk/volar/issues/1340
'hgroup',
'slot',
'component',
])],
dataAttributes: vueOptions.dataAttributes ?? [],

@@ -183,0 +154,0 @@ htmlAttributes: vueOptions.htmlAttributes ?? ['aria-*'],

{
"name": "@volar/vue-language-core",
"version": "1.5.0",
"version": "1.5.1",
"main": "out/index.js",

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

},
"gitHead": "4e2ea5bb680127968bb82a6622ea335372e0e786"
"gitHead": "e4f83fc66b4761cb3949066b11e41baf1c978e3d"
}
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