@ripast/vue 0.4.0 → 0.5.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/dist/index.d.mts CHANGED
@@ -24,7 +24,7 @@ interface ListComponentsOptions {
24
24
  /** Emit warnings to this sink (default: process.stderr). Pass () => {} to silence. */
25
25
  warn?: (msg: string) => void;
26
26
  }
27
- declare function listComponents(cwd: string, opts?: ListComponentsOptions): VueComponent[];
27
+ export declare function listComponents(cwd: string, opts?: ListComponentsOptions): VueComponent[];
28
28
  interface PropSig {
29
29
  name: string;
30
30
  type?: string;
@@ -40,8 +40,8 @@ interface ParsedComponentShape {
40
40
  setup: boolean;
41
41
  propsResolution: PropsResolution;
42
42
  }
43
- declare function parseComponent(absPath: string): ParsedComponentShape;
44
- declare function parseComponentSource(absPath: string, source: string): ParsedComponentShape;
43
+ export declare function parseComponent(absPath: string): ParsedComponentShape;
44
+ export declare function parseComponentSource(absPath: string, source: string): ParsedComponentShape;
45
45
  type UsageForm = 'tag-pascal' | 'tag-kebab' | 'resolveComponent' | 'dynamic-is-literal' | 'dynamic-is-binding';
46
46
  interface ComponentUsage {
47
47
  name: string;
@@ -57,7 +57,7 @@ interface FindUsagesOptions {
57
57
  cwd?: string;
58
58
  glob?: string | string[];
59
59
  }
60
- declare function findComponentUsages(names: string[], opts?: FindUsagesOptions): ComponentUsage[];
61
- declare function findComponentUsage(name: string, opts?: FindUsagesOptions): ComponentUsage[];
60
+ export declare function findComponentUsages(names: string[], opts?: FindUsagesOptions): ComponentUsage[];
61
+ export declare function findComponentUsage(name: string, opts?: FindUsagesOptions): ComponentUsage[];
62
62
  declare const adapter: FrameworkAdapter;
63
- export { type ComponentKind, type ComponentUsage, type ListComponentsOptions, type ParsedComponentShape, type PropSig, type UsageForm, type VueComponent, adapter as default, findComponentUsage, findComponentUsages, listComponents, parseComponent, parseComponentSource };
63
+ export { type ComponentKind, type ComponentUsage, type ListComponentsOptions, type ParsedComponentShape, type PropSig, type UsageForm, type VueComponent, adapter as default };
package/dist/index.mjs CHANGED
@@ -3,14 +3,13 @@ import { basename, dirname, join, relative, resolve } from "node:path";
3
3
  import { extractTemplateExpressions, hyphenateVueName, isInsideAutoImportScope, parseSourceFile, parseVueTemplateAst, posToLineCol, rewriteTemplateReferences, rgFiles, rgFilesMany, scan } from "@ripast/core/adapter";
4
4
  import { URI } from "vscode-uri";
5
5
  import process from "node:process";
6
+ import ts from "@typescript/typescript6";
6
7
  import { FileType, createLanguage, createLanguageService, createUriMap } from "@volar/language-service";
7
8
  import { createLanguageServiceHost, resolveFileLanguageId } from "@volar/typescript";
8
9
  import { createParsedCommandLine, createVueLanguagePlugin, getAllExtensions } from "@vue/language-core";
9
10
  import { createVueLanguageServicePlugins } from "@vue/language-service";
10
- import ts from "typescript";
11
11
  import { create } from "volar-service-typescript";
12
12
  import { TextDocument } from "vscode-languageserver-textdocument";
13
- import { spawnSync } from "node:child_process";
14
13
  function stringifyArg(arg) {
15
14
  if (arg instanceof Error) return arg.message;
16
15
  if (typeof arg === "string") return arg;
@@ -149,7 +148,8 @@ function createVueServiceInternal(tsconfigPath, cwd) {
149
148
  },
150
149
  ...createLanguageServiceHost(ts, ts.sys, language, fileToUri, projectHost)
151
150
  } };
152
- const service = createLanguageService(language, [...create(ts), ...createVueLanguageServicePlugins(ts)], env, project);
151
+ const plugins = [...create(ts), ...createVueLanguageServicePlugins(ts)];
152
+ const service = createLanguageService(language, plugins, env, project);
153
153
  return {
154
154
  service,
155
155
  fileToUri,
@@ -201,27 +201,17 @@ function hasVueFilesContaining(cwd, pattern) {
201
201
  return listVueFilesContaining(cwd, pattern).length > 0;
202
202
  }
203
203
  function listVueFiles(cwd) {
204
- return rgVueFiles(cwd, ["--files"]);
204
+ return rgFiles("", {
205
+ cwd,
206
+ glob: "*.vue",
207
+ listAll: true
208
+ });
205
209
  }
206
210
  function listVueFilesContaining(cwd, pattern) {
207
- return rgVueFiles(cwd, [
208
- "--files-with-matches",
209
- "--fixed-strings",
210
- pattern
211
- ]);
212
- }
213
- function rgVueFiles(cwd, args) {
214
- return spawnSync("rg", [
215
- ...args,
216
- "--hidden",
217
- "--no-messages",
218
- "-g",
219
- "*.vue",
220
- "."
221
- ], {
211
+ return rgFiles(pattern, {
222
212
  cwd,
223
- encoding: "utf8"
224
- }).stdout.split("\n").filter(Boolean).map((path) => resolve(cwd, path));
213
+ glob: "*.vue"
214
+ });
225
215
  }
226
216
  async function applyVueRename(tsconfigPath, cwd, from, to, sites) {
227
217
  const vue = createVueService(tsconfigPath, cwd);
@@ -300,7 +290,7 @@ async function vueRegressions(tsconfigPath, cwd, pendingChanges) {
300
290
  const baselinePairs = await withFilteredConsoleWarn(() => Promise.all(vueFiles.map(async (file) => [file, await collectDiagKeys(vue, file)])));
301
291
  const baseline = new Map(baselinePairs);
302
292
  for (const c of pendingChanges) vue.setSnapshot(c.path, c.after);
303
- const checkSet = [...new Set([...vueFiles, ...pendingChanges.filter((c) => c.path.endsWith(".vue")).map((c) => c.path)])];
293
+ const checkSet = [.../* @__PURE__ */ new Set([...vueFiles, ...pendingChanges.filter((c) => c.path.endsWith(".vue")).map((c) => c.path)])];
304
294
  const postPairs = await withFilteredConsoleWarn(() => Promise.all(checkSet.map(async (file) => [file, await getDiags(vue, file)])));
305
295
  const out = [];
306
296
  for (const [file, post] of postPairs) {
@@ -734,7 +724,8 @@ function collectFromSfc(abs, source, cwd, alias, out) {
734
724
  if (node.type !== NODE_ELEMENT$1) return;
735
725
  const canonical = alias.byTag.get(node.tag);
736
726
  if (canonical) {
737
- const { line, col } = posToLineCol(source, node.loc.start.offset + 1);
727
+ const offset = node.loc.start.offset + 1;
728
+ const { line, col } = posToLineCol(source, offset);
738
729
  out.push({
739
730
  name: canonical,
740
731
  file: abs,
@@ -821,7 +812,8 @@ function collectFromScript(abs, source, cwd, alias, out) {
821
812
  const arg = node.arguments?.[0];
822
813
  if (arg?.type !== "Literal" || typeof arg.value !== "string") return;
823
814
  if (!alias.byString.has(arg.value)) return;
824
- const { line, col } = posToLineCol(source, (arg.start ?? 0) + scriptOffset);
815
+ const offset = (arg.start ?? 0) + scriptOffset;
816
+ const { line, col } = posToLineCol(source, offset);
825
817
  out.push({
826
818
  name: arg.value,
827
819
  file: abs,
@@ -1010,7 +1002,7 @@ function stripModuleExt(path) {
1010
1002
  }
1011
1003
  const MANIFEST_PATH = ".nuxt/components.d.ts";
1012
1004
  const MANIFEST_ENTRY_RE = /^\s*(?:export\s+const\s+)?([A-Z]\w*)\s*:\s*(?:LazyComponent<\s*)?typeof\s+import\(\s*["']([^"']+)["']\s*\)\s*\[\s*["']default["']\s*\]/gm;
1013
- const COMPONENT_DIR_NAMES = new Set(["components"]);
1005
+ const COMPONENT_DIR_NAMES = /* @__PURE__ */ new Set(["components"]);
1014
1006
  const DEFAULT_VUE_GLOB = ["*.vue"];
1015
1007
  function listComponents(cwd, opts = {}) {
1016
1008
  const source = opts.source ?? "auto";
@@ -1392,7 +1384,7 @@ const doctor = {
1392
1384
  return out;
1393
1385
  }
1394
1386
  };
1395
- const VUE_BUILTINS = new Set([
1387
+ const VUE_BUILTINS = /* @__PURE__ */ new Set([
1396
1388
  "Transition",
1397
1389
  "TransitionGroup",
1398
1390
  "KeepAlive",
@@ -1403,7 +1395,7 @@ const VUE_BUILTINS = new Set([
1403
1395
  "Template",
1404
1396
  "ClientOnly"
1405
1397
  ]);
1406
- const NUXT_BUILTINS = new Set([
1398
+ const NUXT_BUILTINS = /* @__PURE__ */ new Set([
1407
1399
  "NuxtPage",
1408
1400
  "NuxtLink",
1409
1401
  "NuxtLayout",
@@ -1454,7 +1446,7 @@ function scopeForFile(abs, roots, cwd) {
1454
1446
  return best;
1455
1447
  }
1456
1448
  function buildKnownSet(root) {
1457
- const known = new Set([...VUE_BUILTINS, ...NUXT_BUILTINS]);
1449
+ const known = /* @__PURE__ */ new Set([...VUE_BUILTINS, ...NUXT_BUILTINS]);
1458
1450
  for (const c of listComponents(root, {
1459
1451
  source: "auto",
1460
1452
  warn: () => {}
@@ -1465,7 +1457,7 @@ function buildKnownSet(root) {
1465
1457
  return known;
1466
1458
  }
1467
1459
  function buildUnionKnownSet(roots, cwd) {
1468
- const known = new Set([...VUE_BUILTINS, ...NUXT_BUILTINS]);
1460
+ const known = /* @__PURE__ */ new Set([...VUE_BUILTINS, ...NUXT_BUILTINS]);
1469
1461
  const sources = roots.length ? roots : [cwd];
1470
1462
  for (const root of sources) for (const c of listComponents(root, {
1471
1463
  source: "auto",
@@ -1664,7 +1656,8 @@ function findStaleNuxtConfigRefs(cwd) {
1664
1656
  if (importsMatch) for (const lit of importsMatch[1].matchAll(/['"`]([^'"`]+)['"`]/g)) {
1665
1657
  const value = lit[1];
1666
1658
  if (!value.startsWith(".") && !value.startsWith("/")) continue;
1667
- if (existsSync(resolve(root, value.replace(/\/\*\*.*$/, "").replace(/\/\*.*$/, "")))) continue;
1659
+ const dirPath = resolve(root, value.replace(/\/\*\*.*$/, "").replace(/\/\*.*$/, ""));
1660
+ if (existsSync(dirPath)) continue;
1668
1661
  out.push({
1669
1662
  check: "stale-nuxt-config-ref",
1670
1663
  file: rel,
@@ -1679,7 +1672,8 @@ function findStaleNuxtConfigRefs(cwd) {
1679
1672
  for (const m of source.matchAll(COMPONENT_PATH_RE)) {
1680
1673
  const value = m[1];
1681
1674
  if (!value.startsWith(".") && !value.startsWith("/")) continue;
1682
- if (existsSync(resolve(root, value.replace(/\/\*\*.*$/, "").replace(/\/\*.*$/, "")))) continue;
1675
+ const dirPath = resolve(root, value.replace(/\/\*\*.*$/, "").replace(/\/\*.*$/, ""));
1676
+ if (existsSync(dirPath)) continue;
1683
1677
  out.push({
1684
1678
  check: "stale-nuxt-config-ref",
1685
1679
  file: rel,
@@ -1872,7 +1866,7 @@ function rewriteResolveComponentSites(cwd, oldName, newName, changes, oldAbs, ne
1872
1866
  return out;
1873
1867
  }
1874
1868
  function addExplicitComponentImports(cwd, oldName, newName, newAbs, changes, oldAbs) {
1875
- const tokens = new Set([
1869
+ const tokens = /* @__PURE__ */ new Set([
1876
1870
  oldName,
1877
1871
  newName,
1878
1872
  hyphenateVueName(oldName),
@@ -1911,7 +1905,7 @@ function escapeRe(s) {
1911
1905
  function rewriteIsAttributeSites(cwd, oldName, newName, changes, oldAbs, newAbs, warnings) {
1912
1906
  const oldKebab = hyphenateVueName(oldName);
1913
1907
  const newKebab = hyphenateVueName(newName);
1914
- const candidates = new Set([...rgFiles(oldName, {
1908
+ const candidates = /* @__PURE__ */ new Set([...rgFiles(oldName, {
1915
1909
  cwd,
1916
1910
  glob: "*.vue"
1917
1911
  }), ...rgFiles(oldKebab, {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@ripast/vue",
3
3
  "type": "module",
4
- "version": "0.4.0",
4
+ "version": "0.5.0",
5
5
  "description": "Vue (and Nuxt) framework adapter for ripast. Provides Volar/Vue Language Service-backed rename, move, and template rewriting for .vue SFCs.",
6
6
  "author": {
7
7
  "name": "Harlan Wilton",
@@ -28,34 +28,34 @@
28
28
  ],
29
29
  "exports": {
30
30
  ".": {
31
- "types": "./dist/index.d.ts",
31
+ "types": "./dist/index.d.mts",
32
32
  "import": "./dist/index.mjs"
33
33
  }
34
34
  },
35
35
  "main": "./dist/index.mjs",
36
- "types": "./dist/index.d.ts",
36
+ "types": "./dist/index.d.mts",
37
37
  "files": [
38
38
  "dist"
39
39
  ],
40
40
  "engines": {
41
- "node": ">=20.11"
41
+ "node": ">=22.13"
42
42
  },
43
43
  "peerDependencies": {
44
- "typescript": ">=5.4",
45
- "@ripast/core": "0.4.0"
44
+ "@ripast/core": "0.5.0"
46
45
  },
47
46
  "dependencies": {
47
+ "@typescript/typescript6": "^6.0.2",
48
48
  "@volar/language-service": "^2.4.28",
49
49
  "@volar/typescript": "^2.4.28",
50
- "@vue/language-core": "^3.2.8",
51
- "@vue/language-service": "^3.2.8",
50
+ "@vue/language-core": "^3.3.12",
51
+ "@vue/language-service": "^3.3.12",
52
52
  "volar-service-typescript": "^0.0.71",
53
- "vscode-languageserver-protocol": "3.17.5",
54
- "vscode-languageserver-textdocument": "^1.0.12",
55
- "vscode-uri": "^3.1.0"
53
+ "vscode-languageserver-protocol": "3.18.4",
54
+ "vscode-languageserver-textdocument": "^1.0.15",
55
+ "vscode-uri": "^3.2.0"
56
56
  },
57
57
  "devDependencies": {
58
- "@ripast/core": "0.4.0"
58
+ "@ripast/core": "0.5.0"
59
59
  },
60
60
  "scripts": {
61
61
  "build": "obuild",