Skip to content

Commit dfa7925

Browse files
authored
feat: trace diagnostics (#9)
1 parent 438aca3 commit dfa7925

37 files changed

+11739
-204
lines changed

debug.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
pnpm ui:build --sourcemap &&
2+
pnpm build --sourcemap &&
3+
code ./playground --extensionDevelopmentPath=. --inspect-extensions 3300

messages/src/messages.ts

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
import z from 'zod'
2+
3+
export const ping = z.object({
4+
message: z.literal('ping'),
5+
})
6+
export type Ping = z.infer<typeof ping>
7+
8+
export const pong = z.object({
9+
message: z.literal('pong'),
10+
})
11+
export type Pong = z.infer<typeof pong>
12+
13+
export const gotoPosition = z.object({
14+
message: z.literal('gotoPosition'),
15+
fileName: z.string(),
16+
pos: z.number(),
17+
})
18+
export type GotoPosition = z.infer<typeof gotoPosition>
19+
20+
export const gotoLocation = z.object({
21+
message: z.literal('gotoLocation'),
22+
fileName: z.string(),
23+
line: z.number(),
24+
character: z.number(),
25+
})
26+
export type GotoLocation = z.infer<typeof gotoPosition>
27+
28+
export const traceFile = z.object({
29+
message: z.literal('traceFile'),
30+
fileName: z.string(),
31+
traceString: z.string(),
32+
})
33+
export type TraceFile = z.infer<typeof traceFile>
34+
35+
export const gotoTracePosition = z.object({
36+
message: z.literal('gotoTracePosition'),
37+
fileName: z.string(),
38+
position: z.number(),
39+
})
40+
export type GotoTracePosition = z.infer<typeof gotoTracePosition>
41+
42+
export const positionTypeCounts = z.object({
43+
message: z.literal('postionTypeCounts'),
44+
counts: z.record(z.string(), z.record(z.string(), z.number())),
45+
})
46+
export type PositionTypeCounts = z.infer<typeof positionTypeCounts>
47+
48+
export const fileStat = z.object({
49+
pos: z.number(),
50+
end: z.number(),
51+
dur: z.number(),
52+
types: z.number(),
53+
totalTypes: z.number(),
54+
})
55+
export type FileStat = z.infer<typeof fileStat>
56+
57+
export const fileStats = z.object({
58+
message: z.literal('fileStats'),
59+
fileName: z.string(),
60+
stats: z.array(fileStat),
61+
})
62+
export type FileStats = z.infer<typeof fileStats>
63+
64+
export type Message = z.infer<typeof message>
65+
export const message = z.union([ping, pong, gotoLocation, gotoPosition, traceFile, gotoTracePosition, positionTypeCounts, fileStats])

package.json

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,11 @@
5151
"Use tracer TypeScript path setting"
5252
]
5353
},
54+
"tsperf.tracer.traceCmd": {
55+
"type": "string",
56+
"default": "npx tsc --generateTrace ${traceDir}",
57+
"description": "command to generate tsc traces"
58+
},
5459
"tsperf.tracer.typescript-path": {
5560
"type": "string",
5661
"default": "",
@@ -76,7 +81,8 @@
7681
"commandPalette": [
7782
{
7883
"command": "tsperf.tracer.sendTrace",
79-
"when": "!notebookEditorFocused && editorLangId == 'json'"
84+
"when": "!notebookEditorFocused && editorLangId == 'json'",
85+
"group": "tracer"
8086
}
8187
],
8288
"commands": [
@@ -108,8 +114,11 @@
108114
]
109115
},
110116
"scripts": {
111-
"build": "rollup -c",
117+
"pretest": "nr build && nr lint",
118+
"build": "nr ui:build && rollup -c",
112119
"dev": "nr build --watch --sourcemap",
120+
"ui:dev": "nuxt dev ui",
121+
"ui:build": "nuxt build ui",
113122
"lint": "eslint .",
114123
"vscode:prepublish": "nr build",
115124
"publish": "vsce publish --no-dependencies",
@@ -136,6 +145,7 @@
136145
"rollup-plugin-esbuild": "^6.1.1",
137146
"rollup-plugin-vue": "^6.0.0",
138147
"typescript": "^5.4.5",
139-
"vitest": "^1.6.0"
148+
"vitest": "^1.6.0",
149+
"zod": "^3.23.8"
140150
}
141151
}

playground/traces/trace.json

Lines changed: 1511 additions & 0 deletions
Large diffs are not rendered by default.

playground/traces/types.json

Lines changed: 483 additions & 0 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)