@ttsc/wasm 0.30.4 → 0.31.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.
- package/README.md +3 -3
- package/build/build-wasm.cjs +5 -4
- package/build/go-build-cache.cjs +347 -0
- package/build/pack-prepare.cjs +3 -2
- package/cmd/ttsc-wasm/main.go +22 -10
- package/cmd/ttsc-wasm/main_wasm.go +2 -2
- package/dist/.ttsc-wasm-build.json +138 -58
- package/dist/go.mod +7 -5
- package/dist/ttsc.wasm +2 -2
- package/go.mod +7 -5
- package/go.sum +10 -10
- package/host/api.go +34 -41
- package/host/doc.go +7 -6
- package/host/expose.go +42 -0
- package/host/fountain.go +192 -22
- package/host/host.go +10 -25
- package/host/host_native.go +3 -5
- package/host/invoke.go +133 -0
- package/host/plugin.go +37 -72
- package/host/result.go +108 -0
- package/lib/src/BootTtscWorkerTerminationError.d.ts +20 -0
- package/lib/src/BootTtscWorkerTerminationError.js +20 -0
- package/lib/src/BootTtscWorkerTerminationError.js.map +1 -1
- package/lib/src/MemFSError.d.ts +21 -2
- package/lib/src/MemFSError.js +25 -2
- package/lib/src/MemFSError.js.map +1 -1
- package/lib/src/bootTtsc.d.ts +49 -2
- package/lib/src/bootTtsc.js +89 -23
- package/lib/src/bootTtsc.js.map +1 -1
- package/lib/src/createMemFS.d.ts +45 -0
- package/lib/src/createMemFS.js +269 -66
- package/lib/src/createMemFS.js.map +1 -1
- package/lib/src/parseResult.d.ts +19 -0
- package/lib/src/parseResult.js +19 -0
- package/lib/src/parseResult.js.map +1 -1
- package/lib/src/structures/IBootResult.d.ts +20 -2
- package/lib/src/structures/IBootTtscOptions.d.ts +28 -6
- package/lib/src/structures/IFileStats.d.ts +51 -0
- package/lib/src/structures/IMemFSHost.d.ts +89 -0
- package/lib/src/structures/ITtscApi.d.ts +154 -9
- package/lib/src/structures/ITtscBuildOpts.d.ts +18 -1
- package/lib/src/structures/ITtscCompileResult.d.ts +20 -2
- package/lib/src/structures/ITtscDiagnostic.d.ts +25 -1
- package/lib/src/structures/ITtscFileQuery.d.ts +19 -1
- package/lib/src/structures/ITtscFountainDiagnosticsResult.d.ts +20 -1
- package/lib/src/structures/ITtscNodeAtPositionResult.d.ts +18 -1
- package/lib/src/structures/ITtscNodeInfo.d.ts +23 -2
- package/lib/src/structures/ITtscPluginOpts.d.ts +24 -3
- package/lib/src/structures/ITtscPositionQuery.d.ts +21 -4
- package/lib/src/structures/ITtscReleaseSnapshotResult.d.ts +22 -2
- package/lib/src/structures/ITtscResult.d.ts +31 -5
- package/lib/src/structures/ITtscSnapshotHandle.d.ts +19 -1
- package/lib/src/structures/ITtscSnapshotResult.d.ts +22 -1
- package/lib/src/structures/ITtscSnapshotsResult.d.ts +19 -1
- package/lib/src/structures/ITtscSourceFileTextResult.d.ts +19 -1
- package/lib/src/structures/ITtscSourceFilesResult.d.ts +23 -2
- package/lib/src/structures/ITtscSymbolAtPositionResult.d.ts +18 -1
- package/lib/src/structures/ITtscSymbolDeclaration.d.ts +25 -2
- package/lib/src/structures/ITtscSymbolInfo.d.ts +19 -1
- package/lib/src/structures/ITtscTransformResult.d.ts +21 -3
- package/lib/src/structures/ITtscTypeAtPositionResult.d.ts +18 -1
- package/lib/src/structures/ITtscTypeInfo.d.ts +19 -1
- package/lib/src/structures/ITtscVersion.d.ts +28 -1
- package/lib/src/structures/IWasmExecFS.d.ts +310 -0
- package/package.json +4 -2
- package/shim-vendor/shim/ast/enums_gen.go +4 -2
- package/shim-vendor/shim/ast/go.mod +5 -5
- package/shim-vendor/shim/ast/go.sum +10 -10
- package/shim-vendor/shim/ast/lint.go +1088 -20
- package/shim-vendor/shim/ast/parent.go +38 -22
- package/shim-vendor/shim/ast/safe_text.go +48 -26
- package/shim-vendor/shim/ast/shim.go +1307 -20
- package/shim-vendor/shim/ast/test/next_jsdoc_comment_location_reaches_variable_statement_test.go +51 -0
- package/shim-vendor/shim/ast/test/node_text_joins_multi_hop_qualified_name_test.go +24 -9
- package/shim-vendor/shim/ast/test/node_text_joins_one_hop_qualified_name_test.go +9 -5
- package/shim-vendor/shim/ast/test/node_text_returns_empty_for_nil_test.go +13 -5
- package/shim-vendor/shim/ast/test/node_text_returns_identifier_text_test.go +12 -5
- package/shim-vendor/shim/ast/test/node_text_skips_empty_qualified_left_test.go +35 -5
- package/shim-vendor/shim/astnav/go.mod +5 -5
- package/shim-vendor/shim/astnav/go.sum +12 -10
- package/shim-vendor/shim/astnav/shim.go +9 -0
- package/shim-vendor/shim/bundled/go.mod +7 -1
- package/shim-vendor/shim/bundled/go.sum +12 -0
- package/shim-vendor/shim/checker/enums_gen.go +4 -2
- package/shim-vendor/shim/checker/extra-shim.json +6 -0
- package/shim-vendor/shim/checker/go.mod +5 -5
- package/shim-vendor/shim/checker/go.sum +10 -10
- package/shim-vendor/shim/checker/node_builder_fields_gen.go +19 -0
- package/shim-vendor/shim/checker/shim.go +827 -114
- package/shim-vendor/shim/compiler/emit_sourcemap.go +68 -29
- package/shim-vendor/shim/compiler/emitassemble.go +36 -2
- package/shim-vendor/shim/compiler/emithook.go +13 -3
- package/shim-vendor/shim/compiler/go.mod +5 -5
- package/shim-vendor/shim/compiler/go.sum +10 -10
- package/shim-vendor/shim/compiler/incremental.go +56 -20
- package/shim-vendor/shim/compiler/resolution.go +92 -9
- package/shim-vendor/shim/core/enums_gen.go +2 -2
- package/shim-vendor/shim/core/go.mod +6 -1
- package/shim-vendor/shim/core/go.sum +10 -0
- package/shim-vendor/shim/core/modulekind.go +9 -0
- package/shim-vendor/shim/core/shim.go +157 -6
- package/shim-vendor/shim/diagnosticwriter/go.mod +10 -1
- package/shim-vendor/shim/diagnosticwriter/go.sum +20 -0
- package/shim-vendor/shim/diagnosticwriter/lint.go +188 -10
- package/shim-vendor/shim/diagnosticwriter/shim.go +14 -0
- package/shim-vendor/shim/lsp/go.mod +5 -5
- package/shim-vendor/shim/lsp/go.sum +10 -10
- package/shim-vendor/shim/lsp/shim.go +78 -2
- package/shim-vendor/shim/parser/go.mod +10 -1
- package/shim-vendor/shim/parser/go.sum +22 -0
- package/shim-vendor/shim/printer/emithost.go +46 -1
- package/shim-vendor/shim/printer/go.mod +5 -5
- package/shim-vendor/shim/printer/go.sum +10 -10
- package/shim-vendor/shim/printer/shim.go +114 -7
- package/shim-vendor/shim/printer/sourcemap.go +55 -0
- package/shim-vendor/shim/scanner/go.mod +10 -1
- package/shim-vendor/shim/scanner/go.sum +20 -0
- package/shim-vendor/shim/scanner/regexp.go +19 -4
- package/shim-vendor/shim/scanner/shim.go +3 -0
- package/shim-vendor/shim/stringutil/extra-shim.json +1 -0
- package/shim-vendor/shim/stringutil/go.mod +5 -0
- package/shim-vendor/shim/stringutil/go.sum +2 -0
- package/shim-vendor/shim/stringutil/shim.go +119 -0
- package/shim-vendor/shim/transformers/go.mod +5 -5
- package/shim-vendor/shim/transformers/go.sum +12 -10
- package/shim-vendor/shim/transformers/shim.go +12 -3
- package/shim-vendor/shim/tsoptions/command_line_raw.go +44 -0
- package/shim-vendor/shim/tsoptions/go.mod +10 -1
- package/shim-vendor/shim/tsoptions/go.sum +22 -0
- package/shim-vendor/shim/tsoptions/shim.go +1 -1
- package/shim-vendor/shim/tspath/go.mod +1 -1
- package/shim-vendor/shim/tspath/go.sum +6 -0
- package/shim-vendor/shim/vfs/cachedvfs/go.mod +3 -1
- package/shim-vendor/shim/vfs/cachedvfs/go.sum +12 -0
- package/shim-vendor/shim/vfs/decode.go +26 -0
- package/shim-vendor/shim/vfs/decode_test.go +42 -0
- package/shim-vendor/shim/vfs/go.mod +7 -1
- package/shim-vendor/shim/vfs/go.sum +12 -0
- package/shim-vendor/shim/vfs/osvfs/go.mod +7 -1
- package/shim-vendor/shim/vfs/osvfs/go.sum +12 -0
- package/src/BootTtscWorkerTerminationError.ts +22 -0
- package/src/MemFSError.ts +29 -2
- package/src/bootTtsc.ts +104 -28
- package/src/createMemFS.ts +291 -64
- package/src/parseResult.ts +19 -0
- package/src/structures/IBootResult.ts +21 -2
- package/src/structures/IBootTtscOptions.ts +32 -6
- package/src/structures/IFileStats.ts +65 -0
- package/src/structures/IMemFSHost.ts +97 -0
- package/src/structures/ITtscApi.ts +154 -9
- package/src/structures/ITtscBuildOpts.ts +19 -1
- package/src/structures/ITtscCompileResult.ts +21 -2
- package/src/structures/ITtscDiagnostic.ts +32 -1
- package/src/structures/ITtscFileQuery.ts +19 -1
- package/src/structures/ITtscFountainDiagnosticsResult.ts +20 -1
- package/src/structures/ITtscNodeAtPositionResult.ts +18 -1
- package/src/structures/ITtscNodeInfo.ts +27 -2
- package/src/structures/ITtscPluginOpts.ts +28 -3
- package/src/structures/ITtscPositionQuery.ts +21 -4
- package/src/structures/ITtscReleaseSnapshotResult.ts +22 -2
- package/src/structures/ITtscResult.ts +34 -5
- package/src/structures/ITtscSnapshotHandle.ts +19 -1
- package/src/structures/ITtscSnapshotResult.ts +22 -1
- package/src/structures/ITtscSnapshotsResult.ts +19 -1
- package/src/structures/ITtscSourceFileTextResult.ts +19 -1
- package/src/structures/ITtscSourceFilesResult.ts +23 -2
- package/src/structures/ITtscSymbolAtPositionResult.ts +18 -1
- package/src/structures/ITtscSymbolDeclaration.ts +27 -2
- package/src/structures/ITtscSymbolInfo.ts +23 -1
- package/src/structures/ITtscTransformResult.ts +22 -3
- package/src/structures/ITtscTypeAtPositionResult.ts +18 -1
- package/src/structures/ITtscTypeInfo.ts +20 -1
- package/src/structures/ITtscVersion.ts +33 -1
- package/src/structures/IWasmExecFS.ts +336 -0
|
@@ -2,4 +2,13 @@ module github.com/microsoft/typescript-go/shim/scanner
|
|
|
2
2
|
|
|
3
3
|
go 1.26
|
|
4
4
|
|
|
5
|
-
require github.com/microsoft/typescript-go v0.0.0-
|
|
5
|
+
require github.com/microsoft/typescript-go v0.0.0-20260610182825-7fc57c005063
|
|
6
|
+
|
|
7
|
+
require (
|
|
8
|
+
github.com/go-json-experiment/json v0.0.0-20260601182631-00ed12fed2a6 // 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.21.0 // indirect
|
|
12
|
+
golang.org/x/sys v0.46.0 // indirect
|
|
13
|
+
golang.org/x/text v0.38.0 // indirect
|
|
14
|
+
)
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
github.com/go-json-experiment/json v0.0.0-20260601182631-00ed12fed2a6 h1:nxP4pPoyqOAgX8lYDFCfl3DyKeXErCvSvhcyzwGV9CE=
|
|
2
|
+
github.com/go-json-experiment/json v0.0.0-20260601182631-00ed12fed2a6/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-20260610182825-7fc57c005063 h1:UUVrjTrD+7nkVvkJTjxwA5+SaZ5n1uyAffm2zX2gn+o=
|
|
8
|
+
github.com/microsoft/typescript-go v0.0.0-20260610182825-7fc57c005063/go.mod h1:s3yhRRZ7nzSZaiKicku520Tj9Mvewr9y2UtrvpwOmDE=
|
|
9
|
+
github.com/zeebo/assert v1.3.0 h1:g7C04CbJuIDKNPFHmsk4hwZDO5O+kntRxzaUoNXj+IQ=
|
|
10
|
+
github.com/zeebo/assert v1.3.0/go.mod h1:Pq9JiuJQpG8JLJdtkwrJESF0Foym2/D9XMU5ciN/wJ0=
|
|
11
|
+
github.com/zeebo/xxh3 v1.1.0 h1:s7DLGDK45Dyfg7++yxI0khrfwq9661w9EN78eP/UZVs=
|
|
12
|
+
github.com/zeebo/xxh3 v1.1.0/go.mod h1:IisAie1LELR4xhVinxWS5+zf1lA4p0MW4T+w+W07F5s=
|
|
13
|
+
golang.org/x/sync v0.21.0 h1:HLII4xRRTtCRkxYp4HNFF0Js/Og6q2i++KXbg0gHCwM=
|
|
14
|
+
golang.org/x/sync v0.21.0/go.mod h1:9xrNwdLfx4jkKbNva9FpL6vEN7evnE43NNNJQ2LF3+0=
|
|
15
|
+
golang.org/x/sys v0.46.0 h1:noSf2Fq6F8DBgS+LysIkx7rIExoNHJsxOAtPp4rthXw=
|
|
16
|
+
golang.org/x/sys v0.46.0/go.mod h1:4GL1E5IUh+htKOUEOaiffhrAeqysfVGipDYzABqnCmw=
|
|
17
|
+
golang.org/x/text v0.38.0 h1:sXmwo9DwP3OK9EZ7PqAdaooSGozfl/3a6/xJcbzPRhE=
|
|
18
|
+
golang.org/x/text v0.38.0/go.mod h1:YXZt3QhHUKYT53r2lLKFIVi6Ao1jdzrTR/KQ09qyxF4=
|
|
19
|
+
gotest.tools/v3 v3.5.2 h1:7koQfIKdy+I8UTetycgUqXWSDwpgv193Ka+qRsmBY8Q=
|
|
20
|
+
gotest.tools/v3 v3.5.2/go.mod h1:LtdLGcnqToBH83WByAAi/wiwSFCArdFIUV/xxN4pcjA=
|
|
@@ -5,10 +5,25 @@ import (
|
|
|
5
5
|
"github.com/microsoft/typescript-go/internal/diagnostics"
|
|
6
6
|
)
|
|
7
7
|
|
|
8
|
-
// IsValidRegularExpressionLiteral reports whether text
|
|
9
|
-
//
|
|
10
|
-
//
|
|
11
|
-
//
|
|
8
|
+
// IsValidRegularExpressionLiteral reports whether text contains one regexp
|
|
9
|
+
// literal accepted without diagnostics by the pinned compiler's scanner and
|
|
10
|
+
// regexp parser, after optional leading scanner trivia. It uses the scanner's
|
|
11
|
+
// default latest target and the compiler's escape, flag, Unicode and Unicode
|
|
12
|
+
// Sets policies. This is not a runtime regexp-execution check or a complete
|
|
13
|
+
// certificate of ECMAScript grammar validity: the compiler can diagnose
|
|
14
|
+
// otherwise Annex-B-compatible backreferences as likely mistakes.
|
|
15
|
+
//
|
|
16
|
+
// Trailing text is rejected, including whitespace after the literal. Scanner
|
|
17
|
+
// diagnostics cause a false result rather than escaping.
|
|
18
|
+
//
|
|
19
|
+
// @evidence contracts/common.md#principled-implementation The initial slash token enters upstream's regexp rescan mode; success requires a regexp token, no scanner diagnostic, and a token end equal to the input byte length, establishing one literal after the scanner's permitted leading trivia.
|
|
20
|
+
// @evidence contracts/common.md#clear-and-simple-design A fresh local scanner and diagnostic flag handle one input without shared parser state or an independent regexp grammar.
|
|
21
|
+
// @evidence contracts/common.md#prohibited-implementation-shortcuts Slash and slash-equals are the scanner's documented regexp-entry tokens; the diagnostic callback uses supported injection rather than replacing scanner internals.
|
|
22
|
+
// @evidence contracts/common.md#meaningful-documentation Native prose states compiler grammar ownership, leading-trivia acceptance, trailing-text rejection and diagnostic-to-false behavior, with a separate acknowledgment section.
|
|
23
|
+
// @evidence contracts/performance.md#bound-retention-and-release-resources One local scanner retains the input during the call, and regexp parsing can allocate capture/name/reference maps and lists plus recursive group state. Only a boolean escapes; scanner, callback and parser storage become unreachable after completion. There is no historical cache, handle, input-size cap or adapter-enforced nesting limit.
|
|
24
|
+
// @evidence contracts/performance.md#efficient-algorithms One scanner performs leading-trivia admission, delimiter and flag scanning and compiler regexp parsing, then checks token-end equality without an independent grammar implementation. Work grows with text bytes, nested groups, captures and references; invalid named references can also trigger upstream spelling suggestions across capture names even though diagnostics only set a flag here. The adapter does not claim fixed work or an early parser stop after the first diagnostic.
|
|
25
|
+
// @evidenceExclude contracts/performance.md#reuse-equivalent-work This predicate owns no cross-request producer or validity coordinator; a fresh scanner keeps token state and diagnostic observation local to the supplied text, with no shared mutable parse state.
|
|
26
|
+
// @evidenceExclude contracts/portability.md#os-neutral-implementation IsValidRegularExpressionLiteral computes from its arguments only; it opens no file, builds no path and calls no platform or process API.
|
|
12
27
|
func IsValidRegularExpressionLiteral(text string) bool {
|
|
13
28
|
scanner := NewScanner()
|
|
14
29
|
valid := true
|
|
@@ -74,6 +74,9 @@ func GetShebang(text string) string
|
|
|
74
74
|
//go:linkname GetSourceTextOfNodeFromSourceFile github.com/microsoft/typescript-go/internal/scanner.GetSourceTextOfNodeFromSourceFile
|
|
75
75
|
func GetSourceTextOfNodeFromSourceFile(sourceFile *ast.SourceFile, node *ast.Node, includeTrivia bool) string
|
|
76
76
|
|
|
77
|
+
//go:linkname GetTextOfJSDocComment github.com/microsoft/typescript-go/internal/scanner.GetTextOfJSDocComment
|
|
78
|
+
func GetTextOfJSDocComment(comment *ast.NodeList) string
|
|
79
|
+
|
|
77
80
|
//go:linkname GetTextOfNode github.com/microsoft/typescript-go/internal/scanner.GetTextOfNode
|
|
78
81
|
func GetTextOfNode(node *ast.Node) string
|
|
79
82
|
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
// Code generated by packages/ttsc/tools/gen_shims. DO NOT EDIT.
|
|
2
|
+
|
|
3
|
+
package stringutil
|
|
4
|
+
|
|
5
|
+
import "github.com/microsoft/typescript-go/internal/stringutil"
|
|
6
|
+
import _ "unsafe"
|
|
7
|
+
|
|
8
|
+
//go:linkname AddUTF8ByteOrderMark github.com/microsoft/typescript-go/internal/stringutil.AddUTF8ByteOrderMark
|
|
9
|
+
func AddUTF8ByteOrderMark(text string) string
|
|
10
|
+
|
|
11
|
+
//go:linkname CodePointToSurrogatePair github.com/microsoft/typescript-go/internal/stringutil.CodePointToSurrogatePair
|
|
12
|
+
func CodePointToSurrogatePair(ch rune) (high rune, low rune)
|
|
13
|
+
|
|
14
|
+
//go:linkname CombineSurrogatePairs github.com/microsoft/typescript-go/internal/stringutil.CombineSurrogatePairs
|
|
15
|
+
func CombineSurrogatePairs(s string) string
|
|
16
|
+
|
|
17
|
+
//go:linkname CompareStringsCaseInsensitive github.com/microsoft/typescript-go/internal/stringutil.CompareStringsCaseInsensitive
|
|
18
|
+
func CompareStringsCaseInsensitive(a string, b string) stringutil.Comparison
|
|
19
|
+
|
|
20
|
+
//go:linkname CompareStringsCaseInsensitiveEslintCompatible github.com/microsoft/typescript-go/internal/stringutil.CompareStringsCaseInsensitiveEslintCompatible
|
|
21
|
+
func CompareStringsCaseInsensitiveEslintCompatible(a string, b string) stringutil.Comparison
|
|
22
|
+
|
|
23
|
+
//go:linkname CompareStringsCaseInsensitiveThenSensitive github.com/microsoft/typescript-go/internal/stringutil.CompareStringsCaseInsensitiveThenSensitive
|
|
24
|
+
func CompareStringsCaseInsensitiveThenSensitive(a string, b string) stringutil.Comparison
|
|
25
|
+
|
|
26
|
+
//go:linkname CompareStringsCaseSensitive github.com/microsoft/typescript-go/internal/stringutil.CompareStringsCaseSensitive
|
|
27
|
+
func CompareStringsCaseSensitive(a string, b string) stringutil.Comparison
|
|
28
|
+
|
|
29
|
+
type Comparison = stringutil.Comparison
|
|
30
|
+
|
|
31
|
+
const ComparisonEqual = stringutil.ComparisonEqual
|
|
32
|
+
const ComparisonGreaterThan = stringutil.ComparisonGreaterThan
|
|
33
|
+
const ComparisonLessThan = stringutil.ComparisonLessThan
|
|
34
|
+
|
|
35
|
+
//go:linkname DecodeJSStringRune github.com/microsoft/typescript-go/internal/stringutil.DecodeJSStringRune
|
|
36
|
+
func DecodeJSStringRune(s string) (rune, int)
|
|
37
|
+
|
|
38
|
+
//go:linkname EncodeJSStringRune github.com/microsoft/typescript-go/internal/stringutil.EncodeJSStringRune
|
|
39
|
+
func EncodeJSStringRune(ch rune) string
|
|
40
|
+
|
|
41
|
+
//go:linkname EncodeURI github.com/microsoft/typescript-go/internal/stringutil.EncodeURI
|
|
42
|
+
func EncodeURI(s string) string
|
|
43
|
+
|
|
44
|
+
//go:linkname EquateStringCaseInsensitive github.com/microsoft/typescript-go/internal/stringutil.EquateStringCaseInsensitive
|
|
45
|
+
func EquateStringCaseInsensitive(a string, b string) bool
|
|
46
|
+
|
|
47
|
+
//go:linkname EquateStringCaseSensitive github.com/microsoft/typescript-go/internal/stringutil.EquateStringCaseSensitive
|
|
48
|
+
func EquateStringCaseSensitive(a string, b string) bool
|
|
49
|
+
|
|
50
|
+
//go:linkname GetStringComparer github.com/microsoft/typescript-go/internal/stringutil.GetStringComparer
|
|
51
|
+
func GetStringComparer(ignoreCase bool) func(a string, b string) stringutil.Comparison
|
|
52
|
+
|
|
53
|
+
//go:linkname GetStringEqualityComparer github.com/microsoft/typescript-go/internal/stringutil.GetStringEqualityComparer
|
|
54
|
+
func GetStringEqualityComparer(ignoreCase bool) func(a string, b string) bool
|
|
55
|
+
|
|
56
|
+
//go:linkname GuessIndentation github.com/microsoft/typescript-go/internal/stringutil.GuessIndentation
|
|
57
|
+
func GuessIndentation(lines []string) int
|
|
58
|
+
|
|
59
|
+
//go:linkname HasPrefix github.com/microsoft/typescript-go/internal/stringutil.HasPrefix
|
|
60
|
+
func HasPrefix(s string, prefix string, caseSensitive bool) bool
|
|
61
|
+
|
|
62
|
+
//go:linkname HasPrefixAndSuffixWithoutOverlap github.com/microsoft/typescript-go/internal/stringutil.HasPrefixAndSuffixWithoutOverlap
|
|
63
|
+
func HasPrefixAndSuffixWithoutOverlap(s string, prefix string, suffix string, caseSensitive bool) bool
|
|
64
|
+
|
|
65
|
+
//go:linkname HasSuffix github.com/microsoft/typescript-go/internal/stringutil.HasSuffix
|
|
66
|
+
func HasSuffix(s string, suffix string, caseSensitive bool) bool
|
|
67
|
+
|
|
68
|
+
//go:linkname IsASCIILetter github.com/microsoft/typescript-go/internal/stringutil.IsASCIILetter
|
|
69
|
+
func IsASCIILetter(ch rune) bool
|
|
70
|
+
|
|
71
|
+
//go:linkname IsDigit github.com/microsoft/typescript-go/internal/stringutil.IsDigit
|
|
72
|
+
func IsDigit(ch rune) bool
|
|
73
|
+
|
|
74
|
+
//go:linkname IsHexDigit github.com/microsoft/typescript-go/internal/stringutil.IsHexDigit
|
|
75
|
+
func IsHexDigit(ch rune) bool
|
|
76
|
+
|
|
77
|
+
//go:linkname IsHighSurrogate github.com/microsoft/typescript-go/internal/stringutil.IsHighSurrogate
|
|
78
|
+
func IsHighSurrogate(ch rune) bool
|
|
79
|
+
|
|
80
|
+
//go:linkname IsLineBreak github.com/microsoft/typescript-go/internal/stringutil.IsLineBreak
|
|
81
|
+
func IsLineBreak(ch rune) bool
|
|
82
|
+
|
|
83
|
+
//go:linkname IsLowSurrogate github.com/microsoft/typescript-go/internal/stringutil.IsLowSurrogate
|
|
84
|
+
func IsLowSurrogate(ch rune) bool
|
|
85
|
+
|
|
86
|
+
//go:linkname IsOctalDigit github.com/microsoft/typescript-go/internal/stringutil.IsOctalDigit
|
|
87
|
+
func IsOctalDigit(ch rune) bool
|
|
88
|
+
|
|
89
|
+
//go:linkname IsSurrogate github.com/microsoft/typescript-go/internal/stringutil.IsSurrogate
|
|
90
|
+
func IsSurrogate(ch rune) bool
|
|
91
|
+
|
|
92
|
+
//go:linkname IsWhiteSpaceLike github.com/microsoft/typescript-go/internal/stringutil.IsWhiteSpaceLike
|
|
93
|
+
func IsWhiteSpaceLike(ch rune) bool
|
|
94
|
+
|
|
95
|
+
//go:linkname IsWhiteSpaceSingleLine github.com/microsoft/typescript-go/internal/stringutil.IsWhiteSpaceSingleLine
|
|
96
|
+
func IsWhiteSpaceSingleLine(ch rune) bool
|
|
97
|
+
|
|
98
|
+
//go:linkname LowerFirstChar github.com/microsoft/typescript-go/internal/stringutil.LowerFirstChar
|
|
99
|
+
func LowerFirstChar(str string) string
|
|
100
|
+
|
|
101
|
+
//go:linkname RemoveByteOrderMark github.com/microsoft/typescript-go/internal/stringutil.RemoveByteOrderMark
|
|
102
|
+
func RemoveByteOrderMark(text string) string
|
|
103
|
+
|
|
104
|
+
//go:linkname SplitLines github.com/microsoft/typescript-go/internal/stringutil.SplitLines
|
|
105
|
+
func SplitLines(text string) []string
|
|
106
|
+
|
|
107
|
+
//go:linkname StripQuotes github.com/microsoft/typescript-go/internal/stringutil.StripQuotes
|
|
108
|
+
func StripQuotes(name string) string
|
|
109
|
+
|
|
110
|
+
const SurrogateLowStart = stringutil.SurrogateLowStart
|
|
111
|
+
|
|
112
|
+
//go:linkname SurrogatePairToCodePoint github.com/microsoft/typescript-go/internal/stringutil.SurrogatePairToCodePoint
|
|
113
|
+
func SurrogatePairToCodePoint(high rune, low rune) rune
|
|
114
|
+
|
|
115
|
+
//go:linkname TruncateByRunes github.com/microsoft/typescript-go/internal/stringutil.TruncateByRunes
|
|
116
|
+
func TruncateByRunes(str string, maxLength int) string
|
|
117
|
+
|
|
118
|
+
//go:linkname UnquoteString github.com/microsoft/typescript-go/internal/stringutil.UnquoteString
|
|
119
|
+
func UnquoteString(str string) string
|
|
@@ -2,13 +2,13 @@ module github.com/microsoft/typescript-go/shim/transformers
|
|
|
2
2
|
|
|
3
3
|
go 1.26
|
|
4
4
|
|
|
5
|
-
require github.com/microsoft/typescript-go v0.0.0-
|
|
5
|
+
require github.com/microsoft/typescript-go v0.0.0-20260610182825-7fc57c005063
|
|
6
6
|
|
|
7
7
|
require (
|
|
8
|
-
github.com/go-json-experiment/json v0.0.0-
|
|
8
|
+
github.com/go-json-experiment/json v0.0.0-20260601182631-00ed12fed2a6 // indirect
|
|
9
9
|
github.com/klauspost/cpuid/v2 v2.2.10 // indirect
|
|
10
10
|
github.com/zeebo/xxh3 v1.1.0 // indirect
|
|
11
|
-
golang.org/x/sync v0.
|
|
12
|
-
golang.org/x/sys v0.
|
|
13
|
-
golang.org/x/text v0.
|
|
11
|
+
golang.org/x/sync v0.21.0 // indirect
|
|
12
|
+
golang.org/x/sys v0.46.0 // indirect
|
|
13
|
+
golang.org/x/text v0.38.0 // indirect
|
|
14
14
|
)
|
|
@@ -1,20 +1,22 @@
|
|
|
1
|
-
github.com/go-json-experiment/json v0.0.0-
|
|
2
|
-
github.com/go-json-experiment/json v0.0.0-
|
|
1
|
+
github.com/go-json-experiment/json v0.0.0-20260601182631-00ed12fed2a6 h1:nxP4pPoyqOAgX8lYDFCfl3DyKeXErCvSvhcyzwGV9CE=
|
|
2
|
+
github.com/go-json-experiment/json v0.0.0-20260601182631-00ed12fed2a6/go.mod h1:tphK2c80bpPhMOI4v6bIc2xWywPfbqi1Z06+RcrMkDg=
|
|
3
3
|
github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
|
|
4
4
|
github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU=
|
|
5
5
|
github.com/klauspost/cpuid/v2 v2.2.10 h1:tBs3QSyvjDyFTq3uoc/9xFpCuOsJQFNPiAhYdw2skhE=
|
|
6
6
|
github.com/klauspost/cpuid/v2 v2.2.10/go.mod h1:hqwkgyIinND0mEev00jJYCxPNVRVXFQeu1XKlok6oO0=
|
|
7
|
-
github.com/microsoft/typescript-go v0.0.0-
|
|
8
|
-
github.com/microsoft/typescript-go v0.0.0-
|
|
7
|
+
github.com/microsoft/typescript-go v0.0.0-20260610182825-7fc57c005063 h1:UUVrjTrD+7nkVvkJTjxwA5+SaZ5n1uyAffm2zX2gn+o=
|
|
8
|
+
github.com/microsoft/typescript-go v0.0.0-20260610182825-7fc57c005063/go.mod h1:s3yhRRZ7nzSZaiKicku520Tj9Mvewr9y2UtrvpwOmDE=
|
|
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=
|
|
9
11
|
github.com/zeebo/assert v1.3.0 h1:g7C04CbJuIDKNPFHmsk4hwZDO5O+kntRxzaUoNXj+IQ=
|
|
10
12
|
github.com/zeebo/assert v1.3.0/go.mod h1:Pq9JiuJQpG8JLJdtkwrJESF0Foym2/D9XMU5ciN/wJ0=
|
|
11
13
|
github.com/zeebo/xxh3 v1.1.0 h1:s7DLGDK45Dyfg7++yxI0khrfwq9661w9EN78eP/UZVs=
|
|
12
14
|
github.com/zeebo/xxh3 v1.1.0/go.mod h1:IisAie1LELR4xhVinxWS5+zf1lA4p0MW4T+w+W07F5s=
|
|
13
|
-
golang.org/x/sync v0.
|
|
14
|
-
golang.org/x/sync v0.
|
|
15
|
-
golang.org/x/sys v0.
|
|
16
|
-
golang.org/x/sys v0.
|
|
17
|
-
golang.org/x/text v0.
|
|
18
|
-
golang.org/x/text v0.
|
|
15
|
+
golang.org/x/sync v0.21.0 h1:HLII4xRRTtCRkxYp4HNFF0Js/Og6q2i++KXbg0gHCwM=
|
|
16
|
+
golang.org/x/sync v0.21.0/go.mod h1:9xrNwdLfx4jkKbNva9FpL6vEN7evnE43NNNJQ2LF3+0=
|
|
17
|
+
golang.org/x/sys v0.46.0 h1:noSf2Fq6F8DBgS+LysIkx7rIExoNHJsxOAtPp4rthXw=
|
|
18
|
+
golang.org/x/sys v0.46.0/go.mod h1:4GL1E5IUh+htKOUEOaiffhrAeqysfVGipDYzABqnCmw=
|
|
19
|
+
golang.org/x/text v0.38.0 h1:sXmwo9DwP3OK9EZ7PqAdaooSGozfl/3a6/xJcbzPRhE=
|
|
20
|
+
golang.org/x/text v0.38.0/go.mod h1:YXZt3QhHUKYT53r2lLKFIVi6Ao1jdzrTR/KQ09qyxF4=
|
|
19
21
|
gotest.tools/v3 v3.5.2 h1:7koQfIKdy+I8UTetycgUqXWSDwpgv193Ka+qRsmBY8Q=
|
|
20
22
|
gotest.tools/v3 v3.5.2/go.mod h1:LtdLGcnqToBH83WByAAi/wiwSFCArdFIUV/xxN4pcjA=
|
|
@@ -9,7 +9,16 @@ package transformers
|
|
|
9
9
|
|
|
10
10
|
import innertransformers "github.com/microsoft/typescript-go/internal/transformers"
|
|
11
11
|
|
|
12
|
-
// Transformer is one stage of tsgo's emit transformer chain
|
|
13
|
-
//
|
|
14
|
-
// EmitContext
|
|
12
|
+
// Transformer is one stage of tsgo's emit transformer chain.
|
|
13
|
+
// TransformSourceFile returns the visited source file, which may replace the
|
|
14
|
+
// input; its visitor and factory share the stage's EmitContext.
|
|
15
|
+
//
|
|
16
|
+
// @evidence contracts/common.md#principled-implementation Go alias identity preserves the upstream visitor, factory and context relationship; callers receive the transformed SourceFile returned by the visitor rather than assuming in-place mutation.
|
|
17
|
+
// @evidence contracts/common.md#clear-and-simple-design One native transformer stage participates in the existing chain without an additional transform protocol or duplicated visitor state.
|
|
18
|
+
// @evidence contracts/common.md#prohibited-implementation-shortcuts Plugins return compiler AST nodes through the supported stage, without text-splice substitutes or monkey-patched builtin passes.
|
|
19
|
+
// @evidence contracts/common.md#meaningful-documentation Native prose identifies the possible replacement result and shared context rather than promising preservation of the input node's identity.
|
|
20
|
+
// @evidenceExclude contracts/performance.md#bound-retention-and-release-resources A type declaration acquires and holds no runtime resource.
|
|
21
|
+
// @evidenceExclude contracts/performance.md#efficient-algorithms A type declaration chooses no processing strategy.
|
|
22
|
+
// @evidenceExclude contracts/performance.md#reuse-equivalent-work A type declaration computes nothing, so there is no work to share.
|
|
23
|
+
// @evidenceExclude contracts/portability.md#os-neutral-implementation This type declaration describes a data shape only; it opens no file, builds no path and branches on no platform.
|
|
15
24
|
type Transformer = innertransformers.Transformer
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
// gen_shims:hand-maintained
|
|
2
|
+
|
|
3
|
+
package tsoptions
|
|
4
|
+
|
|
5
|
+
import (
|
|
6
|
+
"github.com/microsoft/typescript-go/internal/collections"
|
|
7
|
+
"github.com/microsoft/typescript-go/internal/tsoptions"
|
|
8
|
+
)
|
|
9
|
+
|
|
10
|
+
// CommandLineRawOptions returns the options a parsed command line spelled out,
|
|
11
|
+
// wrapped in a "compilerOptions" key: the `optionsRaw` shape
|
|
12
|
+
// GetParsedCommandLineOfConfigFile merges over the config it parses.
|
|
13
|
+
//
|
|
14
|
+
// TypeScript-Go's own command line passes exactly this beside the parsed
|
|
15
|
+
// CompilerOptions. The struct alone cannot carry an option the command line
|
|
16
|
+
// resets: `--declarationDir null` leaves the field at its zero value, which the
|
|
17
|
+
// merge reads as "not given", so the config's own value survives. The raw map
|
|
18
|
+
// records the explicit null, and the merge honors it.
|
|
19
|
+
//
|
|
20
|
+
// Returns nil for a nil command line or an absent, nil or differently typed
|
|
21
|
+
// raw value. A present ordered map is wrapped even when it contains no options.
|
|
22
|
+
// The wrapper retains the original ordered map; callers must not mutate it
|
|
23
|
+
// while configuration merging reads the command line.
|
|
24
|
+
//
|
|
25
|
+
// @evidence contracts/common.md#principled-implementation The compilerOptions wrapper preserves the parsed ordered raw values, including explicit null, because config merging distinguishes an absent option from a supplied zero-like value.
|
|
26
|
+
// @evidence contracts/common.md#clear-and-simple-design Nil and raw-shape checks precede one ordered-map wrapper, keeping representation adaptation separate from the config parser that owns merging.
|
|
27
|
+
// @evidence contracts/common.md#prohibited-implementation-shortcuts compilerOptions is the compiler's merge-envelope key, not a consumer exception; the adapter preserves upstream parsing rather than patching fields or inventing reset values.
|
|
28
|
+
// @evidence contracts/common.md#meaningful-documentation Native prose explains explicit-null reset semantics, nil results and shared-map ownership, keeping the example and ownership note in distinct paragraphs.
|
|
29
|
+
// @evidence contracts/performance.md#bound-retention-and-release-resources The returned one-entry wrapper retains the original ordered map and its reachable raw option values for its consumers; it adds no deep copy, handle or historical cache. Callers own reference release and must avoid concurrent mutation during merging; this adapter imposes no bound on the supplied raw graph.
|
|
30
|
+
// @evidence contracts/performance.md#efficient-algorithms Nil and type checks precede one insertion into a fresh ordered map, taking constant wrapper work and space independent of raw option count; the raw values are referenced without traversal or copying, while downstream config merging owns its separate option scan.
|
|
31
|
+
// @evidenceExclude contracts/performance.md#reuse-equivalent-work This representation adapter owns no shared producer, request cache or validity coordinator; upstream parsing produces the supplied raw map and callers determine when that same command line remains valid for merging.
|
|
32
|
+
// @evidenceExclude contracts/portability.md#os-neutral-implementation CommandLineRawOptions computes from its arguments only; it opens no file, builds no path and calls no platform or process API.
|
|
33
|
+
func CommandLineRawOptions(commandLine *tsoptions.ParsedCommandLine) *collections.OrderedMap[string, any] {
|
|
34
|
+
if commandLine == nil {
|
|
35
|
+
return nil
|
|
36
|
+
}
|
|
37
|
+
raw, ok := commandLine.Raw.(*collections.OrderedMap[string, any])
|
|
38
|
+
if !ok || raw == nil {
|
|
39
|
+
return nil
|
|
40
|
+
}
|
|
41
|
+
wrapped := &collections.OrderedMap[string, any]{}
|
|
42
|
+
wrapped.Set("compilerOptions", raw)
|
|
43
|
+
return wrapped
|
|
44
|
+
}
|
|
@@ -2,4 +2,13 @@ module github.com/microsoft/typescript-go/shim/tsoptions
|
|
|
2
2
|
|
|
3
3
|
go 1.26
|
|
4
4
|
|
|
5
|
-
require github.com/microsoft/typescript-go v0.0.0-
|
|
5
|
+
require github.com/microsoft/typescript-go v0.0.0-20260610182825-7fc57c005063
|
|
6
|
+
|
|
7
|
+
require (
|
|
8
|
+
github.com/go-json-experiment/json v0.0.0-20260601182631-00ed12fed2a6 // 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.21.0 // indirect
|
|
12
|
+
golang.org/x/sys v0.46.0 // indirect
|
|
13
|
+
golang.org/x/text v0.38.0 // indirect
|
|
14
|
+
)
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
github.com/go-json-experiment/json v0.0.0-20260601182631-00ed12fed2a6 h1:nxP4pPoyqOAgX8lYDFCfl3DyKeXErCvSvhcyzwGV9CE=
|
|
2
|
+
github.com/go-json-experiment/json v0.0.0-20260601182631-00ed12fed2a6/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-20260610182825-7fc57c005063 h1:UUVrjTrD+7nkVvkJTjxwA5+SaZ5n1uyAffm2zX2gn+o=
|
|
8
|
+
github.com/microsoft/typescript-go v0.0.0-20260610182825-7fc57c005063/go.mod h1:s3yhRRZ7nzSZaiKicku520Tj9Mvewr9y2UtrvpwOmDE=
|
|
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.21.0 h1:HLII4xRRTtCRkxYp4HNFF0Js/Og6q2i++KXbg0gHCwM=
|
|
16
|
+
golang.org/x/sync v0.21.0/go.mod h1:9xrNwdLfx4jkKbNva9FpL6vEN7evnE43NNNJQ2LF3+0=
|
|
17
|
+
golang.org/x/sys v0.46.0 h1:noSf2Fq6F8DBgS+LysIkx7rIExoNHJsxOAtPp4rthXw=
|
|
18
|
+
golang.org/x/sys v0.46.0/go.mod h1:4GL1E5IUh+htKOUEOaiffhrAeqysfVGipDYzABqnCmw=
|
|
19
|
+
golang.org/x/text v0.38.0 h1:sXmwo9DwP3OK9EZ7PqAdaooSGozfl/3a6/xJcbzPRhE=
|
|
20
|
+
golang.org/x/text v0.38.0/go.mod h1:YXZt3QhHUKYT53r2lLKFIVi6Ao1jdzrTR/KQ09qyxF4=
|
|
21
|
+
gotest.tools/v3 v3.5.2 h1:7koQfIKdy+I8UTetycgUqXWSDwpgv193Ka+qRsmBY8Q=
|
|
22
|
+
gotest.tools/v3 v3.5.2/go.mod h1:LtdLGcnqToBH83WByAAi/wiwSFCArdFIUV/xxN4pcjA=
|
|
@@ -133,7 +133,7 @@ func ParseConfigFileTextToJson(fileName string, path tspath.Path, jsonText strin
|
|
|
133
133
|
type ParseConfigHost = tsoptions.ParseConfigHost
|
|
134
134
|
|
|
135
135
|
//go:linkname ParseExtendedConfig github.com/microsoft/typescript-go/internal/tsoptions.ParseExtendedConfig
|
|
136
|
-
func ParseExtendedConfig(fileName string, path tspath.Path, resolutionStack []
|
|
136
|
+
func ParseExtendedConfig(fileName string, path tspath.Path, resolutionStack []tspath.Path, host tsoptions.ParseConfigHost, extendedConfigCache tsoptions.ExtendedConfigCache) *tsoptions.ExtendedConfigCacheEntry
|
|
137
137
|
|
|
138
138
|
//go:linkname ParseJsonConfigFileContent github.com/microsoft/typescript-go/internal/tsoptions.ParseJsonConfigFileContent
|
|
139
139
|
func ParseJsonConfigFileContent(json any, host tsoptions.ParseConfigHost, basePath string, existingOptions *core.CompilerOptions, configFileName string, resolutionStack []tspath.Path, extraFileExtensions []tsoptions.FileExtensionInfo, extendedConfigCache tsoptions.ExtendedConfigCache) *tsoptions.ParsedCommandLine
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
|
|
2
|
+
github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU=
|
|
3
|
+
github.com/microsoft/typescript-go v0.0.0-20260610182825-7fc57c005063 h1:UUVrjTrD+7nkVvkJTjxwA5+SaZ5n1uyAffm2zX2gn+o=
|
|
4
|
+
github.com/microsoft/typescript-go v0.0.0-20260610182825-7fc57c005063/go.mod h1:s3yhRRZ7nzSZaiKicku520Tj9Mvewr9y2UtrvpwOmDE=
|
|
5
|
+
gotest.tools/v3 v3.5.2 h1:7koQfIKdy+I8UTetycgUqXWSDwpgv193Ka+qRsmBY8Q=
|
|
6
|
+
gotest.tools/v3 v3.5.2/go.mod h1:LtdLGcnqToBH83WByAAi/wiwSFCArdFIUV/xxN4pcjA=
|
|
@@ -2,4 +2,6 @@ module github.com/microsoft/typescript-go/shim/vfs/cachedvfs
|
|
|
2
2
|
|
|
3
3
|
go 1.26
|
|
4
4
|
|
|
5
|
-
require github.com/microsoft/typescript-go v0.0.0-
|
|
5
|
+
require github.com/microsoft/typescript-go v0.0.0-20260610182825-7fc57c005063
|
|
6
|
+
|
|
7
|
+
require github.com/go-json-experiment/json v0.0.0-20260601182631-00ed12fed2a6 // indirect
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
github.com/go-json-experiment/json v0.0.0-20260601182631-00ed12fed2a6 h1:nxP4pPoyqOAgX8lYDFCfl3DyKeXErCvSvhcyzwGV9CE=
|
|
2
|
+
github.com/go-json-experiment/json v0.0.0-20260601182631-00ed12fed2a6/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/microsoft/typescript-go v0.0.0-20260610182825-7fc57c005063 h1:UUVrjTrD+7nkVvkJTjxwA5+SaZ5n1uyAffm2zX2gn+o=
|
|
6
|
+
github.com/microsoft/typescript-go v0.0.0-20260610182825-7fc57c005063/go.mod h1:s3yhRRZ7nzSZaiKicku520Tj9Mvewr9y2UtrvpwOmDE=
|
|
7
|
+
golang.org/x/sync v0.21.0 h1:HLII4xRRTtCRkxYp4HNFF0Js/Og6q2i++KXbg0gHCwM=
|
|
8
|
+
golang.org/x/sync v0.21.0/go.mod h1:9xrNwdLfx4jkKbNva9FpL6vEN7evnE43NNNJQ2LF3+0=
|
|
9
|
+
golang.org/x/sys v0.46.0 h1:noSf2Fq6F8DBgS+LysIkx7rIExoNHJsxOAtPp4rthXw=
|
|
10
|
+
golang.org/x/sys v0.46.0/go.mod h1:4GL1E5IUh+htKOUEOaiffhrAeqysfVGipDYzABqnCmw=
|
|
11
|
+
gotest.tools/v3 v3.5.2 h1:7koQfIKdy+I8UTetycgUqXWSDwpgv193Ka+qRsmBY8Q=
|
|
12
|
+
gotest.tools/v3 v3.5.2/go.mod h1:LtdLGcnqToBH83WByAAi/wiwSFCArdFIUV/xxN4pcjA=
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
package vfs
|
|
2
|
+
|
|
3
|
+
import (
|
|
4
|
+
_ "github.com/microsoft/typescript-go/internal/vfs/osvfs"
|
|
5
|
+
_ "unsafe"
|
|
6
|
+
)
|
|
7
|
+
|
|
8
|
+
// DecodeBytes applies the pinned compiler filesystem's BOM and UTF-16 decoding
|
|
9
|
+
// to one immutable byte string. Callers can hash the same captured bytes without
|
|
10
|
+
// another filesystem read; the returned text is suitable for compiler overlays.
|
|
11
|
+
// UTF-8 BOMs are removed; UTF-16 BOMs select byte order and upstream code-unit
|
|
12
|
+
// decoding. Other bytes pass through unchanged without UTF-8 validation. The
|
|
13
|
+
// pinned helper returns ok=true in every branch, so that flag does not certify
|
|
14
|
+
// well-formed encoding or successful file acquisition.
|
|
15
|
+
//
|
|
16
|
+
// @evidence contracts/common.md#principled-implementation The exact pinned filesystem decoder receives the caller's captured byte string so raw hashes and decoded text can share one immutable read.
|
|
17
|
+
// @evidence contracts/common.md#clear-and-simple-design One thin linkname bridge exposes upstream decoding without another filesystem abstraction or copied algorithm.
|
|
18
|
+
// @evidence contracts/common.md#prohibited-implementation-shortcuts This declaration links the actual upstream helper, retaining BOM, endian and malformed-code-unit behavior rather than approximating the decoder locally.
|
|
19
|
+
// @evidence contracts/common.md#meaningful-documentation Native prose states captured-input ownership, BOM selection, unchanged non-BOM bytes and the pinned ok flag's lack of encoding or file-read certification.
|
|
20
|
+
// @evidenceExclude contracts/performance.md#bound-retention-and-release-resources DecodeBytes declares a signature only; the implementation owns acquisition and release of resources.
|
|
21
|
+
// @evidenceExclude contracts/performance.md#efficient-algorithms DecodeBytes declares a signature only; the implementation owns the processing strategy.
|
|
22
|
+
// @evidenceExclude contracts/performance.md#reuse-equivalent-work DecodeBytes declares a signature only; the implementation owns any shared work.
|
|
23
|
+
// @evidenceExclude contracts/portability.md#os-neutral-implementation DecodeBytes is a signature without a body here; path and platform behavior belongs to the implementation that supplies it.
|
|
24
|
+
//
|
|
25
|
+
//go:linkname DecodeBytes github.com/microsoft/typescript-go/internal/vfs/internal.decodeBytes
|
|
26
|
+
func DecodeBytes(s string) (contents string, ok bool)
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
package vfs
|
|
2
|
+
|
|
3
|
+
import "testing"
|
|
4
|
+
|
|
5
|
+
// TestDecodeBytesUsesCompilerFilesystemSemantics verifies the real pinned
|
|
6
|
+
// decoder bridge against literal byte/text pairs, including endian, empty,
|
|
7
|
+
// truncated-code-unit and surrogate boundaries.
|
|
8
|
+
//
|
|
9
|
+
// The bridge must call upstream code so filesystem and overlay decoding cannot
|
|
10
|
+
// drift. No copied decoder or filesystem substitute runs in this test.
|
|
11
|
+
//
|
|
12
|
+
// 1. Supply literal byte inputs for each decoding boundary.
|
|
13
|
+
// 2. Call the linked compiler decoder in the test process.
|
|
14
|
+
// 3. Collect each independently specified Unicode text and success assertion.
|
|
15
|
+
//
|
|
16
|
+
// @evidence contracts/testing.md#behavioral-verification DecodeBytes links and calls the real pinned compiler filesystem decoder for every byte/text pair.
|
|
17
|
+
// @evidence contracts/testing.md#independent-expectations Literal bytes and Unicode text specify expected decoding independently of the linked implementation.
|
|
18
|
+
// @evidence contracts/testing.md#distinguishing-cases Plain newline spellings contrast UTF-8 BOM, both UTF-16 byte orders, empty inputs, odd trailing bytes, paired and unpaired surrogates.
|
|
19
|
+
// @evidence contracts/testing.md#execution-ownership TestDecodeBytesUsesCompilerFilesystemSemantics is a Go source unit executed through the actual shim module dependency from the owning compiler module, without an installed consumer or native product process.
|
|
20
|
+
func TestDecodeBytesUsesCompilerFilesystemSemantics(t *testing.T) {
|
|
21
|
+
for _, input := range []struct{ name, bytes, text string }{
|
|
22
|
+
{"plain", "a\r\nb\u2028c\u2029", "a\r\nb\u2028c\u2029"},
|
|
23
|
+
{"utf8", "\xef\xbb\xbfhello", "hello"},
|
|
24
|
+
{"little", "\xff\xfeh\x00i\x00", "hi"},
|
|
25
|
+
{"big", "\xfe\xff\x00h\x00i", "hi"},
|
|
26
|
+
{"empty", "", ""},
|
|
27
|
+
{"empty little", "\xff\xfe", ""},
|
|
28
|
+
{"empty big", "\xfe\xff", ""},
|
|
29
|
+
{"odd little", "\xff\xfea\x00b", "a"},
|
|
30
|
+
{"odd big", "\xfe\xff\x00ab", "a"},
|
|
31
|
+
{"surrogate little", "\xff\xfe\x3d\xd8\x00\xde", "\U0001f600"},
|
|
32
|
+
{"surrogate big", "\xfe\xff\xd8\x3d\xde\x00", "\U0001f600"},
|
|
33
|
+
{"unpaired little", "\xff\xfe\x3d\xd8", "\ufffd"},
|
|
34
|
+
} {
|
|
35
|
+
t.Run(input.name, func(t *testing.T) {
|
|
36
|
+
text, ok := DecodeBytes(input.bytes)
|
|
37
|
+
if !ok || text != input.text {
|
|
38
|
+
t.Errorf("DecodeBytes = %q, %v; want %q, true", text, ok, input.text)
|
|
39
|
+
}
|
|
40
|
+
})
|
|
41
|
+
}
|
|
42
|
+
}
|
|
@@ -2,4 +2,10 @@ module github.com/microsoft/typescript-go/shim/vfs
|
|
|
2
2
|
|
|
3
3
|
go 1.26
|
|
4
4
|
|
|
5
|
-
require github.com/microsoft/typescript-go v0.0.0-
|
|
5
|
+
require github.com/microsoft/typescript-go v0.0.0-20260610182825-7fc57c005063
|
|
6
|
+
|
|
7
|
+
require (
|
|
8
|
+
github.com/go-json-experiment/json v0.0.0-20260601182631-00ed12fed2a6 // indirect
|
|
9
|
+
golang.org/x/sync v0.21.0 // indirect
|
|
10
|
+
golang.org/x/sys v0.46.0 // indirect
|
|
11
|
+
)
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
github.com/go-json-experiment/json v0.0.0-20260601182631-00ed12fed2a6 h1:nxP4pPoyqOAgX8lYDFCfl3DyKeXErCvSvhcyzwGV9CE=
|
|
2
|
+
github.com/go-json-experiment/json v0.0.0-20260601182631-00ed12fed2a6/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/microsoft/typescript-go v0.0.0-20260610182825-7fc57c005063 h1:UUVrjTrD+7nkVvkJTjxwA5+SaZ5n1uyAffm2zX2gn+o=
|
|
6
|
+
github.com/microsoft/typescript-go v0.0.0-20260610182825-7fc57c005063/go.mod h1:s3yhRRZ7nzSZaiKicku520Tj9Mvewr9y2UtrvpwOmDE=
|
|
7
|
+
golang.org/x/sync v0.21.0 h1:HLII4xRRTtCRkxYp4HNFF0Js/Og6q2i++KXbg0gHCwM=
|
|
8
|
+
golang.org/x/sync v0.21.0/go.mod h1:9xrNwdLfx4jkKbNva9FpL6vEN7evnE43NNNJQ2LF3+0=
|
|
9
|
+
golang.org/x/sys v0.46.0 h1:noSf2Fq6F8DBgS+LysIkx7rIExoNHJsxOAtPp4rthXw=
|
|
10
|
+
golang.org/x/sys v0.46.0/go.mod h1:4GL1E5IUh+htKOUEOaiffhrAeqysfVGipDYzABqnCmw=
|
|
11
|
+
gotest.tools/v3 v3.5.2 h1:7koQfIKdy+I8UTetycgUqXWSDwpgv193Ka+qRsmBY8Q=
|
|
12
|
+
gotest.tools/v3 v3.5.2/go.mod h1:LtdLGcnqToBH83WByAAi/wiwSFCArdFIUV/xxN4pcjA=
|
|
@@ -2,4 +2,10 @@ module github.com/microsoft/typescript-go/shim/vfs/osvfs
|
|
|
2
2
|
|
|
3
3
|
go 1.26
|
|
4
4
|
|
|
5
|
-
require github.com/microsoft/typescript-go v0.0.0-
|
|
5
|
+
require github.com/microsoft/typescript-go v0.0.0-20260610182825-7fc57c005063
|
|
6
|
+
|
|
7
|
+
require (
|
|
8
|
+
github.com/go-json-experiment/json v0.0.0-20260601182631-00ed12fed2a6 // indirect
|
|
9
|
+
golang.org/x/sync v0.21.0 // indirect
|
|
10
|
+
golang.org/x/sys v0.46.0 // indirect
|
|
11
|
+
)
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
github.com/go-json-experiment/json v0.0.0-20260601182631-00ed12fed2a6 h1:nxP4pPoyqOAgX8lYDFCfl3DyKeXErCvSvhcyzwGV9CE=
|
|
2
|
+
github.com/go-json-experiment/json v0.0.0-20260601182631-00ed12fed2a6/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/microsoft/typescript-go v0.0.0-20260610182825-7fc57c005063 h1:UUVrjTrD+7nkVvkJTjxwA5+SaZ5n1uyAffm2zX2gn+o=
|
|
6
|
+
github.com/microsoft/typescript-go v0.0.0-20260610182825-7fc57c005063/go.mod h1:s3yhRRZ7nzSZaiKicku520Tj9Mvewr9y2UtrvpwOmDE=
|
|
7
|
+
golang.org/x/sync v0.21.0 h1:HLII4xRRTtCRkxYp4HNFF0Js/Og6q2i++KXbg0gHCwM=
|
|
8
|
+
golang.org/x/sync v0.21.0/go.mod h1:9xrNwdLfx4jkKbNva9FpL6vEN7evnE43NNNJQ2LF3+0=
|
|
9
|
+
golang.org/x/sys v0.46.0 h1:noSf2Fq6F8DBgS+LysIkx7rIExoNHJsxOAtPp4rthXw=
|
|
10
|
+
golang.org/x/sys v0.46.0/go.mod h1:4GL1E5IUh+htKOUEOaiffhrAeqysfVGipDYzABqnCmw=
|
|
11
|
+
gotest.tools/v3 v3.5.2 h1:7koQfIKdy+I8UTetycgUqXWSDwpgv193Ka+qRsmBY8Q=
|
|
12
|
+
gotest.tools/v3 v3.5.2/go.mod h1:LtdLGcnqToBH83WByAAi/wiwSFCArdFIUV/xxN4pcjA=
|
|
@@ -5,12 +5,34 @@
|
|
|
5
5
|
* same API name in the same Worker would install a new readiness bridge that
|
|
6
6
|
* the stale runtime could invoke, so `bootTtsc` terminally rejects later boots
|
|
7
7
|
* until the caller terminates the Worker.
|
|
8
|
+
*
|
|
9
|
+
* @evidence contracts/common.md#principled-implementation
|
|
10
|
+
* An Error subclass carries a stable machine-readable code, API identity and
|
|
11
|
+
* original cause so the owner can replace the Worker rather than parse prose.
|
|
12
|
+
* @evidence contracts/common.md#clear-and-simple-design
|
|
13
|
+
* One error identity groups the terminal discriminator, API slot and cause;
|
|
14
|
+
* Worker replacement remains the caller's responsibility, outside this value.
|
|
15
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts
|
|
16
|
+
* The error exposes the runtime's terminal ownership limit rather than hiding
|
|
17
|
+
* it under retries that would reuse a stale global readiness bridge.
|
|
18
|
+
* @evidence contracts/common.md#meaningful-documentation
|
|
19
|
+
* Separate JSDoc paragraphs explain the failure and why replacement is required;
|
|
20
|
+
* members explain identity and cause, following the documentation skill.
|
|
21
|
+
* @evidenceExclude contracts/performance.md#bound-retention-and-release-resources BootTtscWorkerTerminationError retains only its own fields and cause and is released with the rejection.
|
|
22
|
+
* @evidenceExclude contracts/performance.md#efficient-algorithms BootTtscWorkerTerminationError builds one message string and chooses no processing strategy.
|
|
23
|
+
* @evidenceExclude contracts/performance.md#reuse-equivalent-work BootTtscWorkerTerminationError is an error value and coordinates no shared or repeated computation.
|
|
8
24
|
*/
|
|
9
25
|
export class BootTtscWorkerTerminationError extends Error {
|
|
26
|
+
/** Stable discriminator for Worker-replacement handling. */
|
|
10
27
|
public static readonly CODE = "TTSC_WASM_WORKER_TERMINATION_REQUIRED";
|
|
11
28
|
|
|
29
|
+
/** Global API bridge whose Go runtime has already started. */
|
|
12
30
|
public readonly apiName: string;
|
|
31
|
+
|
|
32
|
+
/** Instance discriminator shared with the class constant. */
|
|
13
33
|
public readonly code = BootTtscWorkerTerminationError.CODE;
|
|
34
|
+
|
|
35
|
+
/** Original cancellation, startup or runtime failure. */
|
|
14
36
|
public override readonly cause: unknown;
|
|
15
37
|
|
|
16
38
|
public constructor(apiName: string, cause: unknown) {
|