@typeslayer/analyze-trace 0.1.13 → 0.1.15
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/browser.d.mts +3182 -0
- package/dist/browser.mjs +6 -0
- package/dist/browser.mjs.map +1 -0
- package/dist/index.d.mts +4315 -0
- package/dist/index.mjs +466 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +13 -11
- package/{tsup.config.ts → tsdown.config.ts} +1 -7
- package/dist/browser.d.ts +0 -3179
- package/dist/browser.js +0 -6
- package/dist/browser.js.map +0 -1
- package/dist/index.d.ts +0 -4307
- package/dist/index.js +0 -1591
- package/dist/index.js.map +0 -1
package/dist/index.js
DELETED
|
@@ -1,1591 +0,0 @@
|
|
|
1
|
-
// src/analyze-trace.ts
|
|
2
|
-
import { existsSync as existsSync3 } from "fs";
|
|
3
|
-
import { readFile as readFile2, writeFile } from "fs/promises";
|
|
4
|
-
import { join as join2 } from "path";
|
|
5
|
-
|
|
6
|
-
// ../validate/dist/index.js
|
|
7
|
-
import { z as z2 } from "zod/v4";
|
|
8
|
-
import { z } from "zod/v4";
|
|
9
|
-
import { z as z3 } from "zod/v4";
|
|
10
|
-
var packageNameRegex = /\/node_modules\/((?:[^@][^/]+)|(?:@[^/]+\/[^/]+))/g;
|
|
11
|
-
var typeId = z.number().int().positive().or(z.literal(-1));
|
|
12
|
-
var position = z.object({
|
|
13
|
-
line: typeId,
|
|
14
|
-
character: z.number()
|
|
15
|
-
});
|
|
16
|
-
var absolutePath = z.string();
|
|
17
|
-
var location = z.object({
|
|
18
|
-
path: absolutePath,
|
|
19
|
-
start: position,
|
|
20
|
-
end: position
|
|
21
|
-
});
|
|
22
|
-
var TRACE_JSON_FILENAME = "trace.json";
|
|
23
|
-
var eventPhase = {
|
|
24
|
-
begin: "B",
|
|
25
|
-
end: "E",
|
|
26
|
-
complete: "X",
|
|
27
|
-
metadata: "M",
|
|
28
|
-
instantGlobal: "I"
|
|
29
|
-
// 'i' is instantThread
|
|
30
|
-
};
|
|
31
|
-
var instantScope = {
|
|
32
|
-
thread: "t",
|
|
33
|
-
global: "g",
|
|
34
|
-
process: "p"
|
|
35
|
-
};
|
|
36
|
-
var durationEvent = {
|
|
37
|
-
ph: z2.union([z2.literal(eventPhase.begin), z2.literal(eventPhase.end)])
|
|
38
|
-
};
|
|
39
|
-
var completeEvent = {
|
|
40
|
-
ph: z2.literal(eventPhase.complete),
|
|
41
|
-
dur: z2.number().positive()
|
|
42
|
-
};
|
|
43
|
-
var instantEvent = {
|
|
44
|
-
ph: z2.literal(eventPhase.instantGlobal)
|
|
45
|
-
};
|
|
46
|
-
var category = {
|
|
47
|
-
parse: {
|
|
48
|
-
cat: z2.literal("parse")
|
|
49
|
-
},
|
|
50
|
-
program: {
|
|
51
|
-
cat: z2.literal("program")
|
|
52
|
-
},
|
|
53
|
-
bind: {
|
|
54
|
-
cat: z2.literal("bind")
|
|
55
|
-
},
|
|
56
|
-
check: {
|
|
57
|
-
cat: z2.literal("check")
|
|
58
|
-
},
|
|
59
|
-
checkTypes: {
|
|
60
|
-
cat: z2.literal("checkTypes")
|
|
61
|
-
},
|
|
62
|
-
emit: {
|
|
63
|
-
cat: z2.literal("emit")
|
|
64
|
-
},
|
|
65
|
-
session: {
|
|
66
|
-
cat: z2.literal("session")
|
|
67
|
-
}
|
|
68
|
-
};
|
|
69
|
-
var eventCommon = {
|
|
70
|
-
pid: z2.number().int().positive(),
|
|
71
|
-
tid: z2.number().int().positive(),
|
|
72
|
-
ts: z2.number().positive()
|
|
73
|
-
};
|
|
74
|
-
var event_metadata__TracingStartedInBrowser = z2.object({
|
|
75
|
-
...eventCommon,
|
|
76
|
-
cat: z2.literal("disabled-by-default-devtools.timeline"),
|
|
77
|
-
name: z2.literal("TracingStartedInBrowser"),
|
|
78
|
-
ph: z2.literal(eventPhase.metadata)
|
|
79
|
-
}).strict();
|
|
80
|
-
var event_metadata__process_name = z2.object({
|
|
81
|
-
...eventCommon,
|
|
82
|
-
ph: z2.literal(eventPhase.metadata),
|
|
83
|
-
args: z2.object({
|
|
84
|
-
name: z2.literal("tsc")
|
|
85
|
-
}),
|
|
86
|
-
cat: z2.literal("__metadata"),
|
|
87
|
-
name: z2.literal("process_name")
|
|
88
|
-
}).strict();
|
|
89
|
-
var event_metadata__thread_name = z2.object({
|
|
90
|
-
...eventCommon,
|
|
91
|
-
name: z2.literal("thread_name"),
|
|
92
|
-
cat: z2.literal("__metadata"),
|
|
93
|
-
ph: z2.literal(eventPhase.metadata),
|
|
94
|
-
args: z2.object({
|
|
95
|
-
name: z2.literal("Main")
|
|
96
|
-
})
|
|
97
|
-
}).strict();
|
|
98
|
-
var event_parse__createSourceFile = z2.object({
|
|
99
|
-
...eventCommon,
|
|
100
|
-
...category.parse,
|
|
101
|
-
...durationEvent,
|
|
102
|
-
name: z2.literal("createSourceFile"),
|
|
103
|
-
args: z2.object({
|
|
104
|
-
path: absolutePath
|
|
105
|
-
})
|
|
106
|
-
}).strict();
|
|
107
|
-
var event_parse__parseJsonSourceFileConfigFileContent = z2.object({
|
|
108
|
-
...eventCommon,
|
|
109
|
-
...category.parse,
|
|
110
|
-
...completeEvent,
|
|
111
|
-
name: z2.literal("parseJsonSourceFileConfigFileContent"),
|
|
112
|
-
args: z2.object({
|
|
113
|
-
path: absolutePath
|
|
114
|
-
})
|
|
115
|
-
}).strict();
|
|
116
|
-
var event_program__createProgram = z2.object({
|
|
117
|
-
...eventCommon,
|
|
118
|
-
...category.program,
|
|
119
|
-
...durationEvent,
|
|
120
|
-
name: z2.literal("createProgram"),
|
|
121
|
-
args: z2.object({
|
|
122
|
-
configFilePath: absolutePath
|
|
123
|
-
// path to the tsconfig.json file
|
|
124
|
-
})
|
|
125
|
-
}).strict();
|
|
126
|
-
var event_program__findSourceFile = z2.object({
|
|
127
|
-
...eventCommon,
|
|
128
|
-
...category.program,
|
|
129
|
-
...completeEvent,
|
|
130
|
-
name: z2.literal("findSourceFile"),
|
|
131
|
-
dur: z2.number(),
|
|
132
|
-
args: z2.object({
|
|
133
|
-
fileName: absolutePath,
|
|
134
|
-
fileIncludeKind: z2.union([
|
|
135
|
-
z2.literal("RootFile"),
|
|
136
|
-
z2.literal("Import"),
|
|
137
|
-
z2.literal("TypeReferenceDirective"),
|
|
138
|
-
z2.literal("LibFile"),
|
|
139
|
-
z2.literal("LibReferenceDirective"),
|
|
140
|
-
z2.literal("AutomaticTypeDirectiveFile"),
|
|
141
|
-
z2.literal("ReferenceFile")
|
|
142
|
-
])
|
|
143
|
-
})
|
|
144
|
-
}).strict();
|
|
145
|
-
var event_program__processRootFiles = z2.object({
|
|
146
|
-
...eventCommon,
|
|
147
|
-
...category.program,
|
|
148
|
-
...completeEvent,
|
|
149
|
-
name: z2.literal("processRootFiles"),
|
|
150
|
-
dur: z2.number(),
|
|
151
|
-
args: z2.object({ count: z2.number().int().positive() })
|
|
152
|
-
}).strict();
|
|
153
|
-
var event_program__processTypeReferenceDirective = z2.object({
|
|
154
|
-
...eventCommon,
|
|
155
|
-
...category.program,
|
|
156
|
-
...completeEvent,
|
|
157
|
-
name: z2.literal("processTypeReferenceDirective"),
|
|
158
|
-
dur: z2.number(),
|
|
159
|
-
args: z2.object({
|
|
160
|
-
directive: z2.string(),
|
|
161
|
-
hasResolved: z2.literal(true),
|
|
162
|
-
refKind: z2.number().int().positive(),
|
|
163
|
-
refPath: absolutePath.optional()
|
|
164
|
-
})
|
|
165
|
-
}).strict();
|
|
166
|
-
var event_program__processTypeReferences = z2.object({
|
|
167
|
-
...eventCommon,
|
|
168
|
-
...category.program,
|
|
169
|
-
...completeEvent,
|
|
170
|
-
name: z2.literal("processTypeReferences"),
|
|
171
|
-
dur: z2.number(),
|
|
172
|
-
args: z2.object({
|
|
173
|
-
count: z2.number().int().positive()
|
|
174
|
-
})
|
|
175
|
-
}).strict();
|
|
176
|
-
var event_program__resolveLibrary = z2.object({
|
|
177
|
-
...eventCommon,
|
|
178
|
-
...category.program,
|
|
179
|
-
...completeEvent,
|
|
180
|
-
name: z2.literal("resolveLibrary"),
|
|
181
|
-
args: z2.object({
|
|
182
|
-
resolveFrom: absolutePath
|
|
183
|
-
})
|
|
184
|
-
}).strict();
|
|
185
|
-
var event_program__resolveModuleNamesWorker = z2.object({
|
|
186
|
-
...eventCommon,
|
|
187
|
-
...category.program,
|
|
188
|
-
...completeEvent,
|
|
189
|
-
name: z2.literal("resolveModuleNamesWorker"),
|
|
190
|
-
args: z2.object({
|
|
191
|
-
containingFileName: absolutePath
|
|
192
|
-
})
|
|
193
|
-
}).strict();
|
|
194
|
-
var event_program__resolveTypeReferenceDirectiveNamesWorker = z2.object({
|
|
195
|
-
...eventCommon,
|
|
196
|
-
...category.program,
|
|
197
|
-
...completeEvent,
|
|
198
|
-
name: z2.literal("resolveTypeReferenceDirectiveNamesWorker"),
|
|
199
|
-
args: z2.object({
|
|
200
|
-
containingFileName: absolutePath
|
|
201
|
-
})
|
|
202
|
-
}).strict();
|
|
203
|
-
var event_program__shouldProgramCreateNewSourceFiles = z2.object({
|
|
204
|
-
...eventCommon,
|
|
205
|
-
...category.program,
|
|
206
|
-
...instantEvent,
|
|
207
|
-
name: z2.literal("shouldProgramCreateNewSourceFiles"),
|
|
208
|
-
s: z2.union([
|
|
209
|
-
z2.literal(instantScope.global),
|
|
210
|
-
z2.literal(instantScope.thread),
|
|
211
|
-
z2.literal(instantScope.process)
|
|
212
|
-
]),
|
|
213
|
-
args: z2.object({
|
|
214
|
-
hasOldProgram: z2.boolean()
|
|
215
|
-
})
|
|
216
|
-
}).strict();
|
|
217
|
-
var event_program__tryReuseStructureFromOldProgram = z2.object({
|
|
218
|
-
...eventCommon,
|
|
219
|
-
...category.program,
|
|
220
|
-
...completeEvent,
|
|
221
|
-
name: z2.literal("tryReuseStructureFromOldProgram"),
|
|
222
|
-
dur: z2.number(),
|
|
223
|
-
args: z2.object({})
|
|
224
|
-
}).strict();
|
|
225
|
-
var event_bind__bindSourceFile = z2.object({
|
|
226
|
-
...eventCommon,
|
|
227
|
-
...category.bind,
|
|
228
|
-
...durationEvent,
|
|
229
|
-
name: z2.literal("bindSourceFile"),
|
|
230
|
-
args: z2.object({
|
|
231
|
-
path: absolutePath
|
|
232
|
-
})
|
|
233
|
-
}).strict();
|
|
234
|
-
var event_check__checkExpression = z2.object({
|
|
235
|
-
...eventCommon,
|
|
236
|
-
...category.check,
|
|
237
|
-
...completeEvent,
|
|
238
|
-
name: z2.literal("checkExpression"),
|
|
239
|
-
dur: z2.number(),
|
|
240
|
-
args: z2.object({
|
|
241
|
-
kind: z2.number(),
|
|
242
|
-
pos: z2.number(),
|
|
243
|
-
end: z2.number(),
|
|
244
|
-
path: absolutePath.optional()
|
|
245
|
-
})
|
|
246
|
-
}).strict();
|
|
247
|
-
var event_check__checkSourceFile = z2.object({
|
|
248
|
-
...eventCommon,
|
|
249
|
-
...category.check,
|
|
250
|
-
...durationEvent,
|
|
251
|
-
name: z2.literal("checkSourceFile"),
|
|
252
|
-
args: z2.object({
|
|
253
|
-
path: absolutePath
|
|
254
|
-
})
|
|
255
|
-
}).strict();
|
|
256
|
-
var event_check__checkVariableDeclaration = z2.object({
|
|
257
|
-
...eventCommon,
|
|
258
|
-
...category.check,
|
|
259
|
-
...completeEvent,
|
|
260
|
-
name: z2.literal("checkVariableDeclaration"),
|
|
261
|
-
dur: z2.number(),
|
|
262
|
-
args: z2.object({
|
|
263
|
-
kind: z2.number(),
|
|
264
|
-
pos: z2.number(),
|
|
265
|
-
end: z2.number(),
|
|
266
|
-
path: absolutePath
|
|
267
|
-
})
|
|
268
|
-
}).strict();
|
|
269
|
-
var event_check__checkDeferredNode = z2.object({
|
|
270
|
-
...eventCommon,
|
|
271
|
-
...category.check,
|
|
272
|
-
...completeEvent,
|
|
273
|
-
name: z2.literal("checkDeferredNode"),
|
|
274
|
-
dur: z2.number(),
|
|
275
|
-
args: z2.object({
|
|
276
|
-
kind: z2.number(),
|
|
277
|
-
pos: z2.number(),
|
|
278
|
-
end: z2.number(),
|
|
279
|
-
path: absolutePath
|
|
280
|
-
})
|
|
281
|
-
}).strict();
|
|
282
|
-
var event_check__checkSourceFileNodes = z2.object({
|
|
283
|
-
...eventCommon,
|
|
284
|
-
...category.check,
|
|
285
|
-
...completeEvent,
|
|
286
|
-
name: z2.literal("checkSourceFileNodes"),
|
|
287
|
-
dur: z2.number(),
|
|
288
|
-
args: z2.object({
|
|
289
|
-
path: absolutePath
|
|
290
|
-
})
|
|
291
|
-
}).strict();
|
|
292
|
-
var event_checktypes__checkTypeParameterDeferred = z2.object({
|
|
293
|
-
...eventCommon,
|
|
294
|
-
...category.checkTypes,
|
|
295
|
-
...completeEvent,
|
|
296
|
-
name: z2.literal("checkTypeParameterDeferred"),
|
|
297
|
-
dur: z2.number(),
|
|
298
|
-
args: z2.object({
|
|
299
|
-
parent: typeId,
|
|
300
|
-
id: typeId
|
|
301
|
-
})
|
|
302
|
-
}).strict();
|
|
303
|
-
var event_checktypes__getVariancesWorker = z2.object({
|
|
304
|
-
...eventCommon,
|
|
305
|
-
...category.checkTypes,
|
|
306
|
-
...completeEvent,
|
|
307
|
-
name: z2.literal("getVariancesWorker"),
|
|
308
|
-
dur: z2.number(),
|
|
309
|
-
args: z2.object({
|
|
310
|
-
arity: z2.number().int().nonnegative(),
|
|
311
|
-
id: z2.number().int().positive(),
|
|
312
|
-
results: z2.object({
|
|
313
|
-
variances: z2.array(
|
|
314
|
-
z2.union([
|
|
315
|
-
z2.literal("[independent]"),
|
|
316
|
-
z2.literal("[independent] (unreliable)"),
|
|
317
|
-
z2.literal("[independent] (unmeasurable)"),
|
|
318
|
-
z2.literal("[bivariant]"),
|
|
319
|
-
z2.literal("[bivariant] (unreliable)"),
|
|
320
|
-
z2.literal("[bivariant] (unmeasurable)"),
|
|
321
|
-
z2.literal("in"),
|
|
322
|
-
z2.literal("in (unreliable)"),
|
|
323
|
-
z2.literal("in (unmeasurable)"),
|
|
324
|
-
z2.literal("out"),
|
|
325
|
-
z2.literal("out (unreliable)"),
|
|
326
|
-
z2.literal("out (unmeasurable)"),
|
|
327
|
-
z2.literal(
|
|
328
|
-
"in out"
|
|
329
|
-
/*burger*/
|
|
330
|
-
),
|
|
331
|
-
z2.literal("in out (unreliable)"),
|
|
332
|
-
z2.literal("in out (unmeasurable)")
|
|
333
|
-
])
|
|
334
|
-
)
|
|
335
|
-
})
|
|
336
|
-
})
|
|
337
|
-
}).strict();
|
|
338
|
-
var event_checktypes__structuredTypeRelatedTo = z2.object({
|
|
339
|
-
...eventCommon,
|
|
340
|
-
...category.checkTypes,
|
|
341
|
-
...completeEvent,
|
|
342
|
-
name: z2.literal("structuredTypeRelatedTo"),
|
|
343
|
-
args: z2.object({
|
|
344
|
-
sourceId: typeId,
|
|
345
|
-
targetId: typeId
|
|
346
|
-
})
|
|
347
|
-
}).strict();
|
|
348
|
-
var event_checktypes__checkCrossProductUnion_DepthLimit = z2.object({
|
|
349
|
-
...eventCommon,
|
|
350
|
-
...category.checkTypes,
|
|
351
|
-
...instantEvent,
|
|
352
|
-
name: z2.literal("checkCrossProductUnion_DepthLimit"),
|
|
353
|
-
s: z2.union([
|
|
354
|
-
z2.literal(instantScope.global),
|
|
355
|
-
z2.literal(instantScope.thread),
|
|
356
|
-
z2.literal(instantScope.process)
|
|
357
|
-
]),
|
|
358
|
-
args: z2.object({
|
|
359
|
-
types: z2.array(typeId),
|
|
360
|
-
size: z2.number().int().positive()
|
|
361
|
-
})
|
|
362
|
-
}).strict();
|
|
363
|
-
var event_checktypes__checkTypeRelatedTo_DepthLimit = z2.object({
|
|
364
|
-
...eventCommon,
|
|
365
|
-
...category.checkTypes,
|
|
366
|
-
...instantEvent,
|
|
367
|
-
name: z2.literal("checkTypeRelatedTo_DepthLimit"),
|
|
368
|
-
s: z2.union([
|
|
369
|
-
z2.literal(instantScope.global),
|
|
370
|
-
z2.literal(instantScope.thread),
|
|
371
|
-
z2.literal(instantScope.process)
|
|
372
|
-
]),
|
|
373
|
-
args: z2.object({
|
|
374
|
-
sourceId: typeId,
|
|
375
|
-
targetId: typeId,
|
|
376
|
-
depth: z2.number().int().positive(),
|
|
377
|
-
targetDepth: z2.number().int().positive()
|
|
378
|
-
})
|
|
379
|
-
}).strict();
|
|
380
|
-
var event_checktypes__getTypeAtFlowNode_DepthLimit = z2.object({
|
|
381
|
-
...eventCommon,
|
|
382
|
-
...category.checkTypes,
|
|
383
|
-
...instantEvent,
|
|
384
|
-
name: z2.literal("getTypeAtFlowNode_DepthLimit"),
|
|
385
|
-
s: z2.union([
|
|
386
|
-
z2.literal(instantScope.global),
|
|
387
|
-
z2.literal(instantScope.thread),
|
|
388
|
-
z2.literal(instantScope.process)
|
|
389
|
-
]),
|
|
390
|
-
args: z2.object({
|
|
391
|
-
flowId: z2.number().int().positive()
|
|
392
|
-
})
|
|
393
|
-
}).strict();
|
|
394
|
-
var event_checktypes__instantiateType_DepthLimit = z2.object({
|
|
395
|
-
...eventCommon,
|
|
396
|
-
...category.checkTypes,
|
|
397
|
-
...instantEvent,
|
|
398
|
-
name: z2.literal("instantiateType_DepthLimit"),
|
|
399
|
-
s: z2.union([
|
|
400
|
-
z2.literal(instantScope.global),
|
|
401
|
-
z2.literal(instantScope.thread),
|
|
402
|
-
z2.literal(instantScope.process)
|
|
403
|
-
]),
|
|
404
|
-
args: z2.object({
|
|
405
|
-
typeId,
|
|
406
|
-
instantiationDepth: z2.number().int(),
|
|
407
|
-
instantiationCount: z2.number().int().positive()
|
|
408
|
-
})
|
|
409
|
-
}).strict();
|
|
410
|
-
var event_checktypes__recursiveTypeRelatedTo_DepthLimit = z2.object({
|
|
411
|
-
...eventCommon,
|
|
412
|
-
...category.checkTypes,
|
|
413
|
-
...instantEvent,
|
|
414
|
-
name: z2.literal("recursiveTypeRelatedTo_DepthLimit"),
|
|
415
|
-
s: z2.union([
|
|
416
|
-
z2.literal(instantScope.global),
|
|
417
|
-
z2.literal(instantScope.thread),
|
|
418
|
-
z2.literal(instantScope.process)
|
|
419
|
-
]),
|
|
420
|
-
args: z2.object({
|
|
421
|
-
sourceId: typeId,
|
|
422
|
-
sourceIdStack: z2.array(typeId),
|
|
423
|
-
targetId: typeId,
|
|
424
|
-
targetIdStack: z2.array(typeId),
|
|
425
|
-
depth: z2.number().int().positive(),
|
|
426
|
-
targetDepth: z2.number().int().positive()
|
|
427
|
-
})
|
|
428
|
-
}).strict();
|
|
429
|
-
var event_checktypes__removeSubtypes_DepthLimit = z2.object({
|
|
430
|
-
...eventCommon,
|
|
431
|
-
...category.checkTypes,
|
|
432
|
-
...instantEvent,
|
|
433
|
-
name: z2.literal("removeSubtypes_DepthLimit"),
|
|
434
|
-
s: z2.union([
|
|
435
|
-
z2.literal(instantScope.global),
|
|
436
|
-
z2.literal(instantScope.thread),
|
|
437
|
-
z2.literal(instantScope.process)
|
|
438
|
-
]),
|
|
439
|
-
args: z2.object({
|
|
440
|
-
typeIds: z2.array(typeId)
|
|
441
|
-
})
|
|
442
|
-
}).strict();
|
|
443
|
-
var event_checktypes__traceUnionsOrIntersectionsTooLarge_DepthLimit = z2.object({
|
|
444
|
-
...eventCommon,
|
|
445
|
-
...category.checkTypes,
|
|
446
|
-
...instantEvent,
|
|
447
|
-
name: z2.literal("traceUnionsOrIntersectionsTooLarge_DepthLimit"),
|
|
448
|
-
s: z2.union([
|
|
449
|
-
z2.literal(instantScope.global),
|
|
450
|
-
z2.literal(instantScope.thread),
|
|
451
|
-
z2.literal(instantScope.process)
|
|
452
|
-
]),
|
|
453
|
-
args: z2.object({
|
|
454
|
-
sourceId: typeId,
|
|
455
|
-
sourceSize: z2.number().int().positive(),
|
|
456
|
-
targetId: typeId,
|
|
457
|
-
targetSize: z2.number().int().positive(),
|
|
458
|
-
pos: z2.number().int().nonnegative().optional(),
|
|
459
|
-
end: z2.number().int().positive().optional()
|
|
460
|
-
})
|
|
461
|
-
}).strict();
|
|
462
|
-
var event_checktypes__typeRelatedToDiscriminatedType_DepthLimit = z2.object({
|
|
463
|
-
...eventCommon,
|
|
464
|
-
...category.checkTypes,
|
|
465
|
-
...instantEvent,
|
|
466
|
-
name: z2.literal("typeRelatedToDiscriminatedType_DepthLimit"),
|
|
467
|
-
s: z2.union([
|
|
468
|
-
z2.literal(instantScope.global),
|
|
469
|
-
z2.literal(instantScope.thread),
|
|
470
|
-
z2.literal(instantScope.process)
|
|
471
|
-
]),
|
|
472
|
-
args: z2.object({
|
|
473
|
-
sourceId: typeId,
|
|
474
|
-
targetId: typeId,
|
|
475
|
-
numCombinations: z2.number().int().positive()
|
|
476
|
-
})
|
|
477
|
-
}).strict();
|
|
478
|
-
var depthLimits = [
|
|
479
|
-
event_checktypes__checkCrossProductUnion_DepthLimit,
|
|
480
|
-
event_checktypes__checkTypeRelatedTo_DepthLimit,
|
|
481
|
-
event_checktypes__getTypeAtFlowNode_DepthLimit,
|
|
482
|
-
event_checktypes__instantiateType_DepthLimit,
|
|
483
|
-
event_checktypes__recursiveTypeRelatedTo_DepthLimit,
|
|
484
|
-
event_checktypes__removeSubtypes_DepthLimit,
|
|
485
|
-
event_checktypes__traceUnionsOrIntersectionsTooLarge_DepthLimit,
|
|
486
|
-
event_checktypes__typeRelatedToDiscriminatedType_DepthLimit
|
|
487
|
-
];
|
|
488
|
-
var event_emit__emit = z2.object({
|
|
489
|
-
...eventCommon,
|
|
490
|
-
...category.emit,
|
|
491
|
-
...durationEvent,
|
|
492
|
-
name: z2.literal("emit"),
|
|
493
|
-
args: z2.object({})
|
|
494
|
-
// for some reason, this is empty
|
|
495
|
-
}).strict();
|
|
496
|
-
var event_emit__emitBuildInfo = z2.object({
|
|
497
|
-
...eventCommon,
|
|
498
|
-
...category.emit,
|
|
499
|
-
ph: z2.union([
|
|
500
|
-
z2.literal(eventPhase.begin),
|
|
501
|
-
z2.literal(eventPhase.end),
|
|
502
|
-
z2.literal(eventPhase.complete)
|
|
503
|
-
]),
|
|
504
|
-
dur: z2.number().positive().optional(),
|
|
505
|
-
name: z2.literal("emitBuildInfo"),
|
|
506
|
-
args: z2.union([
|
|
507
|
-
z2.object({}),
|
|
508
|
-
z2.object({
|
|
509
|
-
buildInfoPath: absolutePath
|
|
510
|
-
})
|
|
511
|
-
])
|
|
512
|
-
}).strict();
|
|
513
|
-
var event_emit__emitDeclarationFileOrBundle = z2.object({
|
|
514
|
-
...eventCommon,
|
|
515
|
-
...category.emit,
|
|
516
|
-
...completeEvent,
|
|
517
|
-
name: z2.literal("emitDeclarationFileOrBundle"),
|
|
518
|
-
dur: z2.number(),
|
|
519
|
-
args: z2.object({
|
|
520
|
-
declarationFilePath: absolutePath
|
|
521
|
-
})
|
|
522
|
-
}).strict();
|
|
523
|
-
var event_emit__emitJsFileOrBundle = z2.object({
|
|
524
|
-
...eventCommon,
|
|
525
|
-
...category.emit,
|
|
526
|
-
...completeEvent,
|
|
527
|
-
name: z2.literal("emitJsFileOrBundle"),
|
|
528
|
-
dur: z2.number(),
|
|
529
|
-
args: z2.object({
|
|
530
|
-
jsFilePath: absolutePath
|
|
531
|
-
})
|
|
532
|
-
}).strict();
|
|
533
|
-
var event_emit__transformNodes = z2.object({
|
|
534
|
-
...eventCommon,
|
|
535
|
-
...category.emit,
|
|
536
|
-
...completeEvent,
|
|
537
|
-
name: z2.literal("transformNodes"),
|
|
538
|
-
args: z2.object({
|
|
539
|
-
path: absolutePath
|
|
540
|
-
})
|
|
541
|
-
}).strict();
|
|
542
|
-
var event_session__cancellationThrown = z2.object({
|
|
543
|
-
...eventCommon,
|
|
544
|
-
...category.session,
|
|
545
|
-
...instantEvent,
|
|
546
|
-
name: z2.literal("cancellationThrown"),
|
|
547
|
-
args: z2.object({
|
|
548
|
-
kind: z2.union([
|
|
549
|
-
z2.literal("CancellationTokenObject"),
|
|
550
|
-
z2.literal("ThrotledCancellationToken")
|
|
551
|
-
])
|
|
552
|
-
})
|
|
553
|
-
}).strict();
|
|
554
|
-
var event_session__commandCanceled = z2.object({
|
|
555
|
-
...eventCommon,
|
|
556
|
-
...category.session,
|
|
557
|
-
...instantEvent,
|
|
558
|
-
name: z2.literal("commandCanceled"),
|
|
559
|
-
args: z2.object({
|
|
560
|
-
seq: z2.number().int().nonnegative(),
|
|
561
|
-
command: z2.string()
|
|
562
|
-
})
|
|
563
|
-
}).strict();
|
|
564
|
-
var event_session__commandError = z2.object({
|
|
565
|
-
...eventCommon,
|
|
566
|
-
...category.session,
|
|
567
|
-
...instantEvent,
|
|
568
|
-
name: z2.literal("commandError"),
|
|
569
|
-
args: z2.object({
|
|
570
|
-
seq: z2.number().int().nonnegative(),
|
|
571
|
-
command: z2.string(),
|
|
572
|
-
message: z2.string()
|
|
573
|
-
})
|
|
574
|
-
}).strict();
|
|
575
|
-
var event_session__createConfiguredProject = z2.object({
|
|
576
|
-
...eventCommon,
|
|
577
|
-
...category.session,
|
|
578
|
-
...instantEvent,
|
|
579
|
-
name: z2.literal("createConfiguredProject"),
|
|
580
|
-
args: z2.object({
|
|
581
|
-
configFilePath: absolutePath
|
|
582
|
-
})
|
|
583
|
-
}).strict();
|
|
584
|
-
var event_session__createdDocumentRegistryBucket = z2.object({
|
|
585
|
-
...eventCommon,
|
|
586
|
-
...category.session,
|
|
587
|
-
...instantEvent,
|
|
588
|
-
name: z2.literal("createdDocumentRegistryBucket"),
|
|
589
|
-
args: z2.object({
|
|
590
|
-
configFilePath: absolutePath,
|
|
591
|
-
key: z2.string()
|
|
592
|
-
})
|
|
593
|
-
}).strict();
|
|
594
|
-
var event_session__documentRegistryBucketOverlap = z2.object({
|
|
595
|
-
...eventCommon,
|
|
596
|
-
...category.session,
|
|
597
|
-
...instantEvent,
|
|
598
|
-
name: z2.literal("documentRegistryBucketOverlap"),
|
|
599
|
-
args: z2.object({
|
|
600
|
-
path: absolutePath,
|
|
601
|
-
key1: z2.string(),
|
|
602
|
-
key2: z2.string()
|
|
603
|
-
})
|
|
604
|
-
}).strict();
|
|
605
|
-
var event_session__executeCommand = z2.object({
|
|
606
|
-
...eventCommon,
|
|
607
|
-
...category.session,
|
|
608
|
-
...durationEvent,
|
|
609
|
-
name: z2.literal("executeCommand"),
|
|
610
|
-
args: z2.object({
|
|
611
|
-
seq: z2.number().int().nonnegative(),
|
|
612
|
-
command: z2.string()
|
|
613
|
-
})
|
|
614
|
-
}).strict();
|
|
615
|
-
var event_session__finishCachingPerDirectoryResolution = z2.object({
|
|
616
|
-
...eventCommon,
|
|
617
|
-
...category.session,
|
|
618
|
-
...instantEvent,
|
|
619
|
-
name: z2.literal("finishCachingPerDirectoryResolution"),
|
|
620
|
-
s: z2.union([
|
|
621
|
-
z2.literal(instantScope.global),
|
|
622
|
-
z2.literal(instantScope.thread),
|
|
623
|
-
z2.literal(instantScope.process)
|
|
624
|
-
])
|
|
625
|
-
}).strict();
|
|
626
|
-
var event_session__getPackageJsonAutoImportProvider = z2.object({
|
|
627
|
-
...eventCommon,
|
|
628
|
-
...category.session,
|
|
629
|
-
...completeEvent,
|
|
630
|
-
name: z2.literal("getPackageJsonAutoImportProvider")
|
|
631
|
-
}).strict();
|
|
632
|
-
var event_session__getUnresolvedImports = z2.object({
|
|
633
|
-
...eventCommon,
|
|
634
|
-
...category.session,
|
|
635
|
-
...completeEvent,
|
|
636
|
-
name: z2.literal("getUnresolvedImports"),
|
|
637
|
-
args: z2.object({
|
|
638
|
-
count: z2.number().int().nonnegative()
|
|
639
|
-
})
|
|
640
|
-
}).strict();
|
|
641
|
-
var event_session__loadConfiguredProject = z2.object({
|
|
642
|
-
...eventCommon,
|
|
643
|
-
...category.session,
|
|
644
|
-
...durationEvent,
|
|
645
|
-
name: z2.literal("loadConfiguredProject"),
|
|
646
|
-
args: z2.object({
|
|
647
|
-
configFilePath: absolutePath
|
|
648
|
-
})
|
|
649
|
-
}).strict();
|
|
650
|
-
var event_session__regionSemanticCheck = z2.object({
|
|
651
|
-
...eventCommon,
|
|
652
|
-
...category.session,
|
|
653
|
-
...durationEvent,
|
|
654
|
-
name: z2.literal("regionSemanticCheck"),
|
|
655
|
-
args: z2.object({
|
|
656
|
-
file: absolutePath,
|
|
657
|
-
configFilePath: absolutePath
|
|
658
|
-
})
|
|
659
|
-
}).strict();
|
|
660
|
-
var event_session__request = z2.object({
|
|
661
|
-
...eventCommon,
|
|
662
|
-
...category.session,
|
|
663
|
-
...instantEvent,
|
|
664
|
-
name: z2.literal("request"),
|
|
665
|
-
args: z2.object({
|
|
666
|
-
seq: z2.number().int().nonnegative(),
|
|
667
|
-
command: z2.string()
|
|
668
|
-
})
|
|
669
|
-
}).strict();
|
|
670
|
-
var event_session__response = z2.object({
|
|
671
|
-
...eventCommon,
|
|
672
|
-
...category.session,
|
|
673
|
-
...instantEvent,
|
|
674
|
-
name: z2.literal("response"),
|
|
675
|
-
args: z2.object({
|
|
676
|
-
seq: z2.number().int().nonnegative(),
|
|
677
|
-
command: z2.string(),
|
|
678
|
-
success: z2.boolean()
|
|
679
|
-
})
|
|
680
|
-
}).strict();
|
|
681
|
-
var event_session__semanticCheck = z2.object({
|
|
682
|
-
...eventCommon,
|
|
683
|
-
...category.session,
|
|
684
|
-
...durationEvent,
|
|
685
|
-
name: z2.literal("semanticCheck"),
|
|
686
|
-
args: z2.object({
|
|
687
|
-
file: absolutePath,
|
|
688
|
-
configFilePath: absolutePath
|
|
689
|
-
})
|
|
690
|
-
}).strict();
|
|
691
|
-
var event_session__stepAction = z2.object({
|
|
692
|
-
...eventCommon,
|
|
693
|
-
...category.session,
|
|
694
|
-
...instantEvent,
|
|
695
|
-
name: z2.literal("stepAction"),
|
|
696
|
-
s: z2.union([
|
|
697
|
-
z2.literal(instantScope.global),
|
|
698
|
-
z2.literal(instantScope.thread),
|
|
699
|
-
z2.literal(instantScope.process)
|
|
700
|
-
]),
|
|
701
|
-
args: z2.object({
|
|
702
|
-
seq: z2.number().int().nonnegative()
|
|
703
|
-
})
|
|
704
|
-
}).strict();
|
|
705
|
-
var event_session__stepCanceled = z2.object({
|
|
706
|
-
...eventCommon,
|
|
707
|
-
...category.session,
|
|
708
|
-
...instantEvent,
|
|
709
|
-
name: z2.literal("stepCanceled"),
|
|
710
|
-
args: z2.object({
|
|
711
|
-
seq: z2.number().int().nonnegative(),
|
|
712
|
-
early: z2.literal(true).optional()
|
|
713
|
-
})
|
|
714
|
-
}).strict();
|
|
715
|
-
var event_session__stepError = z2.object({
|
|
716
|
-
...eventCommon,
|
|
717
|
-
...category.session,
|
|
718
|
-
...instantEvent,
|
|
719
|
-
name: z2.literal("stepError"),
|
|
720
|
-
args: z2.object({
|
|
721
|
-
seq: z2.number().int().nonnegative(),
|
|
722
|
-
message: z2.string()
|
|
723
|
-
})
|
|
724
|
-
}).strict();
|
|
725
|
-
var event_session__suggestionCheck = z2.object({
|
|
726
|
-
...eventCommon,
|
|
727
|
-
...category.session,
|
|
728
|
-
...durationEvent,
|
|
729
|
-
name: z2.literal("suggestionCheck"),
|
|
730
|
-
args: z2.object({
|
|
731
|
-
file: absolutePath,
|
|
732
|
-
configFilePath: absolutePath
|
|
733
|
-
})
|
|
734
|
-
}).strict();
|
|
735
|
-
var event_session__syntacticCheck = z2.object({
|
|
736
|
-
...eventCommon,
|
|
737
|
-
...category.session,
|
|
738
|
-
...durationEvent,
|
|
739
|
-
name: z2.literal("syntacticCheck"),
|
|
740
|
-
args: z2.object({
|
|
741
|
-
file: absolutePath,
|
|
742
|
-
configFilePath: absolutePath
|
|
743
|
-
})
|
|
744
|
-
}).strict();
|
|
745
|
-
var event_session__updateGraph = z2.object({
|
|
746
|
-
...eventCommon,
|
|
747
|
-
...category.session,
|
|
748
|
-
...durationEvent,
|
|
749
|
-
name: z2.literal("updateGraph"),
|
|
750
|
-
args: z2.object({
|
|
751
|
-
name: z2.string(),
|
|
752
|
-
kind: z2.union([
|
|
753
|
-
z2.literal(0),
|
|
754
|
-
//"Inferred
|
|
755
|
-
z2.literal(1),
|
|
756
|
-
// Configured"
|
|
757
|
-
z2.literal(2),
|
|
758
|
-
// "Inferred"
|
|
759
|
-
z2.literal(3),
|
|
760
|
-
// "External"
|
|
761
|
-
z2.literal(4),
|
|
762
|
-
// "AutoImportProvider"
|
|
763
|
-
z2.literal(5)
|
|
764
|
-
// "Auxiliary"
|
|
765
|
-
])
|
|
766
|
-
})
|
|
767
|
-
}).strict();
|
|
768
|
-
var traceEvent = z2.discriminatedUnion(
|
|
769
|
-
"name",
|
|
770
|
-
[
|
|
771
|
-
event_metadata__TracingStartedInBrowser,
|
|
772
|
-
event_metadata__process_name,
|
|
773
|
-
event_metadata__thread_name,
|
|
774
|
-
event_parse__createSourceFile,
|
|
775
|
-
event_parse__parseJsonSourceFileConfigFileContent,
|
|
776
|
-
event_program__createProgram,
|
|
777
|
-
event_program__findSourceFile,
|
|
778
|
-
event_program__processRootFiles,
|
|
779
|
-
event_program__processTypeReferenceDirective,
|
|
780
|
-
event_program__processTypeReferences,
|
|
781
|
-
event_program__resolveLibrary,
|
|
782
|
-
event_program__resolveModuleNamesWorker,
|
|
783
|
-
event_program__resolveTypeReferenceDirectiveNamesWorker,
|
|
784
|
-
event_program__shouldProgramCreateNewSourceFiles,
|
|
785
|
-
event_program__tryReuseStructureFromOldProgram,
|
|
786
|
-
event_bind__bindSourceFile,
|
|
787
|
-
event_check__checkExpression,
|
|
788
|
-
event_check__checkSourceFile,
|
|
789
|
-
event_check__checkVariableDeclaration,
|
|
790
|
-
event_check__checkDeferredNode,
|
|
791
|
-
event_check__checkSourceFileNodes,
|
|
792
|
-
event_checktypes__checkTypeParameterDeferred,
|
|
793
|
-
event_checktypes__getVariancesWorker,
|
|
794
|
-
event_checktypes__structuredTypeRelatedTo,
|
|
795
|
-
...depthLimits,
|
|
796
|
-
event_emit__emit,
|
|
797
|
-
event_emit__emitBuildInfo,
|
|
798
|
-
event_emit__emitDeclarationFileOrBundle,
|
|
799
|
-
event_emit__emitJsFileOrBundle,
|
|
800
|
-
event_emit__transformNodes,
|
|
801
|
-
event_session__cancellationThrown,
|
|
802
|
-
event_session__commandCanceled,
|
|
803
|
-
event_session__commandError,
|
|
804
|
-
event_session__createConfiguredProject,
|
|
805
|
-
event_session__createdDocumentRegistryBucket,
|
|
806
|
-
event_session__documentRegistryBucketOverlap,
|
|
807
|
-
event_session__executeCommand,
|
|
808
|
-
event_session__finishCachingPerDirectoryResolution,
|
|
809
|
-
event_session__getPackageJsonAutoImportProvider,
|
|
810
|
-
event_session__getUnresolvedImports,
|
|
811
|
-
event_session__loadConfiguredProject,
|
|
812
|
-
event_session__regionSemanticCheck,
|
|
813
|
-
event_session__request,
|
|
814
|
-
event_session__response,
|
|
815
|
-
event_session__semanticCheck,
|
|
816
|
-
event_session__stepAction,
|
|
817
|
-
event_session__stepCanceled,
|
|
818
|
-
event_session__stepError,
|
|
819
|
-
event_session__suggestionCheck,
|
|
820
|
-
event_session__syntacticCheck,
|
|
821
|
-
event_session__updateGraph
|
|
822
|
-
],
|
|
823
|
-
{
|
|
824
|
-
// errorMap: (issue, ctx) => ({
|
|
825
|
-
// // prettier-ignore
|
|
826
|
-
// message: issue.code === "invalid_union_discriminator" ?
|
|
827
|
-
// `Invalid discriminator value. Expected ${issue.options.map(opt => `'${String(opt)}'`).join(' | ')}, got '${ctx.data.type}'.`
|
|
828
|
-
// : ctx.defaultError,
|
|
829
|
-
// }),
|
|
830
|
-
}
|
|
831
|
-
);
|
|
832
|
-
var traceJsonSchema = z2.array(traceEvent);
|
|
833
|
-
var ALL_LIFE_IS_SUFFERING_THAT_BASKS_IN_NOTHINGNESS___ALL_LIFE_IS_TEMPORARY___WHAT_LASTS_IS_CONSCIOUSNESS = [{ id: 0, recursionId: -1, flags: [] }];
|
|
834
|
-
var createTypeRegistry = (typesJson) => {
|
|
835
|
-
return ALL_LIFE_IS_SUFFERING_THAT_BASKS_IN_NOTHINGNESS___ALL_LIFE_IS_TEMPORARY___WHAT_LASTS_IS_CONSCIOUSNESS.concat(
|
|
836
|
-
typesJson
|
|
837
|
-
);
|
|
838
|
-
};
|
|
839
|
-
var TYPES_JSON_FILENAME = "types.json";
|
|
840
|
-
var flag = z3.enum([
|
|
841
|
-
"Any",
|
|
842
|
-
"Unknown",
|
|
843
|
-
"String",
|
|
844
|
-
"Number",
|
|
845
|
-
"Boolean",
|
|
846
|
-
"Enum",
|
|
847
|
-
"BigInt",
|
|
848
|
-
"StringLiteral",
|
|
849
|
-
"NumberLiteral",
|
|
850
|
-
"BooleanLiteral",
|
|
851
|
-
"EnumLiteral",
|
|
852
|
-
"BigIntLiteral",
|
|
853
|
-
"ESSymbol",
|
|
854
|
-
"UniqueESSymbol",
|
|
855
|
-
"Void",
|
|
856
|
-
"Undefined",
|
|
857
|
-
"Null",
|
|
858
|
-
"Never",
|
|
859
|
-
"TypeParameter",
|
|
860
|
-
"Object",
|
|
861
|
-
"Union",
|
|
862
|
-
"Intersection",
|
|
863
|
-
"Index",
|
|
864
|
-
"IndexedAccess",
|
|
865
|
-
"Conditional",
|
|
866
|
-
"Substitution",
|
|
867
|
-
"NonPrimitive",
|
|
868
|
-
"TemplateLiteral",
|
|
869
|
-
"StringMapping",
|
|
870
|
-
"Reserved1",
|
|
871
|
-
"Reserved2",
|
|
872
|
-
"AnyOrUnknown",
|
|
873
|
-
"Nullable",
|
|
874
|
-
"Literal",
|
|
875
|
-
"Unit",
|
|
876
|
-
"Freshable",
|
|
877
|
-
"StringOrNumberLiteral",
|
|
878
|
-
"StringOrNumberLiteralOrUnique",
|
|
879
|
-
"DefinitelyFalsy",
|
|
880
|
-
"PossiblyFalsy",
|
|
881
|
-
"Intrinsic",
|
|
882
|
-
"StringLike",
|
|
883
|
-
"NumberLike",
|
|
884
|
-
"BigIntLike",
|
|
885
|
-
"BooleanLike",
|
|
886
|
-
"EnumLike",
|
|
887
|
-
"ESSymbolLike",
|
|
888
|
-
"VoidLike",
|
|
889
|
-
"Primitive",
|
|
890
|
-
"DefinitelyNonNullable",
|
|
891
|
-
"DisjointDomains",
|
|
892
|
-
"UnionOrIntersection",
|
|
893
|
-
"StructuredType",
|
|
894
|
-
"TypeVariable",
|
|
895
|
-
"InstantiableNonPrimitive",
|
|
896
|
-
"InstantiablePrimitive",
|
|
897
|
-
"Instantiable",
|
|
898
|
-
"StructuredOrInstantiable",
|
|
899
|
-
"ObjectFlagsType",
|
|
900
|
-
"Simplifiable",
|
|
901
|
-
"Singleton",
|
|
902
|
-
"Narrowable",
|
|
903
|
-
"IncludesMask",
|
|
904
|
-
"IncludesMissingType",
|
|
905
|
-
"IncludesNonWideningType",
|
|
906
|
-
"IncludesWildcard",
|
|
907
|
-
"IncludesEmptyObject",
|
|
908
|
-
"IncludesInstantiable",
|
|
909
|
-
"IncludesConstrainedTypeVariable",
|
|
910
|
-
"IncludesError",
|
|
911
|
-
"NotPrimitiveUnion"
|
|
912
|
-
]);
|
|
913
|
-
var resolvedType = z3.object({
|
|
914
|
-
id: typeId,
|
|
915
|
-
flags: z3.array(flag),
|
|
916
|
-
recursionId: z3.number().optional(),
|
|
917
|
-
intrinsicName: z3.enum([
|
|
918
|
-
"any",
|
|
919
|
-
"error",
|
|
920
|
-
"unresolved",
|
|
921
|
-
"unknown",
|
|
922
|
-
"true",
|
|
923
|
-
"false",
|
|
924
|
-
"never",
|
|
925
|
-
"void",
|
|
926
|
-
"symbol",
|
|
927
|
-
"bigint",
|
|
928
|
-
"null",
|
|
929
|
-
"undefined",
|
|
930
|
-
"intrinsic",
|
|
931
|
-
"object",
|
|
932
|
-
"boolean",
|
|
933
|
-
"number",
|
|
934
|
-
"string"
|
|
935
|
-
]).optional(),
|
|
936
|
-
firstDeclaration: location.optional(),
|
|
937
|
-
referenceLocation: location.optional(),
|
|
938
|
-
destructuringPattern: location.optional(),
|
|
939
|
-
// TODO, awards for all of these
|
|
940
|
-
typeArguments: z3.array(typeId).optional(),
|
|
941
|
-
unionTypes: z3.array(typeId).optional(),
|
|
942
|
-
intersectionTypes: z3.array(typeId).optional(),
|
|
943
|
-
aliasTypeArguments: z3.array(typeId).optional(),
|
|
944
|
-
instantiatedType: typeId.optional(),
|
|
945
|
-
substitutionBaseType: typeId.optional(),
|
|
946
|
-
constraintType: typeId.optional(),
|
|
947
|
-
indexedAccessObjectType: typeId.optional(),
|
|
948
|
-
indexedAccessIndexType: typeId.optional(),
|
|
949
|
-
conditionalCheckType: typeId.optional(),
|
|
950
|
-
conditionalExtendsType: typeId.optional(),
|
|
951
|
-
conditionalTrueType: typeId.optional(),
|
|
952
|
-
conditionalFalseType: typeId.optional(),
|
|
953
|
-
keyofType: typeId.optional(),
|
|
954
|
-
aliasType: typeId.optional(),
|
|
955
|
-
evolvingArrayElementType: typeId.optional(),
|
|
956
|
-
evolvingArrayFinalType: typeId.optional(),
|
|
957
|
-
reverseMappedSourceType: typeId.optional(),
|
|
958
|
-
reverseMappedMappedType: typeId.optional(),
|
|
959
|
-
reverseMappedConstraintType: typeId.optional(),
|
|
960
|
-
isTuple: z3.literal(true).optional(),
|
|
961
|
-
symbolName: z3.string().optional(),
|
|
962
|
-
display: z3.string().optional()
|
|
963
|
-
}).strict();
|
|
964
|
-
var typesJsonSchema = z3.array(resolvedType);
|
|
965
|
-
|
|
966
|
-
// src/constants.ts
|
|
967
|
-
var ANALYZE_TRACE_FILENAME = "analyze-trace.json";
|
|
968
|
-
|
|
969
|
-
// src/depth-limits.ts
|
|
970
|
-
var createDepthLimits = (traceFile) => {
|
|
971
|
-
const limitNamesSet = new Set(
|
|
972
|
-
depthLimits.map((d) => d.shape.name)
|
|
973
|
-
);
|
|
974
|
-
const limitEvents = traceFile.filter((event) => limitNamesSet.has(event.name));
|
|
975
|
-
return {
|
|
976
|
-
checkCrossProductUnion_DepthLimit: limitEvents.filter(
|
|
977
|
-
(event) => event_checktypes__checkCrossProductUnion_DepthLimit.safeParse(event).success
|
|
978
|
-
).sort((a, b) => a.args.size - b.args.size),
|
|
979
|
-
checkTypeRelatedTo_DepthLimit: limitEvents.filter(
|
|
980
|
-
(event) => event_checktypes__checkTypeRelatedTo_DepthLimit.safeParse(event).success
|
|
981
|
-
).sort((a, b) => a.args.depth - b.args.depth),
|
|
982
|
-
getTypeAtFlowNode_DepthLimit: limitEvents.filter(
|
|
983
|
-
(event) => event_checktypes__getTypeAtFlowNode_DepthLimit.safeParse(event).success
|
|
984
|
-
).sort((a, b) => a.args.flowId - b.args.flowId),
|
|
985
|
-
instantiateType_DepthLimit: limitEvents.filter(
|
|
986
|
-
(event) => event_checktypes__instantiateType_DepthLimit.safeParse(event).success
|
|
987
|
-
).sort((a, b) => a.args.instantiationDepth - b.args.instantiationDepth),
|
|
988
|
-
recursiveTypeRelatedTo_DepthLimit: limitEvents.filter(
|
|
989
|
-
(event) => event_checktypes__recursiveTypeRelatedTo_DepthLimit.safeParse(event).success
|
|
990
|
-
).sort((a, b) => a.args.depth - b.args.depth),
|
|
991
|
-
removeSubtypes_DepthLimit: limitEvents.filter(
|
|
992
|
-
(event) => event_checktypes__removeSubtypes_DepthLimit.safeParse(event).success
|
|
993
|
-
),
|
|
994
|
-
traceUnionsOrIntersectionsTooLarge_DepthLimit: limitEvents.filter(
|
|
995
|
-
(event) => event_checktypes__traceUnionsOrIntersectionsTooLarge_DepthLimit.safeParse(
|
|
996
|
-
event
|
|
997
|
-
).success
|
|
998
|
-
).sort(
|
|
999
|
-
(a, b) => a.args.sourceSize * a.args.targetSize - b.args.sourceSize * b.args.targetSize
|
|
1000
|
-
),
|
|
1001
|
-
typeRelatedToDiscriminatedType_DepthLimit: limitEvents.filter(
|
|
1002
|
-
(event) => event_checktypes__typeRelatedToDiscriminatedType_DepthLimit.safeParse(
|
|
1003
|
-
event
|
|
1004
|
-
).success
|
|
1005
|
-
).sort((a, b) => a.args.numCombinations - b.args.numCombinations)
|
|
1006
|
-
};
|
|
1007
|
-
};
|
|
1008
|
-
|
|
1009
|
-
// src/get-duplicate-node-modules.ts
|
|
1010
|
-
import { existsSync } from "fs";
|
|
1011
|
-
import { readFile } from "fs/promises";
|
|
1012
|
-
import { join } from "path";
|
|
1013
|
-
async function getPackageVersion(packagePath2) {
|
|
1014
|
-
const packageJsonPath = join(packagePath2, "package.json");
|
|
1015
|
-
console.log("packageJsonPath", packageJsonPath);
|
|
1016
|
-
if (!existsSync(packageJsonPath)) {
|
|
1017
|
-
console.warn(
|
|
1018
|
-
`Package.json not found at ${packageJsonPath}. This may not be a node module.`
|
|
1019
|
-
);
|
|
1020
|
-
return "unknown";
|
|
1021
|
-
}
|
|
1022
|
-
const jsonString = await readFile(packageJsonPath, "utf-8");
|
|
1023
|
-
const jsonObj = JSON.parse(jsonString);
|
|
1024
|
-
return jsonObj.version;
|
|
1025
|
-
}
|
|
1026
|
-
var getDuplicateNodeModules = async (nodeModulePaths2) => {
|
|
1027
|
-
const duplicates = [];
|
|
1028
|
-
for (const [packageName2, packagePaths] of Object.entries(nodeModulePaths2)) {
|
|
1029
|
-
if (packagePaths.length < 2) {
|
|
1030
|
-
continue;
|
|
1031
|
-
}
|
|
1032
|
-
const instances = [];
|
|
1033
|
-
for (const packagePath2 of packagePaths) {
|
|
1034
|
-
instances.push({
|
|
1035
|
-
path: packagePath2,
|
|
1036
|
-
version: await getPackageVersion(packagePath2)
|
|
1037
|
-
});
|
|
1038
|
-
}
|
|
1039
|
-
duplicates.push({
|
|
1040
|
-
name: packageName2,
|
|
1041
|
-
instances
|
|
1042
|
-
});
|
|
1043
|
-
}
|
|
1044
|
-
return duplicates;
|
|
1045
|
-
};
|
|
1046
|
-
|
|
1047
|
-
// src/get-hotspots.ts
|
|
1048
|
-
import { normalize } from "path";
|
|
1049
|
-
var getHotspots = async (hotPathsTree, typesFile, options) => getHotspotsWorker({
|
|
1050
|
-
span: hotPathsTree,
|
|
1051
|
-
currentFile: void 0,
|
|
1052
|
-
typeRegistry: createTypeRegistry(typesFile),
|
|
1053
|
-
options
|
|
1054
|
-
});
|
|
1055
|
-
async function getHotspotsWorker({
|
|
1056
|
-
span,
|
|
1057
|
-
currentFile,
|
|
1058
|
-
typeRegistry,
|
|
1059
|
-
options
|
|
1060
|
-
}) {
|
|
1061
|
-
if (span.event.cat === "check") {
|
|
1062
|
-
currentFile = span.event.args.path;
|
|
1063
|
-
}
|
|
1064
|
-
const children = [];
|
|
1065
|
-
if (span.children.length) {
|
|
1066
|
-
const sortedChildren = span.children.sort(
|
|
1067
|
-
(a, b) => b.duration - a.duration
|
|
1068
|
-
);
|
|
1069
|
-
for (const child of sortedChildren) {
|
|
1070
|
-
children.push(
|
|
1071
|
-
...await getHotspotsWorker({
|
|
1072
|
-
span: child,
|
|
1073
|
-
currentFile,
|
|
1074
|
-
typeRegistry,
|
|
1075
|
-
options
|
|
1076
|
-
})
|
|
1077
|
-
);
|
|
1078
|
-
}
|
|
1079
|
-
}
|
|
1080
|
-
if (span.event.name !== "root") {
|
|
1081
|
-
const hotFrame = await makeHotFrame({
|
|
1082
|
-
span,
|
|
1083
|
-
children,
|
|
1084
|
-
typeRegistry
|
|
1085
|
-
});
|
|
1086
|
-
if (hotFrame) {
|
|
1087
|
-
return [hotFrame];
|
|
1088
|
-
}
|
|
1089
|
-
}
|
|
1090
|
-
return children;
|
|
1091
|
-
}
|
|
1092
|
-
var notFound = {
|
|
1093
|
-
children: [],
|
|
1094
|
-
resolvedType: {
|
|
1095
|
-
id: -1,
|
|
1096
|
-
display: "[Type Not Found]",
|
|
1097
|
-
flags: []
|
|
1098
|
-
}
|
|
1099
|
-
};
|
|
1100
|
-
function getHotType({
|
|
1101
|
-
id,
|
|
1102
|
-
typeRegistry
|
|
1103
|
-
}) {
|
|
1104
|
-
function worker(id2, ancestorIds) {
|
|
1105
|
-
if (id2 === -1) {
|
|
1106
|
-
return notFound;
|
|
1107
|
-
}
|
|
1108
|
-
const resolvedType2 = typeRegistry[id2];
|
|
1109
|
-
if (!resolvedType2) {
|
|
1110
|
-
throw new Error(`Type ${id2} not found`);
|
|
1111
|
-
}
|
|
1112
|
-
const children = [];
|
|
1113
|
-
if (ancestorIds.indexOf(id2) < 0) {
|
|
1114
|
-
ancestorIds.push(id2);
|
|
1115
|
-
const properties = Object.keys(resolvedType2);
|
|
1116
|
-
for (const property of properties) {
|
|
1117
|
-
switch (property) {
|
|
1118
|
-
case "aliasTypeArguments":
|
|
1119
|
-
case "intersectionTypes":
|
|
1120
|
-
case "typeArguments":
|
|
1121
|
-
case "unionTypes": {
|
|
1122
|
-
const typeIds = resolvedType2[property];
|
|
1123
|
-
if (!Array.isArray(typeIds)) {
|
|
1124
|
-
throw new Error(`Expected array for ${property}`);
|
|
1125
|
-
}
|
|
1126
|
-
for (const typeId2 of typeIds) {
|
|
1127
|
-
const child = worker(typeId2, ancestorIds);
|
|
1128
|
-
if (child) {
|
|
1129
|
-
children.push(child);
|
|
1130
|
-
}
|
|
1131
|
-
}
|
|
1132
|
-
continue;
|
|
1133
|
-
}
|
|
1134
|
-
case "aliasType":
|
|
1135
|
-
case "conditionalCheckType":
|
|
1136
|
-
case "conditionalExtendsType":
|
|
1137
|
-
case "conditionalFalseType":
|
|
1138
|
-
case "conditionalTrueType":
|
|
1139
|
-
case "constraintType":
|
|
1140
|
-
case "evolvingArrayElementType":
|
|
1141
|
-
case "evolvingArrayFinalType":
|
|
1142
|
-
case "indexedAccessIndexType":
|
|
1143
|
-
case "indexedAccessObjectType":
|
|
1144
|
-
case "instantiatedType":
|
|
1145
|
-
case "keyofType":
|
|
1146
|
-
case "reverseMappedConstraintType":
|
|
1147
|
-
case "reverseMappedMappedType":
|
|
1148
|
-
case "reverseMappedSourceType":
|
|
1149
|
-
case "substitutionBaseType": {
|
|
1150
|
-
const typeId2 = resolvedType2[property];
|
|
1151
|
-
const child = worker(typeId2, ancestorIds);
|
|
1152
|
-
if (child) {
|
|
1153
|
-
children.push(child);
|
|
1154
|
-
}
|
|
1155
|
-
break;
|
|
1156
|
-
}
|
|
1157
|
-
case "destructuringPattern":
|
|
1158
|
-
case "display":
|
|
1159
|
-
case "firstDeclaration":
|
|
1160
|
-
case "flags":
|
|
1161
|
-
case "id":
|
|
1162
|
-
case "intrinsicName":
|
|
1163
|
-
case "isTuple":
|
|
1164
|
-
case "recursionId":
|
|
1165
|
-
case "referenceLocation":
|
|
1166
|
-
case "symbolName":
|
|
1167
|
-
break;
|
|
1168
|
-
default:
|
|
1169
|
-
property;
|
|
1170
|
-
throw new Error(`Unexpected property ${property}`);
|
|
1171
|
-
}
|
|
1172
|
-
}
|
|
1173
|
-
ancestorIds.pop();
|
|
1174
|
-
}
|
|
1175
|
-
return {
|
|
1176
|
-
resolvedType: resolvedType2,
|
|
1177
|
-
children
|
|
1178
|
-
};
|
|
1179
|
-
}
|
|
1180
|
-
return worker(id, []);
|
|
1181
|
-
}
|
|
1182
|
-
async function makeHotFrame({
|
|
1183
|
-
span,
|
|
1184
|
-
children,
|
|
1185
|
-
typeRegistry
|
|
1186
|
-
}) {
|
|
1187
|
-
const { event, duration } = span;
|
|
1188
|
-
const timeMs = Math.round(duration / 1e3);
|
|
1189
|
-
switch (event.name) {
|
|
1190
|
-
// case "findSourceFile":
|
|
1191
|
-
// TODO (https://github.com/microsoft/typescript-analyze-trace/issues/2)
|
|
1192
|
-
case "checkSourceFile": {
|
|
1193
|
-
const filePath = event.args.path;
|
|
1194
|
-
const normalizedPath = normalize(filePath);
|
|
1195
|
-
return {
|
|
1196
|
-
description: `Check file ${normalizedPath}`,
|
|
1197
|
-
timeMs,
|
|
1198
|
-
path: normalizedPath,
|
|
1199
|
-
children
|
|
1200
|
-
};
|
|
1201
|
-
}
|
|
1202
|
-
case "structuredTypeRelatedTo":
|
|
1203
|
-
return {
|
|
1204
|
-
description: `Compare types ${event.args.sourceId} and ${event.args.targetId}`,
|
|
1205
|
-
timeMs,
|
|
1206
|
-
children,
|
|
1207
|
-
types: [
|
|
1208
|
-
getHotType({
|
|
1209
|
-
id: event.args.sourceId,
|
|
1210
|
-
typeRegistry
|
|
1211
|
-
}),
|
|
1212
|
-
getHotType({
|
|
1213
|
-
id: event.args.targetId,
|
|
1214
|
-
typeRegistry
|
|
1215
|
-
})
|
|
1216
|
-
]
|
|
1217
|
-
};
|
|
1218
|
-
case "getVariancesWorker":
|
|
1219
|
-
return {
|
|
1220
|
-
description: `Determine variance of type ${event.args.id}`,
|
|
1221
|
-
timeMs,
|
|
1222
|
-
children,
|
|
1223
|
-
types: [getHotType({ id: event.args.id, typeRegistry })]
|
|
1224
|
-
};
|
|
1225
|
-
case "checkExpression":
|
|
1226
|
-
case "checkVariableDeclaration": {
|
|
1227
|
-
const filePath = event.args.path;
|
|
1228
|
-
const path = filePath ? { path: normalize(filePath) } : {};
|
|
1229
|
-
const frame = {
|
|
1230
|
-
description: event.name,
|
|
1231
|
-
timeMs,
|
|
1232
|
-
...path,
|
|
1233
|
-
children: []
|
|
1234
|
-
};
|
|
1235
|
-
return frame;
|
|
1236
|
-
}
|
|
1237
|
-
default:
|
|
1238
|
-
return void 0;
|
|
1239
|
-
}
|
|
1240
|
-
}
|
|
1241
|
-
|
|
1242
|
-
// src/node-module-paths.ts
|
|
1243
|
-
function getNodeModulePaths(traceJson) {
|
|
1244
|
-
const nodeModulePaths2 = {};
|
|
1245
|
-
traceJson.forEach((event) => {
|
|
1246
|
-
if (event.name !== "findSourceFile") {
|
|
1247
|
-
return;
|
|
1248
|
-
}
|
|
1249
|
-
const path = event.args.fileName;
|
|
1250
|
-
if (path) {
|
|
1251
|
-
while (true) {
|
|
1252
|
-
const match = packageNameRegex.exec(path);
|
|
1253
|
-
if (!match) {
|
|
1254
|
-
break;
|
|
1255
|
-
}
|
|
1256
|
-
const packageName2 = match[1];
|
|
1257
|
-
const packagePath2 = match.input.substring(
|
|
1258
|
-
0,
|
|
1259
|
-
match.index + match[0].length
|
|
1260
|
-
);
|
|
1261
|
-
if (packageName2 in nodeModulePaths2) {
|
|
1262
|
-
const paths = nodeModulePaths2[packageName2];
|
|
1263
|
-
if (paths && paths.indexOf(packagePath2) < 0) {
|
|
1264
|
-
paths.push(packagePath2);
|
|
1265
|
-
}
|
|
1266
|
-
} else {
|
|
1267
|
-
nodeModulePaths2[packageName2] = [packagePath2];
|
|
1268
|
-
}
|
|
1269
|
-
}
|
|
1270
|
-
}
|
|
1271
|
-
});
|
|
1272
|
-
return nodeModulePaths2;
|
|
1273
|
-
}
|
|
1274
|
-
|
|
1275
|
-
// src/spans.ts
|
|
1276
|
-
function createSpans(traceFile) {
|
|
1277
|
-
const unclosedStack = [];
|
|
1278
|
-
const spans = [];
|
|
1279
|
-
traceFile.forEach((event) => {
|
|
1280
|
-
switch (event.ph) {
|
|
1281
|
-
case eventPhase.begin:
|
|
1282
|
-
unclosedStack.push(event);
|
|
1283
|
-
return;
|
|
1284
|
-
case eventPhase.end: {
|
|
1285
|
-
const beginEvent = unclosedStack.pop();
|
|
1286
|
-
if (!beginEvent) {
|
|
1287
|
-
throw new Error("Unmatched end event");
|
|
1288
|
-
}
|
|
1289
|
-
spans.push({
|
|
1290
|
-
event: beginEvent,
|
|
1291
|
-
start: beginEvent.ts,
|
|
1292
|
-
end: event.ts,
|
|
1293
|
-
duration: event.ts - beginEvent.ts,
|
|
1294
|
-
children: []
|
|
1295
|
-
});
|
|
1296
|
-
break;
|
|
1297
|
-
}
|
|
1298
|
-
case eventPhase.complete: {
|
|
1299
|
-
const start = event.ts;
|
|
1300
|
-
const duration = event.dur ?? 0;
|
|
1301
|
-
spans.push({
|
|
1302
|
-
event,
|
|
1303
|
-
start,
|
|
1304
|
-
end: start + duration,
|
|
1305
|
-
duration,
|
|
1306
|
-
children: []
|
|
1307
|
-
});
|
|
1308
|
-
break;
|
|
1309
|
-
}
|
|
1310
|
-
case eventPhase.instantGlobal:
|
|
1311
|
-
case eventPhase.metadata:
|
|
1312
|
-
return;
|
|
1313
|
-
default:
|
|
1314
|
-
event;
|
|
1315
|
-
}
|
|
1316
|
-
});
|
|
1317
|
-
const parseResult2 = {
|
|
1318
|
-
firstSpanStart: Math.min(...spans.map((span) => span.start)),
|
|
1319
|
-
lastSpanEnd: Math.max(...spans.map((span) => span.end)),
|
|
1320
|
-
spans,
|
|
1321
|
-
unclosedStack
|
|
1322
|
-
};
|
|
1323
|
-
return parseResult2;
|
|
1324
|
-
}
|
|
1325
|
-
function createSpanTree(parseResult2, options) {
|
|
1326
|
-
const { firstSpanStart, lastSpanEnd, spans, unclosedStack } = parseResult2;
|
|
1327
|
-
for (let i = unclosedStack.length - 1; i >= 0; i--) {
|
|
1328
|
-
const event = unclosedStack[i];
|
|
1329
|
-
const start = event.ts;
|
|
1330
|
-
const end = lastSpanEnd;
|
|
1331
|
-
spans.push({
|
|
1332
|
-
event,
|
|
1333
|
-
start,
|
|
1334
|
-
end,
|
|
1335
|
-
duration: end - start,
|
|
1336
|
-
children: []
|
|
1337
|
-
});
|
|
1338
|
-
}
|
|
1339
|
-
spans.sort((a, b) => a.start - b.start);
|
|
1340
|
-
const root = {
|
|
1341
|
-
event: {
|
|
1342
|
-
name: "root",
|
|
1343
|
-
cat: "program"
|
|
1344
|
-
},
|
|
1345
|
-
start: firstSpanStart,
|
|
1346
|
-
end: lastSpanEnd,
|
|
1347
|
-
duration: lastSpanEnd - firstSpanStart,
|
|
1348
|
-
children: []
|
|
1349
|
-
};
|
|
1350
|
-
const stack = [root];
|
|
1351
|
-
for (const span of spans) {
|
|
1352
|
-
let i = stack.length - 1;
|
|
1353
|
-
for (; i > 0; i--) {
|
|
1354
|
-
const curr = stack[i];
|
|
1355
|
-
if (curr.end > span.start) {
|
|
1356
|
-
stack.length = i + 1;
|
|
1357
|
-
break;
|
|
1358
|
-
}
|
|
1359
|
-
}
|
|
1360
|
-
const thresholdDuration = options.forceMillis * 1e3;
|
|
1361
|
-
const isAboveThresholdDuration = span.duration >= thresholdDuration;
|
|
1362
|
-
const parent = stack[i];
|
|
1363
|
-
const parentDuration = parent.end - parent.start;
|
|
1364
|
-
const isSignificantPortionOfParent = span.duration >= parentDuration * options.minSpanParentPercentage;
|
|
1365
|
-
if (isAboveThresholdDuration || isSignificantPortionOfParent) {
|
|
1366
|
-
parent.children.push(span);
|
|
1367
|
-
stack.push(span);
|
|
1368
|
-
}
|
|
1369
|
-
}
|
|
1370
|
-
return root;
|
|
1371
|
-
}
|
|
1372
|
-
|
|
1373
|
-
// src/utils.ts
|
|
1374
|
-
import { existsSync as existsSync2 } from "fs";
|
|
1375
|
-
import { stat } from "fs/promises";
|
|
1376
|
-
import { z as z4 } from "zod/v4";
|
|
1377
|
-
var absolutePath2 = z4.string().refine(
|
|
1378
|
-
(path) => {
|
|
1379
|
-
return path.startsWith("/") || path.startsWith("C:\\") || path.startsWith("D:\\");
|
|
1380
|
-
},
|
|
1381
|
-
{
|
|
1382
|
-
message: "Path must be absolute"
|
|
1383
|
-
}
|
|
1384
|
-
);
|
|
1385
|
-
var project = z4.object({
|
|
1386
|
-
configFilePath: absolutePath2.optional(),
|
|
1387
|
-
tracePath: absolutePath2,
|
|
1388
|
-
typesPath: absolutePath2
|
|
1389
|
-
});
|
|
1390
|
-
var projectResult = z4.object({
|
|
1391
|
-
project,
|
|
1392
|
-
stdout: z4.string(),
|
|
1393
|
-
stderr: z4.string(),
|
|
1394
|
-
exitCode: z4.number().optional(),
|
|
1395
|
-
signal: z4.enum(["SIGINT", "SIGTERM"]).optional()
|
|
1396
|
-
});
|
|
1397
|
-
var hotType = z4.object({
|
|
1398
|
-
resolvedType,
|
|
1399
|
-
get children() {
|
|
1400
|
-
return z4.array(hotType);
|
|
1401
|
-
}
|
|
1402
|
-
});
|
|
1403
|
-
var hotSpot = z4.object({
|
|
1404
|
-
description: z4.string(),
|
|
1405
|
-
timeMs: z4.number(),
|
|
1406
|
-
get children() {
|
|
1407
|
-
return z4.array(hotSpot);
|
|
1408
|
-
},
|
|
1409
|
-
path: absolutePath2.optional(),
|
|
1410
|
-
types: z4.array(hotType).optional(),
|
|
1411
|
-
startLine: z4.number().optional(),
|
|
1412
|
-
startChar: z4.number().optional(),
|
|
1413
|
-
startOffset: z4.number().optional(),
|
|
1414
|
-
endLine: z4.number().optional(),
|
|
1415
|
-
endChar: z4.number().optional(),
|
|
1416
|
-
endOffset: z4.number().optional()
|
|
1417
|
-
});
|
|
1418
|
-
var duplicatedPackageInstance = z4.object({
|
|
1419
|
-
path: absolutePath2,
|
|
1420
|
-
version: z4.string()
|
|
1421
|
-
});
|
|
1422
|
-
var duplicatedPackage = z4.object({
|
|
1423
|
-
name: z4.string(),
|
|
1424
|
-
instances: z4.array(duplicatedPackageInstance)
|
|
1425
|
-
});
|
|
1426
|
-
var rootSpan = z4.object({
|
|
1427
|
-
name: z4.literal("root"),
|
|
1428
|
-
cat: z4.literal("program")
|
|
1429
|
-
});
|
|
1430
|
-
var eventSpan = z4.object({
|
|
1431
|
-
event: z4.union([traceEvent, rootSpan]),
|
|
1432
|
-
start: z4.number(),
|
|
1433
|
-
end: z4.number(),
|
|
1434
|
-
duration: z4.number(),
|
|
1435
|
-
get children() {
|
|
1436
|
-
return z4.array(eventSpan);
|
|
1437
|
-
}
|
|
1438
|
-
});
|
|
1439
|
-
var microseconds = z4.number();
|
|
1440
|
-
var packageName = z4.string();
|
|
1441
|
-
var packagePath = z4.string();
|
|
1442
|
-
var nodeModulePaths = z4.record(packageName, z4.array(packagePath));
|
|
1443
|
-
var parseResult = z4.object({
|
|
1444
|
-
firstSpanStart: z4.number(),
|
|
1445
|
-
lastSpanEnd: z4.number(),
|
|
1446
|
-
spans: z4.array(eventSpan),
|
|
1447
|
-
unclosedStack: z4.array(traceEvent)
|
|
1448
|
-
});
|
|
1449
|
-
var analyzeTraceOptions = z4.object({
|
|
1450
|
-
/** Events of at least this duration (in milliseconds) will reported unconditionally */
|
|
1451
|
-
forceMillis: z4.number(),
|
|
1452
|
-
/** Events of less than this duration (in milliseconds) will suppressed unconditionally */
|
|
1453
|
-
skipMillis: z4.number(),
|
|
1454
|
-
/** Expand types when printing */
|
|
1455
|
-
expandTypes: z4.boolean(),
|
|
1456
|
-
/** force showing spans that are some percentage of their parent, independent of parent time */
|
|
1457
|
-
minSpanParentPercentage: z4.number(),
|
|
1458
|
-
/** the minimum number of emitted imports from a declaration file or bundle */
|
|
1459
|
-
importExpressionThreshold: z4.number()
|
|
1460
|
-
});
|
|
1461
|
-
var isFile = async (path) => {
|
|
1462
|
-
return stat(path).then((stats) => stats.isFile()).catch((_) => false);
|
|
1463
|
-
};
|
|
1464
|
-
var throwIfNotDirectory = async (path) => {
|
|
1465
|
-
if (!existsSync2(path) || !(await stat(path))?.isDirectory()) {
|
|
1466
|
-
throw new Error(`${path} is not a directory`);
|
|
1467
|
-
}
|
|
1468
|
-
return path;
|
|
1469
|
-
};
|
|
1470
|
-
var analyzeTraceResult = z4.object({
|
|
1471
|
-
/** Events that were not closed */
|
|
1472
|
-
unterminatedEvents: z4.array(traceEvent),
|
|
1473
|
-
/** Hot spots in the trace */
|
|
1474
|
-
hotSpots: z4.array(hotSpot),
|
|
1475
|
-
/** Packages that are duplicated in the trace */
|
|
1476
|
-
duplicatePackages: z4.array(duplicatedPackage),
|
|
1477
|
-
/** Paths to all node modules used in the trace */
|
|
1478
|
-
nodeModulePaths,
|
|
1479
|
-
/** Depth limit events grouped by their event name */
|
|
1480
|
-
depthLimits: z4.object({
|
|
1481
|
-
checkCrossProductUnion_DepthLimit: z4.array(
|
|
1482
|
-
event_checktypes__checkCrossProductUnion_DepthLimit
|
|
1483
|
-
),
|
|
1484
|
-
checkTypeRelatedTo_DepthLimit: z4.array(
|
|
1485
|
-
event_checktypes__checkTypeRelatedTo_DepthLimit
|
|
1486
|
-
),
|
|
1487
|
-
getTypeAtFlowNode_DepthLimit: z4.array(
|
|
1488
|
-
event_checktypes__getTypeAtFlowNode_DepthLimit
|
|
1489
|
-
),
|
|
1490
|
-
instantiateType_DepthLimit: z4.array(
|
|
1491
|
-
event_checktypes__instantiateType_DepthLimit
|
|
1492
|
-
),
|
|
1493
|
-
recursiveTypeRelatedTo_DepthLimit: z4.array(
|
|
1494
|
-
event_checktypes__recursiveTypeRelatedTo_DepthLimit
|
|
1495
|
-
),
|
|
1496
|
-
removeSubtypes_DepthLimit: z4.array(
|
|
1497
|
-
event_checktypes__removeSubtypes_DepthLimit
|
|
1498
|
-
),
|
|
1499
|
-
traceUnionsOrIntersectionsTooLarge_DepthLimit: z4.array(
|
|
1500
|
-
event_checktypes__traceUnionsOrIntersectionsTooLarge_DepthLimit
|
|
1501
|
-
),
|
|
1502
|
-
typeRelatedToDiscriminatedType_DepthLimit: z4.array(
|
|
1503
|
-
event_checktypes__typeRelatedToDiscriminatedType_DepthLimit
|
|
1504
|
-
)
|
|
1505
|
-
})
|
|
1506
|
-
});
|
|
1507
|
-
|
|
1508
|
-
// src/analyze-trace.ts
|
|
1509
|
-
function validateOptions(options) {
|
|
1510
|
-
if (options.forceMillis < options.skipMillis) {
|
|
1511
|
-
throw new Error("forceMillis cannot be less than skipMillis");
|
|
1512
|
-
}
|
|
1513
|
-
}
|
|
1514
|
-
var validateTraceDir = async (traceDir) => {
|
|
1515
|
-
await throwIfNotDirectory(traceDir);
|
|
1516
|
-
const typesFilePath = join2(traceDir, TYPES_JSON_FILENAME);
|
|
1517
|
-
if (!existsSync3(typesFilePath)) {
|
|
1518
|
-
throw new Error(
|
|
1519
|
-
`types.json must exist in ${traceDir}. first run --generateTrace`
|
|
1520
|
-
);
|
|
1521
|
-
}
|
|
1522
|
-
const typesFileJson = JSON.parse(await readFile2(typesFilePath, "utf8"));
|
|
1523
|
-
const typesFile = typesJsonSchema.parse(typesFileJson);
|
|
1524
|
-
const traceFilePath = join2(traceDir, TRACE_JSON_FILENAME);
|
|
1525
|
-
if (!existsSync3(traceFilePath)) {
|
|
1526
|
-
throw new Error(
|
|
1527
|
-
`trace.json must exist in ${traceDir}. first run --generateTrace`
|
|
1528
|
-
);
|
|
1529
|
-
}
|
|
1530
|
-
const traceFileJson = JSON.parse(await readFile2(traceFilePath, "utf8"));
|
|
1531
|
-
const traceFile = traceJsonSchema.parse(traceFileJson);
|
|
1532
|
-
return {
|
|
1533
|
-
traceFile,
|
|
1534
|
-
typesFile
|
|
1535
|
-
};
|
|
1536
|
-
};
|
|
1537
|
-
var defaultOptions = {
|
|
1538
|
-
forceMillis: 500,
|
|
1539
|
-
skipMillis: 100,
|
|
1540
|
-
expandTypes: true,
|
|
1541
|
-
minSpanParentPercentage: 0.6,
|
|
1542
|
-
importExpressionThreshold: 10
|
|
1543
|
-
};
|
|
1544
|
-
var analyzeTrace = async ({
|
|
1545
|
-
traceDir,
|
|
1546
|
-
options = defaultOptions
|
|
1547
|
-
}) => {
|
|
1548
|
-
validateOptions(options);
|
|
1549
|
-
const { traceFile, typesFile } = await validateTraceDir(traceDir);
|
|
1550
|
-
const nodeModulePaths2 = getNodeModulePaths(traceFile);
|
|
1551
|
-
const spans = createSpans(traceFile);
|
|
1552
|
-
const hotPathsTree = createSpanTree(spans, options);
|
|
1553
|
-
const result = {
|
|
1554
|
-
nodeModulePaths: nodeModulePaths2,
|
|
1555
|
-
unterminatedEvents: spans.unclosedStack.reverse(),
|
|
1556
|
-
hotSpots: await getHotspots(hotPathsTree, typesFile, options),
|
|
1557
|
-
duplicatePackages: await getDuplicateNodeModules(nodeModulePaths2),
|
|
1558
|
-
depthLimits: createDepthLimits(traceFile)
|
|
1559
|
-
};
|
|
1560
|
-
await writeFile(
|
|
1561
|
-
join2(traceDir, ANALYZE_TRACE_FILENAME),
|
|
1562
|
-
JSON.stringify(result, null, 2)
|
|
1563
|
-
);
|
|
1564
|
-
return result;
|
|
1565
|
-
};
|
|
1566
|
-
export {
|
|
1567
|
-
ANALYZE_TRACE_FILENAME,
|
|
1568
|
-
absolutePath2 as absolutePath,
|
|
1569
|
-
analyzeTrace,
|
|
1570
|
-
analyzeTraceOptions,
|
|
1571
|
-
analyzeTraceResult,
|
|
1572
|
-
createDepthLimits,
|
|
1573
|
-
defaultOptions,
|
|
1574
|
-
duplicatedPackage,
|
|
1575
|
-
duplicatedPackageInstance,
|
|
1576
|
-
eventSpan,
|
|
1577
|
-
hotSpot,
|
|
1578
|
-
hotType,
|
|
1579
|
-
isFile,
|
|
1580
|
-
microseconds,
|
|
1581
|
-
nodeModulePaths,
|
|
1582
|
-
packageName,
|
|
1583
|
-
packagePath,
|
|
1584
|
-
parseResult,
|
|
1585
|
-
project,
|
|
1586
|
-
projectResult,
|
|
1587
|
-
rootSpan,
|
|
1588
|
-
throwIfNotDirectory,
|
|
1589
|
-
validateOptions
|
|
1590
|
-
};
|
|
1591
|
-
//# sourceMappingURL=index.js.map
|