ttsc 0.15.1 → 0.15.3
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/driver/emit_plugin.go +34 -5
- package/driver/sourcemap_preamble.go +375 -0
- package/lib/TtscCompiler.js +4 -1
- package/lib/TtscCompiler.js.map +1 -1
- package/lib/compiler/internal/project/readProjectConfig.js +4 -1
- package/lib/compiler/internal/project/readProjectConfig.js.map +1 -1
- package/lib/compiler/internal/transformProjectInMemory.d.ts +1 -0
- package/lib/compiler/internal/transformProjectInMemory.js +36 -0
- package/lib/compiler/internal/transformProjectInMemory.js.map +1 -1
- package/lib/launcher/internal/prepareExecution.js +14 -0
- package/lib/launcher/internal/prepareExecution.js.map +1 -1
- package/lib/launcher/internal/runtimeHooks.js +369 -24
- package/lib/launcher/internal/runtimeHooks.js.map +1 -1
- package/lib/plugin/internal/buildSourcePlugin.js +7 -7
- package/lib/plugin/internal/buildSourcePlugin.js.map +1 -1
- package/lib/structures/ITtscCompilerTransformation.d.ts +18 -0
- package/package.json +9 -9
- package/shim/compiler/emit_sourcemap.go +176 -0
- package/src/TtscCompiler.ts +5 -1
- package/src/compiler/internal/project/readProjectConfig.ts +5 -1
- package/src/compiler/internal/transformProjectInMemory.ts +46 -0
- package/src/launcher/internal/prepareExecution.ts +16 -0
- package/src/launcher/internal/runtimeHooks.ts +475 -33
- package/src/plugin/internal/buildSourcePlugin.ts +11 -8
- package/src/structures/ITtscCompilerTransformation.ts +20 -0
- package/utility/host.go +30 -7
package/driver/emit_plugin.go
CHANGED
|
@@ -2,6 +2,7 @@ package driver
|
|
|
2
2
|
|
|
3
3
|
import (
|
|
4
4
|
"errors"
|
|
5
|
+
"strings"
|
|
5
6
|
|
|
6
7
|
shimast "github.com/microsoft/typescript-go/shim/ast"
|
|
7
8
|
shimcompiler "github.com/microsoft/typescript-go/shim/compiler"
|
|
@@ -130,13 +131,17 @@ func restoreOriginalDeclarationSymbols(ec *shimprinter.EmitContext, node *shimas
|
|
|
130
131
|
// in the same EmitContext as the builtin chain (type-erase, import-elision,
|
|
131
132
|
// module-transform, ...). No text-splice and no hand-rolled import aliasing:
|
|
132
133
|
// tsgo's module-transform aliases the plugins' injected imports itself.
|
|
134
|
+
//
|
|
135
|
+
// Because this bypasses tsgo's own emitter, it reproduces the emitter's
|
|
136
|
+
// source-map step via PrintFileWithSourceMap: a `sourceMap` / `inlineSourceMap`
|
|
137
|
+
// build emits a `.js.map` (and `//# sourceMappingURL=` trailer) just like a
|
|
138
|
+
// plain build, even when a transform expanded one source line into many.
|
|
133
139
|
func (p *Program) EmitWithPluginTransformers(transforms []PluginTransform, writeFile shimcompiler.WriteFile) ([]Diagnostic, error) {
|
|
134
140
|
if p == nil || p.TSProgram == nil {
|
|
135
141
|
return nil, errors.New("driver: nil program")
|
|
136
142
|
}
|
|
137
143
|
host := &pluginEmitHost{program: p.TSProgram, emitResolver: p.Checker.GetEmitResolver()}
|
|
138
144
|
options := p.TSProgram.Options()
|
|
139
|
-
newLine := options.NewLine.GetNewLineCharacter()
|
|
140
145
|
for _, sf := range shimcompiler.GetSourceFilesToEmit(host, nil, false) {
|
|
141
146
|
ec := shimprinter.NewEmitContext()
|
|
142
147
|
out := sf
|
|
@@ -154,12 +159,36 @@ func (p *Program) EmitWithPluginTransformers(transforms []PluginTransform, write
|
|
|
154
159
|
out = tr.TransformSourceFile(out)
|
|
155
160
|
}
|
|
156
161
|
paths := shimcompiler.GetOutputPathsFor(sf, options, host, false)
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
162
|
+
// Print through the source-map-aware helper so a `sourceMap` /
|
|
163
|
+
// `inlineSourceMap` build still gets its `.js.map` and sourceMappingURL
|
|
164
|
+
// trailer: the hand-assembled emit pipeline does not run tsgo's emitter, so
|
|
165
|
+
// the source-map step printSourceFile would otherwise perform has to happen
|
|
166
|
+
// here. With maps off this is the same bare-printer output as before.
|
|
167
|
+
printed := shimcompiler.PrintFileWithSourceMap(ec, out.AsNode(), out, options, host, paths.JsFilePath(), paths.SourceMapFilePath())
|
|
168
|
+
// A source-level preamble (e.g. @ttsc/banner linked into a typia host) shifts
|
|
169
|
+
// the map's source coordinates; correct them here too, so the
|
|
170
|
+
// preamble-plus-transform combination is not left uncorrected the way it
|
|
171
|
+
// would be if only the utility host's WriteFile patched maps. Covers both the
|
|
172
|
+
// external `.js.map` and an inline base64 map embedded in the JS.
|
|
173
|
+
if p.SourcePreamble != "" {
|
|
174
|
+
dropLines := strings.Count(p.SourcePreamble, "\n")
|
|
175
|
+
if adjusted, ok := AdjustEmittedSourceMap(paths.JsFilePath(), printed.JS, dropLines); ok {
|
|
176
|
+
printed.JS = adjusted
|
|
177
|
+
}
|
|
178
|
+
if printed.MapPath != "" {
|
|
179
|
+
if adjusted, ok := AdjustEmittedSourceMap(printed.MapPath, printed.MapText, dropLines); ok {
|
|
180
|
+
printed.MapText = adjusted
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
if err := writeFile(paths.JsFilePath(), printed.JS, nil); err != nil {
|
|
161
185
|
return nil, err
|
|
162
186
|
}
|
|
187
|
+
if printed.MapPath != "" {
|
|
188
|
+
if err := writeFile(printed.MapPath, printed.MapText, nil); err != nil {
|
|
189
|
+
return nil, err
|
|
190
|
+
}
|
|
191
|
+
}
|
|
163
192
|
}
|
|
164
193
|
return nil, nil
|
|
165
194
|
}
|
|
@@ -0,0 +1,375 @@
|
|
|
1
|
+
package driver
|
|
2
|
+
|
|
3
|
+
import (
|
|
4
|
+
"bytes"
|
|
5
|
+
"encoding/base64"
|
|
6
|
+
"encoding/json"
|
|
7
|
+
"strings"
|
|
8
|
+
)
|
|
9
|
+
|
|
10
|
+
// marshalSourceMapJSON encodes a source-map value WITHOUT Go's default HTML
|
|
11
|
+
// escaping, so `<`, `>`, and `&` in embedded source text (`sourcesContent`)
|
|
12
|
+
// stay literal — matching TypeScript-Go's serializer and avoiding a byte-level
|
|
13
|
+
// divergence from the maps tsgo emits natively.
|
|
14
|
+
func marshalSourceMapJSON(v any) ([]byte, error) {
|
|
15
|
+
var buf bytes.Buffer
|
|
16
|
+
encoder := json.NewEncoder(&buf)
|
|
17
|
+
encoder.SetEscapeHTML(false)
|
|
18
|
+
if err := encoder.Encode(v); err != nil {
|
|
19
|
+
return nil, err
|
|
20
|
+
}
|
|
21
|
+
return bytes.TrimRight(buf.Bytes(), "\n"), nil
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
// inlineSourceMapMarker is the full trailer tsgo writes before an inline
|
|
25
|
+
// (base64) source map: `//# sourceMappingURL=` (the comment) followed by
|
|
26
|
+
// sourcemap.Generator.Base64DataURL's `data:application/json;base64,` prefix.
|
|
27
|
+
// Anchoring on the comment form (not the bare `sourceMappingURL=`) keeps a
|
|
28
|
+
// stray `data:` string literal elsewhere in the output from being mistaken for
|
|
29
|
+
// the trailer. The map JSON follows, StdEncoding-base64'd, to the line's end.
|
|
30
|
+
const inlineSourceMapMarker = "//# sourceMappingURL=data:application/json;base64,"
|
|
31
|
+
|
|
32
|
+
// AdjustEmittedSourceMap corrects a source map that a source-level preamble
|
|
33
|
+
// shifted, given one emitted output file's name and text. It dispatches on the
|
|
34
|
+
// shape: an external `.map` file carries the map JSON directly; a JS/declaration
|
|
35
|
+
// output with `inlineSourceMap` carries it base64-embedded in a
|
|
36
|
+
// `//# sourceMappingURL=data:...` trailer. Non-map, non-JS/declaration outputs
|
|
37
|
+
// (e.g. `.tsbuildinfo`) are never scanned. Returns (text, false) when there is
|
|
38
|
+
// nothing to correct (no preamble, no map, or unparseable).
|
|
39
|
+
//
|
|
40
|
+
// This is the single entry point every map-emitting path funnels through so the
|
|
41
|
+
// preamble correction is applied uniformly — the utility host's WriteFile (tsgo
|
|
42
|
+
// native emit) and the driver's plugin-transform emit (EmitWithPluginTransformers,
|
|
43
|
+
// e.g. typia + @ttsc/banner) both call it, external and inline alike.
|
|
44
|
+
//
|
|
45
|
+
// NOTE: this is NOT idempotent — applying it twice shifts source lines up by
|
|
46
|
+
// dropLines twice. Each emit path must call it exactly once per file; a writeFile
|
|
47
|
+
// passed to an emit path that already self-corrects (EmitWithPluginTransformers)
|
|
48
|
+
// must not call it again.
|
|
49
|
+
func AdjustEmittedSourceMap(fileName, text string, dropLines int) (string, bool) {
|
|
50
|
+
if dropLines <= 0 {
|
|
51
|
+
return text, false
|
|
52
|
+
}
|
|
53
|
+
lower := strings.ToLower(fileName)
|
|
54
|
+
if strings.HasSuffix(lower, ".map") {
|
|
55
|
+
return AdjustSourceMapForPreamble(text, dropLines)
|
|
56
|
+
}
|
|
57
|
+
if !isInlineSourceMapCarrier(lower) {
|
|
58
|
+
return text, false
|
|
59
|
+
}
|
|
60
|
+
return adjustInlineSourceMap(text, dropLines)
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// isInlineSourceMapCarrier reports whether an emitted file can carry an inline
|
|
64
|
+
// `//# sourceMappingURL=data:...` trailer (a JavaScript or declaration output),
|
|
65
|
+
// so other outputs (`.tsbuildinfo`, `.json`, ...) are never scanned for the
|
|
66
|
+
// marker and cannot be corrupted by a coincidental match.
|
|
67
|
+
func isInlineSourceMapCarrier(lowerName string) bool {
|
|
68
|
+
for _, suffix := range []string{".js", ".jsx", ".mjs", ".cjs", ".d.ts", ".d.mts", ".d.cts"} {
|
|
69
|
+
if strings.HasSuffix(lowerName, suffix) {
|
|
70
|
+
return true
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
return false
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
// adjustInlineSourceMap rewrites the base64 map embedded in a
|
|
77
|
+
// `//# sourceMappingURL=data:application/json;base64,<...>` trailer of an emitted
|
|
78
|
+
// JS/declaration file, leaving the rest of the text untouched. The data URL is
|
|
79
|
+
// the file's last line, so LastIndex lands on the real trailer.
|
|
80
|
+
func adjustInlineSourceMap(text string, dropLines int) (string, bool) {
|
|
81
|
+
marker := strings.LastIndex(text, inlineSourceMapMarker)
|
|
82
|
+
if marker < 0 {
|
|
83
|
+
return text, false
|
|
84
|
+
}
|
|
85
|
+
start := marker + len(inlineSourceMapMarker)
|
|
86
|
+
end := start
|
|
87
|
+
for end < len(text) && text[end] != '\n' && text[end] != '\r' {
|
|
88
|
+
end++
|
|
89
|
+
}
|
|
90
|
+
raw, err := base64.StdEncoding.DecodeString(strings.TrimRight(text[start:end], " \t"))
|
|
91
|
+
if err != nil {
|
|
92
|
+
return text, false
|
|
93
|
+
}
|
|
94
|
+
adjusted, ok := AdjustSourceMapForPreamble(string(raw), dropLines)
|
|
95
|
+
if !ok {
|
|
96
|
+
return text, false
|
|
97
|
+
}
|
|
98
|
+
return text[:start] + base64.StdEncoding.EncodeToString([]byte(adjusted)) + text[end:], true
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
// AdjustSourceMapForPreamble corrects a source map after a source preamble was
|
|
102
|
+
// injected ahead of the parsed source.
|
|
103
|
+
//
|
|
104
|
+
// ttsc injects a plugin's source preamble (e.g. @ttsc/banner's copyright block)
|
|
105
|
+
// at the SOURCE level: sourcePreambleFS prepends it before TypeScript-Go parses,
|
|
106
|
+
// so the preamble participates in comment emission, removeComments, JSDoc
|
|
107
|
+
// association, and `.d.ts` emit naturally. The side effect is that every source
|
|
108
|
+
// coordinate the emitter records is shifted down by the preamble's line count —
|
|
109
|
+
// but the on-disk source file the map points at has no preamble. Left unpatched,
|
|
110
|
+
// every mapping for real code lands `dropLines` lines too far down (on blank or
|
|
111
|
+
// nonexistent lines), so a debugger jumps to the wrong place.
|
|
112
|
+
//
|
|
113
|
+
// This rewrites the map's `mappings` to undo that shift, per source: a segment is
|
|
114
|
+
// only adjusted when its source file (`sources[sourceIndex]`) is one the preamble
|
|
115
|
+
// was injected into (`isSourcePreambleTarget`) — so a mixed map (e.g. a bundled
|
|
116
|
+
// `.js`/`.json` map under `outFile`) leaves `.json` segments alone. For an
|
|
117
|
+
// adjusted source, segments inside the preamble region (source line < dropLines)
|
|
118
|
+
// are dropped — those generated lines are the emitted preamble comment, which has
|
|
119
|
+
// no real-source counterpart and is left unmapped — and every remaining segment's
|
|
120
|
+
// source line is moved up by dropLines so it points at the real file. The
|
|
121
|
+
// generated side is untouched.
|
|
122
|
+
//
|
|
123
|
+
// dropLines is the number of newlines the preamble adds (strings.Count(preamble,
|
|
124
|
+
// "\n")). The drop region assumes the preamble occupies the leading source lines
|
|
125
|
+
// [0, dropLines); for a hashbang file ApplySourcePreamble inserts the preamble
|
|
126
|
+
// after the shebang line, so the region is nominally off by one — but shebang and
|
|
127
|
+
// preamble-comment lines never carry node mappings, so real-code correction is
|
|
128
|
+
// unaffected. Returns (rewritten, true) on success, or (input, false) when there
|
|
129
|
+
// is nothing to do or the map cannot be parsed (the caller then writes it as-is).
|
|
130
|
+
func AdjustSourceMapForPreamble(mapText string, dropLines int) (string, bool) {
|
|
131
|
+
if dropLines <= 0 || strings.TrimSpace(mapText) == "" {
|
|
132
|
+
return mapText, false
|
|
133
|
+
}
|
|
134
|
+
var doc map[string]json.RawMessage
|
|
135
|
+
if err := json.Unmarshal([]byte(mapText), &doc); err != nil {
|
|
136
|
+
return mapText, false
|
|
137
|
+
}
|
|
138
|
+
rawMappings, ok := doc["mappings"]
|
|
139
|
+
if !ok {
|
|
140
|
+
return mapText, false
|
|
141
|
+
}
|
|
142
|
+
var mappings string
|
|
143
|
+
if err := json.Unmarshal(rawMappings, &mappings); err != nil {
|
|
144
|
+
return mapText, false
|
|
145
|
+
}
|
|
146
|
+
mask := preambleSourceMask(doc["sources"])
|
|
147
|
+
rewritten, mappingsChanged := shiftMappingSources(mappings, dropLines, mask)
|
|
148
|
+
// Under `inlineSources` the map embeds the source TEXT in `sourcesContent`, and
|
|
149
|
+
// that text is the preamble-injected source (sourcePreambleFS prepended the
|
|
150
|
+
// preamble before parsing). Strip the leading dropLines preamble lines from
|
|
151
|
+
// each preamble-injected source so the embedded text lines up with the
|
|
152
|
+
// corrected mappings; otherwise a debugger using sourcesContent shows the
|
|
153
|
+
// banner and every line is off by dropLines. This is computed independently of
|
|
154
|
+
// the mapping shift: a comment-only or empty source file has no mappings to
|
|
155
|
+
// shift, yet its embedded sourcesContent still carries the preamble.
|
|
156
|
+
stripped, contentChanged := stripPreambleFromSourcesContent(doc["sourcesContent"], dropLines, mask)
|
|
157
|
+
if !mappingsChanged && !contentChanged {
|
|
158
|
+
return mapText, false
|
|
159
|
+
}
|
|
160
|
+
if mappingsChanged {
|
|
161
|
+
encoded, err := marshalSourceMapJSON(rewritten)
|
|
162
|
+
if err != nil {
|
|
163
|
+
return mapText, false
|
|
164
|
+
}
|
|
165
|
+
doc["mappings"] = encoded
|
|
166
|
+
}
|
|
167
|
+
if contentChanged {
|
|
168
|
+
doc["sourcesContent"] = stripped
|
|
169
|
+
}
|
|
170
|
+
out, err := marshalSourceMapJSON(doc)
|
|
171
|
+
if err != nil {
|
|
172
|
+
return mapText, false
|
|
173
|
+
}
|
|
174
|
+
return string(out), true
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
// stripPreambleFromSourcesContent removes the leading dropLines lines (the
|
|
178
|
+
// injected preamble) from each non-null `sourcesContent` entry whose source was
|
|
179
|
+
// preamble-injected (per mask). Returns the re-encoded array and true when it
|
|
180
|
+
// changed anything, or (nil, false) when there is no sourcesContent to adjust.
|
|
181
|
+
func stripPreambleFromSourcesContent(rawContent json.RawMessage, dropLines int, mask []bool) (json.RawMessage, bool) {
|
|
182
|
+
if len(rawContent) == 0 {
|
|
183
|
+
return nil, false
|
|
184
|
+
}
|
|
185
|
+
var contents []*string
|
|
186
|
+
if err := json.Unmarshal(rawContent, &contents); err != nil {
|
|
187
|
+
return nil, false
|
|
188
|
+
}
|
|
189
|
+
changed := false
|
|
190
|
+
for i, content := range contents {
|
|
191
|
+
if content == nil {
|
|
192
|
+
continue
|
|
193
|
+
}
|
|
194
|
+
if mask != nil && i < len(mask) && !mask[i] {
|
|
195
|
+
continue
|
|
196
|
+
}
|
|
197
|
+
parts := strings.SplitN(*content, "\n", dropLines+1)
|
|
198
|
+
if len(parts) <= dropLines {
|
|
199
|
+
continue
|
|
200
|
+
}
|
|
201
|
+
rest := parts[dropLines]
|
|
202
|
+
contents[i] = &rest
|
|
203
|
+
changed = true
|
|
204
|
+
}
|
|
205
|
+
if !changed {
|
|
206
|
+
return nil, false
|
|
207
|
+
}
|
|
208
|
+
encoded, err := marshalSourceMapJSON(contents)
|
|
209
|
+
if err != nil {
|
|
210
|
+
return nil, false
|
|
211
|
+
}
|
|
212
|
+
return encoded, true
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
// preambleSourceMask decodes a source map's `sources` array into a per-index flag
|
|
216
|
+
// of whether that source was preamble-injected (and therefore needs correcting).
|
|
217
|
+
// Returns nil when sources is absent or unparseable, which shiftMappingSources
|
|
218
|
+
// treats as "adjust every source" — the correct default for the common single
|
|
219
|
+
// `.ts`-source map.
|
|
220
|
+
func preambleSourceMask(rawSources json.RawMessage) []bool {
|
|
221
|
+
if len(rawSources) == 0 {
|
|
222
|
+
return nil
|
|
223
|
+
}
|
|
224
|
+
var sources []string
|
|
225
|
+
if err := json.Unmarshal(rawSources, &sources); err != nil {
|
|
226
|
+
return nil
|
|
227
|
+
}
|
|
228
|
+
mask := make([]bool, len(sources))
|
|
229
|
+
for i, source := range sources {
|
|
230
|
+
mask[i] = isSourcePreambleTarget(source)
|
|
231
|
+
}
|
|
232
|
+
return mask
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
// shiftMappingSources decodes a source map `mappings` string and, for every
|
|
236
|
+
// segment whose source was preamble-injected (per mask), drops it when its
|
|
237
|
+
// absolute source line is below dropLines and subtracts dropLines otherwise;
|
|
238
|
+
// segments on non-preamble sources pass through unchanged. It then re-encodes.
|
|
239
|
+
// genCol resets per generated line; sourceIndex, sourceLine, sourceColumn, and
|
|
240
|
+
// nameIndex are cumulative across the whole string (Base64 VLQ deltas), so the
|
|
241
|
+
// absolute state is tracked and the deltas recomputed from scratch after the edit.
|
|
242
|
+
// mask is nil to adjust every source.
|
|
243
|
+
func shiftMappingSources(mappings string, dropLines int, mask []bool) (string, bool) {
|
|
244
|
+
var srcIdx, srcLine, srcCol, nameIdx int // running absolute decode state
|
|
245
|
+
// Re-encode state mirrors the decode cumulants but only advances over kept
|
|
246
|
+
// segments, so dropped segments do not leave a delta gap.
|
|
247
|
+
var outSrcIdx, outSrcLine, outSrcCol, outNameIdx int
|
|
248
|
+
changed := false
|
|
249
|
+
|
|
250
|
+
shiftable := func(index int) bool {
|
|
251
|
+
return mask == nil || index < 0 || index >= len(mask) || mask[index]
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
lines := strings.Split(mappings, ";")
|
|
255
|
+
outLines := make([]string, len(lines))
|
|
256
|
+
for li, line := range lines {
|
|
257
|
+
if line == "" {
|
|
258
|
+
outLines[li] = ""
|
|
259
|
+
continue
|
|
260
|
+
}
|
|
261
|
+
var genCol int // resets each generated line (decode)
|
|
262
|
+
var outGenCol int // resets each generated line (encode)
|
|
263
|
+
segments := strings.Split(line, ",")
|
|
264
|
+
kept := make([]string, 0, len(segments))
|
|
265
|
+
for _, seg := range segments {
|
|
266
|
+
if seg == "" {
|
|
267
|
+
continue
|
|
268
|
+
}
|
|
269
|
+
fields := decodeVLQ(seg)
|
|
270
|
+
if len(fields) == 0 {
|
|
271
|
+
continue
|
|
272
|
+
}
|
|
273
|
+
genCol += fields[0]
|
|
274
|
+
if len(fields) < 4 {
|
|
275
|
+
// Generated-column-only segment: no source position to shift. Keep it,
|
|
276
|
+
// encoding the genCol delta against the running output genCol.
|
|
277
|
+
kept = append(kept, encodeVLQ([]int{genCol - outGenCol}))
|
|
278
|
+
outGenCol = genCol
|
|
279
|
+
continue
|
|
280
|
+
}
|
|
281
|
+
srcIdx += fields[1]
|
|
282
|
+
srcLine += fields[2]
|
|
283
|
+
srcCol += fields[3]
|
|
284
|
+
hasName := len(fields) >= 5
|
|
285
|
+
if hasName {
|
|
286
|
+
nameIdx += fields[4]
|
|
287
|
+
}
|
|
288
|
+
newSrcLine := srcLine
|
|
289
|
+
if shiftable(srcIdx) {
|
|
290
|
+
if srcLine < dropLines {
|
|
291
|
+
// Inside the injected preamble region: drop the mapping. The decode
|
|
292
|
+
// cumulants already advanced above, so deltas for later kept segments
|
|
293
|
+
// stay correct relative to the real source position.
|
|
294
|
+
changed = true
|
|
295
|
+
continue
|
|
296
|
+
}
|
|
297
|
+
newSrcLine = srcLine - dropLines
|
|
298
|
+
changed = changed || newSrcLine != srcLine
|
|
299
|
+
}
|
|
300
|
+
out := []int{
|
|
301
|
+
genCol - outGenCol,
|
|
302
|
+
srcIdx - outSrcIdx,
|
|
303
|
+
newSrcLine - outSrcLine,
|
|
304
|
+
srcCol - outSrcCol,
|
|
305
|
+
}
|
|
306
|
+
if hasName {
|
|
307
|
+
out = append(out, nameIdx-outNameIdx)
|
|
308
|
+
outNameIdx = nameIdx
|
|
309
|
+
}
|
|
310
|
+
kept = append(kept, encodeVLQ(out))
|
|
311
|
+
outGenCol = genCol
|
|
312
|
+
outSrcIdx = srcIdx
|
|
313
|
+
outSrcLine = newSrcLine
|
|
314
|
+
outSrcCol = srcCol
|
|
315
|
+
}
|
|
316
|
+
outLines[li] = strings.Join(kept, ",")
|
|
317
|
+
}
|
|
318
|
+
return strings.Join(outLines, ";"), changed
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
const base64Chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"
|
|
322
|
+
|
|
323
|
+
// decodeVLQ decodes a Base64 VLQ-encoded source-map segment into its signed
|
|
324
|
+
// integer fields.
|
|
325
|
+
func decodeVLQ(segment string) []int {
|
|
326
|
+
var out []int
|
|
327
|
+
shift := 0
|
|
328
|
+
value := 0
|
|
329
|
+
for i := 0; i < len(segment); i++ {
|
|
330
|
+
digit := strings.IndexByte(base64Chars, segment[i])
|
|
331
|
+
if digit < 0 {
|
|
332
|
+
return nil
|
|
333
|
+
}
|
|
334
|
+
cont := digit&32 != 0
|
|
335
|
+
value += (digit & 31) << shift
|
|
336
|
+
if cont {
|
|
337
|
+
shift += 5
|
|
338
|
+
continue
|
|
339
|
+
}
|
|
340
|
+
negative := value&1 != 0
|
|
341
|
+
value >>= 1
|
|
342
|
+
if negative {
|
|
343
|
+
value = -value
|
|
344
|
+
}
|
|
345
|
+
out = append(out, value)
|
|
346
|
+
shift = 0
|
|
347
|
+
value = 0
|
|
348
|
+
}
|
|
349
|
+
return out
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
// encodeVLQ encodes signed integer fields as a Base64 VLQ source-map segment.
|
|
353
|
+
func encodeVLQ(fields []int) string {
|
|
354
|
+
var b strings.Builder
|
|
355
|
+
for _, field := range fields {
|
|
356
|
+
var value int
|
|
357
|
+
if field < 0 {
|
|
358
|
+
value = (-field << 1) | 1
|
|
359
|
+
} else {
|
|
360
|
+
value = field << 1
|
|
361
|
+
}
|
|
362
|
+
for {
|
|
363
|
+
digit := value & 31
|
|
364
|
+
value >>= 5
|
|
365
|
+
if value > 0 {
|
|
366
|
+
digit |= 32
|
|
367
|
+
}
|
|
368
|
+
b.WriteByte(base64Chars[digit])
|
|
369
|
+
if value == 0 {
|
|
370
|
+
break
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
return b.String()
|
|
375
|
+
}
|
package/lib/TtscCompiler.js
CHANGED
|
@@ -314,17 +314,20 @@ function createProcessDiagnostic(result) {
|
|
|
314
314
|
};
|
|
315
315
|
}
|
|
316
316
|
function toCompilerTransformation(project) {
|
|
317
|
-
const { result, typescript } = project;
|
|
317
|
+
const { dependencies, result, typescript } = project;
|
|
318
|
+
const dependencyField = dependencies === undefined ? {} : { dependencies };
|
|
318
319
|
if (result.status === 0 && !hasErrorDiagnostics(result.diagnostics)) {
|
|
319
320
|
return {
|
|
320
321
|
...(result.diagnostics.length === 0
|
|
321
322
|
? {}
|
|
322
323
|
: { diagnostics: result.diagnostics }),
|
|
324
|
+
...dependencyField,
|
|
323
325
|
type: "success",
|
|
324
326
|
typescript,
|
|
325
327
|
};
|
|
326
328
|
}
|
|
327
329
|
return {
|
|
330
|
+
...dependencyField,
|
|
328
331
|
diagnostics: result.diagnostics.length === 0
|
|
329
332
|
? [createProcessDiagnostic(result)]
|
|
330
333
|
: result.diagnostics,
|
package/lib/TtscCompiler.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TtscCompiler.js","sourceRoot":"","sources":["../src/TtscCompiler.ts"],"names":[],"mappings":";;;;;;AAAA,sDAAyB;AACzB,0DAA6B;AAE7B,uFAAoF;AACpF,2FAAwF;AACxF,qEAAkE;AAClE,2FAAwF;AACxF,2EAAqF;AACrF,6EAA0E;AAO1E;;;;;;;;;;;;;;;;;;;GAmBG;AACH;IACmB,OAAO,CAAuB;IAE/C;;;;;;OAMG;IACH,YAAmB,OAAO,GAAyB,EAAE;QACnD,IAAI,CAAC,OAAO,GAAG;YACb,GAAG,OAAO;YACV,GAAG,EAAE,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,SAAS;YACjD,OAAO,EAAE,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC;gBACrC,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC;gBACtB,CAAC,CAAC,OAAO,CAAC,OAAO;SACpB,CAAC;IACJ,CAAC;IAED;;;;;;;;;;;;OAYG;IACI,OAAO;QACZ,MAAM,SAAS,GAAG,IAAI,CAAC,uBAAuB,EAAE,CAAC;QACjD,MAAM,MAAM,GAAG,IAAA,uCAAkB,EAAC;YAChC,MAAM,EAAE,IAAA,6BAAa,EAAC,IAAI,CAAC,eAAe,EAAE,CAAC,IAAI,EAAE;YACnD,QAAQ,EAAE,IAAI,CAAC,qBAAqB,EAAE;YACtC,GAAG,EAAE,SAAS,CAAC,GAAG;YAClB,OAAO,EAAE,IAAI,CAAC,OAAO,CAAC,OA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C,KAAc;IACpC,IAAI,CAAC,CAAC,KAAK,YAAY,KAAK,CAAC,EAAE,CAAC;QAC9B,OAAO,KAAK,CAAC;IACf,CAAC;IACD,OAAO;QACL,OAAO,EAAE,KAAK,CAAC,OAAO;QACtB,IAAI,EAAE,KAAK,CAAC,IAAI;QAChB,KAAK,EAAE,KAAK,CAAC,KAAK;KACnB,CAAC;AACJ,CAAC"}
|
|
@@ -242,7 +242,10 @@ function isRelativeSpecifier(specifier) {
|
|
|
242
242
|
* commas before handing off to `JSON.parse`.
|
|
243
243
|
*/
|
|
244
244
|
function parseJsonc(input) {
|
|
245
|
-
return JSON.parse(stripTrailingCommas(stripComments(input)));
|
|
245
|
+
return JSON.parse(stripTrailingCommas(stripComments(stripLeadingBom(input))));
|
|
246
|
+
}
|
|
247
|
+
function stripLeadingBom(input) {
|
|
248
|
+
return input.charCodeAt(0) === 0xfeff ? input.slice(1) : input;
|
|
246
249
|
}
|
|
247
250
|
/**
|
|
248
251
|
* Remove `//` line comments and `/* block comments *\/` from a JSONC string.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"readProjectConfig.js","sourceRoot":"","sources":["../../../../src/compiler/internal/project/readProjectConfig.ts"],"names":[],"mappings":";;;;;;AAAA,sDAAyB;AACzB,6CAA4C;AAC5C,0DAA6B;AAK7B,iEAA8D;AAE9D;;;GAGG;AACH,MAAM,YAAY,GAAG,IAAI,GAAG,CAAC,CAAC,SAAS,EAAE,gBAAgB,EAAE,SAAS,CAAC,CAAC,CAAC;AAiBvE;;;;;;;;GAQG;AACH,2BACE,IAAI,GAA+B,EAAE;IAErC,MAAM,QAAQ,GAAG,IAAA,2CAAoB,EAAC,IAAI,CAAC,CAAC;IAC5C,MAAM,IAAI,GAAG,IAAI,CAAC,WAAW;QAC3B,CAAC,CAAC,mBAAI,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,OAAO,CAAC,GAAG,EAAE,EAAE,IAAI,CAAC,WAAW,CAAC;QAC3D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AC;YAC7C,IAAI,IAAI,KAAK,GAAG,IAAI,IAAI,KAAK,GAAG,EAAE,CAAC;gBACjC,SAAS;YACX,CAAC;QACH,CAAC;QACD,MAAM,IAAI,OAAO,CAAC;IACpB,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AAED;;;;GAIG;AACH,SAAS,iBAAiB,CAAC,KAAa,EAAE,IAAY;IACpD,KAAK,IAAI,CAAC,GAAG,IAAI,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC;QAC5C,MAAM,OAAO,GAAG,KAAK,CAAC,CAAC,CAAE,CAAC;QAC1B,IAAI,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,KAAK,EAAE,CAAC;YACjC,OAAO,OAAO,CAAC;QACjB,CAAC;IACH,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC"}
|
|
@@ -16,6 +16,7 @@ import type { TtscBuildResult } from "../../structures/internal/TtscBuildResult"
|
|
|
16
16
|
* to their transformed TypeScript source text.
|
|
17
17
|
*/
|
|
18
18
|
export declare function transformProjectInMemory(options: ITtscCompilerContext): {
|
|
19
|
+
dependencies?: Record<string, string[]>;
|
|
19
20
|
result: TtscBuildResult;
|
|
20
21
|
typescript: Record<string, string>;
|
|
21
22
|
};
|
|
@@ -65,6 +65,9 @@ function transformProjectWithNativeHost(options, project) {
|
|
|
65
65
|
}
|
|
66
66
|
const output = parseNativeTransformOutput((0, spawnNative_1.outputText)(res.stdout), (0, spawnNative_1.outputText)(res.stderr));
|
|
67
67
|
return {
|
|
68
|
+
...(output.dependencies === undefined
|
|
69
|
+
? {}
|
|
70
|
+
: { dependencies: output.dependencies }),
|
|
68
71
|
result: {
|
|
69
72
|
diagnostics: output.diagnostics,
|
|
70
73
|
status: res.status ?? 1,
|
|
@@ -98,6 +101,9 @@ function transformProjectWithPlugins(options, cwd, project) {
|
|
|
98
101
|
if (transformers.length === 0) {
|
|
99
102
|
const transformed = transformProjectWithNativeHost(options, project);
|
|
100
103
|
return {
|
|
104
|
+
...(transformed.dependencies === undefined
|
|
105
|
+
? {}
|
|
106
|
+
: { dependencies: transformed.dependencies }),
|
|
101
107
|
result: (0, runBuild_1.appendBuildOutput)(checked, transformed.result),
|
|
102
108
|
typescript: transformed.typescript,
|
|
103
109
|
};
|
|
@@ -119,6 +125,9 @@ function transformProjectWithPlugins(options, cwd, project) {
|
|
|
119
125
|
stderr: (0, spawnNative_1.outputText)(res.stderr),
|
|
120
126
|
};
|
|
121
127
|
return {
|
|
128
|
+
...(output.dependencies === undefined
|
|
129
|
+
? {}
|
|
130
|
+
: { dependencies: output.dependencies }),
|
|
122
131
|
result: (0, runBuild_1.appendBuildOutput)(checked, result),
|
|
123
132
|
typescript: output.typescript,
|
|
124
133
|
};
|
|
@@ -211,6 +220,11 @@ function nativePluginEnv(options, tsgoBinary, nativePlugins, plugin) {
|
|
|
211
220
|
* The `typescript` field must be a `Record<string, string>`. Any other shape is
|
|
212
221
|
* treated as a protocol error and throws with the stderr/stdout context. JSON
|
|
213
222
|
* parse errors are also wrapped with the same context message.
|
|
223
|
+
*
|
|
224
|
+
* The optional `dependencies` field (per-file consulted-source lists, see
|
|
225
|
+
* `ITtscCompilerTransformation`) is forwarded when well-formed; entries that
|
|
226
|
+
* are not string arrays are dropped rather than failing the transform — the
|
|
227
|
+
* field is advisory watch metadata, not output.
|
|
214
228
|
*/
|
|
215
229
|
function parseNativeTransformOutput(stdout, stderr) {
|
|
216
230
|
try {
|
|
@@ -218,7 +232,9 @@ function parseNativeTransformOutput(stdout, stderr) {
|
|
|
218
232
|
if (!isTextRecord(parsed.typescript)) {
|
|
219
233
|
throw new Error("ttsc: native transform host did not return a TypeScript source map");
|
|
220
234
|
}
|
|
235
|
+
const dependencies = parseDependencyLists(parsed.dependencies);
|
|
221
236
|
return {
|
|
237
|
+
...(dependencies === undefined ? {} : { dependencies }),
|
|
222
238
|
diagnostics: Array.isArray(parsed.diagnostics) ? parsed.diagnostics : [],
|
|
223
239
|
typescript: parsed.typescript,
|
|
224
240
|
};
|
|
@@ -231,6 +247,26 @@ function parseNativeTransformOutput(stdout, stderr) {
|
|
|
231
247
|
"ttsc: native transform host returned no output");
|
|
232
248
|
}
|
|
233
249
|
}
|
|
250
|
+
/**
|
|
251
|
+
* Normalize the optional `dependencies` envelope field into a record of string
|
|
252
|
+
* arrays, or `undefined` when absent or carrying nothing usable.
|
|
253
|
+
*/
|
|
254
|
+
function parseDependencyLists(value) {
|
|
255
|
+
if (typeof value !== "object" || value === null || Array.isArray(value)) {
|
|
256
|
+
return undefined;
|
|
257
|
+
}
|
|
258
|
+
const output = {};
|
|
259
|
+
for (const [key, entries] of Object.entries(value)) {
|
|
260
|
+
if (!Array.isArray(entries)) {
|
|
261
|
+
continue;
|
|
262
|
+
}
|
|
263
|
+
const files = entries.filter((entry) => typeof entry === "string");
|
|
264
|
+
if (files.length !== 0) {
|
|
265
|
+
output[key] = files;
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
return Object.keys(output).length === 0 ? undefined : output;
|
|
269
|
+
}
|
|
234
270
|
/** Type guard: true when `value` is a non-null, non-array object of strings. */
|
|
235
271
|
function isTextRecord(value) {
|
|
236
272
|
return (typeof value === "object" &&
|