@ttsc/paths 0.33.1 → 0.34.1

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.
Files changed (3) hide show
  1. package/driver/paths.go +23 -24
  2. package/go.mod +2 -2
  3. package/package.json +1 -1
package/driver/paths.go CHANGED
@@ -9,6 +9,7 @@ import (
9
9
  shimchecker "github.com/microsoft/typescript-go/shim/checker"
10
10
  shimcore "github.com/microsoft/typescript-go/shim/core"
11
11
  shimtspath "github.com/microsoft/typescript-go/shim/tspath"
12
+ shimvfs "github.com/microsoft/typescript-go/shim/vfs"
12
13
 
13
14
  "github.com/samchon/ttsc/packages/ttsc/driver"
14
15
  )
@@ -157,30 +158,28 @@ var sourceLookupExtensions = []string{
157
158
  // Patterns are sorted by decreasing specificity (longer literal prefix first)
158
159
  // so the most-specific match wins on overlapping patterns.
159
160
  func newRewriter(prog *driver.Program) *rewriter {
160
- caseSensitive := useCaseSensitiveFileNames(prog)
161
+ caseSensitivity := fileSystemCaseSensitivity(prog)
161
162
  out := &rewriter{
162
- canonicalFileName: func(name string) string {
163
- return shimtspath.GetCanonicalFileName(name, caseSensitive)
164
- },
165
- sourceFiles: map[string]string{},
163
+ canonicalFileName: func(text string) string { return shimtspath.Canonicalize(caseSensitivity, text) },
164
+ sourceFiles: map[string]string{},
166
165
  }
167
166
  if prog == nil || prog.ParsedConfig == nil || prog.ParsedConfig.ParsedConfig == nil || prog.ParsedConfig.ParsedConfig.CompilerOptions == nil {
168
167
  return out
169
168
  }
170
169
  out.checker = prog.Checker
171
170
  options := prog.ParsedConfig.ParsedConfig.CompilerOptions
172
- cwd := prog.Host.GetCurrentDirectory()
173
- out.basePath = filepath.Clean(options.GetPathsBasePath(cwd))
171
+ cwd := prog.TSProgram.GetCurrentDirectory()
172
+ out.basePath = filepath.Clean(string(options.GetPathsBasePath(cwd)))
174
173
  out.jsxPreserve = options.Jsx == shimcore.JsxEmitPreserve
175
- out.outDir = optionalPath(options.OutDir, cwd)
176
- out.rootDir = optionalPath(options.RootDir, cwd)
174
+ out.outDir = optionalPath(string(options.OutDir), string(cwd))
175
+ out.rootDir = optionalPath(string(options.RootDir), string(cwd))
177
176
  files := prog.SourceFiles()
178
177
  fileNames := make([]string, 0, len(files))
179
178
  for _, file := range files {
180
- fileNames = append(fileNames, normalizePath(file.FileName()))
179
+ fileNames = append(fileNames, normalizePath(string(file.FileName())))
181
180
  }
182
181
  if out.rootDir == "" {
183
- out.rootDir = inferredRootDir(options.ConfigFilePath, fileNames, cwd, useCaseSensitiveFileNames(prog))
182
+ out.rootDir = inferredRootDir(string(options.ConfigFilePath), fileNames, string(cwd), caseSensitivity)
184
183
  }
185
184
  for _, name := range fileNames {
186
185
  out.sourceFiles[out.sourceKey(name)] = name
@@ -197,14 +196,14 @@ func newRewriter(prog *driver.Program) *rewriter {
197
196
  return out
198
197
  }
199
198
 
200
- // useCaseSensitiveFileNames reports the host filesystem's case sensitivity,
199
+ // fileSystemCaseSensitivity reports the Program filesystem's case policy,
201
200
  // defaulting to case-sensitive when the program carries no filesystem (bare
202
201
  // rewriters built by unit tests).
203
- func useCaseSensitiveFileNames(prog *driver.Program) bool {
202
+ func fileSystemCaseSensitivity(prog *driver.Program) shimtspath.CaseSensitivity {
204
203
  if prog == nil || prog.FS == nil {
205
- return true
204
+ return shimtspath.CaseSensitive
206
205
  }
207
- return prog.FS.UseCaseSensitiveFileNames()
206
+ return shimvfs.CaseSensitivityOf(prog.FS)
208
207
  }
209
208
 
210
209
  // apply rewrites all module specifiers in file that match a tsconfig paths pattern.
@@ -217,7 +216,7 @@ func (r *rewriter) apply(file *shimast.SourceFile) {
217
216
  return
218
217
  }
219
218
  spec := lit.Text()
220
- rewritten, ok := r.rewrite(file.FileName(), spec)
219
+ rewritten, ok := r.rewrite(string(file.FileName()), spec)
221
220
  if ok && rewritten != spec {
222
221
  lit.AsStringLiteral().Text = rewritten
223
222
  lit.Flags |= shimast.NodeFlagsSynthesized
@@ -302,9 +301,9 @@ func isModuleLoader(checker *shimchecker.Checker, expression *shimast.Node) bool
302
301
  if symbol == nil {
303
302
  return true
304
303
  }
305
- return symbol.Flags&shimast.SymbolFlagsAlias == 0 &&
306
- symbol.ValueDeclaration != nil &&
307
- symbol.ValueDeclaration.Flags&shimast.NodeFlagsAmbient != 0
304
+ return shimast.SymbolFlagsOf(symbol)&shimast.SymbolFlagsAlias == 0 &&
305
+ shimast.SymbolValueDeclarationOf(symbol) != nil &&
306
+ shimast.SymbolValueDeclarationOf(symbol).Flags&shimast.NodeFlagsAmbient != 0
308
307
  }
309
308
 
310
309
  // rewrite resolves specifier from fromSource using the tsconfig paths table and
@@ -560,11 +559,11 @@ func optionalPath(value string, cwd string) string {
560
559
  // directory fallback serves only a Program built without one. That fallback
561
560
  // intersects every file name it is given, whereas TypeScript-Go excludes
562
561
  // declaration files; the caller passes the Program's full source list.
563
- func inferredRootDir(configFilePath string, fileNames []string, currentDirectory string, useCaseSensitiveFileNames bool) string {
562
+ func inferredRootDir(configFilePath string, fileNames []string, currentDirectory string, caseSensitivity shimtspath.CaseSensitivity) string {
564
563
  if configFilePath != "" {
565
564
  return normalizePath(filepath.Dir(configFilePath))
566
565
  }
567
- return commonSourceDir(fileNames, currentDirectory, useCaseSensitiveFileNames)
566
+ return commonSourceDir(fileNames, currentDirectory, caseSensitivity)
568
567
  }
569
568
 
570
569
  // commonSourceDir mirrors TypeScript-Go's
@@ -577,7 +576,7 @@ func inferredRootDir(configFilePath string, fileNames []string, currentDirectory
577
576
  // the backslash form ("C:\") while the termination guard compared it against
578
577
  // the slash-normalized cursor ("C:/"), re-normalizing the same directory
579
578
  // forever.
580
- func commonSourceDir(fileNames []string, currentDirectory string, useCaseSensitiveFileNames bool) string {
579
+ func commonSourceDir(fileNames []string, currentDirectory string, caseSensitivity shimtspath.CaseSensitivity) string {
581
580
  var common []string
582
581
  for _, fileName := range fileNames {
583
582
  components := shimtspath.GetNormalizedPathComponents(fileName, currentDirectory)
@@ -590,8 +589,8 @@ func commonSourceDir(fileNames []string, currentDirectory string, useCaseSensiti
590
589
  shared := 0
591
590
  limit := min(len(common), len(components))
592
591
  for shared < limit &&
593
- shimtspath.GetCanonicalFileName(common[shared], useCaseSensitiveFileNames) ==
594
- shimtspath.GetCanonicalFileName(components[shared], useCaseSensitiveFileNames) {
592
+ shimtspath.Canonicalize(caseSensitivity, common[shared]) ==
593
+ shimtspath.Canonicalize(caseSensitivity, components[shared]) {
595
594
  shared++
596
595
  }
597
596
  if shared == 0 {
package/go.mod CHANGED
@@ -5,9 +5,9 @@ go 1.26
5
5
  require github.com/samchon/ttsc/packages/ttsc v0.0.0
6
6
 
7
7
  require (
8
- github.com/go-json-experiment/json v0.0.0-20260601182631-00ed12fed2a6 // indirect
8
+ github.com/go-json-experiment/json v0.0.0-20260623181947-01eb4420fa68 // indirect
9
9
  github.com/klauspost/cpuid/v2 v2.2.10 // indirect
10
- github.com/microsoft/typescript-go v0.0.0-20260610182825-7fc57c005063 // indirect
10
+ github.com/microsoft/typescript-go v0.0.0-20260708042240-2bd066d87f5b // indirect
11
11
  github.com/zeebo/xxh3 v1.1.0 // indirect
12
12
  golang.org/x/sync v0.21.0 // indirect
13
13
  golang.org/x/sys v0.46.0 // indirect
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ttsc/paths",
3
- "version": "0.33.1",
3
+ "version": "0.34.1",
4
4
  "description": "First-party ttsc plugin that rewrites emitted module specifiers from tsconfig paths.",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",