@ttsc/wasm 0.26.2 → 0.27.0

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.
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "schema": 1,
3
- "identity": "d2aaebc4a3fb711653c25dd4bd96266235c1765720f25de03366130d14fe1d2e",
3
+ "identity": "909fe771e33d587b54640b0c1f1971dbda3250440df3de236c2824dd9986231f",
4
4
  "artifacts": [
5
5
  {
6
6
  "path": "/home/runner/work/ttsc/ttsc/packages/wasm/dist/ttsc.wasm",
7
7
  "type": "file",
8
- "sha256": "29bafd930043ecd531782f8565448fb18ea8c5ae703b78dd1dca1c183e06ba83"
8
+ "sha256": "566c2e1f04b41c9c41c249b4d693efae7aa97a326c4946711a50d867069d30f7"
9
9
  },
10
10
  {
11
11
  "path": "/home/runner/work/ttsc/ttsc/packages/wasm/dist/wasm_exec.js",
@@ -111,11 +111,15 @@
111
111
  },
112
112
  {
113
113
  "path": "checker/go.mod",
114
- "sha256": "d191ae8d581a2d548e02221e27cdde3ad54611abd62ac7ba3c647da7435f67e6"
114
+ "sha256": "94e107d6628d4693f2da8a342e49ff326ad28d5d0c31bec30ad3a42a98aad4cf"
115
+ },
116
+ {
117
+ "path": "checker/go.sum",
118
+ "sha256": "a94c806630860a27e74df1db99b2abf86fada0e699937a813b42fe190021a16d"
115
119
  },
116
120
  {
117
121
  "path": "checker/shim.go",
118
- "sha256": "cd45126b5cc0fbbe1213343dd561c51c4d0673135ff62d6542bd1ea6e3426eab"
122
+ "sha256": "432f81d0e74e879f6a67a1f96c248b82950a899db8fe16a983bd48c9fa5af488"
119
123
  },
120
124
  {
121
125
  "path": "compiler/emit_sourcemap.go",
@@ -143,7 +147,7 @@
143
147
  },
144
148
  {
145
149
  "path": "compiler/incremental.go",
146
- "sha256": "8020631b8bc293f7cc860afbd4f40b1f4a304459b28d1111ecf366826f7e88ab"
150
+ "sha256": "3c873bed3659cfe1969a97caea105d230dad510e66d8da6e4ca2c4dc6617a04c"
147
151
  },
148
152
  {
149
153
  "path": "compiler/shim.go",
package/dist/ttsc.wasm CHANGED
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ttsc/wasm",
3
- "version": "0.26.2",
3
+ "version": "0.27.0",
4
4
  "description": "Build in-browser ttsc playgrounds. Compose ttsc + typescript-go with your own plugins via the Go host helper.",
5
5
  "main": "lib/src/index.js",
6
6
  "types": "lib/src/index.d.ts",
@@ -3,3 +3,12 @@ module github.com/microsoft/typescript-go/shim/checker
3
3
  go 1.26
4
4
 
5
5
  require github.com/microsoft/typescript-go v0.0.0-20260429010842-56ab4af42157
6
+
7
+ require (
8
+ github.com/go-json-experiment/json v0.0.0-20260214004413-d219187c3433 // indirect
9
+ github.com/klauspost/cpuid/v2 v2.2.10 // indirect
10
+ github.com/zeebo/xxh3 v1.1.0 // indirect
11
+ golang.org/x/sync v0.20.0 // indirect
12
+ golang.org/x/sys v0.43.0 // indirect
13
+ golang.org/x/text v0.36.0 // indirect
14
+ )
@@ -0,0 +1,22 @@
1
+ github.com/go-json-experiment/json v0.0.0-20260214004413-d219187c3433 h1:vymEbVwYFP/L05h5TKQxvkXoKxNvTpjxYKdF1Nlwuao=
2
+ github.com/go-json-experiment/json v0.0.0-20260214004413-d219187c3433/go.mod h1:tphK2c80bpPhMOI4v6bIc2xWywPfbqi1Z06+RcrMkDg=
3
+ github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
4
+ github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU=
5
+ github.com/klauspost/cpuid/v2 v2.2.10 h1:tBs3QSyvjDyFTq3uoc/9xFpCuOsJQFNPiAhYdw2skhE=
6
+ github.com/klauspost/cpuid/v2 v2.2.10/go.mod h1:hqwkgyIinND0mEev00jJYCxPNVRVXFQeu1XKlok6oO0=
7
+ github.com/microsoft/typescript-go v0.0.0-20260429010842-56ab4af42157 h1:llOMPhKDiQ+UEJiAaQuuWaJOTg5V7tNNTEf9JPWoYSY=
8
+ github.com/microsoft/typescript-go v0.0.0-20260429010842-56ab4af42157/go.mod h1:m8YA0PMC7ti0GW0RI05D6fEcjQeu98XVS+FWF+VDW2k=
9
+ github.com/peter-evans/patience v0.3.0 h1:rX0JdJeepqdQl1Sk9c9uvorjYYzL2TfgLX1adqYm9cA=
10
+ github.com/peter-evans/patience v0.3.0/go.mod h1:Kmxu5sY1NmBLFSStvXjX1wS9mIv7wMcP/ubucyMOAu0=
11
+ github.com/zeebo/assert v1.3.0 h1:g7C04CbJuIDKNPFHmsk4hwZDO5O+kntRxzaUoNXj+IQ=
12
+ github.com/zeebo/assert v1.3.0/go.mod h1:Pq9JiuJQpG8JLJdtkwrJESF0Foym2/D9XMU5ciN/wJ0=
13
+ github.com/zeebo/xxh3 v1.1.0 h1:s7DLGDK45Dyfg7++yxI0khrfwq9661w9EN78eP/UZVs=
14
+ github.com/zeebo/xxh3 v1.1.0/go.mod h1:IisAie1LELR4xhVinxWS5+zf1lA4p0MW4T+w+W07F5s=
15
+ golang.org/x/sync v0.20.0 h1:e0PTpb7pjO8GAtTs2dQ6jYa5BWYlMuX047Dco/pItO4=
16
+ golang.org/x/sync v0.20.0/go.mod h1:9xrNwdLfx4jkKbNva9FpL6vEN7evnE43NNNJQ2LF3+0=
17
+ golang.org/x/sys v0.43.0 h1:Rlag2XtaFTxp19wS8MXlJwTvoh8ArU6ezoyFsMyCTNI=
18
+ golang.org/x/sys v0.43.0/go.mod h1:4GL1E5IUh+htKOUEOaiffhrAeqysfVGipDYzABqnCmw=
19
+ golang.org/x/text v0.36.0 h1:JfKh3XmcRPqZPKevfXVpI1wXPTqbkE5f7JA92a55Yxg=
20
+ golang.org/x/text v0.36.0/go.mod h1:NIdBknypM8iqVmPiuco0Dh6P5Jcdk8lJL0CUebqK164=
21
+ gotest.tools/v3 v3.5.2 h1:7koQfIKdy+I8UTetycgUqXWSDwpgv193Ka+qRsmBY8Q=
22
+ gotest.tools/v3 v3.5.2/go.mod h1:LtdLGcnqToBH83WByAAi/wiwSFCArdFIUV/xxN4pcjA=
@@ -22,6 +22,8 @@ type IndexInfo = innerchecker.IndexInfo
22
22
  type Signature = innerchecker.Signature
23
23
  type SignatureKind = innerchecker.SignatureKind
24
24
  type Type = innerchecker.Type
25
+ type TypeMapper = innerchecker.TypeMapper
26
+ type TypeMapperKind = innerchecker.TypeMapperKind
25
27
  type TypeFlags = innerchecker.TypeFlags
26
28
  type ObjectFlags = innerchecker.ObjectFlags
27
29
  type ElementFlags = innerchecker.ElementFlags
@@ -216,6 +218,11 @@ func Checker_isSymbolAccessibleAsValue(recv *innerchecker.Checker, symbol *inner
216
218
  const (
217
219
  SignatureKindCall = innerchecker.SignatureKindCall
218
220
 
221
+ TypeMapperKindUnknown = innerchecker.TypeMapperKindUnknown
222
+ TypeMapperKindSimple = innerchecker.TypeMapperKindSimple
223
+ TypeMapperKindArray = innerchecker.TypeMapperKindArray
224
+ TypeMapperKindMerged = innerchecker.TypeMapperKindMerged
225
+
219
226
  TypeFlagsAny = innerchecker.TypeFlagsAny
220
227
  TypeFlagsUnknown = innerchecker.TypeFlagsUnknown
221
228
  TypeFlagsUndefined = innerchecker.TypeFlagsUndefined
@@ -597,3 +604,71 @@ func Checker_getRestTypeOfSignature(recv *innerchecker.Checker, signature *inner
597
604
  }
598
605
  return recv.GetRestTypeOfSignature(signature)
599
606
  }
607
+
608
+ //go:linkname checkerInstantiateType github.com/microsoft/typescript-go/internal/checker.(*Checker).instantiateType
609
+ func checkerInstantiateType(recv *innerchecker.Checker, t *innerchecker.Type, m *innerchecker.TypeMapper) *innerchecker.Type
610
+
611
+ //go:linkname checkerNewSimpleTypeMapper github.com/microsoft/typescript-go/internal/checker.newSimpleTypeMapper
612
+ func checkerNewSimpleTypeMapper(source *innerchecker.Type, target *innerchecker.Type) *innerchecker.TypeMapper
613
+
614
+ //go:linkname checkerNewTypeMapper github.com/microsoft/typescript-go/internal/checker.newTypeMapper
615
+ func checkerNewTypeMapper(sources []*innerchecker.Type, targets []*innerchecker.Type) *innerchecker.TypeMapper
616
+
617
+ // Checker_instantiateType substitutes the type parameters of `t` with the
618
+ // concrete types in `mapper`, returning the instantiated type. A type-transform
619
+ // plugin uses it to instantiate a generic class's constructor type with the
620
+ // reference's type arguments, so a type parameter nested inside a container
621
+ // (`A[]`, `[A, B]`) is substituted for free. Returns nil if recv or t is nil.
622
+ func Checker_instantiateType(recv *innerchecker.Checker, t *innerchecker.Type, mapper *innerchecker.TypeMapper) *innerchecker.Type {
623
+ if recv == nil || t == nil {
624
+ return nil
625
+ }
626
+ return checkerInstantiateType(recv, t, mapper)
627
+ }
628
+
629
+ // Checker_newSimpleTypeMapper builds a single-pair type mapper that substitutes
630
+ // `source` with `target`. It is the building block for instantiating a generic
631
+ // class's constructor type with its reference type arguments. Returns nil if
632
+ // source or target is nil.
633
+ func Checker_newSimpleTypeMapper(source *innerchecker.Type, target *innerchecker.Type) *innerchecker.TypeMapper {
634
+ if source == nil || target == nil {
635
+ return nil
636
+ }
637
+ return checkerNewSimpleTypeMapper(source, target)
638
+ }
639
+
640
+ // Checker_newTypeMapper builds a parallel type mapper from corresponding
641
+ // source and target slices. Unlike Checker_combineTypeMappers, it does not feed
642
+ // one substitution's target through later substitutions, so a mapping such as
643
+ // `[A, B] -> [B, A]` preserves both target identities. Returns nil when the
644
+ // slices are empty, differ in length, or contain nil types.
645
+ func Checker_newTypeMapper(sources []*innerchecker.Type, targets []*innerchecker.Type) *innerchecker.TypeMapper {
646
+ if len(sources) == 0 || len(sources) != len(targets) {
647
+ return nil
648
+ }
649
+ for i := range sources {
650
+ if sources[i] == nil || targets[i] == nil {
651
+ return nil
652
+ }
653
+ }
654
+ return checkerNewTypeMapper(sources, targets)
655
+ }
656
+
657
+ //go:linkname checkerCombineTypeMappers github.com/microsoft/typescript-go/internal/checker.(*Checker).combineTypeMappers
658
+ func checkerCombineTypeMappers(recv *innerchecker.Checker, m1 *innerchecker.TypeMapper, m2 *innerchecker.TypeMapper) *innerchecker.TypeMapper
659
+
660
+ // Checker_combineTypeMappers composes two mapper stages. The first mapper's
661
+ // substituted target is instantiated through the second mapper, so use
662
+ // Checker_newTypeMapper instead when source and target slices are parallel
663
+ // declaration-parameter mappings. Returns m2 when m1 is nil, including when
664
+ // recv is nil. Returns nil when m1 is non-nil and recv or m2 is nil, because
665
+ // both are required to build a usable composite mapper.
666
+ func Checker_combineTypeMappers(recv *innerchecker.Checker, m1 *innerchecker.TypeMapper, m2 *innerchecker.TypeMapper) *innerchecker.TypeMapper {
667
+ if m1 == nil {
668
+ return m2
669
+ }
670
+ if recv == nil || m2 == nil {
671
+ return nil
672
+ }
673
+ return checkerCombineTypeMappers(recv, m1, m2)
674
+ }
@@ -1,13 +1,20 @@
1
1
  // gen_shims:hand-maintained
2
2
  //
3
- // Reference-graph parts of tsgo's own incremental engine (`tsc --incremental`
4
- // semantics), linked from internal/execute/incremental so ttsc's transform
5
- // envelopes can carry the same language-semantic input bound the compiler
6
- // itself uses for invalidation: per-file direct resolved references and the
7
- // files that contribute to the global scope.
3
+ // Parts of tsgo's own incremental engine (`tsc --incremental` semantics),
4
+ // exposed from internal/execute/incremental for the two things a ttsc host
5
+ // needs from it:
6
+ //
7
+ // - the reference graph, so transform envelopes can carry the same
8
+ // language-semantic input bound the compiler itself uses for invalidation:
9
+ // per-file direct resolved references and the files that contribute to the
10
+ // global scope;
11
+ // - the build-information emit, so a host that constructs its Program
12
+ // in-process still writes the `.tsbuildinfo` an `incremental` or
13
+ // `composite` project asked for.
8
14
  package compiler
9
15
 
10
16
  import (
17
+ "context"
11
18
  _ "unsafe"
12
19
 
13
20
  innerast "github.com/microsoft/typescript-go/internal/ast"
@@ -15,11 +22,41 @@ import (
15
22
  innercompiler "github.com/microsoft/typescript-go/internal/compiler"
16
23
  "github.com/microsoft/typescript-go/internal/tspath"
17
24
 
18
- // The linknamed symbols below live in the incremental package; the blank
19
- // import compiles it into every shim consumer so the references resolve.
20
- _ "github.com/microsoft/typescript-go/internal/execute/incremental"
25
+ // Imported for EmitFreshWithBuildInfo below, and for the linknamed symbols
26
+ // further down: compiling the package into every shim consumer is what makes
27
+ // those references resolve.
28
+ "github.com/microsoft/typescript-go/internal/execute/incremental"
21
29
  )
22
30
 
31
+ // EmitFreshWithBuildInfo runs a full emit through tsgo's own incremental
32
+ // program, so an `incremental` or `composite` project gets the `.tsbuildinfo`
33
+ // tsgo would have written, in the exact format and location
34
+ // `outputpaths.GetBuildInfoFileName` resolves from the compiler options.
35
+ //
36
+ // This is the emit half of `tsc.go::performIncrementalCompilation`, which the
37
+ // tsgo CLI takes whenever `CompilerOptions.IsIncremental()`. A host that builds
38
+ // its Program in-process (ttsc's driver, and therefore every plugin sidecar
39
+ // emitting through it) never reaches that CLI path, so without this the build
40
+ // information is silently dropped even though the options parsed cleanly.
41
+ //
42
+ // "Fresh" is the load-bearing word: no previous snapshot is supplied, so
43
+ // `programToSnapshot` marks every file changed and this emits the whole program
44
+ // exactly as `Program.Emit` does, then writes the build info. A ttsc plugin's
45
+ // output is not a pure function of the source text a build info records — it
46
+ // also depends on the plugin binary, its config file, and its contributors —
47
+ // so reusing a previous snapshot to skip a file would serve stale transformed
48
+ // output. Producing the record is sound; consuming it needs plugin identity in
49
+ // the invalidation key first.
50
+ func EmitFreshWithBuildInfo(ctx context.Context, program *Program, options EmitOptions) *EmitResult {
51
+ incrementalProgram := incremental.NewProgram(
52
+ program,
53
+ nil,
54
+ incremental.CreateHost(program.Host()),
55
+ false,
56
+ )
57
+ return incrementalProgram.Emit(ctx, options)
58
+ }
59
+
23
60
  //go:linkname incrementalGetReferencedFiles github.com/microsoft/typescript-go/internal/execute/incremental.getReferencedFiles
24
61
  func incrementalGetReferencedFiles(program *innercompiler.Program, file *innerast.SourceFile) *collections.Set[tspath.Path]
25
62