vue-component-meta 3.1.0-alpha.0 → 3.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/lib/base.js +23 -22
  2. package/package.json +4 -4
package/lib/base.js CHANGED
@@ -17,15 +17,15 @@ Object.defineProperty(exports, "__esModule", { value: true });
17
17
  exports.createCheckerByJsonConfigBase = createCheckerByJsonConfigBase;
18
18
  exports.createCheckerBase = createCheckerBase;
19
19
  const typescript_1 = require("@volar/typescript");
20
- const vue = require("@vue/language-core");
20
+ const core = require("@vue/language-core");
21
21
  const path_browserify_1 = require("path-browserify");
22
22
  __exportStar(require("./types"), exports);
23
23
  const windowsPathReg = /\\/g;
24
24
  function createCheckerByJsonConfigBase(ts, rootDir, json, checkerOptions = {}) {
25
25
  rootDir = rootDir.replace(windowsPathReg, '/');
26
26
  return baseCreate(ts, () => {
27
- const commandLine = vue.createParsedCommandLineByJson(ts, ts.sys, rootDir, json);
28
- const { fileNames } = ts.parseJsonConfigFileContent(json, ts.sys, rootDir, {}, undefined, undefined, vue.getAllExtensions(commandLine.vueOptions)
27
+ const commandLine = core.createParsedCommandLineByJson(ts, ts.sys, rootDir, json);
28
+ const { fileNames } = ts.parseJsonConfigFileContent(json, ts.sys, rootDir, {}, undefined, undefined, core.getAllExtensions(commandLine.vueOptions)
29
29
  .map(extension => ({
30
30
  extension: extension.slice(1),
31
31
  isMixedContent: true,
@@ -37,8 +37,8 @@ function createCheckerByJsonConfigBase(ts, rootDir, json, checkerOptions = {}) {
37
37
  function createCheckerBase(ts, tsconfig, checkerOptions = {}) {
38
38
  tsconfig = tsconfig.replace(windowsPathReg, '/');
39
39
  return baseCreate(ts, () => {
40
- const commandLine = vue.createParsedCommandLine(ts, ts.sys, tsconfig);
41
- const { fileNames } = ts.parseJsonSourceFileConfigFileContent(ts.readJsonConfigFile(tsconfig, ts.sys.readFile), ts.sys, path_browserify_1.posix.dirname(tsconfig), {}, tsconfig, undefined, vue.getAllExtensions(commandLine.vueOptions)
40
+ const commandLine = core.createParsedCommandLine(ts, ts.sys, tsconfig);
41
+ const { fileNames } = ts.parseJsonSourceFileConfigFileContent(ts.readJsonConfigFile(tsconfig, ts.sys.readFile), ts.sys, path_browserify_1.posix.dirname(tsconfig), {}, tsconfig, undefined, core.getAllExtensions(commandLine.vueOptions)
42
42
  .map(extension => ({
43
43
  extension: extension.slice(1),
44
44
  isMixedContent: true,
@@ -48,19 +48,19 @@ function createCheckerBase(ts, tsconfig, checkerOptions = {}) {
48
48
  }, checkerOptions, path_browserify_1.posix.dirname(tsconfig), tsconfig + '.global.vue');
49
49
  }
50
50
  function baseCreate(ts, getConfigAndFiles, checkerOptions, rootPath, globalComponentName) {
51
- let [commandLine, _fileNames] = getConfigAndFiles();
51
+ let [{ vueOptions, options, projectReferences }, fileNames] = getConfigAndFiles();
52
52
  /**
53
53
  * Used to lookup if a file is referenced.
54
54
  */
55
- let fileNames = new Set(_fileNames.map(path => path.replace(windowsPathReg, '/')));
55
+ let fileNamesSet = new Set(fileNames.map(path => path.replace(windowsPathReg, '/')));
56
56
  let projectVersion = 0;
57
- vue.writeGlobalTypes(commandLine.vueOptions, ts.sys.writeFile);
57
+ vueOptions.globalTypesPath = core.createGlobalTypesWriter(vueOptions, ts.sys.writeFile);
58
58
  const projectHost = {
59
59
  getCurrentDirectory: () => rootPath,
60
60
  getProjectVersion: () => projectVersion.toString(),
61
- getCompilationSettings: () => commandLine.options,
62
- getScriptFileNames: () => [...fileNames],
63
- getProjectReferences: () => commandLine.projectReferences,
61
+ getCompilationSettings: () => options,
62
+ getScriptFileNames: () => [...fileNamesSet],
63
+ getProjectReferences: () => projectReferences,
64
64
  };
65
65
  const globalComponentSnapshot = ts.ScriptSnapshot.fromString('<script setup lang="ts"></script>');
66
66
  const scriptSnapshots = new Map();
@@ -75,15 +75,15 @@ function baseCreate(ts, getConfigAndFiles, checkerOptions, rootPath, globalCompo
75
75
  getMetaFileName(globalComponentName),
76
76
  ];
77
77
  };
78
- const vueLanguagePlugin = vue.createVueLanguagePlugin(ts, projectHost.getCompilationSettings(), commandLine.vueOptions, id => id);
79
- const language = vue.createLanguage([
78
+ const vueLanguagePlugin = core.createVueLanguagePlugin(ts, projectHost.getCompilationSettings(), vueOptions, id => id);
79
+ const language = core.createLanguage([
80
80
  vueLanguagePlugin,
81
81
  {
82
82
  getLanguageId(fileName) {
83
83
  return (0, typescript_1.resolveFileLanguageId)(fileName);
84
84
  },
85
85
  },
86
- ], new vue.FileMap(ts.sys.useCaseSensitiveFileNames), fileName => {
86
+ ], new core.FileMap(ts.sys.useCaseSensitiveFileNames), fileName => {
87
87
  let snapshot = scriptSnapshots.get(fileName);
88
88
  if (fileName === globalComponentName) {
89
89
  snapshot = globalComponentSnapshot;
@@ -119,7 +119,7 @@ function baseCreate(ts, getConfigAndFiles, checkerOptions, rootPath, globalCompo
119
119
  const getScriptKind = languageServiceHost.getScriptKind?.bind(languageServiceHost);
120
120
  languageServiceHost.getScriptKind = fileName => {
121
121
  const scriptKind = getScriptKind(fileName);
122
- if (commandLine.vueOptions.extensions.some(ext => fileName.endsWith(ext))) {
122
+ if (vueOptions.extensions.some(ext => fileName.endsWith(ext))) {
123
123
  if (scriptKind === ts.ScriptKind.JS) {
124
124
  return ts.ScriptKind.TS;
125
125
  }
@@ -138,17 +138,18 @@ function baseCreate(ts, getConfigAndFiles, checkerOptions, rootPath, globalCompo
138
138
  fileName = fileName.replace(windowsPathReg, '/');
139
139
  scriptSnapshots.set(fileName, ts.ScriptSnapshot.fromString(text));
140
140
  // Ensure the file is referenced
141
- fileNames.add(fileName);
141
+ fileNamesSet.add(fileName);
142
142
  projectVersion++;
143
143
  },
144
144
  deleteFile(fileName) {
145
145
  fileName = fileName.replace(windowsPathReg, '/');
146
- fileNames.delete(fileName);
146
+ fileNamesSet.delete(fileName);
147
147
  projectVersion++;
148
148
  },
149
149
  reload() {
150
- [commandLine, _fileNames] = getConfigAndFiles();
151
- fileNames = new Set(_fileNames.map(path => path.replace(windowsPathReg, '/')));
150
+ [{ vueOptions, options, projectReferences }, fileNames] = getConfigAndFiles();
151
+ vueOptions.globalTypesPath = core.createGlobalTypesWriter(vueOptions, ts.sys.writeFile);
152
+ fileNamesSet = new Set(fileNames.map(path => path.replace(windowsPathReg, '/')));
152
153
  this.clearCache();
153
154
  },
154
155
  clearCache() {
@@ -163,7 +164,7 @@ function baseCreate(ts, getConfigAndFiles, checkerOptions, rootPath, globalCompo
163
164
  return fileName.endsWith('.meta.ts');
164
165
  }
165
166
  function getMetaFileName(fileName) {
166
- return (commandLine.vueOptions.extensions.some(ext => fileName.endsWith(ext))
167
+ return (vueOptions.extensions.some(ext => fileName.endsWith(ext))
167
168
  ? fileName
168
169
  : fileName.slice(0, fileName.lastIndexOf('.'))) + '.meta.ts';
169
170
  }
@@ -258,7 +259,7 @@ interface ComponentMeta<T> {
258
259
  const { snapshot } = sourceScript;
259
260
  const vueFile = sourceScript.generated?.root;
260
261
  const vueDefaults = vueFile && exportName === 'default'
261
- ? (vueFile instanceof vue.VueVirtualCode ? readVueComponentDefaultProps(vueFile, printer, ts) : {})
262
+ ? (vueFile instanceof core.VueVirtualCode ? readVueComponentDefaultProps(vueFile, printer, ts) : {})
262
263
  : {};
263
264
  const tsDefaults = !vueFile
264
265
  ? readTsComponentDefaultProps(ts.createSourceFile('/tmp.' + componentPath.slice(componentPath.lastIndexOf('.') + 1), // ts | js | tsx | jsx
@@ -596,7 +597,7 @@ function readVueComponentDefaultProps(root, printer, ts) {
596
597
  return;
597
598
  }
598
599
  const { ast } = sfc.scriptSetup;
599
- const codegen = vue.tsCodegen.get(sfc);
600
+ const codegen = core.tsCodegen.get(sfc);
600
601
  const scriptSetupRanges = codegen?.getScriptSetupRanges();
601
602
  if (scriptSetupRanges?.withDefaults?.argNode) {
602
603
  const obj = findObjectLiteralExpression(scriptSetupRanges.withDefaults.argNode);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vue-component-meta",
3
- "version": "3.1.0-alpha.0",
3
+ "version": "3.1.1",
4
4
  "license": "MIT",
5
5
  "files": [
6
6
  "**/*.js",
@@ -14,9 +14,9 @@
14
14
  },
15
15
  "dependencies": {
16
16
  "@volar/typescript": "2.4.23",
17
- "@vue/language-core": "3.1.0-alpha.0",
17
+ "@vue/language-core": "3.1.1",
18
18
  "path-browserify": "^1.0.1",
19
- "vue-component-type-helpers": "3.1.0-alpha.0"
19
+ "vue-component-type-helpers": "3.1.1"
20
20
  },
21
21
  "peerDependencies": {
22
22
  "typescript": "*"
@@ -25,5 +25,5 @@
25
25
  "@types/node": "^22.10.4",
26
26
  "@types/path-browserify": "^1.0.1"
27
27
  },
28
- "gitHead": "adcbd8b1a7bf432844230755de999d22b95dc160"
28
+ "gitHead": "3ea27dacce47613f49ae83e96e3aa271ee54746e"
29
29
  }