@eventra_dev/eventra-cli 0.1.18 → 0.1.20

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.
@@ -24,14 +24,19 @@ async function check({ fix = false }) {
24
24
  for (const file of files) {
25
25
  try {
26
26
  const raw = await promises_1.default.readFile(file, "utf-8");
27
- const { content, virtualFile } = (0, processFile_1.processFile)(file, raw);
27
+ const { content, virtualFile, deps } = (0, processFile_1.processFile)(file, raw);
28
28
  engine.scanFile(virtualFile, content, config);
29
+ for (const dep of deps) {
30
+ try {
31
+ const depRaw = await promises_1.default.readFile(dep, "utf-8");
32
+ const { content: depContent, virtualFile: depVirtual, } = (0, processFile_1.processFile)(dep, depRaw);
33
+ engine.scanFile(depVirtual, depContent, config);
34
+ }
35
+ catch { }
36
+ }
29
37
  }
30
38
  catch (err) {
31
39
  console.log(chalk_1.default.yellow(`Skipped: ${file}`));
32
- if (err instanceof Error) {
33
- console.log(chalk_1.default.gray(err.message));
34
- }
35
40
  }
36
41
  }
37
42
  const found = new Set(engine.getAllEvents());
@@ -29,13 +29,21 @@ async function sync() {
29
29
  for (const file of files) {
30
30
  try {
31
31
  const raw = await promises_1.default.readFile(file, "utf-8");
32
- const { content, virtualFile } = (0, processFile_1.processFile)(file, raw);
32
+ const { content, virtualFile, deps } = (0, processFile_1.processFile)(file, raw);
33
33
  engine["ts"].updateFile(virtualFile, content);
34
34
  fileCache.push({ file: virtualFile, content });
35
+ // deps
36
+ for (const dep of deps) {
37
+ try {
38
+ const depRaw = await promises_1.default.readFile(dep, "utf-8");
39
+ const { content: depContent, virtualFile: depVirtual, } = (0, processFile_1.processFile)(dep, depRaw);
40
+ engine["ts"].updateFile(depVirtual, depContent);
41
+ fileCache.push({ file: depVirtual, content: depContent });
42
+ }
43
+ catch { }
44
+ }
35
45
  }
36
- catch {
37
- // ignore
38
- }
46
+ catch { }
39
47
  }
40
48
  for (const { file, content } of fileCache) {
41
49
  try {
@@ -53,8 +53,17 @@ async function watch() {
53
53
  for (const file of batch) {
54
54
  try {
55
55
  const raw = await promises_1.default.readFile(file, "utf-8");
56
- const { content, virtualFile } = (0, processFile_1.processFile)(file, raw);
56
+ const { content, virtualFile, deps } = (0, processFile_1.processFile)(file, raw);
57
57
  engine.updateFile(virtualFile, content, config);
58
+ // deps
59
+ for (const dep of deps) {
60
+ try {
61
+ const depRaw = await promises_1.default.readFile(dep, "utf-8");
62
+ const { content: depContent, virtualFile: depVirtual, } = (0, processFile_1.processFile)(dep, depRaw);
63
+ engine.updateFile(depVirtual, depContent, config);
64
+ }
65
+ catch { }
66
+ }
58
67
  }
59
68
  catch {
60
69
  console.log(chalk_1.default.gray(`skip: ${file}`));
@@ -5,29 +5,45 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.parseAstro = parseAstro;
7
7
  const path_1 = __importDefault(require("path"));
8
+ const utils_1 = require("./utils");
8
9
  function parseAstro(content, file) {
9
10
  const parts = [];
11
+ const deps = [];
10
12
  // frontmatter
11
13
  const frontmatter = content.match(/^---([\s\S]*?)---/);
12
14
  if (frontmatter?.[1]) {
13
15
  parts.push(frontmatter[1]);
14
16
  }
17
+ // scripts
15
18
  const scripts = content.matchAll(/<script([^>]*)>([\s\S]*?)<\/script>/g);
16
19
  for (const m of scripts) {
17
20
  const attrs = m[1];
18
21
  const body = m[2];
22
+ // external script
19
23
  if (attrs.includes("src")) {
20
24
  const src = attrs.match(/src=["'](.+?)["']/)?.[1];
21
25
  if (!src)
22
26
  continue;
23
- const resolved = src.startsWith("/")
24
- ? path_1.default.resolve(process.cwd(), src.slice(1))
25
- : path_1.default.resolve(path_1.default.dirname(file), src);
26
- parts.push(`import "${resolved}"`);
27
+ let resolved;
28
+ if (src.startsWith("/")) {
29
+ resolved = path_1.default.join(process.cwd(), src); // FIX
30
+ }
31
+ else {
32
+ resolved = path_1.default.resolve(path_1.default.dirname(file), src);
33
+ }
34
+ deps.push(resolved);
35
+ continue;
27
36
  }
28
- else {
29
- parts.push(body);
37
+ parts.push(body);
38
+ const imports = body.matchAll(/import\s+.*?from\s+["'](.+?)["']/g);
39
+ for (const im of imports) {
40
+ const resolved = (0, utils_1.resolveImport)(file, im[1]);
41
+ if (resolved)
42
+ deps.push(resolved);
30
43
  }
31
44
  }
32
- return parts.join("\n");
45
+ return {
46
+ code: parts.join("\n"),
47
+ deps,
48
+ };
33
49
  }
@@ -4,7 +4,10 @@ exports.detectParser = detectParser;
4
4
  const vue_1 = require("./vue");
5
5
  const svelte_1 = require("./svelte");
6
6
  const astro_1 = require("./astro");
7
- const fallback = (content) => content;
7
+ const fallback = (content) => ({
8
+ code: content,
9
+ deps: [],
10
+ });
8
11
  function detectParser(file) {
9
12
  const f = file.toLowerCase();
10
13
  if (f.endsWith(".vue"))
@@ -1,31 +1,30 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
6
3
  exports.parseSvelte = parseSvelte;
7
- const path_1 = __importDefault(require("path"));
4
+ const utils_1 = require("./utils");
8
5
  function parseSvelte(content, file) {
9
6
  const parts = [];
10
- const scripts = content.matchAll(/<script([^>]*)>([\s\S]*?)<\/script>/g);
7
+ const deps = [];
8
+ // script
9
+ const scripts = content.matchAll(/<script[^>]*>([\s\S]*?)<\/script>/g);
11
10
  for (const m of scripts) {
12
- const attrs = m[1];
13
- const body = m[2];
14
- if (attrs.includes("src")) {
15
- const src = attrs.match(/src=["'](.+?)["']/)?.[1];
16
- if (!src)
17
- continue;
18
- const resolved = src.startsWith("/")
19
- ? path_1.default.resolve(process.cwd(), src.slice(1))
20
- : path_1.default.resolve(path_1.default.dirname(file), src);
21
- parts.push(`import "${resolved}"`);
22
- continue;
11
+ const code = m[1];
12
+ parts.push(code);
13
+ // imports
14
+ const imports = code.matchAll(/import\s+.*?from\s+["'](.+?)["']/g);
15
+ for (const im of imports) {
16
+ const resolved = (0, utils_1.resolveImport)(file, im[1]);
17
+ if (resolved)
18
+ deps.push(resolved);
23
19
  }
24
- parts.push(body);
25
20
  }
26
21
  // handlers
27
- for (const h of content.matchAll(/on:\w+=\{([^}]+)\}/g)) {
28
- parts.push(`${h[1]}();`);
22
+ const handlers = content.matchAll(/on:\w+=\{([^}]+)\}/g);
23
+ for (const h of handlers) {
24
+ parts.push(h[1] + ";");
29
25
  }
30
- return parts.join("\n");
26
+ return {
27
+ code: parts.join("\n"),
28
+ deps,
29
+ };
31
30
  }
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.resolveImport = resolveImport;
7
+ const fs_1 = __importDefault(require("fs"));
8
+ const path_1 = __importDefault(require("path"));
9
+ function resolveImport(from, src) {
10
+ if (!src.startsWith("."))
11
+ return null;
12
+ const base = path_1.default.resolve(path_1.default.dirname(from), src);
13
+ const exts = [".ts", ".tsx", ".js", ".jsx"];
14
+ for (const ext of exts) {
15
+ if (fs_1.default.existsSync(base + ext))
16
+ return base + ext;
17
+ }
18
+ if (fs_1.default.existsSync(base))
19
+ return base;
20
+ return null;
21
+ }
@@ -5,37 +5,55 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.parseVue = parseVue;
7
7
  const path_1 = __importDefault(require("path"));
8
+ const utils_1 = require("./utils");
8
9
  function parseVue(content, file) {
9
10
  const parts = [];
11
+ const deps = [];
12
+ // SCRIPT
10
13
  const scripts = content.matchAll(/<script([^>]*)>([\s\S]*?)<\/script>/g);
11
14
  for (const m of scripts) {
12
15
  const attrs = m[1];
13
16
  const body = m[2];
14
- // src
15
17
  if (attrs.includes("src")) {
16
18
  const src = attrs.match(/src=["'](.+?)["']/)?.[1];
17
19
  if (!src)
18
20
  continue;
19
21
  const resolved = src.startsWith("/")
20
- ? path_1.default.resolve(process.cwd(), src.slice(1))
22
+ ? path_1.default.join(process.cwd(), src)
21
23
  : path_1.default.resolve(path_1.default.dirname(file), src);
22
- parts.push(`import "${resolved}"`);
24
+ deps.push(resolved);
23
25
  continue;
24
26
  }
25
- // script setup
26
27
  parts.push(body);
28
+ // imports
29
+ const imports = body.matchAll(/import\s+.*?from\s+["'](.+?)["']/g);
30
+ for (const im of imports) {
31
+ const resolved = (0, utils_1.resolveImport)(file, im[1]);
32
+ if (resolved)
33
+ deps.push(resolved);
34
+ }
27
35
  }
28
36
  // TEMPLATE
29
37
  const templateMatch = content.match(/<template[^>]*>([\s\S]*?)<\/template>/);
30
38
  let template = templateMatch?.[1] ?? "";
31
39
  template = template.replace(/<!--[\s\S]*?-->/g, "");
32
40
  // @click
33
- for (const m of template.matchAll(/@[\w-]+="([^"]+)"/g)) {
34
- parts.push(`${m[1]}();`);
41
+ const handlers = template.matchAll(/@[\w-]+="([^"]+)"/g);
42
+ for (const h of handlers) {
43
+ parts.push(h[1] + ";");
35
44
  }
36
45
  // v-on
37
- for (const m of template.matchAll(/v-on:[\w-]+="([^"]+)"/g)) {
38
- parts.push(`${m[1]}();`);
46
+ const vOn = template.matchAll(/v-on:[\w-]+="([^"]+)"/g);
47
+ for (const v of vOn) {
48
+ parts.push(v[1] + ";");
49
+ }
50
+ // :bind
51
+ const binds = template.matchAll(/:[\w-]+="([^"]+)"/g);
52
+ for (const b of binds) {
53
+ parts.push(b[1] + ";");
39
54
  }
40
- return parts.join("\n");
55
+ return {
56
+ code: parts.join("\n"),
57
+ deps,
58
+ };
41
59
  }
@@ -1,18 +1,18 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
6
3
  exports.processFile = processFile;
7
- const path_1 = __importDefault(require("path"));
8
4
  const router_1 = require("./parsers/router");
9
5
  function processFile(file, content) {
10
- const abs = path_1.default.resolve(file);
11
- const parser = (0, router_1.detectParser)(abs);
12
- content = parser(content, abs);
13
- const isVirtual = file.endsWith(".vue") ||
6
+ const parser = (0, router_1.detectParser)(file);
7
+ const res = parser(content, file);
8
+ const virtualFile = file.endsWith(".vue") ||
14
9
  file.endsWith(".svelte") ||
15
- file.endsWith(".astro");
16
- const virtualFile = isVirtual ? abs + ".tsx" : abs;
17
- return { content, virtualFile };
10
+ file.endsWith(".astro")
11
+ ? file + ".tsx"
12
+ : file;
13
+ return {
14
+ content: res.code,
15
+ virtualFile,
16
+ deps: res.deps,
17
+ };
18
18
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eventra_dev/eventra-cli",
3
- "version": "0.1.18",
3
+ "version": "0.1.20",
4
4
  "description": "Eventra CLI",
5
5
  "type": "commonjs",
6
6
  "bin": {
@@ -25,16 +25,26 @@ export async function check({ fix = false }: { fix?: boolean }) {
25
25
  for (const file of files) {
26
26
  try {
27
27
  const raw = await fs.readFile(file, "utf-8");
28
- const { content, virtualFile } = processFile(file, raw);
28
+
29
+ const { content, virtualFile, deps } = processFile(file, raw);
29
30
 
30
31
  engine.scanFile(virtualFile, content, config);
31
32
 
32
- } catch (err) {
33
- console.log(chalk.yellow(`Skipped: ${file}`));
33
+ for (const dep of deps) {
34
+ try {
35
+ const depRaw = await fs.readFile(dep, "utf-8");
36
+
37
+ const {
38
+ content: depContent,
39
+ virtualFile: depVirtual,
40
+ } = processFile(dep, depRaw);
34
41
 
35
- if (err instanceof Error) {
36
- console.log(chalk.gray(err.message));
42
+ engine.scanFile(depVirtual, depContent, config);
43
+ } catch {}
37
44
  }
45
+
46
+ } catch (err) {
47
+ console.log(chalk.yellow(`Skipped: ${file}`));
38
48
  }
39
49
  }
40
50
 
@@ -31,12 +31,29 @@ export async function sync() {
31
31
  for (const file of files) {
32
32
  try {
33
33
  const raw = await fs.readFile(file, "utf-8");
34
- const { content, virtualFile } = processFile(file, raw);
34
+
35
+ const { content, virtualFile, deps } = processFile(file, raw);
36
+
35
37
  engine["ts"].updateFile(virtualFile, content);
36
38
  fileCache.push({ file: virtualFile, content });
37
- } catch {
38
- // ignore
39
- }
39
+
40
+ // deps
41
+ for (const dep of deps) {
42
+ try {
43
+ const depRaw = await fs.readFile(dep, "utf-8");
44
+
45
+ const {
46
+ content: depContent,
47
+ virtualFile: depVirtual,
48
+ } = processFile(dep, depRaw);
49
+
50
+ engine["ts"].updateFile(depVirtual, depContent);
51
+ fileCache.push({ file: depVirtual, content: depContent });
52
+
53
+ } catch {}
54
+ }
55
+
56
+ } catch {}
40
57
  }
41
58
 
42
59
  for (const { file, content } of fileCache) {
@@ -60,10 +60,26 @@ export async function watch() {
60
60
  for (const file of batch) {
61
61
  try {
62
62
  const raw = await fs.readFile(file, "utf-8");
63
- const { content, virtualFile } = processFile(file, raw);
63
+
64
+ const { content, virtualFile, deps } = processFile(file, raw);
64
65
 
65
66
  engine.updateFile(virtualFile, content, config);
66
67
 
68
+ // deps
69
+ for (const dep of deps) {
70
+ try {
71
+ const depRaw = await fs.readFile(dep, "utf-8");
72
+
73
+ const {
74
+ content: depContent,
75
+ virtualFile: depVirtual,
76
+ } = processFile(dep, depRaw);
77
+
78
+ engine.updateFile(depVirtual, depContent, config);
79
+
80
+ } catch {}
81
+ }
82
+
67
83
  } catch {
68
84
  console.log(chalk.gray(`skip: ${file}`));
69
85
  }
package/src/types.ts CHANGED
@@ -1,6 +1,12 @@
1
1
  export type ScanMode = "strict" | "hybrid" | "discovery";
2
2
 
3
- export type Parser = (content: string, file: string) => string;
3
+ export type ParseResult = {
4
+ code: string;
5
+ deps: string[];
6
+ };
7
+
8
+ export type Parser = (content: string, file: string) => ParseResult;
9
+
4
10
 
5
11
  export type ComponentWrapper = {
6
12
  name: string;
@@ -1,7 +1,10 @@
1
1
  import path from "path";
2
+ import { ParseResult } from "../../types";
3
+ import { resolveImport } from "./utils";
2
4
 
3
- export function parseAstro(content: string, file: string) {
5
+ export function parseAstro(content: string, file: string): ParseResult {
4
6
  const parts: string[] = [];
7
+ const deps: string[] = [];
5
8
 
6
9
  // frontmatter
7
10
  const frontmatter = content.match(/^---([\s\S]*?)---/);
@@ -9,25 +12,42 @@ export function parseAstro(content: string, file: string) {
9
12
  parts.push(frontmatter[1]);
10
13
  }
11
14
 
15
+ // scripts
12
16
  const scripts = content.matchAll(/<script([^>]*)>([\s\S]*?)<\/script>/g);
13
17
 
14
18
  for (const m of scripts) {
15
19
  const attrs = m[1];
16
20
  const body = m[2];
17
21
 
22
+ // external script
18
23
  if (attrs.includes("src")) {
19
24
  const src = attrs.match(/src=["'](.+?)["']/)?.[1];
20
25
  if (!src) continue;
21
26
 
22
- const resolved = src.startsWith("/")
23
- ? path.resolve(process.cwd(), src.slice(1))
24
- : path.resolve(path.dirname(file), src);
27
+ let resolved: string;
25
28
 
26
- parts.push(`import "${resolved}"`);
27
- } else {
28
- parts.push(body);
29
+ if (src.startsWith("/")) {
30
+ resolved = path.join(process.cwd(), src); // FIX
31
+ } else {
32
+ resolved = path.resolve(path.dirname(file), src);
33
+ }
34
+
35
+ deps.push(resolved);
36
+ continue;
37
+ }
38
+
39
+ parts.push(body);
40
+
41
+ const imports = body.matchAll(/import\s+.*?from\s+["'](.+?)["']/g);
42
+
43
+ for (const im of imports) {
44
+ const resolved = resolveImport(file, im[1]);
45
+ if (resolved) deps.push(resolved);
29
46
  }
30
47
  }
31
48
 
32
- return parts.join("\n");
49
+ return {
50
+ code: parts.join("\n"),
51
+ deps,
52
+ };
33
53
  }
@@ -3,7 +3,10 @@ import { parseVue } from "./vue";
3
3
  import { parseSvelte } from "./svelte";
4
4
  import { parseAstro } from "./astro";
5
5
 
6
- const fallback: Parser = (content) => content;
6
+ const fallback: Parser = (content) => ({
7
+ code: content,
8
+ deps: [],
9
+ });
7
10
 
8
11
  export function detectParser(file: string): Parser {
9
12
  const f = file.toLowerCase();
@@ -1,33 +1,36 @@
1
- import path from "path";
1
+ import { ParseResult } from "../../types";
2
+ import { resolveImport } from "./utils";
2
3
 
3
- export function parseSvelte(content: string, file: string) {
4
+ export function parseSvelte(content: string, file: string): ParseResult {
4
5
  const parts: string[] = [];
6
+ const deps: string[] = [];
5
7
 
6
- const scripts = content.matchAll(/<script([^>]*)>([\s\S]*?)<\/script>/g);
8
+ // script
9
+ const scripts = content.matchAll(/<script[^>]*>([\s\S]*?)<\/script>/g);
7
10
 
8
11
  for (const m of scripts) {
9
- const attrs = m[1];
10
- const body = m[2];
12
+ const code = m[1];
11
13
 
12
- if (attrs.includes("src")) {
13
- const src = attrs.match(/src=["'](.+?)["']/)?.[1];
14
- if (!src) continue;
14
+ parts.push(code);
15
15
 
16
- const resolved = src.startsWith("/")
17
- ? path.resolve(process.cwd(), src.slice(1))
18
- : path.resolve(path.dirname(file), src);
16
+ // imports
17
+ const imports = code.matchAll(/import\s+.*?from\s+["'](.+?)["']/g);
19
18
 
20
- parts.push(`import "${resolved}"`);
21
- continue;
19
+ for (const im of imports) {
20
+ const resolved = resolveImport(file, im[1]);
21
+ if (resolved) deps.push(resolved);
22
22
  }
23
-
24
- parts.push(body);
25
23
  }
26
24
 
27
25
  // handlers
28
- for (const h of content.matchAll(/on:\w+=\{([^}]+)\}/g)) {
29
- parts.push(`${h[1]}();`);
26
+ const handlers = content.matchAll(/on:\w+=\{([^}]+)\}/g);
27
+
28
+ for (const h of handlers) {
29
+ parts.push(h[1] + ";");
30
30
  }
31
31
 
32
- return parts.join("\n");
32
+ return {
33
+ code: parts.join("\n"),
34
+ deps,
35
+ };
33
36
  }
@@ -0,0 +1,18 @@
1
+ import fs from "fs";
2
+ import path from "path";
3
+
4
+ export function resolveImport(from: string, src: string): string | null {
5
+ if (!src.startsWith(".")) return null;
6
+
7
+ const base = path.resolve(path.dirname(from), src);
8
+
9
+ const exts = [".ts", ".tsx", ".js", ".jsx"];
10
+
11
+ for (const ext of exts) {
12
+ if (fs.existsSync(base + ext)) return base + ext;
13
+ }
14
+
15
+ if (fs.existsSync(base)) return base;
16
+
17
+ return null;
18
+ }
@@ -1,29 +1,39 @@
1
1
  import path from "path";
2
+ import { ParseResult } from "../../types";
3
+ import { resolveImport } from "./utils";
2
4
 
3
- export function parseVue(content: string, file: string) {
5
+ export function parseVue(content: string, file: string): ParseResult {
4
6
  const parts: string[] = [];
7
+ const deps: string[] = [];
5
8
 
9
+ // SCRIPT
6
10
  const scripts = content.matchAll(/<script([^>]*)>([\s\S]*?)<\/script>/g);
7
11
 
8
12
  for (const m of scripts) {
9
13
  const attrs = m[1];
10
14
  const body = m[2];
11
15
 
12
- // src
13
16
  if (attrs.includes("src")) {
14
17
  const src = attrs.match(/src=["'](.+?)["']/)?.[1];
15
18
  if (!src) continue;
16
19
 
17
20
  const resolved = src.startsWith("/")
18
- ? path.resolve(process.cwd(), src.slice(1))
21
+ ? path.join(process.cwd(), src)
19
22
  : path.resolve(path.dirname(file), src);
20
23
 
21
- parts.push(`import "${resolved}"`);
24
+ deps.push(resolved);
22
25
  continue;
23
26
  }
24
27
 
25
- // script setup
26
28
  parts.push(body);
29
+
30
+ // imports
31
+ const imports = body.matchAll(/import\s+.*?from\s+["'](.+?)["']/g);
32
+
33
+ for (const im of imports) {
34
+ const resolved = resolveImport(file, im[1]);
35
+ if (resolved) deps.push(resolved);
36
+ }
27
37
  }
28
38
 
29
39
  // TEMPLATE
@@ -33,14 +43,25 @@ export function parseVue(content: string, file: string) {
33
43
  template = template.replace(/<!--[\s\S]*?-->/g, "");
34
44
 
35
45
  // @click
36
- for (const m of template.matchAll(/@[\w-]+="([^"]+)"/g)) {
37
- parts.push(`${m[1]}();`);
46
+ const handlers = template.matchAll(/@[\w-]+="([^"]+)"/g);
47
+ for (const h of handlers) {
48
+ parts.push(h[1] + ";");
38
49
  }
39
50
 
40
51
  // v-on
41
- for (const m of template.matchAll(/v-on:[\w-]+="([^"]+)"/g)) {
42
- parts.push(`${m[1]}();`);
52
+ const vOn = template.matchAll(/v-on:[\w-]+="([^"]+)"/g);
53
+ for (const v of vOn) {
54
+ parts.push(v[1] + ";");
55
+ }
56
+
57
+ // :bind
58
+ const binds = template.matchAll(/:[\w-]+="([^"]+)"/g);
59
+ for (const b of binds) {
60
+ parts.push(b[1] + ";");
43
61
  }
44
62
 
45
- return parts.join("\n");
63
+ return {
64
+ code: parts.join("\n"),
65
+ deps,
66
+ };
46
67
  }
@@ -1,18 +1,20 @@
1
- import path from "path";
2
1
  import { detectParser } from "./parsers/router";
3
2
 
4
3
  export function processFile(file: string, content: string) {
5
- const abs = path.resolve(file);
4
+ const parser = detectParser(file);
6
5
 
7
- const parser = detectParser(abs);
8
- content = parser(content, abs);
6
+ const res = parser(content, file);
9
7
 
10
- const isVirtual =
8
+ const virtualFile =
11
9
  file.endsWith(".vue") ||
12
10
  file.endsWith(".svelte") ||
13
- file.endsWith(".astro");
11
+ file.endsWith(".astro")
12
+ ? file + ".tsx"
13
+ : file;
14
14
 
15
- const virtualFile = isVirtual ? abs + ".tsx" : abs;
16
-
17
- return { content, virtualFile };
15
+ return {
16
+ content: res.code,
17
+ virtualFile,
18
+ deps: res.deps,
19
+ };
18
20
  }