@dxup/nuxt 0.3.2 → 0.4.0

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.
package/README.md CHANGED
@@ -60,6 +60,8 @@ useFetch("/api/foo");
60
60
  // Also `$fetch` and `useLazyFetch`.
61
61
  ```
62
62
 
63
+ It will fallback to resolve the URL from your `public` directory when no nitro routes match.
64
+
63
65
  ### 4. pageMeta
64
66
 
65
67
  Go to definition for page metadata.
@@ -73,8 +75,6 @@ definePageMeta({
73
75
  });
74
76
  ```
75
77
 
76
- It will fallback to resolve the URL from your `public` directory when no nitro routes match.
77
-
78
78
  ### 5. runtimeConfig
79
79
 
80
80
  Go to definition for runtime config.
@@ -101,6 +101,10 @@ It can be triggered on the `name` property of an object literal constrained by t
101
101
 
102
102
  ### 7. unimport
103
103
 
104
+ Please refer to the [@dxup/unimport](/packages/unimport) package for more details.
105
+
106
+ ### 8. unofficial
107
+
104
108
  Find references for SFC on `<template>`.
105
109
 
106
110
  ```vue
@@ -108,5 +112,3 @@ Find references for SFC on `<template>`.
108
112
  <!-- ^^^^^^^^ -->
109
113
  </template>
110
114
  ```
111
-
112
- Please refer to the [@dxup/unimport](/packages/unimport) package for more details.
package/dist/module.d.mts CHANGED
@@ -37,12 +37,13 @@ interface ModuleOptions {
37
37
  * Whether to enable enhanced navigation for auto imported APIs.
38
38
  * @default true
39
39
  */
40
- unimport?: boolean | {
41
- /**
42
- * Whether to enable Find References for SFC on `<template>`.
43
- */
44
- componentReferences: boolean;
45
- };
40
+ unimport?: boolean;
41
+ /**
42
+ * Whether to enable unofficial features for Vue itself.
43
+ * - find references for SFC on `<template>`
44
+ * @default true
45
+ */
46
+ unofficial?: boolean;
46
47
  };
47
48
  }
48
49
  declare const _default: _nuxt_schema0.NuxtModule<ModuleOptions, {
@@ -54,6 +55,7 @@ declare const _default: _nuxt_schema0.NuxtModule<ModuleOptions, {
54
55
  runtimeConfig: true;
55
56
  typedPages: true;
56
57
  unimport: true;
58
+ unofficial: true;
57
59
  };
58
60
  }, true>;
59
61
  //#endregion
package/dist/module.mjs CHANGED
@@ -76,7 +76,8 @@ var module_default = defineNuxtModule().with({
76
76
  pageMeta: true,
77
77
  runtimeConfig: true,
78
78
  typedPages: true,
79
- unimport: true
79
+ unimport: true,
80
+ unofficial: true
80
81
  } },
81
82
  async setup(options, nuxt) {
82
83
  const pluginsTs = [{ name: "@dxup/nuxt" }];
@@ -111,10 +112,7 @@ var module_default = defineNuxtModule().with({
111
112
  middleware,
112
113
  nitroRoutes,
113
114
  typedPages,
114
- features: {
115
- ...options.features,
116
- unimport: { componentReferences: typeof options.features.unimport === "object" ? options.features.unimport.componentReferences : options.features.unimport }
117
- }
115
+ features: options.features
118
116
  };
119
117
  return JSON.stringify(data, null, 2);
120
118
  }
@@ -47,7 +47,7 @@ const initialValue = {
47
47
  pageMeta: true,
48
48
  runtimeConfig: true,
49
49
  typedPages: true,
50
- unimport: { componentReferences: true }
50
+ unofficial: true
51
51
  }
52
52
  };
53
53
  const callbacks = {};
@@ -124,7 +124,7 @@ function postprocess$1(context, language, findReferences) {
124
124
  return (...args) => {
125
125
  const result = findReferences(...args);
126
126
  if (!result?.length) {
127
- const sourceScript = language.scripts.get(args[0]);
127
+ const sourceScript = language.scripts.get(args[0].replaceAll("\\", "/"));
128
128
  const root = sourceScript?.generated?.root;
129
129
  if (!isVueVirtualCode(root)) return;
130
130
  const start = (root.sfc.template?.start ?? Infinity) + 1;
@@ -195,7 +195,7 @@ function postprocess(context, language, getDefinitionAndBoundSpan) {
195
195
  return (...args) => {
196
196
  const result = getDefinitionAndBoundSpan(...args);
197
197
  if (!result?.definitions?.length) {
198
- const root = language.scripts.get(args[0])?.generated?.root;
198
+ const root = language.scripts.get(args[0].replaceAll("\\", "/"))?.generated?.root;
199
199
  if (!isVueVirtualCode(root)) return result;
200
200
  const textSpan = {
201
201
  start: (root.sfc.template?.start ?? Infinity) + 1,
@@ -462,12 +462,12 @@ function preprocess(context, getEditsForFileRename) {
462
462
  return (...args) => {
463
463
  const result = getEditsForFileRename(...args);
464
464
  if (!result?.length) return result;
465
- const languageService = info.project.getLanguageService();
466
- const program = languageService.getProgram();
467
- const references = {};
468
- for (const change of result) {
469
- const { fileName, textChanges } = change;
470
- if (data.features.components && fileName.endsWith("components.d.ts")) {
465
+ if (data.features.components) {
466
+ const languageService = info.project.getLanguageService();
467
+ const program = languageService.getProgram();
468
+ const references = {};
469
+ for (const { fileName, textChanges } of result) {
470
+ if (!fileName.endsWith("components.d.ts")) continue;
471
471
  const sourceFile = program.getSourceFile(fileName);
472
472
  if (!sourceFile) continue;
473
473
  for (const { span } of textChanges) for (const node of forEachTouchingNode(ts, sourceFile, span.start)) {
@@ -482,11 +482,11 @@ function preprocess(context, getEditsForFileRename) {
482
482
  break;
483
483
  }
484
484
  }
485
+ if (Object.keys(references).length) server.write("components:rename", {
486
+ fileName: args[1],
487
+ references
488
+ });
485
489
  }
486
- if (Object.keys(references).length) server.write("components:rename", {
487
- fileName: args[1],
488
- references
489
- });
490
490
  return result.filter((change) => {
491
491
  return !change.fileName.startsWith(data.buildDir);
492
492
  });
@@ -507,7 +507,7 @@ const plugin = (module$1) => {
507
507
  };
508
508
  queueMicrotask(() => {
509
509
  context.language = info.project.__vue__?.language;
510
- if (!context.language || !data.features.unimport.componentReferences) return;
510
+ if (!context.language || !data.features.unofficial) return;
511
511
  const languageService = info.project.getLanguageService();
512
512
  const methods = {};
513
513
  for (const [key, method] of [["findReferences", findReferences_exports], ["getDefinitionAndBoundSpan", getDefinitionAndBoundSpan_exports]]) {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@dxup/nuxt",
3
3
  "type": "module",
4
- "version": "0.3.2",
4
+ "version": "0.4.0",
5
5
  "description": "TypeScript plugin for Nuxt",
6
6
  "author": "KazariEX",
7
7
  "license": "MIT",
@@ -15,6 +15,9 @@
15
15
  "files": [
16
16
  "dist"
17
17
  ],
18
+ "peerDependencies": {
19
+ "typescript": "*"
20
+ },
18
21
  "dependencies": {
19
22
  "@nuxt/kit": "^4.2.2",
20
23
  "chokidar": "^5.0.0",
@@ -24,9 +27,9 @@
24
27
  },
25
28
  "devDependencies": {
26
29
  "@dxup/shared": "",
27
- "@volar/language-core": "^2.4.26",
28
- "@volar/typescript": "^2.4.26",
29
- "@vue/language-core": "^3.1.8",
30
+ "@volar/language-core": "^2.4.27",
31
+ "@volar/typescript": "^2.4.27",
32
+ "@vue/language-core": "^3.2.1",
30
33
  "nuxt": "^4.2.2",
31
34
  "typescript": "^5.9.3"
32
35
  },