@volar/vue-language-core
Advanced tools
Comparing version 1.0.0 to 1.0.1
@@ -476,3 +476,3 @@ Object.defineProperty(exports, "__esModule", { value: true }); | ||
var _a, _b; | ||
const varComponentInstance = `__VLS_${elementIndex++}`; | ||
let _varComponentInstance; | ||
let writedInstance = false; | ||
@@ -483,7 +483,14 @@ for (const prop of node.props) { | ||
&& ((_a = prop.arg) === null || _a === void 0 ? void 0 : _a.type) === 4 /* CompilerDOM.NodeTypes.SIMPLE_EXPRESSION */) { | ||
tryWriteInstance(); | ||
const varComponentInstance = tryWriteInstance(); | ||
const componentVar = componentVars[node.tag]; | ||
const varInstanceProps = `__VLS_${elementIndex++}`; | ||
const key_2 = (0, shared_1.camelize)('on-' + prop.arg.loc.source); // onClickOutside | ||
codeGen.push(`type ${varInstanceProps} = import('./__VLS_types.js').InstanceProps<typeof ${varComponentInstance}, ${componentVar ? 'typeof ' + componentVar : '{}'}>;\n`); | ||
codeGen.push(`type ${varInstanceProps} = `); | ||
if (!varComponentInstance) { | ||
codeGen.push(`JSX.IntrinsicElements['${node.tag}'];\n`); | ||
} | ||
else { | ||
codeGen.push(`import('./__VLS_types.js').InstanceProps<typeof ${varComponentInstance}, ${componentVar ? 'typeof ' + componentVar : '{}'}>;\n`); | ||
; | ||
} | ||
codeGen.push(`const __VLS_${elementIndex++}: import('./__VLS_types.js').EventObject<typeof ${varComponentInstance}, '${prop.arg.loc.source}', ${componentVar ? 'typeof ' + componentVar : '{}'}, `); | ||
@@ -503,15 +510,2 @@ codeGen.push(`${varInstanceProps}[`); | ||
} })); | ||
codeGen.push(`], import('./__VLS_types.js').GlobalAttrs[`); | ||
writeCodeWithQuotes(key_2, [prop.arg.loc.start.offset, prop.arg.loc.end.offset], Object.assign(Object.assign({}, capabilitiesSet.attrReference), { rename: { | ||
normalize(newName) { | ||
return (0, shared_1.camelize)('on-' + newName); | ||
}, | ||
apply(newName) { | ||
const hName = (0, shared_1.hyphenate)(newName); | ||
if ((0, shared_1.hyphenate)(newName).startsWith('on-')) { | ||
return (0, shared_1.camelize)(hName.slice('on-'.length)); | ||
} | ||
return newName; | ||
}, | ||
} })); | ||
codeGen.push(`]> = {\n`); | ||
@@ -578,7 +572,9 @@ { | ||
function tryWriteInstance() { | ||
if (writedInstance) | ||
return; | ||
if (writedInstance) { | ||
return _varComponentInstance; | ||
} | ||
const componentVar = componentVars[node.tag]; | ||
if (componentVar) { | ||
codeGen.push(`const ${varComponentInstance} = new ${componentVar}({ `); | ||
_varComponentInstance = `__VLS_${elementIndex++}`; | ||
codeGen.push(`const ${_varComponentInstance} = new ${componentVar}({ `); | ||
writeProps(node, 'class', 'slots'); | ||
@@ -588,2 +584,3 @@ codeGen.push(`});\n`); | ||
writedInstance = true; | ||
return _varComponentInstance; | ||
} | ||
@@ -1200,3 +1197,3 @@ } | ||
'template', | ||
typeof sourceRange === 'number' ? sourceRange : sourceRange[0], | ||
typeof sourceRange === 'number' ? sourceRange : sourceRange[1], | ||
data, | ||
@@ -1203,0 +1200,0 @@ ]); |
@@ -1,2 +0,1 @@ | ||
; | ||
const plugin = ({ modules, vueCompilerOptions }) => { | ||
@@ -18,4 +17,3 @@ return { | ||
const hitNode = hitNodes[0]; | ||
if (hitNode.type === 4 /* CompilerDOM.NodeTypes.SIMPLE_EXPRESSION */ | ||
|| hitNode.type === 'self-closing-tag-name') { | ||
if (hitNode.type === 4 /* CompilerDOM.NodeTypes.SIMPLE_EXPRESSION */) { | ||
return oldResult; | ||
@@ -37,31 +35,10 @@ } | ||
else if (node.type === 1 /* CompilerDOM.NodeTypes.ELEMENT */) { | ||
if (node.isSelfClosing) { | ||
const elementNameNode = { | ||
type: 'self-closing-tag-name', | ||
loc: { | ||
start: { offset: node.loc.start.offset + 1 }, | ||
end: { offset: node.loc.start.offset + 1 + node.tag.length }, | ||
source: node.tag, | ||
}, | ||
}; | ||
const oldTagType = getTagType(node.tag); | ||
if (!tryUpdateNode(elementNameNode)) { | ||
if (withinChangeRange(node.loc)) { | ||
// if not self closing, should not hit tag name | ||
const start = node.loc.start.offset + 2; | ||
const end = node.loc.start.offset + node.loc.source.lastIndexOf('</'); | ||
if (!withinChangeRange({ start: { offset: start }, end: { offset: end }, source: '' })) { | ||
return false; | ||
} | ||
node.tag = elementNameNode.loc.source; | ||
const newTagType = getTagType(node.tag); | ||
if (newTagType !== oldTagType) { | ||
return false; | ||
} | ||
} | ||
else { | ||
if (withinChangeRange(node.loc)) { | ||
// if not self closing, should not hit tag name | ||
const start = node.loc.start.offset + 2; | ||
const end = node.loc.start.offset + node.loc.source.lastIndexOf('</'); | ||
if (!withinChangeRange({ start: { offset: start }, end: { offset: end }, source: '' })) { | ||
return false; | ||
} | ||
} | ||
} | ||
for (const prop of node.props) { | ||
@@ -174,11 +151,3 @@ if (!tryUpdateNode(prop)) { | ||
}; | ||
function getTagType(tag) { | ||
if (tag === 'slot' || tag === 'template') { | ||
return tag; | ||
} | ||
else { | ||
return 'element'; | ||
} | ||
} | ||
module.exports = plugin; | ||
//# sourceMappingURL=vue-template-html.js.map |
@@ -112,6 +112,5 @@ Object.defineProperty(exports, "__esModule", { value: true }); | ||
${vueCompilerOptions.strictTemplates ? '' : 'Record<string, unknown> &'} | ||
GlobalAttrs & | ||
ExtractProps<T>; | ||
export type InstanceProps<I, C> = I extends { $props: infer Props } ? Props & Record<string, unknown> : C & Record<string, unknown>; | ||
export type EventObject<I, K1 extends string, C, E1, E2> = { | ||
export type EventObject<I, K1 extends string, C, E1> = { | ||
[K in K1]: import('./__VLS_types.js').FillingEventArg< | ||
@@ -122,3 +121,2 @@ import('./__VLS_types.js').FirstFunction< | ||
I extends { $emit: infer Emit } ? import('./__VLS_types.js').EmitEvent2<Emit, K1> : unknown, | ||
E2, | ||
> | ||
@@ -125,0 +123,0 @@ > |
{ | ||
"name": "@volar/vue-language-core", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"main": "out/index.js", | ||
@@ -16,4 +16,4 @@ "license": "MIT", | ||
"dependencies": { | ||
"@volar/language-core": "1.0.0", | ||
"@volar/source-map": "1.0.0", | ||
"@volar/language-core": "1.0.1", | ||
"@volar/source-map": "1.0.1", | ||
"@vue/compiler-dom": "^3.2.38", | ||
@@ -29,3 +29,3 @@ "@vue/compiler-sfc": "^3.2.38", | ||
}, | ||
"gitHead": "5496c1ecc0ae6207d6fa7da745f047c44c32db81" | ||
"gitHead": "62a5dce528c505fcadb609fb391ad7f3f8302fb2" | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
222475
4845
+ Added@volar/language-core@1.0.1(transitive)
+ Added@volar/source-map@1.0.1(transitive)
- Removed@volar/language-core@1.0.0(transitive)
- Removed@volar/source-map@1.0.0(transitive)
Updated@volar/language-core@1.0.1
Updated@volar/source-map@1.0.1