tempo-sdk 0.0.12 → 0.0.13

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.js CHANGED
@@ -1,5 +1,5 @@
1
1
  // index.ts
2
- import { realpathSync as realpathSync2, statSync as statSync2 } from "fs";
2
+ import { realpathSync as realpathSync4, statSync as statSync3 } from "fs";
3
3
  import { relative as relative2 } from "path";
4
4
 
5
5
  // ../../modules/annotation/annotate-file.ts
@@ -172,6 +172,7 @@ function computeTempoAnnotatedProps(params) {
172
172
  filepath,
173
173
  modifiedtsMs,
174
174
  computeAnnotatedProps,
175
+ typeInfo,
175
176
  elementSupportOverrides
176
177
  } = params;
177
178
  const userProps = computeAnnotatedProps ? computeAnnotatedProps(info, filepath, modifiedtsMs) : defaultComputeAnnotatedProps(info, filepath, modifiedtsMs);
@@ -196,7 +197,563 @@ function computeTempoAnnotatedProps(params) {
196
197
  ) ? void 0 : override.supportsChildren
197
198
  };
198
199
  }
199
- return userProps;
200
+ const support = typeInfo?.get(info.element.openingElement.start);
201
+ return {
202
+ ...userProps,
203
+ "data-tempo-supports-style": support?.supportsStyle ?? false,
204
+ "data-tempo-supports-classname": support?.supportsClassName ?? false,
205
+ "data-tempo-supports-children": hasJsxAttribute(
206
+ info,
207
+ "data-tempo-supports-children"
208
+ ) ? void 0 : support?.supportsChildren ?? false
209
+ };
210
+ }
211
+
212
+ // type-analyzer.ts
213
+ import ts2 from "typescript";
214
+ import path2 from "path";
215
+ import { realpathSync as realpathSync3 } from "fs";
216
+
217
+ // ../../modules/typescript/workspace-service.ts
218
+ import { realpathSync as realpathSync2, statSync as statSync2 } from "fs";
219
+ import path from "path";
220
+ import ts from "typescript";
221
+ function canonicalPath(input) {
222
+ const resolved = path.resolve(input);
223
+ try {
224
+ return realpathSync2.native(resolved);
225
+ } catch {
226
+ return resolved;
227
+ }
228
+ }
229
+ function compareProjectPriority(left, right) {
230
+ const depthDelta = right.rootDir.length - left.rootDir.length;
231
+ if (depthDelta !== 0) {
232
+ return depthDelta;
233
+ }
234
+ const priorityDelta = right.priority - left.priority;
235
+ if (priorityDelta !== 0) {
236
+ return priorityDelta;
237
+ }
238
+ return left.id.localeCompare(right.id);
239
+ }
240
+ function isWithinRoot(filePath, rootDir) {
241
+ return filePath === rootDir || filePath.startsWith(`${rootDir}${path.sep}`);
242
+ }
243
+ function loadProject(descriptor) {
244
+ const id = descriptor.id.trim();
245
+ if (!id) {
246
+ throw new Error("Project id must be a non-empty string");
247
+ }
248
+ const tsconfigPath = canonicalPath(descriptor.tsconfigPath);
249
+ const rootDir = canonicalPath(descriptor.rootDir);
250
+ const readResult = ts.readConfigFile(tsconfigPath, ts.sys.readFile);
251
+ if (readResult.error) {
252
+ throw new Error(
253
+ `Failed to read tsconfig at ${tsconfigPath}: ${ts.flattenDiagnosticMessageText(
254
+ readResult.error.messageText,
255
+ "\n"
256
+ )}`
257
+ );
258
+ }
259
+ const parsed = ts.parseJsonConfigFileContent(
260
+ readResult.config,
261
+ ts.sys,
262
+ path.dirname(tsconfigPath)
263
+ );
264
+ if (parsed.errors.length > 0) {
265
+ const message = parsed.errors.map(
266
+ (diagnostic) => ts.flattenDiagnosticMessageText(diagnostic.messageText, "\n")
267
+ ).join("; ");
268
+ throw new Error(`Failed to parse tsconfig at ${tsconfigPath}: ${message}`);
269
+ }
270
+ const normalizedFiles = parsed.fileNames.map(
271
+ (fileName) => canonicalPath(fileName)
272
+ );
273
+ return {
274
+ id,
275
+ rootDir,
276
+ tsconfigPath,
277
+ priority: descriptor.priority ?? 0,
278
+ options: parsed.options,
279
+ fileNames: normalizedFiles,
280
+ moduleResolutionCache: ts.createModuleResolutionCache(
281
+ rootDir,
282
+ (value) => value,
283
+ parsed.options
284
+ )
285
+ };
286
+ }
287
+ function getFileMtimeVersion(filePath) {
288
+ try {
289
+ const stats = statSync2(filePath);
290
+ return String(stats.mtimeMs);
291
+ } catch {
292
+ return "0";
293
+ }
294
+ }
295
+ function createTsWorkspaceService(descriptor) {
296
+ if (descriptor.projects.length === 0) {
297
+ throw new Error(
298
+ "TsWorkspaceDescriptor.projects must include at least one project"
299
+ );
300
+ }
301
+ const workspaceRoot = canonicalPath(descriptor.workspaceRoot);
302
+ const loadedProjects = descriptor.projects.map(
303
+ (project) => loadProject(project)
304
+ );
305
+ const projectsById = /* @__PURE__ */ new Map();
306
+ for (const project of loadedProjects) {
307
+ if (projectsById.has(project.id)) {
308
+ throw new Error(`Duplicate project id: ${project.id}`);
309
+ }
310
+ projectsById.set(project.id, project);
311
+ }
312
+ const primaryProject = (descriptor.primaryProjectId ? projectsById.get(descriptor.primaryProjectId) : null) ?? loadedProjects[0];
313
+ if (descriptor.primaryProjectId && !projectsById.has(descriptor.primaryProjectId)) {
314
+ throw new Error(
315
+ `Primary project id not found: ${descriptor.primaryProjectId}`
316
+ );
317
+ }
318
+ const orderedProjects = [...loadedProjects].sort(compareProjectPriority);
319
+ const rootFileNames = /* @__PURE__ */ new Set();
320
+ for (const project of loadedProjects) {
321
+ for (const fileName of project.fileNames) {
322
+ rootFileNames.add(fileName);
323
+ }
324
+ }
325
+ const inMemoryFiles = /* @__PURE__ */ new Map();
326
+ let projectVersion = 0;
327
+ function getOwningProject(filePath) {
328
+ const canonicalFilePath = canonicalPath(filePath);
329
+ for (const project of orderedProjects) {
330
+ if (isWithinRoot(canonicalFilePath, project.rootDir)) {
331
+ return project;
332
+ }
333
+ }
334
+ return primaryProject;
335
+ }
336
+ const moduleResolutionHost = {
337
+ fileExists: ts.sys.fileExists,
338
+ readFile: ts.sys.readFile,
339
+ realpath: ts.sys.realpath,
340
+ directoryExists: ts.sys.directoryExists,
341
+ getCurrentDirectory: () => workspaceRoot,
342
+ getDirectories: ts.sys.getDirectories
343
+ };
344
+ const host = {
345
+ getScriptFileNames: () => Array.from(rootFileNames),
346
+ getScriptVersion: (filePath) => {
347
+ const canonicalFilePath = canonicalPath(filePath);
348
+ const inMemory = inMemoryFiles.get(canonicalFilePath);
349
+ if (inMemory) {
350
+ return String(inMemory.version);
351
+ }
352
+ return getFileMtimeVersion(canonicalFilePath);
353
+ },
354
+ getScriptSnapshot: (filePath) => {
355
+ const canonicalFilePath = canonicalPath(filePath);
356
+ const inMemory = inMemoryFiles.get(canonicalFilePath);
357
+ if (inMemory) {
358
+ return ts.ScriptSnapshot.fromString(inMemory.content);
359
+ }
360
+ const diskContent = ts.sys.readFile(canonicalFilePath);
361
+ if (diskContent === void 0) {
362
+ return void 0;
363
+ }
364
+ return ts.ScriptSnapshot.fromString(diskContent);
365
+ },
366
+ getCurrentDirectory: () => workspaceRoot,
367
+ getCompilationSettings: () => primaryProject.options,
368
+ getDefaultLibFileName: (options) => ts.getDefaultLibFilePath(options),
369
+ fileExists: ts.sys.fileExists,
370
+ readFile: ts.sys.readFile,
371
+ readDirectory: ts.sys.readDirectory,
372
+ directoryExists: ts.sys.directoryExists,
373
+ getDirectories: ts.sys.getDirectories,
374
+ useCaseSensitiveFileNames: () => ts.sys.useCaseSensitiveFileNames,
375
+ getProjectVersion: () => String(projectVersion),
376
+ resolveModuleNames: (moduleNames, containingFile) => {
377
+ const owningProject = getOwningProject(containingFile);
378
+ return moduleNames.map((moduleName) => {
379
+ const ownerResolution = ts.resolveModuleName(
380
+ moduleName,
381
+ containingFile,
382
+ owningProject.options,
383
+ moduleResolutionHost,
384
+ owningProject.moduleResolutionCache
385
+ ).resolvedModule;
386
+ if (ownerResolution) {
387
+ return ownerResolution;
388
+ }
389
+ if (owningProject.id === primaryProject.id) {
390
+ return void 0;
391
+ }
392
+ return ts.resolveModuleName(
393
+ moduleName,
394
+ containingFile,
395
+ primaryProject.options,
396
+ moduleResolutionHost,
397
+ primaryProject.moduleResolutionCache
398
+ ).resolvedModule;
399
+ });
400
+ }
401
+ };
402
+ const languageService = ts.createLanguageService(
403
+ host,
404
+ ts.createDocumentRegistry()
405
+ );
406
+ return {
407
+ updateFile(filePath, content) {
408
+ const canonicalFilePath = canonicalPath(filePath);
409
+ const currentVersion = inMemoryFiles.get(canonicalFilePath)?.version ?? 0;
410
+ inMemoryFiles.set(canonicalFilePath, {
411
+ version: currentVersion + 1,
412
+ content
413
+ });
414
+ if (!rootFileNames.has(canonicalFilePath)) {
415
+ rootFileNames.add(canonicalFilePath);
416
+ }
417
+ projectVersion += 1;
418
+ },
419
+ closeFile(filePath) {
420
+ const canonicalFilePath = canonicalPath(filePath);
421
+ inMemoryFiles.delete(canonicalFilePath);
422
+ projectVersion += 1;
423
+ },
424
+ getProgram() {
425
+ return languageService.getProgram() ?? null;
426
+ },
427
+ getSemanticDiagnostics(filePath) {
428
+ const canonicalFilePath = canonicalPath(filePath);
429
+ return languageService.getSemanticDiagnostics(canonicalFilePath);
430
+ },
431
+ getDefinition(filePath, position) {
432
+ const canonicalFilePath = canonicalPath(filePath);
433
+ return languageService.getDefinitionAtPosition(
434
+ canonicalFilePath,
435
+ position
436
+ );
437
+ },
438
+ dispose() {
439
+ languageService.dispose();
440
+ }
441
+ };
442
+ }
443
+
444
+ // type-analyzer.ts
445
+ function isCustomComponent(node) {
446
+ const text = node.getText();
447
+ return text.length > 0 && text[0] !== text[0].toLowerCase();
448
+ }
449
+ function canonicalPath2(value) {
450
+ const resolved = path2.resolve(value);
451
+ try {
452
+ return realpathSync3.native(resolved);
453
+ } catch {
454
+ return resolved;
455
+ }
456
+ }
457
+ function parseManagedTsconfigPaths(rawConfig) {
458
+ if (!rawConfig || typeof rawConfig !== "object" || Array.isArray(rawConfig)) {
459
+ return [];
460
+ }
461
+ const metadata = rawConfig.tempobook;
462
+ if (!metadata || typeof metadata !== "object" || Array.isArray(metadata)) {
463
+ return [];
464
+ }
465
+ const managedPaths = metadata.managedTsconfigPaths;
466
+ if (!Array.isArray(managedPaths)) {
467
+ return [];
468
+ }
469
+ return managedPaths.filter(
470
+ (entry) => typeof entry === "string" && entry.trim().length > 0
471
+ );
472
+ }
473
+ function parseProjectReferenceTsconfigPaths(references, configDir) {
474
+ if (!references || references.length === 0) {
475
+ return [];
476
+ }
477
+ const entries = [];
478
+ for (const reference of references) {
479
+ const referencePath = reference.path;
480
+ if (!referencePath) {
481
+ continue;
482
+ }
483
+ const resolvedPath = path2.resolve(configDir, referencePath);
484
+ const tsconfigPath = resolvedPath.endsWith(".json") ? resolvedPath : path2.join(resolvedPath, "tsconfig.json");
485
+ entries.push(tsconfigPath);
486
+ }
487
+ return entries;
488
+ }
489
+ function buildWorkspaceProjects(root, configPath, parsedConfig, rawConfig) {
490
+ const configDir = path2.dirname(configPath);
491
+ const projects = [
492
+ {
493
+ id: "root",
494
+ rootDir: root,
495
+ tsconfigPath: configPath,
496
+ priority: 0
497
+ }
498
+ ];
499
+ const seenTsconfigPaths = /* @__PURE__ */ new Set([canonicalPath2(configPath)]);
500
+ const referencedTsconfigPaths = parseProjectReferenceTsconfigPaths(
501
+ parsedConfig.projectReferences,
502
+ configDir
503
+ );
504
+ const managedTsconfigPaths = parseManagedTsconfigPaths(rawConfig).map(
505
+ (entry) => path2.resolve(configDir, entry)
506
+ );
507
+ const candidateTsconfigPaths = [
508
+ ...managedTsconfigPaths,
509
+ ...referencedTsconfigPaths
510
+ ];
511
+ for (const candidatePath of candidateTsconfigPaths) {
512
+ const normalizedPath = canonicalPath2(candidatePath);
513
+ if (seenTsconfigPaths.has(normalizedPath)) {
514
+ continue;
515
+ }
516
+ if (!ts2.sys.fileExists(normalizedPath)) {
517
+ continue;
518
+ }
519
+ seenTsconfigPaths.add(normalizedPath);
520
+ projects.push({
521
+ id: `external-${projects.length}`,
522
+ rootDir: path2.dirname(normalizedPath),
523
+ tsconfigPath: normalizedPath,
524
+ priority: 0
525
+ });
526
+ }
527
+ return projects;
528
+ }
529
+ function createTypeAnalyzer(root) {
530
+ const configPath = ts2.findConfigFile(
531
+ root,
532
+ ts2.sys.fileExists,
533
+ "tsconfig.json"
534
+ );
535
+ if (!configPath) return null;
536
+ const configFile = ts2.readConfigFile(configPath, ts2.sys.readFile);
537
+ if (configFile.error) return null;
538
+ const parsedConfig = ts2.parseJsonConfigFileContent(
539
+ configFile.config,
540
+ ts2.sys,
541
+ root
542
+ );
543
+ const workspaceProjects = buildWorkspaceProjects(
544
+ root,
545
+ configPath,
546
+ parsedConfig,
547
+ configFile.config
548
+ );
549
+ const workspaceProjectRoots = workspaceProjects.map(
550
+ (project) => canonicalPath2(project.rootDir)
551
+ );
552
+ const workspaceService = createTsWorkspaceService({
553
+ workspaceRoot: root,
554
+ primaryProjectId: "root",
555
+ projects: workspaceProjects
556
+ });
557
+ let cssPropertiesType;
558
+ function resolveCSSPropertiesType(checker, sourceFile) {
559
+ if (cssPropertiesType !== void 0) return cssPropertiesType;
560
+ try {
561
+ let jsxNs = checker.resolveName(
562
+ "JSX",
563
+ sourceFile,
564
+ ts2.SymbolFlags.Namespace,
565
+ false
566
+ );
567
+ if (!jsxNs) {
568
+ const program = workspaceService.getProgram();
569
+ const compilerOptions = program?.getCompilerOptions();
570
+ const jsxImportSource = compilerOptions?.jsxImportSource ?? "react";
571
+ const resolved = ts2.resolveModuleName(
572
+ `${jsxImportSource}/jsx-runtime`,
573
+ sourceFile.fileName,
574
+ compilerOptions,
575
+ ts2.sys
576
+ );
577
+ if (resolved.resolvedModule) {
578
+ const runtimeFile = program?.getSourceFile(
579
+ resolved.resolvedModule.resolvedFileName
580
+ );
581
+ if (runtimeFile) {
582
+ const runtimeSymbol = checker.getSymbolAtLocation(runtimeFile);
583
+ if (runtimeSymbol) {
584
+ const exports = checker.getExportsOfModule(runtimeSymbol);
585
+ jsxNs = exports.find((s) => s.name === "JSX");
586
+ }
587
+ }
588
+ }
589
+ }
590
+ if (!jsxNs) {
591
+ cssPropertiesType = null;
592
+ return null;
593
+ }
594
+ const intrinsicSym = checker.getExportsOfModule(jsxNs).find((s) => s.name === "IntrinsicElements") ?? checker.getDeclaredTypeOfSymbol(jsxNs).getProperty("IntrinsicElements");
595
+ if (!intrinsicSym) {
596
+ cssPropertiesType = null;
597
+ return null;
598
+ }
599
+ const divSym = checker.getDeclaredTypeOfSymbol(intrinsicSym).getProperty("div");
600
+ if (!divSym) {
601
+ cssPropertiesType = null;
602
+ return null;
603
+ }
604
+ const styleSym = checker.getTypeOfSymbol(divSym).getProperty("style");
605
+ if (!styleSym) {
606
+ cssPropertiesType = null;
607
+ return null;
608
+ }
609
+ const styleType = checker.getTypeOfSymbol(styleSym);
610
+ if (styleType.isUnion()) {
611
+ const nonUndefined = styleType.types.find(
612
+ (t) => !(t.flags & ts2.TypeFlags.Undefined)
613
+ );
614
+ cssPropertiesType = nonUndefined ?? null;
615
+ } else {
616
+ cssPropertiesType = styleType;
617
+ }
618
+ } catch {
619
+ cssPropertiesType = null;
620
+ }
621
+ return cssPropertiesType;
622
+ }
623
+ let reactNodeType;
624
+ function resolveReactNodeType(checker, sourceFile) {
625
+ if (reactNodeType !== void 0) return reactNodeType;
626
+ try {
627
+ let jsxNs = checker.resolveName(
628
+ "JSX",
629
+ sourceFile,
630
+ ts2.SymbolFlags.Namespace,
631
+ false
632
+ );
633
+ if (!jsxNs) {
634
+ const program = workspaceService.getProgram();
635
+ const compilerOptions = program?.getCompilerOptions();
636
+ const jsxImportSource = compilerOptions?.jsxImportSource ?? "react";
637
+ const resolved = ts2.resolveModuleName(
638
+ `${jsxImportSource}/jsx-runtime`,
639
+ sourceFile.fileName,
640
+ compilerOptions,
641
+ ts2.sys
642
+ );
643
+ if (resolved.resolvedModule) {
644
+ const runtimeFile = program?.getSourceFile(
645
+ resolved.resolvedModule.resolvedFileName
646
+ );
647
+ if (runtimeFile) {
648
+ const runtimeSymbol = checker.getSymbolAtLocation(runtimeFile);
649
+ if (runtimeSymbol) {
650
+ const exports = checker.getExportsOfModule(runtimeSymbol);
651
+ jsxNs = exports.find((s) => s.name === "JSX");
652
+ }
653
+ }
654
+ }
655
+ }
656
+ if (!jsxNs) {
657
+ reactNodeType = null;
658
+ return null;
659
+ }
660
+ const intrinsicSym = checker.getExportsOfModule(jsxNs).find((s) => s.name === "IntrinsicElements") ?? checker.getDeclaredTypeOfSymbol(jsxNs).getProperty("IntrinsicElements");
661
+ if (!intrinsicSym) {
662
+ reactNodeType = null;
663
+ return null;
664
+ }
665
+ const divSym = checker.getDeclaredTypeOfSymbol(intrinsicSym).getProperty("div");
666
+ if (!divSym) {
667
+ reactNodeType = null;
668
+ return null;
669
+ }
670
+ const childrenSym = checker.getTypeOfSymbol(divSym).getProperty("children");
671
+ if (!childrenSym) {
672
+ reactNodeType = null;
673
+ return null;
674
+ }
675
+ const childrenType = checker.getTypeOfSymbol(childrenSym);
676
+ if (childrenType.isUnion()) {
677
+ const nonUndefined = childrenType.types.find(
678
+ (t) => !(t.flags & ts2.TypeFlags.Undefined)
679
+ );
680
+ reactNodeType = nonUndefined ?? null;
681
+ } else {
682
+ reactNodeType = childrenType;
683
+ }
684
+ } catch {
685
+ reactNodeType = null;
686
+ }
687
+ return reactNodeType;
688
+ }
689
+ return {
690
+ analyzeFileTypes(filePath, source) {
691
+ const canonicalFilePath = canonicalPath2(filePath);
692
+ const belongsToWorkspace = workspaceProjectRoots.some(
693
+ (projectRoot) => canonicalFilePath === projectRoot || canonicalFilePath.startsWith(`${projectRoot}${path2.sep}`)
694
+ );
695
+ if (!belongsToWorkspace) {
696
+ return null;
697
+ }
698
+ workspaceService.updateFile(filePath, source);
699
+ const program = workspaceService.getProgram();
700
+ if (!program) return null;
701
+ const sourceFile = program.getSourceFile(filePath);
702
+ if (!sourceFile) return null;
703
+ const checker = program.getTypeChecker();
704
+ const cssProps = resolveCSSPropertiesType(checker, sourceFile);
705
+ const result = /* @__PURE__ */ new Map();
706
+ function visit(node) {
707
+ if ((ts2.isJsxOpeningElement(node) || ts2.isJsxSelfClosingElement(node)) && isCustomComponent(node.tagName)) {
708
+ const position = node.getStart(sourceFile);
709
+ const attrsType = checker.getContextualType(node.attributes);
710
+ let supportsStyle = false;
711
+ let supportsClassName = false;
712
+ let supportsChildren = false;
713
+ if (attrsType) {
714
+ const classNameProp = attrsType.getProperty("className");
715
+ if (classNameProp) {
716
+ const propType = checker.getTypeOfSymbol(classNameProp);
717
+ supportsClassName = checker.isTypeAssignableTo(
718
+ checker.getStringType(),
719
+ propType
720
+ );
721
+ }
722
+ const styleProp = attrsType.getProperty("style");
723
+ if (styleProp && cssProps) {
724
+ let propType = checker.getTypeOfSymbol(styleProp);
725
+ if (propType.isUnion()) {
726
+ const nonUndefined = propType.types.find(
727
+ (t) => !(t.flags & ts2.TypeFlags.Undefined)
728
+ );
729
+ if (nonUndefined) propType = nonUndefined;
730
+ }
731
+ supportsStyle = checker.isTypeAssignableTo(cssProps, propType);
732
+ }
733
+ const reactNode = resolveReactNodeType(checker, sourceFile);
734
+ const childrenProp = attrsType.getProperty("children");
735
+ if (childrenProp && reactNode) {
736
+ let propType = checker.getTypeOfSymbol(childrenProp);
737
+ if (propType.isUnion()) {
738
+ const nonUndefined = propType.types.find(
739
+ (t) => !(t.flags & ts2.TypeFlags.Undefined)
740
+ );
741
+ if (nonUndefined) propType = nonUndefined;
742
+ }
743
+ supportsChildren = checker.isTypeAssignableTo(
744
+ reactNode,
745
+ propType
746
+ );
747
+ }
748
+ }
749
+ result.set(position, { supportsStyle, supportsClassName, supportsChildren });
750
+ }
751
+ ts2.forEachChild(node, visit);
752
+ }
753
+ visit(sourceFile);
754
+ return result;
755
+ }
756
+ };
200
757
  }
201
758
 
202
759
  // index.ts
@@ -208,7 +765,7 @@ function cleanModuleId(id) {
208
765
  }
209
766
  function resolveCanonicalRoot(root) {
210
767
  try {
211
- return realpathSync2.native(root);
768
+ return realpathSync4.native(root);
212
769
  } catch {
213
770
  return root;
214
771
  }
@@ -325,6 +882,7 @@ function tempoVitePlugin(options = {}) {
325
882
  const filter = createFilter(include, exclude);
326
883
  let canonicalRoot = process.cwd();
327
884
  let command = "serve";
885
+ let typeAnalyzer = null;
328
886
  const errorServer = createErrorServer();
329
887
  return {
330
888
  name: "tempo-annotate",
@@ -335,6 +893,9 @@ function tempoVitePlugin(options = {}) {
335
893
  if (!enabled) return;
336
894
  command = resolvedConfig.command;
337
895
  canonicalRoot = resolveCanonicalRoot(resolvedConfig.root);
896
+ if (command === "serve") {
897
+ typeAnalyzer = createTypeAnalyzer(canonicalRoot);
898
+ }
338
899
  },
339
900
  configureServer(server) {
340
901
  if (!enabled) return;
@@ -404,7 +965,8 @@ function tempoVitePlugin(options = {}) {
404
965
  }
405
966
  try {
406
967
  const filepath = relative2(canonicalRoot, cleanId);
407
- const modifiedtsMs = Math.trunc(statSync2(cleanId).mtimeMs);
968
+ const modifiedtsMs = Math.trunc(statSync3(cleanId).mtimeMs);
969
+ const typeInfo = typeAnalyzer?.analyzeFileTypes(cleanId, source);
408
970
  const result = annotateFile(
409
971
  source,
410
972
  cleanId,
@@ -412,7 +974,8 @@ function tempoVitePlugin(options = {}) {
412
974
  info,
413
975
  filepath,
414
976
  modifiedtsMs,
415
- computeAnnotatedProps: options.computeAnnotatedProps
977
+ computeAnnotatedProps: options.computeAnnotatedProps,
978
+ typeInfo
416
979
  })
417
980
  );
418
981
  if (result.elementsAnnotated === 0) {
@@ -430,6 +993,7 @@ function tempoVitePlugin(options = {}) {
430
993
  }
431
994
  var tempoAnnotate = tempoVitePlugin;
432
995
  export {
996
+ createTypeAnalyzer,
433
997
  tempoAnnotate,
434
998
  tempoVitePlugin
435
999
  };