@vue/language-core
Advanced tools
| // @ts-check | ||
| const { readFile, writeFile } = require('node:fs/promises'); | ||
| const { join } = require('node:path'); | ||
| generateNames(); | ||
| async function generateNames() { | ||
| const typePath = join(__dirname, '../types/template-helpers.d.ts'); | ||
| const typeText = await readFile(typePath, 'utf-8'); | ||
| /** @type {Set<string>} */ | ||
| const pascalNames = new Set(); | ||
| /** @type {Set<string>} */ | ||
| const camelNames = new Set(); | ||
| const declReg = /(?<=const\s+)\w*?(?=:)|(?<=type\s+)\w*?(?=\s*=|<)|(?<=function\s+)\w*?(?=\(|<)/g; | ||
| const prefix = '__VLS_'; | ||
| for (const match of typeText.matchAll(declReg)) { | ||
| const name = match[0].slice(prefix.length); | ||
| if (name[0]?.toUpperCase() === name[0]) { | ||
| pascalNames.add(name); | ||
| } | ||
| else { | ||
| camelNames.add(name); | ||
| } | ||
| } | ||
| const namesPath = join(__dirname, '../lib/codegen/names.ts'); | ||
| const namesText = await readFile(namesPath, 'utf-8'); | ||
| await writeFile( | ||
| namesPath, | ||
| namesText.replace( | ||
| /(?<=\/\/ #region .*\n).*?(?=\t\/\/ #endregion)/ms, | ||
| [...camelNames].sort().map(name => `\t${name}: '',\n`).join('') | ||
| + '\n' | ||
| + [...pascalNames].sort().map(name => `\t${name}: '',\n`).join(''), | ||
| ), | ||
| ); | ||
| } |
+1
-1
@@ -13,4 +13,4 @@ export * from './lib/codegen/template'; | ||
| export * from './lib/virtualCode'; | ||
| export * as names from './lib/codegen/names'; | ||
| export { names } from './lib/codegen/names'; | ||
| export { tsCodegen } from './lib/plugins/vue-tsx'; | ||
| export * from '@volar/language-core'; |
+2
-23
@@ -13,27 +13,5 @@ "use strict"; | ||
| })); | ||
| var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { | ||
| Object.defineProperty(o, "default", { enumerable: true, value: v }); | ||
| }) : function(o, v) { | ||
| o["default"] = v; | ||
| }); | ||
| var __exportStar = (this && this.__exportStar) || function(m, exports) { | ||
| for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); | ||
| }; | ||
| var __importStar = (this && this.__importStar) || (function () { | ||
| var ownKeys = function(o) { | ||
| ownKeys = Object.getOwnPropertyNames || function (o) { | ||
| var ar = []; | ||
| for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k; | ||
| return ar; | ||
| }; | ||
| return ownKeys(o); | ||
| }; | ||
| return function (mod) { | ||
| if (mod && mod.__esModule) return mod; | ||
| var result = {}; | ||
| if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]); | ||
| __setModuleDefault(result, mod); | ||
| return result; | ||
| }; | ||
| })(); | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -53,3 +31,4 @@ exports.tsCodegen = exports.names = void 0; | ||
| __exportStar(require("./lib/virtualCode"), exports); | ||
| exports.names = __importStar(require("./lib/codegen/names")); | ||
| var names_1 = require("./lib/codegen/names"); | ||
| Object.defineProperty(exports, "names", { enumerable: true, get: function () { return names_1.names; } }); | ||
| var vue_tsx_1 = require("./lib/plugins/vue-tsx"); | ||
@@ -56,0 +35,0 @@ Object.defineProperty(exports, "tsCodegen", { enumerable: true, get: function () { return vue_tsx_1.tsCodegen; } }); |
+73
-26
@@ -1,26 +0,73 @@ | ||
| export declare const ctx = "__VLS_ctx"; | ||
| export declare const dollars = "__VLS_dollars"; | ||
| export declare const slots = "__VLS_slots"; | ||
| export declare const props = "__VLS_props"; | ||
| export declare const defaults = "__VLS_defaults"; | ||
| export declare const defaultModels = "__VLS_defaultModels"; | ||
| export declare const modelEmit = "__VLS_modelEmit"; | ||
| export declare const emit = "__VLS_emit"; | ||
| export declare const exposed = "__VLS_exposed"; | ||
| export declare const setup = "__VLS_setup"; | ||
| export declare const components = "__VLS_components"; | ||
| export declare const directives = "__VLS_directives"; | ||
| export declare const intrinsics = "__VLS_intrinsics"; | ||
| export declare const _export = "__VLS_export"; | ||
| export declare const ModelProps = "__VLS_ModelProps"; | ||
| export declare const Props = "__VLS_Props"; | ||
| export declare const Slots = "__VLS_Slots"; | ||
| export declare const InheritedAttrs = "__VLS_InheritedAttrs"; | ||
| export declare const TemplateRefs = "__VLS_TemplateRefs"; | ||
| export declare const RootEl = "__VLS_RootEl"; | ||
| export declare const ModelEmit = "__VLS_ModelEmit"; | ||
| export declare const EmitProps = "__VLS_EmitProps"; | ||
| export declare const Emit = "__VLS_Emit"; | ||
| export declare const SetupExposed = "__VLS_SetupExposed"; | ||
| export declare const PublicProps = "__VLS_PublicProps"; | ||
| export declare const StyleModules = "__VLS_StyleModules"; | ||
| declare const raw: { | ||
| base: string; | ||
| export: string; | ||
| components: string; | ||
| componentsOption: string; | ||
| ctx: string; | ||
| defaultModels: string; | ||
| defaults: string; | ||
| directives: string; | ||
| directivesOption: string; | ||
| dollars: string; | ||
| emit: string; | ||
| exposed: string; | ||
| intrinsics: string; | ||
| modelEmit: string; | ||
| props: string; | ||
| propsOption: string; | ||
| self: string; | ||
| setup: string; | ||
| slots: string; | ||
| src: string; | ||
| Emit: string; | ||
| EmitProps: string; | ||
| GlobalComponents: string; | ||
| InheritedAttrs: string; | ||
| LocalComponents: string; | ||
| LocalDirectives: string; | ||
| ModelEmit: string; | ||
| ModelProps: string; | ||
| Props: string; | ||
| PublicProps: string; | ||
| RootEl: string; | ||
| SetupExposed: string; | ||
| Slots: string; | ||
| StyleModules: string; | ||
| StyleScopedClasses: string; | ||
| TemplateRefs: string; | ||
| asFunctionalComponent0: string; | ||
| asFunctionalComponent1: string; | ||
| asFunctionalDirective: string; | ||
| asFunctionalElement0: string; | ||
| asFunctionalElement1: string; | ||
| asFunctionalSlot: string; | ||
| directiveBindingRestFields: string; | ||
| functionalComponentArgsRest: string; | ||
| tryAsConstant: string; | ||
| vFor: string; | ||
| vSlot: string; | ||
| ConstructorOverloads: string; | ||
| Elements: string; | ||
| EmitsToProps: string; | ||
| FunctionalComponent0: string; | ||
| FunctionalComponent1: string; | ||
| FunctionalComponentCtx: string; | ||
| FunctionalComponentProps: string; | ||
| IsAny: string; | ||
| IsFunction: string; | ||
| NormalizeComponentEvent: string; | ||
| NormalizeEmits: string; | ||
| OverloadUnion: string; | ||
| OverloadUnionInner: string; | ||
| PickNotAny: string; | ||
| PrettifyGlobal: string; | ||
| ResolveDirectives: string; | ||
| ResolveEmits: string; | ||
| ShortEmits: string; | ||
| ShortEmitsToObject: string; | ||
| SpreadMerge: string; | ||
| UnionToIntersection: string; | ||
| WithComponent: string; | ||
| }; | ||
| export declare const names: typeof raw; | ||
| export {}; |
+75
-27
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.StyleModules = exports.PublicProps = exports.SetupExposed = exports.Emit = exports.EmitProps = exports.ModelEmit = exports.RootEl = exports.TemplateRefs = exports.InheritedAttrs = exports.Slots = exports.Props = exports.ModelProps = exports._export = exports.intrinsics = exports.directives = exports.components = exports.setup = exports.exposed = exports.emit = exports.modelEmit = exports.defaultModels = exports.defaults = exports.props = exports.slots = exports.dollars = exports.ctx = void 0; | ||
| exports.ctx = '__VLS_ctx'; | ||
| exports.dollars = '__VLS_dollars'; | ||
| exports.slots = '__VLS_slots'; | ||
| exports.props = '__VLS_props'; | ||
| exports.defaults = '__VLS_defaults'; | ||
| exports.defaultModels = '__VLS_defaultModels'; | ||
| exports.modelEmit = '__VLS_modelEmit'; | ||
| exports.emit = '__VLS_emit'; | ||
| exports.exposed = '__VLS_exposed'; | ||
| exports.setup = '__VLS_setup'; | ||
| exports.components = '__VLS_components'; | ||
| exports.directives = '__VLS_directives'; | ||
| exports.intrinsics = '__VLS_intrinsics'; | ||
| exports._export = '__VLS_export'; | ||
| exports.ModelProps = '__VLS_ModelProps'; | ||
| exports.Props = '__VLS_Props'; | ||
| exports.Slots = '__VLS_Slots'; | ||
| exports.InheritedAttrs = '__VLS_InheritedAttrs'; | ||
| exports.TemplateRefs = '__VLS_TemplateRefs'; | ||
| exports.RootEl = '__VLS_RootEl'; | ||
| exports.ModelEmit = '__VLS_ModelEmit'; | ||
| exports.EmitProps = '__VLS_EmitProps'; | ||
| exports.Emit = '__VLS_Emit'; | ||
| exports.SetupExposed = '__VLS_SetupExposed'; | ||
| exports.PublicProps = '__VLS_PublicProps'; | ||
| exports.StyleModules = '__VLS_StyleModules'; | ||
| exports.names = void 0; | ||
| const raw = { | ||
| base: '', | ||
| export: '', | ||
| components: '', | ||
| componentsOption: '', | ||
| ctx: '', | ||
| defaultModels: '', | ||
| defaults: '', | ||
| directives: '', | ||
| directivesOption: '', | ||
| dollars: '', | ||
| emit: '', | ||
| exposed: '', | ||
| intrinsics: '', | ||
| modelEmit: '', | ||
| props: '', | ||
| propsOption: '', | ||
| self: '', | ||
| setup: '', | ||
| slots: '', | ||
| src: '', | ||
| Emit: '', | ||
| EmitProps: '', | ||
| GlobalComponents: '', | ||
| InheritedAttrs: '', | ||
| LocalComponents: '', | ||
| LocalDirectives: '', | ||
| ModelEmit: '', | ||
| ModelProps: '', | ||
| Props: '', | ||
| PublicProps: '', | ||
| RootEl: '', | ||
| SetupExposed: '', | ||
| Slots: '', | ||
| StyleModules: '', | ||
| StyleScopedClasses: '', | ||
| TemplateRefs: '', | ||
| // #region template helpers | ||
| asFunctionalComponent0: '', | ||
| asFunctionalComponent1: '', | ||
| asFunctionalDirective: '', | ||
| asFunctionalElement0: '', | ||
| asFunctionalElement1: '', | ||
| asFunctionalSlot: '', | ||
| directiveBindingRestFields: '', | ||
| functionalComponentArgsRest: '', | ||
| tryAsConstant: '', | ||
| vFor: '', | ||
| vSlot: '', | ||
| ConstructorOverloads: '', | ||
| Elements: '', | ||
| EmitsToProps: '', | ||
| FunctionalComponent0: '', | ||
| FunctionalComponent1: '', | ||
| FunctionalComponentCtx: '', | ||
| FunctionalComponentProps: '', | ||
| IsAny: '', | ||
| IsFunction: '', | ||
| NormalizeComponentEvent: '', | ||
| NormalizeEmits: '', | ||
| OverloadUnion: '', | ||
| OverloadUnionInner: '', | ||
| PickNotAny: '', | ||
| PrettifyGlobal: '', | ||
| ResolveDirectives: '', | ||
| ResolveEmits: '', | ||
| ShortEmits: '', | ||
| ShortEmitsToObject: '', | ||
| SpreadMerge: '', | ||
| UnionToIntersection: '', | ||
| WithComponent: '', | ||
| // #endregion | ||
| }; | ||
| exports.names = Object.fromEntries(Object.keys(raw).map(key => [key, `__VLS_${key}`])); | ||
| //# sourceMappingURL=names.js.map |
| "use strict"; | ||
| var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
| if (k2 === undefined) k2 = k; | ||
| var desc = Object.getOwnPropertyDescriptor(m, k); | ||
| if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { | ||
| desc = { enumerable: true, get: function() { return m[k]; } }; | ||
| } | ||
| Object.defineProperty(o, k2, desc); | ||
| }) : (function(o, m, k, k2) { | ||
| if (k2 === undefined) k2 = k; | ||
| o[k2] = m[k]; | ||
| })); | ||
| var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { | ||
| Object.defineProperty(o, "default", { enumerable: true, value: v }); | ||
| }) : function(o, v) { | ||
| o["default"] = v; | ||
| }); | ||
| var __importStar = (this && this.__importStar) || (function () { | ||
| var ownKeys = function(o) { | ||
| ownKeys = Object.getOwnPropertyNames || function (o) { | ||
| var ar = []; | ||
| for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k; | ||
| return ar; | ||
| }; | ||
| return ownKeys(o); | ||
| }; | ||
| return function (mod) { | ||
| if (mod && mod.__esModule) return mod; | ||
| var result = {}; | ||
| if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]); | ||
| __setModuleDefault(result, mod); | ||
| return result; | ||
| }; | ||
| })(); | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.generateComponent = generateComponent; | ||
| const codeFeatures_1 = require("../codeFeatures"); | ||
| const names = __importStar(require("../names")); | ||
| const names_1 = require("../names"); | ||
| const utils_1 = require("../utils"); | ||
@@ -43,11 +10,5 @@ const merge_1 = require("../utils/merge"); | ||
| yield `(await import('${options.vueCompilerOptions.lib}')).defineComponent({${utils_1.newLine}`; | ||
| const returns = []; | ||
| if (scriptSetupRanges.defineExpose) { | ||
| returns.push([names.exposed]); | ||
| yield `setup: () => ${names_1.names.exposed},${utils_1.newLine}`; | ||
| } | ||
| if (returns.length) { | ||
| yield `setup: () => (`; | ||
| yield* (0, merge_1.generateSpreadMerge)(returns); | ||
| yield `),${utils_1.newLine}`; | ||
| } | ||
| const emitOptionCodes = [...generateEmitsOption(options, scriptSetupRanges)]; | ||
@@ -58,9 +19,9 @@ yield* emitOptionCodes; | ||
| && options.vueCompilerOptions.inferComponentDollarRefs | ||
| && options.templateAndStyleTypes.has(names.TemplateRefs)) { | ||
| yield `__typeRefs: {} as ${names.TemplateRefs},${utils_1.newLine}`; | ||
| && options.templateAndStyleTypes.has(names_1.names.TemplateRefs)) { | ||
| yield `__typeRefs: {} as ${names_1.names.TemplateRefs},${utils_1.newLine}`; | ||
| } | ||
| if (options.vueCompilerOptions.target >= 3.5 | ||
| && options.vueCompilerOptions.inferComponentDollarEl | ||
| && options.templateAndStyleTypes.has(names.RootEl)) { | ||
| yield `__typeEl: {} as ${names.RootEl},${utils_1.newLine}`; | ||
| && options.templateAndStyleTypes.has(names_1.names.RootEl)) { | ||
| yield `__typeEl: {} as ${names_1.names.RootEl},${utils_1.newLine}`; | ||
| } | ||
@@ -73,10 +34,10 @@ yield `})`; | ||
| if (scriptSetupRanges.defineModel.length) { | ||
| optionCodes.push([`{} as __VLS_NormalizeEmits<typeof ${names.modelEmit}>`]); | ||
| typeOptionCodes.push([names.ModelEmit]); | ||
| optionCodes.push([`{} as ${names_1.names.NormalizeEmits}<typeof ${names_1.names.modelEmit}>`]); | ||
| typeOptionCodes.push([names_1.names.ModelEmit]); | ||
| } | ||
| if (scriptSetupRanges.defineEmits) { | ||
| const { name, typeArg, hasUnionTypeArg } = scriptSetupRanges.defineEmits; | ||
| optionCodes.push([`{} as __VLS_NormalizeEmits<typeof ${name ?? names.emit}>`]); | ||
| optionCodes.push([`{} as ${names_1.names.NormalizeEmits}<typeof ${name ?? names_1.names.emit}>`]); | ||
| if (typeArg && !hasUnionTypeArg) { | ||
| typeOptionCodes.push([names.Emit]); | ||
| typeOptionCodes.push([names_1.names.Emit]); | ||
| } | ||
@@ -101,8 +62,8 @@ else { | ||
| const typeOptionGenerates = []; | ||
| if (options.templateAndStyleTypes.has(names.InheritedAttrs)) { | ||
| if (options.templateAndStyleTypes.has(names_1.names.InheritedAttrs)) { | ||
| const attrsType = hasEmitsOption | ||
| ? `Omit<${names.InheritedAttrs}, keyof ${names.EmitProps}>` | ||
| : names.InheritedAttrs; | ||
| ? `Omit<${names_1.names.InheritedAttrs}, keyof ${names_1.names.EmitProps}>` | ||
| : names_1.names.InheritedAttrs; | ||
| optionGenerates.push(function* () { | ||
| const propsType = `__VLS_PickNotAny<${ctx.localTypes.OmitIndexSignature}<${attrsType}>, {}>`; | ||
| const propsType = `${names_1.names.PickNotAny}<${ctx.localTypes.OmitIndexSignature}<${attrsType}>, {}>`; | ||
| const optionType = `${ctx.localTypes.TypePropsToOption}<${propsType}>`; | ||
@@ -115,8 +76,8 @@ yield `{} as ${optionType}`; | ||
| } | ||
| if (ctx.generatedTypes.has(names.PublicProps)) { | ||
| if (ctx.generatedTypes.has(names_1.names.PublicProps)) { | ||
| if (options.vueCompilerOptions.target < 3.6) { | ||
| optionGenerates.push(function* () { | ||
| let propsType = `${ctx.localTypes.TypePropsToOption}<${names.PublicProps}>`; | ||
| let propsType = `${ctx.localTypes.TypePropsToOption}<${names_1.names.PublicProps}>`; | ||
| if (scriptSetupRanges.withDefaults?.arg) { | ||
| propsType = `${ctx.localTypes.WithDefaults}<${propsType}, typeof ${names.defaults}>`; | ||
| propsType = `${ctx.localTypes.WithDefaults}<${propsType}, typeof ${names_1.names.defaults}>`; | ||
| } | ||
@@ -127,3 +88,3 @@ yield `{} as ${propsType}`; | ||
| typeOptionGenerates.push(function* () { | ||
| yield `{} as ${names.PublicProps}`; | ||
| yield `{} as ${names_1.names.PublicProps}`; | ||
| }); | ||
@@ -141,3 +102,3 @@ } | ||
| && scriptSetupRanges.withDefaults?.arg) { | ||
| yield `__defaults: ${names.defaults},${utils_1.newLine}`; | ||
| yield `__defaults: ${names_1.names.defaults},${utils_1.newLine}`; | ||
| } | ||
@@ -144,0 +105,0 @@ yield `__typeProps: `; |
@@ -39,3 +39,3 @@ "use strict"; | ||
| const codeFeatures_1 = require("../codeFeatures"); | ||
| const names = __importStar(require("../names")); | ||
| const names_1 = require("../names"); | ||
| const utils_1 = require("../utils"); | ||
@@ -46,3 +46,3 @@ const boundary_1 = require("../utils/boundary"); | ||
| const template_1 = require("./template"); | ||
| const exportExpression = `{} as typeof ${names._export}`; | ||
| const exportExpression = `{} as typeof ${names_1.names.export}`; | ||
| function generate(options) { | ||
@@ -65,3 +65,3 @@ const ctx = (0, context_1.createScriptCodegenContext)(options); | ||
| } | ||
| yield `import __VLS_default from `; | ||
| yield `import ${names_1.names.src} from `; | ||
| const token = yield* (0, boundary_1.startBoundary)('main', script.src.offset, { | ||
@@ -77,4 +77,4 @@ ...codeFeatures_1.codeFeatures.all, | ||
| yield utils_1.endOfLine; | ||
| yield `export default __VLS_default;${utils_1.endOfLine}`; | ||
| yield* (0, template_1.generateTemplate)(options, ctx, '__VLS_default'); | ||
| yield `export default ${names_1.names.src}${utils_1.endOfLine}`; | ||
| yield* (0, template_1.generateTemplate)(options, ctx, names_1.names.src); | ||
| } | ||
@@ -88,3 +88,3 @@ // <script> + <script setup> | ||
| if (exportDefault) { | ||
| yield* generateScriptWithExportDefault(ctx, script, scriptRanges, exportDefault, vueCompilerOptions, selfType = '__VLS_self'); | ||
| yield* generateScriptWithExportDefault(ctx, script, scriptRanges, exportDefault, vueCompilerOptions, selfType = names_1.names.self); | ||
| } | ||
@@ -96,3 +96,3 @@ else { | ||
| // <script setup> | ||
| yield* generateExportDeclareEqual(scriptSetup, names._export); | ||
| yield* generateExportDeclareEqual(scriptSetup, names_1.names.export); | ||
| if (scriptSetup.generic) { | ||
@@ -111,3 +111,3 @@ yield* (0, scriptSetup_1.generateGeneric)(options, ctx, scriptSetup, scriptSetupRanges, scriptSetup.generic, (0, scriptSetup_1.generateSetupFunction)(options, ctx, scriptSetup, scriptSetupRanges, (0, template_1.generateTemplate)(options, ctx, selfType))); | ||
| if (scriptSetup.generic) { | ||
| yield* generateExportDeclareEqual(scriptSetup, names._export); | ||
| yield* generateExportDeclareEqual(scriptSetup, names_1.names.export); | ||
| yield* (0, scriptSetup_1.generateGeneric)(options, ctx, scriptSetup, scriptSetupRanges, scriptSetup.generic, (0, scriptSetup_1.generateSetupFunction)(options, ctx, scriptSetup, scriptSetupRanges, (0, template_1.generateTemplate)(options, ctx))); | ||
@@ -117,3 +117,3 @@ } | ||
| // no script block, generate script setup code at root | ||
| yield* (0, scriptSetup_1.generateSetupFunction)(options, ctx, scriptSetup, scriptSetupRanges, (0, template_1.generateTemplate)(options, ctx), generateExportDeclareEqual(scriptSetup, names._export)); | ||
| yield* (0, scriptSetup_1.generateSetupFunction)(options, ctx, scriptSetup, scriptSetupRanges, (0, template_1.generateTemplate)(options, ctx), generateExportDeclareEqual(scriptSetup, names_1.names.export)); | ||
| } | ||
@@ -126,9 +126,9 @@ yield `export default ${exportExpression}${utils_1.endOfLine}`; | ||
| if (exportDefault) { | ||
| yield* generateScriptWithExportDefault(ctx, script, scriptRanges, exportDefault, vueCompilerOptions, names._export, (0, template_1.generateTemplate)(options, ctx, names._export)); | ||
| yield* generateScriptWithExportDefault(ctx, script, scriptRanges, exportDefault, vueCompilerOptions, names_1.names.export, (0, template_1.generateTemplate)(options, ctx, names_1.names.export)); | ||
| } | ||
| else { | ||
| yield* (0, utils_1.generateSfcBlockSection)(script, 0, script.content.length, codeFeatures_1.codeFeatures.all); | ||
| yield* generateExportDeclareEqual(script, names._export); | ||
| yield* generateExportDeclareEqual(script, names_1.names.export); | ||
| yield `(await import('${vueCompilerOptions.lib}')).defineComponent({})${utils_1.endOfLine}`; | ||
| yield* (0, template_1.generateTemplate)(options, ctx, names._export); | ||
| yield* (0, template_1.generateTemplate)(options, ctx, names_1.names.export); | ||
| yield `export default ${exportExpression}${utils_1.endOfLine}`; | ||
@@ -135,0 +135,0 @@ } |
| "use strict"; | ||
| var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
| if (k2 === undefined) k2 = k; | ||
| var desc = Object.getOwnPropertyDescriptor(m, k); | ||
| if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { | ||
| desc = { enumerable: true, get: function() { return m[k]; } }; | ||
| } | ||
| Object.defineProperty(o, k2, desc); | ||
| }) : (function(o, m, k, k2) { | ||
| if (k2 === undefined) k2 = k; | ||
| o[k2] = m[k]; | ||
| })); | ||
| var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { | ||
| Object.defineProperty(o, "default", { enumerable: true, value: v }); | ||
| }) : function(o, v) { | ||
| o["default"] = v; | ||
| }); | ||
| var __importStar = (this && this.__importStar) || (function () { | ||
| var ownKeys = function(o) { | ||
| ownKeys = Object.getOwnPropertyNames || function (o) { | ||
| var ar = []; | ||
| for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k; | ||
| return ar; | ||
| }; | ||
| return ownKeys(o); | ||
| }; | ||
| return function (mod) { | ||
| if (mod && mod.__esModule) return mod; | ||
| var result = {}; | ||
| if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]); | ||
| __setModuleDefault(result, mod); | ||
| return result; | ||
| }; | ||
| })(); | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -41,3 +8,3 @@ exports.generateScriptSetupImports = generateScriptSetupImports; | ||
| const codeFeatures_1 = require("../codeFeatures"); | ||
| const names = __importStar(require("../names")); | ||
| const names_1 = require("../names"); | ||
| const utils_1 = require("../utils"); | ||
@@ -67,6 +34,6 @@ const boundary_1 = require("../utils/boundary"); | ||
| yield `(${utils_1.newLine}` | ||
| + ` ${names.props}: NonNullable<Awaited<typeof ${names.setup}>>['props'],${utils_1.newLine}` | ||
| + ` ${names.ctx}?: ${ctx.localTypes.PrettifyLocal}<Pick<NonNullable<Awaited<typeof ${names.setup}>>, 'attrs' | 'emit' | 'slots'>>,${utils_1.newLine}` // use __VLS_Prettify for less dts code | ||
| + ` ${names.exposed}?: NonNullable<Awaited<typeof ${names.setup}>>['expose'],${utils_1.newLine}` | ||
| + ` ${names.setup} = (async () => {${utils_1.newLine}`; | ||
| + ` ${names_1.names.props}: NonNullable<Awaited<typeof ${names_1.names.setup}>>['props'],${utils_1.newLine}` | ||
| + ` ${names_1.names.ctx}?: ${ctx.localTypes.PrettifyLocal}<Pick<NonNullable<Awaited<typeof ${names_1.names.setup}>>, 'attrs' | 'emit' | 'slots'>>,${utils_1.newLine}` | ||
| + ` ${names_1.names.exposed}?: NonNullable<Awaited<typeof ${names_1.names.setup}>>['expose'],${utils_1.newLine}` | ||
| + ` ${names_1.names.setup} = (async () => {${utils_1.newLine}`; | ||
| yield* body; | ||
@@ -76,22 +43,22 @@ const propTypes = []; | ||
| const { vueCompilerOptions } = options; | ||
| if (ctx.generatedTypes.has(names.PublicProps)) { | ||
| propTypes.push(names.PublicProps); | ||
| if (ctx.generatedTypes.has(names_1.names.PublicProps)) { | ||
| propTypes.push(names_1.names.PublicProps); | ||
| } | ||
| if (scriptSetupRanges.defineProps?.arg) { | ||
| yield `const __VLS_propsOption = `; | ||
| yield `const ${names_1.names.propsOption} = `; | ||
| yield* (0, utils_1.generateSfcBlockSection)(scriptSetup, scriptSetupRanges.defineProps.arg.start, scriptSetupRanges.defineProps.arg.end, codeFeatures_1.codeFeatures.navigation); | ||
| yield utils_1.endOfLine; | ||
| propTypes.push(`import('${vueCompilerOptions.lib}').${vueCompilerOptions.target >= 3.3 ? `ExtractPublicPropTypes` : `ExtractPropTypes`}<typeof __VLS_propsOption>`); | ||
| propTypes.push(`import('${vueCompilerOptions.lib}').${vueCompilerOptions.target >= 3.3 ? `ExtractPublicPropTypes` : `ExtractPropTypes`}<typeof ${names_1.names.propsOption}>`); | ||
| } | ||
| if (scriptSetupRanges.defineEmits || scriptSetupRanges.defineModel.length) { | ||
| propTypes.push(names.EmitProps); | ||
| propTypes.push(names_1.names.EmitProps); | ||
| } | ||
| if (options.templateAndStyleTypes.has(names.InheritedAttrs)) { | ||
| propTypes.push(names.InheritedAttrs); | ||
| if (options.templateAndStyleTypes.has(names_1.names.InheritedAttrs)) { | ||
| propTypes.push(names_1.names.InheritedAttrs); | ||
| } | ||
| if (scriptSetupRanges.defineEmits) { | ||
| emitTypes.push(`typeof ${scriptSetupRanges.defineEmits.name ?? names.emit}`); | ||
| emitTypes.push(`typeof ${scriptSetupRanges.defineEmits.name ?? names_1.names.emit}`); | ||
| } | ||
| if (scriptSetupRanges.defineModel.length) { | ||
| emitTypes.push(`typeof ${names.modelEmit}`); | ||
| emitTypes.push(`typeof ${names_1.names.modelEmit}`); | ||
| } | ||
@@ -113,19 +80,19 @@ yield `return {} as {${utils_1.newLine}`; | ||
| yield scriptSetupRanges.defineExpose | ||
| ? `import('${vueCompilerOptions.lib}').ShallowUnwrapRef<typeof ${names.exposed}>` | ||
| ? `import('${vueCompilerOptions.lib}').ShallowUnwrapRef<typeof ${names_1.names.exposed}>` | ||
| : `{}`; | ||
| if (options.vueCompilerOptions.inferComponentDollarRefs | ||
| && options.templateAndStyleTypes.has(names.TemplateRefs)) { | ||
| yield ` & { $refs: ${names.TemplateRefs}; }`; | ||
| && options.templateAndStyleTypes.has(names_1.names.TemplateRefs)) { | ||
| yield ` & { $refs: ${names_1.names.TemplateRefs}; }`; | ||
| } | ||
| if (options.vueCompilerOptions.inferComponentDollarEl | ||
| && options.templateAndStyleTypes.has(names.RootEl)) { | ||
| yield ` & { $el: ${names.RootEl}; }`; | ||
| && options.templateAndStyleTypes.has(names_1.names.RootEl)) { | ||
| yield ` & { $el: ${names_1.names.RootEl}; }`; | ||
| } | ||
| yield `) => void${utils_1.endOfLine}`; | ||
| yield ` attrs: any${utils_1.endOfLine}`; | ||
| yield ` slots: ${hasSlotsType(options) ? names.Slots : `{}`}${utils_1.endOfLine}`; | ||
| yield ` slots: ${hasSlotsType(options) ? names_1.names.Slots : `{}`}${utils_1.endOfLine}`; | ||
| yield ` emit: ${emitTypes.length ? emitTypes.join(` & `) : `{}`}${utils_1.endOfLine}`; | ||
| yield `}${utils_1.endOfLine}`; | ||
| yield `})(),${utils_1.newLine}`; // __VLS_setup = (async () => { | ||
| yield `) => ({} as import('${vueCompilerOptions.lib}').VNode & { __ctx?: Awaited<typeof ${names.setup}> }))${utils_1.endOfLine}`; | ||
| yield `) => ({} as import('${vueCompilerOptions.lib}').VNode & { __ctx?: Awaited<typeof ${names_1.names.setup}> }))${utils_1.endOfLine}`; | ||
| } | ||
@@ -137,11 +104,11 @@ function* generateSetupFunction(options, ctx, scriptSetup, scriptSetupRanges, body, output) { | ||
| const _callExp = scriptSetupRanges.withDefaults?.callExp ?? callExp; | ||
| transforms.push(...generateDefineWithTypeTransforms(scriptSetup, statement, _callExp, typeArg, name, names.props, names.Props)); | ||
| transforms.push(...generateDefineWithTypeTransforms(scriptSetup, statement, _callExp, typeArg, name, names_1.names.props, names_1.names.Props)); | ||
| } | ||
| if (scriptSetupRanges.defineEmits) { | ||
| const { name, statement, callExp, typeArg } = scriptSetupRanges.defineEmits; | ||
| transforms.push(...generateDefineWithTypeTransforms(scriptSetup, statement, callExp, typeArg, name, names.emit, names.Emit)); | ||
| transforms.push(...generateDefineWithTypeTransforms(scriptSetup, statement, callExp, typeArg, name, names_1.names.emit, names_1.names.Emit)); | ||
| } | ||
| if (scriptSetupRanges.defineSlots) { | ||
| const { name, statement, callExp, typeArg } = scriptSetupRanges.defineSlots; | ||
| transforms.push(...generateDefineWithTypeTransforms(scriptSetup, statement, callExp, typeArg, name, names.slots, names.Slots)); | ||
| transforms.push(...generateDefineWithTypeTransforms(scriptSetup, statement, callExp, typeArg, name, names_1.names.slots, names_1.names.Slots)); | ||
| } | ||
@@ -152,7 +119,7 @@ if (scriptSetupRanges.defineExpose) { | ||
| transforms.push((0, transform_1.insert)(callExp.start, function* () { | ||
| yield `let ${names.exposed}!: `; | ||
| yield `let ${names_1.names.exposed}!: `; | ||
| yield* (0, utils_1.generateSfcBlockSection)(scriptSetup, typeArg.start, typeArg.end, codeFeatures_1.codeFeatures.all); | ||
| yield utils_1.endOfLine; | ||
| }), (0, transform_1.replace)(typeArg.start, typeArg.end, function* () { | ||
| yield `typeof ${names.exposed}`; | ||
| yield `typeof ${names_1.names.exposed}`; | ||
| })); | ||
@@ -162,7 +129,7 @@ } | ||
| transforms.push((0, transform_1.insert)(callExp.start, function* () { | ||
| yield `const ${names.exposed} = `; | ||
| yield `const ${names_1.names.exposed} = `; | ||
| yield* (0, utils_1.generateSfcBlockSection)(scriptSetup, arg.start, arg.end, codeFeatures_1.codeFeatures.all); | ||
| yield utils_1.endOfLine; | ||
| }), (0, transform_1.replace)(arg.start, arg.end, function* () { | ||
| yield `${names.exposed}`; | ||
| yield names_1.names.exposed; | ||
| })); | ||
@@ -172,3 +139,3 @@ } | ||
| transforms.push((0, transform_1.insert)(callExp.start, function* () { | ||
| yield `const ${names.exposed} = {}${utils_1.endOfLine}`; | ||
| yield `const ${names_1.names.exposed} = {}${utils_1.endOfLine}`; | ||
| })); | ||
@@ -182,3 +149,3 @@ } | ||
| }), (0, transform_1.insert)(callExp.end, function* () { | ||
| yield ` as typeof ${names.dollars}.$attrs)`; | ||
| yield ` as typeof ${names_1.names.dollars}.$attrs)`; | ||
| })); | ||
@@ -191,4 +158,4 @@ } | ||
| })); | ||
| const type = options.templateAndStyleTypes.has(names.StyleModules) | ||
| ? names.StyleModules | ||
| const type = options.templateAndStyleTypes.has(names_1.names.StyleModules) | ||
| ? names_1.names.StyleModules | ||
| : `{}`; | ||
@@ -219,3 +186,3 @@ if (arg) { | ||
| }), (0, transform_1.insert)(callExp.end, function* () { | ||
| yield ` as typeof ${names.dollars}.$slots)`; | ||
| yield ` as typeof ${names_1.names.dollars}.$slots)`; | ||
| })); | ||
@@ -230,3 +197,3 @@ } | ||
| if (arg) { | ||
| yield names.TemplateRefs; | ||
| yield names_1.names.TemplateRefs; | ||
| yield `[`; | ||
@@ -254,7 +221,7 @@ yield* (0, utils_1.generateSfcBlockSection)(scriptSetup, arg.start, arg.end, codeFeatures_1.codeFeatures.withoutSemantic); | ||
| if (hasSlotsType(options)) { | ||
| yield `const __VLS_base = `; | ||
| yield `const ${names_1.names.base} = `; | ||
| yield* (0, component_1.generateComponent)(options, ctx, scriptSetup, scriptSetupRanges); | ||
| yield utils_1.endOfLine; | ||
| yield* output; | ||
| yield `{} as ${ctx.localTypes.WithSlots}<typeof __VLS_base, ${names.Slots}>${utils_1.endOfLine}`; | ||
| yield `{} as ${ctx.localTypes.WithSlots}<typeof ${names_1.names.base}, ${names_1.names.Slots}>${utils_1.endOfLine}`; | ||
| } | ||
@@ -332,3 +299,3 @@ else { | ||
| if (scriptSetupRanges.defineProps?.typeArg && scriptSetupRanges.withDefaults?.arg) { | ||
| yield `const ${names.defaults} = `; | ||
| yield `const ${names_1.names.defaults} = `; | ||
| yield* (0, utils_1.generateSfcBlockSection)(scriptSetup, scriptSetupRanges.withDefaults.arg.start, scriptSetupRanges.withDefaults.arg.end, codeFeatures_1.codeFeatures.navigation); | ||
@@ -339,13 +306,13 @@ yield utils_1.endOfLine; | ||
| if (options.vueCompilerOptions.jsxSlots && hasSlotsType(options)) { | ||
| propTypes.push(`${ctx.localTypes.PropsChildren}<${names.Slots}>`); | ||
| propTypes.push(`${ctx.localTypes.PropsChildren}<${names_1.names.Slots}>`); | ||
| } | ||
| if (scriptSetupRanges.defineProps?.typeArg) { | ||
| propTypes.push(names.Props); | ||
| propTypes.push(names_1.names.Props); | ||
| } | ||
| if (scriptSetupRanges.defineModel.length) { | ||
| propTypes.push(names.ModelProps); | ||
| propTypes.push(names_1.names.ModelProps); | ||
| } | ||
| if (propTypes.length) { | ||
| yield `type ${names.PublicProps} = ${propTypes.join(` & `)}${utils_1.endOfLine}`; | ||
| ctx.generatedTypes.add(names.PublicProps); | ||
| yield `type ${names_1.names.PublicProps} = ${propTypes.join(` & `)}${utils_1.endOfLine}`; | ||
| ctx.generatedTypes.add(names_1.names.PublicProps); | ||
| } | ||
@@ -355,3 +322,3 @@ } | ||
| return !!(options.scriptSetupRanges?.defineSlots | ||
| || options.templateAndStyleTypes.has(names.Slots)); | ||
| || options.templateAndStyleTypes.has(names_1.names.Slots)); | ||
| } | ||
@@ -380,3 +347,3 @@ function* generateModels(scriptSetup, scriptSetupRanges) { | ||
| // Infer from defineModel({ default: T }) | ||
| modelType = `typeof ${names.defaultModels}['${propName}']`; | ||
| modelType = `typeof ${names_1.names.defaultModels}['${propName}']`; | ||
| } | ||
@@ -393,7 +360,7 @@ else { | ||
| if (defaultCodes.length) { | ||
| yield `const ${names.defaultModels} = {${utils_1.newLine}`; | ||
| yield `const ${names_1.names.defaultModels} = {${utils_1.newLine}`; | ||
| yield* defaultCodes; | ||
| yield `}${utils_1.endOfLine}`; | ||
| } | ||
| yield `type ${names.ModelProps} = {${utils_1.newLine}`; | ||
| yield `type ${names_1.names.ModelProps} = {${utils_1.newLine}`; | ||
| for (const codes of propCodes) { | ||
@@ -403,3 +370,3 @@ yield* codes; | ||
| yield `}${utils_1.endOfLine}`; | ||
| yield `type ${names.ModelEmit} = {${utils_1.newLine}`; | ||
| yield `type ${names_1.names.ModelEmit} = {${utils_1.newLine}`; | ||
| for (const codes of emitCodes) { | ||
@@ -410,3 +377,3 @@ yield* codes; | ||
| // avoid `defineModel<...>()` to prevent JS AST issues | ||
| yield `let ${names.modelEmit}!: __VLS_ShortEmits<${names.ModelEmit}>${utils_1.endOfLine}`; | ||
| yield `let ${names_1.names.modelEmit}!: ${names_1.names.ShortEmits}<${names_1.names.ModelEmit}>${utils_1.endOfLine}`; | ||
| } | ||
@@ -413,0 +380,0 @@ function* generateModelProp(scriptSetup, defineModel, propName, modelType) { |
| "use strict"; | ||
| var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
| if (k2 === undefined) k2 = k; | ||
| var desc = Object.getOwnPropertyDescriptor(m, k); | ||
| if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { | ||
| desc = { enumerable: true, get: function() { return m[k]; } }; | ||
| } | ||
| Object.defineProperty(o, k2, desc); | ||
| }) : (function(o, m, k, k2) { | ||
| if (k2 === undefined) k2 = k; | ||
| o[k2] = m[k]; | ||
| })); | ||
| var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { | ||
| Object.defineProperty(o, "default", { enumerable: true, value: v }); | ||
| }) : function(o, v) { | ||
| o["default"] = v; | ||
| }); | ||
| var __importStar = (this && this.__importStar) || (function () { | ||
| var ownKeys = function(o) { | ||
| ownKeys = Object.getOwnPropertyNames || function (o) { | ||
| var ar = []; | ||
| for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k; | ||
| return ar; | ||
| }; | ||
| return ownKeys(o); | ||
| }; | ||
| return function (mod) { | ||
| if (mod && mod.__esModule) return mod; | ||
| var result = {}; | ||
| if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]); | ||
| __setModuleDefault(result, mod); | ||
| return result; | ||
| }; | ||
| })(); | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.generateTemplate = generateTemplate; | ||
| const codeFeatures_1 = require("../codeFeatures"); | ||
| const names = __importStar(require("../names")); | ||
| const names_1 = require("../names"); | ||
| const utils_1 = require("../utils"); | ||
@@ -58,3 +25,3 @@ const merge_1 = require("../utils/merge"); | ||
| if (selfType) { | ||
| exps.push([`{} as InstanceType<__VLS_PickNotAny<typeof ${selfType}, new () => {}>>`]); | ||
| exps.push([`{} as InstanceType<${names_1.names.PickNotAny}<typeof ${selfType}, new () => {}>>`]); | ||
| } | ||
@@ -64,24 +31,23 @@ else { | ||
| } | ||
| if (templateAndStyleTypes.has(names.StyleModules)) { | ||
| exps.push([`{} as ${names.StyleModules}`]); | ||
| if (templateAndStyleTypes.has(names_1.names.StyleModules)) { | ||
| exps.push([`{} as ${names_1.names.StyleModules}`]); | ||
| } | ||
| if (scriptSetupRanges?.defineEmits) { | ||
| const { defineEmits } = scriptSetupRanges; | ||
| emitTypes.push(`typeof ${defineEmits.name ?? names.emit}`); | ||
| emitTypes.push(`typeof ${scriptSetupRanges.defineEmits.name ?? names_1.names.emit}`); | ||
| } | ||
| if (scriptSetupRanges?.defineModel.length) { | ||
| emitTypes.push(`typeof ${names.modelEmit}`); | ||
| emitTypes.push(`typeof ${names_1.names.modelEmit}`); | ||
| } | ||
| if (emitTypes.length) { | ||
| yield `type ${names.EmitProps} = __VLS_EmitsToProps<__VLS_NormalizeEmits<${emitTypes.join(` & `)}>>${utils_1.endOfLine}`; | ||
| yield `type ${names_1.names.EmitProps} = ${names_1.names.EmitsToProps}<${names_1.names.NormalizeEmits}<${emitTypes.join(` & `)}>>${utils_1.endOfLine}`; | ||
| exps.push([`{} as { $emit: ${emitTypes.join(` & `)} }`]); | ||
| } | ||
| if (scriptSetupRanges?.defineProps) { | ||
| propTypes.push(`typeof ${scriptSetupRanges.defineProps.name ?? names.props}`); | ||
| propTypes.push(`typeof ${scriptSetupRanges.defineProps.name ?? names_1.names.props}`); | ||
| } | ||
| if (scriptSetupRanges?.defineModel.length) { | ||
| propTypes.push(names.ModelProps); | ||
| propTypes.push(names_1.names.ModelProps); | ||
| } | ||
| if (emitTypes.length) { | ||
| propTypes.push(names.EmitProps); | ||
| propTypes.push(names_1.names.EmitProps); | ||
| } | ||
@@ -92,6 +58,6 @@ if (propTypes.length) { | ||
| } | ||
| if (ctx.generatedTypes.has(names.SetupExposed)) { | ||
| exps.push([`{} as ${names.SetupExposed}`]); | ||
| if (ctx.generatedTypes.has(names_1.names.SetupExposed)) { | ||
| exps.push([`{} as ${names_1.names.SetupExposed}`]); | ||
| } | ||
| yield `const ${names.ctx} = `; | ||
| yield `const ${names_1.names.ctx} = `; | ||
| yield* (0, merge_1.generateSpreadMerge)(exps); | ||
@@ -102,18 +68,18 @@ yield utils_1.endOfLine; | ||
| const types = []; | ||
| if (ctx.generatedTypes.has(names.SetupExposed)) { | ||
| types.push(names.SetupExposed); | ||
| if (ctx.generatedTypes.has(names_1.names.SetupExposed)) { | ||
| types.push(names_1.names.SetupExposed); | ||
| } | ||
| if (script && scriptRanges?.exportDefault?.options?.components) { | ||
| const { components } = scriptRanges.exportDefault.options; | ||
| yield `const __VLS_componentsOption = `; | ||
| yield `const ${names_1.names.componentsOption} = `; | ||
| yield* (0, utils_1.generateSfcBlockSection)(script, components.start, components.end, codeFeatures_1.codeFeatures.navigation); | ||
| yield utils_1.endOfLine; | ||
| types.push(`typeof __VLS_componentsOption`); | ||
| types.push(`typeof ${names_1.names.componentsOption}`); | ||
| } | ||
| yield `type __VLS_LocalComponents = ${types.length ? types.join(` & `) : `{}`}${utils_1.endOfLine}`; | ||
| yield `type __VLS_GlobalComponents = ${vueCompilerOptions.target >= 3.5 | ||
| yield `type ${names_1.names.LocalComponents} = ${types.length ? types.join(` & `) : `{}`}${utils_1.endOfLine}`; | ||
| yield `type ${names_1.names.GlobalComponents} = ${vueCompilerOptions.target >= 3.5 | ||
| ? `import('${vueCompilerOptions.lib}').GlobalComponents` | ||
| : `import('${vueCompilerOptions.lib}').GlobalComponents & Pick<typeof import('${vueCompilerOptions.lib}'), 'Transition' | 'TransitionGroup' | 'KeepAlive' | 'Suspense' | 'Teleport'>`}${utils_1.endOfLine}`; | ||
| yield `let ${names.components}!: __VLS_LocalComponents & __VLS_GlobalComponents${utils_1.endOfLine}`; | ||
| yield `let ${names.intrinsics}!: ${vueCompilerOptions.target >= 3.3 | ||
| yield `let ${names_1.names.components}!: ${names_1.names.LocalComponents} & ${names_1.names.GlobalComponents}${utils_1.endOfLine}`; | ||
| yield `let ${names_1.names.intrinsics}!: ${vueCompilerOptions.target >= 3.3 | ||
| ? `import('${vueCompilerOptions.lib}/jsx-runtime').JSX.IntrinsicElements` | ||
@@ -124,14 +90,14 @@ : `globalThis.JSX.IntrinsicElements`}${utils_1.endOfLine}`; | ||
| const types = []; | ||
| if (ctx.generatedTypes.has(names.SetupExposed)) { | ||
| types.push(names.SetupExposed); | ||
| if (ctx.generatedTypes.has(names_1.names.SetupExposed)) { | ||
| types.push(names_1.names.SetupExposed); | ||
| } | ||
| if (script && scriptRanges?.exportDefault?.options?.directives) { | ||
| const { directives } = scriptRanges.exportDefault.options; | ||
| yield `const __VLS_directivesOption = `; | ||
| yield `const ${names_1.names.directivesOption} = `; | ||
| yield* (0, utils_1.generateSfcBlockSection)(script, directives.start, directives.end, codeFeatures_1.codeFeatures.navigation); | ||
| yield utils_1.endOfLine; | ||
| types.push(`__VLS_ResolveDirectives<typeof __VLS_directivesOption>`); | ||
| types.push(`${names_1.names.ResolveDirectives}<typeof ${names_1.names.directivesOption}>`); | ||
| } | ||
| yield `type __VLS_LocalDirectives = ${types.length ? types.join(` & `) : `{}`}${utils_1.endOfLine}`; | ||
| yield `let ${names.directives}!: __VLS_LocalDirectives & import('${vueCompilerOptions.lib}').GlobalDirectives${utils_1.endOfLine}`; | ||
| yield `type ${names_1.names.LocalDirectives} = ${types.length ? types.join(` & `) : `{}`}${utils_1.endOfLine}`; | ||
| yield `let ${names_1.names.directives}!: ${names_1.names.LocalDirectives} & import('${vueCompilerOptions.lib}').GlobalDirectives${utils_1.endOfLine}`; | ||
| } | ||
@@ -142,4 +108,4 @@ function* generateSetupExposed({ vueCompilerOptions, exposed }, ctx) { | ||
| } | ||
| ctx.generatedTypes.add(names.SetupExposed); | ||
| yield `type ${names.SetupExposed} = import('${vueCompilerOptions.lib}').ShallowUnwrapRef<{${utils_1.newLine}`; | ||
| ctx.generatedTypes.add(names_1.names.SetupExposed); | ||
| yield `type ${names_1.names.SetupExposed} = import('${vueCompilerOptions.lib}').ShallowUnwrapRef<{${utils_1.newLine}`; | ||
| for (const bindingName of exposed) { | ||
@@ -146,0 +112,0 @@ const token = Symbol(bindingName.length); |
| "use strict"; | ||
| var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
| if (k2 === undefined) k2 = k; | ||
| var desc = Object.getOwnPropertyDescriptor(m, k); | ||
| if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { | ||
| desc = { enumerable: true, get: function() { return m[k]; } }; | ||
| } | ||
| Object.defineProperty(o, k2, desc); | ||
| }) : (function(o, m, k, k2) { | ||
| if (k2 === undefined) k2 = k; | ||
| o[k2] = m[k]; | ||
| })); | ||
| var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { | ||
| Object.defineProperty(o, "default", { enumerable: true, value: v }); | ||
| }) : function(o, v) { | ||
| o["default"] = v; | ||
| }); | ||
| var __importStar = (this && this.__importStar) || (function () { | ||
| var ownKeys = function(o) { | ||
| ownKeys = Object.getOwnPropertyNames || function (o) { | ||
| var ar = []; | ||
| for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k; | ||
| return ar; | ||
| }; | ||
| return ownKeys(o); | ||
| }; | ||
| return function (mod) { | ||
| if (mod && mod.__esModule) return mod; | ||
| var result = {}; | ||
| if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]); | ||
| __setModuleDefault(result, mod); | ||
| return result; | ||
| }; | ||
| })(); | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.generateStyleModules = generateStyleModules; | ||
| const codeFeatures_1 = require("../codeFeatures"); | ||
| const names = __importStar(require("../names")); | ||
| const names_1 = require("../names"); | ||
| const utils_1 = require("../utils"); | ||
@@ -46,4 +13,4 @@ const common_1 = require("./common"); | ||
| } | ||
| ctx.generatedTypes.add(names.StyleModules); | ||
| yield `type ${names.StyleModules} = {${utils_1.newLine}`; | ||
| ctx.generatedTypes.add(names_1.names.StyleModules); | ||
| yield `type ${names_1.names.StyleModules} = {${utils_1.newLine}`; | ||
| for (const style of styleModules) { | ||
@@ -66,3 +33,3 @@ if (style.module === true) { | ||
| } | ||
| yield `__VLS_PrettifyGlobal<{}`; | ||
| yield `${names_1.names.PrettifyGlobal}<{}`; | ||
| if (vueCompilerOptions.resolveStyleImports) { | ||
@@ -69,0 +36,0 @@ yield* (0, common_1.generateStyleImports)(style); |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.generateStyleScopedClasses = generateStyleScopedClasses; | ||
| const names_1 = require("../names"); | ||
| const styleScopedClasses_1 = require("../template/styleScopedClasses"); | ||
@@ -18,3 +19,3 @@ const utils_1 = require("../utils"); | ||
| const deferredGenerations = []; | ||
| yield `type __VLS_StyleScopedClasses = {}`; | ||
| yield `type ${names_1.names.StyleScopedClasses} = {}`; | ||
| for (const style of scopedStyles) { | ||
@@ -21,0 +22,0 @@ if (resolveStyleImports) { |
@@ -44,3 +44,3 @@ "use strict"; | ||
| const inlayHints_1 = require("../inlayHints"); | ||
| const names = __importStar(require("../names")); | ||
| const names_1 = require("../names"); | ||
| const utils_1 = require("../utils"); | ||
@@ -118,5 +118,5 @@ const boundary_1 = require("../utils/boundary"); | ||
| else { | ||
| yield `let ${componentVar}!: __VLS_WithComponent<'${tag}', __VLS_LocalComponents, __VLS_GlobalComponents`; | ||
| yield `let ${componentVar}!: ${names_1.names.WithComponent}<'${tag}', ${names_1.names.LocalComponents}, ${names_1.names.GlobalComponents}`; | ||
| yield originalNames.has(options.componentName) | ||
| ? `, typeof ${names._export}` | ||
| ? `, typeof ${names_1.names.export}` | ||
| : `, void`; | ||
@@ -136,15 +136,18 @@ for (const name of originalNames) { | ||
| // navigation support | ||
| yield `/** @ts-ignore @type {typeof ${names.components}.`; | ||
| yield* (0, camelized_1.generateCamelized)(tag, 'template', startTagOffset, codeFeatures_1.codeFeatures.navigation); | ||
| if (tag[0] !== tag[0].toUpperCase()) { | ||
| yield ` | typeof ${names.components}.`; | ||
| yield* (0, camelized_1.generateCamelized)((0, shared_1.capitalize)(tag), 'template', startTagOffset, codeFeatures_1.codeFeatures.navigation); | ||
| } | ||
| if (endTagOffset !== undefined) { | ||
| yield ` | typeof ${names.components}.`; | ||
| yield* (0, camelized_1.generateCamelized)(tag, 'template', endTagOffset, codeFeatures_1.codeFeatures.navigation); | ||
| yield `/** @ts-ignore @type {`; | ||
| for (const offset of [startTagOffset, endTagOffset]) { | ||
| if (offset === undefined) { | ||
| continue; | ||
| } | ||
| yield ` | typeof ${names_1.names.components}.`; | ||
| yield* (0, camelized_1.generateCamelized)(tag, 'template', offset, codeFeatures_1.codeFeatures.navigation); | ||
| if (tag[0] !== tag[0].toUpperCase()) { | ||
| yield ` | typeof ${names.components}.`; | ||
| yield* (0, camelized_1.generateCamelized)((0, shared_1.capitalize)(tag), 'template', endTagOffset, codeFeatures_1.codeFeatures.navigation); | ||
| yield ` | typeof ${names_1.names.components}.`; | ||
| yield* (0, camelized_1.generateCamelized)((0, shared_1.capitalize)(tag), 'template', offset, codeFeatures_1.codeFeatures.navigation); | ||
| } | ||
| if (tag.includes('-')) { | ||
| yield ` | typeof ${names_1.names.components}[`; | ||
| yield* (0, stringLiteralKey_1.generateStringLiteralKey)(tag, offset, codeFeatures_1.codeFeatures.navigation); | ||
| yield `]`; | ||
| } | ||
| } | ||
@@ -169,7 +172,7 @@ yield `} */${utils_1.newLine}`; | ||
| const functionalVar = ctx.getInternalVariable(); | ||
| const vNodeVar = ctx.getInternalVariable(); | ||
| const vnodeVar = ctx.getInternalVariable(); | ||
| const ctxVar = ctx.getInternalVariable(); | ||
| const propsVar = ctx.getInternalVariable(); | ||
| yield `// @ts-ignore${utils_1.newLine}`; | ||
| yield `const ${functionalVar} = ${options.vueCompilerOptions.checkUnknownProps ? '__VLS_asFunctionalComponent0' : '__VLS_asFunctionalComponent1'}(${componentVar}, new ${componentVar}({${utils_1.newLine}`; | ||
| yield `const ${functionalVar} = ${options.vueCompilerOptions.checkUnknownProps ? names_1.names.asFunctionalComponent0 : names_1.names.asFunctionalComponent1}(${componentVar}, new ${componentVar}({${utils_1.newLine}`; | ||
| yield (0, muggle_string_1.toString)(propCodes); | ||
@@ -179,3 +182,3 @@ yield `}))${utils_1.endOfLine}`; | ||
| const token = yield* (0, boundary_1.startBoundary)('template', node.loc.start.offset, codeFeatures_1.codeFeatures.doNotReportTs6133); | ||
| yield vNodeVar; | ||
| yield vnodeVar; | ||
| yield (0, boundary_1.endBoundary)(token, node.loc.end.offset); | ||
@@ -197,3 +200,3 @@ yield ` = ${functionalVar}`; | ||
| yield (0, boundary_1.endBoundary)(token2, tagOffset + tag.length); | ||
| yield `, ...__VLS_functionalComponentArgsRest(${functionalVar}))${utils_1.endOfLine}`; | ||
| yield `, ...${names_1.names.functionalComponentArgsRest}(${functionalVar}))${utils_1.endOfLine}`; | ||
| yield* generateFailedExpressions(options, ctx, failGeneratedExpressions); | ||
@@ -229,6 +232,6 @@ yield* (0, elementEvents_1.generateElementEvents)(options, ctx, node, componentVar, getCtxVar, getPropsVar); | ||
| if (isCtxVarUsed) { | ||
| yield `var ${ctxVar}!: __VLS_FunctionalComponentCtx<typeof ${componentVar}, typeof ${vNodeVar}>${utils_1.endOfLine}`; | ||
| yield `var ${ctxVar}!: ${names_1.names.FunctionalComponentCtx}<typeof ${componentVar}, typeof ${vnodeVar}>${utils_1.endOfLine}`; | ||
| } | ||
| if (isPropsVarUsed) { | ||
| yield `var ${propsVar}!: __VLS_FunctionalComponentProps<typeof ${componentVar}, typeof ${vNodeVar}>${utils_1.endOfLine}`; | ||
| yield `var ${propsVar}!: ${names_1.names.FunctionalComponentProps}<typeof ${componentVar}, typeof ${vnodeVar}>${utils_1.endOfLine}`; | ||
| } | ||
@@ -240,7 +243,7 @@ ctx.components.pop(); | ||
| const failedPropExps = []; | ||
| yield `${options.vueCompilerOptions.checkUnknownProps ? `__VLS_asFunctionalElement0` : `__VLS_asFunctionalElement1`}(${names.intrinsics}`; | ||
| yield `${options.vueCompilerOptions.checkUnknownProps ? names_1.names.asFunctionalElement0 : names_1.names.asFunctionalElement1}(${names_1.names.intrinsics}`; | ||
| yield* (0, propertyAccess_1.generatePropertyAccess)(options, ctx, node.tag, startTagOffset, codeFeatures_1.codeFeatures.withoutHighlightAndCompletion); | ||
| if (endTagOffset !== undefined) { | ||
| yield `, `; | ||
| yield names.intrinsics; | ||
| yield names_1.names.intrinsics; | ||
| yield* (0, propertyAccess_1.generatePropertyAccess)(options, ctx, node.tag, endTagOffset, codeFeatures_1.codeFeatures.withoutHighlightAndCompletion); | ||
@@ -259,3 +262,3 @@ } | ||
| if (templateRef) { | ||
| let typeExp = `__VLS_Elements['${node.tag}']`; | ||
| let typeExp = `${names_1.names.Elements}['${node.tag}']`; | ||
| if (ctx.inVFor) { | ||
@@ -267,6 +270,6 @@ typeExp += `[]`; | ||
| if (ctx.singleRootNodes.has(node)) { | ||
| ctx.singleRootElTypes.add(`__VLS_Elements['${node.tag}']`); | ||
| ctx.singleRootElTypes.add(`${names_1.names.Elements}['${node.tag}']`); | ||
| } | ||
| if (hasVBindAttrs(options, ctx, node)) { | ||
| ctx.inheritedAttrVars.add(`__VLS_intrinsics.${node.tag}`); | ||
| ctx.inheritedAttrVars.add(`${names_1.names.intrinsics}.${node.tag}`); | ||
| } | ||
@@ -273,0 +276,0 @@ yield* generateStyleScopedClassReferences(options, node); |
@@ -41,3 +41,3 @@ "use strict"; | ||
| const codeFeatures_1 = require("../codeFeatures"); | ||
| const names = __importStar(require("../names")); | ||
| const names_1 = require("../names"); | ||
| const utils_1 = require("../utils"); | ||
@@ -60,5 +60,5 @@ const boundary_1 = require("../utils/boundary"); | ||
| const token = yield* (0, boundary_1.startBoundary)('template', prop.loc.start.offset, codeFeatures_1.codeFeatures.verification); | ||
| yield `__VLS_asFunctionalDirective(`; | ||
| yield `${names_1.names.asFunctionalDirective}(`; | ||
| yield* generateIdentifier(options, ctx, prop); | ||
| yield `, {} as import('${options.vueCompilerOptions.lib}').ObjectDirective)(null!, { ...__VLS_directiveBindingRestFields, `; | ||
| yield `, {} as import('${options.vueCompilerOptions.lib}').ObjectDirective)(null!, { ...${names_1.names.directiveBindingRestFields}, `; | ||
| yield* generateArg(options, ctx, prop); | ||
@@ -76,3 +76,3 @@ yield* generateModifiers(options, ctx, prop); | ||
| const token = yield* (0, boundary_1.startBoundary)('template', startOffset, codeFeatures_1.codeFeatures.verification); | ||
| yield names.directives; | ||
| yield names_1.names.directives; | ||
| yield `.`; | ||
@@ -79,0 +79,0 @@ yield* (0, camelized_1.generateCamelized)(rawName, 'template', prop.loc.start.offset, { |
@@ -44,2 +44,3 @@ "use strict"; | ||
| const codeFeatures_1 = require("../codeFeatures"); | ||
| const names_1 = require("../names"); | ||
| const utils_1 = require("../utils"); | ||
@@ -60,3 +61,3 @@ const boundary_1 = require("../utils/boundary"); | ||
| emitsVar = ctx.getInternalVariable(); | ||
| yield `let ${emitsVar}!: __VLS_ResolveEmits<typeof ${componentOriginalVar}, typeof ${getCtxVar()}.emit>${utils_1.endOfLine}`; | ||
| yield `let ${emitsVar}!: ${names_1.names.ResolveEmits}<typeof ${componentOriginalVar}, typeof ${getCtxVar()}.emit>${utils_1.endOfLine}`; | ||
| } | ||
@@ -80,3 +81,3 @@ let source = prop.arg?.loc.source ?? 'model-value'; | ||
| const camelizedEmitName = (0, shared_1.camelize)(emitName); | ||
| yield `const ${ctx.getInternalVariable()}: __VLS_NormalizeComponentEvent<typeof ${getPropsVar()}, typeof ${emitsVar}, '${propName}', '${emitName}', '${camelizedEmitName}'> = (${utils_1.newLine}`; | ||
| yield `const ${ctx.getInternalVariable()}: ${names_1.names.NormalizeComponentEvent}<typeof ${getPropsVar()}, typeof ${emitsVar}, '${propName}', '${emitName}', '${camelizedEmitName}'> = (${utils_1.newLine}`; | ||
| if (prop.name === 'on') { | ||
@@ -83,0 +84,0 @@ yield `{ `; |
@@ -44,3 +44,3 @@ "use strict"; | ||
| const inlayHints_1 = require("../inlayHints"); | ||
| const names = __importStar(require("../names")); | ||
| const names_1 = require("../names"); | ||
| const utils_1 = require("../utils"); | ||
@@ -140,3 +140,3 @@ const boundary_1 = require("../utils/boundary"); | ||
| ? !prop.arg.isStatic | ||
| ? `[__VLS_tryAsConstant(\`\${${prop.arg.content}}Modifiers\`)]` | ||
| ? `[${names_1.names.tryAsConstant}(\`\${${prop.arg.content}}Modifiers\`)]` | ||
| : (0, shared_1.camelize)(propName) + `Modifiers` | ||
@@ -224,3 +224,3 @@ : `modelModifiers`; | ||
| ctx.recordComponentAccess('template', propVariableName, exp.loc.start.offset); | ||
| yield names.ctx; | ||
| yield names_1.names.ctx; | ||
| yield `.`; | ||
@@ -227,0 +227,0 @@ yield* codes; |
| "use strict"; | ||
| var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
| if (k2 === undefined) k2 = k; | ||
| var desc = Object.getOwnPropertyDescriptor(m, k); | ||
| if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { | ||
| desc = { enumerable: true, get: function() { return m[k]; } }; | ||
| } | ||
| Object.defineProperty(o, k2, desc); | ||
| }) : (function(o, m, k, k2) { | ||
| if (k2 === undefined) k2 = k; | ||
| o[k2] = m[k]; | ||
| })); | ||
| var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { | ||
| Object.defineProperty(o, "default", { enumerable: true, value: v }); | ||
| }) : function(o, v) { | ||
| o["default"] = v; | ||
| }); | ||
| var __importStar = (this && this.__importStar) || (function () { | ||
| var ownKeys = function(o) { | ||
| ownKeys = Object.getOwnPropertyNames || function (o) { | ||
| var ar = []; | ||
| for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k; | ||
| return ar; | ||
| }; | ||
| return ownKeys(o); | ||
| }; | ||
| return function (mod) { | ||
| if (mod && mod.__esModule) return mod; | ||
| var result = {}; | ||
| if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]); | ||
| __setModuleDefault(result, mod); | ||
| return result; | ||
| }; | ||
| })(); | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.generateTemplate = generate; | ||
| const codeFeatures_1 = require("../codeFeatures"); | ||
| const names = __importStar(require("../names")); | ||
| const names_1 = require("../names"); | ||
| const utils_1 = require("../utils"); | ||
@@ -87,5 +54,5 @@ const boundary_1 = require("../utils/boundary"); | ||
| if (ctx.dollarVars.size) { | ||
| yield `var ${names.dollars}!: {${utils_1.newLine}`; | ||
| yield `var ${names_1.names.dollars}!: {${utils_1.newLine}`; | ||
| if (ctx.dollarVars.has('$slots')) { | ||
| const type = ctx.generatedTypes.has(names.Slots) ? names.Slots : `{}`; | ||
| const type = ctx.generatedTypes.has(names_1.names.Slots) ? names_1.names.Slots : `{}`; | ||
| yield `$slots: ${type}${utils_1.endOfLine}`; | ||
@@ -95,4 +62,4 @@ } | ||
| yield `$attrs: import('${vueCompilerOptions.lib}').ComponentPublicInstance['$attrs']`; | ||
| if (ctx.generatedTypes.has(names.InheritedAttrs)) { | ||
| yield ` & ${names.InheritedAttrs}`; | ||
| if (ctx.generatedTypes.has(names_1.names.InheritedAttrs)) { | ||
| yield ` & ${names_1.names.InheritedAttrs}`; | ||
| } | ||
@@ -102,7 +69,7 @@ yield utils_1.endOfLine; | ||
| if (ctx.dollarVars.has('$refs')) { | ||
| const type = ctx.generatedTypes.has(names.TemplateRefs) ? names.TemplateRefs : `{}`; | ||
| const type = ctx.generatedTypes.has(names_1.names.TemplateRefs) ? names_1.names.TemplateRefs : `{}`; | ||
| yield `$refs: ${type}${utils_1.endOfLine}`; | ||
| } | ||
| if (ctx.dollarVars.has('$el')) { | ||
| const type = ctx.generatedTypes.has(names.RootEl) ? names.RootEl : `any`; | ||
| const type = ctx.generatedTypes.has(names_1.names.RootEl) ? names_1.names.RootEl : `any`; | ||
| yield `$el: ${type}${utils_1.endOfLine}`; | ||
@@ -116,3 +83,3 @@ } | ||
| if (options.hasDefineSlots) { | ||
| ctx.generatedTypes.add(names.Slots); | ||
| ctx.generatedTypes.add(names_1.names.Slots); | ||
| return; | ||
@@ -123,4 +90,4 @@ } | ||
| } | ||
| ctx.generatedTypes.add(names.Slots); | ||
| yield `type ${names.Slots} = {}`; | ||
| ctx.generatedTypes.add(names_1.names.Slots); | ||
| yield `type ${names_1.names.Slots} = {}`; | ||
| for (const { expVar, propsVar } of ctx.dynamicSlots) { | ||
@@ -147,4 +114,4 @@ yield `${utils_1.newLine}& { [K in NonNullable<typeof ${expVar}>]?: (props: typeof ${propsVar}) => any }`; | ||
| } | ||
| ctx.generatedTypes.add(names.InheritedAttrs); | ||
| yield `type ${names.InheritedAttrs} = Partial<${[...ctx.inheritedAttrVars].map(name => `typeof ${name}`).join(` & `)}>`; | ||
| ctx.generatedTypes.add(names_1.names.InheritedAttrs); | ||
| yield `type ${names_1.names.InheritedAttrs} = Partial<${[...ctx.inheritedAttrVars].map(name => `typeof ${name}`).join(` & `)}>`; | ||
| yield utils_1.endOfLine; | ||
@@ -156,4 +123,4 @@ } | ||
| } | ||
| ctx.generatedTypes.add(names.TemplateRefs); | ||
| yield `type ${names.TemplateRefs} = {}`; | ||
| ctx.generatedTypes.add(names_1.names.TemplateRefs); | ||
| yield `type ${names_1.names.TemplateRefs} = {}`; | ||
| for (const [name, refs] of ctx.templateRefs) { | ||
@@ -183,4 +150,4 @@ yield `${utils_1.newLine}& `; | ||
| } | ||
| ctx.generatedTypes.add(names.RootEl); | ||
| yield `type ${names.RootEl} = `; | ||
| ctx.generatedTypes.add(names_1.names.RootEl); | ||
| yield `type ${names_1.names.RootEl} = `; | ||
| for (const type of ctx.singleRootElTypes) { | ||
@@ -187,0 +154,0 @@ yield `${utils_1.newLine}| ${type}`; |
| "use strict"; | ||
| var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
| if (k2 === undefined) k2 = k; | ||
| var desc = Object.getOwnPropertyDescriptor(m, k); | ||
| if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { | ||
| desc = { enumerable: true, get: function() { return m[k]; } }; | ||
| } | ||
| Object.defineProperty(o, k2, desc); | ||
| }) : (function(o, m, k, k2) { | ||
| if (k2 === undefined) k2 = k; | ||
| o[k2] = m[k]; | ||
| })); | ||
| var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { | ||
| Object.defineProperty(o, "default", { enumerable: true, value: v }); | ||
| }) : function(o, v) { | ||
| o["default"] = v; | ||
| }); | ||
| var __importStar = (this && this.__importStar) || (function () { | ||
| var ownKeys = function(o) { | ||
| ownKeys = Object.getOwnPropertyNames || function (o) { | ||
| var ar = []; | ||
| for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k; | ||
| return ar; | ||
| }; | ||
| return ownKeys(o); | ||
| }; | ||
| return function (mod) { | ||
| if (mod && mod.__esModule) return mod; | ||
| var result = {}; | ||
| if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]); | ||
| __setModuleDefault(result, mod); | ||
| return result; | ||
| }; | ||
| })(); | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -41,3 +8,3 @@ exports.generateInterpolation = generateInterpolation; | ||
| const codeFeatures_1 = require("../codeFeatures"); | ||
| const names = __importStar(require("../names")); | ||
| const names_1 = require("../names"); | ||
| const utils_1 = require("../utils"); | ||
@@ -99,7 +66,7 @@ // https://github.com/vuejs/core/blob/fb0c3ca519f1fccf52049cd6b8db3a67a669afe9/packages/compiler-core/src/transforms/transformExpression.ts#L47 | ||
| if (ctx.dollarVars.has(name)) { | ||
| yield names.dollars; | ||
| yield names_1.names.dollars; | ||
| } | ||
| else { | ||
| ctx.recordComponentAccess(block.name, name, start - prefix.length + offset); | ||
| yield names.ctx; | ||
| yield names_1.names.ctx; | ||
| } | ||
@@ -106,0 +73,0 @@ yield `.`; |
@@ -5,2 +5,3 @@ "use strict"; | ||
| const shared_1 = require("@vue/shared"); | ||
| const names_1 = require("../names"); | ||
| const utils_1 = require("../utils"); | ||
@@ -14,3 +15,3 @@ const boundary_1 = require("../utils/boundary"); | ||
| if (shouldBeConstant) { | ||
| yield* (0, interpolation_1.generateInterpolation)(options, ctx, options.template, features, code.slice(1, -1), offset + 1, `[__VLS_tryAsConstant(`, `)]`); | ||
| yield* (0, interpolation_1.generateInterpolation)(options, ctx, options.template, features, code.slice(1, -1), offset + 1, `[${names_1.names.tryAsConstant}(`, `)]`); | ||
| } | ||
@@ -17,0 +18,0 @@ else { |
@@ -41,3 +41,3 @@ "use strict"; | ||
| const inlayHints_1 = require("../inlayHints"); | ||
| const names = __importStar(require("../names")); | ||
| const names_1 = require("../names"); | ||
| const utils_1 = require("../utils"); | ||
@@ -63,3 +63,3 @@ const boundary_1 = require("../utils/boundary"); | ||
| if (options.hasDefineSlots) { | ||
| yield `__VLS_asFunctionalSlot(`; | ||
| yield `${names_1.names.asFunctionalSlot}(`; | ||
| if (nameProp) { | ||
@@ -83,3 +83,3 @@ let codes; | ||
| const token = yield* (0, boundary_1.startBoundary)('template', nameProp.loc.start.offset, codeFeatures_1.codeFeatures.verification); | ||
| yield options.slotsAssignName ?? names.slots; | ||
| yield options.slotsAssignName ?? names_1.names.slots; | ||
| yield* codes; | ||
@@ -90,3 +90,3 @@ yield (0, boundary_1.endBoundary)(token, nameProp.loc.end.offset); | ||
| const token = yield* (0, boundary_1.startBoundary)('template', startTagOffset, codeFeatures_1.codeFeatures.verification); | ||
| yield `${options.slotsAssignName ?? names.slots}[`; | ||
| yield `${options.slotsAssignName ?? names_1.names.slots}[`; | ||
| const token2 = yield* (0, boundary_1.startBoundary)('template', startTagOffset, codeFeatures_1.codeFeatures.verification); | ||
@@ -127,3 +127,3 @@ yield `'default'`; | ||
| const expVar = ctx.getInternalVariable(); | ||
| yield `var ${expVar} = __VLS_tryAsConstant(`; | ||
| yield `var ${expVar} = ${names_1.names.tryAsConstant}(`; | ||
| yield* (0, interpolation_1.generateInterpolation)(options, ctx, options.template, isShortHand | ||
@@ -130,0 +130,0 @@ ? codeFeatures_1.codeFeatures.withoutHighlightAndCompletion |
@@ -6,2 +6,3 @@ "use strict"; | ||
| const codeFeatures_1 = require("../codeFeatures"); | ||
| const names_1 = require("../names"); | ||
| const utils_1 = require("../utils"); | ||
@@ -15,3 +16,3 @@ const boundary_1 = require("../utils/boundary"); | ||
| if (!className) { | ||
| yield `/** @type {__VLS_StyleScopedClasses['`; | ||
| yield `/** @type {${names_1.names.StyleScopedClasses}['`; | ||
| yield ['', 'template', offset, codeFeatures_1.codeFeatures.completion]; | ||
@@ -30,3 +31,3 @@ yield `']} */${utils_1.endOfLine}`; | ||
| } | ||
| yield `/** @type {__VLS_StyleScopedClasses[`; | ||
| yield `/** @type {${names_1.names.StyleScopedClasses}[`; | ||
| const token = yield* (0, boundary_1.startBoundary)(block.name, fullStart, codeFeatures_1.codeFeatures.navigation); | ||
@@ -33,0 +34,0 @@ yield `'`; |
@@ -41,2 +41,3 @@ "use strict"; | ||
| const codeFeatures_1 = require("../codeFeatures"); | ||
| const names_1 = require("../names"); | ||
| const utils_1 = require("../utils"); | ||
@@ -62,3 +63,3 @@ const interpolation_1 = require("./interpolation"); | ||
| if (source.type === CompilerDOM.NodeTypes.SIMPLE_EXPRESSION) { | ||
| yield `__VLS_vFor(`; | ||
| yield `${names_1.names.vFor}(`; | ||
| yield* (0, interpolation_1.generateInterpolation)(options, ctx, options.template, codeFeatures_1.codeFeatures.all, source.content, source.loc.start.offset, `(`, `)`); | ||
@@ -65,0 +66,0 @@ yield `!)`; // #3102 |
@@ -41,2 +41,3 @@ "use strict"; | ||
| const codeFeatures_1 = require("../codeFeatures"); | ||
| const names_1 = require("../names"); | ||
| const utils_1 = require("../utils"); | ||
@@ -129,3 +130,3 @@ const boundary_1 = require("../utils/boundary"); | ||
| yield* interpolation; | ||
| yield `] = __VLS_vSlot(${slotVar}!`; | ||
| yield `] = ${names_1.names.vSlot}(${slotVar}!`; | ||
| if (types.some(t => t)) { | ||
@@ -132,0 +133,0 @@ yield `, `; |
@@ -36,4 +36,2 @@ "use strict"; | ||
| .replace(codeblockReg, (match, quotes) => quotes + ' '.repeat(match.length - quotes.length * 2) + quotes) | ||
| // inline code block | ||
| .replace(inlineCodeblockReg, match => `\`${' '.repeat(match.length - 2)}\``) | ||
| // latex block | ||
@@ -54,2 +52,4 @@ .replace(latexBlockReg, (match, quotes) => quotes + ' '.repeat(match.length - quotes.length * 2) + quotes) | ||
| content = content | ||
| // inline code block | ||
| .replace(inlineCodeblockReg, match => `\`${' '.repeat(match.length - 2)}\``) | ||
| // angle bracket: <http://foo.com> | ||
@@ -56,0 +56,0 @@ .replace(angleBracketReg, match => ' '.repeat(match.length)) |
@@ -209,24 +209,7 @@ "use strict"; | ||
| } | ||
| const exposedNames = new Set(); | ||
| const generatedTemplate = getGeneratedTemplate(); | ||
| const generatedStyle = getGeneratedStyle(); | ||
| for (const [name] of generatedTemplate?.componentAccessMap ?? []) { | ||
| if (allVars.has(name)) { | ||
| exposedNames.add(name); | ||
| } | ||
| } | ||
| for (const [name] of generatedStyle?.componentAccessMap ?? []) { | ||
| if (allVars.has(name)) { | ||
| exposedNames.add(name); | ||
| } | ||
| } | ||
| for (const component of sfc.template?.ast?.components ?? []) { | ||
| const testNames = new Set([(0, shared_1.camelize)(component), (0, shared_1.capitalize)((0, shared_1.camelize)(component))]); | ||
| for (const testName of testNames) { | ||
| if (allVars.has(testName)) { | ||
| exposedNames.add(testName); | ||
| } | ||
| } | ||
| } | ||
| return exposedNames; | ||
| return new Set([ | ||
| ...getGeneratedTemplate()?.componentAccessMap.keys() ?? [], | ||
| ...getGeneratedStyle()?.componentAccessMap.keys() ?? [], | ||
| ...sfc.template?.ast?.components.flatMap(name => [(0, shared_1.camelize)(name), (0, shared_1.capitalize)((0, shared_1.camelize)(name))]) ?? [], | ||
| ].filter(name => allVars.has(name))); | ||
| }); | ||
@@ -233,0 +216,0 @@ const getGeneratedScript = (0, alien_signals_1.computed)(() => { |
+5
-2
| { | ||
| "name": "@vue/language-core", | ||
| "version": "3.2.7", | ||
| "version": "3.2.8", | ||
| "license": "MIT", | ||
@@ -15,2 +15,5 @@ "files": [ | ||
| }, | ||
| "scripts": { | ||
| "generate-names": "node scripts/generate-names.js" | ||
| }, | ||
| "dependencies": { | ||
@@ -32,3 +35,3 @@ "@volar/language-core": "2.4.28", | ||
| }, | ||
| "gitHead": "a7092edf12862f0db8e39bd2afbda3d54aa26506" | ||
| "gitHead": "618bd6bfb19729726787df7b52fccda72c888c95" | ||
| } |
AI-detected potential code anomaly
Supply chain riskAI has identified unusual behaviors that may pose a security risk.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
AI-detected potential code anomaly
Supply chain riskAI has identified unusual behaviors that may pose a security risk.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
147
0.68%386452
-1.55%8887
-1.18%